@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
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{R as i,j as n,f as pe,r as Nt,c as pc}from"./vendor-react-BUCujlKS.js";import{bZ as gc,a as qe,h as Hs,au as bo,dD as vc,a3 as wc,a8 as xc,a9 as bc,F as yc,aa as jc,H as Oe,u as Ge,g7 as Cc,R as _n,M as Sc,f2 as $a,ai as Nc,g4 as Fc,P as Ec,e as kc,g5 as Rc,bs as Tc,g6 as Mc}from"./index-DxNa7xYB.js";import{f as Xe,a8 as qs,B,h as X,e0 as Pc,e2 as Vc,dR as Dc,I as P,e1 as Ac,d$ as Lc,m0 as zc,m1 as Kr,fd as Ic,cv as Jr,km as Oc,m2 as Bc,m3 as $c,b1 as Ks,jg as _c,da as Uc,N as Wc,_ as Hc,bJ as Kc,ay as Gc,L as Dr,aA as qc,dh as Xc,t as q,fD as _a,l6 as Yc,iX as Jc,l as Ua,aY as Ar,d6 as _s,dT as Zc,b as Qc,m4 as Us,cy as eu,aZ as Lr,m5 as zr,d7 as Wa,d8 as Ha,m6 as Ka,m7 as Ga,m8 as tu,m9 as su,ma as nu,dX as ru,mb as iu,jS as au,mc as ou,md as qa,me as lu,b_ as yo,bZ as jo,bW as Co,bU as So,bV as No,cz as Fo,aR as Gr,aS as qr,aU as Xr,bH as Ws,cA as Ir,b2 as Ln,fG as Or,at as Kt,au as Gt,av as qt,cw as cu,cx as uu,bI as Eo,g as Wn,db as du,dc as fu,dd as mu,de as hu,df as pu,dg as gu}from"./useAppFontEffects-DGlvOqP_.js";import{a as vu,c as Xa,s as wu,P as ps,C as xu}from"./shikiHighlight-DHDx-6eM.js";import{a as ko,E as bu,i as Ro,S as To,R as Yr,l as yu}from"./vendor-codemirror-state-Dek9sMtw.js";import{E as Qe,k as Zr,f as ju,j as Cu,m as Su,g as Nu,V as Fu,G as Eu}from"./vendor-codemirror-view-1e0FQ6Wn.js";import{v as ku,A as Ru,B as Tu,C as Mu}from"./vendor-codemirror-language-DufXoQvE.js";import{a as Pu,u as zn,b as Vu,c as Du,G as Au}from"./fileTreeStatus-D438yi8M.js";import{V as Lu,J as zu,F as Iu}from"./JsonTreeView-DRKHZfsn.js";import{ensurePierreThemeRegistered as Ya,getResolvedShikiTheme as Ou}from"./appThemeRegistry-B9gkFq9i.js";import{V as Bu,W as $u}from"./Virtualizer-CGNyscoc.js";import{K as _u,bx as Uu,by as Wu,bw as Hu}from"./runtimeEndpointReset-CZ5aafpl.js";import{V as Ku}from"./Virtualizer-C0IsclZn.js";import{D as Gu}from"./vendor-react-drawio-Ct3Q0DsD.js";import{e as qu,h as Xu}from"./vendor-codemirror-search-CvXM_pZg.js";import{a as Yu,b as Ju}from"./vendor-codemirror-autocomplete-BSHQHbKu.js";import{p as Zu}from"./parseDiffFromFile-BUgn-T9p.js";import{o as Qu,s as ed}from"./vendor-zod-CxRSdNoV.js";import{u as td,n as sd}from"./useInlineCommentController-kMN4Wg_D.js";import{b as nd,F as Ja}from"./FilePreviewCommentMenu-D4kLseHj.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-BmFcUkbQ.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-base-ui-Det7U81h.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-CvuLsk7D.js";import"./vendor-tanstack-virtual-core-DPaNcJcT.js";import"./vendor-framer-motion-DxDVhOLc.js";import"./vendor-motion-dom-HXPOMxb7.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-codemirror-commands-C4G_dPWe.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DbpEcZM0.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-BzgckzmB.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Cayfb29q.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-BQWerHsJ.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-D2TEBIvZ.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CtwSWKtX.js";import"./vendor-codemirror-lang-python-jAMtYiA9.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-capacitor-core-B4EWRrHz.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-legendapp-list-DViGR95I.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-replit-codemirror-vim-BlJRn-cW.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./computeVirtualFileMetrics-C2WM6JC2.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-_ZS5UYRj.js";import"./textMateThemeFromAppTheme-DlsTphbY.js";import"./space-apply-DM_2pRW7.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-diff-C3JhlQdm.js";const rd=(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)},Za=(r,e)=>{const t=r.state.doc.lineAt(e.main.head);return{lineNumber:t.number,character:e.main.head-t.from+1,selection:e}},Qa=(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:ko.cursor(f),effects:Qe.scrollIntoView(f,{y:"center"})})};function id({open:r,onOpenChange:e,view:t,variant:a="overlay"}){const{t:m}=Xe(),[f,p]=i.useState(""),h=i.useRef(null),v=i.useRef(!1),b=i.useRef(null),u=i.useRef(null),x=i.useMemo(()=>rd(f,t),[f,t]);i.useEffect(()=>{!r||!t||(v.current=!1,h.current=Za(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:y}=h.current;t.dispatch({selection:y,effects:Qe.scrollIntoView(y.main.from,{y:"center"})});return}Qa(t,x,h.current.character)}},[x,r,t]);const C=i.useCallback(()=>{if(!t||v.current||!h.current)return;const{selection:y}=h.current;t.dispatch({selection:y,effects:Qe.scrollIntoView(y.main.from,{y:"center"})})},[t]),N=i.useRef(r);i.useEffect(()=>{N.current&&!r&&C(),N.current=r},[r,C]);const R=i.useCallback(y=>{y||C(),e(y)},[e,C]),j=i.useCallback(()=>{!t||x===null||!h.current||(v.current=!0,Qa(t,x,h.current.character),e(!1),t.focus())},[x,e,t]);i.useEffect(()=>{if(!r)return;const y=M=>{const T=b.current,D=M.target;!T||!(D instanceof Element)||T.contains(D)||D.closest("[data-go-to-line-toggle]")||R(!1)},l=M=>{M.key==="Escape"&&(M.preventDefault(),R(!1))};return document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",l,!0)}},[R,r,a]);const F=i.useMemo(()=>{if(!t)return m("goToLineDialog.helper.editorUnavailable");if(x===null){const y=h.current??Za(t,t.state.selection);return m("goToLineDialog.helper.currentLineRange",{current:y.lineNumber,max:t.state.doc.lines})}return m("goToLineDialog.helper.goToLine",{line:x})},[x,m,t]);return a==="inline"?r?n.jsxs("div",{ref:b,"data-editor-overlay":!0,className:"ml-1 flex h-6 items-center gap-1",children:[n.jsx(qs,{ref:u,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:y=>p(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),j())},placeholder:m("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),n.jsx(B,{variant:"outline",size:"xs",onClick:j,disabled:!t||x===null,className:"h-6 px-2",children:m("goToLineDialog.actions.go")})]}):null:n.jsx("div",{ref:b,"data-editor-overlay":!0,className:X("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:n.jsxs("div",{className:"min-w-0",children:[n.jsx(qs,{ref:u,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:y=>p(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),j())},placeholder:m("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),n.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:F})]})})}const ad=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"})),od=new Map([["VariableDeclaration","function"],["PropertyDeclaration","method"]]),ld=new Set(["ArrowFunction","FunctionExpression"]),cd=new Set(["VariableDefinition","PropertyDefinition","TypeDefinition","VariableName","DefName","FieldName","BoundIdentifier","TypeIdentifier"]),Mo=/^(?:ATXHeading|SetextHeading)([1-6])$/,Po=(r,e)=>{for(let t=r.firstChild;t;t=t.nextSibling)if(e.has(t.name))return t;return null},ud=r=>{if(Mo.test(r.name))return"heading";const e=ad.get(r.name);if(e)return e;const t=od.get(r.name);return t&&Po(r,ld)?t:null},dd=(r,e)=>r.doc.lineAt(e.from).text.replace(/^\s{0,3}#{1,6}\s*/,"").replace(/\s+#+\s*$/,"").trim(),fd=(r,e=200)=>{const t=ku(r,r.doc.length,e);if(!t)return[];const a=[],m=[];return t.iterate({enter:f=>{const p=ud(f.node);if(!p)return;let h,v;if(p==="heading")h=dd(r,f.node),v=f.from;else{const u=Po(f.node,cd);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 b=p==="heading"?Number(Mo.exec(f.name)?.[1]??1)-1:m.length;a.push({name:h,kind:p,line:r.doc.lineAt(v).number,from:v,depth:b}),p!=="heading"&&m.push(f.to)}}),a},md={function:"braces",method:"braces",class:"box-3",type:"code-box",module:"folder-3",heading:"text"},hd="data-document-symbols-toggle";function eo(r){const e=pe.c(44),{open:t,onOpenChange:a,view:m}=r,{t:f}=Xe(),p=i.useRef(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[0]=h):h=e[0];const[v,b]=i.useState(h),[u,x]=i.useState("");let C,N;e[1]!==t||e[2]!==m?(C=()=>{t&&(x(""),b(m?fd(m.state):[]))},N=[t,m],e[1]=t,e[2]=m,e[3]=C,e[4]=N):(C=e[3],N=e[4]),i.useEffect(C,N);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 j=R;let F,y;e[8]!==a||e[9]!==t?(F=()=>{if(!t)return;const $=U=>{const se=U.target;!(se instanceof Element)||!p.current||p.current.contains(se)||se.closest(`[${hd}]`)||a(!1)};return document.addEventListener("pointerdown",$,!0),()=>document.removeEventListener("pointerdown",$,!0)},y=[a,t],e[8]=a,e[9]=t,e[10]=F,e[11]=y):(F=e[10],y=e[11]),i.useEffect(F,y);let l;e[12]!==j||e[13]!==m?(l=$=>{m&&m.dispatch({selection:ko.cursor($.from),effects:Qe.scrollIntoView($.from,{y:"center"})}),j()},e[12]=j,e[13]=m,e[14]=l):l=e[14];const M=l;if(!t)return null;let T;e[15]!==j?(T=$=>{$.key==="Escape"&&($.preventDefault(),$.stopPropagation(),j())},e[15]=j,e[16]=T):T=e[16];let D;e[17]!==f?(D=f("filesView.symbols.placeholder"),e[17]=f,e[18]=D):D=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]!==D?(k=n.jsx(Pc,{autoFocus:!0,value:u,onValueChange:x,placeholder:D,"aria-label":z}),e[21]=u,e[22]=z,e[23]=D,e[24]=k):k=e[24];let A;e[25]!==v.length||e[26]!==f?(A=v.length===0?f("filesView.symbols.noneInFile"):f("filesView.symbols.noMatches"),e[25]=v.length,e[26]=f,e[27]=A):A=e[27];let O;e[28]!==A?(O=n.jsx(Vc,{className:"px-3 py-4 typography-meta text-muted-foreground",children:A}),e[28]=A,e[29]=O):O=e[29];let E;if(e[30]!==M||e[31]!==v){let $;e[33]!==M?($=U=>n.jsxs(Dc,{value:`${U.name}\0${U.from}`,onSelect:()=>M(U),className:"gap-2",children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",style:{paddingLeft:`${U.depth*12}px`},children:[n.jsx(P,{name:md[U.kind],className:"size-3.5 shrink-0 text-muted-foreground"}),n.jsx("span",{className:"min-w-0 truncate text-foreground",children:U.name})]}),n.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:U.line})]},`${U.from}:${U.name}`),e[33]=M,e[34]=$):$=e[34],E=v.map($),e[30]=M,e[31]=v,e[32]=E}else E=e[32];let L;e[35]!==O||e[36]!==E?(L=n.jsxs(Ac,{className:"max-h-[min(20rem,calc(100vh-16rem))]",children:[O,E]}),e[35]=O,e[36]=E,e[37]=L):L=e[37];let I;e[38]!==k||e[39]!==L?(I=n.jsxs(Lc,{loop:!0,filter:pd,className:"[&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1 [&_[cmdk-item]]:typography-meta",children:[k,L]}),e[38]=k,e[39]=L,e[40]=I):I=e[40];let K;return e[41]!==I||e[42]!==T?(K=n.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]=K):K=e[43],K}function pd(r,e){return r.split("\0")[0].toLowerCase().includes(e.trim().toLowerCase())?1:0}const gd=(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},Kn="data-md-find",Br="data-md-find-current",Vo="rounded-[2px] bg-status-warning/30 text-foreground",vd="rounded-[2px] bg-status-warning/60 text-foreground",wd=120,xd=r=>r instanceof Element&&r.hasAttribute(Kn),bd=r=>r.target instanceof Element&&r.target.hasAttribute(Kn)?!0:[...r.addedNodes].some(e=>xd(e)),Do=r=>{const e=new Set;r.querySelectorAll(`mark[${Kn}]`).forEach(t=>{const a=t.parentNode;a&&(a.replaceChild(document.createTextNode(t.textContent??""),t),e.add(a))}),e.forEach(t=>t.normalize())},yd=(r,e)=>{Do(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=gd(h,t);if(v.length===0)continue;const b=p.parentNode;if(!b)continue;const u=document.createDocumentFragment();let x=0;for(const C of v){C.start>x&&u.appendChild(document.createTextNode(h.slice(x,C.start)));const N=document.createElement("mark");N.setAttribute(Kn,""),N.className=Vo,N.textContent=h.slice(C.start,C.end),u.appendChild(N),a.push(N),x=C.end}x<h.length&&u.appendChild(document.createTextNode(h.slice(x))),b.replaceChild(u,p)}return a},to=({containerRef:r,open:e,onOpenChange:t,focusNonce:a,className:m})=>{const{t:f}=Xe(),[p,h]=i.useState(""),[v,b]=i.useState(0),[u,x]=i.useState(0),C=i.useRef(null),N=i.useRef([]),R=i.useRef(p);R.current=p;const j=i.useRef(null),F=i.useRef(null),y=i.useCallback((k,A=!1)=>{const O=r.current;if(!O){N.current=[],b(0),x(0);return}N.current=yd(O,k);const E=N.current.length;b(E),x(L=>!A||E===0?0:Math.min(L,E-1))},[r]),l=i.useCallback((k,A=!1)=>{j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{j.current=null,y(k,A)},wd)},[y]);i.useEffect(()=>()=>{j.current&&clearTimeout(j.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 A=new MutationObserver(O=>{!R.current.trim()||!O.some(L=>!bd(L))||l(R.current,!0)});return A.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{A.disconnect(),Do(k)}},[r,e,l]),i.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!F.current&&(F.current=k),C.current?.focus()},[e]),i.useEffect(()=>{e&&a>0&&(C.current?.focus(),C.current?.select())},[e,a]),i.useEffect(()=>{const k=r.current;if(!k||(k.querySelectorAll(`mark[${Br}]`).forEach(O=>{O.removeAttribute(Br),O.className=Vo}),v===0))return;const A=N.current[Math.min(Math.max(u,0),v-1)];A&&(A.setAttribute(Br,""),A.className=vd,A.scrollIntoView({block:"nearest"}))},[r,u,v]);const T=i.useCallback(()=>{x(k=>v===0?0:(k+1)%v)},[v]),D=i.useCallback(()=>{x(k=>v===0?0:(k-1+v)%v)},[v]),z=i.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?D():T()):k.key==="Escape"&&(k.preventDefault(),M())},[M,T,D]);return e?n.jsxs("div",{className:X("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:[n.jsx(P,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),n.jsx(qs,{ref:C,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"}),n.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}`:""}),n.jsx(B,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:D,title:f("filesView.preview.find.previousAria"),"aria-label":f("filesView.preview.find.previousAria"),disabled:v===0,children:n.jsx(P,{name:"arrow-up",className:"size-3.5"})}),n.jsx(B,{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:n.jsx(P,{name:"arrow-down",className:"size-3.5"})}),n.jsx(B,{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:n.jsx(P,{name:"close",className:"size-3.5"})})]}):null},jd=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}}},Cd=1,so=({stat:r,showsFailure:e,sawMissing:t,hasUnsavedChanges:a})=>r==="missing"?a?"none":"show-missing":r==="failed"?"none":e?t?"reload":"none":"check-changes",Sd=(r,e)=>e.size!==r.size||e.mtimeMs!==void 0&&r.mtimeMs!==void 0&&Math.abs(e.mtimeMs-r.mtimeMs)>=Cd,Nd=({selectedPath:r,targetPath:e,targetShown:t,targetSettled:a,showsText:m,canEdit:f,textViewMode:p})=>r!==e?t?"wait":"select-target":a?m?p==="edit"?"jump":f?"show-editor":"end":"end":"wait";function no(){const r=pe.c(8),[e]=Nt.useState(Fd),t=Nt.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]),Nt.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 Fd(){return new Ku}const gs=new Map,Ed=100;function In(r){const[e,t]=Nt.useState(null),a=Nt.useRef(null),m=Nt.useRef(null),f=Nt.useRef(null),p=Nt.useCallback((h,v)=>{h&&v instanceof Lu&&(f.current={key:r,file:v,node:h});const b=a.current,u=m.current,x=()=>{a.current===b&&(b?.(),u?.())};v?queueMicrotask(x):x()},[r]);return Nt.useLayoutEffect(()=>{if(!e||!r)return;const h=gs.get(r)??{top:0,left:0};let v=!0;const b=()=>f.current?.key===r?f.current.file:null,u=y=>f.current?.key===r?f.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${y-1}"]`):null,x=()=>{N.disconnect(),R.disconnect()},C=()=>{if(!v)return;const y=b(),l=h.line&&y?.getLinePosition(h.line.number),M=h.line&&u(h.line.number);let T=h.top;h.line&&l&&(T=(y?.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())},N=new ResizeObserver(C),R=new MutationObserver(()=>{if(v){for(const y of e.children)N.observe(y);C()}});N.observe(e);for(const y of e.children)N.observe(y);R.observe(e,{childList:!0,subtree:!0});const j=()=>{if(v)return;const y=b(),l=y?.getNumericScrollAnchor(e.scrollTop-(y.top??0)),M=l&&u(l.lineNumber),T=M?M.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(gs.delete(r),gs.set(r,{top:e.scrollTop,left:e.scrollLeft,line:l&&T!==null&&T>=0&&T<e.clientHeight?{number:l.lineNumber,offset:T}:void 0}),gs.size>Ed){const D=gs.keys().next().value;D!==void 0&&gs.delete(D)}},F=()=>{v=!1,x()};return a.current=C,m.current=j,C(),e.addEventListener("scroll",j,{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",j),e.removeEventListener("wheel",F),e.removeEventListener("touchstart",F),e.removeEventListener("pointerdown",F),e.removeEventListener("keydown",F)}},[r,e]),{setScroller:t,restore:p}}function kd(r){return!(!r.autoSaveEnabled||!r.isDirty||!r.canWrite||r.isSaving||r.fileLoading||r.isNonEditableBinary||r.wouldEmptyFile||!r.selectedFilePath||r.loadedFilePath!==r.selectedFilePath)}function Rd(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 Ao=2e5,Td=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
|
|
2
|
+
`:`
|
|
3
|
+
`},Lo=r=>r.replace(/\r\n/g,`
|
|
4
|
+
`).replace(/\r/g,`
|
|
5
|
+
`),Md=r=>({content:Lo(r),lineEnding:Td(r)}),Pd=(r,e)=>{const t=Lo(r);return e===`\r
|
|
6
|
+
`?t.replace(/\n/g,`\r
|
|
7
|
+
`):t},Vd=(r,e)=>e??(r.length>Ao?"view":"edit"),Dd=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)}`},Ad='<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 ro(){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 Ld=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),[b,u]=i.useState(ro),x=i.useRef(e),C=i.useRef(e);C.current!==e&&(C.current=e,x.current=e,p.current=e);const N=i.useRef(b);N.current!==b&&(N.current=b,x.current=p.current);const R=i.useRef(null);i.useEffect(()=>{const y=()=>u(ro());y();const l=new MutationObserver(y);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>l.disconnect()},[]),i.useEffect(()=>{const y=setTimeout(()=>{R.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(y)},[]),i.useImperativeHandle(f,()=>({getXml:()=>p.current}));const j=i.useCallback(()=>{!e&&!v.current&&(v.current=!0,setTimeout(()=>{h.current?.template({})},500))},[e]),F=i.useCallback(y=>{p.current=y.xml,m?.(y.xml)},[m]);return n.jsx("div",{ref:R,className:X("h-full w-full",a),children:n.jsx(Gu,{ref:h,xml:x.current||Ad,autosave:!0,urlParameters:{ui:t?"simple":b?"dark":"kennedy",spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:j,onAutoSave:F},b?"dark":"light")})}),$r={ok:!0,snapshot:null},zd=r=>r.hasCanvas&&r.viewMode==="preview"&&r.previewReady&&r.mountable,io=r=>r.slice(r.replace(/\\/g,"/").lastIndexOf("/")+1)||r,Id=i.forwardRef(function(e,t){const{guestId:a,editorId:m,title:f,contentKind:p,path:h,content:v,readOnly:b}=e,{t:u}=Xe(),x=i.useRef(e);x.current=e;const C=i.useCallback(y=>zc(y,{onChange:l=>{l.edited&&x.current.onEdit(),x.current.onDirtyChange(l.dirty)},onSave:()=>x.current.onSaveRequest(),onUnsupported:()=>x.current.onUnsupported()}),[]),[N,R]=i.useState(()=>p==="text"?C({path:h,name:io(h),readOnly:b,encoding:"text",content:v}):null),[j]=i.useState(()=>({contentKind:p,path:h,readOnly:b}));i.useEffect(()=>{if(j.contentKind!=="binary")return;let y=!1;return x.current.loadBytes().then(l=>{if(!y){if(l.byteLength>Kr){x.current.onTooLarge();return}R(C({path:j.path,name:io(j.path),readOnly:j.readOnly,encoding:"binary",bytes:l}))}},()=>{y||x.current.onLoadFailed()}),()=>{y=!0}},[j,C]),i.useImperativeHandle(t,()=>({getContent:async y=>{const l={ok:!1,message:u("filesView.fileEditor.snapshotFailed",{editor:f})};if(!N)return l;try{const M=await N.requestSnapshot(y);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:y=>{N?.markSaved(y),x.current.onDirtyChange(!1)}}),[N,p,u,f]);const F=i.useMemo(()=>N?{editorId:m,channel:N}:null,[N,m]);return F?n.jsx(Ic,{mode:gc(a),surface:"file",fileEditor:F}):n.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:u("common.loading")})}),Od=r=>r.slice(r.replace(/\\/g,"/").lastIndexOf("/")+1),zo=(r,e)=>{const t=Od(e);if(!t)return null;for(const a of r)if(!(!a.fileEditors?.length||!Oc(a))){for(const m of a.fileEditors)if(m.match.some(f=>Bc(t,f)))return{guestId:a.id,editor:m}}return null},Bd=r=>{const e=pe.c(3),t=Jr($d);let a;return e[0]!==r||e[1]!==t?(a=r?zo(t,r):null,e[0]=r,e[1]=t,e[2]=a):a=e[2],a};function $d(r){return r.guests}const _d=Tu.filter(r=>r.mac!==void 0),Ud=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},Wd=()=>[Ru({markerDOM:Ud}),Zr.of(_d),Qe.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"}})],Hd=()=>[Mu(),Yu(),Zr.of(Ju)],Kd=({vimMode:r})=>[bu.allowMultipleSelections.of(!0),ju(),Cu(),Su(),r?[]:Zr.of([{key:"Mod-d",run:qu,preventDefault:!0}])],Gd=300,qd=1e6,Xd=(r,e)=>{const t=new Map;if(r===e)return t;const a=Zu({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 On extends Eu{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 Yd={added:new On("added"),modified:new On("modified"),deleted:new On("deleted"),deletedAbove:new On("deletedAbove")},Jd=(r,e)=>{const t=new yu;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,Yd[m])}return t.finish()},Gn=To.define(),Io=To.define(),Qr=Ro.define({create:()=>null,update(r,e){for(const t of e.effects)if(t.is(Gn))return t.value;return r}}),ao=Ro.define({create:()=>Yr.empty,update(r,e){for(const t of e.effects){if(t.is(Io))return t.value;if(t.is(Gn)&&t.value===null)return Yr.empty}return e.docChanged?r.map(e.changes):r}}),Zd=Fu.fromClass(class{constructor(r){this.view=r}timer=null;update(r){r.transactions.some(t=>t.effects.some(a=>a.is(Gn)))?this.schedule(0):r.docChanged&&this.schedule(Gd)}schedule(r){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=null;const{state:e}=this.view,t=e.field(Qr),a=e.doc.toString(),m=t!==null&&Math.max(t.length,a.length)>qd,f=t===null||m?Yr.empty:Jd(e.doc,Xd(t,a));this.view.dispatch({effects:Io.of(f)})},r)}destroy(){this.timer&&clearTimeout(this.timer)}}),Qd=r=>[Qr,ao,Zd,Nu({class:"cm-git-gutter",markers:e=>e.state.field(ao)}),Qe.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"}})],ef=(r,e)=>{r.state.field(Qr,!1)!==void 0&&r.dispatch({effects:Gn.of(e)})},Xs=r=>{const e=pe.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 C=t.filter(tf);if(C.length===0&&!a){v=null;break e}e[7]!==m?(h=X("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=C.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 b;e[9]!==f||e[10]!==p?(b=n.jsx("div",{className:f,children:p}),e[9]=f,e[10]=p,e[11]=b):b=e[11];let u;e[12]!==a?(u=a?n.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]!==b||e[16]!==u?(x=n.jsxs("div",{className:h,children:[b,u]}),e[14]=h,e[15]=b,e[16]=u,e[17]=x):x=e[17],x};function tf(r){return r.length>0}const Ys=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""},sf=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)}`},Oo=r=>r&&r.width>0&&r.height>0?`${r.width} × ${r.height}`:"",nf=r=>{const e=pe.c(28),{name:t,path:a,sizeBytes:m,download:f}=r,{t:p}=Xe();let h,v,b,u,x,C,N;if(e[0]!==t||e[1]!==a||e[2]!==m||e[3]!==p){const y=$c(a).toUpperCase();C="flex h-full min-h-0 flex-col",N=n.jsx(Xs,{items:[y,Ys(m)]}),b="flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",e[11]!==a?(u=n.jsx(Ks,{filePath:a,className:"size-10"}),e[11]=a,e[12]=u):u=e[12],e[13]!==t?(x=n.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=y?p("filesView.artifact.binary.descriptionWithType",{extension:y}):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]=b,e[7]=u,e[8]=x,e[9]=C,e[10]=N}else h=e[4],v=e[5],b=e[6],u=e[7],x=e[8],C=e[9],N=e[10];let R;e[15]!==h||e[16]!==v?(R=n.jsx("div",{className:h,children:v}),e[15]=h,e[16]=v,e[17]=R):R=e[17];let j;e[18]!==f||e[19]!==b||e[20]!==u||e[21]!==x||e[22]!==R?(j=n.jsxs("div",{className:b,children:[u,x,R,f]}),e[18]=f,e[19]=b,e[20]=u,e[21]=x,e[22]=R,e[23]=j):j=e[23];let F;return e[24]!==C||e[25]!==N||e[26]!==j?(F=n.jsxs("div",{className:C,children:[N,j]}),e[24]=C,e[25]=N,e[26]=j,e[27]=F):F=e[27],F},rf=[48,32,24,18,14],af=["ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz",`0123456789 .,;:!?&@#%()[]{}<>+-=/\\*"'`];let _r=0;const of=r=>{const e=pe.c(16),{src:t,name:a,sizeBytes:m}=r,{t:f}=Xe(),[p,h]=i.useState("loading"),[v]=i.useState(lf);let b,u;e[0]!==v||e[1]!==t?(b=()=>{let j=!1;h("loading");const F=new FontFace(v,`url("${t.replace(/"/g,"%22")}")`);return document.fonts.add(F),F.load().then(()=>{j||h("ready")}).catch(()=>{j||h("failed")}),()=>{j=!0,document.fonts.delete(F)}},u=[v,t],e[0]=v,e[1]=t,e[2]=b,e[3]=u):(b=e[2],u=e[3]),i.useEffect(b,u);let x;e[4]!==m?(x=Ys(m),e[4]=m,e[5]=x):x=e[5];let C;e[6]!==a||e[7]!==x?(C=n.jsx(Xs,{items:[a,x]}),e[6]=a,e[7]=x,e[8]=C):C=e[8];let N;e[9]!==v||e[10]!==p||e[11]!==f?(N=p==="failed"?n.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"?n.jsxs("div",{className:"flex items-center gap-2 p-3 typography-ui text-muted-foreground",children:[n.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}),f("common.loading")]}):n.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",style:{fontFamily:`"${v}"`},children:n.jsxs("div",{className:"flex flex-col gap-4",children:[rf.map(j=>n.jsxs("div",{className:"flex items-baseline gap-3",children:[n.jsx("span",{className:"w-8 shrink-0 text-right font-sans typography-meta text-muted-foreground",children:j}),n.jsx("span",{className:"min-w-0 break-words leading-tight text-foreground",style:{fontSize:`${j}px`},children:f("filesView.artifact.font.sample")})]},j)),n.jsx("div",{className:"mt-2 flex flex-col gap-1 border-t border-border/40 pt-4 text-foreground",style:{fontSize:"20px"},children:af.map(cf)})]})}),e[9]=v,e[10]=p,e[11]=f,e[12]=N):N=e[12];let R;return e[13]!==C||e[14]!==N?(R=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[C,N]}),e[13]=C,e[14]=N,e[15]=R):R=e[15],R};function lf(){return _r=_r+1,`oc-font-preview-${_r}`}function cf(r){return n.jsx("div",{className:"break-all leading-relaxed",children:r},r)}const Hn=12,Bo=.1,$o=16,oo=[.1,.25,.5,.75,1,1.5,2,3,4,6,8,12,16],uf=16,lo=30,df=(r,e)=>{const t=e.width-Hn*2,a=e.height-Hn*2;return r.width<=0||r.height<=0||t<=0||a<=0?1:Math.min(1,t/r.width,a/r.height)},ff=(r,e)=>Math.min($o,Math.max(Math.min(Bo,e),r)),co=(r,e)=>e===1?oo.find(t=>t>r*1.001)??$o:[...oo].reverse().find(t=>t<r*.999)??Bo,mf=(r,e)=>{const t=e===1?r*uf:r,a=Math.max(-lo,Math.min(lo,t));return Math.exp(-a/100)},uo=(r,e)=>Math.hypot(r.clientX-e.clientX,r.clientY-e.clientY),hf=({src:r,name:e,sizeBytes:t})=>{const{t:a}=Xe(),[m,f]=i.useState(null),[p,h]=i.useState(null),[v,b]=i.useState(null),[u,x]=i.useState(!1),C=i.useRef(null),N=i.useRef(null),R=i.useRef(null),j=i.useRef(null);i.useEffect(()=>{h(null),f(null)},[r]),i.useEffect(()=>{const E=C.current;if(!E)return;const L=new ResizeObserver(()=>{b({width:E.clientWidth,height:E.clientHeight})});return L.observe(E),()=>L.disconnect()},[]);const F=p&&v?df(p,v):1,y=m??F,l=m!==null&&p!==null&&v!==null&&(p.width*m+Hn*2>v.width||p.height*m+Hn*2>v.height),M=(E,L,I)=>{const K=N.current;if(!K||!p)return;const $=K.getBoundingClientRect(),U=K.clientWidth/p.width;U<=0||(R.current={imageX:(L-$.left-K.clientLeft)/U,imageY:(I-$.top-K.clientTop)/U,clientX:L,clientY:I},pc.flushSync(()=>f(ff(E,F))))},T=E=>{const L=C.current;if(!L)return;const I=L.getBoundingClientRect();M(E,I.left+I.width/2,I.top+I.height/2)};i.useLayoutEffect(()=>{const E=R.current,L=C.current,I=N.current;if(R.current=null,!E||!L||!I||m===null||I.naturalWidth<=0)return;const K=I.getBoundingClientRect(),$=I.clientWidth/I.naturalWidth;L.scrollLeft+=K.left+I.clientLeft+E.imageX*$-E.clientX,L.scrollTop+=K.top+I.clientTop+E.imageY*$-E.clientY},[m]);const D=i.useRef({zoomTo:M,shownScale:y});D.current={zoomTo:M,shownScale:y},i.useEffect(()=>{const E=C.current;if(!E)return;let L=0,I=null,K=null;const $=W=>{if(!W.ctrlKey&&!W.metaKey)return;W.preventDefault();const te=D.current;te.zoomTo(te.shownScale*mf(W.deltaY,W.deltaMode),W.clientX,W.clientY)},U=W=>{L=W.touches.length,W.touches.length===2&&(I={distance:uo(W.touches[0],W.touches[1]),scale:D.current.shownScale})},se=W=>{if(!I||W.touches.length!==2||I.distance<=0)return;W.preventDefault();const[te,Ye]=[W.touches[0],W.touches[1]];D.current.zoomTo(I.scale*(uo(te,Ye)/I.distance),(te.clientX+Ye.clientX)/2,(te.clientY+Ye.clientY)/2)},ie=W=>{L=W.touches.length,W.touches.length<2&&(I=null)},ge=W=>{W.preventDefault(),K=L>0?null:D.current.shownScale},ne=W=>{W.preventDefault(),K!==null&&D.current.zoomTo(K*W.scale,W.clientX,W.clientY)},fe=W=>{W.preventDefault(),K=null};return E.addEventListener("wheel",$,{passive:!1}),E.addEventListener("touchstart",U,{passive:!0}),E.addEventListener("touchmove",se,{passive:!1}),E.addEventListener("touchend",ie,{passive:!0}),E.addEventListener("touchcancel",ie,{passive:!0}),E.addEventListener("gesturestart",ge),E.addEventListener("gesturechange",ne),E.addEventListener("gestureend",fe),()=>{E.removeEventListener("wheel",$),E.removeEventListener("touchstart",U),E.removeEventListener("touchmove",se),E.removeEventListener("touchend",ie),E.removeEventListener("touchcancel",ie),E.removeEventListener("gesturestart",ge),E.removeEventListener("gesturechange",ne),E.removeEventListener("gestureend",fe)}},[]);const z=E=>{if(!l||E.pointerType!=="mouse"||E.button!==0)return;const L=E.currentTarget,I=L.getBoundingClientRect();E.clientX-I.left>=L.clientWidth||E.clientY-I.top>=L.clientHeight||(E.preventDefault(),L.setPointerCapture(E.pointerId),j.current={pointerId:E.pointerId,x:E.clientX,y:E.clientY,left:L.scrollLeft,top:L.scrollTop},x(!0))},k=E=>{const L=j.current;!L||L.pointerId!==E.pointerId||(E.currentTarget.scrollLeft=L.left-(E.clientX-L.x),E.currentTarget.scrollTop=L.top-(E.clientY-L.y))},A=E=>{j.current?.pointerId===E.pointerId&&(j.current=null,x(!1))},O=E=>{if(m===null){M(1,E.clientX,E.clientY);return}f(null)};return n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n.jsx(Xs,{items:[Oo(p),Ys(t)],actions:n.jsxs(n.Fragment,{children:[n.jsx(B,{variant:"ghost",size:"xs","aria-label":a("filesView.artifact.image.zoomOut"),title:a("filesView.artifact.image.zoomOut"),disabled:!p,onClick:()=>T(co(y,-1)),children:n.jsx(P,{name:"subtract",className:"size-3.5"})}),n.jsx(B,{variant:"ghost",size:"xs",className:"min-w-11 tabular-nums",title:a("filesView.artifact.image.actualTitle"),disabled:!p,onClick:()=>T(1),children:`${Math.round(y*100)}%`}),n.jsx(B,{variant:"ghost",size:"xs","aria-label":a("filesView.artifact.image.zoomIn"),title:a("filesView.artifact.image.zoomIn"),disabled:!p,onClick:()=>T(co(y,1)),children:n.jsx(P,{name:"add",className:"size-3.5"})}),n.jsx(B,{variant:"chip",size:"xs","aria-pressed":m===null,title:a("filesView.artifact.image.fitTitle"),onClick:()=>f(null),children:a("filesView.artifact.image.fit")})]})}),n.jsx("div",{ref:C,className:X("min-h-0 flex-1 overflow-auto",l&&(u?"cursor-grabbing":"cursor-grab")),onPointerDown:z,onPointerMove:k,onPointerUp:A,onPointerCancel:A,onDoubleClick:O,children:n.jsx("div",{className:X("flex items-center justify-center p-3",m===null?"h-full w-full":"min-h-full min-w-full w-max"),children:n.jsx("img",{ref:N,src:r,alt:e,draggable:!1,onLoad:E=>{const L=E.currentTarget;h({width:L.naturalWidth,height:L.naturalHeight})},style:m!==null&&p?{width:p.width*m,height:p.height*m}:void 0,className:X("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)})})]})},pf=r=>{const e=pe.c(24),{kind:t,src:a,name:m,sizeBytes:f,download:p}=r,{t:h}=Xe(),[v,b]=i.useState(null),[u,x]=i.useState(null),[C,N]=i.useState(!1);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{b(null),x(null),N(!1)},e[0]=R):R=e[0];let j;e[1]!==a?(j=[a],e[1]=a,e[2]=j):j=e[2],i.useEffect(R,j);let F;e[3]===Symbol.for("react.memo_cache_sentinel")?(F=A=>{const O=A.currentTarget;b(Number.isFinite(O.duration)?O.duration:null),O instanceof HTMLVideoElement&&x({width:O.videoWidth,height:O.videoHeight})},e[3]=F):F=e[3];const y=F;let l;e[4]!==v?(l=sf(v),e[4]=v,e[5]=l):l=e[5];let M;e[6]!==u?(M=Oo(u),e[6]=u,e[7]=M):M=e[7];let T;e[8]!==f?(T=Ys(f),e[8]=f,e[9]=T):T=e[9];let D;e[10]!==l||e[11]!==M||e[12]!==T?(D=n.jsx(Xs,{items:[l,M,T]}),e[10]=l,e[11]=M,e[12]=T,e[13]=D):D=e[13];let z;e[14]!==p||e[15]!==C||e[16]!==t||e[17]!==m||e[18]!==a||e[19]!==h?(z=C?n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:h("filesView.artifact.media.unplayable")}),p]}):t==="video"?n.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-[var(--surface-background)] p-3",children:n.jsx("video",{src:a,controls:!0,playsInline:!0,preload:"metadata",title:m,className:"max-h-full max-w-full rounded-md",onLoadedMetadata:y,onError:()=>N(!0)},a)}):n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 p-6",children:[n.jsx("div",{className:"typography-ui-label truncate text-foreground",children:m}),n.jsx("audio",{src:a,controls:!0,preload:"metadata",title:m,className:"w-full max-w-lg",onLoadedMetadata:y,onError:()=>N(!0)},a)]}),e[14]=p,e[15]=C,e[16]=t,e[17]=m,e[18]=a,e[19]=h,e[20]=z):z=e[20];let k;return e[21]!==D||e[22]!==z?(k=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[D,z]}),e[21]=D,e[22]=z,e[23]=k):k=e[23],k},gf=2e3,vf=r=>r.toLowerCase().endsWith(".tsv")?" ":",",wf=(r,e,t=gf)=>{const a=[];let m=0,f="",p=[],h=!1,v=!1;const b=()=>{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 j=0;j<u.length;j+=1){const F=u[j];if(h){F==='"'?u[j+1]==='"'?(f+='"',j+=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===`
|
|
8
|
+
`||F==="\r"){F==="\r"&&u[j+1]===`
|
|
9
|
+
`&&(j+=1),b();continue}f+=F}(f.length>0||p.length>0||h)&&b();const x=a[0]??[],C=a.slice(1),N=a.reduce((j,F)=>Math.max(j,F.length),0),R=Math.max(0,m-1);return{header:x,rows:C,totalRows:R,columnCount:N,truncated:C.length<R}},xf=r=>{const e=pe.c(29),{path:t,content:a,sizeBytes:m}=r,{t:f}=Xe();let p;e[0]!==a||e[1]!==t?(p=wf(a,vf(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 b=v;let u;e[7]!==h.columnCount?(u=Array.from({length:h.columnCount},bf),e[7]=h.columnCount,e[8]=u):u=e[8];const x=u;let C;e[9]!==f||e[10]!==h.rows||e[11]!==h.totalRows||e[12]!==h.truncated?(C=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]=C):C=e[13];let N;e[14]!==m?(N=Ys(m),e[14]=m,e[15]=N):N=e[15];let R;e[16]!==b||e[17]!==C||e[18]!==N?(R=n.jsx(Xs,{items:[b,C,N]}),e[16]=b,e[17]=C,e[18]=N,e[19]=R):R=e[19];let j;e[20]!==x||e[21]!==f||e[22]!==h.columnCount||e[23]!==h.header||e[24]!==h.rows?(j=h.columnCount===0?n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:f("filesView.artifact.table.empty")}):n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsxs("table",{className:"min-w-full border-separate border-spacing-0 font-mono typography-meta",children:[n.jsx("thead",{className:"sticky top-0 z-10 bg-[var(--surface-subtle)]",children:n.jsx("tr",{children:x.map(y=>n.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[y]??""},y))})}),n.jsx("tbody",{children:h.rows.map((y,l)=>n.jsx("tr",{className:"odd:bg-[var(--surface-background)] even:bg-[var(--surface-subtle)]/40",children:x.map(M=>n.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:y[M]??"",children:y[M]??""},M))},l))})]})}),e[20]=x,e[21]=f,e[22]=h.columnCount,e[23]=h.header,e[24]=h.rows,e[25]=j):j=e[25];let F;return e[26]!==R||e[27]!==j?(F=n.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[R,j]}),e[26]=R,e[27]=j,e[28]=F):F=e[28],F};function bf(r,e){return e}const vs="data-oc-local-asset",yf=25*1024*1024,Bn=r=>{const e=r.trim();return!e||e.startsWith("#")||e.startsWith("//")?!1:!/^[a-z][a-z\d+.-]*:/i.test(e)},jf=r=>r.split(/[?#]/,1)[0]??"",Cf=r=>r.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s+/g,"-"),Sf=(r,e)=>{const t=_o(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||Cf(a.textContent??"")===t)return a.scrollIntoView({block:"start"}),!0;return!1},_o=r=>{try{return decodeURIComponent(r)}catch{return r}},Nf=r=>r.split(",").flatMap(e=>{const[t,...a]=e.trim().split(/\s+/);return t?[{url:t,descriptor:a.join(" ")}]:[]}),Ur="data-oc-media",Ff=/\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)/gi,fo=(r,e)=>{for(const t of Array.from(r.querySelectorAll("picture > source[media]"))){const a=t.getAttribute(Ur)??t.getAttribute("media")??"",m=a.replace(Ff,(f,p)=>p.toLowerCase()===e?"(min-width: 0px)":"(max-width: -1px)");m!==a&&(t.getAttribute(Ur)!==a&&t.setAttribute(Ur,a),t.getAttribute("media")!==m&&t.setAttribute("media",m))}},mo=({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&&fo(r,f)},[f,r,m]),i.useEffect(()=>{if(!m||!r||!e)return;const v=e.slice(0,e.lastIndexOf("/")+1)||"/",b=l=>_c(v,_o(jf(l))),u=l=>({path:l,allowOutsideWorkspace:t&&Uc(l,t)?void 0:"true",directory:t||void 0});let x=!1;const C=qe(),N=new Map,R=l=>{const M=N.get(l);if(M)return M;const T=(async()=>{const D=await Hs("/api/fs/raw",{query:u(l),signal:AbortSignal.timeout(3e4)});if(!D.ok)throw new Error(`Image read failed (${D.status})`);const z=await D.blob();if(z.size>yf)throw new Error("Image too large for preview");if(x||qe()!==C)throw new Error("Preview closed");return URL.createObjectURL(z)})();return N.set(l,T),T.catch(()=>N.delete(l)),T},j=()=>{for(const l of Array.from(r.querySelectorAll("img[src]"))){const M=l.getAttribute("src")??"";if(!Bn(M))continue;const T=b(M);l.setAttribute(vs,T),R(T).then(D=>{x||l.getAttribute(vs)!==T||l.getAttribute("src")!==D&&(l.src=D)}).catch(()=>{x||l.removeAttribute(vs)})}for(const l of Array.from(r.querySelectorAll("source[srcset], img[srcset]"))){const M=Nf(l.getAttribute("srcset")??"");if(!M.some(z=>Bn(z.url)))continue;const T=M.map(z=>({...z,path:Bn(z.url)?b(z.url):null})),D=T.map(z=>z.path??z.url).join(",");l.setAttribute(vs,D),Promise.all(T.map(async({url:z,descriptor:k,path:A})=>{const O=A?await R(A):z;return k?`${O} ${k}`:O})).then(z=>{if(x||l.getAttribute(vs)!==D)return;const k=z.join(", ");l.getAttribute("srcset")!==k&&l.setAttribute("srcset",k)}).catch(()=>{x||l.removeAttribute(vs)})}fo(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 D=T.getAttribute("href")??"";if(D.startsWith("#")){l.preventDefault(),l.stopPropagation(),Sf(r,D);return}Bn(D)&&(l.preventDefault(),l.stopPropagation(),p.current(b(D)))};j();const y=new MutationObserver(j);return y.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src","srcset","media"]}),r.addEventListener("click",F,!0),()=>{x=!0,y.disconnect(),r.removeEventListener("click",F,!0);for(const l of N.values())l.then(M=>URL.revokeObjectURL(M)).catch(()=>{})}},[r,m,e,t])},Ef=Qu({grant:ed().min(1)}),kf=async(r,e,t=Hs)=>{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=Ef.safeParse(await a.json().catch(()=>null));if(!m.success)throw new Error("Preview grant response was invalid");return m.data.grant},Rf=(r,e)=>{const t=e.split("/").map(m=>encodeURIComponent(m)).join("/"),a=t.startsWith("/")?t:`/${t}`;return bo().api(`/api/fs/preview/${encodeURIComponent(r)}${a}`)},Tf=(r,e,t)=>{const a=pe.c(8),m=kf;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??"",b=r?.directory??"",u=r?.revision??"";let x,C;return a[1]!==b||a[2]!==e||a[3]!==m||a[4]!==v||a[5]!==u?(x=()=>{if(!v){h({status:"idle"});return}const N=new AbortController;return h({status:"loading"}),(async()=>{try{const j=await m({path:v,directory:b,revision:u},N.signal);N.signal.aborted||h({status:"ready",url:Rf(j,v)})}catch(j){const F=j;if(N.signal.aborted)return;h({status:"error",message:F instanceof Error?F.message:e})}})(),()=>N.abort()},C=[v,b,u,e,m],a[1]=b,a[2]=e,a[3]=m,a[4]=v,a[5]=u,a[6]=x,a[7]=C):(x=a[6],C=a[7]),i.useEffect(x,C),p},bs=[];let ho=!1;const po=()=>{vc()&&wc("desktop_set_close_tab_target",{active:bs.length>0})},Mf=()=>{bs[bs.length-1]?.()},Pf=r=>(ho||(window.addEventListener("openchamber:close-tab",Mf),ho=!0),bs.push(r),po(),()=>{const e=bs.lastIndexOf(r);e>=0&&bs.splice(e,1),po()}),Vf=r=>{const e=Z(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},Df=r=>{const e=pe.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=n.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=X("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 b;return e[6]!==h?(b=n.jsx("span",{className:v,children:h}),e[6]=h,e[7]=b):b=e[7],b},Af=r=>r.slice().sort((e,t)=>e.type!==t.type?e.type==="directory"?-1:1:e.name.localeCompare(t.name)),Z=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},Lf=r=>r.startsWith("/")||r.startsWith("//")||/^[A-Za-z]:\//.test(r),xs=r=>/^[A-Za-z]:\//.test(r)?r.toLowerCase():r,Gs=(r,e)=>{const t=Z(e),a=Z(r);if(!t||!a)return!1;const m=xs(t),f=xs(a);return f===m||f.startsWith(`${m}/`)},go=(r,e)=>{const t=Z(e),a=Z(r);if(!Gs(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},Un=(r,e)=>{if(!e)return"";const t=Z(e);if(!r||!Gs(t,r))return t;const a=t.slice(r.length);return a.startsWith("/")?a.slice(1):a},zf=new Set(["node_modules"]),If=r=>{const e=pe.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=n.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:m}}),e[1]=m,e[2]=f):f=e[2],f},vo=r=>{const e=pe.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 C=a.current,N=m.current;if(!C||!N)return;const R=()=>{p(N.scrollWidth>C.clientWidth+1)};R();const j=new ResizeObserver(R);return j.observe(C),j.observe(N),()=>{j.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 b;e[3]!==t?(b=n.jsx("span",{ref:m,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:t}),e[3]=t,e[4]=b):b=e[4];let u;e[5]!==t||e[6]!==f?(u=f?n.jsxs("span",{className:"open-file-name-marquee-track",children:[n.jsx("span",{className:"open-file-name-marquee-item",children:t}),n.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:t})]}):n.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]!==b||e[9]!==u?(x=n.jsxs("span",{ref:a,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[b,u]}),e[8]=b,e[9]=u,e[10]=x):x=e[10],x},Of=r=>zf.has(r),Bf=r=>{const e=Z(r);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},$f=r=>{const t=(r instanceof Error?r.message:String(r??"")).toLowerCase();return t.includes("is a directory")||t.includes("eisdir")},_f=2e5,Uo=(r,e)=>n.jsx(Ks,{filePath:r,extension:e}),Wr=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"},Hr=r=>!!(r&&zo(Jr.getState().guests,r)),wo=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},$n=r=>{if(!r)return!1;const e=r.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Uf=r=>{const e=pe.c(78),{node:t,root:a,isExpanded:m,isActive:f,isMobile:p,isBrowserClient:h,alwaysShowActions:v,status:b,badge:u,permissions:x,downloadFile:C,contextMenuPath:N,setContextMenuPath:R,rightClickMenuPath:j,setRightClickMenuPath:F,onSelect:y,onToggle:l,onRevealPath:M,onOpenDialog:T,canUpload:D,onPickFiles:z}=r,{t:k}=Xe(),A=t.type==="directory",{canRename:O,canCreateFile:E,canCreateFolder:L,canDelete:I,canReveal:K}=x,$=!A&&!!C,U=K&&!h,se=A&&D,ie=O||E||L||se||I||$||U;let ge;e[0]!==ie||e[1]!==t.path||e[2]!==F?(ge=$e=>{ie&&($e?.preventDefault(),F(t.path))},e[0]=ie,e[1]=t.path,e[2]=F,e[3]=ge):ge=e[3];const ne=ge;let fe;e[4]!==A||e[5]!==t||e[6]!==y||e[7]!==l?(fe=()=>{A?l(t.path):y(t)},e[4]=A,e[5]=t,e[6]=y,e[7]=l,e[8]=fe):fe=e[8];const W=fe;let te;e[9]!==t.path||e[10]!==R||e[11]!==F?(te=$e=>{$e.stopPropagation(),F(null),R(t.path)},e[9]=t.path,e[10]=R,e[11]=F,e[12]=te):te=e[12];const Ye=te;let Dt;e[13]!==E||e[14]!==L||e[15]!==I||e[16]!==O||e[17]!==U||e[18]!==se||e[19]!==C||e[20]!==h||e[21]!==A||e[22]!==t||e[23]!==T||e[24]!==z||e[25]!==M||e[26]!==a||e[27]!==k?(Dt=$e=>{const{Item:me,Separator:js}=$e;return n.jsxs(n.Fragment,{children:[O&&n.jsxs(me,{onClick:Y=>{Y.stopPropagation(),T("rename",t)},children:[n.jsx(P,{name:"edit",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.rename")]}),n.jsxs(me,{onClick:Y=>{Y.stopPropagation(),Wn(t.path).then(it=>{if(it.ok){q.success(k("sidebarFilesTree.toast.pathCopied"));return}q.error(k("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(P,{name:"file-copy",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.copyPath")]}),n.jsxs(me,{onClick:Y=>{Y.stopPropagation();const it=Un(a,t.path)||t.path;Wn(it).then(pt=>{if(pt.ok){q.success(k("filesView.toast.relativePathCopied"));return}q.error(k("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(P,{name:"file-copy-2",className:"mr-2 size-4"})," ",k("filesView.tree.menu.copyRelativePath")]}),!A&&C&&n.jsxs(me,{onClick:Y=>{Y.stopPropagation(),C(t.path).catch(it=>{console.error("Download failed:",it),q.error(k("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(P,{name:"download",className:"mr-2 size-4"})," ",k(h?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),U&&n.jsxs(me,{onClick:Y=>{Y.stopPropagation(),M(t.path)},children:[n.jsx(P,{name:"folder-received",className:"mr-2 size-4"})," ",k(hu())]}),!A&&U&&Ec()&&n.jsxs(me,{onClick:Y=>{Y.stopPropagation(),_n(t.path).then(it=>{it||q.error(k("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(P,{name:"external-link",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.openInDefaultApp")]}),A&&(E||L||se)&&n.jsxs(n.Fragment,{children:[n.jsx(js,{}),E&&n.jsxs(me,{onClick:Y=>{Y.stopPropagation(),T("createFile",t)},children:[n.jsx(P,{name:"file-add",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.newFile")]}),L&&n.jsxs(me,{onClick:Y=>{Y.stopPropagation(),T("createFolder",t)},children:[n.jsx(P,{name:"folder-add",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.newFolder")]}),se&&n.jsxs(me,{onClick:Y=>{Y.stopPropagation(),z(t.path)},children:[n.jsx(P,{name:"upload-2",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.uploadFiles")]})]}),I&&n.jsxs(n.Fragment,{children:[n.jsx(js,{}),n.jsxs(me,{onClick:Y=>{Y.stopPropagation(),T("delete",t)},className:"text-destructive focus:text-destructive",children:[n.jsx(P,{name:"delete-bin",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.delete")]})]})]})},e[13]=E,e[14]=L,e[15]=I,e[16]=O,e[17]=U,e[18]=se,e[19]=C,e[20]=h,e[21]=A,e[22]=t,e[23]=T,e[24]=z,e[25]=M,e[26]=a,e[27]=k,e[28]=Dt):Dt=e[28];const mt=Dt,At=j===t.path;let ht;e[29]!==t.path||e[30]!==F?(ht=$e=>F($e?t.path:null),e[29]=t.path,e[30]=F,e[31]=ht):ht=e[31];const ys=p?void 0:ne;let re;e[32]!==ys?(re=n.jsx("div",{className:"group relative flex items-center",onContextMenu:ys}),e[32]=ys,e[33]=re):re=e[33];const et=p?void 0:ne,Ft=f?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let tt;e[34]!==Ft?(tt=X("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",Ft),e[34]=Ft,e[35]=tt):tt=e[35];let Ce;e[36]!==A||e[37]!==m||e[38]!==t.extension||e[39]!==t.path?(Ce=A?m?n.jsx(P,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):n.jsx(P,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Uo(t.path,t.extension),e[36]=A,e[37]=m,e[38]=t.extension,e[39]=t.path,e[40]=Ce):Ce=e[40];let st;e[41]!==t.name||e[42]!==t.path?(st=n.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]=st):st=e[43];let Se;e[44]!==A||e[45]!==b?(Se=!A&&b&&n.jsx(If,{status:b}),e[44]=A,e[45]=b,e[46]=Se):Se=e[46];let nt;e[47]!==u||e[48]!==A?(nt=A&&u&&n.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[u.modified>0&&n.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",u.modified]}),u.added>0&&n.jsxs("span",{className:"text-[var(--status-success)]",children:["+",u.added]})]}),e[47]=u,e[48]=A,e[49]=nt):nt=e[49];let Ne;e[50]!==W||e[51]!==tt||e[52]!==Ce||e[53]!==st||e[54]!==Se||e[55]!==nt||e[56]!==et?(Ne=n.jsxs("button",{type:"button",onClick:W,onContextMenu:et,className:tt,children:[Ce,st,Se,nt]}),e[50]=W,e[51]=tt,e[52]=Ce,e[53]=st,e[54]=Se,e[55]=nt,e[56]=et,e[57]=Ne):Ne=e[57];let Be;e[58]!==v||e[59]!==N||e[60]!==Ye||e[61]!==ie||e[62]!==p||e[63]!==t.path||e[64]!==mt||e[65]!==R?(Be=ie&&n.jsx("div",{className:X("absolute right-1 top-1/2 -translate-y-1/2",v?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:n.jsxs(Gr,{open:N===t.path,onOpenChange:$e=>R($e?t.path:null),children:[n.jsx(qr,{asChild:!0,children:n.jsx(B,{variant:"ghost",size:"icon",className:"size-6",onClick:Ye,children:n.jsx(P,{name:"more-2-fill",className:"size-4"})})}),n.jsx(Xr,{align:"end",side:"bottom",onCloseAutoFocus:()=>R(null),children:mt({Item:Ws,Separator:Eo})})]})}),e[58]=v,e[59]=N,e[60]=Ye,e[61]=ie,e[62]=p,e[63]=t.path,e[64]=mt,e[65]=R,e[66]=Be):Be=e[66];let Fe;e[67]!==Ne||e[68]!==Be||e[69]!==re?(Fe=n.jsxs(pu,{render:re,children:[Ne,Be]}),e[67]=Ne,e[68]=Be,e[69]=re,e[70]=Fe):Fe=e[70];let Ee;e[71]!==mt?(Ee=n.jsx(du,{className:"min-w-[180px]",children:mt({Item:mu,Separator:fu})}),e[71]=mt,e[72]=Ee):Ee=e[72];let rt;return e[73]!==Fe||e[74]!==Ee||e[75]!==At||e[76]!==ht?(rt=n.jsxs(gu,{open:At,onOpenChange:ht,children:[Fe,Ee]}),e[73]=Fe,e[74]=Ee,e[75]=At,e[76]=ht,e[77]=rt):rt=e[77],rt},Wf=r=>{const e=pe.c(83),{activeDialog:t,dialogData:a,dialogInputValue:m,onDialogInputChange:f,isDialogSubmitting:p,onDialogSubmit:h,onClose:v,inputRef:b}=r,{t:u}=Xe(),x=!!t;let C;e[0]!==v?(C=ne=>!ne&&v(),e[0]=v,e[1]=C):C=e[1];let N;e[2]!==t||e[3]!==u?(N=t==="createFile"&&u("filesView.dialog.createFile.title"),e[2]=t,e[3]=u,e[4]=N):N=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 j;e[8]!==t||e[9]!==u?(j=t==="rename"&&u("filesView.dialog.rename.title"),e[8]=t,e[9]=u,e[10]=j):j=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 y;e[14]!==N||e[15]!==R||e[16]!==j||e[17]!==F?(y=n.jsxs(So,{children:[N,R,j,F]}),e[14]=N,e[15]=R,e[16]=j,e[17]=F,e[18]=y):y=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 D;e[31]!==t||e[32]!==a?.name||e[33]!==u?(D=t==="delete"&&u("filesView.dialog.delete.description",{name:a?.name??""}),e[31]=t,e[32]=a?.name,e[33]=u,e[34]=D):D=e[34];let z;e[35]!==T||e[36]!==D||e[37]!==l||e[38]!==M?(z=n.jsxs(No,{children:[l,M,T,D]}),e[35]=T,e[36]=D,e[37]=l,e[38]=M,e[39]=z):z=e[39];let k;e[40]!==z||e[41]!==y?(k=n.jsxs(Co,{children:[y,z]}),e[40]=z,e[41]=y,e[42]=k):k=e[42];let A;e[43]!==t||e[44]!==m||e[45]!==b||e[46]!==f||e[47]!==h||e[48]!==u?(A=t!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(qs,{value:m,onChange:ne=>f(ne.target.value),placeholder:u(t==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:ne=>{ne.key==="Enter"&&h()},ref:b})}),e[43]=t,e[44]=m,e[45]=b,e[46]=f,e[47]=h,e[48]=u,e[49]=A):A=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=n.jsx(B,{variant:"outline",onClick:v,disabled:p,children:O}),e[52]=p,e[53]=v,e[54]=O,e[55]=E):E=e[55];const L=t==="delete"?"destructive":"default";let I;e[56]!==h?(I=()=>{h()},e[56]=h,e[57]=I):I=e[57];let K;e[58]!==t||e[59]!==m||e[60]!==p?(K=p||t!=="delete"&&!m.trim(),e[58]=t,e[59]=m,e[60]=p,e[61]=K):K=e[61];let $;e[62]!==t||e[63]!==p||e[64]!==u?($=p?n.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]=$):$=e[65];let U;e[66]!==L||e[67]!==I||e[68]!==K||e[69]!==$?(U=n.jsx(B,{variant:L,onClick:I,disabled:K,children:$}),e[66]=L,e[67]=I,e[68]=K,e[69]=$,e[70]=U):U=e[70];let se;e[71]!==E||e[72]!==U?(se=n.jsxs(Fo,{children:[E,U]}),e[71]=E,e[72]=U,e[73]=se):se=e[73];let ie;e[74]!==b||e[75]!==k||e[76]!==A||e[77]!==se?(ie=n.jsxs(jo,{initialFocus:b,children:[k,A,se]}),e[74]=b,e[75]=k,e[76]=A,e[77]=se,e[78]=ie):ie=e[78];let ge;return e[79]!==x||e[80]!==C||e[81]!==ie?(ge=n.jsx(yo,{open:x,onOpenChange:C,children:ie}),e[79]=x,e[80]=C,e[81]=ie,e[82]=ge):ge=e[82],ge},ws=new Map,Hf=100,xo=r=>{const e=pe.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:C}=u.state.selection.main;if(ws.delete(a),ws.set(a,{scroll:u.scrollSnapshot(),anchor:x,head:C}),ws.size>Hf){const N=ws.keys().next().value;N!==void 0&&ws.delete(N)}},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=ws.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 b;return e[10]!==m||e[11]!==v?(b=n.jsx(xu,{...m,onViewReady:v}),e[10]=m,e[11]=v,e[12]=b):b=e[12],b},Kf=(r,e,t)=>{const a=pe.c(8),[m,f]=i.useState(""),[p,h]=i.useState(0);let v,b;a[0]!==r||a[1]!==t||a[2]!==e?(v=()=>{if(!r){f("");return}let x=!1;f("");const C=kc(),N=Rc(C);Tc(C).then(j=>{x||!j||(f(r),e(null))}).catch(j=>{x||(e(j instanceof Error?j.message:t),f(r))});const R=Mc(()=>{x||(f(r),h(Gf),e(null))});return()=>{x=!0,N(),R()}},b=[r,e,t],a[0]=r,a[1]=t,a[2]=e,a[3]=v,a[4]=b):(v=a[3],b=a[4]),i.useEffect(v,b);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},gp=({mode:r="full",visible:e=!0})=>{const{t}=Xe(),{files:a,runtime:m,git:f}=Wc(),{currentTheme:p,availableThemes:h,lightThemeId:v,darkThemeId:b}=Hc(),{isMobile:u,isTablet:x,screenWidth:C}=Kc(),N=xc(m.platform),R=u||x,j=bc(),F=yc(),y=Gc()??"",l=Z(y.trim()),M=u||r==="full",T=M&&e,D=Dr(s=>s.runtimeKey),z=JSON.stringify([D,l]),k=i.useRef(z);k.current=z;const A=JSON.stringify([D,l,j,F]),O=i.useRef(A);O.current=A;const E=r!=="editor-only",L=r==="editor-only"&&!u,I=jc(s=>s.searchFiles),K=qc(T?y:null),[$,U]=i.useState(""),se=Xc($,200),ie=i.useRef(null),[ge,ne]=i.useState(!1),[fe,W]=i.useState(!0),[te,Ye]=i.useState(!1),Dt=i.useCallback(s=>{if(!rr.current){Ye(s);return}const o=gt.current;if(ks.current){mi.current?.().then(c=>{c&>.current===o&&Ye(s)});return}Promise.resolve(Qt.current?.getContent("handoff")??$r).then(c=>{if(gt.current===o){if(!c.ok){q.error(c.message);return}c.snapshot&&"content"in c.snapshot&&(de(c.snapshot.content),ct(!1)),Ye(s)}})},[]),[mt,At]=i.useState(!1),ht=i.useRef(0),ys=i.useCallback(s=>{ht.current=Math.max(0,ht.current+(s?1:-1))},[]),[re,et]=i.useState("edit"),[Ft,tt]=i.useState("edit"),[Ce,st]=i.useState("tree"),[Se,nt]=i.useState("edit"),[Ne,Be]=i.useState("preview"),[Fe,Ee]=i.useState("preview"),[rt,$e]=i.useState("preview"),[me,js]=i.useState("preview"),[Y,it]=i.useState("table"),[pt,ei]=i.useState(null),[Wo,Ho]=i.useState(0),[Ko,Js]=i.useState(0),Zs=i.useRef({}),qn=i.useRef({}),Xn=i.useRef({}),ti=i.useRef({}),si=i.useRef({}),ni=i.useRef({}),Yn=i.useRef({}),Cs=i.useRef({}),Qs=i.useMemo(()=>h.find(s=>s.metadata.id===v)??_a(!1),[h,v]),en=i.useMemo(()=>h.find(s=>s.metadata.id===b)??_a(!0),[h,b]);i.useEffect(()=>{Ya(Qs),Ya(en)},[Qs,en]);const tn=i.useMemo(()=>[],[]),ve=Oe(s=>l?s.byRoot[l]?.openPaths??tn:tn),Lt=Oe(s=>l?s.byRoot[l]?.selectedPath??null:null),at=Oe(s=>l?s.byRoot[l]?.expandedPaths??tn:tn),Go=i.useMemo(()=>new Set(at),[at]),Xt=Oe(s=>s.removeOpenPath),Jn=Oe(s=>s.removeOpenPathsByPrefix),Zn=Oe(s=>s.removeUnselectedOpenPath),ri=Oe(s=>s.removeExpandedPathsByPrefix),we=Oe(s=>s.setSelectedPath),ii=Oe(s=>s.toggleExpandedPath),sn=Oe(s=>s.expandPaths),Yt=i.useCallback(s=>{const o=Z(s),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}},[]),Jt=i.useMemo(()=>ve.map(Yt),[ve,Yt]),Qn=i.useMemo(()=>{if(Lt){const s=xs(Lt);if(ve.some(o=>xs(o)===s))return Lt}return ve[0]??null},[ve,Lt]),d=i.useMemo(()=>Qn?Yt(Qn):null,[Qn,Yt]),ke=d?.path??"",gt=i.useRef(ke);gt.current=ke,i.useEffect(()=>{if(!l||!Lt)return;const s=xs(Lt);ve.some(c=>xs(c)===s)||we(l,ve[0]??null)},[ve,l,Lt,we]);const nn=!!(l&&ke&&!Gs(ke,l)),Ss=i.useMemo(()=>({allowOutsideWorkspace:nn,directory:l||void 0}),[nn,l]),ot=i.useCallback(s=>({allowOutsideWorkspace:!!(l&&!Gs(s,l))}),[l]),er=i.useRef(null),[ai,qo]=i.useState({left:!1,right:!1}),oi=i.useCallback(()=>{const s=er.current;s&&qo({left:s.scrollLeft>2,right:s.scrollLeft+s.clientWidth<s.scrollWidth-2})},[]),li=i.useRef(oi);li.current=oi,i.useEffect(()=>{const s=er.current;if(!s)return;const o=()=>li.current();o(),s.addEventListener("scroll",o,{passive:!0});const c=new ResizeObserver(o);return c.observe(s),()=>{s.removeEventListener("scroll",o),c.disconnect()}},[Jt.length]);const[ci,tr]=i.useState({}),[rn,Ns]=i.useState({}),_e=i.useRef(new Set),Re=i.useMemo(()=>new Pu,[]);i.useEffect(()=>()=>Re.clear(),[Re]);const[ui,an]=i.useState([]),[Xo,on]=i.useState(!1),[H,ue]=i.useState(""),{isPlaying:ln,play:Yo,stop:Jo}=Yc(),[xe,Et]=i.useState(!1),[Je,ce]=i.useState(null),[Zo,Ue]=i.useState(""),[ae,oe]=i.useState(null),[vt,sr]=i.useState(null),cn=i.useRef(null),kt=JSON.stringify([qe(),l,ae]),[Q,de]=i.useState(""),[Zt,nr]=i.useState(!1),[di,Qo]=i.useState(`
|
|
10
|
+
`),el=i.useRef(null),lt=i.useRef(null),Ve=i.useRef(null),Rt=i.useRef(""),Fs=i.useRef(""),wt=i.useRef(null),zt=i.useRef(null),fi=i.useRef(null),Qt=i.useRef(null),[Es,ct]=i.useState(!1),rr=i.useRef(!1);rr.current=Es;const ks=i.useRef(!1),mi=i.useRef(null),De=i.useRef(null),ir=i.useRef(""),ar=i.useRef(0),es=i.useRef(0),It=i.useRef(null),[ts,hi]=i.useState(0),[tl,ss]=i.useState("idle"),[sl,un]=i.useState(!1),[nl,pi]=i.useState(!1),[Ot,gi]=i.useState(!1),be=Ge(s=>s.autoSaveEnabled),rl=Ge(s=>s.setAutoSaveEnabled),[or,Rs]=i.useState(!1),ns=i.useRef(null),Ts=i.useRef(null),Ms=i.useRef(!1),Ps=i.useRef(null),Vs=i.useRef(null),ye=i.useRef(null),Ds=i.useRef(null),vi=i.useRef(null),wi=i.useRef(0),[il,lr]=i.useState(0),rs=i.useRef(null),xt=i.useRef({key:"",attempts:0,targetShown:!1});i.useEffect(()=>()=>{rs.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(rs.current),rs.current=null)},[]);const[Bt,cr]=i.useState(null),[$t,al]=i.useState(null),[Tt,xi]=i.useState(""),[ol,ur]=i.useState(!1),[ll,cl]=i.useState(null),[ul,dl]=i.useState(null),[fl,bi]=i.useState(!1),[ml,yi]=i.useState(!1),[hl,dr]=i.useState(!1),[ji,dn]=i.useState(!1),[Ci,fn]=i.useState(!1),[Si,Ni]=i.useState(0),mn=i.useRef(null),hn=i.useCallback(s=>{const o=s?.currentTarget??mn.current;if(!o)return;const c=document.activeElement;c&&c!==document.body&&c!==o&&(Jc(c)||o.contains(c))||o.focus({preventScroll:!0})},[]),pn=i.useRef(null),Fi=!!a.writeFile,Ei=!!a.createDirectory,ki=!!a.rename,Ri=!!a.delete,Ti=!!a.revealPath,Mi=zn(s=>s.availableApps),pl=zn(s=>s.isCacheStale),Pi=zn(s=>s.initialize),gl=zn(s=>s.loadInstalledApps);i.useEffect(()=>{Pi()},[Pi]);const vl=i.useCallback(s=>{a.revealPath&&a.revealPath(s).catch(()=>{q.error(t("sidebarFilesTree.toast.revealFailed"))})},[a,t]),wl=i.useCallback(async s=>{if(!d?.path||await Cc(d.path,s.id,s.appName)||await _n(d.path,s.appName))return;const g=Vf(d.path)||l;g&&await _n(g,s.appName)||q.error(t("filesView.toast.openInAppFailed",{app:s.appName}))},[l,d?.path,t]),fr=i.useCallback((s,o)=>{cr(s),al(o),xi(s==="rename"&&o.name||""),ur(!1)},[]),[J,Ze]=i.useState(null),is=i.useRef(!1),Mt=i.useRef(null),[Vi,as]=i.useState(!1),ut=Ge(s=>s.pendingFileNavigation),gn=Ge(s=>s.setPendingFileNavigation),mr=Ge(s=>s.pendingFileFocusPath),hr=Ge(s=>s.setPendingFileFocusPath),os=Ge(s=>s.fileEditorKeymap),Di=Ge(s=>s.fileEditorVimMappings);i.useEffect(()=>{os==="vim"&&vu(Di)},[os,Di]);const As=Ua(s=>s.settingsDefaultFileViewerPreview),xl=Ua(s=>s.showMessageTTSButtons);i.useEffect(()=>{const s=()=>{is.current=!1,Mt.current=null,as(!1)};return document.addEventListener("mouseup",s),()=>document.removeEventListener("mouseup",s)},[]),i.useEffect(()=>()=>{Ps.current!==null&&window.clearTimeout(Ps.current),Vs.current!==null&&window.clearTimeout(Vs.current)},[]);const bl=i.useCallback((s,o)=>{const c=s.split(`
|
|
11
|
+
`),g=Math.max(1,o.start),w=Math.min(c.length,o.end);return g>w?"":c.slice(g-1,w).join(`
|
|
12
|
+
`)},[]),Ai=i.useRef(null),yl=td({source:"file",fileLabel:d?.path??null,language:d?.path&&Ar(d.path)||"text",getCodeForRange:s=>bl(H,sd(s)),toStoreRange:s=>({startLine:s.start,endLine:s.end}),fromDraftRange:s=>({start:s.startLine,end:s.endLine})}),{drafts:Li,commentText:vn,setCommentText:zi,editingDraftId:wn,setSelection:Ii,saveComment:Oi,cancel:Ls,reset:Bi,startEdit:$i,deleteDraft:_i}=yl;i.useEffect(()=>{Ze(null),Bi(),de(""),nr(!1)},[d?.path,Bi]),i.useEffect(()=>{Ii(J)},[J,Ii]),i.useEffect(()=>{if(!J&&!wn)return;const s=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]")||vn.trim()||(Ze(null),Ls())},o=setTimeout(()=>{document.addEventListener("click",s)},100);return()=>{clearTimeout(o),document.removeEventListener("click",s)}},[Ls,vn,wn,J]),i.useEffect(()=>{if(!u||!J)return;const s=ye.current;if(!s)return;const o=s.state.selection.main;o.empty||s.dispatch({selection:{anchor:o.head}});const c=document.getSelection();c&&!c.isCollapsed&&c.anchorNode&&s.contentDOM.contains(c.anchorNode)&&c.removeAllRanges()},[u,J]);const Ui=i.useCallback((s,o)=>{const c=o??J??void 0;o&&Ze(o),Oi(s,c),Ze(null)},[J,Oi]),Wi=i.useCallback((s,o)=>{const c=[];for(const g of o){if(!(g&&typeof g.name=="string"&&g.name.length>0)||!j&&g.name.startsWith(".")||!F&&Of(g.name))continue;const w=g.name,S=Z(g.path||""),V=S?Lf(S)?S:Z(`${s}/${S}`):Z(`${s}/${w}`),_=g.isDirectory?"directory":"file",le=_==="file"&&w.includes(".")?w.split(".").pop()?.toLowerCase():void 0;c.push({name:w,path:V,type:_,extension:le})}return Af(c)},[F,j]),Te=i.useCallback(async(s,o=!1)=>{if(!T)return;const c=Z(s.trim());if(!c||!o&&_e.current.has(c))return;const g=O.current,w=qe();return Re.run(c,async S=>{const V=()=>S()&&O.current===g&&qe()===w;try{const _=!F,le=a.listDirectory?(await a.listDirectory(c,{respectGitignore:_})).entries:await Sc.listLocalDirectory(c,{respectGitignore:_});if(!V())return;const ee=Wi(c,le);_e.current=new Set(_e.current),_e.current.add(c),Ns(G=>{if(!G[c])return G;const Pe={...G};return delete Pe[c],Pe}),tr(G=>G[c]&&Vu(G[c],ee)?G:{...G,[c]:ee})}catch(_){if(!V())return;const le=_ instanceof Error?_.message:String(_??"");if(le==="Directory not found"&&l&&c!==l){ri(l,c),Ns(ee=>{if(!ee[c])return ee;const G={...ee};return delete G[c],G});return}console.error("Failed to load files directory:",_),Ns(ee=>({...ee,[c]:le}))}},o)},[Re,a,Wi,ri,l,F,T]),xn=i.useCallback(async()=>{l&&(_e.current=new Set,Re.clear(),Ns({}),tr(s=>Object.keys(s).length===0?s:{}),await Te(l))},[Re,Te,l]),Ae=i.useCallback(async s=>{if(!s){await xn();return}const o=Z(s);_e.current=new Set(_e.current),_e.current.delete(o),await Te(o,!0)},[Te,xn]),{canUpload:Hi,uploadingDirectory:jl,pickFiles:Ki,uploadElements:Cl}=_u({root:l,refreshDirectory:Ae}),bn=jl!==null,Gi=i.useRef(""),qi=i.useRef("");i.useEffect(()=>{if(!l)return;const s=A,o=Gi.current!==z,c=qi.current!==s;!o&&!c||(o&&(Gi.current=z,es.current+=1,It.current=null,ue(""),ce(null),Ue(""),oe(null),ne(!1)),c&&(qi.current=s,_e.current=new Set,Re.clear(),Ns({}),tr(g=>Object.keys(g).length===0?g:{}),Te(l)))},[Re,z,Te,l,A]),i.useEffect(()=>{if(!T||!a.listDirectory)return;const s=()=>{if(!document.hidden&&at.length>0)for(const o of at)Re.has(o)||Ae(o)};return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[Re,at,a.listDirectory,Ae,T]);const Xi=i.useRef(!1);i.useEffect(()=>{const s=T&&!Xi.current;if(Xi.current=T,!(!T||!l)&&(Te(l),s))for(const o of at)Re.has(o)||Ae(o)},[Re,at,Te,Ae,l,T]),i.useEffect(()=>{if(!T||!a.listDirectory||at.length===0)return;const s=setInterval(()=>{if(!document.hidden)for(const o of at)Re.has(o)||Ae(o)},8e3);return()=>clearInterval(s)},[Re,at,a.listDirectory,Ae,T]);const Sl=i.useCallback(async s=>{if(s?.preventDefault(),!$t||!Bt)return;ur(!0);const o=()=>{cr(null)},c=w=>{q.error(w)},g=()=>{ur(!1)};if(Bt==="createFile"){if(!Tt.trim()){c(t("sidebarFilesTree.toast.filenameRequired")),g();return}if(!a.writeFile){c(t("sidebarFilesTree.toast.writeNotSupported")),g();return}const w=$t.path,S=w?`${w}/`:"",V=Z(`${S}${Tt.trim()}`);await a.writeFile(V,"").then(async _=>{_.success&&(q.success(t("sidebarFilesTree.toast.fileCreated")),await Ae(w)),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(g);return}if(Bt==="createFolder"){if(!Tt.trim()){c(t("sidebarFilesTree.toast.folderNameRequired")),g();return}const w=$t.path,S=w?`${w}/`:"",V=Z(`${S}${Tt.trim()}`);await a.createDirectory(V).then(async _=>{_.success&&(q.success(t("sidebarFilesTree.toast.folderCreated")),await Ae(w)),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(g);return}if(Bt==="rename"){if(!Tt.trim()){c(t("sidebarFilesTree.toast.nameRequired")),g();return}if(!a.rename){c(t("sidebarFilesTree.toast.renameNotSupported")),g();return}const w=$t.path,S=w.split("/").slice(0,-1).join("/"),V=S?`${S}/`:"",_=Z(`${V}${Tt.trim()}`);await a.rename(w,_).then(async le=>{le.success&&(q.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await Ae(S),l&&Jn(l,w),(d?.path===w||d?.path.startsWith(`${w}/`))&&(l&&we(l,null),ue(""),ce(null),Ue(""),oe(null),u&&ne(!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,S=w.split("/").slice(0,-1).join("/");await a.delete(w).then(async V=>{V.success&&(q.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await Ae(S),l&&Jn(l,w),(d?.path===w||d?.path.startsWith(`${w}/`))&&(l&&we(l,null),ue(""),ce(null),Ue(""),oe(null),u&&ne(!1))),o()}).catch(()=>c(t("sidebarFilesTree.toast.operationFailed"))).finally(g);return}g()},[Bt,$t,Tt,a,Ae,u,Jn,l,d?.path,we,t]);i.useEffect(()=>{if(!y){an([]),on(!1);return}const s=se.trim();if(!s){an([]),on(!1);return}let o=!1;return on(!0),I(y,s,150,{includeHidden:j,respectGitignore:!F,type:"file"}).then(c=>{if(o)return;const w=c.filter(S=>F||!Bf(S.path)).map(S=>({name:S.name,path:Z(S.path),type:"file",extension:S.extension,relativePath:S.relativePath}));an(w)}).catch(()=>{o||an([])}).finally(()=>{o||on(!1)}),()=>{o=!0}},[y,se,I,j,F]);const yn=i.useCallback(async(s,o)=>{const c=ot(s);if(a.readFile)return(await a.readFile(s,{...c,directory:l||void 0,...o})).content??"";const g=new URLSearchParams({path:s});c.allowOutsideWorkspace&&g.set("allowOutsideWorkspace","true"),l&&g.set("directory",l);const w=await Hs(`/api/fs/read?${g.toString()}`,{cache:o?.fresh?"no-store":"default",signal:AbortSignal.timeout(3e4)});if(!w.ok){const S=await w.json().catch(()=>({error:w.statusText}));throw new Error(S.error||t("filesView.error.readFileFailed"))}return w.text()},[a,ot,l,t]),dt=i.useCallback(async s=>{if(a.statFile){const o=ot(s),c=await a.statFile(s,{...o,directory:l||void 0});return{path:c.path,size:c.size,mtimeMs:c.mtimeMs}}return null},[a,ot,l]);i.useEffect(()=>{if(!l||!a.statFile||ve.length===0)return;let s=!1;const o=[...ve];return Promise.all(o.map(async c=>{try{const g=ot(c),w=await a.statFile?.(c,{...g,directory:l||void 0});!s&&w&&!w.isFile&&Zn(l,c)}catch(g){!s&&$a(g)&&Zn(l,c)}})),()=>{s=!0}},[a,ve,Zn,ot,l]);const Le=Q!==H||Es,Pt=i.useCallback((s,o=!0)=>{const{content:c,lineEnding:g}=Md(s);return o&&Hr(gt.current)&&Js(w=>w+1),ir.current=s,ar.current+=1,Qo(g),ue(c),Rt.current=c,Fs.current=c,de(c),c},[]),bt=i.useCallback(async()=>{if(!d||!a.writeFile)return q.error(t("filesView.toast.savingNotSupported")),!1;const s=(_s(d.path)||Ot)&&!ks.current;if(!Rd({selectedFilePath:d.path,loadedFilePath:ae,fileLoading:xe,isDirty:Le,draftContent:Q,fileContent:H,isNonEditableBinary:s}))return s?console.warn(`[saveDraft] refusing to save binary file "${d.path}".`):Q===""&&H!==""&&ae!==d.path&&console.warn(`[saveDraft] refusing to save empty draft for "${d.path}" (${H.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(!Le)return!0;nr(!0);try{const o=Es?Qt.current:null;Es&&!o&&ct(!1);const c=o?await o.getContent("save"):$r;if(!c.ok)return q.error(c.message),!1;const g=c.snapshot;if(g&&"bytes"in g){if(!a.uploadFile)return q.error(t("filesView.toast.savingNotSupported")),!1;if(De.current=null,!(await a.uploadFile(d.path,new Blob([g.bytes]),{overwrite:!0}))?.success)return q.error(t("filesView.toast.writeFileFailed")),!1;Qt.current?.markSaved(g.signature)}else{const w=Pd(g?g.content:Q,di);if(!(await a.writeFile(d.path,w))?.success)return q.error(t("filesView.toast.writeFileFailed")),!1;g?(Pt(w,!1),Qt.current?.markSaved(g.signature)):(ue(Q),ir.current=w,ar.current+=1)}if(l&&Gs(d.path,l)){const w=Un(l,d.path);w&&Zc.requestGitRefresh({directory:l,paths:[w]})}if(l&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(Z(d.path))){const w=Qc.getState().projects.find(S=>Z(S.path)===Z(l));if(w)try{await Uu(w.id)}catch{q.error(t("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return d?.path&&Us(d.path)&&(Rt.current=Q,Fs.current=Q),dt(d.path).then(w=>{w&&(De.current=w)}).catch(()=>{}),!0}catch(o){return q.error(o instanceof Error?o.message:t("filesView.toast.saveFailed")),!1}finally{nr(!1)}},[Pt,Ot,Q,Es,H,xe,a,Le,di,ae,dt,l,d,t]);mi.current=bt,i.useEffect(()=>{be||(ss("idle"),lt.current&&(clearTimeout(lt.current),lt.current=null))},[be]);const jn=1500;i.useEffect(()=>{const s=!!(d&&a.writeFile),o=!!(d?.path&&(_s(d.path)||Ot))&&!ks.current;if(!kd({autoSaveEnabled:be,isDirty:Le,canWrite:s,isSaving:Zt,fileLoading:xe,selectedFilePath:d?.path,loadedFilePath:ae,isNonEditableBinary:o,wouldEmptyFile:Q===""&&H!==""}))return;const c=g=>{lt.current=setTimeout(()=>{const w=Date.now()-wi.current;if(w<jn){c(jn-w);return}bt().then(S=>{S&&(ss("saved"),setTimeout(()=>ss("idle"),2e3))})},g)};return c(jn),()=>{lt.current&&(clearTimeout(lt.current),lt.current=null)}},[be,Ot,Q,H,xe,Le,ae,d,a.writeFile,Zt,bt]),i.useEffect(()=>{ss("idle")},[d?.path]);const Yi=i.useCallback(()=>{lt.current&&(clearTimeout(lt.current),lt.current=null),Zt||bt().then(s=>{s&&(ss("saved"),setTimeout(()=>ss("idle"),2e3))})},[Zt,bt]);eu({save_file:s=>{if(!(s.target instanceof Node)||!Ds.current?.contains(s.target)&&!vi.current?.contains(s.target))return!1;Yi()},find_in_file:s=>{if(!(s.target instanceof Node))return!1;if(Ke&&Ie()==="preview"){if(u||!(te?pn.current:mn.current)?.contains(s.target))return!1;fn(!0),Ni(c=>c+1);return}if(!Ds.current?.contains(s.target))return!1;At(!0)}});const Ji=i.useCallback(async s=>{const o=es.current+1;es.current=o;const c=qe(),g=k.current,w=()=>{if(!l||qe()!==c||k.current!==g)return!1;const ee=Oe.getState().byRoot[l],G=ee?.selectedPath??ee?.openPaths[0]??null;return es.current===o&&G===s.path};ce(null),sr(null),cn.current=null,Ue(""),oe(null),gi(!1),Et(!0);const S=Lr(s.path),V=zr(s.path),_=Wa(s.path),le=_s(s.path);if(u&&ne(!0),m.isDesktop&&S&&!V){ue(""),de("");return}if(!m.isDesktop&&S&&!V){ue(""),de(""),oe(s.path),Et(!1);return}if(_){ue(""),de(""),oe(s.path),Et(!1);return}if(le){ue(""),de(""),oe(s.path),Et(!1);return}await yn(s.path).then(ee=>{if(!w())return;if(Ha(ee)){gi(!0),ue(""),de(""),oe(s.path);return}const G=Pt(ee),Pe=Wr(s.path)||$n(s.path)||wo(s.path)||Us(s.path)||zr(s.path)||Ka(s.path)||Ga(s.path)||Hr(s.path);et(Pe?"edit":Vd(G,Zs.current[s.path])),oe(s.path),dt(s.path).then(he=>{he&&w()&&(De.current=he)}).catch(()=>{})}).catch(ee=>{if(w()){if($f(ee)){if(Et(!1),l&&we(l,null),ce(null),ue(""),de(""),oe(null),De.current=null,$.trim().length>0&&U(""),u&&ne(!1),l){const Pe=[...go(s.path,l),s.path];Pe.length>0&&sn(l,Pe);for(const he of Pe)_e.current.has(he)||Te(he)}return}ue(""),de(""),ce(ee instanceof Error?ee.message:t("filesView.error.readFileFailed")),sr(s.path),De.current=null}}).finally(()=>{w()&&Et(!1)})},[Pt,sn,u,Te,yn,dt,l,m.isDesktop,$,we,t]),Cn=i.useCallback(async(s,o)=>{if(!e||!l)return;const c=go(s,l),g=o?[...c,s]:c;if(g.length>0&&sn(l,g),!T)return;const w=g.map(S=>{if(!_e.current.has(S))return Te(S)}).filter(Boolean);await Promise.all(w)},[sn,Te,l,T,e]),Zi=i.useCallback((s,o)=>{const c=o.findIndex(g=>g.path===s);return c===-1||o.length<=1?null:o[c+1]??o[c-1]??null},[]),Me=i.useCallback(async s=>{if(Ms.current)Ms.current=!1;else if(Le){Rs(!0),ns.current=s;return}l&&(we(l,s.path),Cn(s.path,!1)),ce(null),Ue(""),ue(""),Rt.current="",Fs.current="",ct(!1),de(""),oe(null),u&&ne(!0)},[Cn,Le,u,l,we]);i.useEffect(()=>{d?.path&&Cn(d.path,!1)},[Cn,d?.path]),i.useEffect(()=>{if(!e)return;if(!d){es.current+=1,It.current=null,Et(!1);return}if(ae===d.path||It.current===d.path)return;const s=d.path;It.current=s,Ji(d).finally(()=>{It.current===s&&(It.current=null)})},[ts,Ji,ae,d,e]);const Sn=i.useRef(Le);Sn.current=Le,i.useEffect(()=>Wu(({runtimeKey:s,paths:o})=>{const c=d?.path;s!==qe()||!c||Sn.current||!o.includes(Z(c))||(es.current+=1,It.current=null,De.current=null,Ue(""),ce(null),oe(null),hi(g=>g+1))}),[d?.path]),i.useEffect(()=>{if(!e||!d?.path||ae!==d.path&&vt!==d.path)return;const s=d.path,o=vt===s,c=qe(),g=k.current,w=()=>Sn.current||Us(s)&&Rt.current!==Fs.current,S=!_s(s)&&!Lr(s)&&!Ot?jd({readContent:()=>yn(s,{fresh:!0}),getLoadedContent:()=>ir.current,getLoadedRevision:()=>ar.current,isDirty:w,applyContent:G=>{if(!(V||qe()!==c||k.current!==g)){if(Ha(G)){oe(null);return}Pt(G)}}}):null;let V=!1,_=!1;const le=()=>{document.hidden||_||(_=!0,dt(s).then(async G=>{if(V||qe()!==c||k.current!==g||!G)return;const Pe=cn.current===s,he=so({stat:"found",showsFailure:o,sawMissing:Pe,hasUnsavedChanges:w()});if(he==="reload"){De.current=null,oe(null),hi(Pr=>Pr+1);return}if(he!=="check-changes")return;const An=De.current;if(!An||An.path!==s){De.current=G;return}if(Sd(An,G)){if(S&&G.size<=_f){await S.poll()&&!V&&(De.current=G);return}Sn.current||(De.current=G,oe(null))}}).catch(G=>{if(V||qe()!==c||k.current!==g)return;const Pe=$a(G)?"missing":"failed",he=cn.current===s;so({stat:Pe,showsFailure:o,sawMissing:he,hasUnsavedChanges:w()})==="show-missing"&&(cn.current=s,De.current=null,ue(""),de(""),ce(G instanceof Error?G.message:t("filesView.error.readFileFailed")),sr(s))}).finally(()=>{_=!1}))};le();const ee=window.setInterval(le,2e3);return()=>{V=!0,S?.dispose(),window.clearInterval(ee)}},[Pt,Ot,vt,ae,yn,dt,d?.path,t,e]);const Nl=i.useCallback(()=>{const s=ns.current,o=Ts.current;if(ns.current=null,Ts.current=null,Ms.current=!0,Rs(!1),ct(!1),Js(c=>c+1),de(H),o){l&&Xt(l,o),d?.path===o&&(s?Me(s):(l&&we(l,null),ue(""),ce(null),Ue(""),oe(null),u&&ne(!1)));return}if(s){Me(s);return}},[H,Me,u,Xt,l,d?.path,we]),Fl=i.useCallback(async()=>{const s=ns.current,o=Ts.current;if(!await bt()){Ms.current=!1;return}if(ns.current=null,Ts.current=null,Ms.current=!0,Rs(!1),o){l&&Xt(l,o),d?.path===o&&(s?await Me(s):(l&&we(l,null),ue(""),ce(null),Ue(""),oe(null),u&&ne(!1)));return}if(s){await Me(s);return}},[Me,u,Xt,l,bt,d?.path,we]),zs=i.useCallback(s=>{const o=d?.path===s,c=Zi(s,Jt);if(o&&Le){Rs(!0),ns.current=c,Ts.current=s;return}if(l&&Xt(l,s),!!o){if(c){Me(c);return}l&&we(l,null),ue(""),ce(null),Ue(""),oe(null),u&&ne(!1)}},[Zi,Me,Le,u,Jt,Xt,l,d?.path,we]),Qi=i.useRef(zs);i.useEffect(()=>{Qi.current=zs},[zs]);const pr=d?.path??null;i.useEffect(()=>{if(!(!e||!pr))return Pf(()=>Qi.current(pr))},[pr,e]);const ea=i.useMemo(()=>new Set(ve),[ve]),Nn=i.useMemo(()=>Du(M?K?.files??[]:[]),[K?.files,M]),El=i.useCallback(s=>{if(ea.has(s))return"open";const o=s.startsWith(l+"/")?s.slice(l.length+1):s;return Nn.statusByPath.get(o)??null},[ea,Nn,l]),kl=i.useCallback(s=>{if(!K?.files)return null;const o=s.startsWith(l+"/")?s.slice(l.length+1):s;return Nn.badgeByDir.get(o)??null},[K,Nn,l]),Rl=i.useCallback(async s=>{const o=Z(s);l&&(ii(l,o),_e.current.has(o)||await Te(o))},[Te,l,ii]),Tl=i.useMemo(()=>({canRename:ki,canCreateFile:Fi,canCreateFolder:Ei,canDelete:Ri,canReveal:Ti}),[ki,Fi,Ei,Ri,Ti]);function ta(s,o){const c=ci[s]??[];return c.map((g,w)=>{const S=g.type==="directory",V=S&&Go.has(g.path),_=d?.path===g.path,le=w===c.length-1;return n.jsxs("li",{className:"relative",children:[o>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),le&&n.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),n.jsx(Uf,{node:g,root:l,isExpanded:V,isActive:_,isMobile:u,isBrowserClient:N,alwaysShowActions:R,status:S?void 0:El(g.path),badge:S?kl(g.path):void 0,permissions:Tl,downloadFile:a.downloadFile,contextMenuPath:ll,setContextMenuPath:cl,rightClickMenuPath:ul,setRightClickMenuPath:dl,onSelect:Me,onToggle:Rl,onRevealPath:vl,onOpenDialog:fr,canUpload:Hi&&!bn,onPickFiles:Ki}),S&&V&&n.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[rn[g.path]?n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:rn[g.path],children:rn[g.path]}),n.jsxs(B,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ae(g.path)},children:[n.jsx(P,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})]}):null,ta(g.path,o+1)]})]},g.path)})}const ze=!!(d?.path&&Lr(d.path)),We=!!(d?.path&&zr(d.path)),sa=We&&rt==="edit",Vt=!!(d?.path&&Wa(d.path)),na=!!(d?.path&&tu(d.path)),gr=na||!!(d?.path&&su(d.path)),vr=!!(d?.path&&nu(d.path)),Fn=!!(d?.path&&(_s(d.path)||Ot)),ls=Fn&&!ze&&!Vt&&!gr&&!vr,ra=Fn||ze&&!sa,ia=i.useMemo(()=>Z(ut?.path??""),[ut?.path]),cs=!!(ut&&ia&&ke&&ke===ia&&!xe&&!Je&&!ra),yt=i.useMemo(()=>Un(l,ke),[ke,l]),Ml=!!(d&&(!ze||We)&&!Vt&&!ls&&H.length>0),Pl=!!(d&&yt.length>0),He=!!(d&&!nn&&!Fn&&(!ze||We)&&a.writeFile),wr=!!(d&&!Fn&&(!ze||We)),xr=Bd(d?.path),je=xr&&(wr||xr.editor.content==="binary")?xr:null,jt=je!==null,Vl=ru(),Is=je?.editor.content==="binary";ks.current=Is;const Ke=!jt&&!!(d?.path&&Wr(d.path)),us=!jt&&!!(d?.path&&wo(d.path)),_t=!jt&&!!(d?.path&&$n(d.path)),Os=!jt&&!Vl&&!!(d?.path&&Us(d.path)),ds=!jt&&!!(d?.path&&Ka(d.path)),fs=!jt&&!!(d?.path&&Ga(d.path)),ms=jt,Bs=jt&&(Is?pt===null||pt<=Kr:Q.length<=Kr),Dl=Jr(s=>s.status),Al=!jt&&wr&&Dl!=="unsupported"&&!!(d?.path&&iu(d.path)),En=wr&&!Ke&&!Os&&!ms&&!(_t&&Se==="preview")&&!(We&&rt==="preview")&&!(ds&&me==="preview")&&!(fs&&Y==="table"),Ll=Ke&&Ft==="edit"||_t&&Se==="edit"||ms&&(Fe==="edit"||!Bs)||We&&rt==="edit"||ds&&me==="edit"||fs&&Y==="text"||us&&Ce==="text"||!Ke&&!_t&&!us&&!ms&&!We&&!ds&&!fs&&re==="edit",kn=i.useMemo(()=>ke?au(ke):null,[ke]),[aa,br]=i.useState(null);i.useEffect(()=>{let s=!1;const o=d?.path;if(!o||kn){br(null);return}return br(null),ou(o).then(c=>{s||br(c)}),()=>{s=!0}},[d?.path,kn]),i.useEffect(()=>{!He&&re==="edit"&&et("view")},[He,re]);const yr="openchamber:files:md-viewer-mode",jr="openchamber:files:html-viewer-mode",Cr="openchamber:files:json-viewer-mode";i.useEffect(()=>{const s=d?.path;if(!s)return;et(Zs.current[s]??"edit");let o=As?"preview":"edit";try{const w=localStorage.getItem(yr);(w==="preview"||w==="edit")&&(o=w)}catch{}tt(qn.current[s]??o);let c=As?"preview":"edit";try{const w=localStorage.getItem(jr);(w==="preview"||w==="edit")&&(c=w)}catch{}nt(Xn.current[s]??c),Be(Yn.current[s]??(As?"preview":"edit")),Ee(Cs.current[s]??"preview"),$e(ti.current[s]??"preview"),js(si.current[s]??"preview"),it(ni.current[s]??"table");let g=As?"tree":"text";try{const w=localStorage.getItem(Cr);(w==="tree"||w==="text")&&(g=w)}catch{}st(g)},[d?.path,As]);const zl=i.useCallback(s=>{const o=d?.path;o&&(Zs.current[o]=s),et(s)},[d?.path]),Il=i.useCallback(s=>{const o=d?.path;o&&(qn.current[o]=s),tt(s);try{localStorage.setItem(yr,s)}catch{}},[d?.path]),Ie=i.useCallback(()=>Ft,[Ft]),Ol=i.useCallback(s=>{const o=d?.path;o&&(ti.current[o]=s),$e(s)},[d?.path]),Bl=i.useCallback(s=>{const o=d?.path;o&&(si.current[o]=s),js(s)},[d?.path]),$l=i.useCallback(s=>{const o=d?.path;o&&(ni.current[o]=s),it(s)},[d?.path]);i.useEffect(()=>{const s=d?.path;if(ei(null),!s||ae!==s)return;let o=!1;return dt(s).then(c=>{!o&&c&&ei(c.size)}).catch(()=>{}),()=>{o=!0}},[ts,ae,dt,d?.path]);const oa=d&&Ke&&Ie()==="preview"&&!xe?d.path:null;i.useEffect(()=>{!oa||u||hn()},[hn,te,u,oa]);const _l=i.useCallback(s=>{st(s);try{localStorage.setItem(Cr,s)}catch{}},[]),Ul=i.useCallback(s=>{const o=d?.path;o&&(Xn.current[o]=s),nt(s);try{localStorage.setItem(jr,s)}catch{}},[d?.path]),Wl=i.useCallback(s=>{const o=d?.path;if(o&&(Yn.current[o]=s),Ve.current&&(clearTimeout(Ve.current),Ve.current=null),wt.current!==null&&(cancelAnimationFrame(wt.current),wt.current=null),s==="edit")de(Rt.current||H),Be(s);else{Rt.current=Q;const c=o;Be("edit"),wt.current=requestAnimationFrame(()=>{wt.current=requestAnimationFrame(()=>{wt.current=null,!(l&&c&&Oe.getState().byRoot[l]?.selectedPath!==c)&&(Ho(g=>g+1),Be("preview"))})});return}},[Q,H,l,d?.path]),Hl=i.useCallback(s=>{const o=d?.path,c=()=>{o&&(Cs.current[o]=s)};if(s==="edit"){if(!rr.current){c(),ct(!1),Ee(s);return}Promise.resolve(Qt.current?.getContent("handoff")??$r).then(w=>{if(gt.current===o){if(!w.ok){q.error(w.message);return}c(),de(w.snapshot&&"content"in w.snapshot?w.snapshot.content:H),ct(!1),Ee(s)}});return}if(!Bs){je&&q.error(t("filesView.fileEditor.tooLarge",{editor:je.editor.title}));return}c(),ct(!1);const g=o;zt.current!==null&&cancelAnimationFrame(zt.current),zt.current=requestAnimationFrame(()=>{zt.current=null,!(l&&g&&Oe.getState().byRoot[l]?.selectedPath!==g)&&(Js(w=>w+1),Ee("preview"))})},[Bs,H,je,l,d?.path,t]),Sr=i.useCallback(async(s,o)=>{if(!a.writeFile||o===Fs.current)return!1;if(!(await a.writeFile(s,o))?.success)return q.error(t("filesView.toast.writeFileFailed")),!1;Pt(o);const g=await dt(s).catch(()=>null);return g&&(De.current=g),!0},[Pt,a,dt,t]);i.useEffect(()=>()=>{Ve.current&&(clearTimeout(Ve.current),Ve.current=null),wt.current!==null&&(cancelAnimationFrame(wt.current),wt.current=null)},[Ne,d?.path]);const Kl=i.useCallback(s=>{if(Rt.current=s,!be||!d?.path||Ne!=="preview"||!a.writeFile)return;Ve.current&&clearTimeout(Ve.current);const o=d.path;Ve.current=setTimeout(()=>{Ve.current=null,Sr(o,s).then(c=>{c&&(un(!0),setTimeout(()=>un(!1),1500))}).catch(c=>{q.error(c instanceof Error?c.message:t("filesView.toast.saveFailed"))})},jn)},[be,Ne,a.writeFile,Sr,d?.path,t]),Gl=i.useMemo(()=>Os&&(Rt.current||Q)||H,[Q,H,Os]),ql=i.useCallback(()=>{const s=gt.current;s&&(Cs.current[s]="edit"),ct(!1),Ee("edit"),je&&q.error(t("filesView.fileEditor.unsupported",{editor:je.editor.title}))},[je,t]);i.useEffect(()=>()=>{zt.current!==null&&(cancelAnimationFrame(zt.current),zt.current=null)},[Fe,d?.path]);const la=i.useCallback(()=>Se,[Se]);i.useEffect(()=>{const s=c=>{const g=c?"preview":"edit",w=c?"tree":"text";for(const S of ve)Zs.current[S]="edit",Wr(S)&&(qn.current[S]=g),$n(S)&&(Xn.current[S]=g),Us(S)&&(Yn.current[S]=g),Hr(S)&&(Cs.current[S]=g);et("edit"),tt(g),nt(g),Be(g),Ee(g),st(w);try{localStorage.setItem(yr,g),localStorage.setItem(jr,g),localStorage.setItem(Cr,w)}catch{}},o=c=>{const g=!!c.detail?.enabled;s(g)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",o),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",o)}},[ve]),i.useEffect(()=>{if(!ut||!l)return;const s=()=>{typeof window>"u"||rs.current===null&&(rs.current=window.requestAnimationFrame(()=>{rs.current=null,lr(St=>St+1)}))},o=(St,Ht)=>{if(St.state.doc.length!==Ht.length)return!1;if(Ht.length===0)return!0;const Vr=Math.min(128,Ht.length);if(St.state.sliceDoc(0,Vr)!==Ht.slice(0,Vr))return!1;const Ba=Math.max(0,Ht.length-Vr);return St.state.sliceDoc(Ba,Ht.length)===Ht.slice(Ba)},c=Z(ut.path);if(!c){gn(null),xt.current={key:"",attempts:0,targetShown:!1};return}const g=`${c}:${ut.line}:${ut.column??1}`;xt.current.key!==g&&(xt.current={key:g,attempts:0,targetShown:!1});const w=d?.path??null;w===c&&(xt.current.targetShown=!0);const S=Nd({selectedPath:w,targetPath:c,targetShown:xt.current.targetShown,targetSettled:!xe&&(ae===c||vt===c),showsText:vt!==c&&!Je&&!ze&&!Vt&&!ls,canEdit:He,textViewMode:re});if(S==="select-target"){or||Me(Yt(c));return}if(S==="wait")return;if(S==="end"){gn(null),xt.current={key:"",attempts:0,targetShown:!1};return}if(S==="show-editor"){et("edit");return}const V=ye.current;if(!V){s();return}if(!o(V,Q)){s();return}const _=Math.max(1,Math.min(ut.line,V.state.doc.lines)),le=V.state.doc.line(_),ee=Math.max(1,ut.column||1),G=Math.max(0,le.to-le.from),Pe=Math.min(G,ee-1),he=le.from+Pe;if(!(V.state.selection.main.head===he)||xt.current.attempts===0){xt.current.attempts+=1,V.dispatch({selection:{anchor:he},effects:Qe.scrollIntoView(he,{y:"center"})}),V.focus(),s();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const St=ye.current;St&&(St.dispatch({selection:{anchor:he},effects:Qe.scrollIntoView(he,{y:"center"})}),St.focus())}),gn(null),xt.current={key:"",attempts:0,targetShown:!1}},[He,or,Q,il,vt,Je,xe,ze,Vt,ls,ae,Me,ut,l,d?.path,gn,re,Yt]),i.useEffect(()=>{if(!mr||!l)return;const s=Z(mr);if(!s){hr(null);return}d?.path===s&&(xe||ae!==s&&vt!==s||(vt!==s&&!Je&&!ze&&!Vt&&!ls&&He&&re==="edit"&&ye.current?.focus(),hr(null)))},[He,vt,Je,xe,ze,Vt,ls,ae,mr,l,d?.path,hr,re]);const hs=i.useCallback(s=>{if(!u||!s||typeof window>"u")return;const o=document.activeElement,c=!s.hasFocus&&o instanceof HTMLElement&&s.dom.contains(o)?o.closest('[data-comment-input="true"]'):null;if(!s.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 V=c?c.getBoundingClientRect():s.coordsAtPos(s.state.selection.main.head);if(!V)return;const _=Math.round(g.offsetTop+g.height),ee=V.bottom+20-_;ee<=0||(s.scrollDOM.scrollTop+=ee)},[u]);i.useEffect(()=>{if(!u||typeof window>"u")return;const s=()=>{window.requestAnimationFrame(()=>{hs(ye.current)})},o=window.visualViewport;return o?.addEventListener("resize",s),o?.addEventListener("scroll",s,{passive:!0}),document.addEventListener("selectionchange",s),()=>{o?.removeEventListener("resize",s),o?.removeEventListener("scroll",s),document.removeEventListener("selectionchange",s)}},[u,hs]),qa("open_go_to_line",s=>{if(!He||re!=="edit"||u)return!1;const o=s.target;if(o?.closest('[role="dialog"]')||!(o instanceof Node)||!Ds.current?.contains(o))return!1;const c=!!o?.closest(".cm-editor");if(!!o?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!c)return!1;dr(!0)}),qa("open_document_symbols",s=>{if(!He||re!=="edit"||u)return!1;const o=s.target;if(o?.closest('[role="dialog"]')||!(o instanceof Node)||!Ds.current?.contains(o))return!1;dn(!0)});const Ut=Ge(s=>s.editorFontSize),ca=i.useMemo(()=>({"--text-markdown":`${Ut+1}px`,"--text-code":`${Ut-1}px`}),[Ut]),ft=d?.path&&l&&d.path.startsWith(`${l}/`)?d.path.slice(l.length+1):null,ua=Dr(s=>{if(!ft||!l)return null;const o=s.directories.get(y)?.status,c=o?.files.find(g=>g.path===ft)??null;return JSON.stringify([ft,o?.current??null,c])}),[Nr,Fr]=i.useState(null);i.useEffect(()=>{if(!ft||!l||!ua){Fr(null);return}let s=!1;return f.getGitFileDiff(l,{path:ft}).then(o=>{if(s)return;const c=Dr.getState().directories.get(y)?.status?.files.find(S=>S.path===ft),g=c!==void 0&&(c.index==="?"||c.index==="A"||c.working_dir==="?"),w=!o.isBinary&&!o.submodule&&(o.original!==""||g);Fr({path:ft,text:w?o.original:null})}).catch(()=>{s||Fr({path:ft,text:null})}),()=>{s=!0}},[y,f,ua,l]);const da=i.useRef(Nr);da.current=Nr;const Rn=i.useCallback(s=>{if(!s)return;const o=da.current;ef(s,o&&o.path===ft?o.text:null)},[ft]);i.useEffect(()=>{Rn(ye.current)},[Rn,Nr]);const fa=i.useRef(()=>{});fa.current=()=>{if(!d?.path||!l)return;const s=Nc(l),o=Ge.getState(),c=o.contextPanelByDirectory[s]?.tabs.find(g=>g.preview&&g.targetPath===d.path);c&&o.pinContextPanelTab(s,c.id)};const ma=i.useMemo(()=>Qe.updateListener.of(s=>{if(!s.docChanged)return;s.transactions.some(c=>c.isUserEvent("input")||c.isUserEvent("delete")||c.isUserEvent("undo")||c.isUserEvent("redo")||c.isUserEvent("move"))&&fa.current()}),[]),ha=i.useMemo(()=>{if(!d?.path)return[Xa(p,{fontSize:Ut})];const s=Ar(d.path),o=[Xa(p,s?{syntaxColors:!1,fontSize:Ut}:{fontSize:Ut})],c=kn??aa;c&&o.push(c),s&&o.push(wu({language:s,themeName:p.metadata.id,theme:Ou(p)})),fe&&o.push(Qe.lineWrapping);const g=p.colors.syntax.highlights;return o.push(Qd({added:g?.diffAdded??p.colors.status.success,modified:g?.diffModified??p.colors.status.info,removed:g?.diffRemoved??p.colors.status.error}),Xu({highlightWordAroundCursor:!0,minSelectionLength:2}),ma,Hd()),u||o.push(Wd(),Kd({vimMode:os==="vim"})),u&&o.push(Qe.updateListener.of(w=>{w.view.hasFocus&&(w.selectionSet||w.focusChanged||w.viewportChanged||w.geometryChanged)&&window.requestAnimationFrame(()=>{hs(w.view)})})),o},[p,d?.path,kn,aa,fe,u,hs,Ut,ma,os]),pa=i.useMemo(()=>({light:Qs.metadata.id,dark:en.metadata.id}),[Qs.metadata.id,en.metadata.id]),ga=Vt||gr||vr,$s=d?.path&&ga?`${d.path}|${Ss.allowOutsideWorkspace?"outside":"workspace"}|${ts}`:"",Xl=i.useMemo(()=>d?.path&&_t&&Se==="preview"&&!m.isVSCode?{path:d.path,directory:l||"",revision:String(ts)}:null,[d?.path,_t,Se,m.isVSCode,l,ts]),va=t("filesView.error.readFileFailed"),Wt=Tf(Xl,va);i.useEffect(()=>{Wt.status==="error"?ce(Wt.message):Wt.status==="ready"&&ce(null)},[Wt,ce]);const{readyKey:wa,nonce:Tn}=Kf($s,ce,va),Er=!!($s&&wa!==$s),Yl=d?.path&&ze?We?`data:${lu(d.path)};utf8,${encodeURIComponent(H)}`:Zo:"",Mn=d?.path&&ga&&$s&&wa===$s?bo().authenticatedAsset(Fc("/api/fs/raw",l),{path:d.path,allowOutsideWorkspace:Ss.allowOutsideWorkspace?"true":void 0,directory:l||void 0}):"",Jl=i.useCallback(s=>n.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:n.jsx("iframe",{src:Mn,className:"h-full w-full border-0",title:s.name},Tn)}),[Mn,Tn]),xa=d&&a.downloadFile?n.jsxs(B,{type:"button",variant:"outline",size:"sm",onClick:()=>{const s=a.downloadFile;!s||!d||s(d.path,Ss).catch(o=>{console.error("Download failed:",o),q.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(P,{name:"download",className:"mr-2 size-4"}),t("filesView.editor.saveFile")]}):null,Pn=d&&!xe&&!Er&&!Je?(s=>ze&&!sa?n.jsx(hf,{src:Yl,name:s.name,sizeBytes:pt}):Vt?Jl(s):gr?n.jsx(pf,{kind:na?"video":"audio",src:Mn,name:s.name,sizeBytes:pt,download:xa},Tn):vr?n.jsx(of,{src:Mn,name:s.name,sizeBytes:pt},Tn):ls?n.jsx(nf,{name:s.name,path:s.path,sizeBytes:pt,download:xa}):fs&&Y==="table"?n.jsx(xf,{path:s.path,content:H,sizeBytes:pt}):ds&&me==="preview"?n.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:n.jsx(Ln,{fallback:n.jsxs("div",{className:"m-3 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:n.jsx(Or,{content:`\`\`\`mermaid
|
|
13
|
+
${H}
|
|
14
|
+
\`\`\``,className:"markdown-mermaid-fullscreen h-full",enableFileReferences:!1,allowMermaidWheelEvents:!0})})}):null)(d):null;i.useEffect(()=>{let s=!1,o="";return(async()=>{if(!d?.path||!ze||We){Ue("");return}ce(null);const g=ot(d.path);if(s)return;await(a.readFileBinary?a.readFileBinary(d.path,g).then(S=>S.dataUrl):(async()=>{const S=await Hs("/api/fs/raw",{signal:AbortSignal.timeout(3e4),query:{path:d.path,allowOutsideWorkspace:g.allowOutsideWorkspace?"true":void 0,directory:l||void 0}});if(!S.ok)throw new Error(t("filesView.error.readFileFailed"));const V=await S.blob();return o=URL.createObjectURL(V),s?(URL.revokeObjectURL(o),o="",""):o})()).then(S=>{s||(Ue(S),oe(d.path))}).catch(S=>{s||(Ue(""),ce(S instanceof Error?S.message:t("filesView.error.readFileFailed")),oe(null))}).finally(()=>{s||Et(!1)})})(),()=>{s=!0,o&&URL.revokeObjectURL(o)}},[ts,a,ze,We,ot,l,d?.path,Ss,t]);const Zl=i.useCallback(()=>cr(null),[]),Ql=i.useMemo(()=>nd({drafts:Li,editingDraftId:wn,commentText:vn,onTextChange:zi,selection:J,isDragging:Vi,fileLabel:d?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:s=>({start:s.startLine,end:s.endLine}),onSave:Ui,onCancel:()=>{Ze(null),Ls()},onEdit:s=>{$i(s),Ze({start:s.startLine,end:s.endLine})},onDelete:_i}),[Ls,vn,_i,wn,Li,Ui,Vi,J,d?.path,zi,$i]),ba=no(),ya=no(),Vn=!xe&&!Je&&ae===ke,kr=i.useMemo(()=>!!ke&&zd({hasCanvas:ms,viewMode:Fe,previewReady:Vn,mountable:Bs}),[Bs,Fe,ms,Vn,ke]),Dn=Vn&&En&&re==="view"&&!(us&&Ce==="tree"),ja=Vn&&Ke&&Ie()==="preview",{setScroller:Ca,restore:ec}=In(Dn?`${kt}:code`:null),{setScroller:Sa,restore:tc}=In(Dn?`${kt}:code:fullscreen`:null),{setScroller:Na}=In(ja?`${kt}:markdown`:null),{setScroller:Fa}=In(ja?`${kt}:markdown:fullscreen`:null),{setScroller:Ea}=ba,{setScroller:ka}=ya,sc=i.useCallback(s=>{Ea(s),Ca(s)},[Ea,Ca]),nc=i.useCallback(s=>{ka(s),Sa(s)},[ka,Sa]),[rc,ic]=i.useState(null),[ac,oc]=i.useState(null),lc=i.useCallback(s=>{Ai.current=s,mn.current=s,ic(s),Na(s)},[Na]),cc=i.useCallback(s=>{pn.current=s,oc(s),Fa(s)},[Fa]),Ra=i.useCallback(s=>{l&&Ge.getState().openContextFile(l,s)},[l]),Ta=Ke&&Ft==="preview"&&!xe,Ma=p.metadata.variant==="light"?"light":"dark";mo({container:rc,filePath:d?.path??null,workspaceRoot:l||null,onOpenFile:Ra,enabled:Ta,colorScheme:Ma}),mo({container:ac,filePath:d?.path??null,workspaceRoot:l||null,onOpenFile:Ra,enabled:Ta,colorScheme:Ma});const Rr=Hu("unified"),Ct=Q.length>Ao,Tr=i.useMemo(()=>Ct&&Dn?Dd(Q):void 0,[Dn,Q,Ct]),Pa=i.useCallback((s,o,c,g)=>{const w={name:s.name,contents:o,lang:Ar(s.path)||void 0},S=V=>n.jsx(Iu,{file:Ct&&Tr?{...w,cacheKey:`${s.path}:${Tr}`}:w,options:{disableFileHeader:!0,overflow:fe?"wrap":"scroll",theme:pa,themeType:p.metadata.variant==="dark"?"dark":"light",onPostRender:g},className:Ct?"block w-full":"block h-full w-full",style:Ct?void 0:{height:"100%"}},V);return Ct?n.jsx("div",{className:"h-full",children:n.jsx(Bu.Provider,{value:c.virtualizer,children:n.jsx($u.Provider,{value:Rr,children:S(`${s.path}:${Rr?"pool":"pending"}`)})})}):n.jsx("div",{className:"h-full",children:S(s.path)})},[p.metadata.variant,Ct,Tr,pa,Rr,fe]),Va=({exitFullscreenOnly:s=!1,layout:o="floating"}={})=>{if(!d)return null;const c=o==="docked",g=cu(uu("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",S=(V,_)=>n.jsxs(Kt,{children:[n.jsx(Gt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:_})}),n.jsx(qt,{side:"bottom",sideOffset:6,children:V})]});return n.jsxs("div",{className:w,children:[He&&Ll&&n.jsxs(n.Fragment,{children:[Zt?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[n.jsx(P,{name:"loader-4",className:"size-3.5 animate-spin"}),t("filesView.editor.saving")]}):be&&tl==="saved"&&!Le?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[n.jsx(P,{name:"check",className:"size-3.5"}),t("filesView.editor.saved")]}):Le?S(t(be?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:g}),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>{bt()},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(be?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:g}),"aria-label":t("filesView.editor.saveAria",{shortcut:g}),children:n.jsx(P,{name:"save-3",className:"size-4"})})):null,S(t(be?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>rl(!be),className:X("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",be?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:t(be?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":t(be?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:be?n.jsx(P,{name:"file-check-fill",className:"size-4"}):n.jsx(P,{name:"file-check",className:"size-4"})}))]}),n.jsxs(Gr,{onOpenChange:ys,children:[n.jsxs(Kt,{children:[n.jsx(Gt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(qr,{asChild:!0,children:n.jsx(B,{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:n.jsx(P,{name:"file-transfer",className:"size-4"})})})})}),n.jsx(qt,{side:"bottom",sideOffset:6,children:t("filesView.editor.openInDesktopApp")})]}),n.jsxs(Xr,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[n.jsxs(Ws,{className:"flex items-center gap-2",onClick:()=>{d?.path&&_n(d.path).then(V=>{V||q.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(P,{name:"external-link",className:"size-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:t("sidebarFilesTree.menu.openInDefaultApp")})]}),Mi.length>0?n.jsx(Eo,{}):null,Mi.map(V=>n.jsxs(Ws,{className:"flex items-center gap-2",onClick:()=>{wl(V)},children:[n.jsx(Df,{label:V.label,iconDataUrl:V.iconDataUrl}),n.jsx("span",{className:"typography-ui-label text-foreground",children:V.label})]},V.id)),pl?n.jsxs(Ws,{className:"flex items-center gap-2",onClick:()=>{gl(!0)},children:[n.jsx(P,{name:"refresh",className:"size-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:t("filesView.editor.refreshApps")})]}):null]})]}),!ra&&n.jsxs(n.Fragment,{children:[S(t(fe?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>W(!fe),className:X("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",fe?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:t(fe?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:n.jsx(P,{name:"text-wrap",className:"size-4"})})),re==="edit"&&n.jsxs(n.Fragment,{children:[S(t("filesView.editor.findInFile"),n.jsx(B,{variant:"ghost",size:"sm",onClick:V=>{At(!mt),V.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:n.jsx(P,{name:"search",className:"size-4"})})),S(t("filesView.editor.goToLine"),n.jsx(B,{variant:"ghost",size:"sm",onClick:V=>{dr(_=>!_),V.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:n.jsx(P,{name:"menu-fold-2",className:"size-4"})})),!u&&S(t("filesView.editor.symbols"),n.jsx(B,{variant:"ghost",size:"sm",onClick:V=>{dn(_=>!_),V.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:n.jsx(P,{name:"list-unordered",className:"size-4"})})),n.jsx(id,{open:hl,onOpenChange:dr,view:ye.current,variant:"inline"})]})]}),En&&He&&!us&&!_t&&!We&&!ds&&!fs&&n.jsx(ps,{currentMode:re==="view"?"preview":"edit",onToggle:()=>{zl(re==="view"?"edit":"view")}}),Ke&&S(t(Ie()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>Il(Ie()==="preview"?"edit":"preview"),className:X("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Ie()==="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(Ie()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":t(Ie()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:n.jsx(P,{name:Ie()==="preview"?"eye":"eye-off",className:"size-4"})})),$n(d?.path??"")&&n.jsx(ps,{currentMode:la(),onToggle:()=>{Ul(la()==="preview"?"edit":"preview")}}),We&&n.jsx(ps,{currentMode:rt,onToggle:()=>Ol(rt==="preview"?"edit":"preview")}),ds&&n.jsx(ps,{currentMode:me,onToggle:()=>Bl(me==="preview"?"edit":"preview")}),fs&&S(t(Y==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>$l(Y==="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(Y==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),"aria-label":t(Y==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),children:Y==="table"?n.jsx(P,{name:"code-sslash",className:"size-4"}):n.jsx(P,{name:"table-2",className:"size-4"})})),Ke&&Ie()==="preview"&&S(t("filesView.editor.findInFile"),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>{fn(!0),Ni(V=>V+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:n.jsx(P,{name:"search",className:"size-4"})})),Ke&&Ie()==="preview"&&xl&&n.jsxs(Kt,{children:[n.jsx(Gt,{asChild:!0,children:n.jsx(B,{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(ln?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{ln?Jo():H.trim()&&Yo(H)},children:n.jsx(P,{name:"volume-up",className:X("size-4",ln&&"animate-pulse text-[var(--primary-text)]")})})}),n.jsx(qt,{sideOffset:8,children:t(ln?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),ms&&n.jsxs(n.Fragment,{children:[!Is&&n.jsx(ps,{currentMode:Fe,onToggle:()=>Hl(Fe==="preview"?"edit":"preview")}),Fe==="preview"&&n.jsx(B,{variant:"ghost",size:"sm",onClick:async()=>{await bt()&&(pi(!0),setTimeout(()=>pi(!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:nl?n.jsx(P,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(P,{name:"save-3",className:"size-4"})})]}),Os&&n.jsxs(n.Fragment,{children:[n.jsx(ps,{currentMode:Ne,onToggle:()=>Wl(Ne==="preview"?"edit":"preview")}),Ne==="preview"&&n.jsx(B,{variant:"ghost",size:"sm",onClick:async()=>{const V=fi.current?.getXml();if(Ve.current&&(clearTimeout(Ve.current),Ve.current=null),d?.path&&V){if(!await Sr(d.path,V))return;un(!0),setTimeout(()=>un(!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:sl?n.jsx(P,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(P,{name:"save-3",className:"size-4"})})]}),us&&S(t(Ce==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>_l(Ce==="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(Ce==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Ce==="tree"?n.jsx(P,{name:"code-sslash",className:"size-4"}):n.jsx(P,{name:"node-tree",className:"size-4"})})),Ml&&S(t("filesView.editor.copyFileContents"),n.jsx(B,{variant:"ghost",size:"sm",onClick:async()=>{(await Wn(H)).ok?(bi(!0),Ps.current!==null&&window.clearTimeout(Ps.current),Ps.current=window.setTimeout(()=>{bi(!1)},1200)):q.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:fl?n.jsx(P,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(P,{name:"clipboard",className:"size-4"})})),Pl&&S(t("filesView.editor.copyFilePathTitle",{path:yt}),n.jsx(B,{variant:"ghost",size:"sm",onClick:async()=>{(await Wn(yt)).ok?(yi(!0),Vs.current!==null&&window.clearTimeout(Vs.current),Vs.current=window.setTimeout(()=>{yi(!1)},1200)):q.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:yt}),"aria-label":t("filesView.editor.copyFilePathTitle",{path:yt}),children:ml?n.jsx(P,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(P,{name:"file-copy-2",className:"size-4"})})),a.downloadFile&&S(t("filesView.editor.saveFile"),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>{const V=a.downloadFile;V&&V(d.path,Ss).catch(_=>{console.error("Download failed:",_),q.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:n.jsx(P,{name:"download",className:"size-4"})})),s?S(t("filesView.editor.exitFullscreen"),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>Dt(!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:n.jsx(P,{name:"fullscreen-exit",className:"size-4"})})):!u&&r==="full"&&S(t(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>Dt(!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?n.jsx(P,{name:"fullscreen-exit",className:"size-4"}):n.jsx(P,{name:"fullscreen",className:"size-4"})}))]})},Da=i.useRef(null);i.useEffect(()=>{ae&&(ks.current&&Da.current===ae&&Js(s=>s+1),Da.current=ae)},[ae]);const uc=i.useCallback(async()=>{const s=gt.current;if(!s)throw new Error("No file is open.");const o=ot(s),c=await Hs("/api/fs/raw",{signal:AbortSignal.timeout(6e4),cache:"no-store",query:{path:s,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())},[ot,l,t]),Aa=i.useCallback(s=>{const o=gt.current;o&&(Cs.current[o]="edit"),ct(!1),Ee("edit"),q.error(s)},[]),La=r==="full"&&te,dc=d?`${d.path}:${Ko}:${La?"fullscreen":"docked"}`:"",za=kr&&d&&je?n.jsx("div",{ref:vi,className:"h-full overflow-hidden",style:{minHeight:"400px"},children:n.jsx(Id,{ref:Qt,guestId:je.guestId,editorId:je.editor.id,title:je.editor.title,contentKind:Is?"binary":"text",path:yt||d.path,content:Q,loadBytes:uc,readOnly:!d||nn||!a.writeFile||Is&&!a.uploadFile,onDirtyChange:ct,onEdit:()=>{wi.current=Date.now()},onSaveRequest:Yi,onUnsupported:ql,onTooLarge:()=>Aa(t("filesView.fileEditor.tooLarge",{editor:je.editor.title})),onLoadFailed:()=>Aa(t("filesView.error.readFileFailed"))},`${dc}:${je.guestId}:${je.editor.id}`)}):null,fc=i.useCallback(()=>{const s=Ge.getState();s.requestSettingsJump("integrations","integrations.extensions.excalidraw"),s.setSettingsDialogOpen(!0)},[]),Mr=n.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[n.jsx(yo,{open:or,onOpenChange:s=>{s||Rs(!0)},children:n.jsxs(jo,{showCloseButton:!1,className:"max-w-md",children:[n.jsxs(Co,{children:[n.jsx(So,{children:t("filesView.unsaved.title")}),n.jsx(No,{children:t("filesView.unsaved.description")})]}),n.jsxs(Fo,{children:[n.jsx(B,{variant:"outline",onClick:()=>{Fl()},disabled:Zt,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")}),n.jsx(B,{variant:"destructive",onClick:Nl,children:t("filesView.unsaved.discard")})]})]})}),n.jsxs("div",{className:X("flex flex-col flex-shrink-0",E&&"border-b border-border/40"),children:[E?n.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[u&&ge&&n.jsx("button",{type:"button",onClick:()=>ne(!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:n.jsx(P,{name:"arrow-left-s",className:"size-5"})}),u?d?n.jsxs(Gr,{children:[n.jsx(qr,{asChild:!0,children:n.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:[n.jsx(Ks,{filePath:d.path,extension:d.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(vo,{name:d.name}),n.jsx(P,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),n.jsx(Xr,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Jt.map(s=>{const o=d?.path===s.path;return n.jsxs(Ws,{onSelect:c=>{if(c.target.closest("[data-close-open-file]")){c.preventDefault();return}o||Me(s)},className:X("flex min-w-0 items-center justify-between gap-2 overflow-hidden",o&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[n.jsx(Ks,{filePath:s.path,extension:s.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(vo,{name:s.name})]}),n.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:c=>{c.preventDefault(),c.stopPropagation(),zs(s.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:s.name}),children:n.jsx(P,{name:"close",className:"size-3.5"})})]},s.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")}):Jt.length>0?n.jsxs("div",{className:"relative min-w-0 flex-1",children:[ai.left&&n.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"}),ai.right&&n.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"}),n.jsx("div",{ref:er,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Jt.map(s=>{const o=d?.path===s.path;return n.jsxs("div",{title:Un(l,s.path),className:X("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:[n.jsx(Ks,{filePath:s.path,extension:s.extension,className:"size-3.5 flex-shrink-0"}),n.jsx("button",{type:"button",onClick:()=>{o||Me(s)},className:"max-w-[12rem] truncate text-left",children:s.name}),n.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),zs(s.path)},className:X("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:s.name}),children:n.jsx(P,{name:"close",className:"size-3.5"})})]},s.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")})]}):null,d?n.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:[yt&&!u?n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:yt,children:yt}):null,n.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Va({layout:"docked"})})]}):null]}),Al?n.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:[n.jsx(P,{name:"information",className:"size-4 shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:t("filesView.excalidraw.installHint")}),n.jsx(B,{type:"button",size:"xs",variant:"outline",onClick:fc,children:t("filesView.excalidraw.installAction")})]}):null,n.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:n.jsx(Ir,{ref:sc,outerClassName:"h-full min-w-0",className:X("h-full min-w-0",Ct&&"[overflow-anchor:none]"),children:d?xe||Er?L?n.jsx("div",{className:"p-3"}):n.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.loading")]}):Je?n.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Je}):kr?La?n.jsx("div",{className:"h-full"}):za:Pn||(d&&Os&&Ne==="preview"?n.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:n.jsx(Ld,{ref:fi,xml:Gl,onChange:Kl},`${d.path}:${Wo}`)}):d&&us&&Ce==="tree"?n.jsx(Ln,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.jsonViewerUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToTextMode")})]}),children:n.jsx("div",{className:"h-full overflow-auto",children:n.jsx(zu,{jsonString:H,maxHeight:"100%",initiallyExpandedDepth:2})})}):d&&Ke&&Ie()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:hn,ref:lc,children:[n.jsx(Ja,{containerRef:Ai,filePath:d.path,fileContent:H}),H.length>500*1024&&n.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(H.length/1024)})}),n.jsx(Ln,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:n.jsx("div",{style:ca,children:n.jsx(Or,{content:H,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})})]}),!te&&n.jsx(to,{containerRef:mn,open:Ci,onOpenChange:fn,focusNonce:Si})]}):d&&_t&&Se==="preview"?!m.isVSCode&&Wt.status==="loading"?n.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:t("common.loading")}):n.jsx("div",{className:"h-full overflow-hidden",children:n.jsx("iframe",{src:Wt.status==="ready"?Wt.url:void 0,srcDoc:m.isVSCode?(()=>{const s=d.path.substring(0,d.path.lastIndexOf("/")+1);return s?H.replace(/<head([^>]*)>/i,`<head$1><base href="${s}">`):H})():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&&En&&re==="view"?Pa(d,Q,ba,ec):n.jsxs("div",{className:X("relative h-full",cs&&"overflow-hidden"),ref:Ds,children:[!te&&n.jsx(eo,{open:ji,onOpenChange:dn,view:ye.current}),n.jsx("div",{className:X("h-full",cs&&"invisible"),children:n.jsx(xo,{positionKey:kt,value:Q,onChange:de,readOnly:!He,vimMode:os==="vim",extensions:ha,className:"h-full",blockWidgets:Ql,onViewReady:s=>{ye.current=s,Rn(s),lr(o=>o+1),window.requestAnimationFrame(()=>{hs(s)})},onViewDestroy:()=>{ye.current&&(ye.current=null),lr(s=>s+1)},enableSearch:!0,searchOpen:mt,onSearchOpenChange:At,highlightLines:J?{start:Math.min(J.start,J.end),end:Math.max(J.start,J.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(s,o,c)=>{if(!(c instanceof MouseEvent)||c.button!==0)return!1;c.preventDefault();const g=s.state.doc.lineAt(o.from).number;if(J&&!c.shiftKey&&Math.min(J.start,J.end)===g&&Math.max(J.start,J.end)===g)return Ze(null),Ls(),is.current=!1,Mt.current=null,as(!1),!0;if(u&&J&&!c.shiftKey){const w=Math.min(J.start,J.end,g),S=Math.max(J.start,J.end,g);return Ze({start:w,end:S}),is.current=!1,Mt.current=null,as(!1),!0}if(is.current=!0,Mt.current=g,as(!0),J&&c.shiftKey){const w=Math.min(J.start,g),S=Math.max(J.end,g);Ze({start:w,end:S})}else Ze({start:g,end:g});return!0},mouseover:(s,o,c)=>{if(!(c instanceof MouseEvent)||c.buttons!==1||!is.current||Mt.current===null)return!1;const g=s.state.doc.lineAt(o.from).number,w=Math.min(Mt.current,g),S=Math.max(Mt.current,g);return Ze({start:w,end:S}),as(!0),!1},mouseup:()=>(is.current=!1,Mt.current=null,as(!1),!1)}}},kt)}),cs&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]})):n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:t("filesView.editor.pickFileFromTree")})})})]}),mc=!!(l&&ci[l]),Ia=l?rn[l]:null,Oa=M?n.jsxs("section",{className:X("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:[n.jsx("div",{className:X("flex flex-col gap-2 py-2",u?"px-3":"px-2"),children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1 min-w-0",children:[n.jsx(P,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),n.jsx(qs,{ref:ie,value:$,onChange:s=>U(s.target.value),placeholder:t("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),$.trim().length>0&&n.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:()=>{U(""),ie.current?.focus()},children:n.jsx(P,{name:"close",className:"size-4"})})]}),n.jsxs(Kt,{children:[n.jsx(Gt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>fr("createFile",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.newFileTitle"),"aria-label":t("filesView.tree.actions.newFileTitle"),children:n.jsx(P,{name:"file-add",className:"size-4"})})})}),n.jsx(qt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.newFileTitle")})]}),n.jsxs(Kt,{children:[n.jsx(Gt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>fr("createFolder",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.newFolderTitle"),"aria-label":t("filesView.tree.actions.newFolderTitle"),children:n.jsx(P,{name:"folder-add",className:"size-4"})})})}),n.jsx(qt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.newFolderTitle")})]}),Hi&&n.jsxs(Kt,{children:[n.jsx(Gt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>Ki(l),disabled:!l||bn,className:"size-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":t("sidebarFilesTree.actions.uploadFilesTitle"),children:n.jsx(P,{name:bn?"loader-4":"upload-2",className:X("size-4",bn&&"animate-spin")})})})}),n.jsx(qt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.uploadFilesTitle")})]}),n.jsx(Au,{className:"size-8"}),n.jsxs(Kt,{children:[n.jsx(Gt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(B,{variant:"ghost",size:"sm",onClick:()=>{xn()},className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.refreshTitle"),"aria-label":t("filesView.tree.actions.refreshTitle"),children:n.jsx(P,{name:"refresh",className:"size-4"})})})}),n.jsx(qt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.refreshTitle")})]})]})}),n.jsx(Ir,{outerClassName:"flex-1 min-h-0",className:X("py-2",u?"px-3":"px-2"),children:n.jsx("ul",{className:"flex flex-col",children:Xo?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.tree.search.searching")]}):ui.length>0?ui.map(s=>{const o=d?.path===s.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>{Me(s)},className:X("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:[Uo(s.path,s.extension),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:s.path,children:s.relativePath??s.path})]})},s.path)}):Ia?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"text-[var(--status-error)]",children:Ia}),n.jsxs(B,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{xn()},children:[n.jsx(P,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})]}):mc?ta(l,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("filesView.state.loading")})})})]}):null,hc=r==="full"&&te&&d&&n.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:n.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[n.jsx("div",{className:"absolute right-4 top-4 z-30",children:Va({exitFullscreenOnly:!0})}),n.jsx(Ir,{ref:nc,outerClassName:"h-full min-w-0",className:X("h-full min-w-0",Ct&&"[overflow-anchor:none]"),children:xe||Er?L?n.jsx("div",{className:"p-4"}):n.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Je?n.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Je}):kr?za:Pn||(Ke&&Ie()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:hn,ref:cc,children:[d?n.jsx(Ja,{containerRef:pn,filePath:d.path,fileContent:H}):null,H.length>500*1024&&n.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(H.length/1024)})}),n.jsx(Ln,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:n.jsx("div",{style:ca,children:n.jsx(Or,{content:H,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1,allowRawHtml:!0})})})]}),n.jsx(to,{containerRef:pn,open:Ci,onOpenChange:fn,focusNonce:Si,className:"right-4 top-16"})]}):En&&re==="view"?Pa(d,Q,ya,tc):n.jsxs("div",{className:X("relative h-full",cs&&"overflow-hidden"),children:[n.jsx(eo,{open:ji,onOpenChange:dn,view:ye.current}),n.jsx("div",{className:X("h-full",cs&&"invisible"),children:n.jsx(xo,{positionKey:`${kt}:fullscreen`,value:Q,onChange:de,readOnly:!He,vimMode:os==="vim",extensions:ha,className:"h-full",onViewReady:s=>{ye.current=s,Rn(s),window.requestAnimationFrame(()=>{hs(s)})},onViewDestroy:()=>{ye.current&&(ye.current=null)}},`${kt}:fullscreen`)}),cs&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(P,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]}))})]})});return n.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[n.jsx(Wf,{activeDialog:Bt,dialogData:$t,dialogInputValue:Tt,onDialogInputChange:xi,isDialogSubmitting:ol,onDialogSubmit:Sl,onClose:Zl,inputRef:el}),Cl,hc,u?ge?Mr:Oa:r==="editor-only"?n.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Mr})}):n.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[C>=700&&n.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Oa}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Mr})]})]})};function Gf(r){return r+1}export{gp as FilesView};
|