@vantran-se/openchamber-web 1.24.4 → 2.0.2
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 +2 -8
- package/bin/lib/commands-connect-url.js +3 -8
- package/bin/lib/commands-tunnel.js +3 -0
- package/dist/assets/{CodeMirrorCommentWidgets-B4a0JkUz.js → CodeMirrorCommentWidgets-B82Oye3V.js} +1 -1
- package/dist/assets/DiffView-DJLmWn6Z.js +4 -0
- package/dist/assets/FilesView-DjksmZRo.js +17 -0
- package/dist/assets/{GitView-Byu2DY7s.js → GitView-DiUsUIgr.js} +4 -4
- package/dist/assets/{GuestAttachDialog-B808E0-d.js → GuestAttachDialog-CYwWYLr3.js} +1 -1
- package/dist/assets/GuestSurfacePane-CmctyRI4.js +1 -0
- package/dist/assets/{JsonTreeView-VW_7czo3.js → JsonTreeView-DOHHcbgJ.js} +1 -1
- package/dist/assets/LinearIssuesView-DaqnylcV.js +1 -0
- package/dist/assets/MarkdownImageGallery-HJNvWt7L.js +1 -0
- package/dist/assets/MarkdownRendererImpl-nDZRGg2I.js +12 -0
- package/dist/assets/OnboardingScreen-C2B5Bsof.js +1 -0
- package/dist/assets/{PatchDiff-DCjGhlYV.js → PatchDiff-C4FLBjpt.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CEDZNkU2.js → PierreDiffViewer-C_1S9c9n.js} +1 -1
- package/dist/assets/PlanView-_eZvb-G5.js +5 -0
- package/dist/assets/PluginPane-sM8fcZIV.js +3 -0
- package/dist/assets/SettingsView-BRfr46hb.js +29 -0
- package/dist/assets/SettingsWindow-CcUDwQHg.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-CrN1ZGwl.js +1 -0
- package/dist/assets/ToolOutputDialog-Cij4jI09.js +15 -0
- package/dist/assets/ToolPartDiffPreview-BXzwQ-JY.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-NU0FHFhT.js → VirtualizedFileDiff-DSWTLJNH.js} +4 -4
- package/dist/assets/{WalkthroughView-BZyjhqHv.js → WalkthroughView-CpUUgY8H.js} +2 -2
- package/dist/assets/appThemeRegistry-B5tHTkR8.js +1 -0
- package/dist/assets/{commitAndPush-BDftrjr6.js → commitAndPush-D7D8qV8p.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DlWlEM3x.js → computeVirtualFileMetrics-cq9uQ30i.js} +1 -1
- package/dist/assets/de-CUO1-KqF.js +10 -0
- package/dist/assets/es-BlbC6sGJ.js +16 -0
- package/dist/assets/fr-D2nwe_0W.js +14 -0
- package/dist/assets/index-BQOoYIOu.js +1 -0
- package/dist/assets/index-CLcM8HKx.css +1 -0
- package/dist/assets/index-CvLgnuNI.js +41 -0
- package/dist/assets/{isDiffPlainText-CO4e5J_S.js → isDiffPlainText-D0obJ2p8.js} +1 -1
- package/dist/assets/{isFilePlainText-ue6kCou7.js → isFilePlainText-DB3_rjyW.js} +1 -1
- package/dist/assets/ja-CA7vnDsZ.js +16 -0
- package/dist/assets/ko-Chy6a9l-.js +16 -0
- package/dist/assets/main-B9JFK3vF.js +896 -0
- package/dist/assets/main-Bhiqnrhd.js +2 -0
- package/dist/assets/{markdownCore-CK48LG0z.js → markdownCore-tfqOFaBd.js} +4 -4
- package/dist/assets/miniChat-B0UOL5zA.js +2 -0
- package/dist/assets/mobile-BJppFIEo.js +2 -0
- package/dist/assets/{patchFileDiff-D7QVlovD.js → patchFileDiff-Db6KuwCP.js} +3 -3
- package/dist/assets/pl-CTR5A_1P.js +16 -0
- package/dist/assets/pt-BR-BE1O1KEx.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-Yz5sfoFh.js +2 -0
- package/dist/assets/renderMobileApp-QQ-yB8aY.js +25 -0
- package/dist/assets/runtimeEndpointReset-DKDdzRzm.js +27 -0
- package/dist/assets/scheduledTasksApi-C5sCuNqf.js +1 -0
- package/dist/assets/{shikiHighlight-BPu3JiQs.js → shikiHighlight-xURoo5t_.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-DWqRPo9A.js → textMateThemeFromAppTheme-BZLGuYTU.js} +1 -1
- package/dist/assets/tr-Bh5vK6cW.js +7 -0
- package/dist/assets/uk-CLDkZFy_.js +16 -0
- package/dist/assets/useAppFontEffects-BxrtCnfR.js +7337 -0
- package/dist/assets/{useInlineCommentController-CgS0fnw_.js → useInlineCommentController-CeXuR-SR.js} +2 -2
- package/dist/assets/useRootScrollLock-DgWxezc1.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-Bx2EHc1O.js → vendor-codemirror-language-data-DOuaQUZ0.js} +2 -2
- package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
- package/dist/assets/vendor-opencode-client-_BAHQo4R.js +12 -0
- package/dist/assets/{vendor-remixicon-react-BDmGmFCA.js → vendor-remixicon-react-D6dZ0UwF.js} +1 -1
- package/dist/assets/{vendor-zod-CgAdXWZO.js → vendor-zod-Gea9uBlY.js} +1 -1
- package/dist/assets/{web-components-DxX8bZ1o.js → web-components-63H1h21j.js} +2 -2
- package/dist/assets/zh-CN-DODgcmYj.js +16 -0
- package/dist/assets/zh-TW-ByNfIwLA.js +16 -0
- package/dist/index.html +13 -7
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +6 -5
- package/server/index.d.ts +1 -0
- package/server/index.js +246 -91
- package/server/lib/agent-tool/DOCUMENTATION.md +32 -15
- package/server/lib/agent-tool/runtime.js +135 -54
- package/server/lib/agent-tool/runtime.test.js +155 -87
- package/server/lib/browser-control/DOCUMENTATION.md +37 -2
- package/server/lib/browser-control/provider.js +217 -0
- package/server/lib/browser-control/provider.test.js +251 -0
- package/server/lib/context-obligatory/runtime.js +61 -50
- package/server/lib/context-obligatory/runtime.test.js +62 -162
- package/server/lib/event-stream/DOCUMENTATION.md +12 -1
- package/server/lib/event-stream/delta-coalescer.js +0 -0
- package/server/lib/event-stream/delta-coalescer.test.js +68 -57
- package/server/lib/event-stream/directory-ws-bridge.js +1 -1
- package/server/lib/event-stream/global-hub.js +10 -1
- package/server/lib/event-stream/global-hub.test.js +27 -26
- package/server/lib/event-stream/index.js +6 -0
- package/server/lib/event-stream/protocol.js +26 -19
- package/server/lib/event-stream/protocol.test.js +18 -7
- package/server/lib/event-stream/rebind.test.js +5 -5
- package/server/lib/event-stream/runtime.test.js +17 -15
- package/server/lib/event-stream/translate-v2.js +313 -0
- package/server/lib/event-stream/translate-v2.test.js +209 -0
- package/server/lib/event-stream/upstream-reader.test.js +16 -16
- package/server/lib/fs/DOCUMENTATION.md +4 -2
- package/server/lib/fs/byte-range.js +35 -0
- package/server/lib/fs/byte-range.test.js +31 -0
- package/server/lib/fs/routes.js +47 -42
- package/server/lib/fs/routes.test.js +123 -18
- package/server/lib/git/service.js +12 -0
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/github/pr-status.js +22 -2
- package/server/lib/github/pr-status.test.js +27 -14
- package/server/lib/guests/DOCUMENTATION.md +13 -0
- package/server/lib/guests/catalog.js +12 -0
- package/server/lib/guests/catalog.test.js +33 -0
- package/server/lib/guests/routes.js +10 -1
- package/server/lib/guests/service.js +192 -14
- package/server/lib/guests/service.test.js +201 -1
- package/server/lib/guests/surface.js +630 -0
- package/server/lib/guests/surface.test.js +486 -0
- package/server/lib/markdown-image-grants/routes.js +18 -5
- package/server/lib/markdown-image-grants/routes.test.js +9 -6
- package/server/lib/message-queue/DOCUMENTATION.md +33 -22
- package/server/lib/message-queue/runtime.js +155 -100
- package/server/lib/message-queue/runtime.test.js +168 -82
- package/server/lib/notifications/DOCUMENTATION.md +28 -0
- package/server/lib/notifications/control-stream.http.test.js +68 -0
- package/server/lib/notifications/emitter-runtime.js +15 -0
- package/server/lib/notifications/emitter-runtime.test.js +32 -0
- package/server/lib/notifications/push-runtime.js +5 -1
- package/server/lib/notifications/push-runtime.test.js +2 -2
- package/server/lib/notifications/routes.js +1 -1
- package/server/lib/notifications/runtime.js +115 -26
- package/server/lib/notifications/template-runtime.js +13 -15
- package/server/lib/notifications/template-runtime.test.js +16 -9
- package/server/lib/notifications/trigger-runtime.test.js +187 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +10 -0
- package/server/lib/openchamber-control/actions.js +3 -2
- package/server/lib/openchamber-control/error.js +1 -1
- package/server/lib/openchamber-control/file-open.js +59 -0
- package/server/lib/openchamber-control/file-open.test.js +57 -0
- package/server/lib/openchamber-control/routes.test.js +12 -0
- package/server/lib/openchamber-control/service.js +102 -49
- package/server/lib/openchamber-control/service.test.js +84 -44
- package/server/lib/openchamber-sessions/archive-store.js +224 -0
- package/server/lib/openchamber-sessions/archive-store.test.js +187 -0
- package/server/lib/openchamber-sessions/opencode-client.js +22 -0
- package/server/lib/openchamber-sessions/routes.js +398 -328
- package/server/lib/openchamber-sessions/routes.test.js +777 -740
- package/server/lib/openchamber-sessions/session-metadata-store.js +285 -0
- package/server/lib/openchamber-sessions/session-metadata-store.test.js +259 -0
- package/server/lib/opencode/DOCUMENTATION.md +449 -29
- package/server/lib/opencode/agents.js +233 -327
- package/server/lib/opencode/auth.js +41 -44
- package/server/lib/opencode/auth.test.js +92 -0
- package/server/lib/opencode/cli-upgrade.d.ts +4 -0
- package/server/lib/opencode/cli-upgrade.js +18 -0
- package/server/lib/opencode/cli-upgrade.test.js +36 -0
- package/server/lib/opencode/commands.js +164 -145
- package/server/lib/opencode/compatibility.d.ts +16 -0
- package/server/lib/opencode/compatibility.js +88 -0
- package/server/lib/opencode/compatibility.test.js +62 -0
- package/server/lib/opencode/config-entity-routes.js +58 -29
- package/server/lib/opencode/config-entity-v2.test.js +290 -0
- package/server/lib/opencode/config-mutation-response.js +17 -7
- package/server/lib/opencode/config-mutation-response.test.js +4 -7
- package/server/lib/opencode/config-paths.test.js +2 -2
- package/server/lib/opencode/config-v2.d.ts +183 -0
- package/server/lib/opencode/config-v2.js +801 -0
- package/server/lib/opencode/config-v2.test.js +466 -0
- package/server/lib/opencode/credential-db.js +144 -0
- package/server/lib/opencode/credential-db.test.js +104 -0
- package/server/lib/opencode/env-runtime.js +48 -9
- package/server/lib/opencode/env-runtime.test.js +45 -0
- package/server/lib/opencode/feature-routes-runtime.js +15 -5
- package/server/lib/opencode/lifecycle-process.test.js +7 -4
- package/server/lib/opencode/lifecycle.js +85 -30
- package/server/lib/opencode/lifecycle.test.js +80 -8
- package/server/lib/opencode/login-shell-env.js +27 -0
- package/server/lib/opencode/managed-config-file.js +119 -0
- package/server/lib/opencode/managed-config-file.test.js +152 -0
- package/server/lib/opencode/managed-plugin-config.js +33 -13
- package/server/lib/opencode/mcp.js +43 -149
- package/server/lib/opencode/network-runtime.js +6 -7
- package/server/lib/opencode/openchamber-routes.test.js +2 -5
- package/server/lib/opencode/plugin-routes.js +3 -3
- package/server/lib/opencode/plugin-routes.test.js +6 -24
- package/server/lib/opencode/plugins.js +91 -40
- package/server/lib/opencode/plugins.test.js +28 -15
- package/server/lib/opencode/providers.js +63 -83
- package/server/lib/opencode/providers.test.js +128 -59
- package/server/lib/opencode/proxy-agent-wiring.test.js +4 -2
- package/server/lib/opencode/proxy.js +179 -129
- package/server/lib/opencode/pwa-manifest-routes.js +4 -2
- package/server/lib/opencode/pwa-manifest-routes.test.js +3 -2
- package/server/lib/opencode/response-envelope.js +14 -0
- package/server/lib/opencode/response-envelope.test.js +23 -0
- package/server/lib/opencode/routes-upgrade.test.js +73 -116
- package/server/lib/opencode/routes.js +121 -428
- package/server/lib/opencode/server-utils-runtime.js +10 -4
- package/server/lib/opencode/session-activity.js +78 -0
- package/server/lib/opencode/session-runtime.js +21 -10
- package/server/lib/opencode/session-runtime.test.js +9 -9
- package/server/lib/opencode/settings-helpers.js +9 -9
- package/server/lib/opencode/settings-helpers.test.js +7 -12
- package/server/lib/opencode/settings-registry.json +6 -8
- package/server/lib/opencode/settings-runtime.js +18 -1
- package/server/lib/opencode/settings-runtime.test.js +31 -2
- package/server/lib/opencode/shared.js +54 -22
- package/server/lib/opencode/shared.test.js +8 -4
- package/server/lib/opencode/shutdown-runtime.js +54 -7
- package/server/lib/opencode/shutdown-runtime.test.js +224 -30
- package/server/lib/opencode/skill-routes.js +23 -24
- package/server/lib/opencode/skills.js +7 -5
- package/server/lib/opencode/tunnel-wiring-runtime.js +2 -1
- package/server/lib/opencode/upgrade-capability.test.js +1 -1
- package/server/lib/opencode/v1-migration-topup.js +288 -0
- package/server/lib/opencode/v1-migration-topup.test.js +266 -0
- package/server/lib/opencode/v2-install.d.ts +8 -0
- package/server/lib/opencode/v2-install.js +158 -0
- package/server/lib/opencode/v2-install.test.js +124 -0
- package/server/lib/opencode/watcher.js +10 -3
- package/server/lib/opencode/watcher.test.js +17 -21
- package/server/lib/opencode/websearch-config.js +66 -0
- package/server/lib/package-manager.js +55 -68
- package/server/lib/package-manager.test.js +241 -75
- package/server/lib/permission-auto-accept/runtime.js +38 -22
- package/server/lib/permission-auto-accept/runtime.test.js +39 -17
- package/server/lib/quota/DOCUMENTATION.md +4 -0
- package/server/lib/quota/providers/xai.js +4 -4
- package/server/lib/relay/tunnel-host.js +4 -1
- package/server/lib/relay/tunnel-host.test.js +7 -0
- package/server/lib/routing/DOCUMENTATION.md +52 -21
- package/server/lib/routing/defaults.js +23 -6
- package/server/lib/routing/jev.js +17 -7
- package/server/lib/routing/routes.http.test.js +68 -33
- package/server/lib/routing/routes.js +65 -22
- package/server/lib/routing/runtime.js +145 -48
- package/server/lib/routing/runtime.test.js +79 -55
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -0
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +51 -46
- package/server/lib/scheduled-tasks/runtime.js +81 -74
- package/server/lib/scheduled-tasks/runtime.test.js +53 -1
- package/server/lib/session-assist/DOCUMENTATION.md +8 -3
- package/server/lib/session-assist/context.js +122 -46
- package/server/lib/session-assist/context.test.js +117 -49
- package/server/lib/session-assist/runtime.js +52 -22
- package/server/lib/session-assist/runtime.test.js +145 -173
- package/server/lib/session-goal/DOCUMENTATION.md +23 -15
- package/server/lib/session-goal/create.js +9 -12
- package/server/lib/session-goal/create.test.js +27 -28
- package/server/lib/session-goal/runtime.js +164 -77
- package/server/lib/session-goal/runtime.test.js +271 -519
- package/server/lib/session-knowledge/DOCUMENTATION.md +5 -0
- package/server/lib/session-knowledge/runtime.js +59 -41
- package/server/lib/session-knowledge/runtime.test.js +90 -20
- package/server/lib/small-model/DOCUMENTATION.md +154 -208
- package/server/lib/small-model/client.js +113 -0
- package/server/lib/small-model/index.js +296 -158
- package/server/lib/small-model/index.test.js +423 -256
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/spaces/DOCUMENTATION.md +807 -0
- package/server/lib/spaces/code-in-bait.js +185 -0
- package/server/lib/spaces/code-in.js +641 -0
- package/server/lib/spaces/code-in.test.js +1048 -0
- package/server/lib/spaces/errors.js +8 -0
- package/server/lib/spaces/exec-http.js +94 -0
- package/server/lib/spaces/gatekeeper-channel.js +202 -0
- package/server/lib/spaces/gatekeeper-channel.test.js +215 -0
- package/server/lib/spaces/gatekeeper-program.cjs +914 -0
- package/server/lib/spaces/gatekeeper-program.test.js +1391 -0
- package/server/lib/spaces/hardening.js +457 -0
- package/server/lib/spaces/hardening.test.js +368 -0
- package/server/lib/spaces/host-git.js +127 -0
- package/server/lib/spaces/host-git.test.js +137 -0
- package/server/lib/spaces/labels.js +234 -0
- package/server/lib/spaces/labels.test.js +219 -0
- package/server/lib/spaces/layout.js +184 -0
- package/server/lib/spaces/layout.test.js +30 -0
- package/server/lib/spaces/manager.js +82 -0
- package/server/lib/spaces/manager.test.js +114 -0
- package/server/lib/spaces/places/code-in.docker.live.test.js +216 -0
- package/server/lib/spaces/places/contract-suite.js +156 -0
- package/server/lib/spaces/places/contract.docker.live.test.js +7 -0
- package/server/lib/spaces/places/contract.test.js +6 -0
- package/server/lib/spaces/places/docker-engine.js +126 -0
- package/server/lib/spaces/places/docker-live-support.js +202 -0
- package/server/lib/spaces/places/docker-tools.js +186 -0
- package/server/lib/spaces/places/docker.js +587 -0
- package/server/lib/spaces/places/docker.test.js +1610 -0
- package/server/lib/spaces/places/escape-suite.js +1018 -0
- package/server/lib/spaces/places/escape.docker.live.test.js +7 -0
- package/server/lib/spaces/places/fake-docker.js +375 -0
- package/server/lib/spaces/places/memory-place.js +103 -0
- package/server/lib/spaces/places/packed.docker.live.test.js +77 -0
- package/server/lib/spaces/places/registry.js +43 -0
- package/server/lib/spaces/places/registry.test.js +50 -0
- package/server/lib/spaces/places/server.docker.live.test.js +225 -0
- package/server/lib/spaces/run-command.js +261 -0
- package/server/lib/spaces/run-command.test.js +396 -0
- package/server/lib/spaces/space-server.js +190 -0
- package/server/lib/spaces/space-server.test.js +335 -0
- package/server/lib/spaces/tools-filler.js +82 -0
- package/server/lib/spaces/tools-filler.test.js +148 -0
- package/server/lib/spaces/tools-pack.js +49 -0
- package/server/lib/spaces/tools-pack.test.js +57 -0
- package/server/lib/spaces/tools.js +138 -0
- package/server/lib/spaces/tools.test.js +153 -0
- package/server/lib/tts/openai-sdk.js +11 -0
- package/server/lib/tts/service.js +7 -5
- package/server/lib/tts/stt.js +3 -2
- package/server/lib/tunnels/DOCUMENTATION.md +2 -0
- package/server/lib/tunnels/routes.js +7 -0
- package/server/lib/tunnels/routes.test.js +55 -0
- package/server/lib/ui-auth/ui-auth.js +38 -2
- package/server/lib/ui-auth/ui-auth.test.js +42 -0
- package/server/lib/ui-auth/ui-passkeys.js +12 -10
- package/server/lib/walkthrough/DOCUMENTATION.md +10 -1
- package/server/lib/walkthrough/pull-request.js +61 -8
- package/server/lib/walkthrough/pull-request.test.js +54 -1
- package/server/lib/walkthrough/routes.js +20 -0
- package/server/lib/walkthrough/routes.test.js +19 -0
- package/server/opencode-proxy.test.js +190 -166
- package/server/opencode-worktree-readiness.test.js +5 -4
- package/dist/assets/DiffView-B2CD9wC8.js +0 -4
- package/dist/assets/FilesView-C4vMFclc.js +0 -13
- package/dist/assets/LinearIssuesView-EzGNCGrd.js +0 -1
- package/dist/assets/MarkdownImageGallery-B2YUDFaB.js +0 -1
- package/dist/assets/MarkdownRendererImpl-B4ikIzR3.js +0 -12
- package/dist/assets/OnboardingScreen-CQHBSTEi.js +0 -1
- package/dist/assets/PlanView-D3x-pTkZ.js +0 -5
- package/dist/assets/PluginPane-DEcgDQ9h.js +0 -3
- package/dist/assets/SettingsView-CSinuH-1.js +0 -29
- package/dist/assets/SettingsWindow-B5CHoJFZ.js +0 -1
- package/dist/assets/SubmoduleDiffSummary-oxeACCWs.js +0 -1
- package/dist/assets/ToolOutputDialog-tLNWmfcW.js +0 -15
- package/dist/assets/ToolPartDiffPreview-CflzmK-x.js +0 -8
- package/dist/assets/appThemeRegistry-DLicw4dH.js +0 -1
- package/dist/assets/de-Bro6_zyl.js +0 -10
- package/dist/assets/es-Bb9XQZvd.js +0 -16
- package/dist/assets/fr-Dgfzn-IL.js +0 -14
- package/dist/assets/index-CtQNmqUL.js +0 -1
- package/dist/assets/index-DqaMWNrC.css +0 -1
- package/dist/assets/index-Dqc6USl3.js +0 -40
- package/dist/assets/ja-BYsakGFh.js +0 -16
- package/dist/assets/ko-BSaQz9aN.js +0 -16
- package/dist/assets/main-B62_pjL5.js +0 -2
- package/dist/assets/main-BEdcOI2P.js +0 -896
- package/dist/assets/miniChat-LT8Rqofr.js +0 -2
- package/dist/assets/mobile-CqarEynh.js +0 -2
- package/dist/assets/pl-OIviPdoj.js +0 -16
- package/dist/assets/pt-BR-Cltg-E6s.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-COyLTtZx.js +0 -2
- package/dist/assets/renderMobileApp-BC1MHg6g.js +0 -25
- package/dist/assets/runtimeEndpointReset-DdrazOVH.js +0 -25
- package/dist/assets/scheduledTasksApi-B2SWMGEU.js +0 -1
- package/dist/assets/tr-CQI-KPre.js +0 -7
- package/dist/assets/uk-CqW7R4DA.js +0 -16
- package/dist/assets/useAppFontEffects-ne84JBVL.js +0 -7333
- package/dist/assets/useRootScrollLock-Cpf1qoGp.js +0 -2
- package/dist/assets/vendor-cron-parser-CUcP7OfX.js +0 -2
- package/dist/assets/vendor-opencode-sdk-BJ73u-bH.js +0 -7
- package/dist/assets/zh-CN-CVZG_o_J.js +0 -16
- package/dist/assets/zh-TW-D5ZxzCZp.js +0 -16
- package/server/lib/opencode/mcp-oauth-callback.test.js +0 -111
- package/server/lib/routing/feature-flag.js +0 -11
- package/server/lib/small-model/call.js +0 -851
- package/server/lib/small-model/call.test.js +0 -1292
- package/server/lib/small-model/catalog.js +0 -13
- package/server/lib/small-model/resolve.js +0 -131
- package/server/lib/small-model/resolve.test.js +0 -197
- package/server/lib/small-model/runtime-providers.js +0 -164
- package/server/lib/small-model/runtime-providers.test.js +0 -118
- package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
- package/server/lib/system-prompt/runtime.js +0 -49
- package/server/lib/system-prompt/runtime.test.js +0 -76
- package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.com/openchamber/openchamber/raw/HEAD/docs/references/badges/openchamber-logo-dark.svg"><img src="https://github.com/openchamber/openchamber/raw/HEAD/docs/references/badges/openchamber-logo-light.svg" width="32" height="32" align="absmiddle" /></picture> @
|
|
1
|
+
# <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.com/openchamber/openchamber/raw/HEAD/docs/references/badges/openchamber-logo-dark.svg"><img src="https://github.com/openchamber/openchamber/raw/HEAD/docs/references/badges/openchamber-logo-light.svg" width="32" height="32" align="absmiddle" /></picture> @openchamber/web
|
|
2
2
|
|
|
3
3
|
[](https://github.com/openchamber/openchamber/stargazers)
|
|
4
4
|
[](https://github.com/openchamber/openchamber/releases/latest)
|
|
@@ -14,13 +14,7 @@ Full project overview, screenshots, and all features: [github.com/openchamber/op
|
|
|
14
14
|
curl -fsSL https://raw.githubusercontent.com/openchamber/openchamber/main/scripts/install.sh | bash
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install -g @vantran-se/openchamber-web
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
The package keeps the `openchamber` command and updates from the same npm package.
|
|
17
|
+
Or install manually: `bun add -g @openchamber/web` (or npm, pnpm, yarn).
|
|
24
18
|
|
|
25
19
|
> **Prerequisites:** [OpenCode CLI](https://opencode.ai) installed, Node.js 22+.
|
|
26
20
|
|
|
@@ -308,14 +308,9 @@ function createConnectUrlCommand({ serveCommand }) {
|
|
|
308
308
|
} else if (resolvedServerUrl.source === 'loopback-fallback') {
|
|
309
309
|
clackLog.warn('OpenChamber is bound to all interfaces, but no LAN address was detected. Use --server to provide a reachable URL.');
|
|
310
310
|
} else if (isLoopbackServerUrl(serverUrl)) {
|
|
311
|
-
// The
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
if (options.relay) {
|
|
315
|
-
logStatus('warn', '[LAN_UNREACHABLE]', 'OpenChamber only listens on this machine, so devices will always connect through the relay. Restart with --lan to allow direct home-network connections.');
|
|
316
|
-
} else {
|
|
317
|
-
logStatus('warn', '[LAN_UNREACHABLE]', 'OpenChamber only listens on this machine, so other devices cannot use this link. Restart with --lan, or use --server to provide a reachable URL.');
|
|
318
|
-
}
|
|
311
|
+
// The advertised address does not establish how the server is bound.
|
|
312
|
+
// Localhost can also be intentional, including Windows-to-WSL forwarding.
|
|
313
|
+
logStatus('info', '[LOOPBACK_URL]', 'This link uses localhost for direct connections. For another device, use --server with a reachable address or include --relay.');
|
|
319
314
|
}
|
|
320
315
|
clackLog.info('Scan or paste this link into another OpenChamber client. It is single-use and expires.');
|
|
321
316
|
if (options.qr === true) {
|
|
@@ -1585,6 +1585,9 @@ async function tunnelCommand(options, subcommand, action, deps) {
|
|
|
1585
1585
|
|
|
1586
1586
|
if (!response.ok || !body?.ok) {
|
|
1587
1587
|
spin?.error('Tunnel start failed');
|
|
1588
|
+
if (body?.code === 'ui_password_required') {
|
|
1589
|
+
throw new Error(body.error);
|
|
1590
|
+
}
|
|
1588
1591
|
const baseError = body?.error || `Tunnel start failed (${response.status})`;
|
|
1589
1592
|
const isCloudflareTimeout = /context deadline exceeded|Client\.Timeout exceeded while awaiting headers|failed to request quick Tunnel/i.test(baseError);
|
|
1590
1593
|
const userError = isCloudflareTimeout
|
package/dist/assets/{CodeMirrorCommentWidgets-B4a0JkUz.js → CodeMirrorCommentWidgets-B82Oye3V.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-
|
|
1
|
+
import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-CeXuR-SR.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{R as i,f as tt,j as n}from"./vendor-react-BUCujlKS.js";import{u as me,O as Fe,B as Ln,a as De,G as Mn}from"./index-CvLgnuNI.js";import{c as Tn,b as Bn,u as In,a as Pn,B as _n,C as On,P as Gt,h as zn,e as Kn,g as Gn,i as Hn,f as $n}from"./patchFileDiff-Db6KuwCP.js";import{c as qn,b as Wn,i as Un,u as Jn,a as Xn,d as Yn,S as Qn}from"./SubmoduleDiffSummary-CrN1ZGwl.js";import{f as qe,B as ke,I as z,h as Ae,_ as en,ai as Zn,K as ae,aj as es,bj as ts,J as ns,ak as ss,am as rs,z as Ht,k as is,d9 as tn,t as $e,kX as os,az as et,kM as nn,kY as as,aA as sn,gV as ls,ax as Ze,ay as cs,c8 as rn,at as us,av as ds,aw as fs,as as ms}from"./useAppFontEffects-BxrtCnfR.js";import{j as ps,f as hs}from"./runtimeEndpointReset-DKDdzRzm.js";import{P as gs}from"./PierreDiffViewer-C_1S9c9n.js";import{u as xs,v as ys,g as ws,W as bs}from"./main-B9JFK3vF.js";import{p as js}from"./VirtualizedFileDiff-DSWTLJNH.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DOuaQUZ0.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-CYwWYLr3.js";import"./PluginPane-sM8fcZIV.js";import"./web-components-63H1h21j.js";import"./computeVirtualFileMetrics-cq9uQ30i.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-CeXuR-SR.js";import"./appThemeRegistry-B5tHTkR8.js";import"./textMateThemeFromAppTheme-BZLGuYTU.js";import"./vendor-katex-CHD9BdDO.js";import"./useRootScrollLock-DgWxezc1.js";import"./scheduledTasksApi-C5sCuNqf.js";import"./vendor-cron-parser-CjvYVigk.js";import"./vendor-luxon-BZ0puJYg.js";import"./isDiffPlainText-D0obJ2p8.js";import"./vendor-diff-C3JhlQdm.js";const vs=i.memo(function(e){const s=tt.c(13),{index:c,staged:y,busyHunk:p,disabled:b,onAction:v}=e,{t:F}=qe();let l;s[0]!==y?(l=y?["unstage"]:["discard","stage"],s[0]=y,s[1]=l):l=s[1];const j=l;let N;s[2]===Symbol.for("react.memo_cache_sentinel")?(N={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=N):N=s[2];let f;s[3]!==j||s[4]!==p||s[5]!==b||s[6]!==c||s[7]!==v||s[8]!==F?(f=n.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:j.map(w=>{const D=F(w==="stage"?"diffView.hunk.stageTitle":w==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:c+1}),_=p?.index===c&&p.action===w;return n.jsx(ke,{variant:"ghost",size:"xs",className:Ae("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",w==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",w==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:b||p!==null,title:D,"aria-label":D,onPointerDown:Ss,onClick:m=>{m.stopPropagation(),v(c,w)},children:n.jsx(z,{name:_?"loader-4":w==="stage"?"add":"arrow-go-back",className:Ae(w==="stage"?"size-4":"size-3.5",_&&"animate-spin")})},w)})}),s[3]=j,s[4]=p,s[5]=b,s[6]=c,s[7]=v,s[8]=F,s[9]=f):f=s[9];let V;return s[10]!==c||s[11]!==f?(V=n.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:N,"data-hunk-actions":c,children:f}),s[10]=c,s[11]=f,s[12]=V):V=s[12],V});function Ss(o){return o.stopPropagation()}const $t=(o,e)=>{if(e.length===0)return null;let s=null,c=null;for(const p of e)p.top<=o?(!s||p.top>s.top)&&(s=p):(!c||p.top<c.top)&&(c=p);const y=s??c;return y?{path:y.path,topOffset:y.top-o}:null},ks=(o,e,s,c)=>Math.min(Math.max(0,c),Math.max(0,o+s-e)),qt=o=>{if(!o)return null;const e=o.split(`
|
|
2
|
+
`);let s=null;for(const c of e){const y=c.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(y){const p=Number.parseInt(y[1]??"",10);s=Number.isFinite(p)&&p>=1?p:null;continue}if(s!==null){if(c.startsWith(" ")){s+=1;continue}if(c.startsWith("+"))return s;if(c.startsWith("-"))return Math.max(1,s)}}return null},Ns=1100,Cs=15e3,Wt=500,Ut=300,on=1e6,Ct=3,Rs=o=>o<=6?o:o<=12?6:o<=25?4:2,Jt={status:"loading"},Fs=3,Ds=i.memo(()=>{const o=tt.c(4),{t:e}=qe();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let c;return o[2]!==s?(c=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=c):c=o[3],c}),an={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},As=an.M,Es=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},ln=o=>{const e=Es(o);return an[e]??As},Vs=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},Xt=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Yt=o=>!!o.working_dir?.trim()||o.index==="?",Ls=(o,e)=>ls(o,e),Qt=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Zt=(o,e)=>{const s=o.split(`
|
|
3
|
+
`),c=e.split(`
|
|
4
|
+
`),y=Math.min(s.length,c.length);for(let p=0;p<y;p+=1)if(s[p]!==c[p])return p+1;return c.length>s.length?s.length+1:s.length>c.length?Math.max(1,c.length):1},Ms=o=>o==="added"?"A":o==="deleted"?"D":"M",Rt=(o,e,s)=>Hn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:$n(o,e),contextMode:s},cn=(o,e,s)=>{const c=o??0,y=e??0;return!c&&!y?null:n.jsxs("span",{className:Ae("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[c?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",c]}):null,y?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",y]}):null]})},Ts=i.memo(o=>{const e=tt.c(68),{scope:s,workingCount:c,stagedCount:y,turnCount:p,branchCount:b,commitCount:v,prCount:F,showCommitOption:l,showBranchOption:j,onScopeChange:N}=o,{t:f}=qe(),[V,w]=i.useState(!1),D=s==="pr"?F??0:s==="staged"?y:s==="turn"?p:s==="branch"?b??0:s==="commit"?v??0:c;let _;e[0]!==s||e[1]!==f?(_=f(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=f,e[2]=_):_=e[2];const m=_;let be;e[3]!==f?(be=f("diffView.scope.selectorAria"),e[3]=f,e[4]=be):be=e[4];let Z;e[5]!==D?(Z=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",D]}),e[5]=D,e[6]=Z):Z=e[6];let ee;e[7]!==m||e[8]!==Z?(ee=n.jsxs("span",{className:"whitespace-nowrap",children:[m,Z]}),e[7]=m,e[8]=Z,e[9]=ee):ee=e[9];let Ne;e[10]===Symbol.for("react.memo_cache_sentinel")?(Ne=n.jsx(z,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=Ne):Ne=e[10];let q;e[11]!==be||e[12]!==ee?(q=n.jsx(us,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":be,children:[ee,Ne]})}),e[11]=be,e[12]=ee,e[13]=q):q=e[13];let x;e[14]!==N?(x=H=>{(H==="working"||H==="staged"||H==="turn"||H==="branch"||H==="commit"||H==="pr")&&(N?.(H),w(!1))},e[14]=N,e[15]=x):x=e[15];let P;e[16]!==f?(P=f("diffView.scope.changed"),e[16]=f,e[17]=P):P=e[17];let W;e[18]!==P?(W=n.jsx("span",{children:P}),e[18]=P,e[19]=W):W=e[19];let le;e[20]!==c?(le=n.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),e[20]=c,e[21]=le):le=e[21];let te;e[22]!==le||e[23]!==W?(te=n.jsx(Ze,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[W,le]})}),e[22]=le,e[23]=W,e[24]=te):te=e[24];let pe;e[25]!==f?(pe=f("diffView.scope.staged"),e[25]=f,e[26]=pe):pe=e[26];let ne;e[27]!==pe?(ne=n.jsx("span",{children:pe}),e[27]=pe,e[28]=ne):ne=e[28];let he;e[29]!==y?(he=n.jsx("span",{className:"typography-meta text-muted-foreground",children:y}),e[29]=y,e[30]=he):he=e[30];let J;e[31]!==ne||e[32]!==he?(J=n.jsx(Ze,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[ne,he]})}),e[31]=ne,e[32]=he,e[33]=J):J=e[33];let I;e[34]!==f?(I=f("diffView.scope.lastTurn"),e[34]=f,e[35]=I):I=e[35];let se;e[36]!==I?(se=n.jsx("span",{children:I}),e[36]=I,e[37]=se):se=e[37];let X;e[38]!==p?(X=n.jsx("span",{className:"typography-meta text-muted-foreground",children:p}),e[38]=p,e[39]=X):X=e[39];let K;e[40]!==se||e[41]!==X?(K=n.jsx(Ze,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[se,X]})}),e[40]=se,e[41]=X,e[42]=K):K=e[42];let je;e[43]!==b||e[44]!==j||e[45]!==f?(je=j?n.jsx(Ze,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:f("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:b??"…"})]})}):null,e[43]=b,e[44]=j,e[45]=f,e[46]=je):je=e[46];let A;e[47]!==v||e[48]!==l||e[49]!==f?(A=l&&n.jsx(Ze,{value:"commit",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:f("commitComparison.mode")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:v??"…"})]})}),e[47]=v,e[48]=l,e[49]=f,e[50]=A):A=e[50];let G;e[51]!==F||e[52]!==l||e[53]!==f?(G=l&&n.jsx(Ze,{value:"pr",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:f("session.githubIntegration.tabs.pullRequests")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:F??"…"})]})}),e[51]=F,e[52]=l,e[53]=f,e[54]=G):G=e[54];let C;e[55]!==s||e[56]!==te||e[57]!==J||e[58]!==K||e[59]!==je||e[60]!==A||e[61]!==G||e[62]!==x?(C=n.jsx(ds,{align:"start",className:"w-40",children:n.jsxs(fs,{value:s,onValueChange:x,children:[te,J,K,je,A,G]})}),e[55]=s,e[56]=te,e[57]=J,e[58]=K,e[59]=je,e[60]=A,e[61]=G,e[62]=x,e[63]=C):C=e[63];let ce;return e[64]!==V||e[65]!==C||e[66]!==q?(ce=n.jsxs(ms,{open:V,onOpenChange:w,children:[q,C]}),e[64]=V,e[65]=C,e[66]=q,e[67]=ce):ce=e[67],ce}),Bs=i.memo(o=>{const e=tt.c(11),{changedFiles:s,selectedFile:c,onSelectFile:y}=o,{t:p}=qe();if(s.length===0)return null;let b;if(e[0]!==s||e[1]!==y||e[2]!==c||e[3]!==p){let F;e[5]!==y||e[6]!==c||e[7]!==p?(F=l=>{const j=ln(l),N=c===l.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>y(l.path),className:Ae("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",N?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(sn,{filePath:l.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:j.color},title:p(j.descriptionKey),"aria-label":p(j.descriptionKey),children:j.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:l.path,children:l.path}),cn(l.insertions,l.deletions)]})},l.path)},e[5]=y,e[6]=c,e[7]=p,e[8]=F):F=e[8],b=s.map(F),e[0]=s,e[1]=y,e[2]=c,e[3]=p,e[4]=b}else b=e[4];let v;return e[9]!==b?(v=n.jsx(rn,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:b})}),e[9]=b,e[10]=v):v=e[10],v}),Is=i.memo(o=>{const e=tt.c(20),{filePath:s,diff:c,renderSideBySide:y}=o,{t:p}=qe(),b=c.original.length>0,v=c.modified.length>0,F=y?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",l=y?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={contain:"layout"},e[0]=j):j=e[0];let N;e[1]!==c.original||e[2]!==s||e[3]!==b||e[4]!==l||e[5]!==y||e[6]!==p?(N=b&&n.jsxs("div",{className:l,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p("diffView.image.original")}),n.jsx("img",{src:c.original,alt:p("diffView.image.originalAlt",{path:s}),className:y?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=c.original,e[2]=s,e[3]=b,e[4]=l,e[5]=y,e[6]=p,e[7]=N):N=e[7];let f;e[8]!==c.modified||e[9]!==s||e[10]!==v||e[11]!==b||e[12]!==l||e[13]!==y||e[14]!==p?(f=v&&n.jsxs("div",{className:l,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p(b?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:c.modified,alt:p("diffView.image.modifiedAlt",{path:s}),className:y?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=c.modified,e[9]=s,e[10]=v,e[11]=b,e[12]=l,e[13]=y,e[14]=p,e[15]=f):f=e[15];let V;return e[16]!==F||e[17]!==N||e[18]!==f?(V=n.jsx("div",{className:"w-full overflow-auto p-4",style:j,children:n.jsxs("div",{className:F,children:[N,f]})}),e[16]=F,e[17]=N,e[18]=f,e[19]=V):V=e[19],V}),Ps=i.memo(o=>{const e=tt.c(23),{filePath:s,diff:c,staged:y,renderSideBySide:p,wrapLines:b,hunkActions:v,onExpandContextRequest:F,pendingContextExpansion:l,contextLoading:j}=o;let N;e[0]!==s?(N=cs(s)||"text",e[0]=s,e[1]=N):N=e[1];const f=N;if(c.submodule){let D;return e[2]!==c.submodule||e[3]!==y?(D=n.jsx(Qn,{state:c.submodule,staged:y}),e[2]=c.submodule,e[3]=y,e[4]=D):D=e[4],D}if(c.isBinary){let D;return e[5]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Ds,{}),e[5]=D):D=e[5],D}if(et(s)){let D;return e[6]!==c||e[7]!==s||e[8]!==p?(D=n.jsx(Is,{filePath:s,diff:c,renderSideBySide:p}),e[6]=c,e[7]=s,e[8]=p,e[9]=D):D=e[9],D}let V;e[10]===Symbol.for("react.memo_cache_sentinel")?(V={contain:"layout"},e[10]=V):V=e[10];let w;return e[11]!==j||e[12]!==c.fileDiff||e[13]!==c.modified||e[14]!==c.original||e[15]!==s||e[16]!==v||e[17]!==f||e[18]!==F||e[19]!==l||e[20]!==p||e[21]!==b?(w=n.jsx("div",{className:"w-full",style:V,children:n.jsx(gs,{original:c.original,modified:c.modified,fileDiff:c.fileDiff,language:f,fileName:s,renderSideBySide:p,wrapLines:b,layout:"inline",hunkActions:v,onExpandContextRequest:F,pendingContextExpansion:l,contextLoading:j})}),e[11]=j,e[12]=c.fileDiff,e[13]=c.modified,e[14]=c.original,e[15]=s,e[16]=v,e[17]=f,e[18]=F,e[19]=l,e[20]=p,e[21]=b,e[22]=w):w=e[22],w}),_s=i.memo(({visible:o=!0,directory:e,file:s,layout:c,wrapLines:y,isSelected:p,isExpanded:b,isMounted:v,onSelect:F,onExpandedChange:l,registerSectionRef:j,showOpenInEditorAction:N=!1,isOpeningInEditor:f=!1,onOpenInEditor:V,staged:w=!1,loadFullFiles:D=!1,initialDiffData:_=null,comparisonDiff:m,onRetryComparisonDiff:be,loadFullComparisonDiff:Z,readOnlyActions:ee=!1,hunkActionsEnabled:Ne=!1,contentRevision:q=0})=>{const{t:x}=qe(),{git:P}=en(),W=ae(i.useCallback(g=>g.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),le=ae(g=>g.setDiff),te=ae(g=>g.fetchStatus),pe=me(g=>g.setDiffFileLayout),[ne,he]=i.useState(0),[J,I]=i.useState(null),[se,X]=i.useState(!1),[K,je]=i.useState(null),A=K!==null&&K.source===m?K.result:m,G=!!e&&!_&&(!m||!!Z),C=i.useMemo(()=>A?A.status==="error"?{kind:"error",message:A.message}:null:J,[A,J]),ce=A?A.status==="loading":se,[H,lt]=i.useState(null),Be=i.useRef(!1),[Ie,nt]=i.useState(null),[ct,xt]=i.useState(!1),[st,Pe]=i.useState(null),[We,_e]=i.useState(null),[a,Ee]=i.useState(null),re=D||a!==null;i.useEffect(()=>{if(!a||!Z||!m||m.status!=="ready"||K?.source===m)return;let g=!1;return Z(s.path).then(M=>{if(!g){if(M.status==="error"){$e.error(M.message),Ee(null);return}je({source:m,result:M})}}),()=>{g=!0}},[a,s.path,K,Z,m]);const ge=i.useRef(null),Ve=i.useRef(null),Oe=i.useMemo(()=>ln(s),[s]),Ue=c==="side-by-side",ze=re?"full":"patch",ve=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,ue=Ne&&!ee&&!_&&!A&&!et(s.path),Je=JSON.stringify([De(),e,s.path,w,ve,ne,q]),U=Ie?.scope===Je?Ie.patch:null,de=Ie?.scope===Je?Ie.submodule:null,ie=i.useMemo(()=>A?A.status==="ready"?A.data:null:_||(w?We:st||(W?{original:W.original,modified:W.modified,isBinary:W.isBinary,submodule:W.submodule,contextMode:"full"}:null)),[A,W,_,st,w,We]),Xe=ie?.contextMode===ze,rt=i.useCallback(g=>{Ve.current=g,j(s.path,g)},[s.path,j]),Ke=i.useCallback(g=>{l(s.path,g)},[s.path,l]),Ye=i.useCallback(()=>{F(s.path)},[s.path,F]),ut=i.useRef({fileStatusKey:ve,staged:w});i.useEffect(()=>{if(!o)return;const g=ut.current;g.fileStatusKey===ve&&g.staged===w||(ut.current={fileStatusKey:ve,staged:w},w?_e(null):Pe(null),I(null),ge.current=null)},[ve,w,o]);const[yt,wt]=i.useState(q),xe=yt===q;i.useEffect(()=>{xe||(I(null),ge.current=null)},[xe]),i.useEffect(()=>{if(!o||!b||!v||J)return;if(!e||A||_||ie&&Xe&&xe&&(!ue||U!==null)){ge.current=null,X(!1);return}const g=`${e}::${s.path}::${w?"staged":"unstaged"}::${ve}::${ze}::${ne}::${q}`;if(ge.current===g)return;ge.current=g,I(null),X(!0);let M=!1;const ye=De(),we=re?on:Ct,O=et(s.path)?P.getGitFileDiff(e,{path:s.path,staged:w}):!re&&U!==null?Promise.resolve({diff:U,submodule:de}):P.getGitDiff(e,{path:s.path,staged:w,contextLines:we}),Ge=ue&&re&&U===null?P.getGitDiff(e,{path:s.path,staged:w,contextLines:Ct}).then(E=>E.diff):Promise.resolve(U),ft=Promise.all([O,Ge]),mt=Cs;let it;const bt=new Promise((E,ot)=>{it=setTimeout(()=>ot(new Error(`Timed out after ${mt}ms`)),mt)});return Promise.race([ft,bt]).then(([E,ot])=>{if(M||ye!==De())return;const L="diff"in E&&!re?E.diff:ot;if(ue&&re&&L!==null&&/^@@\s/m.test(L)&&"diff"in E&&E.diff!==L&&!zn(E.diff,L))throw nt(null),new Error(x("diffView.hunk.unavailable"));if(ue&&L!==null&&nt({scope:Je,patch:L,submodule:E.submodule}),"diff"in E){const Y={...Rt(s.path,E.diff,ze),submodule:E.submodule};w?_e(Y):Pe(Y)}else{const Y={original:E.original??"",modified:E.modified??"",isBinary:E.isBinary,submodule:E.submodule,contextMode:"full"};w?_e(Y):le(e,s.path,Y,ye)}wt(q),X(!1)}).catch(E=>{if(!(M||ye!==De())){if(X(!1),E instanceof Mn){I({kind:"unavailable",reason:E.reason}),E.reason==="path_not_found"&&te(e,P,{force:!0,silent:!0});return}I({kind:"error",message:E instanceof Error?E.message:String(E)})}}).finally(()=>clearTimeout(it)),()=>{M=!0,clearTimeout(it),ge.current===g&&(ge.current=null)}},[U,de,q,ue,xe,Je,A,ze,ie,Xe,ne,e,te,s.path,ve,P,_,b,v,re,J,le,w,x,o]);const Le=i.useCallback(()=>{Ke(!b),Ye()},[Ke,Ye,b]),oe=i.useCallback(()=>{I(null),nt(null),Pe(null),_e(null),ge.current=null,he(g=>g+1)},[]),$=i.useCallback(async(g,M)=>{if(!e||!ue||ce||C||Be.current||H!==null)return;const ye=U?Kn(U,g):null;if(!ye){$e.error(x("diffView.hunk.unavailable"));return}if(w&&M!=="unstage"||!w&&M==="unstage")return;Be.current=!0;const we=De();lt({index:g,action:M});try{const O=M==="stage"?P.stageGitHunk:M==="unstage"?P.unstageGitHunk:P.revertGitHunk;if(!O){$e.error(x("diffView.hunk.unsupported"));return}if(await O(e,s.path,ye),we!==De())return;oe(),tn.requestGitRefresh({directory:e,paths:[s.path]}),await te(e,P)}catch(O){if(we!==De())return;oe(),$e.error(O instanceof Error&&O.message?O.message:x("diffView.hunk.unavailable"))}finally{Be.current=!1,lt(O=>O?.index===g&&O.action===M?null:O)}},[U,ue,ce,C,e,te,s.path,P,H,oe,w,x]),Se=i.useMemo(()=>ue&&U!==null?Gn(U):[],[U,ue]),Ce=i.useCallback(g=>n.jsx(vs,{index:g,staged:w,busyHunk:H,disabled:ce||!!C,onAction:$}),[C,$,H,ce,w]),dt=i.useMemo(()=>Se.length>0?{anchors:Se,render:Ce}:void 0,[Se,Ce]);return n.jsxs("div",{ref:rt,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:Le,onKeyDown:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),Le())},className:Ae("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",p?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:b?n.jsx(z,{name:"arrow-down-s",className:"size-4"}):n.jsx(z,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Oe.color},title:x(Oe.descriptionKey),"aria-label":x(Oe.descriptionKey),children:Oe.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(sn,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const g=s.path.lastIndexOf("/");if(g===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const M=s.path.slice(0,g),ye=s.path.slice(g+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:M}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:ye})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[cn(s.insertions,s.deletions),N&&V?n.jsx(ke,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:x("diffView.actions.openFileInEditorAtChange"),onClick:g=>{g.stopPropagation(),V(s.path,ie)},disabled:f,children:f?n.jsx(z,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(z,{name:"edit",className:"size-3.5"})}):null,n.jsx(nn,{mode:Ue?"side-by-side":"unified",onModeChange:g=>{const M=g==="side-by-side"?"side-by-side":"inline";pe(s.path,M)},className:"opacity-70"})]})]})}),b&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!v&&!C?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,C?.kind==="unavailable"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:C.reason==="nested_repository"?x("diffView.unavailable.nestedRepositoryTitle"):C.reason==="untracked_directory"?x("diffView.unavailable.untrackedDirectoryTitle"):x("diffView.unavailable.missingTitle")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:C.reason==="nested_repository"?x("diffView.unavailable.nestedRepositoryDescription"):C.reason==="untracked_directory"?x("diffView.unavailable.untrackedDirectoryDescription"):x("diffView.unavailable.missingDescription")}),C.reason==="path_not_found"?n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:oe,children:x("diffView.actions.retry")}):null]}):null,C?.kind==="error"?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:x("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:C.message}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>A?be?.():oe(),children:x("diffView.actions.retry")})]}):null,v&&ce&&!ie&&!C?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),x("diffView.state.loadingDiff")]}):null,v&&ie&&!ct&&s.insertions+s.deletions>Wt?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:x("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:x("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>xt(!0),children:x("diffView.actions.renderAnyway")})]}):null,v&&ie&&(ct||s.insertions+s.deletions<=Wt)?n.jsx(n.Fragment,{children:n.jsx(Ps,{filePath:s.path,diff:ie,staged:w,renderSideBySide:Ue,wrapLines:y,hunkActions:dt,onExpandContextRequest:G?Ee:void 0,pendingContextExpansion:a,contextLoading:a!==null&&ie.contextMode!=="full"&&!C})}):null]})]})}),io=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:c=!1,showOpenInEditorAction:y=!1,diffScope:p="all",onDiffScopeChange:b,targetFilePath:v=null,flushContent:F=!1})=>{const{t:l}=qe(),{git:j,files:N}=en(),f=Zn(),V=ae(t=>t.runtimeKey),{rootIsGitRepo:w,gitDirectory:D,nestedRepos:_}=es(f??null,{enabled:o}),m=D??f,be=me(t=>t.openContextSurface),Z=xs(t=>t.requestSource),{screenWidth:ee,isMobile:Ne}=ts(),q=ns(m??null),x=ss(m??null),P=rs(m??null),W=ae(t=>t.setActiveDirectory),le=ae(t=>t.ensureStatus),te=ae(t=>t.selectNestedRepo),pe=ae(t=>t.fetchStatus),ne=ae(t=>t.fetchBranches),he=ae(t=>t.clearDiffCache),J=ae(t=>t.setDiff),[I,se]=i.useState(null),[X,K]=i.useState(!1),[je,A]=i.useState(null),[G,C]=i.useState(()=>new Set),[ce,H]=i.useState(()=>new Set),[lt,Be]=i.useState(0),[Ie,nt]=i.useState(()=>new Map),[ct,xt]=i.useState(0),[st,Pe]=i.useState(!1),[We,_e]=i.useState(!1),[a,Ee]=i.useState(p);i.useEffect(()=>{Ee(p)},[p]);const re=me(t=>t.pendingDiffFile),ge=me(t=>t.pendingDiffStaged),Ve=me(t=>t.pendingDiffScope),Oe=me(t=>t.setPendingDiffFile),Ue=me(t=>t.diffLayoutPreference),ze=me(t=>t.diffFileLayout),ve=me(t=>t.setDiffFileLayout),ue=me(t=>t.diffWrapLines),Je=me(t=>t.setDiffWrapLines),U=me(t=>t.openContextFileAtLine),de=Ht(t=>t.currentSessionId),ie=is(a==="turn"?de??"":"",f??void 0),Xe=ue,rt=a==="staged"?!0:a==="working"?!1:null,Ke=rt??X,Ye=Ne||ee<=768,ut=!!de&&a!=="turn"&&a!=="commit"&&a!=="pr"&&!Ye&&!Fe(),yt=a!=="turn"&&!Ye&&!Fe(),wt=!e&&!Ye&&ee>=1024,xe=i.useRef(null),Le=i.useRef(new Map),oe=i.useRef(null),$=i.useRef(null),Se=i.useRef(!1),Ce=i.useRef(null),dt=i.useRef(null),g=i.useRef(null),M=i.useRef(null),ye=i.useCallback(()=>{const t=xe.current;if(!t)return null;const r=t.getBoundingClientRect().top,u=[];for(const[d,h]of Le.current)h&&u.push({path:d,top:h.getBoundingClientRect().top});return $t(r,u)},[]),we=i.useCallback(()=>{oe.current=null,Se.current=!1,A(null),$.current!==null&&(window.cancelAnimationFrame($.current),$.current=null)},[]),O=i.useCallback(t=>{C(r=>{if(r.has(t))return r;const u=new Set(r);return u.add(t),u})},[]),[Ge,ft]=i.useState([]),mt=ie.length>0?ie[ie.length-1].id:"";i.useEffect(()=>{if(a!=="turn"||!de||!o)return;let t=!1;return Ln.getSessionTurnDiff(de,{directory:f??void 0}).then(r=>{t||ft(r.map(u=>({file:u.file,patch:u.patch,status:u.status,additions:u.additions,deletions:u.deletions})))}).catch(r=>{t||(console.warn("[diff-view] turn diff unavailable:",r instanceof Error?r.message:r),ft([]))}),()=>{t=!0}},[a,de,mt,f,o]);const it=i.useMemo(()=>{const t=new Map;for(const r of Ge)if(r.file){if(typeof r.patch=="string"){t.set(r.file,Rt(r.file,r.patch,"patch"));continue}t.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return t},[Ge]),bt=i.useMemo(()=>x?.files?x.files.filter(Yt).length:0,[x]),E=i.useMemo(()=>x?.files?x.files.filter(Xt).length:0,[x]),ot=Ge.length,L=x?.current??null,Y=Tn(m??null,L,o&&a==="pr"&&!Fe()),Me=Y.selectedSource,Te=Bn(m??null,L,o&&a==="commit"&&!Fe()),He=Te.selectedCommit?.hash??null;i.useEffect(()=>{(a==="commit"||a==="pr")&&Fe()&&(Ee("working"),b?.("working"))},[a,b]);const Qe=ae(t=>m?t.directories.get(m)?.branches??null:null),un=ae(t=>m?t.directories.get(m)?.isLoadingBranches??!1:!1),dn=i.useCallback(()=>{m&&ne(m,j)},[m,ne,j]),fn=qn(m??null,o&&q!==!1,un,!!Qe,dn,Fs),Ft=i.useMemo(()=>{const t=x?.tracking?.trim().split("/")[0];return(t&&Qe?.defaultBranches?.[t])??Qe?.defaultBranches?.origin??null},[Qe,x?.tracking]),Dt=!Fe()&&Wn(L,Ft),mn=x!==null,At=Fe()||fn||Un(L,Ft,mn,Qe!==null),pn=In(t=>t.setOverride),{base:Re,resolved:hn,revision:Et}=Pn(m??null,L,o&&Dt&&a==="branch"),[gn,xn]=i.useState(0);i.useEffect(()=>{const t=Yn(a,!At);t!==a&&(Ee(t),t==="working"&&b?.("working"))},[a,At,b]);const yn=i.useMemo(()=>a==="pr"?Me:a==="commit"&&He?{kind:"commit",hash:He}:a==="branch"&&Re&&L?{kind:"branch",baseRef:Re,headRef:L}:null,[a,Re,L,He,Me]),T=Jn(m??null,yn,o&&!Fe(),a==="branch"?Et:""),{fetchDiff:Vt,fetchFullFile:Lt}=T,Mt=a==="commit"?T.files:null,Tt=a==="commit"?T.error:null,pt=a==="branch"?T.files:null,Bt=a==="branch"?T.error:null,It=T.files?a==="pr"?JSON.stringify([T.key,T.revision]):T.key:null,wn=i.useMemo(()=>a==="branch"||a==="commit"||a==="pr"?Array.from(G).sort().join("\0"):"",[a,G]),jt=i.useCallback(async(t,r=!1)=>{try{const u=await Vt(t,r?on:Ct);return{status:"ready",data:Rt(t,u.diff,r?"full":"patch")}}catch(u){return{status:"error",message:u instanceof Error?u.message:l("diffView.state.failedToLoadDiff")}}},[Vt,l]),Pt=i.useCallback(async t=>{try{const{original:r,modified:u}=await Lt(t),d=js({name:t,contents:r},{name:t,contents:u});return{status:"ready",data:{original:r,modified:u,fileDiff:d,contextMode:"full"}}}catch(r){return{status:"error",message:r instanceof Error?r.message:l("diffView.state.failedToLoadDiff")}}},[Lt,l]),bn=i.useMemo(()=>a==="branch"||a==="commit"?t=>jt(t,!0):a==="pr"?Pt:void 0,[a,jt,Pt]),jn=Xn(It,o?wn:"",It?jt:null,Jt,JSON.stringify([a==="branch"?Et:"",a==="pr"?T.revision:0,gn])),vn=pt?.length??null,k=i.useMemo(()=>{if(a==="commit"||a==="pr")return(T.files??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:d.insertions,deletions:d.deletions,isNew:d.status==="A"}));if(a==="branch")return(pt??[]).map(d=>({path:d.path,index:"",working_dir:d.status,insertions:0,deletions:0,isNew:d.status==="A"})).sort((d,h)=>d.path.localeCompare(h.path));if(a==="turn")return Ge.map(d=>({path:d.file??"",index:"",working_dir:Ms(d.status),insertions:d.additions??0,deletions:d.deletions??0,isNew:d.status==="added"})).filter(d=>d.path).sort((d,h)=>d.path.localeCompare(h.path));if(!x?.files)return[];const t=x.diffStats,r=a==="staged"?Xt:a==="working"?Yt:()=>!0,u=d=>{const h=t?.staged?.[d],R=t?.working?.[d];return a==="staged"?{insertions:h?.insertions??0,deletions:h?.deletions??0}:a==="working"?{insertions:R?.insertions??0,deletions:R?.deletions??0}:{insertions:(h?.insertions??0)+(R?.insertions??0),deletions:(h?.deletions??0)+(R?.deletions??0)}};return x.files.filter(r).map(d=>{const h=u(d.path);return{...d,insertions:h.insertions,deletions:h.deletions,isNew:Vs(d)}}).sort((d,h)=>d.path.localeCompare(h.path))},[a,pt,T.files,Ge,x]),vt=i.useMemo(()=>k.map(t=>t.path).join("\0"),[k]);i.useEffect(()=>{const t=vt?vt.split("\0"):[],r=new Set(t),u=`${m??""}:${a}:${s?"collapsed":"default"}`,d=dt.current!==u;dt.current=u,C(h=>{if(d){const B=s?0:Rs(t.length);return new Set(t.slice(0,B))}let R=!1;const S=new Set;for(const B of h){if(!r.has(B)){R=!0;continue}S.add(B)}return R?S:h}),H(h=>{if(d)return new Set;let R=!1;const S=new Set;for(const B of h){if(!r.has(B)){R=!0;continue}S.add(B)}return R?S:h})},[a,vt,m,s]);const _t=i.useCallback(()=>{if(Ce.current=null,!o)return;const t=xe.current;if(!t)return;const r=t.getBoundingClientRect(),u=r.top-Ut,d=r.bottom+Ut,h={},R=[];for(const[S,B]of Le.current){if(!B)continue;const Q=B.getBoundingClientRect();R.push({path:S,top:Q.top}),G.has(S)&&(Q.bottom<u||Q.top>d||(h[S]=!0))}g.current=$t(r.top,R),H(S=>{let B=!1;const Q=new Set(S);for(const at of Object.keys(h))Q.has(at)||(Q.add(at),B=!0);return B?Q:S})},[G,o]),fe=i.useCallback(()=>{o&&(typeof window>"u"||Ce.current===null&&(Ce.current=window.requestAnimationFrame(_t)))},[_t,o]);i.useEffect(()=>{const t=xe.current;if(!(!o||!t))return fe(),t.addEventListener("scroll",fe,{passive:!0}),window.addEventListener("resize",fe),()=>{t.removeEventListener("scroll",fe),window.removeEventListener("resize",fe),Ce.current!==null&&(window.cancelAnimationFrame(Ce.current),Ce.current=null)}},[k,G,fe,o]);const St=i.useCallback(t=>{const r=ze[t.path];if(r)return r;if(Ue==="inline")return"inline";if(Ue==="side-by-side")return"side-by-side";const u=ee<Ns;return t.isNew||u?"inline":"side-by-side"},[ze,Ue,ee]),Ot=i.useMemo(()=>k.length===0?null:k.every(t=>St(t)==="side-by-side")?"side-by-side":"inline",[k,St]);i.useEffect(()=>{o&&m&&(W(m),le(m,j))},[m,W,le,j,o]);const ht=JSON.stringify([V,m]),kt=i.useRef({scope:ht,paths:new Set,dirty:!1,unscoped:!1}),zt=i.useRef(o);i.useEffect(()=>{const t=o&&!zt.current;if(zt.current=o,kt.current.scope!==ht&&(kt.current={scope:ht,paths:new Set,dirty:!1,unscoped:!1}),!m)return;const r=(d,h)=>{d.length&&(M.current=ye()??g.current,he(m,d),nt(R=>{const S=new Map(R);for(const B of d)S.set(B,(S.get(B)??0)+1);return S})),h&&xt(R=>R+1),pe(m,j,{silent:!0})},u=kt.current;return o&&(t||u.dirty)&&(r([...u.paths],u.unscoped),u.paths.clear(),u.dirty=!1,u.unscoped=!1),tn.onGitRefreshHint(d=>{if(Qt(d.directory)!==Qt(m))return;const h=d.paths??[],R=h.length===0;if(!o){u.dirty=!0,u.unscoped||=R;for(const S of h)u.paths.add(S);return}r(h,R)})},[ye,he,m,pe,j,ht,o]),i.useLayoutEffect(()=>{const t=M.current;if(!t)return;M.current=null;const r=xe.current,u=Le.current.get(t.path);if(!r||!u)return;const d=r.getBoundingClientRect().top,h=u.getBoundingClientRect().top-d;r.scrollTop=ks(r.scrollTop,t.topOffset,h,r.scrollHeight-r.clientHeight),g.current=t},[Ie]),i.useEffect(()=>{!o||a!=="all"&&!Ve||re&&(Ve&&Ee(Ve),se(re),K(Ve==="staged"||!Ve&&ge),Oe(null),Se.current=!0,oe.current=re,O(re),Be(t=>t+1))},[a,O,re,Ve,ge,Oe,o]),i.useEffect(()=>{if(a==="all")return;const t=v?.trim();t&&(se(t),K(a==="staged"),Se.current=!0,oe.current=t,O(t),Be(r=>r+1))},[a,O,v]),i.useEffect(()=>{if(!I)return;k.some(r=>r.path===I)||(se(null),K(!1))},[k,I]);const Sn=i.useCallback((t,r)=>{const u=Le.current;r?u.set(t,r):u.delete(t),fe()},[fe]),kn=i.useCallback((t,r)=>{we(),C(u=>{const d=u.has(t);if(r===d)return u;const h=new Set(u);return r?h.add(t):h.delete(t),h}),r||H(u=>{if(!u.has(t))return u;const d=new Set(u);return d.delete(t),d}),fe()},[we,fe]),Nn=i.useCallback(()=>{we(),C(t=>t.size>0?new Set:new Set(k.map(r=>r.path))),H(new Set),fe()},[we,k,fe]),Cn=i.useCallback(async t=>{if(!de)return;const r=Ht.getState().getDirectoryForSession(de)||f||"";if(!r){$e.error(l("diffView.reviewDialog.toast.noSessionDirectory"));return}_e(!0);try{await os({originalSessionID:de,directory:r,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),Pe(!1)}catch(u){console.error("[review-flow] failed to start review flow",u),$e.error(u instanceof Error?u.message:l("diffView.reviewDialog.toast.startFailed"))}finally{_e(!1)}},[de,f,l]),gt=i.useCallback(t=>{const r=Le.current.get(t),u=xe.current;if(!r||!u)return!1;const d=r.getBoundingClientRect().top-u.getBoundingClientRect().top;return u.scrollTo({top:u.scrollTop+d,behavior:"auto"}),!0},[]);i.useEffect(()=>{const t=oe.current;if(!o||!t)return;let r=0;const u=20;let d=!1;const h=(S=!0)=>{d||(d=!0,oe.current=null,Se.current=!1,S&&A(null),$.current!==null&&(window.cancelAnimationFrame($.current),$.current=null))},R=()=>{if(d){$.current=null;return}const S=oe.current;if(!S){h(),$.current=null;return}if(!gt(S)){r+=1,r<u?$.current=window.requestAnimationFrame(R):(h(),$.current=null);return}if(c&&Se.current){A(S),h(!1);return}h()};return $.current=window.requestAnimationFrame(R),()=>{d=!0,$.current!==null&&(window.cancelAnimationFrame($.current),$.current=null)}},[c,lt,gt,o]);const Rn=i.useCallback(t=>{},[]),Nt=i.useCallback(t=>{we(),se(t),K(!1),Se.current=!0,oe.current=t,O(t),Be(r=>r+1),gt(t)},[we,O,gt]);i.useEffect(()=>{const t=r=>{if(!o||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const u=r.target;if(u instanceof HTMLElement&&(u.isContentEditable||u.tagName==="INPUT"||u.tagName==="TEXTAREA"||u.closest('[role="dialog"]'))||k.length===0)return;const d=r.key==="ArrowDown"?1:-1,h=I?k.findIndex(B=>B.path===I):-1,R=h===-1?d>0?0:k.length-1:h+d,S=k[R];S&&(r.preventDefault(),Nt(S.path))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[k,I,Nt,o]);const Fn=i.useCallback(t=>{const r=t==="side-by-side"?"side-by-side":"inline";k.forEach(u=>{ve(u.path,r)})},[k,ve]),[Dn,Kt]=i.useState(null),An=i.useCallback(async(t,r)=>{if(!m||!t)return;Kt(t);const u=De();try{let d=null;if(r?.patch&&!r.isBinary&&!et(t)?d=qt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!et(t)&&(d=Zt(r.original,r.modified)),d===null)try{const Q=await j.getGitDiff(m,{path:t,staged:Ke,contextLines:3});d=qt(Q.diff)}catch{d=null}let h=r;if(d===null||!h){const Q=await j.getGitFileDiff(m,{path:t,staged:Ke}),at={original:Q.original??"",modified:Q.modified??"",isBinary:Q.isBinary,submodule:Q.submodule};h=at,Ke||J(m,t,at,u)}const R=d??(h.isBinary||et(t)?1:Zt(h.original,h.modified)),S=Ls(m,t),B=await ys(N,S,{directory:m});if(!B.ok){$e.error(ws(B.reason));return}U(m,S,R,1)}finally{Kt(d=>d===t?null:d)}},[Ke,m,N,j,U,J]),En=()=>{if(!m)return null;const t=r=>rt!==null?rt:X&&r===I;return n.jsxs("div",{className:Ae("flex min-w-0 flex-1 min-h-0 h-full",F?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[wt&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:l("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:k.length})]}),n.jsx(Bs,{changedFiles:k,selectedFile:null,onSelectFile:Nt})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(rn,{ref:xe,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:k.map(r=>n.jsx(_s,{visible:o,directory:m,file:r,layout:St(r),wrapLines:Xe,isSelected:!1,isExpanded:G.has(r.path),isMounted:ce.has(r.path)||r.path===je,onSelect:Rn,onExpandedChange:kn,registerSectionRef:Sn,showOpenInEditorAction:y&&a!=="turn",isOpeningInEditor:Dn===r.path,onOpenInEditor:(u,d)=>{An(u,d)},staged:t(r.path),readOnlyActions:a==="branch"||a==="commit"||a==="pr",hunkActionsEnabled:a==="all"||a==="working"||a==="staged",contentRevision:ct,comparisonDiff:a==="branch"||a==="commit"||a==="pr"?jn.get(r.path)??Jt:void 0,onRetryComparisonDiff:()=>xn(u=>u+1),loadFullComparisonDiff:bn,initialDiffData:a==="turn"?it.get(r.path)??null:null},`${De()}:${m}:${r.path}:${Ie.get(r.path)??0}`))})})})]})},Vn=()=>{if(!m)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l("diffView.state.selectSessionDirectory")});if(a!=="turn"&&P&&!x)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingRepositoryStatus")]});if(a!=="turn"&&q===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l("diffView.state.notGitRepository")});if(a==="pr"){if(!Me||T.error)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:T.error??Y.error??(Y.loading?l("session.githubPrPicker.loading.pullRequests"):l("pullRequestComparison.select"))}),(T.error||Y.error)&&n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{Me?T.refresh():Y.refresh()},children:l("diffView.actions.retry")}),!Me&&!Y.loading&&n.jsx(Gt,{comparison:Y})]});if(!T.files)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingDiff")]})}if(a==="commit"){if(Tt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:Tt}),n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{T.refresh()},children:l("diffView.actions.retry")})]});if(!He&&!Te.loading)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Te.error??l("commitComparison.noCommits")});if(!Mt)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingDiff")]})}if(a==="branch"){if(!hn)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.branch.resolvingBase")]});if(!Re)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(z,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:l("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:l("gitView.pr.toast.baseBranchRequired")})]});if(Bt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:l("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Bt}),n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{T.refresh()},children:l("diffView.actions.retry")})]});if(pt===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.branch.loadingFiles")]})}return k.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a==="turn"?l("diffView.state.noLastTurnChanges"):a==="pr"?l("walkthrough.blocked.emptyDiff.description"):a==="commit"?l("commitComparison.emptyDiff"):a==="branch"&&Re?l("diffView.branch.empty",{base:hs(Re)}):l("diffView.state.cleanWorkingTree")}):En()};return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[w===!1&&Array.isArray(_)&&_.length>0?n.jsx(ps,{repositories:_,selectedRepository:D??null,onSelectRepository:t=>{f&&te(f,t)},repositoryRoot:f??void 0}):null,!Ne&&(a!=="all"?n.jsx(Ts,{scope:a,workingCount:bt,stagedCount:E,turnCount:ot,branchCount:vn,commitCount:a==="commit"?Mt?.length??null:null,prCount:a==="pr"?T.files?.length??null:null,showCommitOption:!Fe(),showBranchOption:Dt,onScopeChange:t=>{Ee(t),b?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:P&&!x?l("diffView.state.loadingChanges"):k.length===1?l("diffView.summary.changedFilesSingle",{count:k.length}):l("diffView.summary.changedFilesPlural",{count:k.length})})})),a==="branch"&&n.jsx(_n,{branches:Qe?.all??[],currentBranch:L,base:Re,onSelect:t=>{m&&L&&pn(m,L,t)}},JSON.stringify([m,L])),a==="commit"&&n.jsx(On,{commits:Te.commits,selectedHash:He,loading:Te.loading,error:Te.error,onSelect:Te.select,onRefresh:()=>{Te.refresh()}},JSON.stringify([m,L])),a==="pr"&&n.jsxs(n.Fragment,{children:[n.jsx(Gt,{comparison:Y},JSON.stringify([V,m,L])),Me&&n.jsx(ke,{variant:"ghost",size:"sm",disabled:T.loading,"aria-label":l("session.githubIssuePicker.actions.refresh"),title:l("session.githubIssuePicker.actions.refresh"),onClick:()=>{T.refresh()},children:n.jsx(z,{name:"refresh",className:"size-4"})})]}),k.length>0&&n.jsxs(ke,{variant:"ghost",size:"sm",onClick:Nn,className:Ae("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:G.size>0?l("diffView.actions.collapseAll"):l("diffView.actions.expandAll"),children:[n.jsx(z,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:G.size>0?l("diffView.actions.collapseAll"):l("diffView.actions.expandAll")})]}),k.length>0&&ut&&n.jsxs(ke,{variant:"default",size:"sm",onClick:()=>Pe(!0),disabled:We,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":l("diffView.actions.reviewAria"),children:[We?n.jsx(z,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(z,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:l("diffView.actions.review")})]}),k.length>0&&yt&&n.jsxs(ke,{variant:"outline",size:"sm",onClick:()=>{const t=m??"";Z(t,a==="pr"&&Me?Me:a==="commit"&&He?{kind:"commit",hash:He}:a==="branch"&&Re&&L?{kind:"branch",baseRef:Re,headRef:L}:{kind:"working-tree",scope:a==="staged"||a==="working"?a:"all"}),be(f??t,"walkthrough")},className:Ae("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",bs),"aria-label":l("walkthrough.action.open"),children:[n.jsx(z,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:l("walkthrough.action.open")})]}),k.length>0&&n.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>Je(!ue),className:Ae("h-5 w-5 p-0 transition-opacity",Xe?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:l(Xe?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(z,{name:"text-wrap",className:"size-4"})}),Ot&&n.jsx(nn,{mode:Ot==="side-by-side"?"side-by-side":"unified",onModeChange:Fn})]}),n.jsx(as,{open:st,onOpenChange:Pe,projectDirectory:m??null,submitting:We,onConfirm:Cn}),Vn()]})};export{io as DiffView,_s as MultiFileDiffEntry};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{f as Re,R as i,c as Ei,j as r,r as ht}from"./vendor-react-BUCujlKS.js";import{a as tt,h as en,Y as Mo,Z as Do,_ as zo,$ as Lo,v as et,u as mt,e1 as Ao,I as Vi,B as Io,a3 as Pi,e as Oo,d$ as Bo,a2 as $o,e0 as _o}from"./index-CvLgnuNI.js";import{f as st,z as Mi,ai as sa,cf as Wo,h as W,kw as Uo,g5 as Ko,X as Fs,B as I,I as E,kx as Ho,aA as Ns,gV as qo,gT as Go,_ as Xo,T as Jo,bj as Yo,K as Zo,ak as Qo,cA as el,eF as Di,ix as tl,gr as sl,t as re,l as zi,ay as Kr,ct as bs,d9 as rl,b as nl,ky as ys,c1 as il,az as Hr,kz as qr,cu as Li,cv as Ai,kA as Ii,kB as Oi,kC as al,kD as ol,kE as ll,hy as cl,kF as ul,kG as dl,kH as fl,c2 as ra,c3 as na,c4 as ia,c5 as aa,c6 as oa,c7 as la,as as tn,at as sn,av as rn,bh as ur,c8 as Gr,aB as ar,cp as Xr,ae as Mt,af as Dt,ag as zt,b$ as ml,c0 as hl,g as fr,bi as pl,cz as gl}from"./useAppFontEffects-BxrtCnfR.js";import{at as xl,Y as vl,Z as wl,_ as bl,$ as yl,a0 as jl}from"./runtimeEndpointReset-DKDdzRzm.js";import{c as Bi,s as Nl,P as js,C as Sl}from"./shikiHighlight-xURoo5t_.js";import{a as Fl}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Lt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Cl,J as kl,F as Rl}from"./JsonTreeView-DOHHcbgJ.js";import{ensurePierreThemeRegistered as $i,getResolvedShikiTheme as Tl}from"./appThemeRegistry-B5tHTkR8.js";import{V as El,W as Vl}from"./Virtualizer-CZlLSacm.js";import{V as Pl}from"./Virtualizer-D_a8gKmg.js";import{a as Ml,u as or,b as Dl,c as zl,h as Ll,i as Al,j as Il}from"./scheduledTasksApi-C5sCuNqf.js";import{D as Ol}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Bl,u as $l,n as _l}from"./useInlineCommentController-CeXuR-SR.js";import{b as Wl}from"./CodeMirrorCommentWidgets-B82Oye3V.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-Gea9uBlY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-_BAHQo4R.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-ClYN8CzB.js";import"./vendor-tanstack-virtual-core-BewVQryB.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DOuaQUZ0.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-CYwWYLr3.js";import"./PluginPane-sM8fcZIV.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-63H1h21j.js";import"./computeVirtualFileMetrics-cq9uQ30i.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-DB3_rjyW.js";import"./textMateThemeFromAppTheme-BZLGuYTU.js";function _i(n){const e=Re.c(41),{containerRef:t,filePath:a,fileContent:w}=n,{t:f}=st(),v=Mi(Yl),d=Mi(Jl),x=sa(),g=Wo(Xl),[m,b]=i.useState(null),[y,C]=i.useState(""),[N,F]=i.useState(!1),p=i.useRef(!1),l=i.useRef(null),T=i.useRef(null),[R,M]=i.useState(null);let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{b(null),C(""),F(!1),p.current=!1,T.current=null,M(null)},e[0]=D):D=e[0];const L=D;let k,V;e[1]!==t?(k=()=>{const K=t.current;if(!K)return;const ie=()=>{if(p.current)return;const ae=window.getSelection(),fe=ae?.toString().trim()??"";if(!ae||!fe||ae.rangeCount===0){L();return}const me=ae.getRangeAt(0);if(!K.contains(me.commonAncestorContainer)){L();return}const ce=me.getBoundingClientRect();T.current=me.cloneRange(),C(fe),b({x:ce.left+ce.width/2,y:ce.top-10})},_=ae=>{l.current?.contains(ae.target)||p.current&&L()};return document.addEventListener("selectionchange",ie),document.addEventListener("pointerdown",_),()=>{document.removeEventListener("selectionchange",ie),document.removeEventListener("pointerdown",_)}},V=[t,L],e[1]=t,e[2]=k,e[3]=V):(k=e[2],V=e[3]),i.useEffect(k,V);let z;e[4]!==w?(z=K=>{const ie=he=>w.slice(0,he).split(`
|
|
2
|
+
`).length,_=ql,ae=(he,ve)=>{for(const Ee of _(he)){const ye=w.indexOf(Ee,ve);if(ye>=0)return ye}return-1},fe=K.length>=8?w.indexOf(K):-1;if(fe>=0){const he=ie(fe);return{start:he,end:he+K.split(`
|
|
3
|
+
`).length-1}}const me=K.split(`
|
|
4
|
+
`).map(Hl).filter(Boolean);if(me.length===0)return null;const ce=ae(me[0],0);if(ce<0)return null;const be=ie(ce);if(me.length===1)return{start:be,end:be};const xe=ae(me[me.length-1],ce);return xe<0?null:{start:be,end:Math.max(be,ie(xe))}},e[4]=w,e[5]=z):z=e[5];const B=z;let U;e[6]===Symbol.for("react.memo_cache_sentinel")?(U=()=>{const K=T.current;if(!K){M(null);return}M(Uo(K))},e[6]=U):U=e[6];const Z=U;let te,ee;e[7]!==N?(te=()=>{if(!N)return;let K=null;const ie=()=>{K===null&&(K=window.requestAnimationFrame(()=>{K=null,Z()}))};return document.addEventListener("scroll",ie,{capture:!0,passive:!0}),window.addEventListener("resize",ie),()=>{K!==null&&window.cancelAnimationFrame(K),document.removeEventListener("scroll",ie,{capture:!0}),window.removeEventListener("resize",ie)}},ee=[N,Z],e[7]=N,e[8]=te,e[9]=ee):(te=e[8],ee=e[9]),i.useEffect(te,ee);let q;e[10]!==y?(q=()=>{y&&(F(!0),p.current=!0,Z(),window.getSelection()?.removeAllRanges())},e[10]=y,e[11]=q):q=e[11];const G=q;let X;e[12]!==g||e[13]!==v||e[14]!==x||e[15]!==a||e[16]!==d||e[17]!==B||e[18]!==y?(X=K=>{const ie=v??(d?"draft":null);if(!y||!ie||!x){L();return}const _=B(y);g({directory:x,sessionKey:ie},{source:"file-quote",fileLabel:a,startLine:_?.start??0,endLine:_?.end??0,code:y,language:"",text:K.trim()}),L(),queueMicrotask(Kl)},e[12]=g,e[13]=v,e[14]=x,e[15]=a,e[16]=d,e[17]=B,e[18]=y,e[19]=X):X=e[19];const H=X;if(!m)return null;let Q;e[20]!==N||e[21]!==B||e[22]!==y?(Q=N?B(y):null,e[20]=N,e[21]=B,e[22]=y,e[23]=Q):Q=e[23];const _e=Q;let ne;e[24]!==m.x||e[25]!==m.y?(ne={left:m.x,top:m.y,transform:"translate(-50%, -100%)"},e[24]=m.x,e[25]=m.y,e[26]=ne):ne=e[26];let Te;e[27]!==N||e[28]!==R?(Te=N&&R&&R.length>0?Ei.createPortal(r.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:R.map(Ul)}),document.body):null,e[27]=N,e[28]=R,e[29]=Te):Te=e[29];let De;e[30]!==N||e[31]!==a||e[32]!==_e||e[33]!==G||e[34]!==H||e[35]!==f?(De=N?r.jsx("div",{className:"w-[min(420px,80vw)]",children:r.jsx(Bl,{fileLabel:a,lineRange:_e?{start:_e.start,end:_e.end}:void 0,onSave:H,onCancel:L})}):r.jsx("div",{className:W("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:r.jsx("button",{type:"button",onClick:G,className:W("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-foreground","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:f("chat.textSelection.title.commentOnSelection"),children:f("chat.textSelection.actions.comment")})}),e[30]=N,e[31]=a,e[32]=_e,e[33]=G,e[34]=H,e[35]=f,e[36]=De):De=e[36];let ze;return e[37]!==ne||e[38]!==Te||e[39]!==De?(ze=Ei.createPortal(r.jsxs("div",{ref:l,className:"fixed z-50",style:ne,children:[Te,De]}),document.body),e[37]=ne,e[38]=Te,e[39]=De,e[40]=ze):ze=e[40],ze}function Ul(n,e){return r.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:n.left,top:n.top,width:n.width,height:n.height}},e)}function Kl(){Ko()}function Hl(n){return n.trim()}function ql(n){const e=n.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(Gl)}function Gl(n){return n.length>=8}function Xl(n){return n.addDraft}function Jl(n){return n.newSessionDraft?.open}function Yl(n){return n.currentSessionId}const Zl=(n,e)=>{if(!e)return null;const t=Number.parseInt(n.trim(),10);return!Number.isFinite(t)||t<1?null:Math.min(t,e.state.doc.lines)},Wi=(n,e)=>{const t=n.state.doc.lineAt(e.main.head);return{lineNumber:t.number,character:e.main.head-t.from+1,selection:e}},Ui=(n,e,t)=>{const a=n.state.doc.line(e),w=Math.max(1,Math.min(t,a.length+1)),f=a.from+w-1;n.dispatch({selection:Fl.cursor(f),effects:Lt.scrollIntoView(f,{y:"center"})})};function Ql({open:n,onOpenChange:e,view:t,variant:a="overlay"}){const{t:w}=st(),[f,v]=i.useState(""),d=i.useRef(null),x=i.useRef(!1),g=i.useRef(null),m=i.useRef(null),b=i.useMemo(()=>Zl(f,t),[f,t]);i.useEffect(()=>{!n||!t||(x.current=!1,d.current=Wi(t,t.state.selection),v(""))},[n,t]),i.useEffect(()=>{n&&window.requestAnimationFrame(()=>{m.current?.focus(),m.current?.select()})},[n]),i.useEffect(()=>{if(!(!n||!t||!d.current)){if(b===null){const{selection:p}=d.current;t.dispatch({selection:p,effects:Lt.scrollIntoView(p.main.from,{y:"center"})});return}Ui(t,b,d.current.character)}},[b,n,t]);const y=i.useCallback(()=>{if(!t||x.current||!d.current)return;const{selection:p}=d.current;t.dispatch({selection:p,effects:Lt.scrollIntoView(p.main.from,{y:"center"})})},[t]),C=i.useCallback(p=>{p||y(),e(p)},[e,y]),N=i.useCallback(()=>{!t||b===null||!d.current||(x.current=!0,Ui(t,b,d.current.character),e(!1),t.focus())},[b,e,t]);i.useEffect(()=>{if(!n)return;const p=T=>{const R=g.current,M=T.target;!R||!(M instanceof Node)||R.contains(M)||C(!1)},l=T=>{T.key==="Escape"&&(T.preventDefault(),C(!1))};return document.addEventListener("pointerdown",p,!0),document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("pointerdown",p,!0),document.removeEventListener("keydown",l,!0)}},[C,n,a]);const F=i.useMemo(()=>{if(!t)return w("goToLineDialog.helper.editorUnavailable");if(b===null){const p=d.current??Wi(t,t.state.selection);return w("goToLineDialog.helper.currentLineRange",{current:p.lineNumber,max:t.state.doc.lines})}return w("goToLineDialog.helper.goToLine",{line:b})},[b,w,t]);return a==="inline"?n?r.jsxs("div",{ref:g,className:"ml-1 flex h-6 items-center gap-1",children:[r.jsx(Fs,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:p=>v(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),N())},placeholder:w("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),r.jsx(I,{variant:"outline",size:"xs",onClick:N,disabled:!t||b===null,className:"h-6 px-2",children:w("goToLineDialog.actions.go")})]}):null:r.jsx("div",{ref:g,className:W("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",n?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:r.jsxs("div",{className:"min-w-0",children:[r.jsx(Fs,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:f,onChange:p=>v(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),N())},placeholder:w("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),r.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:F})]})})}const ec=(n,e)=>{const t=e.trim().toLowerCase(),a=[];if(!t)return a;const w=n.toLowerCase();let f=0;for(;;){const v=w.indexOf(t,f);if(v===-1)break;a.push({start:v,end:v+t.length}),f=v+t.length}return a},mr="data-md-find",Jr="data-md-find-current",ca="rounded-[2px] bg-status-warning/30 text-foreground",tc="rounded-[2px] bg-status-warning/60 text-foreground",sc=120,rc=n=>n instanceof Element&&n.hasAttribute(mr),nc=n=>n.target instanceof Element&&n.target.hasAttribute(mr)?!0:[...n.addedNodes].some(e=>rc(e)),ua=n=>{const e=new Set;n.querySelectorAll(`mark[${mr}]`).forEach(t=>{const a=t.parentNode;a&&(a.replaceChild(document.createTextNode(t.textContent??""),t),e.add(a))}),e.forEach(t=>t.normalize())},ic=(n,e)=>{ua(n);const t=e.trim().toLowerCase();if(!t)return[];const a=[],w=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,{acceptNode(v){const d=v.parentElement;return!d||d.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),f=[];for(;w.nextNode();){const v=w.currentNode;v instanceof Text&&f.push(v)}for(const v of f){const d=v.nodeValue??"";if(!d)continue;const x=ec(d,t);if(x.length===0)continue;const g=v.parentNode;if(!g)continue;const m=document.createDocumentFragment();let b=0;for(const y of x){y.start>b&&m.appendChild(document.createTextNode(d.slice(b,y.start)));const C=document.createElement("mark");C.setAttribute(mr,""),C.className=ca,C.textContent=d.slice(y.start,y.end),m.appendChild(C),a.push(C),b=y.end}b<d.length&&m.appendChild(document.createTextNode(d.slice(b))),g.replaceChild(m,v)}return a},Ki=({containerRef:n,open:e,onOpenChange:t,focusNonce:a,className:w})=>{const{t:f}=st(),[v,d]=i.useState(""),[x,g]=i.useState(0),[m,b]=i.useState(0),y=i.useRef(null),C=i.useRef([]),N=i.useRef(v);N.current=v;const F=i.useRef(null),p=i.useRef(null),l=i.useCallback((k,V=!1)=>{const z=n.current;if(!z){C.current=[],g(0),b(0);return}C.current=ic(z,k);const B=C.current.length;g(B),b(U=>!V||B===0?0:Math.min(U,B-1))},[n]),T=i.useCallback((k,V=!1)=>{F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{F.current=null,l(k,V)},sc)},[l]);i.useEffect(()=>()=>{F.current&&clearTimeout(F.current)},[]);const R=i.useCallback(()=>{t(!1);const k=p.current;p.current=null,k?.isConnected&&k.focus()},[t]);i.useEffect(()=>{const k=n.current;if(!e||!k)return;const V=new MutationObserver(z=>{!N.current.trim()||!z.some(U=>!nc(U))||T(N.current,!0)});return V.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{V.disconnect(),ua(k)}},[n,e,T]),i.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!p.current&&(p.current=k),y.current?.focus()},[e]),i.useEffect(()=>{e&&a>0&&(y.current?.focus(),y.current?.select())},[e,a]),i.useEffect(()=>{const k=n.current;if(!k||(k.querySelectorAll(`mark[${Jr}]`).forEach(z=>{z.removeAttribute(Jr),z.className=ca}),x===0))return;const V=C.current[Math.min(Math.max(m,0),x-1)];V&&(V.setAttribute(Jr,""),V.className=tc,V.scrollIntoView({block:"nearest"}))},[n,m,x]);const M=i.useCallback(()=>{b(k=>x===0?0:(k+1)%x)},[x]),D=i.useCallback(()=>{b(k=>x===0?0:(k-1+x)%x)},[x]),L=i.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?D():M()):k.key==="Escape"&&(k.preventDefault(),R())},[R,M,D]);return e?r.jsxs("div",{className:W("absolute right-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",w),children:[r.jsx(E,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),r.jsx(Fs,{ref:y,value:v,onChange:k=>{d(k.target.value),T(k.target.value)},onKeyDown:L,placeholder:f("filesView.preview.find.placeholder"),"aria-label":f("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),r.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":x>0?f("filesView.preview.find.countAria",{current:m+1,total:x}):f("filesView.preview.find.noMatches"),children:v.trim()&&x===0?f("filesView.preview.find.noMatches"):x>0?`${m+1}/${x}`:""}),r.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:D,title:f("filesView.preview.find.previousAria"),"aria-label":f("filesView.preview.find.previousAria"),disabled:x===0,children:r.jsx(E,{name:"arrow-up",className:"size-3.5"})}),r.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:f("filesView.preview.find.nextAria"),"aria-label":f("filesView.preview.find.nextAria"),disabled:x===0,children:r.jsx(E,{name:"arrow-down",className:"size-3.5"})}),r.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:R,title:f("filesView.preview.find.closeAria"),"aria-label":f("filesView.preview.find.closeAria"),children:r.jsx(E,{name:"close",className:"size-3.5"})})]}):null},ac=n=>{let e=!0;return{poll:async()=>{if(!e||n.isDirty())return!1;const t=n.getLoadedContent(),a=n.getLoadedRevision();try{const w=await n.readContent();if(!e||n.isDirty()||a!==n.getLoadedRevision())return!1;if(w===t)return!0;const f=await n.readContent();return!e||n.isDirty()||f!==w||a!==n.getLoadedRevision()?!1:(n.applyContent(w),!0)}catch{return!1}},dispose:()=>{e=!1}}},oc=1,lc=(n,e)=>e.size!==n.size||e.mtimeMs!==void 0&&n.mtimeMs!==void 0&&Math.abs(e.mtimeMs-n.mtimeMs)>=oc;function Hi(){const n=Re.c(8),[e]=ht.useState(cc),t=ht.useRef(!1);let a;n[0]!==e?(a=x=>{if(x==null){e.cleanUp(),t.current=!1;return}t.current||(t.current=!0,e.setup(x,x.firstElementChild??void 0))},n[0]=e,n[1]=a):a=n[1];const w=a;let f,v;n[2]!==e?(f=()=>()=>{t.current=!1,e.cleanUp()},v=[e],n[2]=e,n[3]=f,n[4]=v):(f=n[3],v=n[4]),ht.useLayoutEffect(f,v);let d;return n[5]!==w||n[6]!==e?(d={virtualizer:e,setScroller:w},n[5]=w,n[6]=e,n[7]=d):d=n[7],d}function cc(){return new Pl}const rs=new Map,uc=100;function lr(n){const[e,t]=ht.useState(null),a=ht.useRef(null),w=ht.useRef(null),f=ht.useRef(null),v=ht.useCallback((d,x)=>{d&&x instanceof Cl&&(f.current={key:n,file:x,node:d});const g=a.current,m=w.current,b=()=>{a.current===g&&(g?.(),m?.())};x?queueMicrotask(b):b()},[n]);return ht.useLayoutEffect(()=>{if(!e||!n)return;const d=rs.get(n)??{top:0,left:0};let x=!0;const g=()=>f.current?.key===n?f.current.file:null,m=l=>f.current?.key===n?f.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${l-1}"]`):null,b=()=>{C.disconnect(),N.disconnect()},y=()=>{if(!x)return;const l=g(),T=d.line&&l?.getLinePosition(d.line.number),R=d.line&&m(d.line.number);let M=d.top;d.line&&T&&(M=(l?.top??0)+T.top-d.line.offset),d.line&&R&&(M=e.scrollTop+R.getBoundingClientRect().top-e.getBoundingClientRect().top-d.line.offset),e.scrollTop=M,e.scrollLeft=d.left,(!d.line||R)&&Math.abs(e.scrollTop-M)<1&&Math.abs(e.scrollLeft-d.left)<1&&(x=!1,b())},C=new ResizeObserver(y),N=new MutationObserver(()=>{if(x){for(const l of e.children)C.observe(l);y()}});C.observe(e);for(const l of e.children)C.observe(l);N.observe(e,{childList:!0,subtree:!0});const F=()=>{if(x)return;const l=g(),T=l?.getNumericScrollAnchor(e.scrollTop-(l.top??0)),R=T&&m(T.lineNumber),M=R?R.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(rs.delete(n),rs.set(n,{top:e.scrollTop,left:e.scrollLeft,line:T&&M!==null&&M>=0&&M<e.clientHeight?{number:T.lineNumber,offset:M}:void 0}),rs.size>uc){const D=rs.keys().next().value;D!==void 0&&rs.delete(D)}},p=()=>{x=!1,b()};return a.current=y,w.current=F,y(),e.addEventListener("scroll",F,{passive:!0}),e.addEventListener("wheel",p,{passive:!0}),e.addEventListener("touchstart",p,{passive:!0}),e.addEventListener("pointerdown",p,{passive:!0}),e.addEventListener("keydown",p),()=>{a.current=null,w.current=null,f.current?.key===n&&(f.current=null),b(),e.removeEventListener("scroll",F),e.removeEventListener("wheel",p),e.removeEventListener("touchstart",p),e.removeEventListener("pointerdown",p),e.removeEventListener("keydown",p)}},[n,e]),{setScroller:t,restore:v}}function dc(n){return!(!n.autoSaveEnabled||!n.isDirty||!n.canWrite||n.isSaving||n.fileLoading||n.isNonEditableBinary||!n.selectedFilePath||n.loadedFilePath!==n.selectedFilePath)}function fc(n){return n.selectedFilePath?n.isDirty?!(n.fileLoading||n.loadedFilePath!==n.selectedFilePath||n.isNonEditableBinary||n.draftContent===""&&n.fileContent!==""&&n.loadedFilePath!==n.selectedFilePath):!0:!1}const da=2e5,mc=n=>{let e=0,t=0;for(let a=0;a<n.length;a++)n.charCodeAt(a)===10&&(a>0&&n.charCodeAt(a-1)===13?e++:t++);return e>t?`\r
|
|
5
|
+
`:`
|
|
6
|
+
`},fa=n=>n.replace(/\r\n/g,`
|
|
7
|
+
`).replace(/\r/g,`
|
|
8
|
+
`),hc=n=>({content:fa(n),lineEnding:mc(n)}),pc=(n,e)=>{const t=fa(n);return e===`\r
|
|
9
|
+
`?t.replace(/\n/g,`\r
|
|
10
|
+
`):t},gc=(n,e)=>e??(n.length>da?"view":"edit"),xc=n=>{let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return`${n.length}:${e.toString(16)}`},vc='<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 qi(){if(typeof document>"u")return!1;const n=document.documentElement.getAttribute("data-theme");return n==="dark"||!n&&window.matchMedia("(prefers-color-scheme: dark)").matches}const wc=i.forwardRef(function({xml:e,readOnly:t,className:a,onChange:w},f){const v=i.useRef(e),d=i.useRef(null),x=i.useRef(!1),[g,m]=i.useState(qi),b=i.useRef(e),y=i.useRef(e);y.current!==e&&(y.current=e,b.current=e,v.current=e);const C=i.useRef(g);C.current!==g&&(C.current=g,b.current=v.current);const N=i.useRef(null);i.useEffect(()=>{const l=()=>m(qi());l();const T=new MutationObserver(l);return T.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>T.disconnect()},[]),i.useEffect(()=>{const l=setTimeout(()=>{N.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(l)},[]),i.useImperativeHandle(f,()=>({getXml:()=>v.current}));const F=i.useCallback(()=>{!e&&!x.current&&(x.current=!0,setTimeout(()=>{d.current?.template({})},500))},[e]),p=i.useCallback(l=>{v.current=l.xml,w?.(l.xml)},[w]);return r.jsx("div",{ref:N,className:W("h-full w-full",a),children:r.jsx(Ol,{ref:d,xml:b.current||vc,autosave:!0,urlParameters:{ui:t?"simple":g?"dark":"kennedy",spin:!0,libraries:!t,chrome:t,nav:t,layers:t,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:F,onAutoSave:p},g?"dark":"light")})}),Cs=n=>{const e=Re.c(18),{items:t,actions:a,className:w}=n;let f,v,d,x;if(e[0]!==a||e[1]!==w||e[2]!==t){x=Symbol.for("react.early_return_sentinel");e:{const y=t.filter(bc);if(y.length===0&&!a){x=null;break e}e[7]!==w?(d=W("flex min-h-7 items-center gap-2 border-b border-border/40 bg-[var(--surface-subtle)] px-3 py-1",w),e[7]=w,e[8]=d):d=e[8],f="min-w-0 flex-1 truncate typography-meta text-muted-foreground",v=y.join(" · ")}e[0]=a,e[1]=w,e[2]=t,e[3]=f,e[4]=v,e[5]=d,e[6]=x}else f=e[3],v=e[4],d=e[5],x=e[6];if(x!==Symbol.for("react.early_return_sentinel"))return x;let g;e[9]!==f||e[10]!==v?(g=r.jsx("div",{className:f,children:v}),e[9]=f,e[10]=v,e[11]=g):g=e[11];let m;e[12]!==a?(m=a?r.jsx("div",{className:"flex shrink-0 items-center gap-1",children:a}):null,e[12]=a,e[13]=m):m=e[13];let b;return e[14]!==d||e[15]!==g||e[16]!==m?(b=r.jsxs("div",{className:d,children:[g,m]}),e[14]=d,e[15]=g,e[16]=m,e[17]=b):b=e[17],b};function bc(n){return n.length>0}const ks=n=>{if(n===null||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let t=n/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""},yc=n=>{if(n===null||!Number.isFinite(n)||n<0)return"";const e=Math.round(n),t=Math.floor(e/3600),a=Math.floor(e%3600/60),w=e%60,f=v=>String(v).padStart(2,"0");return t>0?`${t}:${f(a)}:${f(w)}`:`${a}:${f(w)}`},ma=n=>n&&n.width>0&&n.height>0?`${n.width} × ${n.height}`:"",jc=n=>{const e=Re.c(28),{name:t,path:a,sizeBytes:w,download:f}=n,{t:v}=st();let d,x,g,m,b,y,C;if(e[0]!==t||e[1]!==a||e[2]!==w||e[3]!==v){const l=Ho(a).toUpperCase();y="flex h-full min-h-0 flex-col",C=r.jsx(Cs,{items:[l,ks(w)]}),g="flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",e[11]!==a?(m=r.jsx(Ns,{filePath:a,className:"size-10"}),e[11]=a,e[12]=m):m=e[12],e[13]!==t?(b=r.jsx("div",{className:"max-w-full truncate typography-ui-header text-foreground",children:t}),e[13]=t,e[14]=b):b=e[14],d="max-w-md typography-ui text-muted-foreground",x=l?v("filesView.artifact.binary.descriptionWithType",{extension:l}):v("filesView.artifact.binary.description"),e[0]=t,e[1]=a,e[2]=w,e[3]=v,e[4]=d,e[5]=x,e[6]=g,e[7]=m,e[8]=b,e[9]=y,e[10]=C}else d=e[4],x=e[5],g=e[6],m=e[7],b=e[8],y=e[9],C=e[10];let N;e[15]!==d||e[16]!==x?(N=r.jsx("div",{className:d,children:x}),e[15]=d,e[16]=x,e[17]=N):N=e[17];let F;e[18]!==f||e[19]!==g||e[20]!==m||e[21]!==b||e[22]!==N?(F=r.jsxs("div",{className:g,children:[m,b,N,f]}),e[18]=f,e[19]=g,e[20]=m,e[21]=b,e[22]=N,e[23]=F):F=e[23];let p;return e[24]!==y||e[25]!==C||e[26]!==F?(p=r.jsxs("div",{className:y,children:[C,F]}),e[24]=y,e[25]=C,e[26]=F,e[27]=p):p=e[27],p},Nc=[48,32,24,18,14],Sc=["ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz",`0123456789 .,;:!?&@#%()[]{}<>+-=/\\*"'`];let Yr=0;const Fc=n=>{const e=Re.c(16),{src:t,name:a,sizeBytes:w}=n,{t:f}=st(),[v,d]=i.useState("loading"),[x]=i.useState(Cc);let g,m;e[0]!==x||e[1]!==t?(g=()=>{let F=!1;d("loading");const p=new FontFace(x,`url("${t.replace(/"/g,"%22")}")`);return document.fonts.add(p),p.load().then(()=>{F||d("ready")}).catch(()=>{F||d("failed")}),()=>{F=!0,document.fonts.delete(p)}},m=[x,t],e[0]=x,e[1]=t,e[2]=g,e[3]=m):(g=e[2],m=e[3]),i.useEffect(g,m);let b;e[4]!==w?(b=ks(w),e[4]=w,e[5]=b):b=e[5];let y;e[6]!==a||e[7]!==b?(y=r.jsx(Cs,{items:[a,b]}),e[6]=a,e[7]=b,e[8]=y):y=e[8];let C;e[9]!==x||e[10]!==v||e[11]!==f?(C=v==="failed"?r.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")}):v==="loading"?r.jsxs("div",{className:"flex items-center gap-2 p-3 typography-ui text-muted-foreground",children:[r.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),f("common.loading")]}):r.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",style:{fontFamily:`"${x}"`},children:r.jsxs("div",{className:"flex flex-col gap-4",children:[Nc.map(F=>r.jsxs("div",{className:"flex items-baseline gap-3",children:[r.jsx("span",{className:"w-8 shrink-0 text-right font-sans typography-meta text-muted-foreground",children:F}),r.jsx("span",{className:"min-w-0 break-words leading-tight text-foreground",style:{fontSize:`${F}px`},children:f("filesView.artifact.font.sample")})]},F)),r.jsx("div",{className:"mt-2 flex flex-col gap-1 border-t border-border/40 pt-4 text-foreground",style:{fontSize:"20px"},children:Sc.map(kc)})]})}),e[9]=x,e[10]=v,e[11]=f,e[12]=C):C=e[12];let N;return e[13]!==y||e[14]!==C?(N=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[y,C]}),e[13]=y,e[14]=C,e[15]=N):N=e[15],N};function Cc(){return Yr=Yr+1,`oc-font-preview-${Yr}`}function kc(n){return r.jsx("div",{className:"break-all leading-relaxed",children:n},n)}const Rc=n=>{const e=Re.c(46),{src:t,name:a,sizeBytes:w}=n,{t:f}=st(),[v,d]=i.useState("fit"),[x,g]=i.useState(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{g(null),d("fit")},e[0]=m):m=e[0];let b;e[1]!==t?(b=[t],e[1]=t,e[2]=b):b=e[2],i.useEffect(m,b);let y;e[3]!==x?(y=ma(x),e[3]=x,e[4]=y):y=e[4];let C;e[5]!==w?(C=ks(w),e[5]=w,e[6]=C):C=e[6];let N;e[7]!==y||e[8]!==C?(N=[y,C],e[7]=y,e[8]=C,e[9]=N):N=e[9];const F=v==="fit";let p;e[10]!==f?(p=f("filesView.artifact.image.fitTitle"),e[10]=f,e[11]=p):p=e[11];let l;e[12]===Symbol.for("react.memo_cache_sentinel")?(l=()=>d("fit"),e[12]=l):l=e[12];let T;e[13]!==f?(T=f("filesView.artifact.image.fit"),e[13]=f,e[14]=T):T=e[14];let R;e[15]!==F||e[16]!==p||e[17]!==T?(R=r.jsx(I,{variant:"chip",size:"xs","aria-pressed":F,title:p,onClick:l,children:T}),e[15]=F,e[16]=p,e[17]=T,e[18]=R):R=e[18];const M=v==="actual";let D;e[19]!==f?(D=f("filesView.artifact.image.actualTitle"),e[19]=f,e[20]=D):D=e[20];let L;e[21]===Symbol.for("react.memo_cache_sentinel")?(L=()=>d("actual"),e[21]=L):L=e[21];let k;e[22]!==M||e[23]!==D?(k=r.jsx(I,{variant:"chip",size:"xs","aria-pressed":M,title:D,onClick:L,children:"1:1"}),e[22]=M,e[23]=D,e[24]=k):k=e[24];let V;e[25]!==R||e[26]!==k?(V=r.jsxs(r.Fragment,{children:[R,k]}),e[25]=R,e[26]=k,e[27]=V):V=e[27];let z;e[28]!==V||e[29]!==N?(z=r.jsx(Cs,{items:N,actions:V}),e[28]=V,e[29]=N,e[30]=z):z=e[30];const B=v==="fit"&&"flex items-center justify-center";let U;e[31]!==B?(U=W("min-h-0 flex-1 overflow-auto p-3",B),e[31]=B,e[32]=U):U=e[32];let Z;e[33]===Symbol.for("react.memo_cache_sentinel")?(Z=H=>{const Q=H.currentTarget;g({width:Q.naturalWidth,height:Q.naturalHeight})},e[33]=Z):Z=e[33];const te=v==="fit"?"max-h-full max-w-full object-contain":"max-w-none";let ee;e[34]!==te?(ee=W("rounded-md border border-border/30 bg-primary/10",te),e[34]=te,e[35]=ee):ee=e[35];let q;e[36]!==a||e[37]!==t||e[38]!==ee?(q=r.jsx("img",{src:t,alt:a,draggable:!1,onLoad:Z,className:ee},t),e[36]=a,e[37]=t,e[38]=ee,e[39]=q):q=e[39];let G;e[40]!==U||e[41]!==q?(G=r.jsx("div",{className:U,children:q}),e[40]=U,e[41]=q,e[42]=G):G=e[42];let X;return e[43]!==z||e[44]!==G?(X=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[z,G]}),e[43]=z,e[44]=G,e[45]=X):X=e[45],X},Tc=n=>{const e=Re.c(24),{kind:t,src:a,name:w,sizeBytes:f,download:v}=n,{t:d}=st(),[x,g]=i.useState(null),[m,b]=i.useState(null),[y,C]=i.useState(!1);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{g(null),b(null),C(!1)},e[0]=N):N=e[0];let F;e[1]!==a?(F=[a],e[1]=a,e[2]=F):F=e[2],i.useEffect(N,F);let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=V=>{const z=V.currentTarget;g(Number.isFinite(z.duration)?z.duration:null),z instanceof HTMLVideoElement&&b({width:z.videoWidth,height:z.videoHeight})},e[3]=p):p=e[3];const l=p;let T;e[4]!==x?(T=yc(x),e[4]=x,e[5]=T):T=e[5];let R;e[6]!==m?(R=ma(m),e[6]=m,e[7]=R):R=e[7];let M;e[8]!==f?(M=ks(f),e[8]=f,e[9]=M):M=e[9];let D;e[10]!==T||e[11]!==R||e[12]!==M?(D=r.jsx(Cs,{items:[T,R,M]}),e[10]=T,e[11]=R,e[12]=M,e[13]=D):D=e[13];let L;e[14]!==v||e[15]!==y||e[16]!==t||e[17]!==w||e[18]!==a||e[19]!==d?(L=y?r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[r.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:d("filesView.artifact.media.unplayable")}),v]}):t==="video"?r.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-[var(--surface-background)] p-3",children:r.jsx("video",{src:a,controls:!0,playsInline:!0,preload:"metadata",title:w,className:"max-h-full max-w-full rounded-md",onLoadedMetadata:l,onError:()=>C(!0)},a)}):r.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4 p-6",children:[r.jsx("div",{className:"typography-ui-label truncate text-foreground",children:w}),r.jsx("audio",{src:a,controls:!0,preload:"metadata",title:w,className:"w-full max-w-lg",onLoadedMetadata:l,onError:()=>C(!0)},a)]}),e[14]=v,e[15]=y,e[16]=t,e[17]=w,e[18]=a,e[19]=d,e[20]=L):L=e[20];let k;return e[21]!==D||e[22]!==L?(k=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[D,L]}),e[21]=D,e[22]=L,e[23]=k):k=e[23],k},Ec=2e3,Vc=n=>n.toLowerCase().endsWith(".tsv")?" ":",",Pc=(n,e,t=Ec)=>{const a=[];let w=0,f="",v=[],d=!1,x=!1;const g=()=>{v.push(f),f="",v.length===1&&v[0]===""&&!x||((w===0||a.length<=t)&&a.push(v),w+=1),v=[],x=!1},m=n.charCodeAt(0)===65279?n.slice(1):n;for(let F=0;F<m.length;F+=1){const p=m[F];if(d){p==='"'?m[F+1]==='"'?(f+='"',F+=1):d=!1:f+=p;continue}if(p==='"'){d=!0,x=!0;continue}if(p===e){v.push(f),f="",x=!0;continue}if(p===`
|
|
11
|
+
`||p==="\r"){p==="\r"&&m[F+1]===`
|
|
12
|
+
`&&(F+=1),g();continue}f+=p}(f.length>0||v.length>0||d)&&g();const b=a[0]??[],y=a.slice(1),C=a.reduce((F,p)=>Math.max(F,p.length),0),N=Math.max(0,w-1);return{header:b,rows:y,totalRows:N,columnCount:C,truncated:y.length<N}},Mc=n=>{const e=Re.c(29),{path:t,content:a,sizeBytes:w}=n,{t:f}=st();let v;e[0]!==a||e[1]!==t?(v=Pc(a,Vc(t)),e[0]=a,e[1]=t,e[2]=v):v=e[2];const d=v;let x;e[3]!==f||e[4]!==d.columnCount||e[5]!==d.totalRows?(x=d.totalRows===1?f("filesView.artifact.table.rowsSingle",{rows:d.totalRows,columns:d.columnCount}):f("filesView.artifact.table.rowsPlural",{rows:d.totalRows,columns:d.columnCount}),e[3]=f,e[4]=d.columnCount,e[5]=d.totalRows,e[6]=x):x=e[6];const g=x;let m;e[7]!==d.columnCount?(m=Array.from({length:d.columnCount},Dc),e[7]=d.columnCount,e[8]=m):m=e[8];const b=m;let y;e[9]!==f||e[10]!==d.rows||e[11]!==d.totalRows||e[12]!==d.truncated?(y=d.truncated?f("filesView.artifact.table.truncated",{shown:d.rows.length,total:d.totalRows}):"",e[9]=f,e[10]=d.rows,e[11]=d.totalRows,e[12]=d.truncated,e[13]=y):y=e[13];let C;e[14]!==w?(C=ks(w),e[14]=w,e[15]=C):C=e[15];let N;e[16]!==g||e[17]!==y||e[18]!==C?(N=r.jsx(Cs,{items:[g,y,C]}),e[16]=g,e[17]=y,e[18]=C,e[19]=N):N=e[19];let F;e[20]!==b||e[21]!==f||e[22]!==d.columnCount||e[23]!==d.header||e[24]!==d.rows?(F=d.columnCount===0?r.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:f("filesView.artifact.table.empty")}):r.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:r.jsxs("table",{className:"min-w-full border-separate border-spacing-0 font-mono typography-meta",children:[r.jsx("thead",{className:"sticky top-0 z-10 bg-[var(--surface-subtle)]",children:r.jsx("tr",{children:b.map(l=>r.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:d.header[l]??""},l))})}),r.jsx("tbody",{children:d.rows.map((l,T)=>r.jsx("tr",{className:"odd:bg-[var(--surface-background)] even:bg-[var(--surface-subtle)]/40",children:b.map(R=>r.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:l[R]??"",children:l[R]??""},R))},T))})]})}),e[20]=b,e[21]=f,e[22]=d.columnCount,e[23]=d.header,e[24]=d.rows,e[25]=F):F=e[25];let p;return e[26]!==N||e[27]!==F?(p=r.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[N,F]}),e[26]=N,e[27]=F,e[28]=p):p=e[28],p};function Dc(n,e){return e}const Zr="data-oc-local-asset",zc=25*1024*1024,Gi=n=>{const e=n.trim();return!e||e.startsWith("#")||e.startsWith("//")?!1:!/^[a-z][a-z\d+.-]*:/i.test(e)},Lc=n=>n.split(/[?#]/,1)[0]??"",Ac=n=>n.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s+/g,"-"),Ic=(n,e)=>{const t=ha(e.replace(/^#/,"")).toLowerCase();if(!t)return!1;for(const a of Array.from(n.querySelectorAll("h1, h2, h3, h4, h5, h6")))if(a.id===t||Ac(a.textContent??"")===t)return a.scrollIntoView({block:"start"}),!0;return!1},ha=n=>{try{return decodeURIComponent(n)}catch{return n}},Xi=({container:n,filePath:e,workspaceRoot:t,onOpenFile:a,enabled:w})=>{const f=i.useRef(a);f.current=a,i.useEffect(()=>{if(!w||!n||!e)return;const v=e.slice(0,e.lastIndexOf("/")+1)||"/",d=p=>qo(v,ha(Lc(p))),x=p=>({path:p,allowOutsideWorkspace:t&&Go(p,t)?void 0:"true",directory:t||void 0});let g=!1;const m=tt(),b=new Map,y=p=>{const l=b.get(p);if(l)return l;const T=(async()=>{const R=await en("/api/fs/raw",{query:x(p),signal:AbortSignal.timeout(3e4)});if(!R.ok)throw new Error(`Image read failed (${R.status})`);const M=await R.blob();if(M.size>zc)throw new Error("Image too large for preview");if(g||tt()!==m)throw new Error("Preview closed");return URL.createObjectURL(M)})();return b.set(p,T),T.catch(()=>b.delete(p)),T},C=()=>{for(const p of Array.from(n.querySelectorAll("img[src]"))){const l=p.getAttribute("src")??"";if(!Gi(l))continue;const T=d(l);p.setAttribute(Zr,T),y(T).then(R=>{g||p.getAttribute(Zr)!==T||p.getAttribute("src")!==R&&(p.src=R)}).catch(()=>{g||p.removeAttribute(Zr)})}},N=p=>{if(p.defaultPrevented||p.button!==0||p.metaKey||p.ctrlKey||p.shiftKey||p.altKey)return;const l=p.target;if(!(l instanceof Element))return;const T=l.closest("a[href]");if(!(T instanceof HTMLAnchorElement)||!n.contains(T))return;const R=T.getAttribute("href")??"";if(R.startsWith("#")){p.preventDefault(),p.stopPropagation(),Ic(n,R);return}Gi(R)&&(p.preventDefault(),p.stopPropagation(),f.current(d(R)))};C();const F=new MutationObserver(C);return F.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["src"]}),n.addEventListener("click",N,!0),()=>{g=!0,F.disconnect(),n.removeEventListener("click",N,!0);for(const p of b.values())p.then(l=>URL.revokeObjectURL(l)).catch(()=>{})}},[n,w,e,t])},Oc=n=>{const e=Y(n);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},Bc=n=>{const e=Re.c(8),{label:t,iconDataUrl:a}=n,[w,f]=i.useState(!1);let v;e[0]!==t?(v=t.trim().slice(0,1).toUpperCase()||"?",e[0]=t,e[1]=v):v=e[1];const d=v;if(a&&!w){let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>f(!0),e[2]=m):m=e[2];let b;return e[3]!==a?(b=r.jsx("img",{src:a,alt:"",className:"size-4 rounded-sm",onError:m}),e[3]=a,e[4]=b):b=e[4],b}let x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=W("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=x):x=e[5];let g;return e[6]!==d?(g=r.jsx("span",{className:x,children:d}),e[6]=d,e[7]=g):g=e[7],g},$c=n=>n.slice().sort((e,t)=>e.type!==t.type?e.type==="directory"?-1:1:e.name.localeCompare(t.name)),Y=n=>{if(!n)return"";const e=n.replace(/\\/g,"/"),t=e.startsWith("//");let a=e.replace(/\/+/g,"/");t&&!a.startsWith("//")&&(a=`/${a}`);const w=a==="/",f=/^[A-Za-z]:\/$/.test(a);return!w&&!f&&(a=a.replace(/\/+$/,"")),a},_c=n=>n.startsWith("/")||n.startsWith("//")||/^[A-Za-z]:\//.test(n),is=n=>/^[A-Za-z]:\//.test(n)?n.toLowerCase():n,Ss=(n,e)=>{const t=Y(e),a=Y(n);if(!t||!a)return!1;const w=is(t),f=is(a);return f===w||f.startsWith(`${w}/`)},Ji=(n,e)=>{const t=Y(e),a=Y(n);if(!Ss(a,t))return[];const f=a.slice(t.length).replace(/^\//,"").split("/"),v=[];let d=t;for(let x=0;x<f.length-1;x++)d=d?`${d}/${f[x]}`:f[x],v.push(d);return v},dr=(n,e)=>{if(!e)return"";const t=Y(e);if(!n||!Ss(t,n))return t;const a=t.slice(n.length);return a.startsWith("/")?a.slice(1):a},Wc=new Set(["node_modules"]),Uc=n=>{const e=Re.c(3),{status:t}=n;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 w=a[t];let f;return e[1]!==w?(f=r.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:w}}),e[1]=w,e[2]=f):f=e[2],f},Yi=n=>{const e=Re.c(11),{name:t}=n,a=i.useRef(null),w=i.useRef(null),[f,v]=i.useState(!1);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const y=a.current,C=w.current;if(!y||!C)return;const N=()=>{v(C.scrollWidth>y.clientWidth+1)};N();const F=new ResizeObserver(N);return F.observe(y),F.observe(C),()=>{F.disconnect()}},e[0]=d):d=e[0];let x;e[1]!==t?(x=[t],e[1]=t,e[2]=x):x=e[2],i.useLayoutEffect(d,x);let g;e[3]!==t?(g=r.jsx("span",{ref:w,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:t}),e[3]=t,e[4]=g):g=e[4];let m;e[5]!==t||e[6]!==f?(m=f?r.jsxs("span",{className:"open-file-name-marquee-track",children:[r.jsx("span",{className:"open-file-name-marquee-item",children:t}),r.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:t})]}):r.jsx("span",{className:"block min-w-0 truncate",children:t}),e[5]=t,e[6]=f,e[7]=m):m=e[7];let b;return e[8]!==g||e[9]!==m?(b=r.jsxs("span",{ref:a,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[g,m]}),e[8]=g,e[9]=m,e[10]=b):b=e[10],b},Kc=n=>Wc.has(n),Hc=n=>{const e=Y(n);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},qc=n=>{const t=(n instanceof Error?n.message:String(n??"")).toLowerCase();return t.includes("is a directory")||t.includes("eisdir")},Zi=n=>{const t=(n instanceof Error?n.message:String(n??"")).toLowerCase();return t.includes("file not found")||t.includes("enoent")||t.includes("no such file")||t.includes("does not exist")},Gc=2e5,pa=(n,e)=>r.jsx(Ns,{filePath:n,extension:e}),Qr=n=>{if(!n)return!1;const e=n.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Qi=n=>{if(!n)return!1;const e=n.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},cr=n=>{if(!n)return!1;const e=n.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Xc=n=>{const e=Re.c(78),{node:t,root:a,isExpanded:w,isActive:f,isMobile:v,isBrowserClient:d,alwaysShowActions:x,status:g,badge:m,permissions:b,downloadFile:y,contextMenuPath:C,setContextMenuPath:N,rightClickMenuPath:F,setRightClickMenuPath:p,onSelect:l,onToggle:T,onRevealPath:R,onOpenDialog:M,canUpload:D,onPickFiles:L}=n,{t:k}=st(),V=t.type==="directory",{canRename:z,canCreateFile:B,canCreateFolder:U,canDelete:Z,canReveal:te}=b,ee=!V&&!!y,q=te&&!d,G=V&&D,X=z||B||U||G||Z||ee||q;let H;e[0]!==X||e[1]!==t.path||e[2]!==p?(H=Ue=>{X&&(Ue?.preventDefault(),p(t.path))},e[0]=X,e[1]=t.path,e[2]=p,e[3]=H):H=e[3];const Q=H;let _e;e[4]!==V||e[5]!==t||e[6]!==l||e[7]!==T?(_e=()=>{V?T(t.path):l(t)},e[4]=V,e[5]=t,e[6]=l,e[7]=T,e[8]=_e):_e=e[8];const ne=_e;let Te;e[9]!==t.path||e[10]!==N||e[11]!==p?(Te=Ue=>{Ue.stopPropagation(),p(null),N(t.path)},e[9]=t.path,e[10]=N,e[11]=p,e[12]=Te):Te=e[12];const De=Te;let ze;e[13]!==B||e[14]!==U||e[15]!==Z||e[16]!==z||e[17]!==q||e[18]!==G||e[19]!==y||e[20]!==d||e[21]!==V||e[22]!==t||e[23]!==M||e[24]!==L||e[25]!==R||e[26]!==a||e[27]!==k?(ze=Ue=>{const{Item:je,Separator:as}=Ue;return r.jsxs(r.Fragment,{children:[z&&r.jsxs(je,{onClick:ue=>{ue.stopPropagation(),M("rename",t)},children:[r.jsx(E,{name:"edit",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.rename")]}),r.jsxs(je,{onClick:ue=>{ue.stopPropagation(),fr(t.path).then(St=>{if(St.ok){re.success(k("sidebarFilesTree.toast.pathCopied"));return}re.error(k("sidebarFilesTree.toast.copyFailed"))})},children:[r.jsx(E,{name:"file-copy",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.copyPath")]}),r.jsxs(je,{onClick:ue=>{ue.stopPropagation();const St=dr(a,t.path)||t.path;fr(St).then(At=>{if(At.ok){re.success(k("filesView.toast.relativePathCopied"));return}re.error(k("sidebarFilesTree.toast.copyFailed"))})},children:[r.jsx(E,{name:"file-copy-2",className:"mr-2 size-4"})," ",k("filesView.tree.menu.copyRelativePath")]}),!V&&y&&r.jsxs(je,{onClick:ue=>{ue.stopPropagation(),y(t.path).catch(St=>{console.error("Download failed:",St),re.error(k("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(E,{name:"download",className:"mr-2 size-4"})," ",k(d?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),q&&r.jsxs(je,{onClick:ue=>{ue.stopPropagation(),R(t.path)},children:[r.jsx(E,{name:"folder-received",className:"mr-2 size-4"})," ",k(gl())]}),V&&(B||U||G)&&r.jsxs(r.Fragment,{children:[r.jsx(as,{}),B&&r.jsxs(je,{onClick:ue=>{ue.stopPropagation(),M("createFile",t)},children:[r.jsx(E,{name:"file-add",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.newFile")]}),U&&r.jsxs(je,{onClick:ue=>{ue.stopPropagation(),M("createFolder",t)},children:[r.jsx(E,{name:"folder-add",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.newFolder")]}),G&&r.jsxs(je,{onClick:ue=>{ue.stopPropagation(),L(t.path)},children:[r.jsx(E,{name:"upload-2",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.uploadFiles")]})]}),Z&&r.jsxs(r.Fragment,{children:[r.jsx(as,{}),r.jsxs(je,{onClick:ue=>{ue.stopPropagation(),M("delete",t)},className:"text-destructive focus:text-destructive",children:[r.jsx(E,{name:"delete-bin",className:"mr-2 size-4"})," ",k("sidebarFilesTree.menu.delete")]})]})]})},e[13]=B,e[14]=U,e[15]=Z,e[16]=z,e[17]=q,e[18]=G,e[19]=y,e[20]=d,e[21]=V,e[22]=t,e[23]=M,e[24]=L,e[25]=R,e[26]=a,e[27]=k,e[28]=ze):ze=e[28];const K=ze,ie=F===t.path;let _;e[29]!==t.path||e[30]!==p?(_=Ue=>p(Ue?t.path:null),e[29]=t.path,e[30]=p,e[31]=_):_=e[31];const ae=v?void 0:Q;let fe;e[32]!==ae?(fe=r.jsx("div",{className:"group relative flex items-center",onContextMenu:ae}),e[32]=ae,e[33]=fe):fe=e[33];const me=v?void 0:Q,ce=f?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let be;e[34]!==ce?(be=W("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",ce),e[34]=ce,e[35]=be):be=e[35];let xe;e[36]!==V||e[37]!==w||e[38]!==t.extension||e[39]!==t.path?(xe=V?w?r.jsx(E,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):r.jsx(E,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):pa(t.path,t.extension),e[36]=V,e[37]=w,e[38]=t.extension,e[39]=t.path,e[40]=xe):xe=e[40];let he;e[41]!==t.name||e[42]!==t.path?(he=r.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]=he):he=e[43];let ve;e[44]!==V||e[45]!==g?(ve=!V&&g&&r.jsx(Uc,{status:g}),e[44]=V,e[45]=g,e[46]=ve):ve=e[46];let Ee;e[47]!==m||e[48]!==V?(Ee=V&&m&&r.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[m.modified>0&&r.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",m.modified]}),m.added>0&&r.jsxs("span",{className:"text-[var(--status-success)]",children:["+",m.added]})]}),e[47]=m,e[48]=V,e[49]=Ee):Ee=e[49];let ye;e[50]!==ne||e[51]!==be||e[52]!==xe||e[53]!==he||e[54]!==ve||e[55]!==Ee||e[56]!==me?(ye=r.jsxs("button",{type:"button",onClick:ne,onContextMenu:me,className:be,children:[xe,he,ve,Ee]}),e[50]=ne,e[51]=be,e[52]=xe,e[53]=he,e[54]=ve,e[55]=Ee,e[56]=me,e[57]=ye):ye=e[57];let lt;e[58]!==x||e[59]!==C||e[60]!==De||e[61]!==X||e[62]!==v||e[63]!==t.path||e[64]!==K||e[65]!==N?(lt=X&&r.jsx("div",{className:W("absolute right-1 top-1/2 -translate-y-1/2",x?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:r.jsxs(tn,{open:C===t.path,onOpenChange:Ue=>N(Ue?t.path:null),children:[r.jsx(sn,{asChild:!0,children:r.jsx(I,{variant:"ghost",size:"icon",className:"size-6",onClick:De,children:r.jsx(E,{name:"more-2-fill",className:"size-4"})})}),r.jsx(rn,{align:"end",side:"bottom",onCloseAutoFocus:()=>N(null),children:K({Item:ur,Separator:pl})})]})}),e[58]=x,e[59]=C,e[60]=De,e[61]=X,e[62]=v,e[63]=t.path,e[64]=K,e[65]=N,e[66]=lt):lt=e[66];let We;e[67]!==ye||e[68]!==lt||e[69]!==fe?(We=r.jsxs(yl,{render:fe,children:[ye,lt]}),e[67]=ye,e[68]=lt,e[69]=fe,e[70]=We):We=e[70];let ct;e[71]!==K?(ct=r.jsx(vl,{className:"min-w-[180px]",children:K({Item:bl,Separator:wl})}),e[71]=K,e[72]=ct):ct=e[72];let Le;return e[73]!==We||e[74]!==ct||e[75]!==ie||e[76]!==_?(Le=r.jsxs(jl,{open:ie,onOpenChange:_,children:[We,ct]}),e[73]=We,e[74]=ct,e[75]=ie,e[76]=_,e[77]=Le):Le=e[77],Le},Jc=n=>{const e=Re.c(83),{activeDialog:t,dialogData:a,dialogInputValue:w,onDialogInputChange:f,isDialogSubmitting:v,onDialogSubmit:d,onClose:x,inputRef:g}=n,{t:m}=st(),b=!!t;let y;e[0]!==x?(y=Q=>!Q&&x(),e[0]=x,e[1]=y):y=e[1];let C;e[2]!==t||e[3]!==m?(C=t==="createFile"&&m("filesView.dialog.createFile.title"),e[2]=t,e[3]=m,e[4]=C):C=e[4];let N;e[5]!==t||e[6]!==m?(N=t==="createFolder"&&m("filesView.dialog.createFolder.title"),e[5]=t,e[6]=m,e[7]=N):N=e[7];let F;e[8]!==t||e[9]!==m?(F=t==="rename"&&m("filesView.dialog.rename.title"),e[8]=t,e[9]=m,e[10]=F):F=e[10];let p;e[11]!==t||e[12]!==m?(p=t==="delete"&&m("filesView.dialog.delete.title"),e[11]=t,e[12]=m,e[13]=p):p=e[13];let l;e[14]!==C||e[15]!==N||e[16]!==F||e[17]!==p?(l=r.jsxs(aa,{children:[C,N,F,p]}),e[14]=C,e[15]=N,e[16]=F,e[17]=p,e[18]=l):l=e[18];let T;e[19]!==t||e[20]!==a?.path||e[21]!==m?(T=t==="createFile"&&m("filesView.dialog.createFile.description",{path:a?.path??m("filesView.dialog.rootFallback")}),e[19]=t,e[20]=a?.path,e[21]=m,e[22]=T):T=e[22];let R;e[23]!==t||e[24]!==a?.path||e[25]!==m?(R=t==="createFolder"&&m("filesView.dialog.createFolder.description",{path:a?.path??m("filesView.dialog.rootFallback")}),e[23]=t,e[24]=a?.path,e[25]=m,e[26]=R):R=e[26];let M;e[27]!==t||e[28]!==a?.name||e[29]!==m?(M=t==="rename"&&m("filesView.dialog.rename.description",{name:a?.name??""}),e[27]=t,e[28]=a?.name,e[29]=m,e[30]=M):M=e[30];let D;e[31]!==t||e[32]!==a?.name||e[33]!==m?(D=t==="delete"&&m("filesView.dialog.delete.description",{name:a?.name??""}),e[31]=t,e[32]=a?.name,e[33]=m,e[34]=D):D=e[34];let L;e[35]!==M||e[36]!==D||e[37]!==T||e[38]!==R?(L=r.jsxs(oa,{children:[T,R,M,D]}),e[35]=M,e[36]=D,e[37]=T,e[38]=R,e[39]=L):L=e[39];let k;e[40]!==L||e[41]!==l?(k=r.jsxs(ia,{children:[l,L]}),e[40]=L,e[41]=l,e[42]=k):k=e[42];let V;e[43]!==t||e[44]!==w||e[45]!==g||e[46]!==f||e[47]!==d||e[48]!==m?(V=t!=="delete"&&r.jsx("div",{className:"py-4",children:r.jsx(Fs,{value:w,onChange:Q=>f(Q.target.value),placeholder:m(t==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:Q=>{Q.key==="Enter"&&d()},ref:g})}),e[43]=t,e[44]=w,e[45]=g,e[46]=f,e[47]=d,e[48]=m,e[49]=V):V=e[49];let z;e[50]!==m?(z=m("filesView.dialog.cancel"),e[50]=m,e[51]=z):z=e[51];let B;e[52]!==v||e[53]!==x||e[54]!==z?(B=r.jsx(I,{variant:"outline",onClick:x,disabled:v,children:z}),e[52]=v,e[53]=x,e[54]=z,e[55]=B):B=e[55];const U=t==="delete"?"destructive":"default";let Z;e[56]!==d?(Z=()=>{d()},e[56]=d,e[57]=Z):Z=e[57];let te;e[58]!==t||e[59]!==w||e[60]!==v?(te=v||t!=="delete"&&!w.trim(),e[58]=t,e[59]=w,e[60]=v,e[61]=te):te=e[61];let ee;e[62]!==t||e[63]!==v||e[64]!==m?(ee=v?r.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):m(t==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=t,e[63]=v,e[64]=m,e[65]=ee):ee=e[65];let q;e[66]!==U||e[67]!==Z||e[68]!==te||e[69]!==ee?(q=r.jsx(I,{variant:U,onClick:Z,disabled:te,children:ee}),e[66]=U,e[67]=Z,e[68]=te,e[69]=ee,e[70]=q):q=e[70];let G;e[71]!==B||e[72]!==q?(G=r.jsxs(la,{children:[B,q]}),e[71]=B,e[72]=q,e[73]=G):G=e[73];let X;e[74]!==g||e[75]!==k||e[76]!==V||e[77]!==G?(X=r.jsxs(na,{initialFocus:g,children:[k,V,G]}),e[74]=g,e[75]=k,e[76]=V,e[77]=G,e[78]=X):X=e[78];let H;return e[79]!==b||e[80]!==y||e[81]!==X?(H=r.jsx(ra,{open:b,onOpenChange:y,children:X}),e[79]=b,e[80]=y,e[81]=X,e[82]=H):H=e[82],H},ns=new Map,Yc=100,ea=n=>{const e=Re.c(13);let t,a,w;e[0]!==n?({positionKey:a,onViewReady:t,...w}=n,e[0]=n,e[1]=t,e[2]=a,e[3]=w):(t=e[1],a=e[2],w=e[3]);const f=i.useRef(null);let v,d;e[4]!==a?(v=()=>()=>{const m=f.current;if(!m)return;const{anchor:b,head:y}=m.state.selection.main;if(ns.delete(a),ns.set(a,{scroll:m.scrollSnapshot(),anchor:b,head:y}),ns.size>Yc){const C=ns.keys().next().value;C!==void 0&&ns.delete(C)}},d=[a],e[4]=a,e[5]=v,e[6]=d):(v=e[5],d=e[6]),i.useLayoutEffect(v,d);let x;e[7]!==t||e[8]!==a?(x=m=>{f.current=m;const b=ns.get(a);b&&m.dispatch({selection:{anchor:Math.min(b.anchor,m.state.doc.length),head:Math.min(b.head,m.state.doc.length)},effects:b.scroll}),t?.(m)},e[7]=t,e[8]=a,e[9]=x):x=e[9];let g;return e[10]!==w||e[11]!==x?(g=r.jsx(Sl,{...w,onViewReady:x}),e[10]=w,e[11]=x,e[12]=g):g=e[12],g},ta=(n,e,t)=>{const a=Re.c(8),[w,f]=i.useState(""),[v,d]=i.useState(0);let x,g;a[0]!==n||a[1]!==t||a[2]!==e?(x=()=>{if(!n){f("");return}let b=!1;f("");const y=Oo(),C=Bo(y);$o(y).then(F=>{b||!F||(f(n),e(null))}).catch(F=>{b||(e(F instanceof Error?F.message:t),f(n))});const N=_o(()=>{b||(f(n),d(Zc),e(null))});return()=>{b=!0,C(),N()}},g=[n,e,t],a[0]=n,a[1]=t,a[2]=e,a[3]=x,a[4]=g):(x=a[3],g=a[4]),i.useEffect(x,g);let m;return a[5]!==v||a[6]!==w?(m={readyKey:w,nonce:v},a[5]=v,a[6]=w,a[7]=m):m=a[7],m},yf=({mode:n="full",visible:e=!0})=>{const{t}=st(),{files:a,runtime:w}=Xo(),{currentTheme:f,availableThemes:v,lightThemeId:d,darkThemeId:x}=Jo(),{isMobile:g,isTablet:m,screenWidth:b}=Yo(),y=Mo(w.platform),C=g||m,N=Do(),F=zo(),p=sa()??"",l=Y(p.trim()),T=g||n==="full",R=T&&e,M=Zo(s=>s.runtimeKey),D=JSON.stringify([M,l]),L=i.useRef(D);L.current=D;const k=JSON.stringify([M,l,N,F]),V=i.useRef(k);V.current=k;const z=n!=="editor-only",B=n==="editor-only"&&!g,U=Lo(s=>s.searchFiles),Z=Qo(R?p:null),[te,ee]=i.useState(""),q=el(te,200),G=i.useRef(null),[X,H]=i.useState(!1),[Q,_e]=i.useState(!0),[ne,Te]=i.useState(!1),[De,ze]=i.useState(!1),K=i.useRef(0),ie=i.useCallback(s=>{K.current=Math.max(0,K.current+(s?1:-1))},[]),[_,ae]=i.useState("edit"),[fe,me]=i.useState("edit"),[ce,be]=i.useState("tree"),[xe,he]=i.useState("edit"),[ve,Ee]=i.useState("preview"),[ye,lt]=i.useState("preview"),[We,ct]=i.useState("preview"),[Le,Ue]=i.useState("table"),[je,as]=i.useState(null),[ue,St]=i.useState(0),At=i.useRef({}),hr=i.useRef({}),pr=i.useRef({}),nn=i.useRef({}),an=i.useRef({}),on=i.useRef({}),gr=i.useRef({}),Rs=i.useMemo(()=>v.find(s=>s.metadata.id===d)??Di(!1),[v,d]),Ts=i.useMemo(()=>v.find(s=>s.metadata.id===x)??Di(!0),[v,x]);i.useEffect(()=>{$i(Rs),$i(Ts)},[Rs,Ts]);const Es=i.useMemo(()=>[],[]),Ne=et(s=>l?s.byRoot[l]?.openPaths??Es:Es),Ft=et(s=>l?s.byRoot[l]?.selectedPath??null:null),rt=et(s=>l?s.byRoot[l]?.expandedPaths??Es:Es),ga=i.useMemo(()=>new Set(rt),[rt]),It=et(s=>s.removeOpenPath),pt=et(s=>s.removeOpenPathsByPrefix),ln=et(s=>s.removeExpandedPathsByPrefix),Se=et(s=>s.setSelectedPath),cn=et(s=>s.toggleExpandedPath),Vs=et(s=>s.expandPaths),Ot=i.useCallback(s=>{const o=Y(s),u=o.split("/"),h=u[u.length-1]||o,j=h.includes(".")?h.split(".").pop()?.toLowerCase():void 0;return{name:h,path:o,type:"file",extension:j}},[]),Bt=i.useMemo(()=>Ne.map(Ot),[Ne,Ot]),xr=i.useMemo(()=>{if(Ft){const s=is(Ft);if(Ne.some(o=>is(o)===s))return Ft}return Ne[0]??null},[Ne,Ft]),c=i.useMemo(()=>xr?Ot(xr):null,[xr,Ot]),nt=c?.path??"";i.useEffect(()=>{if(!l||!Ft)return;const s=is(Ft);Ne.some(u=>is(u)===s)||Se(l,Ne[0]??null)},[Ne,l,Ft,Se]);const vr=!!(l&&nt&&!Ss(nt,l)),wr=i.useMemo(()=>({allowOutsideWorkspace:vr,directory:l||void 0}),[vr,l]),gt=i.useCallback(s=>({allowOutsideWorkspace:!!(l&&!Ss(s,l))}),[l]),br=i.useRef(null),[un,xa]=i.useState({left:!1,right:!1}),dn=i.useCallback(()=>{const s=br.current;s&&xa({left:s.scrollLeft>2,right:s.scrollLeft+s.clientWidth<s.scrollWidth-2})},[]),fn=i.useRef(dn);fn.current=dn,i.useEffect(()=>{const s=br.current;if(!s)return;const o=()=>fn.current();o(),s.addEventListener("scroll",o,{passive:!0});const u=new ResizeObserver(o);return u.observe(s),()=>{s.removeEventListener("scroll",o),u.disconnect()}},[Bt.length]);const[mn,yr]=i.useState({}),[Ps,os]=i.useState({}),Ke=i.useRef(new Set),Ve=i.useMemo(()=>new Ml,[]);i.useEffect(()=>()=>Ve.clear(),[Ve]);const[hn,Ms]=i.useState([]),[va,Ds]=i.useState(!1),[$,pe]=i.useState(""),{isPlaying:zs,play:wa,stop:ba}=tl(),[Fe,xt]=i.useState(!1),[Xe,we]=i.useState(null),[ya,He]=i.useState(""),[ge,de]=i.useState(null),vt=JSON.stringify([tt(),l,ge]),[se,Ce]=i.useState(""),[ls,jr]=i.useState(!1),[pn,ja]=i.useState(`
|
|
13
|
+
`),Na=i.useRef(null),it=i.useRef(null),Ae=i.useRef(null),wt=i.useRef(""),cs=i.useRef(""),ut=i.useRef(null),gn=i.useRef(null),Je=i.useRef(null),Nr=i.useRef(""),Sr=i.useRef(0),$t=i.useRef(0),Ct=i.useRef(null),[us,Sa]=i.useState(0),[Fa,_t]=i.useState("idle"),[Ca,Ls]=i.useState(!1),[kt,xn]=i.useState(!1),ke=mt(s=>s.autoSaveEnabled),ka=mt(s=>s.setAutoSaveEnabled),[Fr,ds]=i.useState(!1),Wt=i.useRef(null),fs=i.useRef(null),ms=i.useRef(!1),hs=i.useRef(null),ps=i.useRef(null),Ye=i.useRef(null),As=i.useRef(null),[Ra,Cr]=i.useState(0),Ut=i.useRef(null),Rt=i.useRef({key:"",attempts:0});i.useEffect(()=>()=>{Ut.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Ut.current),Ut.current=null)},[]);const[Tt,kr]=i.useState(null),[Et,Ta]=i.useState(null),[bt,vn]=i.useState(""),[Ea,Rr]=i.useState(!1),[Va,Pa]=i.useState(null),[Ma,Da]=i.useState(null),[za,wn]=i.useState(!1),[La,bn]=i.useState(!1),[Aa,Tr]=i.useState(!1),[yn,Is]=i.useState(!1),[jn,Nn]=i.useState(0),Os=i.useRef(null),Bs=i.useCallback(s=>{const o=s?.currentTarget??Os.current;if(!o)return;const u=document.activeElement;u&&u!==document.body&&u!==o&&(sl(u)||o.contains(u))||o.focus({preventScroll:!0})},[]),$s=i.useRef(null),Sn=!!a.writeFile,Fn=!!a.createDirectory,Cn=!!a.rename,kn=!!a.delete,Rn=!!a.revealPath,Ia=or(s=>s.availableApps),Oa=or(s=>s.isCacheStale),Tn=or(s=>s.initialize),Ba=or(s=>s.loadInstalledApps);i.useEffect(()=>{Tn()},[Tn]);const $a=i.useCallback(s=>{a.revealPath&&a.revealPath(s).catch(()=>{re.error(t("sidebarFilesTree.toast.revealFailed"))})},[a,t]),_a=i.useCallback(async s=>{if(!c?.path||await Ao(c.path,s.id,s.appName)||await Vi(c.path,s.appName))return;const h=Oc(c.path)||l;h&&await Vi(h,s.appName)||re.error(t("filesView.toast.openInAppFailed",{app:s.appName}))},[l,c?.path,t]),Er=i.useCallback((s,o)=>{kr(s),Ta(o),vn(s==="rename"&&o.name||""),Rr(!1)},[]),[J,Ze]=i.useState(null),Kt=i.useRef(!1),yt=i.useRef(null),[En,Ht]=i.useState(!1),at=mt(s=>s.pendingFileNavigation),_s=mt(s=>s.setPendingFileNavigation),Vr=mt(s=>s.pendingFileFocusPath),Pr=mt(s=>s.setPendingFileFocusPath),Vn=mt(s=>s.fileEditorKeymap),gs=zi(s=>s.settingsDefaultFileViewerPreview),Wa=zi(s=>s.showMessageTTSButtons);i.useEffect(()=>{const s=()=>{Kt.current=!1,yt.current=null,Ht(!1)};return document.addEventListener("mouseup",s),()=>document.removeEventListener("mouseup",s)},[]),i.useEffect(()=>()=>{hs.current!==null&&window.clearTimeout(hs.current),ps.current!==null&&window.clearTimeout(ps.current)},[]);const Ua=i.useCallback((s,o)=>{const u=s.split(`
|
|
14
|
+
`),h=Math.max(1,o.start),j=Math.min(u.length,o.end);return h>j?"":u.slice(h-1,j).join(`
|
|
15
|
+
`)},[]),Pn=i.useRef(null),Ka=$l({source:"file",fileLabel:c?.path??null,language:c?.path&&Kr(c.path)||"text",getCodeForRange:s=>Ua($,_l(s)),toStoreRange:s=>({startLine:s.start,endLine:s.end}),fromDraftRange:s=>({start:s.startLine,end:s.endLine})}),{drafts:Mn,commentText:Ws,setCommentText:Dn,editingDraftId:Us,setSelection:zn,saveComment:Ln,cancel:xs,reset:An,startEdit:In,deleteDraft:On}=Ka;i.useEffect(()=>{Ze(null),An(),Ce(""),jr(!1)},[c?.path,An]),i.useEffect(()=>{zn(J)},[J,zn]),i.useEffect(()=>{if(!J&&!Us)return;const s=u=>{const h=u.target;h.closest('[data-comment-input="true"]')||h.closest('[data-comment-card="true"]')||h.closest(".cm-gutterElement")||h.closest("[data-sonner-toast]")||h.closest("[data-sonner-toaster]")||Ws.trim()||(Ze(null),xs())},o=setTimeout(()=>{document.addEventListener("click",s)},100);return()=>{clearTimeout(o),document.removeEventListener("click",s)}},[xs,Ws,Us,J]);const Bn=i.useCallback((s,o)=>{const u=o??J??void 0;o&&Ze(o),Ln(s,u),Ze(null)},[J,Ln]),$n=i.useCallback((s,o)=>{const u=[];for(const h of o){if(!(h&&typeof h.name=="string"&&h.name.length>0)||!N&&h.name.startsWith(".")||!F&&Kc(h.name))continue;const j=h.name,S=Y(h.path||""),P=S?_c(S)?S:Y(`${s}/${S}`):Y(`${s}/${j}`),O=h.isDirectory?"directory":"file",oe=O==="file"&&j.includes(".")?j.split(".").pop()?.toLowerCase():void 0;u.push({name:j,path:P,type:O,extension:oe})}return $c(u)},[F,N]),Pe=i.useCallback(async(s,o=!1)=>{if(!R)return;const u=Y(s.trim());if(!u||!o&&Ke.current.has(u))return;const h=V.current,j=tt();return Ve.run(u,async S=>{const P=()=>S()&&V.current===h&&tt()===j;try{const O=a.listDirectory?(await a.listDirectory(u)).entries:await Io.listLocalDirectory(u);if(!P())return;const oe=$n(u,O);Ke.current=new Set(Ke.current),Ke.current.add(u),os(A=>{if(!A[u])return A;const le={...A};return delete le[u],le}),yr(A=>A[u]&&Dl(A[u],oe)?A:{...A,[u]:oe})}catch(O){if(!P())return;const oe=O instanceof Error?O.message:String(O??"");if(oe==="Directory not found"&&l&&u!==l){ln(l,u),os(A=>{if(!A[u])return A;const le={...A};return delete le[u],le});return}console.error("Failed to load files directory:",O),os(A=>({...A,[u]:oe}))}},o)},[Ve,a,$n,ln,l,R]),Ks=i.useCallback(async()=>{l&&(Ke.current=new Set,Ve.clear(),os({}),yr(s=>Object.keys(s).length===0?s:{}),await Pe(l))},[Ve,Pe,l]),Ie=i.useCallback(async s=>{if(!s){await Ks();return}const o=Y(s);Ke.current=new Set(Ke.current),Ke.current.delete(o),await Pe(o,!0)},[Pe,Ks]),{canUpload:_n,uploadingDirectory:Ha,pickFiles:Wn,uploadElements:qa}=zl({root:l,refreshDirectory:Ie}),Hs=Ha!==null,Un=i.useRef(""),Kn=i.useRef("");i.useEffect(()=>{if(!l)return;const s=k,o=Un.current!==D,u=Kn.current!==s;!o&&!u||(o&&(Un.current=D,$t.current+=1,Ct.current=null,pe(""),we(null),He(""),de(null),H(!1)),u&&(Kn.current=s,Ke.current=new Set,Ve.clear(),os({}),yr(h=>Object.keys(h).length===0?h:{}),Pe(l)))},[Ve,D,Pe,l,k]),i.useEffect(()=>{if(!R||!a.listDirectory)return;const s=()=>{if(!document.hidden&&rt.length>0)for(const o of rt)Ve.has(o)||Ie(o)};return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[Ve,rt,a.listDirectory,Ie,R]);const Hn=i.useRef(!1);i.useEffect(()=>{const s=R&&!Hn.current;if(Hn.current=R,!(!R||!l)&&(Pe(l),s))for(const o of rt)Ve.has(o)||Ie(o)},[Ve,rt,Pe,Ie,l,R]),i.useEffect(()=>{if(!R||!a.listDirectory||rt.length===0)return;const s=setInterval(()=>{if(!document.hidden)for(const o of rt)Ve.has(o)||Ie(o)},8e3);return()=>clearInterval(s)},[Ve,rt,a.listDirectory,Ie,R]);const Ga=i.useCallback(async s=>{if(s?.preventDefault(),!Et||!Tt)return;Rr(!0);const o=()=>{kr(null)},u=j=>{re.error(j)},h=()=>{Rr(!1)};if(Tt==="createFile"){if(!bt.trim()){u(t("sidebarFilesTree.toast.filenameRequired")),h();return}if(!a.writeFile){u(t("sidebarFilesTree.toast.writeNotSupported")),h();return}const j=Et.path,S=j?`${j}/`:"",P=Y(`${S}${bt.trim()}`);await a.writeFile(P,"").then(async O=>{O.success&&(re.success(t("sidebarFilesTree.toast.fileCreated")),await Ie(j)),o()}).catch(()=>u(t("sidebarFilesTree.toast.operationFailed"))).finally(h);return}if(Tt==="createFolder"){if(!bt.trim()){u(t("sidebarFilesTree.toast.folderNameRequired")),h();return}const j=Et.path,S=j?`${j}/`:"",P=Y(`${S}${bt.trim()}`);await a.createDirectory(P).then(async O=>{O.success&&(re.success(t("sidebarFilesTree.toast.folderCreated")),await Ie(j)),o()}).catch(()=>u(t("sidebarFilesTree.toast.operationFailed"))).finally(h);return}if(Tt==="rename"){if(!bt.trim()){u(t("sidebarFilesTree.toast.nameRequired")),h();return}if(!a.rename){u(t("sidebarFilesTree.toast.renameNotSupported")),h();return}const j=Et.path,S=j.split("/").slice(0,-1).join("/"),P=S?`${S}/`:"",O=Y(`${P}${bt.trim()}`);await a.rename(j,O).then(async oe=>{oe.success&&(re.success(t("sidebarFilesTree.toast.renamedSuccessfully")),await Ie(S),l&&pt(l,j),(c?.path===j||c?.path.startsWith(`${j}/`))&&(l&&Se(l,null),pe(""),we(null),He(""),de(null),g&&H(!1))),o()}).catch(()=>u(t("sidebarFilesTree.toast.operationFailed"))).finally(h);return}if(Tt==="delete"){if(!a.delete){u(t("sidebarFilesTree.toast.deleteNotSupported")),h();return}const j=Et.path,S=j.split("/").slice(0,-1).join("/");await a.delete(j).then(async P=>{P.success&&(re.success(t("sidebarFilesTree.toast.deletedSuccessfully")),await Ie(S),l&&pt(l,j),(c?.path===j||c?.path.startsWith(`${j}/`))&&(l&&Se(l,null),pe(""),we(null),He(""),de(null),g&&H(!1))),o()}).catch(()=>u(t("sidebarFilesTree.toast.operationFailed"))).finally(h);return}h()},[Tt,Et,bt,a,Ie,g,pt,l,c?.path,Se,t]);i.useEffect(()=>{if(!p){Ms([]),Ds(!1);return}const s=q.trim();if(!s){Ms([]),Ds(!1);return}let o=!1;return Ds(!0),U(p,s,150,{includeHidden:N,respectGitignore:!F,type:"file"}).then(u=>{if(o)return;const j=u.filter(S=>F||!Hc(S.path)).map(S=>({name:S.name,path:Y(S.path),type:"file",extension:S.extension,relativePath:S.relativePath}));Ms(j)}).catch(()=>{o||Ms([])}).finally(()=>{o||Ds(!1)}),()=>{o=!0}},[p,q,U,N,F]);const qs=i.useCallback(async(s,o)=>{const u=gt(s);if(a.readFile)return(await a.readFile(s,{...u,directory:l||void 0,...o})).content??"";const h=new URLSearchParams({path:s});u.allowOutsideWorkspace&&h.set("allowOutsideWorkspace","true"),l&&h.set("directory",l);const j=await en(`/api/fs/read?${h.toString()}`,{cache:o?.fresh?"no-store":"default",signal:AbortSignal.timeout(3e4)});if(!j.ok){const S=await j.json().catch(()=>({error:j.statusText}));throw new Error(S.error||t("filesView.error.readFileFailed"))}return j.text()},[a,gt,l,t]),ot=i.useCallback(async s=>{if(a.statFile){const o=gt(s),u=await a.statFile(s,{...o,directory:l||void 0});return{path:u.path,size:u.size,mtimeMs:u.mtimeMs}}return null},[a,gt,l]);i.useEffect(()=>{if(!l||!a.statFile||Ne.length===0)return;let s=!1;const o=[...Ne];return Promise.all(o.map(async u=>{try{const h=gt(u),j=await a.statFile?.(u,{...h,directory:l||void 0});!s&&j&&!j.isFile&&pt(l,u)}catch(h){!s&&Zi(h)&&pt(l,u)}})),()=>{s=!0}},[a,Ne,pt,gt,l]);const Oe=se!==$,qt=i.useCallback(async()=>{if(!c||!a.writeFile)return re.error(t("filesView.toast.savingNotSupported")),!1;const s=bs(c.path)||kt;if(!fc({selectedFilePath:c.path,loadedFilePath:ge,fileLoading:Fe,isDirty:Oe,draftContent:se,fileContent:$,isNonEditableBinary:s}))return s?console.warn(`[saveDraft] refusing to save binary file "${c.path}".`):se===""&&$!==""&&ge!==c.path&&console.warn(`[saveDraft] refusing to save empty draft for "${c.path}" (${$.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(!Oe)return!0;jr(!0);try{const o=pc(se,pn);if(!(await a.writeFile(c.path,o))?.success)return re.error(t("filesView.toast.writeFileFailed")),!1;if(pe(se),Nr.current=o,Sr.current+=1,l&&Ss(c.path,l)){const h=dr(l,c.path);h&&rl.requestGitRefresh({directory:l,paths:[h]})}if(l&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(Y(c.path))){const h=nl.getState().projects.find(j=>Y(j.path)===Y(l));if(h)try{await Ll(h.id)}catch{re.error(t("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return c?.path&&ys(c.path)&&(wt.current=se,cs.current=se),ot(c.path).then(h=>{h&&(Je.current=h)}).catch(()=>{}),!0}catch(o){return re.error(o instanceof Error?o.message:t("filesView.toast.saveFailed")),!1}finally{jr(!1)}},[kt,se,$,Fe,a,Oe,pn,ge,ot,l,c,t]);i.useEffect(()=>{ke||(_t("idle"),it.current&&(clearTimeout(it.current),it.current=null))},[ke]);const qn=1500;i.useEffect(()=>{const s=!!(c&&a.writeFile),o=!!(c?.path&&(bs(c.path)||kt));if(dc({autoSaveEnabled:ke,isDirty:Oe,canWrite:s,isSaving:ls,fileLoading:Fe,selectedFilePath:c?.path,loadedFilePath:ge,isNonEditableBinary:o}))return it.current=setTimeout(()=>{qt().then(u=>{u&&(_t("saved"),setTimeout(()=>_t("idle"),2e3))})},qn),()=>{it.current&&(clearTimeout(it.current),it.current=null)}},[ke,kt,se,Fe,Oe,ge,c,a.writeFile,ls,qt]),i.useEffect(()=>{_t("idle")},[c?.path]),il({save_file:s=>{if(!(s.target instanceof Node)||!As.current?.contains(s.target))return!1;it.current&&(clearTimeout(it.current),it.current=null),ls||qt().then(o=>{o&&(_t("saved"),setTimeout(()=>_t("idle"),2e3))})},find_in_file:s=>{if(!(s.target instanceof Node))return!1;if(Ge&&$e()==="preview"){if(g||!(ne?$s.current:Os.current)?.contains(s.target))return!1;Is(!0),Nn(u=>u+1);return}if(!As.current?.contains(s.target))return!1;ze(!0)}});const Gt=i.useCallback(s=>{const{content:o,lineEnding:u}=hc(s);return Nr.current=s,Sr.current+=1,ja(u),pe(o),wt.current=o,cs.current=o,Ce(o),o},[]),Gn=i.useCallback(async s=>{const o=$t.current+1;$t.current=o;const u=tt(),h=L.current,j=()=>{if(!l||tt()!==u||L.current!==h)return!1;const A=et.getState().byRoot[l],le=A?.selectedPath??A?.openPaths[0]??null;return $t.current===o&&le===s.path};we(null),He(""),de(null),xn(!1),xt(!0);const S=Hr(s.path),P=qr(s.path),O=Li(s.path),oe=bs(s.path);if(g&&H(!0),w.isDesktop&&S&&!P){pe(""),Ce("");return}if(!w.isDesktop&&S&&!P){pe(""),Ce(""),de(s.path),xt(!1);return}if(O){pe(""),Ce(""),de(s.path),xt(!1);return}if(oe){pe(""),Ce(""),de(s.path),xt(!1);return}await qs(s.path).then(A=>{if(!j())return;if(Ai(A)){xn(!0),pe(""),Ce(""),de(s.path);return}const le=Gt(A),Vt=Qr(s.path)||cr(s.path)||Qi(s.path)||ys(s.path)||qr(s.path)||Ii(s.path)||Oi(s.path);ae(Vt?"edit":gc(le,At.current[s.path])),de(s.path),ot(s.path).then(ss=>{ss&&j()&&(Je.current=ss)}).catch(()=>{})}).catch(A=>{if(j()){if(qc(A)){if(xt(!1),l&&Se(l,null),we(null),pe(""),Ce(""),de(null),Je.current=null,te.trim().length>0&&ee(""),g&&H(!1),l){const Vt=[...Ji(s.path,l),s.path];Vt.length>0&&Vs(l,Vt);for(const ss of Vt)Ke.current.has(ss)||Pe(ss)}return}if(Zi(A)){l&&pt(l,s.path),pe(""),Ce(""),we(null),Je.current=null,g&&H(!1);return}pe(""),Ce(""),we(A instanceof Error?A.message:t("filesView.error.readFileFailed")),Je.current=null}}).finally(()=>{j()&&xt(!1)})},[Gt,Vs,g,Pe,qs,ot,pt,l,w.isDesktop,te,Se,t]),Gs=i.useCallback(async(s,o)=>{if(!e||!l)return;const u=Ji(s,l),h=o?[...u,s]:u;if(h.length>0&&Vs(l,h),!R)return;const j=h.map(S=>{if(!Ke.current.has(S))return Pe(S)}).filter(Boolean);await Promise.all(j)},[Vs,Pe,l,R,e]),Xn=i.useCallback((s,o)=>{const u=o.findIndex(h=>h.path===s);return u===-1||o.length<=1?null:o[u+1]??o[u-1]??null},[]),Me=i.useCallback(async s=>{if(ms.current)ms.current=!1;else if(Oe){ds(!0),Wt.current=s;return}l&&(Se(l,s.path),Gs(s.path,!1)),we(null),He(""),pe(""),wt.current="",cs.current="",Ce(""),de(null),g&&H(!0)},[Gs,Oe,g,l,Se]);i.useEffect(()=>{c?.path&&Gs(c.path,!1)},[Gs,c?.path]),i.useEffect(()=>{if(!e)return;if(!c){$t.current+=1,Ct.current=null,xt(!1);return}if(ge===c.path||Ct.current===c.path)return;const s=c.path;Ct.current=s,Gn(c).finally(()=>{Ct.current===s&&(Ct.current=null)})},[us,Gn,ge,c,e]);const Xs=i.useRef(Oe);Xs.current=Oe,i.useEffect(()=>Al(({runtimeKey:s,paths:o})=>{const u=c?.path;s!==tt()||!u||Xs.current||!o.includes(Y(u))||($t.current+=1,Ct.current=null,Je.current=null,He(""),we(null),de(null),Sa(h=>h+1))}),[c?.path]),i.useEffect(()=>{if(!e||!c?.path||ge!==c.path)return;const s=c.path,o=tt(),u=L.current,h=()=>Xs.current||ys(s)&&wt.current!==cs.current,j=!bs(s)&&!Hr(s)&&!kt?ac({readContent:()=>qs(s,{fresh:!0}),getLoadedContent:()=>Nr.current,getLoadedRevision:()=>Sr.current,isDirty:h,applyContent:A=>{if(!(S||tt()!==o||L.current!==u)){if(Ai(A)){de(null);return}Gt(A)}}}):null;let S=!1,P=!1;const O=()=>{document.hidden||P||(P=!0,ot(s).then(async A=>{if(S||tt()!==o||L.current!==u||!A)return;const le=Je.current;if(!le||le.path!==s){Je.current=A;return}if(lc(le,A)){if(j&&A.size<=Gc){await j.poll()&&!S&&(Je.current=A);return}Xs.current||(Je.current=A,de(null))}}).catch(()=>{}).finally(()=>{P=!1}))};O();const oe=window.setInterval(O,2e3);return()=>{S=!0,j?.dispose(),window.clearInterval(oe)}},[Gt,kt,ge,qs,ot,c?.path,e]);const Xa=i.useCallback(()=>{const s=Wt.current,o=fs.current;if(Wt.current=null,fs.current=null,ms.current=!0,ds(!1),Ce($),o){l&&It(l,o),c?.path===o&&(s?Me(s):(l&&Se(l,null),pe(""),we(null),He(""),de(null),g&&H(!1)));return}if(s){Me(s);return}},[$,Me,g,It,l,c?.path,Se]),Ja=i.useCallback(async()=>{const s=Wt.current,o=fs.current;if(!await qt()){ms.current=!1;return}if(Wt.current=null,fs.current=null,ms.current=!0,ds(!1),o){l&&It(l,o),c?.path===o&&(s?await Me(s):(l&&Se(l,null),pe(""),we(null),He(""),de(null),g&&H(!1)));return}if(s){await Me(s);return}},[Me,g,It,l,qt,c?.path,Se]),Jn=i.useCallback(s=>{const o=c?.path===s,u=Xn(s,Bt);if(o&&Oe){ds(!0),Wt.current=u,fs.current=s;return}if(l&&It(l,s),!!o){if(u){Me(u);return}l&&Se(l,null),pe(""),we(null),He(""),de(null),g&&H(!1)}},[Xn,Me,Oe,g,Bt,It,l,c?.path,Se]),Yn=i.useMemo(()=>new Set(Ne),[Ne]),Js=i.useMemo(()=>Il(T?Z?.files??[]:[]),[Z?.files,T]),Ya=i.useCallback(s=>{if(Yn.has(s))return"open";const o=s.startsWith(l+"/")?s.slice(l.length+1):s;return Js.statusByPath.get(o)??null},[Yn,Js,l]),Za=i.useCallback(s=>{if(!Z?.files)return null;const o=s.startsWith(l+"/")?s.slice(l.length+1):s;return Js.badgeByDir.get(o)??null},[Z,Js,l]),Qa=i.useCallback(async s=>{const o=Y(s);l&&(cn(l,o),Ke.current.has(o)||await Pe(o))},[Pe,l,cn]),eo=i.useMemo(()=>({canRename:Cn,canCreateFile:Sn,canCreateFolder:Fn,canDelete:kn,canReveal:Rn}),[Cn,Sn,Fn,kn,Rn]);function Zn(s,o){const u=mn[s]??[];return u.map((h,j)=>{const S=h.type==="directory",P=S&&ga.has(h.path),O=c?.path===h.path,oe=j===u.length-1;return r.jsxs("li",{className:"relative",children:[o>0&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),oe&&r.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),r.jsx(Xc,{node:h,root:l,isExpanded:P,isActive:O,isMobile:g,isBrowserClient:y,alwaysShowActions:C,status:S?void 0:Ya(h.path),badge:S?Za(h.path):void 0,permissions:eo,downloadFile:a.downloadFile,contextMenuPath:Va,setContextMenuPath:Pa,rightClickMenuPath:Ma,setRightClickMenuPath:Da,onSelect:Me,onToggle:Qa,onRevealPath:$a,onOpenDialog:Er,canUpload:_n&&!Hs,onPickFiles:Wn}),S&&P&&r.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[Ps[h.path]?r.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:Ps[h.path],children:Ps[h.path]}),r.jsxs(I,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ie(h.path)},children:[r.jsx(E,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})]}):null,Zn(h.path,o+1)]})]},h.path)})}const Be=!!(c?.path&&Hr(c.path)),qe=!!(c?.path&&qr(c.path)),Qn=qe&&ye==="edit",jt=!!(c?.path&&Li(c.path)),ei=!!(c?.path&&al(c.path)),Mr=ei||!!(c?.path&&ol(c.path)),Dr=!!(c?.path&&ll(c.path)),Ys=!!(c?.path&&(bs(c.path)||kt)),Xt=Ys&&!Be&&!jt&&!Mr&&!Dr,ti=Ys||Be&&!Qn,si=i.useMemo(()=>Y(at?.path??""),[at?.path]),Jt=!!(at&&si&&nt&&nt===si&&!Fe&&!Xe&&!ti),Nt=i.useMemo(()=>dr(l,nt),[nt,l]),to=!!(c&&(!Be||qe)&&!jt&&!Xt&&$.length>0),so=!!(c&&Nt.length>0),Qe=!!(c&&!vr&&!Ys&&(!Be||qe)&&a.writeFile),Ge=!!(c?.path&&Qr(c.path)),Yt=!!(c?.path&&Qi(c.path)),Zt=!!(c?.path&&cr(c.path)),vs=!!(c?.path&&ys(c.path)),Qt=!!(c?.path&&Ii(c.path)),es=!!(c?.path&&Oi(c.path)),Zs=!!(c&&!Ys&&(!Be||qe))&&!Ge&&!vs&&!(Zt&&xe==="preview")&&!(qe&&ye==="preview")&&!(Qt&&We==="preview")&&!(es&&Le==="table"),ro=Ge&&fe==="edit"||Zt&&xe==="edit"||qe&&ye==="edit"||Qt&&We==="edit"||es&&Le==="text"||Yt&&ce==="text"||!Ge&&!Zt&&!Yt&&!qe&&!Qt&&!es&&_==="edit",Qs=i.useMemo(()=>nt?cl(nt):null,[nt]),[ri,zr]=i.useState(null);i.useEffect(()=>{let s=!1;const o=c?.path;if(!o||Qs){zr(null);return}return zr(null),ul(o).then(u=>{s||zr(u)}),()=>{s=!0}},[c?.path,Qs]),i.useEffect(()=>{!Qe&&_==="edit"&&ae("view")},[Qe,_]);const Lr="openchamber:files:md-viewer-mode",Ar="openchamber:files:html-viewer-mode",Ir="openchamber:files:json-viewer-mode";i.useEffect(()=>{const s=c?.path;if(!s)return;ae(At.current[s]??"edit");let o=gs?"preview":"edit";try{const j=localStorage.getItem(Lr);(j==="preview"||j==="edit")&&(o=j)}catch{}me(hr.current[s]??o);let u=gs?"preview":"edit";try{const j=localStorage.getItem(Ar);(j==="preview"||j==="edit")&&(u=j)}catch{}he(pr.current[s]??u),Ee(gr.current[s]??(gs?"preview":"edit")),lt(nn.current[s]??"preview"),ct(an.current[s]??"preview"),Ue(on.current[s]??"table");let h=gs?"tree":"text";try{const j=localStorage.getItem(Ir);(j==="tree"||j==="text")&&(h=j)}catch{}be(h)},[c?.path,gs]);const no=i.useCallback(s=>{const o=c?.path;o&&(At.current[o]=s),ae(s)},[c?.path]),io=i.useCallback(s=>{const o=c?.path;o&&(hr.current[o]=s),me(s);try{localStorage.setItem(Lr,s)}catch{}},[c?.path]),$e=i.useCallback(()=>fe,[fe]),ao=i.useCallback(s=>{const o=c?.path;o&&(nn.current[o]=s),lt(s)},[c?.path]),oo=i.useCallback(s=>{const o=c?.path;o&&(an.current[o]=s),ct(s)},[c?.path]),lo=i.useCallback(s=>{const o=c?.path;o&&(on.current[o]=s),Ue(s)},[c?.path]);i.useEffect(()=>{const s=c?.path;if(as(null),!s||ge!==s)return;let o=!1;return ot(s).then(u=>{!o&&u&&as(u.size)}).catch(()=>{}),()=>{o=!0}},[us,ge,ot,c?.path]);const ni=c&&Ge&&$e()==="preview"&&!Fe?c.path:null;i.useEffect(()=>{!ni||g||Bs()},[Bs,ne,g,ni]);const co=i.useCallback(s=>{be(s);try{localStorage.setItem(Ir,s)}catch{}},[]),uo=i.useCallback(s=>{const o=c?.path;o&&(pr.current[o]=s),he(s);try{localStorage.setItem(Ar,s)}catch{}},[c?.path]),fo=i.useCallback(s=>{const o=c?.path;if(o&&(gr.current[o]=s),Ae.current&&(clearTimeout(Ae.current),Ae.current=null),ut.current!==null&&(cancelAnimationFrame(ut.current),ut.current=null),s==="edit")Ce(wt.current||$),Ee(s);else{wt.current=se;const u=o;Ee("edit"),ut.current=requestAnimationFrame(()=>{ut.current=requestAnimationFrame(()=>{ut.current=null,!(l&&u&&et.getState().byRoot[l]?.selectedPath!==u)&&(St(h=>h+1),Ee("preview"))})});return}},[se,$,l,c?.path]),Or=i.useCallback(async(s,o)=>{if(!a.writeFile||o===cs.current)return!1;if(!(await a.writeFile(s,o))?.success)return re.error(t("filesView.toast.writeFileFailed")),!1;Gt(o);const h=await ot(s).catch(()=>null);return h&&(Je.current=h),!0},[Gt,a,ot,t]);i.useEffect(()=>()=>{Ae.current&&(clearTimeout(Ae.current),Ae.current=null),ut.current!==null&&(cancelAnimationFrame(ut.current),ut.current=null)},[ve,c?.path]);const mo=i.useCallback(s=>{if(wt.current=s,!ke||!c?.path||ve!=="preview"||!a.writeFile)return;Ae.current&&clearTimeout(Ae.current);const o=c.path;Ae.current=setTimeout(()=>{Ae.current=null,Or(o,s).then(u=>{u&&(Ls(!0),setTimeout(()=>Ls(!1),1500))}).catch(u=>{re.error(u instanceof Error?u.message:t("filesView.toast.saveFailed"))})},qn)},[ke,ve,a.writeFile,Or,c?.path,t]),ho=i.useMemo(()=>vs&&(wt.current||se)||$,[se,$,vs]),ii=i.useCallback(()=>xe,[xe]);i.useEffect(()=>{const s=u=>{const h=u?"preview":"edit",j=u?"tree":"text";for(const S of Ne)At.current[S]="edit",Qr(S)&&(hr.current[S]=h),cr(S)&&(pr.current[S]=h),ys(S)&&(gr.current[S]=h);ae("edit"),me(h),he(h),Ee(h),be(j);try{localStorage.setItem(Lr,h),localStorage.setItem(Ar,h),localStorage.setItem(Ir,j)}catch{}},o=u=>{const h=!!u.detail?.enabled;s(h)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",o),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",o)}},[Ne]),i.useEffect(()=>{if(!at||!l)return;const s=()=>{typeof window>"u"||Ut.current===null&&(Ut.current=window.requestAnimationFrame(()=>{Ut.current=null,Cr(ft=>ft+1)}))},o=(ft,Pt)=>{if(ft.state.doc.length!==Pt.length)return!1;if(Pt.length===0)return!0;const Ur=Math.min(128,Pt.length);if(ft.state.sliceDoc(0,Ur)!==Pt.slice(0,Ur))return!1;const Ti=Math.max(0,Pt.length-Ur);return ft.state.sliceDoc(Ti,Pt.length)===Pt.slice(Ti)},u=Y(at.path);if(!u){_s(null),Rt.current={key:"",attempts:0};return}const h=`${u}:${at.line}:${at.column??1}`;if(Rt.current.key!==h&&(Rt.current={key:h,attempts:0}),c?.path!==u){if(Fr)return;Me(Ot(u));return}if(Fe||ge!==u)return;if(Xe||Be||jt||Xt){_s(null),Rt.current={key:"",attempts:0};return}if(!Qe)return;if(_!=="edit"){ae("edit");return}const j=Ye.current;if(!j){s();return}if(!o(j,se)){s();return}const S=Math.max(1,Math.min(at.line,j.state.doc.lines)),P=j.state.doc.line(S),O=Math.max(1,at.column||1),oe=Math.max(0,P.to-P.from),A=Math.min(oe,O-1),le=P.from+A;if(!(j.state.selection.main.head===le)||Rt.current.attempts===0){Rt.current.attempts+=1,j.dispatch({selection:{anchor:le},effects:Lt.scrollIntoView(le,{y:"center"})}),j.focus(),s();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const ft=Ye.current;ft&&(ft.dispatch({selection:{anchor:le},effects:Lt.scrollIntoView(le,{y:"center"})}),ft.focus())}),_s(null),Rt.current={key:"",attempts:0}},[Qe,Fr,se,Ra,Xe,Fe,Be,jt,Xt,ge,Me,at,l,c?.path,_s,_,Ot]),i.useEffect(()=>{if(!Vr||!l)return;const s=Y(Vr);if(!s){Pr(null);return}c?.path===s&&(Fe||ge!==s||(!Xe&&!Be&&!jt&&!Xt&&Qe&&_==="edit"&&Ye.current?.focus(),Pr(null)))},[Qe,Xe,Fe,Be,jt,Xt,ge,Vr,l,c?.path,Pr,_]);const ts=i.useCallback(s=>{if(!g||!s||!s.hasFocus||typeof window>"u")return;const o=window.visualViewport;if(!o)return;const u=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,u-(o.offsetTop+o.height))<=0)return;const j=s.state.selection.main.head,S=s.coordsAtPos(j);if(!S)return;const P=Math.round(o.offsetTop+o.height),oe=S.bottom+20-P;oe<=0||(s.scrollDOM.scrollTop+=oe)},[g]);i.useEffect(()=>{if(!g||typeof window>"u")return;const s=()=>{window.requestAnimationFrame(()=>{ts(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)}},[g,ts]),dl("open_go_to_line",s=>{if(!Qe||_!=="edit"||g)return!1;const o=s.target;if(o?.closest('[role="dialog"]')||!(o instanceof Node)||!As.current?.contains(o))return!1;const u=!!o?.closest(".cm-editor");if(!!o?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!u)return!1;Tr(!0)});const er=mt(s=>s.editorFontSize),ai=i.useMemo(()=>{if(!c?.path)return[Bi(f,{fontSize:er})];const s=Kr(c.path),o=[Bi(f,s?{syntaxColors:!1,fontSize:er}:{fontSize:er})],u=Qs??ri;return u&&o.push(u),s&&o.push(Nl({language:s,themeName:f.metadata.id,theme:Tl(f)})),Q&&o.push(Lt.lineWrapping),g&&o.push(Lt.updateListener.of(h=>{h.view.hasFocus&&(h.selectionSet||h.focusChanged||h.viewportChanged||h.geometryChanged)&&window.requestAnimationFrame(()=>{ts(h.view)})})),o},[f,c?.path,Qs,ri,Q,g,ts,er]),oi=i.useMemo(()=>({light:Rs.metadata.id,dark:Ts.metadata.id}),[Rs.metadata.id,Ts.metadata.id]),li=jt||Mr||Dr,ws=c?.path&&li?`${c.path}|${wr.allowOutsideWorkspace?"outside":"workspace"}|${us}`:"",tr=c?.path&&Zt&&xe==="preview"&&!w.isVSCode?`${c.path}|${us}`:"",ci=t("filesView.error.readFileFailed"),{readyKey:ui,nonce:po}=ta(tr,we,ci),{readyKey:di,nonce:sr}=ta(ws,we,ci),go=!!(tr&&ui!==tr),Br=!!(ws&&di!==ws),xo=c?.path&&Be?qe?`data:${fl(c.path)};utf8,${encodeURIComponent($)}`:ya:"",rr=c?.path&&li&&ws&&di===ws?Pi().authenticatedAsset("/api/fs/raw",{path:c.path,allowOutsideWorkspace:wr.allowOutsideWorkspace?"true":void 0,directory:l||void 0}):"",vo=i.useCallback(s=>r.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:r.jsx("iframe",{src:rr,className:"h-full w-full border-0",title:s.name},sr)}),[rr,sr]),fi=c&&a.downloadFile?r.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const s=a.downloadFile;!s||!c||s(c.path).catch(o=>{console.error("Download failed:",o),re.error(t("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(E,{name:"download",className:"mr-2 size-4"}),t("filesView.editor.saveFile")]}):null,nr=c&&!Fe&&!Br&&!Xe?(s=>Be&&!Qn?r.jsx(Rc,{src:xo,name:s.name,sizeBytes:je}):jt?vo(s):Mr?r.jsx(Tc,{kind:ei?"video":"audio",src:rr,name:s.name,sizeBytes:je,download:fi},sr):Dr?r.jsx(Fc,{src:rr,name:s.name,sizeBytes:je},sr):Xt?r.jsx(jc,{name:s.name,path:s.path,sizeBytes:je,download:fi}):es&&Le==="table"?r.jsx(Mc,{path:s.path,content:$,sizeBytes:je}):Qt&&We==="preview"?r.jsx("div",{className:"h-full min-h-0 overflow-hidden",children:r.jsx(ar,{fallback:r.jsxs("div",{className:"m-3 rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:r.jsx(Xr,{content:`\`\`\`mermaid
|
|
16
|
+
${$}
|
|
17
|
+
\`\`\``,className:"markdown-mermaid-fullscreen h-full",enableFileReferences:!1,allowMermaidWheelEvents:!0})})}):null)(c):null;i.useEffect(()=>{let s=!1,o="";return(async()=>{if(!c?.path||!Be||qe){He("");return}we(null);const h=gt(c.path);if(s)return;await(a.readFileBinary?a.readFileBinary(c.path,h).then(S=>S.dataUrl):(async()=>{const S=await en("/api/fs/raw",{signal:AbortSignal.timeout(3e4),query:{path:c.path,allowOutsideWorkspace:h.allowOutsideWorkspace?"true":void 0,directory:l||void 0}});if(!S.ok)throw new Error(t("filesView.error.readFileFailed"));const P=await S.blob();return o=URL.createObjectURL(P),s?(URL.revokeObjectURL(o),o="",""):o})()).then(S=>{s||(He(S),de(c.path))}).catch(S=>{s||(He(""),we(S instanceof Error?S.message:t("filesView.error.readFileFailed")),de(null))}).finally(()=>{s||xt(!1)})})(),()=>{s=!0,o&&URL.revokeObjectURL(o)}},[us,a,Be,qe,gt,l,c?.path,wr,t]);const wo=i.useCallback(()=>kr(null),[]),bo=i.useMemo(()=>Wl({drafts:Mn,editingDraftId:Us,commentText:Ws,onTextChange:Dn,selection:J,isDragging:En,fileLabel:c?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:s=>({start:s.startLine,end:s.endLine}),onSave:Bn,onCancel:()=>{Ze(null),xs()},onEdit:s=>{In(s),Ze({start:s.startLine,end:s.endLine})},onDelete:On}),[xs,Ws,On,Us,Mn,Bn,En,J,c?.path,Dn,In]),mi=Hi(),hi=Hi(),pi=!Fe&&!Xe&&ge===nt,ir=pi&&Zs&&_==="view"&&!(Yt&&ce==="tree"),gi=pi&&Ge&&$e()==="preview",{setScroller:xi,restore:yo}=lr(ir?`${vt}:code`:null),{setScroller:vi,restore:jo}=lr(ir?`${vt}:code:fullscreen`:null),{setScroller:wi}=lr(gi?`${vt}:markdown`:null),{setScroller:bi}=lr(gi?`${vt}:markdown:fullscreen`:null),{setScroller:yi}=mi,{setScroller:ji}=hi,No=i.useCallback(s=>{yi(s),xi(s)},[yi,xi]),So=i.useCallback(s=>{ji(s),vi(s)},[ji,vi]),[Fo,Co]=i.useState(null),[ko,Ro]=i.useState(null),To=i.useCallback(s=>{Pn.current=s,Os.current=s,Co(s),wi(s)},[wi]),Eo=i.useCallback(s=>{$s.current=s,Ro(s),bi(s)},[bi]),Ni=i.useCallback(s=>{l&&mt.getState().openContextFile(l,s)},[l]),Si=Ge&&fe==="preview"&&!Fe;Xi({container:Fo,filePath:c?.path??null,workspaceRoot:l||null,onOpenFile:Ni,enabled:Si}),Xi({container:ko,filePath:c?.path??null,workspaceRoot:l||null,onOpenFile:Ni,enabled:Si});const $r=xl("unified"),dt=se.length>da,_r=i.useMemo(()=>dt&&ir?xc(se):void 0,[ir,se,dt]),Fi=i.useCallback((s,o,u,h)=>{const j={name:s.name,contents:o,lang:Kr(s.path)||void 0},S=P=>r.jsx(Rl,{file:dt&&_r?{...j,cacheKey:`${s.path}:${_r}`}:j,options:{disableFileHeader:!0,overflow:Q?"wrap":"scroll",theme:oi,themeType:f.metadata.variant==="dark"?"dark":"light",onPostRender:h},className:dt?"block w-full":"block h-full w-full",style:dt?void 0:{height:"100%"}},P);return dt?r.jsx("div",{className:"h-full",children:r.jsx(El.Provider,{value:u.virtualizer,children:r.jsx(Vl.Provider,{value:$r,children:S(`${s.path}:${$r?"pool":"pending"}`)})})}):r.jsx("div",{className:"h-full",children:S(s.path)})},[f.metadata.variant,dt,_r,oi,$r,Q]),Ci=({exitFullscreenOnly:s=!1,layout:o="floating"}={})=>{if(!c)return null;const u=o==="docked",h=ml(hl("save_file")),j=u?"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=(P,O)=>r.jsxs(Mt,{children:[r.jsx(Dt,{asChild:!0,children:r.jsx("span",{className:"inline-flex",children:O})}),r.jsx(zt,{side:"bottom",sideOffset:6,children:P})]});return r.jsxs("div",{className:j,children:[Qe&&ro&&r.jsxs(r.Fragment,{children:[ls?r.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[r.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}),t("filesView.editor.saving")]}):ke&&Fa==="saved"&&!Oe?r.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[r.jsx(E,{name:"check",className:"size-3.5"}),t("filesView.editor.saved")]}):Oe?S(t(ke?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:h}),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{qt()},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(ke?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:h}),"aria-label":t("filesView.editor.saveAria",{shortcut:h}),children:r.jsx(E,{name:"save-3",className:"size-4"})})):null,S(t(ke?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>ka(!ke),className:W("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",ke?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:t(ke?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":t(ke?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:ke?r.jsx(E,{name:"file-check-fill",className:"size-4"}):r.jsx(E,{name:"file-check",className:"size-4"})}))]}),r.jsxs(tn,{onOpenChange:ie,children:[r.jsxs(Mt,{children:[r.jsx(Dt,{asChild:!0,children:r.jsx("span",{className:"inline-flex",children:r.jsx(sn,{asChild:!0,children:r.jsx(I,{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:r.jsx(E,{name:"file-transfer",className:"size-4"})})})})}),r.jsx(zt,{side:"bottom",sideOffset:6,children:t("filesView.editor.openInDesktopApp")})]}),r.jsxs(rn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Ia.map(P=>r.jsxs(ur,{className:"flex items-center gap-2",onClick:()=>{_a(P)},children:[r.jsx(Bc,{label:P.label,iconDataUrl:P.iconDataUrl}),r.jsx("span",{className:"typography-ui-label text-foreground",children:P.label})]},P.id)),Oa?r.jsxs(ur,{className:"flex items-center gap-2",onClick:()=>{Ba(!0)},children:[r.jsx(E,{name:"refresh",className:"size-4"}),r.jsx("span",{className:"typography-ui-label text-foreground",children:t("filesView.editor.refreshApps")})]}):null]})]}),!ti&&r.jsxs(r.Fragment,{children:[S(t(Q?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>_e(!Q),className:W("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Q?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:t(Q?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:r.jsx(E,{name:"text-wrap",className:"size-4"})})),_==="edit"&&r.jsxs(r.Fragment,{children:[S(t("filesView.editor.findInFile"),r.jsx(I,{variant:"ghost",size:"sm",onClick:P=>{ze(!De),P.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:r.jsx(E,{name:"search",className:"size-4"})})),S(t("filesView.editor.goToLine"),r.jsx(I,{variant:"ghost",size:"sm",onClick:P=>{Tr(O=>!O),P.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.goToLine"),children:r.jsx(E,{name:"menu-fold-2",className:"size-4"})})),r.jsx(Ql,{open:Aa,onOpenChange:Tr,view:Ye.current,variant:"inline"})]})]}),Zs&&Qe&&!Yt&&!Zt&&!qe&&!Qt&&!es&&r.jsx(js,{currentMode:_==="view"?"preview":"edit",onToggle:()=>{no(_==="view"?"edit":"view")}}),Ge&&S(t($e()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>io($e()==="preview"?"edit":"preview"),className:W("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",$e()==="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($e()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":t($e()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:r.jsx(E,{name:$e()==="preview"?"eye":"eye-off",className:"size-4"})})),cr(c?.path??"")&&r.jsx(js,{currentMode:ii(),onToggle:()=>{uo(ii()==="preview"?"edit":"preview")}}),qe&&r.jsx(js,{currentMode:ye,onToggle:()=>ao(ye==="preview"?"edit":"preview")}),Qt&&r.jsx(js,{currentMode:We,onToggle:()=>oo(We==="preview"?"edit":"preview")}),es&&S(t(Le==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>lo(Le==="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(Le==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),"aria-label":t(Le==="table"?"filesView.artifact.table.showSource":"filesView.artifact.table.showTable"),children:Le==="table"?r.jsx(E,{name:"code-sslash",className:"size-4"}):r.jsx(E,{name:"table-2",className:"size-4"})})),Ge&&$e()==="preview"&&S(t("filesView.editor.findInFile"),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{Is(!0),Nn(P=>P+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:r.jsx(E,{name:"search",className:"size-4"})})),Ge&&$e()==="preview"&&Wa&&r.jsxs(Mt,{children:[r.jsx(Dt,{asChild:!0,children:r.jsx(I,{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(zs?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{zs?ba():$.trim()&&wa($)},children:zs?r.jsx(E,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(E,{name:"volume-up",className:"size-4"})})}),r.jsx(zt,{sideOffset:8,children:t(zs?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),vs&&r.jsxs(r.Fragment,{children:[r.jsx(js,{currentMode:ve,onToggle:()=>fo(ve==="preview"?"edit":"preview")}),ve==="preview"&&r.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{const P=gn.current?.getXml();if(Ae.current&&(clearTimeout(Ae.current),Ae.current=null),c?.path&&P){if(!await Or(c.path,P))return;Ls(!0),setTimeout(()=>Ls(!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:Ca?r.jsx(E,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(E,{name:"save-3",className:"size-4"})})]}),Yt&&S(t(ce==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>co(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"?r.jsx(E,{name:"code-sslash",className:"size-4"}):r.jsx(E,{name:"node-tree",className:"size-4"})})),to&&S(t("filesView.editor.copyFileContents"),r.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await fr($)).ok?(wn(!0),hs.current!==null&&window.clearTimeout(hs.current),hs.current=window.setTimeout(()=>{wn(!1)},1200)):re.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:za?r.jsx(E,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(E,{name:"clipboard",className:"size-4"})})),so&&S(t("filesView.editor.copyFilePathTitle",{path:Nt}),r.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await fr(Nt)).ok?(bn(!0),ps.current!==null&&window.clearTimeout(ps.current),ps.current=window.setTimeout(()=>{bn(!1)},1200)):re.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:Nt}),"aria-label":t("filesView.editor.copyFilePathTitle",{path:Nt}),children:La?r.jsx(E,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(E,{name:"file-copy-2",className:"size-4"})})),a.downloadFile&&S(t("filesView.editor.saveFile"),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{const P=a.downloadFile;P&&P(c.path).catch(O=>{console.error("Download failed:",O),re.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:r.jsx(E,{name:"download",className:"size-4"})})),s?S(t("filesView.editor.exitFullscreen"),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Te(!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:r.jsx(E,{name:"fullscreen-exit",className:"size-4"})})):!g&&n==="full"&&S(t(ne?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Te(!ne),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:t(ne?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":t(ne?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:ne?r.jsx(E,{name:"fullscreen-exit",className:"size-4"}):r.jsx(E,{name:"fullscreen",className:"size-4"})}))]})},Wr=r.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[r.jsx(ra,{open:Fr,onOpenChange:s=>{s||ds(!0)},children:r.jsxs(na,{showCloseButton:!1,className:"max-w-md",children:[r.jsxs(ia,{children:[r.jsx(aa,{children:t("filesView.unsaved.title")}),r.jsx(oa,{children:t("filesView.unsaved.description")})]}),r.jsxs(la,{children:[r.jsx(I,{variant:"outline",onClick:()=>{Ja()},disabled:ls,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")}),r.jsx(I,{variant:"destructive",onClick:Xa,children:t("filesView.unsaved.discard")})]})]})}),r.jsxs("div",{className:W("flex flex-col flex-shrink-0",z&&"border-b border-border/40"),children:[z?r.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[g&&X&&r.jsx("button",{type:"button",onClick:()=>H(!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:r.jsx(E,{name:"arrow-left-s",className:"size-5"})}),g?c?r.jsxs(tn,{children:[r.jsx(sn,{asChild:!0,children:r.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:[r.jsx(Ns,{filePath:c.path,extension:c.extension,className:"size-3.5 flex-shrink-0"}),r.jsx(Yi,{name:c.name}),r.jsx(E,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),r.jsx(rn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Bt.map(s=>{const o=c?.path===s.path;return r.jsxs(ur,{onSelect:u=>{if(u.target.closest("[data-close-open-file]")){u.preventDefault();return}o||Me(s)},className:W("flex min-w-0 items-center justify-between gap-2 overflow-hidden",o&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx(Ns,{filePath:s.path,extension:s.extension,className:"size-3.5 flex-shrink-0"}),r.jsx(Yi,{name:s.name})]}),r.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:u=>{u.preventDefault(),u.stopPropagation()},onClick:u=>{u.preventDefault(),u.stopPropagation(),Jn(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:r.jsx(E,{name:"close",className:"size-3.5"})})]},s.path)})})]}):r.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")}):Bt.length>0?r.jsxs("div",{className:"relative min-w-0 flex-1",children:[un.left&&r.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"}),un.right&&r.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"}),r.jsx("div",{ref:br,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Bt.map(s=>{const o=c?.path===s.path;return r.jsxs("div",{title:dr(l,s.path),className:W("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:[r.jsx(Ns,{filePath:s.path,extension:s.extension,className:"size-3.5 flex-shrink-0"}),r.jsx("button",{type:"button",onClick:()=>{o||Me(s)},className:"max-w-[12rem] truncate text-left",children:s.name}),r.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),Jn(s.path)},className:W("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!o&&!C&&"opacity-0 group-hover:opacity-100"),"aria-label":t("filesView.editor.closeFileAria",{name:s.name}),children:r.jsx(E,{name:"close",className:"size-3.5"})})]},s.path)})})]}):r.jsx("div",{className:"typography-ui-label font-medium truncate",children:t("filesView.editor.selectFile")})]}):null,c?r.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:[Nt&&!g?r.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:Nt,children:Nt}):null,r.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Ci({layout:"docked"})})]}):null]}),r.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:r.jsx(Gr,{ref:No,outerClassName:"h-full min-w-0",className:W("h-full min-w-0",dt&&"[overflow-anchor:none]"),children:c?Fe||Br?B?r.jsx("div",{className:"p-3"}):r.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.loading")]}):Xe?r.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Xe}):nr||(c&&vs&&ve==="preview"?r.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:r.jsx(wc,{ref:gn,xml:ho,onChange:mo},`${c.path}:${ue}`)}):c&&Yt&&ce==="tree"?r.jsx(ar,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.jsonViewerUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToTextMode")})]}),children:r.jsx("div",{className:"h-full overflow-auto",children:r.jsx(kl,{jsonString:$,maxHeight:"100%",initiallyExpandedDepth:2})})}):c&&Ge&&$e()==="preview"?r.jsxs("div",{className:"relative h-full min-h-0",children:[r.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:Bs,ref:To,children:[r.jsx(_i,{containerRef:Pn,filePath:c.path,fileContent:$}),$.length>500*1024&&r.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($.length/1024)})}),r.jsx(ar,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:r.jsx(Xr,{content:$,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),!ne&&r.jsx(Ki,{containerRef:Os,open:yn,onOpenChange:Is,focusNonce:jn})]}):c&&Zt&&xe==="preview"?go?r.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:t("common.loading")}):r.jsx("div",{className:"h-full overflow-hidden",children:r.jsx("iframe",{src:!w.isVSCode&&ui===tr?(()=>{const s=c.path.split("/").map(o=>encodeURIComponent(o)).join("/");return Pi().authenticatedAsset(`/api/fs/serve${s.startsWith("/")?s:`/${s}`}`)})():void 0,srcDoc:w.isVSCode?(()=>{const s=c.path.substring(0,c.path.lastIndexOf("/")+1);return s?$.replace(/<head([^>]*)>/i,`<head$1><base href="${s}">`):$})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:t("filesView.editor.htmlPreviewTitle")},po)}):c&&Zs&&_==="view"?Fi(c,se,mi,yo):r.jsxs("div",{className:W("relative h-full",Jt&&"overflow-hidden"),ref:As,children:[r.jsx("div",{className:W("h-full",Jt&&"invisible"),children:r.jsx(ea,{positionKey:vt,value:se,onChange:Ce,readOnly:!Qe,vimMode:Vn==="vim",extensions:ai,className:"h-full",blockWidgets:bo,onViewReady:s=>{Ye.current=s,Cr(o=>o+1),window.requestAnimationFrame(()=>{ts(s)})},onViewDestroy:()=>{Ye.current&&(Ye.current=null),Cr(s=>s+1)},enableSearch:!0,searchOpen:De,onSearchOpenChange:ze,highlightLines:J?{start:Math.min(J.start,J.end),end:Math.max(J.start,J.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(s,o,u)=>{if(!(u instanceof MouseEvent)||u.button!==0)return!1;u.preventDefault();const h=s.state.doc.lineAt(o.from).number;if(J&&!u.shiftKey&&Math.min(J.start,J.end)===h&&Math.max(J.start,J.end)===h)return Ze(null),xs(),Kt.current=!1,yt.current=null,Ht(!1),!0;if(g&&J&&!u.shiftKey){const j=Math.min(J.start,J.end,h),S=Math.max(J.start,J.end,h);return Ze({start:j,end:S}),Kt.current=!1,yt.current=null,Ht(!1),!0}if(Kt.current=!0,yt.current=h,Ht(!0),J&&u.shiftKey){const j=Math.min(J.start,h),S=Math.max(J.end,h);Ze({start:j,end:S})}else Ze({start:h,end:h});return!0},mouseover:(s,o,u)=>{if(!(u instanceof MouseEvent)||u.buttons!==1||!Kt.current||yt.current===null)return!1;const h=s.state.doc.lineAt(o.from).number,j=Math.min(yt.current,h),S=Math.max(yt.current,h);return Ze({start:j,end:S}),Ht(!0),!1},mouseup:()=>(Kt.current=!1,yt.current=null,Ht(!1),!1)}}},vt)}),Jt&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]})):r.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:t("filesView.editor.pickFileFromTree")})})})]}),Vo=!!(l&&mn[l]),ki=l?Ps[l]:null,Ri=T?r.jsxs("section",{className:W("flex min-h-0 flex-col overflow-hidden",g?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[r.jsx("div",{className:W("flex flex-col gap-2 py-2",g?"px-3":"px-2"),children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative flex-1 min-w-0",children:[r.jsx(E,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),r.jsx(Fs,{ref:G,value:te,onChange:s=>ee(s.target.value),placeholder:t("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),te.trim().length>0&&r.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:()=>{ee(""),G.current?.focus()},children:r.jsx(E,{name:"close",className:"size-4"})})]}),r.jsxs(Mt,{children:[r.jsx(Dt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Er("createFile",{path:p,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.newFileTitle"),"aria-label":t("filesView.tree.actions.newFileTitle"),children:r.jsx(E,{name:"file-add",className:"size-4"})})})}),r.jsx(zt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.newFileTitle")})]}),r.jsxs(Mt,{children:[r.jsx(Dt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Er("createFolder",{path:p,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.newFolderTitle"),"aria-label":t("filesView.tree.actions.newFolderTitle"),children:r.jsx(E,{name:"folder-add",className:"size-4"})})})}),r.jsx(zt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.newFolderTitle")})]}),_n&&r.jsxs(Mt,{children:[r.jsx(Dt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Wn(l),disabled:!l||Hs,className:"size-8 p-0 flex-shrink-0",title:t("sidebarFilesTree.actions.uploadFilesTitle"),"aria-label":t("sidebarFilesTree.actions.uploadFilesTitle"),children:r.jsx(E,{name:Hs?"loader-4":"upload-2",className:W("size-4",Hs&&"animate-spin")})})})}),r.jsx(zt,{side:"bottom",sideOffset:6,children:t("sidebarFilesTree.actions.uploadFilesTitle")})]}),r.jsxs(Mt,{children:[r.jsx(Dt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{Ks()},className:"size-8 p-0 flex-shrink-0",title:t("filesView.tree.actions.refreshTitle"),"aria-label":t("filesView.tree.actions.refreshTitle"),children:r.jsx(E,{name:"refresh",className:"size-4"})})})}),r.jsx(zt,{side:"bottom",sideOffset:6,children:t("filesView.tree.actions.refreshTitle")})]})]})}),r.jsx(Gr,{outerClassName:"flex-1 min-h-0",className:W("py-2",g?"px-3":"px-2"),children:r.jsx("ul",{className:"flex flex-col",children:va?r.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.tree.search.searching")]}):hn.length>0?hn.map(s=>{const o=c?.path===s.path;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>{Me(s)},className:W("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:[pa(s.path,s.extension),r.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)}):ki?r.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx("span",{className:"text-[var(--status-error)]",children:ki}),r.jsxs(I,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Ks()},children:[r.jsx(E,{name:"refresh",className:"size-3.5"}),t("filesView.tree.actions.refreshTitle")]})]}):Vo?Zn(l,0):r.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:t("filesView.state.loading")})})})]}):null,Po=n==="full"&&ne&&c&&r.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:r.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[r.jsx("div",{className:"absolute right-4 top-4 z-30",children:Ci({exitFullscreenOnly:!0})}),r.jsx(Gr,{ref:So,outerClassName:"h-full min-w-0",className:W("h-full min-w-0",dt&&"[overflow-anchor:none]"),children:Fe||Br?B?r.jsx("div",{className:"p-4"}):r.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Xe?r.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Xe}):nr||(Ge&&$e()==="preview"?r.jsxs("div",{className:"relative h-full min-h-0",children:[r.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:Bs,ref:Eo,children:[c?r.jsx(_i,{containerRef:$s,filePath:c.path,fileContent:$}):null,$.length>500*1024&&r.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($.length/1024)})}),r.jsx(ar,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:t("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:t("filesView.error.switchToEditMode")})]}),children:r.jsx(Xr,{content:$,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),r.jsx(Ki,{containerRef:$s,open:yn,onOpenChange:Is,focusNonce:jn,className:"right-4 top-16"})]}):Zs&&_==="view"?Fi(c,se,hi,jo):r.jsxs("div",{className:W("relative h-full",Jt&&"overflow-hidden"),children:[r.jsx("div",{className:W("h-full",Jt&&"invisible"),children:r.jsx(ea,{positionKey:`${vt}:fullscreen`,value:se,onChange:Ce,readOnly:!Qe,vimMode:Vn==="vim",extensions:ai,className:"h-full",onViewReady:s=>{Ye.current=s,window.requestAnimationFrame(()=>{ts(s)})},onViewDestroy:()=>{Ye.current&&(Ye.current=null)}},`${vt}:fullscreen`)}),Jt&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),t("filesView.state.openingFileAtChange")]})})]}))})]})});return r.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[r.jsx(Jc,{activeDialog:Tt,dialogData:Et,dialogInputValue:bt,onDialogInputChange:vn,isDialogSubmitting:Ea,onDialogSubmit:Ga,onClose:wo,inputRef:Na}),qa,Po,g?X?Wr:Ri:n==="editor-only"?r.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:r.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Wr})}):r.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[b>=700&&r.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Ri}),r.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Wr})]})]})};function Zc(n){return n+1}export{yf as FilesView};
|