@vantran-se/openchamber-web 1.24.4 → 2.0.1
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-ntXIbhV2.js} +1 -1
- package/dist/assets/DiffView-CjxUovbM.js +4 -0
- package/dist/assets/FilesView-DFWD0RQR.js +17 -0
- package/dist/assets/{GitView-Byu2DY7s.js → GitView-BWa7e5vw.js} +4 -4
- package/dist/assets/{GuestAttachDialog-B808E0-d.js → GuestAttachDialog-DdOuyZzp.js} +1 -1
- package/dist/assets/GuestSurfacePane-DDfzid3U.js +1 -0
- package/dist/assets/{JsonTreeView-VW_7czo3.js → JsonTreeView-3sGwqexh.js} +1 -1
- package/dist/assets/LinearIssuesView-C6dpIdjw.js +1 -0
- package/dist/assets/MarkdownImageGallery-Q7YR_tl4.js +1 -0
- package/dist/assets/MarkdownRendererImpl-DxDV56bL.js +12 -0
- package/dist/assets/OnboardingScreen-rK4Stg__.js +1 -0
- package/dist/assets/{PatchDiff-DCjGhlYV.js → PatchDiff-DS-IMU1j.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CEDZNkU2.js → PierreDiffViewer-DW23KWKZ.js} +1 -1
- package/dist/assets/PlanView-BCk_VobP.js +5 -0
- package/dist/assets/PluginPane-BPP1dbck.js +3 -0
- package/dist/assets/SettingsView-kMmrpn43.js +29 -0
- package/dist/assets/SettingsWindow-BpvD6IYQ.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-BLttSS1X.js +1 -0
- package/dist/assets/ToolOutputDialog-CtqDqbyr.js +15 -0
- package/dist/assets/ToolPartDiffPreview-5FcKdyRy.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-NU0FHFhT.js → VirtualizedFileDiff-C763hNCR.js} +4 -4
- package/dist/assets/{WalkthroughView-BZyjhqHv.js → WalkthroughView-lap5btCF.js} +2 -2
- package/dist/assets/appThemeRegistry-u4zw1l0B.js +1 -0
- package/dist/assets/{commitAndPush-BDftrjr6.js → commitAndPush-CwGJfJG-.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DlWlEM3x.js → computeVirtualFileMetrics-DW5jjX4n.js} +1 -1
- package/dist/assets/de-CndEg67T.js +10 -0
- package/dist/assets/es-DglvPlaC.js +16 -0
- package/dist/assets/fr-DejPCpbS.js +14 -0
- package/dist/assets/index-C2r64QfD.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-D47a6hMP.js} +1 -1
- package/dist/assets/{isFilePlainText-ue6kCou7.js → isFilePlainText-B-mGgeKl.js} +1 -1
- package/dist/assets/ja-CVpQawCd.js +16 -0
- package/dist/assets/ko-Bw446h9j.js +16 -0
- package/dist/assets/main-Bz4WWXbr.js +2 -0
- package/dist/assets/main-oreqDsOV.js +896 -0
- package/dist/assets/{markdownCore-CK48LG0z.js → markdownCore-D2e5sp9y.js} +4 -4
- package/dist/assets/miniChat-D1v2gsBI.js +2 -0
- package/dist/assets/mobile-DBj3lCf2.js +2 -0
- package/dist/assets/{patchFileDiff-D7QVlovD.js → patchFileDiff-BpeUOV91.js} +3 -3
- package/dist/assets/pl-BYNlPdhm.js +16 -0
- package/dist/assets/pt-BR-CL-Yfv9H.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-DVtfEB2z.js +2 -0
- package/dist/assets/renderMobileApp-DFp9-xbG.js +25 -0
- package/dist/assets/runtimeEndpointReset-CsIpUep1.js +27 -0
- package/dist/assets/scheduledTasksApi-B5OHVpPM.js +1 -0
- package/dist/assets/{shikiHighlight-BPu3JiQs.js → shikiHighlight-DNm2Z_Jc.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-DWqRPo9A.js → textMateThemeFromAppTheme-DGF2kG7g.js} +1 -1
- package/dist/assets/tr-DzmbxLy-.js +7 -0
- package/dist/assets/uk-C7vQnwro.js +16 -0
- package/dist/assets/useAppFontEffects-Ci3FEaPf.js +7337 -0
- package/dist/assets/{useInlineCommentController-CgS0fnw_.js → useInlineCommentController-CuUuakrt.js} +2 -2
- package/dist/assets/useRootScrollLock-CQIsyERq.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-Bx2EHc1O.js → vendor-codemirror-language-data-CQa7_1cr.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-B6tKQyJN.js} +2 -2
- package/dist/assets/zh-CN-Cl0srS-z.js +16 -0
- package/dist/assets/zh-TW-DtII5bDb.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
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{R as r,f as et,j as t}from"./vendor-react-BUCujlKS.js";import{u as me,O as De,a as Ae,G as Dn}from"./index-Dqc6USl3.js";import{c as An,b as Vn,u as En,a as Ln,B as Mn,C as Tn,P as _t,h as Bn,e as In,g as Pn,i as _n,f as On}from"./patchFileDiff-D7QVlovD.js";import{c as zn,b as Kn,i as Gn,u as Hn,a as $n,d as qn,S as Wn}from"./SubmoduleDiffSummary-oxeACCWs.js";import{f as $e,B as ke,I as O,h as Ve,Z as Xt,af as Un,K as ae,ag as Jn,bg as Xn,J as Yn,ah as Qn,aj as Zn,z as Ot,k as es,d6 as Yt,t as He,ko as ts,aw as Ze,ke as Qt,kp as ns,ax as Zt,gG as ss,au as Qe,av as rs,c6 as en,aq as is,as as os,at as as,ap as ls}from"./useAppFontEffects-ne84JBVL.js";import{f as cs,d as us}from"./runtimeEndpointReset-DdrazOVH.js";import{P as ds}from"./PierreDiffViewer-CEDZNkU2.js";import{u as fs,v as ms,g as ps,W as hs}from"./main-BEdcOI2P.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CgAdXWZO.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-NU0FHFhT.js";import"./web-components-DxX8bZ1o.js";import"./computeVirtualFileMetrics-DlWlEM3x.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"./isDiffPlainText-CO4e5J_S.js";import"./vendor-diff-C3JhlQdm.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-Bx2EHc1O.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-B808E0-d.js";import"./PluginPane-DEcgDQ9h.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-CgS0fnw_.js";import"./appThemeRegistry-DLicw4dH.js";import"./textMateThemeFromAppTheme-DWqRPo9A.js";import"./vendor-katex-CHD9BdDO.js";import"./useRootScrollLock-Cpf1qoGp.js";import"./scheduledTasksApi-B2SWMGEU.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const gs=r.memo(function(e){const s=et.c(13),{index:l,staged:y,busyHunk:p,disabled:j,onAction:S}=e,{t:D}=$e();let c;s[0]!==y?(c=y?["unstage"]:["discard","stage"],s[0]=y,s[1]=c):c=s[1];const v=c;let C;s[2]===Symbol.for("react.memo_cache_sentinel")?(C={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=C):C=s[2];let m;s[3]!==v||s[4]!==p||s[5]!==j||s[6]!==l||s[7]!==S||s[8]!==D?(m=t.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:v.map(w=>{const A=D(w==="stage"?"diffView.hunk.stageTitle":w==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:l+1}),P=p?.index===l&&p.action===w;return t.jsx(ke,{variant:"ghost",size:"xs",className:Ve("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:j||p!==null,title:A,"aria-label":A,onPointerDown:xs,onClick:f=>{f.stopPropagation(),S(l,w)},children:t.jsx(O,{name:P?"loader-4":w==="stage"?"add":"arrow-go-back",className:Ve(w==="stage"?"size-4":"size-3.5",P&&"animate-spin")})},w)})}),s[3]=v,s[4]=p,s[5]=j,s[6]=l,s[7]=S,s[8]=D,s[9]=m):m=s[9];let E;return s[10]!==l||s[11]!==m?(E=t.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:C,"data-hunk-actions":l,children:m}),s[10]=l,s[11]=m,s[12]=E):E=s[12],E});function xs(o){return o.stopPropagation()}const zt=(o,e)=>{if(e.length===0)return null;let s=null,l=null;for(const p of e)p.top<=o?(!s||p.top>s.top)&&(s=p):(!l||p.top<l.top)&&(l=p);const y=s??l;return y?{path:y.path,topOffset:y.top-o}:null},ys=(o,e,s,l)=>Math.min(Math.max(0,l),Math.max(0,o+s-e)),Kt=o=>{if(!o)return null;const e=o.split(`
|
|
2
|
-
`);let s=null;for(const l of e){const y=l.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(l.startsWith(" ")){s+=1;continue}if(l.startsWith("+"))return s;if(l.startsWith("-"))return Math.max(1,s)}}return null},ws=1100,bs=15e3,Gt=500,Ht=300,tn=1e6,kt=3,js=o=>o<=6?o:o<=12?6:o<=25?4:2,$t={status:"loading"},vs=3,Ss=r.memo(()=>{const o=et.c(4),{t:e}=$e();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let l;return o[2]!==s?(l=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=l):l=o[3],l}),nn={"?":{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"}},ks=nn.M,Ns=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"},sn=o=>{const e=Ns(o);return nn[e]??ks},Cs=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},qt=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Wt=o=>!!o.working_dir?.trim()||o.index==="?",Rs=(o,e)=>ss(o,e),Ut=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Jt=(o,e)=>{const s=o.split(`
|
|
3
|
-
`),l=e.split(`
|
|
4
|
-
`),y=Math.min(s.length,l.length);for(let p=0;p<y;p+=1)if(s[p]!==l[p])return p+1;return l.length>s.length?s.length+1:s.length>l.length?Math.max(1,l.length):1},Fs=o=>Array.isArray(o)?o.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],Ds=o=>o==="added"?"A":o==="deleted"?"D":"M",Nt=(o,e,s)=>_n(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:On(o,e),contextMode:s},rn=(o,e,s)=>{const l=o??0,y=e??0;return!l&&!y?null:t.jsxs("span",{className:Ve("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[l?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",l]}):null,y?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",y]}):null]})},As=r.memo(o=>{const e=et.c(68),{scope:s,workingCount:l,stagedCount:y,turnCount:p,branchCount:j,commitCount:S,prCount:D,showCommitOption:c,showBranchOption:v,onScopeChange:C}=o,{t:m}=$e(),[E,w]=r.useState(!1),A=s==="pr"?D??0:s==="staged"?y:s==="turn"?p:s==="branch"?j??0:s==="commit"?S??0:l;let P;e[0]!==s||e[1]!==m?(P=m(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]=m,e[2]=P):P=e[2];const f=P;let be;e[3]!==m?(be=m("diffView.scope.selectorAria"),e[3]=m,e[4]=be):be=e[4];let Z;e[5]!==A?(Z=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",A]}),e[5]=A,e[6]=Z):Z=e[6];let ee;e[7]!==f||e[8]!==Z?(ee=t.jsxs("span",{className:"whitespace-nowrap",children:[f,Z]}),e[7]=f,e[8]=Z,e[9]=ee):ee=e[9];let Ne;e[10]===Symbol.for("react.memo_cache_sentinel")?(Ne=t.jsx(O,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=Ne):Ne=e[10];let $;e[11]!==be||e[12]!==ee?($=t.jsx(is,{asChild:!0,children:t.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]=$):$=e[13];let x;e[14]!==C?(x=G=>{(G==="working"||G==="staged"||G==="turn"||G==="branch"||G==="commit"||G==="pr")&&(C?.(G),w(!1))},e[14]=C,e[15]=x):x=e[15];let I;e[16]!==m?(I=m("diffView.scope.changed"),e[16]=m,e[17]=I):I=e[17];let q;e[18]!==I?(q=t.jsx("span",{children:I}),e[18]=I,e[19]=q):q=e[19];let le;e[20]!==l?(le=t.jsx("span",{className:"typography-meta text-muted-foreground",children:l}),e[20]=l,e[21]=le):le=e[21];let te;e[22]!==le||e[23]!==q?(te=t.jsx(Qe,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[q,le]})}),e[22]=le,e[23]=q,e[24]=te):te=e[24];let pe;e[25]!==m?(pe=m("diffView.scope.staged"),e[25]=m,e[26]=pe):pe=e[26];let ne;e[27]!==pe?(ne=t.jsx("span",{children:pe}),e[27]=pe,e[28]=ne):ne=e[28];let he;e[29]!==y?(he=t.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=t.jsx(Qe,{value:"staged",children:t.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 B;e[34]!==m?(B=m("diffView.scope.lastTurn"),e[34]=m,e[35]=B):B=e[35];let se;e[36]!==B?(se=t.jsx("span",{children:B}),e[36]=B,e[37]=se):se=e[37];let X;e[38]!==p?(X=t.jsx("span",{className:"typography-meta text-muted-foreground",children:p}),e[38]=p,e[39]=X):X=e[39];let z;e[40]!==se||e[41]!==X?(z=t.jsx(Qe,{value:"turn",children:t.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]=z):z=e[42];let je;e[43]!==j||e[44]!==v||e[45]!==m?(je=v?t.jsx(Qe,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:m("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}):null,e[43]=j,e[44]=v,e[45]=m,e[46]=je):je=e[46];let V;e[47]!==S||e[48]!==c||e[49]!==m?(V=c&&t.jsx(Qe,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:m("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:S??"…"})]})}),e[47]=S,e[48]=c,e[49]=m,e[50]=V):V=e[50];let K;e[51]!==D||e[52]!==c||e[53]!==m?(K=c&&t.jsx(Qe,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:m("session.githubIntegration.tabs.pullRequests")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:D??"…"})]})}),e[51]=D,e[52]=c,e[53]=m,e[54]=K):K=e[54];let R;e[55]!==s||e[56]!==te||e[57]!==J||e[58]!==z||e[59]!==je||e[60]!==V||e[61]!==K||e[62]!==x?(R=t.jsx(os,{align:"start",className:"w-40",children:t.jsxs(as,{value:s,onValueChange:x,children:[te,J,z,je,V,K]})}),e[55]=s,e[56]=te,e[57]=J,e[58]=z,e[59]=je,e[60]=V,e[61]=K,e[62]=x,e[63]=R):R=e[63];let ce;return e[64]!==E||e[65]!==R||e[66]!==$?(ce=t.jsxs(ls,{open:E,onOpenChange:w,children:[$,R]}),e[64]=E,e[65]=R,e[66]=$,e[67]=ce):ce=e[67],ce}),Vs=r.memo(o=>{const e=et.c(11),{changedFiles:s,selectedFile:l,onSelectFile:y}=o,{t:p}=$e();if(s.length===0)return null;let j;if(e[0]!==s||e[1]!==y||e[2]!==l||e[3]!==p){let D;e[5]!==y||e[6]!==l||e[7]!==p?(D=c=>{const v=sn(c),C=l===c.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>y(c.path),className:Ve("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",C?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(Zt,{filePath:c.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:v.color},title:p(v.descriptionKey),"aria-label":p(v.descriptionKey),children:v.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:c.path,children:c.path}),rn(c.insertions,c.deletions)]})},c.path)},e[5]=y,e[6]=l,e[7]=p,e[8]=D):D=e[8],j=s.map(D),e[0]=s,e[1]=y,e[2]=l,e[3]=p,e[4]=j}else j=e[4];let S;return e[9]!==j?(S=t.jsx(en,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:j})}),e[9]=j,e[10]=S):S=e[10],S}),Es=r.memo(o=>{const e=et.c(20),{filePath:s,diff:l,renderSideBySide:y}=o,{t:p}=$e(),j=l.original.length>0,S=l.modified.length>0,D=y?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",c=y?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={contain:"layout"},e[0]=v):v=e[0];let C;e[1]!==l.original||e[2]!==s||e[3]!==j||e[4]!==c||e[5]!==y||e[6]!==p?(C=j&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p("diffView.image.original")}),t.jsx("img",{src:l.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]=l.original,e[2]=s,e[3]=j,e[4]=c,e[5]=y,e[6]=p,e[7]=C):C=e[7];let m;e[8]!==l.modified||e[9]!==s||e[10]!==S||e[11]!==j||e[12]!==c||e[13]!==y||e[14]!==p?(m=S&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p(j?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:l.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]=l.modified,e[9]=s,e[10]=S,e[11]=j,e[12]=c,e[13]=y,e[14]=p,e[15]=m):m=e[15];let E;return e[16]!==D||e[17]!==C||e[18]!==m?(E=t.jsx("div",{className:"w-full overflow-auto p-4",style:v,children:t.jsxs("div",{className:D,children:[C,m]})}),e[16]=D,e[17]=C,e[18]=m,e[19]=E):E=e[19],E}),Ls=r.memo(o=>{const e=et.c(23),{filePath:s,diff:l,staged:y,renderSideBySide:p,wrapLines:j,hunkActions:S,onExpandContextRequest:D,pendingContextExpansion:c,contextLoading:v}=o;let C;e[0]!==s?(C=rs(s)||"text",e[0]=s,e[1]=C):C=e[1];const m=C;if(l.submodule){let A;return e[2]!==l.submodule||e[3]!==y?(A=t.jsx(Wn,{state:l.submodule,staged:y}),e[2]=l.submodule,e[3]=y,e[4]=A):A=e[4],A}if(l.isBinary){let A;return e[5]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(Ss,{}),e[5]=A):A=e[5],A}if(Ze(s)){let A;return e[6]!==l||e[7]!==s||e[8]!==p?(A=t.jsx(Es,{filePath:s,diff:l,renderSideBySide:p}),e[6]=l,e[7]=s,e[8]=p,e[9]=A):A=e[9],A}let E;e[10]===Symbol.for("react.memo_cache_sentinel")?(E={contain:"layout"},e[10]=E):E=e[10];let w;return e[11]!==v||e[12]!==l.fileDiff||e[13]!==l.modified||e[14]!==l.original||e[15]!==s||e[16]!==S||e[17]!==m||e[18]!==D||e[19]!==c||e[20]!==p||e[21]!==j?(w=t.jsx("div",{className:"w-full",style:E,children:t.jsx(ds,{original:l.original,modified:l.modified,fileDiff:l.fileDiff,language:m,fileName:s,renderSideBySide:p,wrapLines:j,layout:"inline",hunkActions:S,onExpandContextRequest:D,pendingContextExpansion:c,contextLoading:v})}),e[11]=v,e[12]=l.fileDiff,e[13]=l.modified,e[14]=l.original,e[15]=s,e[16]=S,e[17]=m,e[18]=D,e[19]=c,e[20]=p,e[21]=j,e[22]=w):w=e[22],w}),Ms=r.memo(({visible:o=!0,directory:e,file:s,layout:l,wrapLines:y,isSelected:p,isExpanded:j,isMounted:S,onSelect:D,onExpandedChange:c,registerSectionRef:v,showOpenInEditorAction:C=!1,isOpeningInEditor:m=!1,onOpenInEditor:E,staged:w=!1,loadFullFiles:A=!1,initialDiffData:P=null,comparisonDiff:f,onRetryComparisonDiff:be,loadFullComparisonDiff:Z,readOnlyActions:ee=!1,hunkActionsEnabled:Ne=!1,contentRevision:$=0})=>{const{t:x}=$e(),{git:I}=Xt(),q=ae(r.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]=r.useState(0),[J,B]=r.useState(null),[se,X]=r.useState(!1),[z,je]=r.useState(null),V=z!==null&&z.source===f?z.result:f,K=!!e&&!P&&(!f||!!Z),R=r.useMemo(()=>V?V.status==="error"?{kind:"error",message:V.message}:null:J,[V,J]),ce=V?V.status==="loading":se,[G,ot]=r.useState(null),Te=r.useRef(!1),[Be,tt]=r.useState(null),[at,pt]=r.useState(!1),[nt,Ie]=r.useState(null),[qe,Pe]=r.useState(null),[a,Ee]=r.useState(null),re=A||a!==null;r.useEffect(()=>{if(!a||!Z||!f||f.status!=="ready"||z?.source===f)return;let g=!1;return Z(s.path).then(L=>{if(!g){if(L.status==="error"){He.error(L.message),Ee(null);return}je({source:f,result:L})}}),()=>{g=!0}},[a,s.path,z,Z,f]);const ge=r.useRef(null),Le=r.useRef(null),_e=r.useMemo(()=>sn(s),[s]),We=l==="side-by-side",Oe=re?"full":"patch",ve=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,ue=Ne&&!ee&&!P&&!V&&!Ze(s.path),Ue=JSON.stringify([Ae(),e,s.path,w,ve,ne,$]),W=Be?.scope===Ue?Be.patch:null,Ce=Be?.scope===Ue?Be.submodule:null,ie=r.useMemo(()=>V?V.status==="ready"?V.data:null:P||(w?qe:nt||(q?{original:q.original,modified:q.modified,isBinary:q.isBinary,submodule:q.submodule,contextMode:"full"}:null)),[V,q,P,nt,w,qe]),Je=ie?.contextMode===Oe,st=r.useCallback(g=>{Le.current=g,v(s.path,g)},[s.path,v]),ze=r.useCallback(g=>{c(s.path,g)},[s.path,c]),Xe=r.useCallback(()=>{D(s.path)},[s.path,D]),lt=r.useRef({fileStatusKey:ve,staged:w});r.useEffect(()=>{if(!o)return;const g=lt.current;g.fileStatusKey===ve&&g.staged===w||(lt.current={fileStatusKey:ve,staged:w},w?Pe(null):Ie(null),B(null),ge.current=null)},[ve,w,o]);const[ht,gt]=r.useState($),xe=ht===$;r.useEffect(()=>{xe||(B(null),ge.current=null)},[xe]),r.useEffect(()=>{if(!o||!j||!S||J)return;if(!e||V||P||ie&&Je&&xe&&(!ue||W!==null)){ge.current=null,X(!1);return}const g=`${e}::${s.path}::${w?"staged":"unstaged"}::${ve}::${Oe}::${ne}::${$}`;if(ge.current===g)return;ge.current=g,B(null),X(!0);let L=!1;const ye=Ae(),we=re?tn:kt,_=Ze(s.path)?I.getGitFileDiff(e,{path:s.path,staged:w}):!re&&W!==null?Promise.resolve({diff:W,submodule:Ce}):I.getGitDiff(e,{path:s.path,staged:w,contextLines:we}),Ke=ue&&re&&W===null?I.getGitDiff(e,{path:s.path,staged:w,contextLines:kt}).then(b=>b.diff):Promise.resolve(W),xt=Promise.all([_,Ke]),ut=bs;let rt;const yt=new Promise((b,de)=>{rt=setTimeout(()=>de(new Error(`Timed out after ${ut}ms`)),ut)});return Promise.race([xt,yt]).then(([b,de])=>{if(L||ye!==Ae())return;const U="diff"in b&&!re?b.diff:de;if(ue&&re&&U!==null&&/^@@\s/m.test(U)&&"diff"in b&&b.diff!==U&&!Bn(b.diff,U))throw tt(null),new Error(x("diffView.hunk.unavailable"));if(ue&&U!==null&&tt({scope:Ue,patch:U,submodule:b.submodule}),"diff"in b){const Y={...Nt(s.path,b.diff,Oe),submodule:b.submodule};w?Pe(Y):Ie(Y)}else{const Y={original:b.original??"",modified:b.modified??"",isBinary:b.isBinary,submodule:b.submodule,contextMode:"full"};w?Pe(Y):le(e,s.path,Y,ye)}gt($),X(!1)}).catch(b=>{if(!(L||ye!==Ae())){if(X(!1),b instanceof Dn){B({kind:"unavailable",reason:b.reason}),b.reason==="path_not_found"&&te(e,I,{force:!0,silent:!0});return}B({kind:"error",message:b instanceof Error?b.message:String(b)})}}).finally(()=>clearTimeout(rt)),()=>{L=!0,clearTimeout(rt),ge.current===g&&(ge.current=null)}},[W,Ce,$,ue,xe,Ue,V,Oe,ie,Je,ne,e,te,s.path,ve,I,P,j,S,re,J,le,w,x,o]);const Me=r.useCallback(()=>{ze(!j),Xe()},[ze,Xe,j]),oe=r.useCallback(()=>{B(null),tt(null),Ie(null),Pe(null),ge.current=null,he(g=>g+1)},[]),H=r.useCallback(async(g,L)=>{if(!e||!ue||ce||R||Te.current||G!==null)return;const ye=W?In(W,g):null;if(!ye){He.error(x("diffView.hunk.unavailable"));return}if(w&&L!=="unstage"||!w&&L==="unstage")return;Te.current=!0;const we=Ae();ot({index:g,action:L});try{const _=L==="stage"?I.stageGitHunk:L==="unstage"?I.unstageGitHunk:I.revertGitHunk;if(!_){He.error(x("diffView.hunk.unsupported"));return}if(await _(e,s.path,ye),we!==Ae())return;oe(),Yt.requestGitRefresh({directory:e,paths:[s.path]}),await te(e,I)}catch(_){if(we!==Ae())return;oe(),He.error(_ instanceof Error&&_.message?_.message:x("diffView.hunk.unavailable"))}finally{Te.current=!1,ot(_=>_?.index===g&&_.action===L?null:_)}},[W,ue,ce,R,e,te,s.path,I,G,oe,w,x]),Se=r.useMemo(()=>ue&&W!==null?Pn(W):[],[W,ue]),Re=r.useCallback(g=>t.jsx(gs,{index:g,staged:w,busyHunk:G,disabled:ce||!!R,onAction:H}),[R,H,G,ce,w]),ct=r.useMemo(()=>Se.length>0?{anchors:Se,render:Re}:void 0,[Se,Re]);return t.jsxs("div",{ref:st,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[t.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:t.jsxs("div",{role:"button",tabIndex:0,onClick:Me,onKeyDown:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),Me())},className:Ve("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:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:j?t.jsx(O,{name:"arrow-down-s",className:"size-4"}):t.jsx(O,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:_e.color},title:x(_e.descriptionKey),"aria-label":x(_e.descriptionKey),children:_e.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Zt,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const g=s.path.lastIndexOf("/");if(g===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const L=s.path.slice(0,g),ye=s.path.slice(g+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:L}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ye})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[rn(s.insertions,s.deletions),C&&E?t.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(),E(s.path,ie)},disabled:m,children:m?t.jsx(O,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(O,{name:"edit",className:"size-3.5"})}):null,t.jsx(Qt,{mode:We?"side-by-side":"unified",onModeChange:g=>{const L=g==="side-by-side"?"side-by-side":"inline";pe(s.path,L)},className:"opacity-70"})]})]})}),j&&t.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!S&&!R?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,R?.kind==="unavailable"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:R.reason==="nested_repository"?x("diffView.unavailable.nestedRepositoryTitle"):R.reason==="untracked_directory"?x("diffView.unavailable.untrackedDirectoryTitle"):x("diffView.unavailable.missingTitle")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:R.reason==="nested_repository"?x("diffView.unavailable.nestedRepositoryDescription"):R.reason==="untracked_directory"?x("diffView.unavailable.untrackedDirectoryDescription"):x("diffView.unavailable.missingDescription")}),R.reason==="path_not_found"?t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:oe,children:x("diffView.actions.retry")}):null]}):null,R?.kind==="error"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:x("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:R.message}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>V?be?.():oe(),children:x("diffView.actions.retry")})]}):null,S&&ce&&!ie&&!R?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),x("diffView.state.loadingDiff")]}):null,S&&ie&&!at&&s.insertions+s.deletions>Gt?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:x("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:x("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>pt(!0),children:x("diffView.actions.renderAnyway")})]}):null,S&&ie&&(at||s.insertions+s.deletions<=Gt)?t.jsx(t.Fragment,{children:t.jsx(Ls,{filePath:s.path,diff:ie,staged:w,renderSideBySide:We,wrapLines:y,hunkActions:ct,onExpandContextRequest:K?Ee:void 0,pendingContextExpansion:a,contextLoading:a!==null&&ie.contextMode!=="full"&&!R})}):null]})]})}),eo=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:l=!1,showOpenInEditorAction:y=!1,diffScope:p="all",onDiffScopeChange:j,targetFilePath:S=null,flushContent:D=!1})=>{const{t:c}=$e(),{git:v,files:C}=Xt(),m=Un(),E=ae(n=>n.runtimeKey),{rootIsGitRepo:w,gitDirectory:A,nestedRepos:P}=Jn(m??null,{enabled:o}),f=A??m,be=me(n=>n.openContextSurface),Z=fs(n=>n.requestSource),{screenWidth:ee,isMobile:Ne}=Xn(),$=Yn(f??null),x=Qn(f??null),I=Zn(f??null),q=ae(n=>n.setActiveDirectory),le=ae(n=>n.ensureStatus),te=ae(n=>n.selectNestedRepo),pe=ae(n=>n.fetchStatus),ne=ae(n=>n.fetchBranches),he=ae(n=>n.clearDiffCache),J=ae(n=>n.setDiff),[B,se]=r.useState(null),[X,z]=r.useState(!1),[je,V]=r.useState(null),[K,R]=r.useState(()=>new Set),[ce,G]=r.useState(()=>new Set),[ot,Te]=r.useState(0),[Be,tt]=r.useState(()=>new Map),[at,pt]=r.useState(0),[nt,Ie]=r.useState(!1),[qe,Pe]=r.useState(!1),[a,Ee]=r.useState(p);r.useEffect(()=>{Ee(p)},[p]);const re=me(n=>n.pendingDiffFile),ge=me(n=>n.pendingDiffStaged),Le=me(n=>n.pendingDiffScope),_e=me(n=>n.setPendingDiffFile),We=me(n=>n.diffLayoutPreference),Oe=me(n=>n.diffFileLayout),ve=me(n=>n.setDiffFileLayout),ue=me(n=>n.diffWrapLines),Ue=me(n=>n.setDiffWrapLines),W=me(n=>n.openContextFileAtLine),Ce=Ot(n=>n.currentSessionId),ie=es(a==="turn"?Ce??"":"",m??void 0),Je=ue,st=a==="staged"?!0:a==="working"?!1:null,ze=st??X,Xe=Ne||ee<=768,lt=!!Ce&&a!=="turn"&&a!=="commit"&&a!=="pr"&&!Xe&&!De(),ht=a!=="turn"&&!Xe&&!De(),gt=!e&&!Xe&&ee>=1024,xe=r.useRef(null),Me=r.useRef(new Map),oe=r.useRef(null),H=r.useRef(null),Se=r.useRef(!1),Re=r.useRef(null),ct=r.useRef(null),g=r.useRef(null),L=r.useRef(null),ye=r.useCallback(()=>{const n=xe.current;if(!n)return null;const i=n.getBoundingClientRect().top,d=[];for(const[u,h]of Me.current)h&&d.push({path:u,top:h.getBoundingClientRect().top});return zt(i,d)},[]),we=r.useCallback(()=>{oe.current=null,Se.current=!1,V(null),H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null)},[]),_=r.useCallback(n=>{R(i=>{if(i.has(n))return i;const d=new Set(i);return d.add(n),d})},[]),Ke=r.useMemo(()=>{for(let n=ie.length-1;n>=0;n-=1){const i=ie[n];if(i.role==="user")return Fs(i.summary?.diffs)}return[]},[ie]),xt=r.useMemo(()=>{const n=new Map;for(const i of Ke)if(i.file){if(typeof i.patch=="string"){n.set(i.file,Nt(i.file,i.patch,"patch"));continue}n.set(i.file,{original:i.before??"",modified:i.after??"",contextMode:"full"})}return n},[Ke]),ut=r.useMemo(()=>x?.files?x.files.filter(Wt).length:0,[x]),rt=r.useMemo(()=>x?.files?x.files.filter(qt).length:0,[x]),yt=Ke.length,b=x?.current??null,de=An(f??null,b,o&&a==="pr"&&!De()),U=de.selectedSource,Y=Vn(f??null,b,o&&a==="commit"&&!De()),Ge=Y.selectedCommit?.hash??null;r.useEffect(()=>{(a==="commit"||a==="pr")&&De()&&(Ee("working"),j?.("working"))},[a,j]);const Ye=ae(n=>f?n.directories.get(f)?.branches??null:null),on=ae(n=>f?n.directories.get(f)?.isLoadingBranches??!1:!1),an=r.useCallback(()=>{f&&ne(f,v)},[f,ne,v]),ln=zn(f??null,o&&$!==!1,on,!!Ye,an,vs),Ct=r.useMemo(()=>{const n=x?.tracking?.trim().split("/")[0];return(n&&Ye?.defaultBranches?.[n])??Ye?.defaultBranches?.origin??null},[Ye,x?.tracking]),Rt=!De()&&Kn(b,Ct),cn=x!==null,Ft=De()||ln||Gn(b,Ct,cn,Ye!==null),un=En(n=>n.setOverride),{base:Fe,resolved:dn,revision:Dt}=Ln(f??null,b,o&&Rt&&a==="branch"),[fn,mn]=r.useState(0);r.useEffect(()=>{const n=qn(a,!Ft);n!==a&&(Ee(n),n==="working"&&j?.("working"))},[a,Ft,j]);const pn=r.useMemo(()=>a==="pr"?U:a==="commit"&&Ge?{kind:"commit",hash:Ge}:a==="branch"&&Fe&&b?{kind:"branch",baseRef:Fe,headRef:b}:null,[a,Fe,b,Ge,U]),M=Hn(f??null,pn,o&&!De(),a==="branch"?Dt:""),{fetchDiff:At}=M,Vt=a==="commit"?M.files:null,Et=a==="commit"?M.error:null,dt=a==="branch"?M.files:null,Lt=a==="branch"?M.error:null,Mt=M.files?a==="pr"?JSON.stringify([M.key,M.revision]):M.key:null,hn=r.useMemo(()=>a==="branch"||a==="commit"||a==="pr"?Array.from(K).sort().join("\0"):"",[a,K]),wt=r.useCallback(async(n,i=!1)=>{try{const d=await At(n,i?tn:kt);return{status:"ready",data:Nt(n,d.diff,i?"full":"patch")}}catch(d){return{status:"error",message:d instanceof Error?d.message:c("diffView.state.failedToLoadDiff")}}},[At,c]),gn=r.useMemo(()=>a==="branch"||a==="commit"?n=>wt(n,!0):void 0,[a,wt]),xn=$n(Mt,o?hn:"",Mt?wt:null,$t,JSON.stringify([a==="branch"?Dt:"",a==="pr"?M.revision:0,fn])),yn=dt?.length??null,N=r.useMemo(()=>{if(a==="commit"||a==="pr")return(M.files??[]).map(u=>({path:u.path,index:"",working_dir:u.status,insertions:u.insertions,deletions:u.deletions,isNew:u.status==="A"}));if(a==="branch")return(dt??[]).map(u=>({path:u.path,index:"",working_dir:u.status,insertions:0,deletions:0,isNew:u.status==="A"})).sort((u,h)=>u.path.localeCompare(h.path));if(a==="turn")return Ke.map(u=>({path:u.file??"",index:"",working_dir:Ds(u.status),insertions:u.additions??0,deletions:u.deletions??0,isNew:u.status==="added"})).filter(u=>u.path).sort((u,h)=>u.path.localeCompare(h.path));if(!x?.files)return[];const n=x.diffStats,i=a==="staged"?qt:a==="working"?Wt:()=>!0,d=u=>{const h=n?.staged?.[u],F=n?.working?.[u];return a==="staged"?{insertions:h?.insertions??0,deletions:h?.deletions??0}:a==="working"?{insertions:F?.insertions??0,deletions:F?.deletions??0}:{insertions:(h?.insertions??0)+(F?.insertions??0),deletions:(h?.deletions??0)+(F?.deletions??0)}};return x.files.filter(i).map(u=>{const h=d(u.path);return{...u,insertions:h.insertions,deletions:h.deletions,isNew:Cs(u)}}).sort((u,h)=>u.path.localeCompare(h.path))},[a,dt,M.files,Ke,x]),bt=r.useMemo(()=>N.map(n=>n.path).join("\0"),[N]);r.useEffect(()=>{const n=bt?bt.split("\0"):[],i=new Set(n),d=`${f??""}:${a}:${s?"collapsed":"default"}`,u=ct.current!==d;ct.current=d,R(h=>{if(u){const T=s?0:js(n.length);return new Set(n.slice(0,T))}let F=!1;const k=new Set;for(const T of h){if(!i.has(T)){F=!0;continue}k.add(T)}return F?k:h}),G(h=>{if(u)return new Set;let F=!1;const k=new Set;for(const T of h){if(!i.has(T)){F=!0;continue}k.add(T)}return F?k:h})},[a,bt,f,s]);const Tt=r.useCallback(()=>{if(Re.current=null,!o)return;const n=xe.current;if(!n)return;const i=n.getBoundingClientRect(),d=i.top-Ht,u=i.bottom+Ht,h={},F=[];for(const[k,T]of Me.current){if(!T)continue;const Q=T.getBoundingClientRect();F.push({path:k,top:Q.top}),K.has(k)&&(Q.bottom<d||Q.top>u||(h[k]=!0))}g.current=zt(i.top,F),G(k=>{let T=!1;const Q=new Set(k);for(const it of Object.keys(h))Q.has(it)||(Q.add(it),T=!0);return T?Q:k})},[K,o]),fe=r.useCallback(()=>{o&&(typeof window>"u"||Re.current===null&&(Re.current=window.requestAnimationFrame(Tt)))},[Tt,o]);r.useEffect(()=>{const n=xe.current;if(!(!o||!n))return fe(),n.addEventListener("scroll",fe,{passive:!0}),window.addEventListener("resize",fe),()=>{n.removeEventListener("scroll",fe),window.removeEventListener("resize",fe),Re.current!==null&&(window.cancelAnimationFrame(Re.current),Re.current=null)}},[N,K,fe,o]);const jt=r.useCallback(n=>{const i=Oe[n.path];if(i)return i;if(We==="inline")return"inline";if(We==="side-by-side")return"side-by-side";const d=ee<ws;return n.isNew||d?"inline":"side-by-side"},[Oe,We,ee]),Bt=r.useMemo(()=>N.length===0?null:N.every(n=>jt(n)==="side-by-side")?"side-by-side":"inline",[N,jt]);r.useEffect(()=>{o&&f&&(q(f),le(f,v))},[f,q,le,v,o]);const ft=JSON.stringify([E,f]),vt=r.useRef({scope:ft,paths:new Set,dirty:!1,unscoped:!1}),It=r.useRef(o);r.useEffect(()=>{const n=o&&!It.current;if(It.current=o,vt.current.scope!==ft&&(vt.current={scope:ft,paths:new Set,dirty:!1,unscoped:!1}),!f)return;const i=(u,h)=>{u.length&&(L.current=ye()??g.current,he(f,u),tt(F=>{const k=new Map(F);for(const T of u)k.set(T,(k.get(T)??0)+1);return k})),h&&pt(F=>F+1),pe(f,v,{silent:!0})},d=vt.current;return o&&(n||d.dirty)&&(i([...d.paths],d.unscoped),d.paths.clear(),d.dirty=!1,d.unscoped=!1),Yt.onGitRefreshHint(u=>{if(Ut(u.directory)!==Ut(f))return;const h=u.paths??[],F=h.length===0;if(!o){d.dirty=!0,d.unscoped||=F;for(const k of h)d.paths.add(k);return}i(h,F)})},[ye,he,f,pe,v,ft,o]),r.useLayoutEffect(()=>{const n=L.current;if(!n)return;L.current=null;const i=xe.current,d=Me.current.get(n.path);if(!i||!d)return;const u=i.getBoundingClientRect().top,h=d.getBoundingClientRect().top-u;i.scrollTop=ys(i.scrollTop,n.topOffset,h,i.scrollHeight-i.clientHeight),g.current=n},[Be]),r.useEffect(()=>{!o||a!=="all"&&!Le||re&&(Le&&Ee(Le),se(re),z(Le==="staged"||!Le&&ge),_e(null),Se.current=!0,oe.current=re,_(re),Te(n=>n+1))},[a,_,re,Le,ge,_e,o]),r.useEffect(()=>{if(a==="all")return;const n=S?.trim();n&&(se(n),z(a==="staged"),Se.current=!0,oe.current=n,_(n),Te(i=>i+1))},[a,_,S]),r.useEffect(()=>{if(!B)return;N.some(i=>i.path===B)||(se(null),z(!1))},[N,B]);const wn=r.useCallback((n,i)=>{const d=Me.current;i?d.set(n,i):d.delete(n),fe()},[fe]),bn=r.useCallback((n,i)=>{we(),R(d=>{const u=d.has(n);if(i===u)return d;const h=new Set(d);return i?h.add(n):h.delete(n),h}),i||G(d=>{if(!d.has(n))return d;const u=new Set(d);return u.delete(n),u}),fe()},[we,fe]),jn=r.useCallback(()=>{we(),R(n=>n.size>0?new Set:new Set(N.map(i=>i.path))),G(new Set),fe()},[we,N,fe]),vn=r.useCallback(async n=>{if(!Ce)return;const i=Ot.getState().getDirectoryForSession(Ce)||m||"";if(!i){He.error(c("diffView.reviewDialog.toast.noSessionDirectory"));return}Pe(!0);try{await ts({originalSessionID:Ce,directory:i,providerID:n.providerID,modelID:n.modelID,agent:n.agent||void 0,variant:n.variant||void 0,generateHandoff:n.generateHandoff,returnAfterHandoffRequest:n.generateHandoff,autoReview:n.autoReview}),Ie(!1)}catch(d){console.error("[review-flow] failed to start review flow",d),He.error(d instanceof Error?d.message:c("diffView.reviewDialog.toast.startFailed"))}finally{Pe(!1)}},[Ce,m,c]),mt=r.useCallback(n=>{const i=Me.current.get(n),d=xe.current;if(!i||!d)return!1;const u=i.getBoundingClientRect().top-d.getBoundingClientRect().top;return d.scrollTo({top:d.scrollTop+u,behavior:"auto"}),!0},[]);r.useEffect(()=>{const n=oe.current;if(!o||!n)return;let i=0;const d=20;let u=!1;const h=(k=!0)=>{u||(u=!0,oe.current=null,Se.current=!1,k&&V(null),H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null))},F=()=>{if(u){H.current=null;return}const k=oe.current;if(!k){h(),H.current=null;return}if(!mt(k)){i+=1,i<d?H.current=window.requestAnimationFrame(F):(h(),H.current=null);return}if(l&&Se.current){V(k),h(!1);return}h()};return H.current=window.requestAnimationFrame(F),()=>{u=!0,H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null)}},[l,ot,mt,o]);const Sn=r.useCallback(n=>{},[]),St=r.useCallback(n=>{we(),se(n),z(!1),Se.current=!0,oe.current=n,_(n),Te(i=>i+1),mt(n)},[we,_,mt]);r.useEffect(()=>{const n=i=>{if(!o||!i.altKey||i.metaKey||i.ctrlKey||i.shiftKey||i.key!=="ArrowDown"&&i.key!=="ArrowUp")return;const d=i.target;if(d instanceof HTMLElement&&(d.isContentEditable||d.tagName==="INPUT"||d.tagName==="TEXTAREA"||d.closest('[role="dialog"]'))||N.length===0)return;const u=i.key==="ArrowDown"?1:-1,h=B?N.findIndex(T=>T.path===B):-1,F=h===-1?u>0?0:N.length-1:h+u,k=N[F];k&&(i.preventDefault(),St(k.path))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[N,B,St,o]);const kn=r.useCallback(n=>{const i=n==="side-by-side"?"side-by-side":"inline";N.forEach(d=>{ve(d.path,i)})},[N,ve]),[Nn,Pt]=r.useState(null),Cn=r.useCallback(async(n,i)=>{if(!f||!n)return;Pt(n);const d=Ae();try{let u=null;if(i?.patch&&!i.isBinary&&!Ze(n)?u=Kt(i.patch):i&&i.contextMode==="full"&&!i.isBinary&&!Ze(n)&&(u=Jt(i.original,i.modified)),u===null)try{const Q=await v.getGitDiff(f,{path:n,staged:ze,contextLines:3});u=Kt(Q.diff)}catch{u=null}let h=i;if(u===null||!h){const Q=await v.getGitFileDiff(f,{path:n,staged:ze}),it={original:Q.original??"",modified:Q.modified??"",isBinary:Q.isBinary,submodule:Q.submodule};h=it,ze||J(f,n,it,d)}const F=u??(h.isBinary||Ze(n)?1:Jt(h.original,h.modified)),k=Rs(f,n),T=await ms(C,k,{directory:f});if(!T.ok){He.error(ps(T.reason));return}W(f,k,F,1)}finally{Pt(u=>u===n?null:u)}},[ze,f,C,v,W,J]),Rn=()=>{if(!f)return null;const n=i=>st!==null?st:X&&i===B;return t.jsxs("div",{className:Ve("flex min-w-0 flex-1 min-h-0 h-full",D?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[gt&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:c("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),t.jsx(Vs,{changedFiles:N,selectedFile:null,onSelectFile:St})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsx(en,{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:t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(i=>t.jsx(Ms,{visible:o,directory:f,file:i,layout:jt(i),wrapLines:Je,isSelected:!1,isExpanded:K.has(i.path),isMounted:ce.has(i.path)||i.path===je,onSelect:Sn,onExpandedChange:bn,registerSectionRef:wn,showOpenInEditorAction:y&&a!=="turn",isOpeningInEditor:Nn===i.path,onOpenInEditor:(d,u)=>{Cn(d,u)},staged:n(i.path),readOnlyActions:a==="branch"||a==="commit"||a==="pr",hunkActionsEnabled:a==="all"||a==="working"||a==="staged",contentRevision:at,comparisonDiff:a==="branch"||a==="commit"||a==="pr"?xn.get(i.path)??$t:void 0,onRetryComparisonDiff:()=>mn(d=>d+1),loadFullComparisonDiff:gn,initialDiffData:a==="turn"?xt.get(i.path)??null:null},`${Ae()}:${f}:${i.path}:${Be.get(i.path)??0}`))})})})]})},Fn=()=>{if(!f)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.selectSessionDirectory")});if(a!=="turn"&&I&&!x)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingRepositoryStatus")]});if(a!=="turn"&&$===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.notGitRepository")});if(a==="pr"){if(!U||M.error)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:M.error??de.error??(de.loading?c("session.githubPrPicker.loading.pullRequests"):c("pullRequestComparison.select"))}),(M.error||de.error)&&t.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{U?M.refresh():de.refresh()},children:c("diffView.actions.retry")}),!U&&!de.loading&&t.jsx(_t,{comparison:de})]});if(!M.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="commit"){if(Et)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:Et}),t.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{M.refresh()},children:c("diffView.actions.retry")})]});if(!Ge&&!Y.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Y.error??c("commitComparison.noCommits")});if(!Vt)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="branch"){if(!dn)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.resolvingBase")]});if(!Fe)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(O,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:c("gitView.pr.toast.baseBranchRequired")})]});if(Lt)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Lt}),t.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{M.refresh()},children:c("diffView.actions.retry")})]});if(dt===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.loadingFiles")]})}return N.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a==="turn"?c("diffView.state.noLastTurnChanges"):a==="pr"?c("walkthrough.blocked.emptyDiff.description"):a==="commit"?c("commitComparison.emptyDiff"):a==="branch"&&Fe?c("diffView.branch.empty",{base:us(Fe)}):c("diffView.state.cleanWorkingTree")}):Rn()};return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[t.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(P)&&P.length>0?t.jsx(cs,{repositories:P,selectedRepository:A??null,onSelectRepository:n=>{m&&te(m,n)},repositoryRoot:m??void 0}):null,!Ne&&(a!=="all"?t.jsx(As,{scope:a,workingCount:ut,stagedCount:rt,turnCount:yt,branchCount:yn,commitCount:a==="commit"?Vt?.length??null:null,prCount:a==="pr"?M.files?.length??null:null,showCommitOption:!De(),showBranchOption:Rt,onScopeChange:n=>{Ee(n),j?.(n)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:I&&!x?c("diffView.state.loadingChanges"):N.length===1?c("diffView.summary.changedFilesSingle",{count:N.length}):c("diffView.summary.changedFilesPlural",{count:N.length})})})),a==="branch"&&t.jsx(Mn,{branches:Ye?.all??[],currentBranch:b,base:Fe,onSelect:n=>{f&&b&&un(f,b,n)}},JSON.stringify([f,b])),a==="commit"&&t.jsx(Tn,{commits:Y.commits,selectedHash:Ge,loading:Y.loading,error:Y.error,onSelect:Y.select,onRefresh:()=>{Y.refresh()}},JSON.stringify([f,b])),a==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(_t,{comparison:de},JSON.stringify([E,f,b])),U&&t.jsx(ke,{variant:"ghost",size:"sm",disabled:M.loading,"aria-label":c("session.githubIssuePicker.actions.refresh"),title:c("session.githubIssuePicker.actions.refresh"),onClick:()=>{M.refresh()},children:t.jsx(O,{name:"refresh",className:"size-4"})})]}),N.length>0&&t.jsxs(ke,{variant:"ghost",size:"sm",onClick:jn,className:Ve("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:K.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll"),children:[t.jsx(O,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:K.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll")})]}),N.length>0&<&&t.jsxs(ke,{variant:"default",size:"sm",onClick:()=>Ie(!0),disabled:qe,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":c("diffView.actions.reviewAria"),children:[qe?t.jsx(O,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(O,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:c("diffView.actions.review")})]}),N.length>0&&ht&&t.jsxs(ke,{variant:"outline",size:"sm",onClick:()=>{const n=f??"";Z(n,a==="pr"&&U?U:a==="commit"&&Ge?{kind:"commit",hash:Ge}:a==="branch"&&Fe&&b?{kind:"branch",baseRef:Fe,headRef:b}:{kind:"working-tree",scope:a==="staged"||a==="working"?a:"all"}),be(m??n,"walkthrough")},className:Ve("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",hs),"aria-label":c("walkthrough.action.open"),children:[t.jsx(O,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:c("walkthrough.action.open")})]}),N.length>0&&t.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>Ue(!ue),className:Ve("h-5 w-5 p-0 transition-opacity",Je?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:c(Je?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(O,{name:"text-wrap",className:"size-4"})}),Bt&&t.jsx(Qt,{mode:Bt==="side-by-side"?"side-by-side":"unified",onModeChange:kn})]}),t.jsx(ns,{open:nt,onOpenChange:Ie,projectDirectory:f??null,submitting:qe,onConfirm:vn}),Fn()]})};export{eo as DiffView,Ms as MultiFileDiffEntry};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{f as ut,R as s,c as ei,j as n,r as ct}from"./vendor-react-BUCujlKS.js";import{Y as Ua,Z as qa,_ as Ka,$ as Ha,v as Ze,a as lt,u as wt,dO as Ga,I as ti,B as Xa,h as ri,a4 as ni,e as Ja,dM as Za,a3 as Ya,dN as Qa}from"./index-Dqc6USl3.js";import{f as tr,z as si,af as Si,cd as eo,h as K,k2 as to,fZ as ro,W as gr,B as I,I as F,Z as no,S as so,bg as io,K as ao,ah as oo,cy as lo,eF as ii,k3 as ai,k4 as co,ic as uo,gg as fo,t as J,l as oi,av as Cn,cr as pr,d6 as mo,b as po,k5 as hr,b$ as ho,aw as Sn,k6 as li,cs as ci,ct as ui,hc as go,k7 as vo,k8 as xo,k9 as wo,c0 as ki,c1 as Ri,c2 as Ti,c3 as Ei,c4 as Vi,c5 as Pi,ap as Pn,aq as Dn,ax as Gr,as as Mn,be as Xr,c6 as kn,ay as Rn,cn as di,aa as Xt,ab as Jt,ac as Zt,bZ as bo,b_ as yo,g as Zr,bf as jo,cx as Fo}from"./useAppFontEffects-ne84JBVL.js";import{an as No,R as Co,V as So,W as ko,X as Ro,Y as To}from"./runtimeEndpointReset-DdrazOVH.js";import{c as fi,s as Eo,P as Tn,C as Vo}from"./shikiHighlight-BPu3JiQs.js";import{a as Po}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Tt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Do,J as Mo,F as zo}from"./JsonTreeView-VW_7czo3.js";import{ensurePierreThemeRegistered as mi,getResolvedShikiTheme as Lo}from"./appThemeRegistry-DLicw4dH.js";import{V as Ao,W as Io}from"./Virtualizer-CZlLSacm.js";import{V as Oo}from"./Virtualizer-D_a8gKmg.js";import{a as Bo,u as qr,b as $o,g as _o,h as Wo,i as Uo}from"./scheduledTasksApi-B2SWMGEU.js";import{D as qo}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Ko,u as Ho,n as Go}from"./useInlineCommentController-CgS0fnw_.js";import{b as Xo}from"./CodeMirrorCommentWidgets-B4a0JkUz.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CgAdXWZO.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.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-Bx2EHc1O.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-B808E0-d.js";import"./PluginPane-DEcgDQ9h.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-DxX8bZ1o.js";import"./computeVirtualFileMetrics-DlWlEM3x.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-ue6kCou7.js";import"./textMateThemeFromAppTheme-DWqRPo9A.js";function pi(i){const e=ut.c(41),{containerRef:r,filePath:o,fileContent:w}=i,{t:h}=tr(),b=si(nl),x=si(rl),v=Si(),m=eo(tl),[f,j]=s.useState(null),[N,R]=s.useState(""),[S,E]=s.useState(!1),y=s.useRef(!1),c=s.useRef(null),D=s.useRef(null),[T,M]=s.useState(null);let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{j(null),R(""),E(!1),y.current=!1,D.current=null,M(null)},e[0]=P):P=e[0];const V=P;let k,L;e[1]!==r?(k=()=>{const q=r.current;if(!q)return;const X=()=>{if(y.current)return;const re=window.getSelection(),ge=re?.toString().trim()??"";if(!re||!ge||re.rangeCount===0){V();return}const ne=re.getRangeAt(0);if(!q.contains(ne.commonAncestorContainer)){V();return}const Q=ne.getBoundingClientRect();D.current=ne.cloneRange(),R(ge),j({x:Q.left+Q.width/2,y:Q.top-10})},_=re=>{c.current?.contains(re.target)||y.current&&V()};return document.addEventListener("selectionchange",X),document.addEventListener("pointerdown",_),()=>{document.removeEventListener("selectionchange",X),document.removeEventListener("pointerdown",_)}},L=[r,V],e[1]=r,e[2]=k,e[3]=L):(k=e[2],L=e[3]),s.useEffect(k,L);let B;e[4]!==w?(B=q=>{const X=fe=>w.slice(0,fe).split(`
|
|
2
|
-
`).length,_=Qo,re=(fe,xe)=>{for(const Re of _(fe)){const Ue=w.indexOf(Re,xe);if(Ue>=0)return Ue}return-1},ge=q.length>=8?w.indexOf(q):-1;if(ge>=0){const fe=X(ge);return{start:fe,end:fe+q.split(`
|
|
3
|
-
`).length-1}}const ne=q.split(`
|
|
4
|
-
`).map(Yo).filter(Boolean);if(ne.length===0)return null;const Q=re(ne[0],0);if(Q<0)return null;const ye=X(Q);if(ne.length===1)return{start:ye,end:ye};const ve=re(ne[ne.length-1],Q);return ve<0?null:{start:ye,end:Math.max(ye,X(ve))}},e[4]=w,e[5]=B):B=e[5];const $=B;let ue;e[6]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>{const q=D.current;if(!q){M(null);return}M(to(q))},e[6]=ue):ue=e[6];const de=ue;let Z,Y;e[7]!==S?(Z=()=>{if(!S)return;let q=null;const X=()=>{q===null&&(q=window.requestAnimationFrame(()=>{q=null,de()}))};return document.addEventListener("scroll",X,{capture:!0,passive:!0}),window.addEventListener("resize",X),()=>{q!==null&&window.cancelAnimationFrame(q),document.removeEventListener("scroll",X,{capture:!0}),window.removeEventListener("resize",X)}},Y=[S,de],e[7]=S,e[8]=Z,e[9]=Y):(Z=e[8],Y=e[9]),s.useEffect(Z,Y);let ae;e[10]!==N?(ae=()=>{N&&(E(!0),y.current=!0,de(),window.getSelection()?.removeAllRanges())},e[10]=N,e[11]=ae):ae=e[11];const pe=ae;let oe;e[12]!==m||e[13]!==b||e[14]!==v||e[15]!==o||e[16]!==x||e[17]!==$||e[18]!==N?(oe=q=>{const X=b??(x?"draft":null);if(!N||!X||!v){V();return}const _=$(N);m({directory:v,sessionKey:X},{source:"file-quote",fileLabel:o,startLine:_?.start??0,endLine:_?.end??0,code:N,language:"",text:q.trim()}),V(),queueMicrotask(Zo)},e[12]=m,e[13]=b,e[14]=v,e[15]=o,e[16]=x,e[17]=$,e[18]=N,e[19]=oe):oe=e[19];const H=oe;if(!f)return null;let G;e[20]!==S||e[21]!==$||e[22]!==N?(G=S?$(N):null,e[20]=S,e[21]=$,e[22]=N,e[23]=G):G=e[23];const We=G;let te;e[24]!==f.x||e[25]!==f.y?(te={left:f.x,top:f.y,transform:"translate(-50%, -100%)"},e[24]=f.x,e[25]=f.y,e[26]=te):te=e[26];let he;e[27]!==S||e[28]!==T?(he=S&&T&&T.length>0?ei.createPortal(n.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:T.map(Jo)}),document.body):null,e[27]=S,e[28]=T,e[29]=he):he=e[29];let De;e[30]!==S||e[31]!==o||e[32]!==We||e[33]!==pe||e[34]!==H||e[35]!==h?(De=S?n.jsx("div",{className:"w-[min(420px,80vw)]",children:n.jsx(Ko,{fileLabel:o,lineRange:We?{start:We.start,end:We.end}:void 0,onSave:H,onCancel:V})}):n.jsx("div",{className:K("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:n.jsx("button",{type:"button",onClick:pe,className:K("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-foreground","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:h("chat.textSelection.title.commentOnSelection"),children:h("chat.textSelection.actions.comment")})}),e[30]=S,e[31]=o,e[32]=We,e[33]=pe,e[34]=H,e[35]=h,e[36]=De):De=e[36];let be;return e[37]!==te||e[38]!==he||e[39]!==De?(be=ei.createPortal(n.jsxs("div",{ref:c,className:"fixed z-50",style:te,children:[he,De]}),document.body),e[37]=te,e[38]=he,e[39]=De,e[40]=be):be=e[40],be}function Jo(i,e){return n.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:i.left,top:i.top,width:i.width,height:i.height}},e)}function Zo(){ro()}function Yo(i){return i.trim()}function Qo(i){const e=i.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(el)}function el(i){return i.length>=8}function tl(i){return i.addDraft}function rl(i){return i.newSessionDraft?.open}function nl(i){return i.currentSessionId}const sl=(i,e)=>{if(!e)return null;const r=Number.parseInt(i.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},hi=(i,e)=>{const r=i.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},gi=(i,e,r)=>{const o=i.state.doc.line(e),w=Math.max(1,Math.min(r,o.length+1)),h=o.from+w-1;i.dispatch({selection:Po.cursor(h),effects:Tt.scrollIntoView(h,{y:"center"})})};function il({open:i,onOpenChange:e,view:r,variant:o="overlay"}){const{t:w}=tr(),[h,b]=s.useState(""),x=s.useRef(null),v=s.useRef(!1),m=s.useRef(null),f=s.useRef(null),j=s.useMemo(()=>sl(h,r),[h,r]);s.useEffect(()=>{!i||!r||(v.current=!1,x.current=hi(r,r.state.selection),b(""))},[i,r]),s.useEffect(()=>{i&&window.requestAnimationFrame(()=>{f.current?.focus(),f.current?.select()})},[i]),s.useEffect(()=>{if(!(!i||!r||!x.current)){if(j===null){const{selection:y}=x.current;r.dispatch({selection:y,effects:Tt.scrollIntoView(y.main.from,{y:"center"})});return}gi(r,j,x.current.character)}},[j,i,r]);const N=s.useCallback(()=>{if(!r||v.current||!x.current)return;const{selection:y}=x.current;r.dispatch({selection:y,effects:Tt.scrollIntoView(y.main.from,{y:"center"})})},[r]),R=s.useCallback(y=>{y||N(),e(y)},[e,N]),S=s.useCallback(()=>{!r||j===null||!x.current||(v.current=!0,gi(r,j,x.current.character),e(!1),r.focus())},[j,e,r]);s.useEffect(()=>{if(!i)return;const y=D=>{const T=m.current,M=D.target;!T||!(M instanceof Node)||T.contains(M)||R(!1)},c=D=>{D.key==="Escape"&&(D.preventDefault(),R(!1))};return document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",c,!0),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",c,!0)}},[R,i,o]);const E=s.useMemo(()=>{if(!r)return w("goToLineDialog.helper.editorUnavailable");if(j===null){const y=x.current??hi(r,r.state.selection);return w("goToLineDialog.helper.currentLineRange",{current:y.lineNumber,max:r.state.doc.lines})}return w("goToLineDialog.helper.goToLine",{line:j})},[j,w,r]);return o==="inline"?i?n.jsxs("div",{ref:m,className:"ml-1 flex h-6 items-center gap-1",children:[n.jsx(gr,{ref:f,type:"number",min:1,step:1,inputMode:"numeric",value:h,onChange:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),S())},placeholder:w("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),n.jsx(I,{variant:"outline",size:"xs",onClick:S,disabled:!r||j===null,className:"h-6 px-2",children:w("goToLineDialog.actions.go")})]}):null:n.jsx("div",{ref:m,className:K("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",i?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:n.jsxs("div",{className:"min-w-0",children:[n.jsx(gr,{ref:f,type:"number",min:1,step:1,inputMode:"numeric",value:h,onChange:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),S())},placeholder:w("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),n.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:E})]})})}const al=(i,e)=>{const r=e.trim().toLowerCase(),o=[];if(!r)return o;const w=i.toLowerCase();let h=0;for(;;){const b=w.indexOf(r,h);if(b===-1)break;o.push({start:b,end:b+r.length}),h=b+r.length}return o},Qr="data-md-find",En="data-md-find-current",Di="rounded-[2px] bg-status-warning/30 text-foreground",ol="rounded-[2px] bg-status-warning/60 text-foreground",ll=120,cl=i=>i instanceof Element&&i.hasAttribute(Qr),ul=i=>i.target instanceof Element&&i.target.hasAttribute(Qr)?!0:[...i.addedNodes].some(e=>cl(e)),Mi=i=>{const e=new Set;i.querySelectorAll(`mark[${Qr}]`).forEach(r=>{const o=r.parentNode;o&&(o.replaceChild(document.createTextNode(r.textContent??""),r),e.add(o))}),e.forEach(r=>r.normalize())},dl=(i,e)=>{Mi(i);const r=e.trim().toLowerCase();if(!r)return[];const o=[],w=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode(b){const x=b.parentElement;return!x||x.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),h=[];for(;w.nextNode();){const b=w.currentNode;b instanceof Text&&h.push(b)}for(const b of h){const x=b.nodeValue??"";if(!x)continue;const v=al(x,r);if(v.length===0)continue;const m=b.parentNode;if(!m)continue;const f=document.createDocumentFragment();let j=0;for(const N of v){N.start>j&&f.appendChild(document.createTextNode(x.slice(j,N.start)));const R=document.createElement("mark");R.setAttribute(Qr,""),R.className=Di,R.textContent=x.slice(N.start,N.end),f.appendChild(R),o.push(R),j=N.end}j<x.length&&f.appendChild(document.createTextNode(x.slice(j))),m.replaceChild(f,b)}return o},vi=({containerRef:i,open:e,onOpenChange:r,focusNonce:o,className:w})=>{const{t:h}=tr(),[b,x]=s.useState(""),[v,m]=s.useState(0),[f,j]=s.useState(0),N=s.useRef(null),R=s.useRef([]),S=s.useRef(b);S.current=b;const E=s.useRef(null),y=s.useRef(null),c=s.useCallback((k,L=!1)=>{const B=i.current;if(!B){R.current=[],m(0),j(0);return}R.current=dl(B,k);const $=R.current.length;m($),j(ue=>!L||$===0?0:Math.min(ue,$-1))},[i]),D=s.useCallback((k,L=!1)=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,c(k,L)},ll)},[c]);s.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const T=s.useCallback(()=>{r(!1);const k=y.current;y.current=null,k?.isConnected&&k.focus()},[r]);s.useEffect(()=>{const k=i.current;if(!e||!k)return;const L=new MutationObserver(B=>{!S.current.trim()||!B.some(ue=>!ul(ue))||D(S.current,!0)});return L.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{L.disconnect(),Mi(k)}},[i,e,D]),s.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!y.current&&(y.current=k),N.current?.focus()},[e]),s.useEffect(()=>{e&&o>0&&(N.current?.focus(),N.current?.select())},[e,o]),s.useEffect(()=>{const k=i.current;if(!k||(k.querySelectorAll(`mark[${En}]`).forEach(B=>{B.removeAttribute(En),B.className=Di}),v===0))return;const L=R.current[Math.min(Math.max(f,0),v-1)];L&&(L.setAttribute(En,""),L.className=ol,L.scrollIntoView({block:"nearest"}))},[i,f,v]);const M=s.useCallback(()=>{j(k=>v===0?0:(k+1)%v)},[v]),P=s.useCallback(()=>{j(k=>v===0?0:(k-1+v)%v)},[v]),V=s.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?P():M()):k.key==="Escape"&&(k.preventDefault(),T())},[T,M,P]);return e?n.jsxs("div",{className:K("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:[n.jsx(F,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),n.jsx(gr,{ref:N,value:b,onChange:k=>{x(k.target.value),D(k.target.value)},onKeyDown:V,placeholder:h("filesView.preview.find.placeholder"),"aria-label":h("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),n.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":v>0?h("filesView.preview.find.countAria",{current:f+1,total:v}):h("filesView.preview.find.noMatches"),children:b.trim()&&v===0?h("filesView.preview.find.noMatches"):v>0?`${f+1}/${v}`:""}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:P,title:h("filesView.preview.find.previousAria"),"aria-label":h("filesView.preview.find.previousAria"),disabled:v===0,children:n.jsx(F,{name:"arrow-up",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:M,title:h("filesView.preview.find.nextAria"),"aria-label":h("filesView.preview.find.nextAria"),disabled:v===0,children:n.jsx(F,{name:"arrow-down",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:T,title:h("filesView.preview.find.closeAria"),"aria-label":h("filesView.preview.find.closeAria"),children:n.jsx(F,{name:"close",className:"size-3.5"})})]}):null},fl=i=>{let e=!0;return{poll:async()=>{if(!e||i.isDirty())return!1;const r=i.getLoadedContent(),o=i.getLoadedRevision();try{const w=await i.readContent();if(!e||i.isDirty()||o!==i.getLoadedRevision())return!1;if(w===r)return!0;const h=await i.readContent();return!e||i.isDirty()||h!==w||o!==i.getLoadedRevision()?!1:(i.applyContent(w),!0)}catch{return!1}},dispose:()=>{e=!1}}},ml=1,pl=(i,e)=>e.size!==i.size||e.mtimeMs!==void 0&&i.mtimeMs!==void 0&&Math.abs(e.mtimeMs-i.mtimeMs)>=ml;function xi(){const i=ut.c(8),[e]=ct.useState(hl),r=ct.useRef(!1);let o;i[0]!==e?(o=v=>{if(v==null){e.cleanUp(),r.current=!1;return}r.current||(r.current=!0,e.setup(v,v.firstElementChild??void 0))},i[0]=e,i[1]=o):o=i[1];const w=o;let h,b;i[2]!==e?(h=()=>()=>{r.current=!1,e.cleanUp()},b=[e],i[2]=e,i[3]=h,i[4]=b):(h=i[3],b=i[4]),ct.useLayoutEffect(h,b);let x;return i[5]!==w||i[6]!==e?(x={virtualizer:e,setScroller:w},i[5]=w,i[6]=e,i[7]=x):x=i[7],x}function hl(){return new Oo}const Yt=new Map,gl=100;function Kr(i){const[e,r]=ct.useState(null),o=ct.useRef(null),w=ct.useRef(null),h=ct.useRef(null),b=ct.useCallback((x,v)=>{x&&v instanceof Do&&(h.current={key:i,file:v,node:x});const m=o.current,f=w.current,j=()=>{o.current===m&&(m?.(),f?.())};v?queueMicrotask(j):j()},[i]);return ct.useLayoutEffect(()=>{if(!e||!i)return;const x=Yt.get(i)??{top:0,left:0};let v=!0;const m=()=>h.current?.key===i?h.current.file:null,f=c=>h.current?.key===i?h.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${c-1}"]`):null,j=()=>{R.disconnect(),S.disconnect()},N=()=>{if(!v)return;const c=m(),D=x.line&&c?.getLinePosition(x.line.number),T=x.line&&f(x.line.number);let M=x.top;x.line&&D&&(M=(c?.top??0)+D.top-x.line.offset),x.line&&T&&(M=e.scrollTop+T.getBoundingClientRect().top-e.getBoundingClientRect().top-x.line.offset),e.scrollTop=M,e.scrollLeft=x.left,(!x.line||T)&&Math.abs(e.scrollTop-M)<1&&Math.abs(e.scrollLeft-x.left)<1&&(v=!1,j())},R=new ResizeObserver(N),S=new MutationObserver(()=>{if(v){for(const c of e.children)R.observe(c);N()}});R.observe(e);for(const c of e.children)R.observe(c);S.observe(e,{childList:!0,subtree:!0});const E=()=>{if(v)return;const c=m(),D=c?.getNumericScrollAnchor(e.scrollTop-(c.top??0)),T=D&&f(D.lineNumber),M=T?T.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(Yt.delete(i),Yt.set(i,{top:e.scrollTop,left:e.scrollLeft,line:D&&M!==null&&M>=0&&M<e.clientHeight?{number:D.lineNumber,offset:M}:void 0}),Yt.size>gl){const P=Yt.keys().next().value;P!==void 0&&Yt.delete(P)}},y=()=>{v=!1,j()};return o.current=N,w.current=E,N(),e.addEventListener("scroll",E,{passive:!0}),e.addEventListener("wheel",y,{passive:!0}),e.addEventListener("touchstart",y,{passive:!0}),e.addEventListener("pointerdown",y,{passive:!0}),e.addEventListener("keydown",y),()=>{o.current=null,w.current=null,h.current?.key===i&&(h.current=null),j(),e.removeEventListener("scroll",E),e.removeEventListener("wheel",y),e.removeEventListener("touchstart",y),e.removeEventListener("pointerdown",y),e.removeEventListener("keydown",y)}},[i,e]),{setScroller:r,restore:b}}function vl(i){return!(!i.autoSaveEnabled||!i.isDirty||!i.canWrite||i.isSaving||i.fileLoading||i.isNonEditableBinary||!i.selectedFilePath||i.loadedFilePath!==i.selectedFilePath)}function xl(i){return i.selectedFilePath?i.isDirty?!(i.fileLoading||i.loadedFilePath!==i.selectedFilePath||i.isNonEditableBinary||i.draftContent===""&&i.fileContent!==""&&i.loadedFilePath!==i.selectedFilePath):!0:!1}const zi=2e5,wl=i=>{let e=0,r=0;for(let o=0;o<i.length;o++)i.charCodeAt(o)===10&&(o>0&&i.charCodeAt(o-1)===13?e++:r++);return e>r?`\r
|
|
5
|
-
`:`
|
|
6
|
-
`},Li=i=>i.replace(/\r\n/g,`
|
|
7
|
-
`).replace(/\r/g,`
|
|
8
|
-
`),bl=i=>({content:Li(i),lineEnding:wl(i)}),yl=(i,e)=>{const r=Li(i);return e===`\r
|
|
9
|
-
`?r.replace(/\n/g,`\r
|
|
10
|
-
`):r},jl=(i,e)=>e??(i.length>zi?"view":"edit"),Fl=i=>{let e=2166136261;for(let r=0;r<i.length;r++)e^=i.charCodeAt(r),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return`${i.length}:${e.toString(16)}`},Nl='<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 wi(){if(typeof document>"u")return!1;const i=document.documentElement.getAttribute("data-theme");return i==="dark"||!i&&window.matchMedia("(prefers-color-scheme: dark)").matches}const Cl=s.forwardRef(function({xml:e,readOnly:r,className:o,onChange:w},h){const b=s.useRef(e),x=s.useRef(null),v=s.useRef(!1),[m,f]=s.useState(wi),j=s.useRef(e),N=s.useRef(e);N.current!==e&&(N.current=e,j.current=e,b.current=e);const R=s.useRef(m);R.current!==m&&(R.current=m,j.current=b.current);const S=s.useRef(null);s.useEffect(()=>{const c=()=>f(wi());c();const D=new MutationObserver(c);return D.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>D.disconnect()},[]),s.useEffect(()=>{const c=setTimeout(()=>{S.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(c)},[]),s.useImperativeHandle(h,()=>({getXml:()=>b.current}));const E=s.useCallback(()=>{!e&&!v.current&&(v.current=!0,setTimeout(()=>{x.current?.template({})},500))},[e]),y=s.useCallback(c=>{b.current=c.xml,w?.(c.xml)},[w]);return n.jsx("div",{ref:S,className:K("h-full w-full",o),children:n.jsx(qo,{ref:x,xml:j.current||Nl,autosave:!0,urlParameters:{ui:r?"simple":m?"dark":"kennedy",spin:!0,libraries:!r,chrome:r,nav:r,layers:r,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:E,onAutoSave:y},m?"dark":"light")})}),Sl=i=>{const e=U(i);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const r=e.lastIndexOf("/");if(r<0)return e;if(r===0)return"/";const o=e.slice(0,r);return/^[A-Za-z]:$/.test(o)?`${o}/`:o},kl=i=>{const e=ut.c(8),{label:r,iconDataUrl:o}=i,[w,h]=s.useState(!1);let b;e[0]!==r?(b=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=b):b=e[1];const x=b;if(o&&!w){let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>h(!0),e[2]=f):f=e[2];let j;return e[3]!==o?(j=n.jsx("img",{src:o,alt:"",className:"size-4 rounded-sm",onError:f}),e[3]=o,e[4]=j):j=e[4],j}let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=K("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=v):v=e[5];let m;return e[6]!==x?(m=n.jsx("span",{className:v,children:x}),e[6]=x,e[7]=m):m=e[7],m},Rl=i=>i.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),U=i=>{if(!i)return"";const e=i.replace(/\\/g,"/"),r=e.startsWith("//");let o=e.replace(/\/+/g,"/");r&&!o.startsWith("//")&&(o=`/${o}`);const w=o==="/",h=/^[A-Za-z]:\/$/.test(o);return!w&&!h&&(o=o.replace(/\/+$/,"")),o},Tl=i=>i.startsWith("/")||i.startsWith("//")||/^[A-Za-z]:\//.test(i),er=i=>/^[A-Za-z]:\//.test(i)?i.toLowerCase():i,Yr=(i,e)=>{const r=U(e),o=U(i);if(!r||!o)return!1;const w=er(r),h=er(o);return h===w||h.startsWith(`${w}/`)},bi=(i,e)=>{const r=U(e),o=U(i);if(!Yr(o,r))return[];const h=o.slice(r.length).replace(/^\//,"").split("/"),b=[];let x=r;for(let v=0;v<h.length-1;v++)x=x?`${x}/${h[v]}`:h[v],b.push(x);return b},Jr=(i,e)=>{if(!e)return"";const r=U(e);if(!i||!Yr(r,i))return r;const o=r.slice(i.length);return o.startsWith("/")?o.slice(1):o},El=new Set(["node_modules"]),Vl=i=>{const e=ut.c(3),{status:r}=i;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={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]=o):o=e[0];const w=o[r];let h;return e[1]!==w?(h=n.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:w}}),e[1]=w,e[2]=h):h=e[2],h},yi=i=>{const e=ut.c(11),{name:r}=i,o=s.useRef(null),w=s.useRef(null),[h,b]=s.useState(!1);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{const N=o.current,R=w.current;if(!N||!R)return;const S=()=>{b(R.scrollWidth>N.clientWidth+1)};S();const E=new ResizeObserver(S);return E.observe(N),E.observe(R),()=>{E.disconnect()}},e[0]=x):x=e[0];let v;e[1]!==r?(v=[r],e[1]=r,e[2]=v):v=e[2],s.useLayoutEffect(x,v);let m;e[3]!==r?(m=n.jsx("span",{ref:w,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=m):m=e[4];let f;e[5]!==r||e[6]!==h?(f=h?n.jsxs("span",{className:"open-file-name-marquee-track",children:[n.jsx("span",{className:"open-file-name-marquee-item",children:r}),n.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):n.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=h,e[7]=f):f=e[7];let j;return e[8]!==m||e[9]!==f?(j=n.jsxs("span",{ref:o,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[m,f]}),e[8]=m,e[9]=f,e[10]=j):j=e[10],j},Pl=i=>El.has(i),Dl=i=>{const e=U(i);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Ml=i=>{const r=(i instanceof Error?i.message:String(i??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},ji=i=>{const r=(i instanceof Error?i.message:String(i??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},zl=2e5,Ai=(i,e)=>n.jsx(Gr,{filePath:i,extension:e}),Vn=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Fi=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},Hr=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Ll=i=>{const e=ut.c(76),{node:r,root:o,isExpanded:w,isActive:h,isMobile:b,isBrowserClient:x,alwaysShowActions:v,status:m,badge:f,permissions:j,downloadFile:N,contextMenuPath:R,setContextMenuPath:S,rightClickMenuPath:E,setRightClickMenuPath:y,onSelect:c,onToggle:D,onRevealPath:T,onOpenDialog:M}=i,{t:P}=tr(),V=r.type==="directory",{canRename:k,canCreateFile:L,canCreateFolder:B,canDelete:$,canReveal:ue}=j,de=!V&&!!N,Z=ue&&!x,Y=k||L||B||$||de||Z;let ae;e[0]!==Y||e[1]!==r.path||e[2]!==y?(ae=Te=>{Y&&(Te?.preventDefault(),y(r.path))},e[0]=Y,e[1]=r.path,e[2]=y,e[3]=ae):ae=e[3];const pe=ae;let oe;e[4]!==V||e[5]!==r||e[6]!==c||e[7]!==D?(oe=()=>{V?D(r.path):c(r)},e[4]=V,e[5]=r,e[6]=c,e[7]=D,e[8]=oe):oe=e[8];const H=oe;let G;e[9]!==r.path||e[10]!==S||e[11]!==y?(G=Te=>{Te.stopPropagation(),y(null),S(r.path)},e[9]=r.path,e[10]=S,e[11]=y,e[12]=G):G=e[12];const We=G;let te;e[13]!==L||e[14]!==B||e[15]!==$||e[16]!==k||e[17]!==Z||e[18]!==N||e[19]!==x||e[20]!==V||e[21]!==r||e[22]!==M||e[23]!==T||e[24]!==o||e[25]!==P?(te=Te=>{const{Item:Ie,Separator:Vt}=Te;return n.jsxs(n.Fragment,{children:[k&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("rename",r)},children:[n.jsx(F,{name:"edit",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.rename")]}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),Zr(r.path).then(Ye=>{if(Ye.ok){J.success(P("sidebarFilesTree.toast.pathCopied"));return}J.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.copyPath")]}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation();const Ye=Jr(o,r.path)||r.path;Zr(Ye).then(Pt=>{if(Pt.ok){J.success(P("filesView.toast.relativePathCopied"));return}J.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ",P("filesView.tree.menu.copyRelativePath")]}),!V&&N&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),N(r.path).catch(Ye=>{console.error("Download failed:",Ye),J.error(P("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"})," ",P(x?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),Z&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),T(r.path)},children:[n.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",P(Fo())]}),V&&(L||B)&&n.jsxs(n.Fragment,{children:[n.jsx(Vt,{}),L&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("createFile",r)},children:[n.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFile")]}),B&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("createFolder",r)},children:[n.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFolder")]})]}),$&&n.jsxs(n.Fragment,{children:[n.jsx(Vt,{}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),M("delete",r)},className:"text-destructive focus:text-destructive",children:[n.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.delete")]})]})]})},e[13]=L,e[14]=B,e[15]=$,e[16]=k,e[17]=Z,e[18]=N,e[19]=x,e[20]=V,e[21]=r,e[22]=M,e[23]=T,e[24]=o,e[25]=P,e[26]=te):te=e[26];const he=te,De=E===r.path;let be;e[27]!==r.path||e[28]!==y?(be=Te=>y(Te?r.path:null),e[27]=r.path,e[28]=y,e[29]=be):be=e[29];const q=b?void 0:pe;let X;e[30]!==q?(X=n.jsx("div",{className:"group relative flex items-center",onContextMenu:q}),e[30]=q,e[31]=X):X=e[31];const _=b?void 0:pe,re=h?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ge;e[32]!==re?(ge=K("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",re),e[32]=re,e[33]=ge):ge=e[33];let ne;e[34]!==V||e[35]!==w||e[36]!==r.extension||e[37]!==r.path?(ne=V?w?n.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):n.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Ai(r.path,r.extension),e[34]=V,e[35]=w,e[36]=r.extension,e[37]=r.path,e[38]=ne):ne=e[38];let Q;e[39]!==r.name||e[40]!==r.path?(Q=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:r.path,children:r.name}),e[39]=r.name,e[40]=r.path,e[41]=Q):Q=e[41];let ye;e[42]!==V||e[43]!==m?(ye=!V&&m&&n.jsx(Vl,{status:m}),e[42]=V,e[43]=m,e[44]=ye):ye=e[44];let ve;e[45]!==f||e[46]!==V?(ve=V&&f&&n.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[f.modified>0&&n.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",f.modified]}),f.added>0&&n.jsxs("span",{className:"text-[var(--status-success)]",children:["+",f.added]})]}),e[45]=f,e[46]=V,e[47]=ve):ve=e[47];let fe;e[48]!==H||e[49]!==ge||e[50]!==ne||e[51]!==Q||e[52]!==ye||e[53]!==ve||e[54]!==_?(fe=n.jsxs("button",{type:"button",onClick:H,onContextMenu:_,className:ge,children:[ne,Q,ye,ve]}),e[48]=H,e[49]=ge,e[50]=ne,e[51]=Q,e[52]=ye,e[53]=ve,e[54]=_,e[55]=fe):fe=e[55];let xe;e[56]!==v||e[57]!==R||e[58]!==We||e[59]!==Y||e[60]!==b||e[61]!==r.path||e[62]!==he||e[63]!==S?(xe=Y&&n.jsx("div",{className:K("absolute right-1 top-1/2 -translate-y-1/2",v?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:n.jsxs(Pn,{open:R===r.path,onOpenChange:Te=>S(Te?r.path:null),children:[n.jsx(Dn,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"icon",className:"size-6",onClick:We,children:n.jsx(F,{name:"more-2-fill",className:"size-4"})})}),n.jsx(Mn,{align:"end",side:"bottom",onCloseAutoFocus:()=>S(null),children:he({Item:Xr,Separator:jo})})]})}),e[56]=v,e[57]=R,e[58]=We,e[59]=Y,e[60]=b,e[61]=r.path,e[62]=he,e[63]=S,e[64]=xe):xe=e[64];let Re;e[65]!==fe||e[66]!==xe||e[67]!==X?(Re=n.jsxs(Ro,{render:X,children:[fe,xe]}),e[65]=fe,e[66]=xe,e[67]=X,e[68]=Re):Re=e[68];let Ue;e[69]!==he?(Ue=n.jsx(Co,{className:"min-w-[180px]",children:he({Item:ko,Separator:So})}),e[69]=he,e[70]=Ue):Ue=e[70];let Et;return e[71]!==Re||e[72]!==Ue||e[73]!==De||e[74]!==be?(Et=n.jsxs(To,{open:De,onOpenChange:be,children:[Re,Ue]}),e[71]=Re,e[72]=Ue,e[73]=De,e[74]=be,e[75]=Et):Et=e[75],Et},Al=i=>{const e=ut.c(83),{activeDialog:r,dialogData:o,dialogInputValue:w,onDialogInputChange:h,isDialogSubmitting:b,onDialogSubmit:x,onClose:v,inputRef:m}=i,{t:f}=tr(),j=!!r;let N;e[0]!==v?(N=G=>!G&&v(),e[0]=v,e[1]=N):N=e[1];let R;e[2]!==r||e[3]!==f?(R=r==="createFile"&&f("filesView.dialog.createFile.title"),e[2]=r,e[3]=f,e[4]=R):R=e[4];let S;e[5]!==r||e[6]!==f?(S=r==="createFolder"&&f("filesView.dialog.createFolder.title"),e[5]=r,e[6]=f,e[7]=S):S=e[7];let E;e[8]!==r||e[9]!==f?(E=r==="rename"&&f("filesView.dialog.rename.title"),e[8]=r,e[9]=f,e[10]=E):E=e[10];let y;e[11]!==r||e[12]!==f?(y=r==="delete"&&f("filesView.dialog.delete.title"),e[11]=r,e[12]=f,e[13]=y):y=e[13];let c;e[14]!==R||e[15]!==S||e[16]!==E||e[17]!==y?(c=n.jsxs(Ei,{children:[R,S,E,y]}),e[14]=R,e[15]=S,e[16]=E,e[17]=y,e[18]=c):c=e[18];let D;e[19]!==r||e[20]!==o?.path||e[21]!==f?(D=r==="createFile"&&f("filesView.dialog.createFile.description",{path:o?.path??f("filesView.dialog.rootFallback")}),e[19]=r,e[20]=o?.path,e[21]=f,e[22]=D):D=e[22];let T;e[23]!==r||e[24]!==o?.path||e[25]!==f?(T=r==="createFolder"&&f("filesView.dialog.createFolder.description",{path:o?.path??f("filesView.dialog.rootFallback")}),e[23]=r,e[24]=o?.path,e[25]=f,e[26]=T):T=e[26];let M;e[27]!==r||e[28]!==o?.name||e[29]!==f?(M=r==="rename"&&f("filesView.dialog.rename.description",{name:o?.name??""}),e[27]=r,e[28]=o?.name,e[29]=f,e[30]=M):M=e[30];let P;e[31]!==r||e[32]!==o?.name||e[33]!==f?(P=r==="delete"&&f("filesView.dialog.delete.description",{name:o?.name??""}),e[31]=r,e[32]=o?.name,e[33]=f,e[34]=P):P=e[34];let V;e[35]!==M||e[36]!==P||e[37]!==D||e[38]!==T?(V=n.jsxs(Vi,{children:[D,T,M,P]}),e[35]=M,e[36]=P,e[37]=D,e[38]=T,e[39]=V):V=e[39];let k;e[40]!==V||e[41]!==c?(k=n.jsxs(Ti,{children:[c,V]}),e[40]=V,e[41]=c,e[42]=k):k=e[42];let L;e[43]!==r||e[44]!==w||e[45]!==m||e[46]!==h||e[47]!==x||e[48]!==f?(L=r!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(gr,{value:w,onChange:G=>h(G.target.value),placeholder:f(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:G=>{G.key==="Enter"&&x()},ref:m})}),e[43]=r,e[44]=w,e[45]=m,e[46]=h,e[47]=x,e[48]=f,e[49]=L):L=e[49];let B;e[50]!==f?(B=f("filesView.dialog.cancel"),e[50]=f,e[51]=B):B=e[51];let $;e[52]!==b||e[53]!==v||e[54]!==B?($=n.jsx(I,{variant:"outline",onClick:v,disabled:b,children:B}),e[52]=b,e[53]=v,e[54]=B,e[55]=$):$=e[55];const ue=r==="delete"?"destructive":"default";let de;e[56]!==x?(de=()=>{x()},e[56]=x,e[57]=de):de=e[57];let Z;e[58]!==r||e[59]!==w||e[60]!==b?(Z=b||r!=="delete"&&!w.trim(),e[58]=r,e[59]=w,e[60]=b,e[61]=Z):Z=e[61];let Y;e[62]!==r||e[63]!==b||e[64]!==f?(Y=b?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):f(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=b,e[64]=f,e[65]=Y):Y=e[65];let ae;e[66]!==ue||e[67]!==de||e[68]!==Z||e[69]!==Y?(ae=n.jsx(I,{variant:ue,onClick:de,disabled:Z,children:Y}),e[66]=ue,e[67]=de,e[68]=Z,e[69]=Y,e[70]=ae):ae=e[70];let pe;e[71]!==$||e[72]!==ae?(pe=n.jsxs(Pi,{children:[$,ae]}),e[71]=$,e[72]=ae,e[73]=pe):pe=e[73];let oe;e[74]!==m||e[75]!==k||e[76]!==L||e[77]!==pe?(oe=n.jsxs(Ri,{initialFocus:m,children:[k,L,pe]}),e[74]=m,e[75]=k,e[76]=L,e[77]=pe,e[78]=oe):oe=e[78];let H;return e[79]!==j||e[80]!==N||e[81]!==oe?(H=n.jsx(ki,{open:j,onOpenChange:N,children:oe}),e[79]=j,e[80]=N,e[81]=oe,e[82]=H):H=e[82],H},Qt=new Map,Il=100,Ni=i=>{const e=ut.c(13);let r,o,w;e[0]!==i?({positionKey:o,onViewReady:r,...w}=i,e[0]=i,e[1]=r,e[2]=o,e[3]=w):(r=e[1],o=e[2],w=e[3]);const h=s.useRef(null);let b,x;e[4]!==o?(b=()=>()=>{const f=h.current;if(!f)return;const{anchor:j,head:N}=f.state.selection.main;if(Qt.delete(o),Qt.set(o,{scroll:f.scrollSnapshot(),anchor:j,head:N}),Qt.size>Il){const R=Qt.keys().next().value;R!==void 0&&Qt.delete(R)}},x=[o],e[4]=o,e[5]=b,e[6]=x):(b=e[5],x=e[6]),s.useLayoutEffect(b,x);let v;e[7]!==r||e[8]!==o?(v=f=>{h.current=f;const j=Qt.get(o);j&&f.dispatch({selection:{anchor:Math.min(j.anchor,f.state.doc.length),head:Math.min(j.head,f.state.doc.length)},effects:j.scroll}),r?.(f)},e[7]=r,e[8]=o,e[9]=v):v=e[9];let m;return e[10]!==w||e[11]!==v?(m=n.jsx(Vo,{...w,onViewReady:v}),e[10]=w,e[11]=v,e[12]=m):m=e[12],m},Ci=(i,e,r)=>{const o=ut.c(8),[w,h]=s.useState(""),[b,x]=s.useState(0);let v,m;o[0]!==i||o[1]!==r||o[2]!==e?(v=()=>{if(!i){h("");return}let j=!1;h("");const N=Ja(),R=Za(N);Ya(N).then(E=>{j||!E||(h(i),e(null))}).catch(E=>{j||(e(E instanceof Error?E.message:r),h(i))});const S=Qa(()=>{j||(h(i),x(Ol),e(null))});return()=>{j=!0,R(),S()}},m=[i,e,r],o[0]=i,o[1]=r,o[2]=e,o[3]=v,o[4]=m):(v=o[3],m=o[4]),s.useEffect(v,m);let f;return o[5]!==b||o[6]!==w?(f={readyKey:w,nonce:b},o[5]=b,o[6]=w,o[7]=f):f=o[7],f},ad=({mode:i="full",visible:e=!0})=>{const{t:r}=tr(),{files:o,runtime:w}=no(),{currentTheme:h,availableThemes:b,lightThemeId:x,darkThemeId:v}=so(),{isMobile:m,isTablet:f,screenWidth:j}=io(),N=Ua(w.platform),R=m||f,S=qa(),E=Ka(),y=Si()??"",c=U(y.trim()),D=m||i==="full",T=D&&e,M=ao(t=>t.runtimeKey),P=JSON.stringify([M,c]),V=s.useRef(P);V.current=P;const k=JSON.stringify([M,c,S,E]),L=s.useRef(k);L.current=k;const B=i!=="editor-only",$=i==="editor-only"&&!m,ue=Ha(t=>t.searchFiles),de=oo(T?y:null),[Z,Y]=s.useState(""),ae=lo(Z,200),pe=s.useRef(null),[oe,H]=s.useState(!1),[G,We]=s.useState(!0),[te,he]=s.useState(!1),[De,be]=s.useState(!1),q=s.useRef(0),X=s.useCallback(t=>{q.current=Math.max(0,q.current+(t?1:-1))},[]),[_,re]=s.useState("edit"),[ge,ne]=s.useState("edit"),[Q,ye]=s.useState("tree"),[ve,fe]=s.useState("edit"),[xe,Re]=s.useState("preview"),[Ue,Et]=s.useState(0),Te=s.useRef({}),Ie=s.useRef({}),Vt=s.useRef({}),le=s.useRef({}),Ye=s.useMemo(()=>b.find(t=>t.metadata.id===x)??ii(!1),[b,x]),Pt=s.useMemo(()=>b.find(t=>t.metadata.id===v)??ii(!0),[b,v]);s.useEffect(()=>{mi(Ye),mi(Pt)},[Ye,Pt]);const vr=s.useMemo(()=>[],[]),je=Ze(t=>c?t.byRoot[c]?.openPaths??vr:vr),bt=Ze(t=>c?t.byRoot[c]?.selectedPath??null:null),Qe=Ze(t=>c?t.byRoot[c]?.expandedPaths??vr:vr),Ii=s.useMemo(()=>new Set(Qe),[Qe]),Dt=Ze(t=>t.removeOpenPath),dt=Ze(t=>t.removeOpenPathsByPrefix),zn=Ze(t=>t.removeExpandedPathsByPrefix),Fe=Ze(t=>t.setSelectedPath),Ln=Ze(t=>t.toggleExpandedPath),xr=Ze(t=>t.expandPaths),Mt=s.useCallback(t=>{const a=U(t),l=a.split("/"),d=l[l.length-1]||a,p=d.includes(".")?d.split(".").pop()?.toLowerCase():void 0;return{name:d,path:a,type:"file",extension:p}},[]),zt=s.useMemo(()=>je.map(Mt),[je,Mt]),en=s.useMemo(()=>{if(bt){const t=er(bt);if(je.some(a=>er(a)===t))return bt}return je[0]??null},[je,bt]),u=s.useMemo(()=>en?Mt(en):null,[en,Mt]),qe=u?.path??"",[,Oi]=s.useState(0);s.useEffect(()=>{if(!c||!bt)return;const t=er(bt);je.some(l=>er(l)===t)||Fe(c,je[0]??null)},[je,c,bt,Fe]);const wr=!!(c&&qe&&!Yr(qe,c)),An=wr?ai(qe):void 0,yt=s.useMemo(()=>({allowOutsideWorkspace:i==="editor-only"&&wr,outsideFileGrant:An,directory:c||void 0}),[i,wr,An,c]),et=s.useCallback(async t=>{const a=ai(t),l=await co(t,c,i==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==a&&Oi(d=>d+1),l},[i,c]),tn=s.useRef(null),[In,Bi]=s.useState({left:!1,right:!1}),On=s.useCallback(()=>{const t=tn.current;t&&Bi({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),Bn=s.useRef(On);Bn.current=On,s.useEffect(()=>{const t=tn.current;if(!t)return;const a=()=>Bn.current();a(),t.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(a);return l.observe(t),()=>{t.removeEventListener("scroll",a),l.disconnect()}},[zt.length]);const[$n,rn]=s.useState({}),[br,rr]=s.useState({}),Oe=s.useRef(new Set),Ee=s.useMemo(()=>new Bo,[]);s.useEffect(()=>()=>Ee.clear(),[Ee]);const[_n,yr]=s.useState([]),[$i,jr]=s.useState(!1),[O,me]=s.useState(""),{isPlaying:Fr,play:_i,stop:Wi}=uo(),[Me,ft]=s.useState(!1),[tt,we]=s.useState(null),[Ui,Be]=s.useState(""),[Ne,ce]=s.useState(null),mt=JSON.stringify([lt(),c,Ne]),[ee,Ce]=s.useState(""),[nr,nn]=s.useState(!1),[Wn,qi]=s.useState(`
|
|
11
|
-
`),Ki=s.useRef(null),rt=s.useRef(null),ze=s.useRef(null),pt=s.useRef(""),sr=s.useRef(""),st=s.useRef(null),Un=s.useRef(null),Ke=s.useRef(null),sn=s.useRef(""),an=s.useRef(0),Lt=s.useRef(0),jt=s.useRef(null),[Nr,Hi]=s.useState(0),[Gi,At]=s.useState("idle"),[Xi,Cr]=s.useState(!1),[Ft,qn]=s.useState(!1),Se=wt(t=>t.autoSaveEnabled),Ji=wt(t=>t.setAutoSaveEnabled),[on,ir]=s.useState(!1),It=s.useRef(null),ar=s.useRef(null),or=s.useRef(!1),lr=s.useRef(null),cr=s.useRef(null),He=s.useRef(null),Sr=s.useRef(null),[Zi,ln]=s.useState(0),Ot=s.useRef(null),Nt=s.useRef({key:"",attempts:0});s.useEffect(()=>()=>{Ot.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Ot.current),Ot.current=null)},[]);const[Ct,cn]=s.useState(null),[St,Yi]=s.useState(null),[ht,Kn]=s.useState(""),[Qi,un]=s.useState(!1),[ea,ta]=s.useState(null),[ra,na]=s.useState(null),[sa,Hn]=s.useState(!1),[ia,Gn]=s.useState(!1),[aa,dn]=s.useState(!1),[Xn,kr]=s.useState(!1),[Jn,Zn]=s.useState(0),Rr=s.useRef(null),Tr=s.useCallback(t=>{const a=t?.currentTarget??Rr.current;if(!a)return;const l=document.activeElement;l&&l!==document.body&&l!==a&&(fo(l)||a.contains(l))||a.focus({preventScroll:!0})},[]),Er=s.useRef(null),Yn=!!o.writeFile,Qn=!!o.createDirectory,es=!!o.rename,ts=!!o.delete,rs=!!o.revealPath,oa=qr(t=>t.availableApps),la=qr(t=>t.isCacheStale),ns=qr(t=>t.initialize),ca=qr(t=>t.loadInstalledApps);s.useEffect(()=>{ns()},[ns]);const ua=s.useCallback(t=>{o.revealPath&&o.revealPath(t).catch(()=>{J.error(r("sidebarFilesTree.toast.revealFailed"))})},[o,r]),da=s.useCallback(async t=>{if(!u?.path||await Ga(u.path,t.id,t.appName)||await ti(u.path,t.appName))return;const d=Sl(u.path)||c;d&&await ti(d,t.appName)||J.error(r("filesView.toast.openInAppFailed",{app:t.appName}))},[c,u?.path,r]),fn=s.useCallback((t,a)=>{cn(t),Yi(a),Kn(t==="rename"&&a.name||""),un(!1)},[]),[W,Ge]=s.useState(null),Bt=s.useRef(!1),gt=s.useRef(null),[ss,$t]=s.useState(!1),nt=wt(t=>t.pendingFileNavigation),Vr=wt(t=>t.setPendingFileNavigation),mn=wt(t=>t.pendingFileFocusPath),pn=wt(t=>t.setPendingFileFocusPath),is=wt(t=>t.fileEditorKeymap),ur=oi(t=>t.settingsDefaultFileViewerPreview),fa=oi(t=>t.showMessageTTSButtons);s.useEffect(()=>{const t=()=>{Bt.current=!1,gt.current=null,$t(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),s.useEffect(()=>()=>{lr.current!==null&&window.clearTimeout(lr.current),cr.current!==null&&window.clearTimeout(cr.current)},[]);const ma=s.useCallback((t,a)=>{const l=t.split(`
|
|
12
|
-
`),d=Math.max(1,a.start),p=Math.min(l.length,a.end);return d>p?"":l.slice(d-1,p).join(`
|
|
13
|
-
`)},[]),as=s.useRef(null),pa=Ho({source:"file",fileLabel:u?.path??null,language:u?.path&&Cn(u.path)||"text",getCodeForRange:t=>ma(O,Go(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:os,commentText:Pr,setCommentText:ls,editingDraftId:Dr,setSelection:cs,saveComment:us,cancel:dr,reset:ds,startEdit:fs,deleteDraft:ms}=pa;s.useEffect(()=>{Ge(null),ds(),Ce(""),nn(!1)},[u?.path,ds]),s.useEffect(()=>{cs(W)},[W,cs]),s.useEffect(()=>{if(!W&&!Dr)return;const t=l=>{const d=l.target;d.closest('[data-comment-input="true"]')||d.closest('[data-comment-card="true"]')||d.closest(".cm-gutterElement")||d.closest("[data-sonner-toast]")||d.closest("[data-sonner-toaster]")||Pr.trim()||(Ge(null),dr())},a=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(a),document.removeEventListener("click",t)}},[dr,Pr,Dr,W]);const ps=s.useCallback((t,a)=>{const l=a??W??void 0;a&&Ge(a),us(t,l),Ge(null)},[W,us]),hs=s.useCallback((t,a)=>{const l=[];for(const d of a){if(!(d&&typeof d.name=="string"&&d.name.length>0)||!S&&d.name.startsWith(".")||!E&&Pl(d.name))continue;const p=d.name,g=U(d.path||""),C=g?Tl(g)?g:U(`${t}/${g}`):U(`${t}/${p}`),A=d.isDirectory?"directory":"file",se=A==="file"&&p.includes(".")?p.split(".").pop()?.toLowerCase():void 0;l.push({name:p,path:C,type:A,extension:se})}return Rl(l)},[E,S]),Ve=s.useCallback(async(t,a=!1)=>{if(!T)return;const l=U(t.trim());if(!l||!a&&Oe.current.has(l))return;const d=L.current,p=lt();return Ee.run(l,async g=>{const C=()=>g()&&L.current===d&<()===p;try{const A=o.listDirectory?(await o.listDirectory(l)).entries:await Xa.listLocalDirectory(l);if(!C())return;const se=hs(l,A);Oe.current=new Set(Oe.current),Oe.current.add(l),rr(z=>{if(!z[l])return z;const ie={...z};return delete ie[l],ie}),rn(z=>z[l]&&$o(z[l],se)?z:{...z,[l]:se})}catch(A){if(!C())return;const se=A instanceof Error?A.message:String(A??"");if(se==="Directory not found"&&c&&l!==c){zn(c,l),rr(z=>{if(!z[l])return z;const ie={...z};return delete ie[l],ie});return}console.error("Failed to load files directory:",A),rr(z=>({...z,[l]:se}))}},a)},[Ee,o,hs,zn,c,T]),Mr=s.useCallback(async()=>{c&&(Oe.current=new Set,Ee.clear(),rr({}),rn(t=>Object.keys(t).length===0?t:{}),await Ve(c))},[Ee,Ve,c]),$e=s.useCallback(async t=>{if(!t){await Mr();return}const a=U(t);Oe.current=new Set(Oe.current),Oe.current.delete(a),await Ve(a,!0)},[Ve,Mr]),gs=s.useRef(""),vs=s.useRef("");s.useEffect(()=>{if(!c)return;const t=k,a=gs.current!==P,l=vs.current!==t;!a&&!l||(a&&(gs.current=P,Lt.current+=1,jt.current=null,me(""),we(null),Be(""),ce(null),H(!1)),l&&(vs.current=t,Oe.current=new Set,Ee.clear(),rr({}),rn(d=>Object.keys(d).length===0?d:{}),Ve(c)))},[Ee,P,Ve,c,k]),s.useEffect(()=>{if(!T||!o.listDirectory)return;const t=()=>{if(!document.hidden&&Qe.length>0)for(const a of Qe)Ee.has(a)||$e(a)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[Ee,Qe,o.listDirectory,$e,T]);const xs=s.useRef(!1);s.useEffect(()=>{const t=T&&!xs.current;if(xs.current=T,!(!T||!c)&&(Ve(c),t))for(const a of Qe)Ee.has(a)||$e(a)},[Ee,Qe,Ve,$e,c,T]),s.useEffect(()=>{if(!T||!o.listDirectory||Qe.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const a of Qe)Ee.has(a)||$e(a)},8e3);return()=>clearInterval(t)},[Ee,Qe,o.listDirectory,$e,T]);const ha=s.useCallback(async t=>{if(t?.preventDefault(),!St||!Ct)return;un(!0);const a=()=>{cn(null)},l=p=>{J.error(p)},d=()=>{un(!1)};if(Ct==="createFile"){if(!ht.trim()){l(r("sidebarFilesTree.toast.filenameRequired")),d();return}if(!o.writeFile){l(r("sidebarFilesTree.toast.writeNotSupported")),d();return}const p=St.path,g=p?`${p}/`:"",C=U(`${g}${ht.trim()}`);await o.writeFile(C,"").then(async A=>{A.success&&(J.success(r("sidebarFilesTree.toast.fileCreated")),await $e(p)),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="createFolder"){if(!ht.trim()){l(r("sidebarFilesTree.toast.folderNameRequired")),d();return}const p=St.path,g=p?`${p}/`:"",C=U(`${g}${ht.trim()}`);await o.createDirectory(C).then(async A=>{A.success&&(J.success(r("sidebarFilesTree.toast.folderCreated")),await $e(p)),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="rename"){if(!ht.trim()){l(r("sidebarFilesTree.toast.nameRequired")),d();return}if(!o.rename){l(r("sidebarFilesTree.toast.renameNotSupported")),d();return}const p=St.path,g=p.split("/").slice(0,-1).join("/"),C=g?`${g}/`:"",A=U(`${C}${ht.trim()}`);await o.rename(p,A).then(async se=>{se.success&&(J.success(r("sidebarFilesTree.toast.renamedSuccessfully")),await $e(g),c&&dt(c,p),(u?.path===p||u?.path.startsWith(`${p}/`))&&(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1))),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="delete"){if(!o.delete){l(r("sidebarFilesTree.toast.deleteNotSupported")),d();return}const p=St.path,g=p.split("/").slice(0,-1).join("/");await o.delete(p).then(async C=>{C.success&&(J.success(r("sidebarFilesTree.toast.deletedSuccessfully")),await $e(g),c&&dt(c,p),(u?.path===p||u?.path.startsWith(`${p}/`))&&(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1))),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}d()},[Ct,St,ht,o,$e,m,dt,c,u?.path,Fe,r]);s.useEffect(()=>{if(!y){yr([]),jr(!1);return}const t=ae.trim();if(!t){yr([]),jr(!1);return}let a=!1;return jr(!0),ue(y,t,150,{includeHidden:S,respectGitignore:!E,type:"file"}).then(l=>{if(a)return;const p=l.filter(g=>E||!Dl(g.path)).map(g=>({name:g.name,path:U(g.path),type:"file",extension:g.extension,relativePath:g.relativePath}));yr(p)}).catch(()=>{a||yr([])}).finally(()=>{a||jr(!1)}),()=>{a=!0}},[y,ae,ue,S,E]);const zr=s.useCallback(async(t,a)=>{const l=await et(t);if(o.readFile)return(await o.readFile(t,{...l,directory:c||void 0,...a})).content??"";const d=new URLSearchParams({path:t});l.allowOutsideWorkspace&&d.set("allowOutsideWorkspace","true"),l.outsideFileGrant&&d.set("outsideFileGrant",l.outsideFileGrant),c&&d.set("directory",c);const p=await ri(`/api/fs/read?${d.toString()}`,a?.fresh?{cache:"no-store"}:void 0);if(!p.ok){const g=await p.json().catch(()=>({error:p.statusText}));throw new Error(g.error||r("filesView.error.readFileFailed"))}return p.text()},[o,et,c,r]),vt=s.useCallback(async t=>{if(o.statFile){const a=await et(t),l=await o.statFile(t,{...a,directory:c||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[o,et,c]);s.useEffect(()=>{if(!c||!o.statFile||je.length===0)return;let t=!1;const a=[...je];return Promise.all(a.map(async l=>{try{const d=await et(l),p=await o.statFile?.(l,{...d,directory:c||void 0});!t&&p&&!p.isFile&&dt(c,l)}catch(d){!t&&ji(d)&&dt(c,l)}})),()=>{t=!0}},[o,je,dt,et,c]);const Le=ee!==O,_t=s.useCallback(async()=>{if(!u||!o.writeFile)return J.error(r("filesView.toast.savingNotSupported")),!1;const t=pr(u.path)||Ft;if(!xl({selectedFilePath:u.path,loadedFilePath:Ne,fileLoading:Me,isDirty:Le,draftContent:ee,fileContent:O,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${u.path}".`):ee===""&&O!==""&&Ne!==u.path&&console.warn(`[saveDraft] refusing to save empty draft for "${u.path}" (${O.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!Le)return!0;nn(!0);try{const a=yl(ee,Wn);if(!(await o.writeFile(u.path,a))?.success)return J.error(r("filesView.toast.writeFileFailed")),!1;if(me(ee),sn.current=a,an.current+=1,c&&Yr(u.path,c)){const d=Jr(c,u.path);d&&mo.requestGitRefresh({directory:c,paths:[d]})}if(c&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(U(u.path))){const d=po.getState().projects.find(p=>U(p.path)===U(c));if(d)try{await _o(d.id)}catch{J.error(r("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return u?.path&&hr(u.path)&&(pt.current=ee,sr.current=ee),vt(u.path).then(d=>{d&&(Ke.current=d)}).catch(()=>{}),!0}catch(a){return J.error(a instanceof Error?a.message:r("filesView.toast.saveFailed")),!1}finally{nn(!1)}},[Ft,ee,O,Me,o,Le,Wn,Ne,vt,c,u,r]);s.useEffect(()=>{Se||(At("idle"),rt.current&&(clearTimeout(rt.current),rt.current=null))},[Se]);const ws=1500;s.useEffect(()=>{const t=!!(u&&o.writeFile),a=!!(u?.path&&(pr(u.path)||Ft));if(vl({autoSaveEnabled:Se,isDirty:Le,canWrite:t,isSaving:nr,fileLoading:Me,selectedFilePath:u?.path,loadedFilePath:Ne,isNonEditableBinary:a}))return rt.current=setTimeout(()=>{_t().then(l=>{l&&(At("saved"),setTimeout(()=>At("idle"),2e3))})},ws),()=>{rt.current&&(clearTimeout(rt.current),rt.current=null)}},[Se,Ft,ee,Me,Le,Ne,u,o.writeFile,nr,_t]),s.useEffect(()=>{At("idle")},[u?.path]),ho({save_file:t=>{if(!(t.target instanceof Node)||!Sr.current?.contains(t.target))return!1;rt.current&&(clearTimeout(rt.current),rt.current=null),nr||_t().then(a=>{a&&(At("saved"),setTimeout(()=>At("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node))return!1;if(Je&&Ae()==="preview"){if(m||!(te?Er.current:Rr.current)?.contains(t.target))return!1;kr(!0),Zn(l=>l+1);return}if(!Sr.current?.contains(t.target))return!1;be(!0)}});const Wt=s.useCallback(t=>{const{content:a,lineEnding:l}=bl(t);return sn.current=t,an.current+=1,qi(l),me(a),pt.current=a,sr.current=a,Ce(a),a},[]),bs=s.useCallback(async t=>{const a=Lt.current+1;Lt.current=a;const l=lt(),d=V.current,p=()=>{if(!c||lt()!==l||V.current!==d)return!1;const z=Ze.getState().byRoot[c],ie=z?.selectedPath??z?.openPaths[0]??null;return Lt.current===a&&ie===t.path};if(we(null),Be(""),ce(null),qn(!1),ft(!0),await et(t.path),!p())return;const g=Sn(t.path),C=li(t.path),A=ci(t.path),se=pr(t.path);if(m&&H(!0),w.isDesktop&&g&&!C){me(""),Ce("");return}if(!w.isDesktop&&g&&!C){me(""),Ce(""),ce(t.path),ft(!1);return}if(A){me(""),Ce(""),ce(t.path),ft(!1);return}if(se){me(""),Ce(""),ce(t.path),ft(!1);return}await zr(t.path).then(z=>{if(!p())return;if(ui(z)){qn(!0),me(""),Ce(""),ce(t.path);return}const ie=Wt(z),kt=Vn(t.path)||Hr(t.path)||Fi(t.path)||hr(t.path);re(kt?"edit":jl(ie,Te.current[t.path])),ce(t.path),vt(t.path).then(Gt=>{Gt&&p()&&(Ke.current=Gt)}).catch(()=>{})}).catch(z=>{if(p()){if(Ml(z)){if(ft(!1),c&&Fe(c,null),we(null),me(""),Ce(""),ce(null),Ke.current=null,Z.trim().length>0&&Y(""),m&&H(!1),c){const kt=[...bi(t.path,c),t.path];kt.length>0&&xr(c,kt);for(const Gt of kt)Oe.current.has(Gt)||Ve(Gt)}return}if(ji(z)){c&&dt(c,t.path),me(""),Ce(""),we(null),Ke.current=null,m&&H(!1);return}me(""),Ce(""),we(z instanceof Error?z.message:r("filesView.error.readFileFailed")),Ke.current=null}}).finally(()=>{p()&&ft(!1)})},[Wt,xr,m,Ve,zr,vt,dt,et,c,w.isDesktop,Z,Fe,r]),Lr=s.useCallback(async(t,a)=>{if(!e||!c)return;const l=bi(t,c),d=a?[...l,t]:l;if(d.length>0&&xr(c,d),!T)return;const p=d.map(g=>{if(!Oe.current.has(g))return Ve(g)}).filter(Boolean);await Promise.all(p)},[xr,Ve,c,T,e]),ys=s.useCallback((t,a)=>{const l=a.findIndex(d=>d.path===t);return l===-1||a.length<=1?null:a[l+1]??a[l-1]??null},[]),Pe=s.useCallback(async t=>{if(or.current)or.current=!1;else if(Le){ir(!0),It.current=t;return}c&&(Fe(c,t.path),Lr(t.path,!1)),we(null),Be(""),me(""),pt.current="",sr.current="",Ce(""),ce(null),m&&H(!0)},[Lr,Le,m,c,Fe]);s.useEffect(()=>{u?.path&&Lr(u.path,!1)},[Lr,u?.path]),s.useEffect(()=>{if(!e)return;if(!u){Lt.current+=1,jt.current=null,ft(!1);return}if(Ne===u.path||jt.current===u.path)return;const t=u.path;jt.current=t,bs(u).finally(()=>{jt.current===t&&(jt.current=null)})},[Nr,bs,Ne,u,e]);const Ar=s.useRef(Le);Ar.current=Le,s.useEffect(()=>Wo(({runtimeKey:t,paths:a})=>{const l=u?.path;t!==lt()||!l||Ar.current||!a.includes(U(l))||(Lt.current+=1,jt.current=null,Ke.current=null,Be(""),we(null),ce(null),Hi(d=>d+1))}),[u?.path]),s.useEffect(()=>{if(!e||!u?.path||Ne!==u.path)return;const t=u.path,a=lt(),l=V.current,d=()=>Ar.current||hr(t)&&pt.current!==sr.current,p=!pr(t)&&!Sn(t)&&!Ft?fl({readContent:()=>zr(t,{fresh:!0}),getLoadedContent:()=>sn.current,getLoadedRevision:()=>an.current,isDirty:d,applyContent:z=>{if(!(g||lt()!==a||V.current!==l)){if(ui(z)){ce(null);return}Wt(z)}}}):null;let g=!1,C=!1;const A=()=>{document.hidden||C||(C=!0,vt(t).then(async z=>{if(g||lt()!==a||V.current!==l||!z)return;const ie=Ke.current;if(!ie||ie.path!==t){Ke.current=z;return}if(pl(ie,z)){if(p&&z.size<=zl){await p.poll()&&!g&&(Ke.current=z);return}Ar.current||(Ke.current=z,ce(null))}}).catch(()=>{}).finally(()=>{C=!1}))};A();const se=window.setInterval(A,2e3);return()=>{g=!0,p?.dispose(),window.clearInterval(se)}},[Wt,Ft,Ne,zr,vt,u?.path,e]);const ga=s.useCallback(()=>{const t=It.current,a=ar.current;if(It.current=null,ar.current=null,or.current=!0,ir(!1),Ce(O),a){c&&Dt(c,a),u?.path===a&&(t?Pe(t):(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)));return}if(t){Pe(t);return}},[O,Pe,m,Dt,c,u?.path,Fe]),va=s.useCallback(async()=>{const t=It.current,a=ar.current;if(!await _t()){or.current=!1;return}if(It.current=null,ar.current=null,or.current=!0,ir(!1),a){c&&Dt(c,a),u?.path===a&&(t?await Pe(t):(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)));return}if(t){await Pe(t);return}},[Pe,m,Dt,c,_t,u?.path,Fe]),js=s.useCallback(t=>{const a=u?.path===t,l=ys(t,zt);if(a&&Le){ir(!0),It.current=l,ar.current=t;return}if(c&&Dt(c,t),!!a){if(l){Pe(l);return}c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)}},[ys,Pe,Le,m,zt,Dt,c,u?.path,Fe]),Fs=s.useMemo(()=>new Set(je),[je]),Ir=s.useMemo(()=>Uo(D?de?.files??[]:[]),[de?.files,D]),xa=s.useCallback(t=>{if(Fs.has(t))return"open";const a=t.startsWith(c+"/")?t.slice(c.length+1):t;return Ir.statusByPath.get(a)??null},[Fs,Ir,c]),wa=s.useCallback(t=>{if(!de?.files)return null;const a=t.startsWith(c+"/")?t.slice(c.length+1):t;return Ir.badgeByDir.get(a)??null},[de,Ir,c]),ba=s.useCallback(async t=>{const a=U(t);c&&(Ln(c,a),Oe.current.has(a)||await Ve(a))},[Ve,c,Ln]),ya=s.useMemo(()=>({canRename:es,canCreateFile:Yn,canCreateFolder:Qn,canDelete:ts,canReveal:rs}),[es,Yn,Qn,ts,rs]);function Ns(t,a){const l=$n[t]??[];return l.map((d,p)=>{const g=d.type==="directory",C=g&&Ii.has(d.path),A=u?.path===d.path,se=p===l.length-1;return n.jsxs("li",{className:"relative",children:[a>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),se&&n.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),n.jsx(Ll,{node:d,root:c,isExpanded:C,isActive:A,isMobile:m,isBrowserClient:N,alwaysShowActions:R,status:g?void 0:xa(d.path),badge:g?wa(d.path):void 0,permissions:ya,downloadFile:o.downloadFile,contextMenuPath:ea,setContextMenuPath:ta,rightClickMenuPath:ra,setRightClickMenuPath:na,onSelect:Pe,onToggle:ba,onRevealPath:ua,onOpenDialog:fn}),g&&C&&n.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[br[d.path]?n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:br[d.path],children:br[d.path]}),n.jsxs(I,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{$e(d.path)},children:[n.jsx(F,{name:"refresh",className:"size-3.5"}),r("filesView.tree.actions.refreshTitle")]})]}):null,Ns(d.path,a+1)]})]},d.path)})}const ke=!!(u?.path&&Sn(u.path)),Or=!!(u?.path&&li(u.path)),_e=!!(u?.path&&ci(u.path)),hn=!!(u?.path&&(pr(u.path)||Ft)),it=hn&&!ke&&!_e,Cs=s.useMemo(()=>U(nt?.path??""),[nt?.path]),Ut=!!(nt&&Cs&&qe&&qe===Cs&&!Me&&!tt&&!ke&&!_e&&!it),xt=s.useMemo(()=>Jr(c,qe),[qe,c]),ja=!!(u&&(!ke||Or)&&!_e&&!it&&O.length>0),Fa=!!(u&&xt.length>0),Xe=!!(u&&!wr&&!hn&&!ke&&o.writeFile),Je=!!(u?.path&&Vn(u.path)),qt=!!(u?.path&&Fi(u.path)),Kt=!!(u?.path&&Hr(u.path)),fr=!!(u?.path&&hr(u.path)),Br=!!(u&&!hn&&!ke)&&!Je&&!fr&&!(Kt&&ve==="preview"),Na=Je&&ge==="edit"||Kt&&ve==="edit"||qt&&Q==="text"||!Je&&!Kt&&!qt&&_==="edit",$r=s.useMemo(()=>qe?go(qe):null,[qe]),[Ss,gn]=s.useState(null);s.useEffect(()=>{let t=!1;const a=u?.path;if(!a||$r){gn(null);return}return gn(null),vo(a).then(l=>{t||gn(l)}),()=>{t=!0}},[u?.path,$r]),s.useEffect(()=>{!Xe&&_==="edit"&&re("view")},[Xe,_]);const vn="openchamber:files:md-viewer-mode",xn="openchamber:files:html-viewer-mode",wn="openchamber:files:json-viewer-mode";s.useEffect(()=>{const t=u?.path;if(!t)return;re(Te.current[t]??"edit");let a=ur?"preview":"edit";try{const p=localStorage.getItem(vn);(p==="preview"||p==="edit")&&(a=p)}catch{}ne(Ie.current[t]??a);let l=ur?"preview":"edit";try{const p=localStorage.getItem(xn);(p==="preview"||p==="edit")&&(l=p)}catch{}fe(Vt.current[t]??l),Re(le.current[t]??(ur?"preview":"edit"));let d=ur?"tree":"text";try{const p=localStorage.getItem(wn);(p==="tree"||p==="text")&&(d=p)}catch{}ye(d)},[u?.path,ur]);const Ca=s.useCallback(t=>{const a=u?.path;a&&(Te.current[a]=t),re(t)},[u?.path]),Sa=s.useCallback(t=>{const a=u?.path;a&&(Ie.current[a]=t),ne(t);try{localStorage.setItem(vn,t)}catch{}},[u?.path]),Ae=s.useCallback(()=>ge,[ge]),ks=u&&Je&&Ae()==="preview"&&!Me?u.path:null;s.useEffect(()=>{!ks||m||Tr()},[Tr,te,m,ks]);const ka=s.useCallback(t=>{ye(t);try{localStorage.setItem(wn,t)}catch{}},[]),Ra=s.useCallback(t=>{const a=u?.path;a&&(Vt.current[a]=t),fe(t);try{localStorage.setItem(xn,t)}catch{}},[u?.path]),Ta=s.useCallback(t=>{const a=u?.path;if(a&&(le.current[a]=t),ze.current&&(clearTimeout(ze.current),ze.current=null),st.current!==null&&(cancelAnimationFrame(st.current),st.current=null),t==="edit")Ce(pt.current||O),Re(t);else{pt.current=ee;const l=a;Re("edit"),st.current=requestAnimationFrame(()=>{st.current=requestAnimationFrame(()=>{st.current=null,!(c&&l&&Ze.getState().byRoot[c]?.selectedPath!==l)&&(Et(d=>d+1),Re("preview"))})});return}},[ee,O,c,u?.path]),bn=s.useCallback(async(t,a)=>{if(!o.writeFile||a===sr.current)return!1;if(!(await o.writeFile(t,a))?.success)return J.error(r("filesView.toast.writeFileFailed")),!1;Wt(a);const d=await vt(t).catch(()=>null);return d&&(Ke.current=d),!0},[Wt,o,vt,r]);s.useEffect(()=>()=>{ze.current&&(clearTimeout(ze.current),ze.current=null),st.current!==null&&(cancelAnimationFrame(st.current),st.current=null)},[xe,u?.path]);const Ea=s.useCallback(t=>{if(pt.current=t,!Se||!u?.path||xe!=="preview"||!o.writeFile)return;ze.current&&clearTimeout(ze.current);const a=u.path;ze.current=setTimeout(()=>{ze.current=null,bn(a,t).then(l=>{l&&(Cr(!0),setTimeout(()=>Cr(!1),1500))}).catch(l=>{J.error(l instanceof Error?l.message:r("filesView.toast.saveFailed"))})},ws)},[Se,xe,o.writeFile,bn,u?.path,r]),Va=s.useMemo(()=>fr&&(pt.current||ee)||O,[ee,O,fr]),Rs=s.useCallback(()=>ve,[ve]);s.useEffect(()=>{const t=l=>{const d=l?"preview":"edit",p=l?"tree":"text";for(const g of je)Te.current[g]="edit",Vn(g)&&(Ie.current[g]=d),Hr(g)&&(Vt.current[g]=d),hr(g)&&(le.current[g]=d);re("edit"),ne(d),fe(d),Re(d),ye(p);try{localStorage.setItem(vn,d),localStorage.setItem(xn,d),localStorage.setItem(wn,p)}catch{}},a=l=>{const d=!!l.detail?.enabled;t(d)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",a),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",a)}},[je]),s.useEffect(()=>{if(!nt||!c)return;const t=()=>{typeof window>"u"||Ot.current===null&&(Ot.current=window.requestAnimationFrame(()=>{Ot.current=null,ln(ot=>ot+1)}))},a=(ot,Rt)=>{if(ot.state.doc.length!==Rt.length)return!1;if(Rt.length===0)return!0;const Nn=Math.min(128,Rt.length);if(ot.state.sliceDoc(0,Nn)!==Rt.slice(0,Nn))return!1;const Qs=Math.max(0,Rt.length-Nn);return ot.state.sliceDoc(Qs,Rt.length)===Rt.slice(Qs)},l=U(nt.path);if(!l){Vr(null),Nt.current={key:"",attempts:0};return}const d=`${l}:${nt.line}:${nt.column??1}`;if(Nt.current.key!==d&&(Nt.current={key:d,attempts:0}),u?.path!==l){if(on)return;Pe(Mt(l));return}if(Me||Ne!==l)return;if(tt||ke||_e||it){Vr(null),Nt.current={key:"",attempts:0};return}if(!Xe)return;if(_!=="edit"){re("edit");return}const p=He.current;if(!p){t();return}if(!a(p,ee)){t();return}const g=Math.max(1,Math.min(nt.line,p.state.doc.lines)),C=p.state.doc.line(g),A=Math.max(1,nt.column||1),se=Math.max(0,C.to-C.from),z=Math.min(se,A-1),ie=C.from+z;if(!(p.state.selection.main.head===ie)||Nt.current.attempts===0){Nt.current.attempts+=1,p.dispatch({selection:{anchor:ie},effects:Tt.scrollIntoView(ie,{y:"center"})}),p.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const ot=He.current;ot&&(ot.dispatch({selection:{anchor:ie},effects:Tt.scrollIntoView(ie,{y:"center"})}),ot.focus())}),Vr(null),Nt.current={key:"",attempts:0}},[Xe,on,ee,Zi,tt,Me,ke,_e,it,Ne,Pe,nt,c,u?.path,Vr,_,Mt]),s.useEffect(()=>{if(!mn||!c)return;const t=U(mn);if(!t){pn(null);return}u?.path===t&&(Me||Ne!==t||(!tt&&!ke&&!_e&&!it&&Xe&&_==="edit"&&He.current?.focus(),pn(null)))},[Xe,tt,Me,ke,_e,it,Ne,mn,c,u?.path,pn,_]);const Ht=s.useCallback(t=>{if(!m||!t||!t.hasFocus||typeof window>"u")return;const a=window.visualViewport;if(!a)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(a.offsetTop+a.height))<=0)return;const p=t.state.selection.main.head,g=t.coordsAtPos(p);if(!g)return;const C=Math.round(a.offsetTop+a.height),se=g.bottom+20-C;se<=0||(t.scrollDOM.scrollTop+=se)},[m]);s.useEffect(()=>{if(!m||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Ht(He.current)})},a=window.visualViewport;return a?.addEventListener("resize",t),a?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{a?.removeEventListener("resize",t),a?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[m,Ht]),xo("open_go_to_line",t=>{if(!Xe||_!=="edit"||m)return!1;const a=t.target;if(a?.closest('[role="dialog"]')||!(a instanceof Node)||!Sr.current?.contains(a))return!1;const l=!!a?.closest(".cm-editor");if(!!a?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;dn(!0)});const _r=wt(t=>t.editorFontSize),Ts=s.useMemo(()=>{if(!u?.path)return[fi(h,{fontSize:_r})];const t=Cn(u.path),a=[fi(h,t?{syntaxColors:!1,fontSize:_r}:{fontSize:_r})],l=$r??Ss;return l&&a.push(l),t&&a.push(Eo({language:t,themeName:h.metadata.id,theme:Lo(h)})),G&&a.push(Tt.lineWrapping),m&&a.push(Tt.updateListener.of(d=>{d.view.hasFocus&&(d.selectionSet||d.focusChanged||d.viewportChanged||d.geometryChanged)&&window.requestAnimationFrame(()=>{Ht(d.view)})})),a},[h,u?.path,$r,Ss,G,m,Ht,_r]),Es=s.useMemo(()=>({light:Ye.metadata.id,dark:Pt.metadata.id}),[Ye.metadata.id,Pt.metadata.id]),mr=u?.path&&_e&&(!yt.allowOutsideWorkspace||yt.outsideFileGrant)?`${u.path}|${yt.allowOutsideWorkspace?"outside":"workspace"}|${yt.outsideFileGrant??""}|${Nr}`:"",Wr=u?.path&&Kt&&ve==="preview"&&!w.isVSCode?`${u.path}|${Nr}`:"",Vs=r("filesView.error.readFileFailed"),{readyKey:Ps,nonce:Pa}=Ci(Wr,we,Vs),{readyKey:Ds,nonce:Ms}=Ci(mr,we,Vs),Da=!!(Wr&&Ps!==Wr),zs=!!(mr&&Ds!==mr),Ls=u?.path&&ke?Or?`data:${wo(u.path)};utf8,${encodeURIComponent(O)}`:Ui:"",As=u?.path&&_e&&mr&&Ds===mr?ni().authenticatedAsset("/api/fs/raw",{path:u.path,allowOutsideWorkspace:yt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:yt.outsideFileGrant,directory:c||void 0}):"",Is=s.useCallback(t=>n.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:n.jsx("iframe",{src:As,className:"h-full w-full border-0",title:t.name},Ms)}),[As,Ms]);s.useEffect(()=>{let t=!1,a="";return(async()=>{if(!u?.path||!ke||Or){Be("");return}we(null);const d=await et(u.path);if(t)return;await(o.readFileBinary?o.readFileBinary(u.path,d).then(g=>g.dataUrl):(async()=>{const g=await ri("/api/fs/raw",{query:{path:u.path,allowOutsideWorkspace:d.allowOutsideWorkspace?"true":void 0,outsideFileGrant:d.outsideFileGrant,directory:c||void 0}});if(!g.ok)throw new Error(r("filesView.error.readFileFailed"));const C=await g.blob();return a=URL.createObjectURL(C),t?(URL.revokeObjectURL(a),a="",""):a})()).then(g=>{t||(Be(g),ce(u.path))}).catch(g=>{t||(Be(""),we(g instanceof Error?g.message:r("filesView.error.readFileFailed")),ce(null))}).finally(()=>{t||ft(!1)})})(),()=>{t=!0,a&&URL.revokeObjectURL(a)}},[Nr,o,ke,Or,et,c,u?.path,yt,r]);const Ma=s.useCallback(()=>cn(null),[]),za=s.useMemo(()=>Xo({drafts:os,editingDraftId:Dr,commentText:Pr,onTextChange:ls,selection:W,isDragging:ss,fileLabel:u?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:ps,onCancel:()=>{Ge(null),dr()},onEdit:t=>{fs(t),Ge({start:t.startLine,end:t.endLine})},onDelete:ms}),[dr,Pr,ms,Dr,os,ps,ss,W,u?.path,ls,fs]),Os=xi(),Bs=xi(),$s=!Me&&!tt&&Ne===qe,Ur=$s&&Br&&_==="view"&&!(qt&&Q==="tree"),_s=$s&&Je&&Ae()==="preview",{setScroller:Ws,restore:La}=Kr(Ur?`${mt}:code`:null),{setScroller:Us,restore:Aa}=Kr(Ur?`${mt}:code:fullscreen`:null),{setScroller:qs}=Kr(_s?`${mt}:markdown`:null),{setScroller:Ks}=Kr(_s?`${mt}:markdown:fullscreen`:null),{setScroller:Hs}=Os,{setScroller:Gs}=Bs,Ia=s.useCallback(t=>{Hs(t),Ws(t)},[Hs,Ws]),Oa=s.useCallback(t=>{Gs(t),Us(t)},[Gs,Us]),Ba=s.useCallback(t=>{as.current=t,Rr.current=t,qs(t)},[qs]),$a=s.useCallback(t=>{Er.current=t,Ks(t)},[Ks]),yn=No("unified"),at=ee.length>zi,jn=s.useMemo(()=>at&&Ur?Fl(ee):void 0,[Ur,ee,at]),Xs=s.useCallback((t,a,l,d)=>{const p={name:t.name,contents:a,lang:Cn(t.path)||void 0},g=C=>n.jsx(zo,{file:at&&jn?{...p,cacheKey:`${t.path}:${jn}`}:p,options:{disableFileHeader:!0,overflow:G?"wrap":"scroll",theme:Es,themeType:h.metadata.variant==="dark"?"dark":"light",onPostRender:d},className:at?"block w-full":"block h-full w-full",style:at?void 0:{height:"100%"}},C);return at?n.jsx("div",{className:"h-full",children:n.jsx(Ao.Provider,{value:l.virtualizer,children:n.jsx(Io.Provider,{value:yn,children:g(`${t.path}:${yn?"pool":"pending"}`)})})}):n.jsx("div",{className:"h-full",children:g(t.path)})},[h.metadata.variant,at,jn,Es,yn,G]),Js=({exitFullscreenOnly:t=!1,layout:a="floating"}={})=>{if(!u)return null;const l=a==="docked",d=bo(yo("save_file")),p=l?"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",g=(C,A)=>n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:A})}),n.jsx(Zt,{side:"bottom",sideOffset:6,children:C})]});return n.jsxs("div",{className:p,children:[Xe&&Na&&n.jsxs(n.Fragment,{children:[nr?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[n.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),r("filesView.editor.saving")]}):Se&&Gi==="saved"&&!Le?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[n.jsx(F,{name:"check",className:"size-3.5"}),r("filesView.editor.saved")]}):Le?g(r(Se?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:d}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{_t()},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:r(Se?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:d}),"aria-label":r("filesView.editor.saveAria",{shortcut:d}),children:n.jsx(F,{name:"save-3",className:"size-4"})})):null,g(r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Ji(!Se),className:K("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Se?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:Se?n.jsx(F,{name:"file-check-fill",className:"size-4"}):n.jsx(F,{name:"file-check",className:"size-4"})}))]}),n.jsxs(Pn,{onOpenChange:X,children:[n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Dn,{asChild:!0,children:n.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:r("filesView.editor.openInDesktopApp"),"aria-label":r("filesView.editor.openInDesktopApp"),children:n.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),n.jsx(Zt,{side:"bottom",sideOffset:6,children:r("filesView.editor.openInDesktopApp")})]}),n.jsxs(Mn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[oa.map(C=>n.jsxs(Xr,{className:"flex items-center gap-2",onClick:()=>{da(C)},children:[n.jsx(kl,{label:C.label,iconDataUrl:C.iconDataUrl}),n.jsx("span",{className:"typography-ui-label text-foreground",children:C.label})]},C.id)),la?n.jsxs(Xr,{className:"flex items-center gap-2",onClick:()=>{ca(!0)},children:[n.jsx(F,{name:"refresh",className:"size-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:r("filesView.editor.refreshApps")})]}):null]})]}),!ke&&!_e&&!it&&n.jsxs(n.Fragment,{children:[g(r(G?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>We(!G),className:K("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",G?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(G?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:n.jsx(F,{name:"text-wrap",className:"size-4"})})),_==="edit"&&n.jsxs(n.Fragment,{children:[g(r("filesView.editor.findInFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:C=>{be(!De),C.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.findInFile"),children:n.jsx(F,{name:"search",className:"size-4"})})),g(r("filesView.editor.goToLine"),n.jsx(I,{variant:"ghost",size:"sm",onClick:C=>{dn(A=>!A),C.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.goToLine"),children:n.jsx(F,{name:"menu-fold-2",className:"size-4"})})),n.jsx(il,{open:aa,onOpenChange:dn,view:He.current,variant:"inline"})]})]}),Br&&Xe&&!qt&&!Kt&&n.jsx(Tn,{currentMode:_==="view"?"preview":"edit",onToggle:()=>{Ca(_==="view"?"edit":"view")}}),Je&&g(r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Sa(Ae()==="preview"?"edit":"preview"),className:K("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:n.jsx(F,{name:Ae()==="preview"?"eye":"eye-off",className:"size-4"})})),Hr(u?.path??"")&&n.jsx(Tn,{currentMode:Rs(),onToggle:()=>{Ra(Rs()==="preview"?"edit":"preview")}}),Je&&Ae()==="preview"&&g(r("filesView.editor.findInFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{kr(!0),Zn(C=>C+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.findInFile"),children:n.jsx(F,{name:"search",className:"size-4"})})),Je&&Ae()==="preview"&&fa&&n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.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":r(Fr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{Fr?Wi():O.trim()&&_i(O)},children:Fr?n.jsx(F,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"volume-up",className:"size-4"})})}),n.jsx(Zt,{sideOffset:8,children:r(Fr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),fr&&n.jsxs(n.Fragment,{children:[n.jsx(Tn,{currentMode:xe,onToggle:()=>Ta(xe==="preview"?"edit":"preview")}),xe==="preview"&&n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{const C=Un.current?.getXml();if(ze.current&&(clearTimeout(ze.current),ze.current=null),u?.path&&C){if(!await bn(u.path,C))return;Cr(!0),setTimeout(()=>Cr(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.diagram.saveDiagram"),children:Xi?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"save-3",className:"size-4"})})]}),qt&&g(r(Q==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>ka(Q==="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:r(Q==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Q==="tree"?n.jsx(F,{name:"code-sslash",className:"size-4"}):n.jsx(F,{name:"node-tree",className:"size-4"})})),ja&&g(r("filesView.editor.copyFileContents"),n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await Zr(O)).ok?(Hn(!0),lr.current!==null&&window.clearTimeout(lr.current),lr.current=window.setTimeout(()=>{Hn(!1)},1200)):J.error(r("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.copyFileContents"),"aria-label":r("filesView.editor.copyFileContents"),children:sa?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"clipboard",className:"size-4"})})),Fa&&g(r("filesView.editor.copyFilePathTitle",{path:xt}),n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await Zr(xt)).ok?(Gn(!0),cr.current!==null&&window.clearTimeout(cr.current),cr.current=window.setTimeout(()=>{Gn(!1)},1200)):J.error(r("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.copyFilePathTitle",{path:xt}),"aria-label":r("filesView.editor.copyFilePathTitle",{path:xt}),children:ia?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"file-copy-2",className:"size-4"})})),o.downloadFile&&g(r("filesView.editor.saveFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{const C=o.downloadFile;C&&C(u.path).catch(A=>{console.error("Download failed:",A),J.error(r("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.saveFile"),"aria-label":r("filesView.editor.saveFile"),children:n.jsx(F,{name:"download",className:"size-4"})})),t?g(r("filesView.editor.exitFullscreen"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>he(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.exitFullscreen"),"aria-label":r("filesView.editor.exitFullscreen"),children:n.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!m&&i==="full"&&g(r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>he(!te),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:te?n.jsx(F,{name:"fullscreen-exit",className:"size-4"}):n.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},Fn=n.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[n.jsx(ki,{open:on,onOpenChange:t=>{t||ir(!0)},children:n.jsxs(Ri,{showCloseButton:!1,className:"max-w-md",children:[n.jsxs(Ti,{children:[n.jsx(Ei,{children:r("filesView.unsaved.title")}),n.jsx(Vi,{children:r("filesView.unsaved.description")})]}),n.jsxs(Pi,{children:[n.jsx(I,{variant:"outline",onClick:()=>{va()},disabled:nr,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:r("filesView.unsaved.saveChanges")}),n.jsx(I,{variant:"destructive",onClick:ga,children:r("filesView.unsaved.discard")})]})]})}),n.jsxs("div",{className:K("flex flex-col flex-shrink-0",B&&"border-b border-border/40"),children:[B?n.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[m&&oe&&n.jsx("button",{type:"button",onClick:()=>H(!1),"aria-label":r("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:n.jsx(F,{name:"arrow-left-s",className:"size-5"})}),m?u?n.jsxs(Pn,{children:[n.jsx(Dn,{asChild:!0,children:n.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":r("filesView.editor.openFilesAria"),children:[n.jsx(Gr,{filePath:u.path,extension:u.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(yi,{name:u.name}),n.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),n.jsx(Mn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:zt.map(t=>{const a=u?.path===t.path;return n.jsxs(Xr,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}a||Pe(t)},className:K("flex min-w-0 items-center justify-between gap-2 overflow-hidden",a&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[n.jsx(Gr,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(yi,{name:t.name})]}),n.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),js(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":r("filesView.editor.closeFileAria",{name:t.name}),children:n.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:r("filesView.editor.selectFile")}):zt.length>0?n.jsxs("div",{className:"relative min-w-0 flex-1",children:[In.left&&n.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),In.right&&n.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),n.jsx("div",{ref:tn,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:zt.map(t=>{const a=u?.path===t.path;return n.jsxs("div",{title:Jr(c,t.path),className:K("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",a?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[n.jsx(Gr,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),n.jsx("button",{type:"button",onClick:()=>{a||Pe(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),n.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),js(t.path)},className:K("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!a&&!R&&"opacity-0 group-hover:opacity-100"),"aria-label":r("filesView.editor.closeFileAria",{name:t.name}),children:n.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:r("filesView.editor.selectFile")})]}):null,u?n.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[xt&&!m?n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:xt,children:xt}):null,n.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Js({layout:"docked"})})]}):null]}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:n.jsx(kn,{ref:Ia,outerClassName:"h-full min-w-0",className:K("h-full min-w-0",at&&"[overflow-anchor:none]"),children:u?Me||zs?$?n.jsx("div",{className:"p-3"}):n.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.loading")]}):tt?n.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:tt}):ke?n.jsx("div",{className:"flex h-full items-center justify-center p-3",children:n.jsx("img",{src:Ls,alt:u?.name??r("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},u.path)}):_e?Is(u):it?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"typography-ui-header text-foreground",children:r("filesView.editor.cannotPreviewBinary")}),n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:r("filesView.editor.binaryFileDescription")}),o.downloadFile?n.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=o.downloadFile;!t||!u||t(u.path).catch(a=>{console.error("Download failed:",a),J.error(r("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"}),r("filesView.editor.saveFile")]}):null]}):u&&fr&&xe==="preview"?n.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:n.jsx(Cl,{ref:Un,xml:Va,onChange:Ea},`${u.path}:${Ue}`)}):u&&qt&&Q==="tree"?n.jsx(Rn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.jsonViewerUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToTextMode")})]}),children:n.jsx("div",{className:"h-full overflow-auto",children:n.jsx(Mo,{jsonString:O,maxHeight:"100%",initiallyExpandedDepth:2})})}):u&&Je&&Ae()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:Tr,ref:Ba,children:[n.jsx(pi,{containerRef:as,filePath:u.path,fileContent:O}),O.length>500*1024&&n.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:r("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(O.length/1024)})}),n.jsx(Rn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToEditMode")})]}),children:n.jsx(di,{content:O,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),!te&&n.jsx(vi,{containerRef:Rr,open:Xn,onOpenChange:kr,focusNonce:Jn})]}):u&&Kt&&ve==="preview"?Da?n.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:r("common.loading")}):n.jsx("div",{className:"h-full overflow-hidden",children:n.jsx("iframe",{src:!w.isVSCode&&Ps===Wr?(()=>{const t=u.path.split("/").map(a=>encodeURIComponent(a)).join("/");return ni().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:w.isVSCode?(()=>{const t=u.path.substring(0,u.path.lastIndexOf("/")+1);return t?O.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):O})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:r("filesView.editor.htmlPreviewTitle")},Pa)}):u&&Br&&_==="view"?Xs(u,ee,Os,La):n.jsxs("div",{className:K("relative h-full",Ut&&"overflow-hidden"),ref:Sr,children:[n.jsx("div",{className:K("h-full",Ut&&"invisible"),children:n.jsx(Ni,{positionKey:mt,value:ee,onChange:Ce,readOnly:!Xe,vimMode:is==="vim",extensions:Ts,className:"h-full",blockWidgets:za,onViewReady:t=>{He.current=t,ln(a=>a+1),window.requestAnimationFrame(()=>{Ht(t)})},onViewDestroy:()=>{He.current&&(He.current=null),ln(t=>t+1)},enableSearch:!0,searchOpen:De,onSearchOpenChange:be,highlightLines:W?{start:Math.min(W.start,W.end),end:Math.max(W.start,W.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,a,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const d=t.state.doc.lineAt(a.from).number;if(W&&!l.shiftKey&&Math.min(W.start,W.end)===d&&Math.max(W.start,W.end)===d)return Ge(null),dr(),Bt.current=!1,gt.current=null,$t(!1),!0;if(m&&W&&!l.shiftKey){const p=Math.min(W.start,W.end,d),g=Math.max(W.start,W.end,d);return Ge({start:p,end:g}),Bt.current=!1,gt.current=null,$t(!1),!0}if(Bt.current=!0,gt.current=d,$t(!0),W&&l.shiftKey){const p=Math.min(W.start,d),g=Math.max(W.end,d);Ge({start:p,end:g})}else Ge({start:d,end:d});return!0},mouseover:(t,a,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Bt.current||gt.current===null)return!1;const d=t.state.doc.lineAt(a.from).number,p=Math.min(gt.current,d),g=Math.max(gt.current,d);return Ge({start:p,end:g}),$t(!0),!1},mouseup:()=>(Bt.current=!1,gt.current=null,$t(!1),!1)}}},mt)}),Ut&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.openingFileAtChange")]})})]}):n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:r("filesView.editor.pickFileFromTree")})})})]}),_a=!!(c&&$n[c]),Zs=c?br[c]:null,Ys=D?n.jsxs("section",{className:K("flex min-h-0 flex-col overflow-hidden",m?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[n.jsx("div",{className:K("flex flex-col gap-2 py-2",m?"px-3":"px-2"),children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1 min-w-0",children:[n.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),n.jsx(gr,{ref:pe,value:Z,onChange:t=>Y(t.target.value),placeholder:r("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),Z.trim().length>0&&n.jsx("button",{type:"button","aria-label":r("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:()=>{Y(""),pe.current?.focus()},children:n.jsx(F,{name:"close",className:"size-4"})})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>fn("createFile",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.newFileTitle"),"aria-label":r("filesView.tree.actions.newFileTitle"),children:n.jsx(F,{name:"file-add",className:"size-4"})})})}),n.jsx(Zt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.newFileTitle")})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>fn("createFolder",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.newFolderTitle"),"aria-label":r("filesView.tree.actions.newFolderTitle"),children:n.jsx(F,{name:"folder-add",className:"size-4"})})})}),n.jsx(Zt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.newFolderTitle")})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{Mr()},className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.refreshTitle"),"aria-label":r("filesView.tree.actions.refreshTitle"),children:n.jsx(F,{name:"refresh",className:"size-4"})})})}),n.jsx(Zt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.refreshTitle")})]})]})}),n.jsx(kn,{outerClassName:"flex-1 min-h-0",className:K("py-2",m?"px-3":"px-2"),children:n.jsx("ul",{className:"flex flex-col",children:$i?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.tree.search.searching")]}):_n.length>0?_n.map(t=>{const a=u?.path===t.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>{Pe(t)},className:K("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",a?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Ai(t.path,t.extension),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):Zs?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"text-[var(--status-error)]",children:Zs}),n.jsxs(I,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Mr()},children:[n.jsx(F,{name:"refresh",className:"size-3.5"}),r("filesView.tree.actions.refreshTitle")]})]}):_a?Ns(c,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:r("filesView.state.loading")})})})]}):null,Wa=i==="full"&&te&&u&&n.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:n.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[n.jsx("div",{className:"absolute right-4 top-4 z-30",children:Js({exitFullscreenOnly:!0})}),n.jsx(kn,{ref:Oa,outerClassName:"h-full min-w-0",className:K("h-full min-w-0",at&&"[overflow-anchor:none]"),children:Me||zs?$?n.jsx("div",{className:"p-4"}):n.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):tt?n.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:tt}):ke?n.jsx("div",{className:"flex h-full items-center justify-center p-4",children:n.jsx("img",{src:Ls,alt:u.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},u.path)}):_e?Is(u):it?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"typography-ui-header text-foreground",children:r("filesView.editor.cannotPreviewBinary")}),n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:r("filesView.editor.binaryFileDescription")}),o.downloadFile?n.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=o.downloadFile;!t||!u||t(u.path).catch(a=>{console.error("Download failed:",a),J.error(r("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"}),r("filesView.editor.saveFile")]}):null]}):Je&&Ae()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:Tr,ref:$a,children:[u?n.jsx(pi,{containerRef:Er,filePath:u.path,fileContent:O}):null,O.length>500*1024&&n.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:r("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(O.length/1024)})}),n.jsx(Rn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToEditMode")})]}),children:n.jsx(di,{content:O,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),n.jsx(vi,{containerRef:Er,open:Xn,onOpenChange:kr,focusNonce:Jn,className:"right-4 top-16"})]}):Br&&_==="view"?Xs(u,ee,Bs,Aa):n.jsxs("div",{className:K("relative h-full",Ut&&"overflow-hidden"),children:[n.jsx("div",{className:K("h-full",Ut&&"invisible"),children:n.jsx(Ni,{positionKey:`${mt}:fullscreen`,value:ee,onChange:Ce,readOnly:!Xe,vimMode:is==="vim",extensions:Ts,className:"h-full",onViewReady:t=>{He.current=t,window.requestAnimationFrame(()=>{Ht(t)})},onViewDestroy:()=>{He.current&&(He.current=null)}},`${mt}:fullscreen`)}),Ut&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.openingFileAtChange")]})})]})})]})});return n.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[n.jsx(Al,{activeDialog:Ct,dialogData:St,dialogInputValue:ht,onDialogInputChange:Kn,isDialogSubmitting:Qi,onDialogSubmit:ha,onClose:Ma,inputRef:Ki}),Wa,m?oe?Fn:Ys:i==="editor-only"?n.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Fn})}):n.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[j>=700&&n.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Ys}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Fn})]})]})};function Ol(i){return i+1}export{ad as FilesView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as r,j as s,f as tt}from"./vendor-react-BUCujlKS.js";import{f as bt,Z as vt,aE as xe,cy as jt,cc as It,t as b,kN as Nt,I as u,B as he,o as Ze,c6 as He,a5 as Ye,ch as Pt,ci as wt,cj as kt,ck as St,cl as Lt,cn as $e,h as K,W as Ct,au as Rt,aq as At,as as Ft,at as Et,ap as Tt}from"./useAppFontEffects-ne84JBVL.js";import{u as f,dQ as M}from"./index-Dqc6USl3.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CgAdXWZO.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.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-Bx2EHc1O.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"./vendor-opencode-sdk-BJ73u-bH.js";const Je="[&_img]:max-w-full [&_img]:h-auto",st="flex h-8 min-w-0 flex-1 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 disabled:cursor-not-allowed disabled:opacity-50",Ae="flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",Mt=520,Xe=t=>t.name?.trim()||t.urlKey?.trim()||t.id,Kt={0:"contextPanel.linear.priority.none",1:"contextPanel.linear.priority.urgent",2:"contextPanel.linear.priority.high",3:"contextPanel.linear.priority.medium",4:"contextPanel.linear.priority.low"},Dt={triage:0,backlog:1,unstarted:2,started:3,completed:4,canceled:5},et=t=>t==="triage"||t==="backlog"||t==="unstarted"||t==="started"||t==="completed"||t==="canceled"?Dt[t]:99,Ot=(t,n)=>{const o=et(t.type)-et(n.type);return o!==0?o:t.position!==n.position?t.position-n.position:t.name.localeCompare(n.name)},zt=t=>t!==0&&t!==1&&t!==2&&t!==3&&t!==4?null:Kt[t],ge=[{value:"all",labelKey:"contextPanel.linear.filter.status.all"},{value:"backlog",labelKey:"contextPanel.linear.filter.status.backlog"},{value:"todo",labelKey:"contextPanel.linear.filter.status.todo"},{value:"started",labelKey:"contextPanel.linear.filter.status.started"},{value:"inReview",labelKey:"contextPanel.linear.filter.status.inReview"},{value:"completed",labelKey:"contextPanel.linear.filter.status.completed"},{value:"canceled",labelKey:"contextPanel.linear.filter.status.canceled"},{value:"duplicate",labelKey:"contextPanel.linear.filter.status.duplicate"}],Ut=t=>ge.some(n=>n.value===t),ye=[{value:"all",labelKey:"contextPanel.linear.filter.priority.all"},{value:"urgent",labelKey:"contextPanel.linear.priority.urgent"},{value:"high",labelKey:"contextPanel.linear.priority.high"},{value:"medium",labelKey:"contextPanel.linear.priority.medium"},{value:"low",labelKey:"contextPanel.linear.priority.low"},{value:"none",labelKey:"contextPanel.linear.priority.none"}],_t=t=>ye.some(n=>n.value===t),Wt=t=>t?{color:t,backgroundColor:`color-mix(in srgb, ${t} 18%, transparent)`}:{backgroundColor:"color-mix(in srgb, var(--surface-muted-foreground) 12%, transparent)"},Vt=t=>{const n=tt.c(4),{labels:o}=t;if(o.length===0)return null;let c;n[0]!==o?(c=o.map(Qt),n[0]=o,n[1]=c):c=n[1];let y;return n[2]!==c?(y=s.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:c}),n[2]=c,n[3]=y):y=n[3],y},te=t=>{const n=tt.c(31),{icon:o,label:c,ariaLabel:y,value:W,items:V,disabled:v,compact:x,active:w,onValueChange:d}=t,[k,G]=r.useState(!1),q=v?!1:k;let F;n[0]!==v?(F=D=>{v||G(D)},n[0]=v,n[1]=F):F=n[1];const Z=w===!0,S=x?Ae:st,H=x?c:void 0,Y=w?"text-primary":"text-muted-foreground";let L;n[2]!==Y?(L=K("size-3.5 shrink-0",Y),n[2]=Y,n[3]=L):L=n[3];let C;n[4]!==o||n[5]!==L?(C=s.jsx(u,{name:o,className:L}),n[4]=o,n[5]=L,n[6]=C):C=n[6];let h;n[7]!==x||n[8]!==c?(h=x?null:s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 truncate",children:c}),s.jsx(u,{name:"arrow-down-s",className:"size-4 shrink-0 opacity-60"})]}),n[7]=x,n[8]=c,n[9]=h):h=n[9];let R;n[10]!==y||n[11]!==v||n[12]!==Z||n[13]!==S||n[14]!==H||n[15]!==C||n[16]!==h?(R=s.jsx(At,{asChild:!0,children:s.jsxs("button",{type:"button",disabled:v,"aria-pressed":Z,className:S,"aria-label":y,title:H,children:[C,h]})}),n[10]=y,n[11]=v,n[12]=Z,n[13]=S,n[14]=H,n[15]=C,n[16]=h,n[17]=R):R=n[17];let j;n[18]!==d?(j=D=>{d(D),G(!1)},n[18]=d,n[19]=j):j=n[19];let A;n[20]!==V?(A=V.map(Zt),n[20]=V,n[21]=A):A=n[21];let I;n[22]!==j||n[23]!==A||n[24]!==W?(I=s.jsx(Ft,{align:"start",className:"min-w-40",children:s.jsx(Et,{value:W,onValueChange:j,children:A})}),n[22]=j,n[23]=A,n[24]=W,n[25]=I):I=n[25];let N;return n[26]!==q||n[27]!==R||n[28]!==I||n[29]!==F?(N=s.jsxs(Tt,{open:q,onOpenChange:F,children:[R,I]}),n[26]=q,n[27]=R,n[28]=I,n[29]=F,n[30]=N):N=n[30],N},Gt=t=>{const n=t.trim();if(!n)return null;const o=n.match(/linear\.app\/(?:[^/]+\/)?issue\/([A-Za-z][A-Za-z0-9]*-\d+)/i);return o?o[1].toUpperCase():/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(n)?n.toUpperCase():null},qt=t=>({id:t.id,identifier:t.identifier,title:t.title,url:t.url,state:t.state,assignee:t.assignee,team:t.team,priority:t.priority,labels:t.labels}),Bt=(t,n)=>{const o=qt(n);return t.map(c=>c.id===n.id?o:c)},Nn=()=>{const{t}=bt(),{linear:n}=vt(),o=xe(e=>e.status),c=xe(e=>e.hasChecked),y=xe(e=>e.refreshStatus),W=xe(e=>e.setStatus),V=f(e=>e.setSettingsDialogOpen),v=f(e=>e.setSettingsPage),x=f(e=>e.linearIssueListStatus),w=f(e=>e.linearIssueListAssignee),d=f(e=>e.linearIssueListTeamId),k=f(e=>e.linearIssueListPriority),G=f(e=>e.linearIssueFocus),q=f(e=>e.timeFormatPreference),F=f(e=>e.setLinearIssueListStatus),Z=f(e=>e.setLinearIssueListAssignee),S=f(e=>e.setLinearIssueListTeamId),H=f(e=>e.setLinearIssueListPriority),Y=f(e=>e.resetLinearIssueListFilters),L=f(e=>e.setLinearIssueFocus),C=f(e=>e.applyLinearIssueListFiltersForRuntime);r.useEffect(()=>{C()},[C]);const[h,R]=r.useState(""),[j,A]=r.useState(!1),[I,N]=r.useState([]),[D,se]=r.useState(null),[be,ne]=r.useState(!1),[O,z]=r.useState(!0),[ae,Fe]=r.useState(!1),[$,Ee]=r.useState(!1),[Te,re]=r.useState(null),[J,E]=r.useState(null),[l,X]=r.useState(null),[U,le]=r.useState([]),[nt,Me]=r.useState(!1),[B,Ke]=r.useState(!1),[ie,De]=r.useState(!1),[oe,ve]=r.useState(!1),[Q,ce]=r.useState([]),[ue,Oe]=r.useState(!1),P=r.useRef(0),je=r.useRef(null),ze=r.useRef(null),[Ue,at]=r.useState(0),de=r.useMemo(()=>Gt(h),[h]),Ie=jt(h,350),rt=r.useCallback(e=>{if(!e)return"";const a=Date.parse(e);return Number.isFinite(a)?It(a,q,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):""},[q]),lt=r.useCallback(()=>{v("integrations"),V(!0)},[V,v]),me=r.useMemo(()=>({query:Ie.trim()||void 0,status:x,assignee:w,teamId:d===M?void 0:d,priority:k==="all"?void 0:k}),[Ie,w,k,x,d]),pe=o?.workspaces??[],_=pe.find(e=>e.current)?.id||o?.organization?.id||"",_e=r.useCallback(async()=>{if(c&&o?.connected===!1){z(!1),N([]),ne(!1),se(null),re(null);return}if(!n?.issuesList){z(!0),re(t("session.linearIssuePicker.error.runtimeUnavailable"));return}const e=P.current+1;P.current=e,Fe(!0),re(null);try{const a=await n.issuesList(me);if(e!==P.current)return;if(z(a.connected!==!1),a.connected===!1){N([]),ne(!1),se(null);return}N(a.issues??[]),se(a.cursor??null),ne(!!a.hasMore)}catch(a){if(e!==P.current)return;re(a instanceof Error?a.message:String(a))}finally{e===P.current&&Fe(!1)}},[n,c,o,me,t]);r.useEffect(()=>{n&&!c&&y(n)},[n,c,y]),r.useEffect(()=>{_e()},[_e]),r.useEffect(()=>{if(!n?.mappingGet||!O){ce([]);return}let e=!1;return n.mappingGet().then(a=>{if(!e){if(a.connected===!1){ce([]);return}ce(a.teams??[])}}).catch(()=>{e||ce([])}),()=>{e=!0}},[O,_,n]),r.useEffect(()=>{d===M||Q.length===0||Q.some(e=>e.id===d)||S(M)},[d,S,Q]);const it=r.useCallback(async()=>{if(!n?.issuesList||$||ae||!be||!D)return;const e=P.current+1;P.current=e,Ee(!0);try{const a=await n.issuesList({...me,cursor:D});if(e!==P.current||(z(a.connected!==!1),a.connected===!1))return;N(i=>[...i,...a.issues??[]]),se(a.cursor??null),ne(!!a.hasMore)}catch(a){if(e!==P.current)return;const i=a instanceof Error?a.message:String(a);b.error(t("session.linearIssuePicker.toast.loadMoreFailed"),{description:i})}finally{e===P.current&&Ee(!1)}},[D,be,ae,$,n,me,t]);r.useEffect(()=>{if(!J||!n?.issueGet)return;let e=!1;return Me(!0),X(null),le([]),(async()=>{try{const a=await n.issueGet(J);if(e)return;if(a.connected===!1){z(!1),E(null);return}const i=a.issue;if(!i){b.error(t("session.linearIssuePicker.error.issueNotFound")),E(null);return}X(i);const T=i.team?.id;if(!T||!n.issueStates)return;try{const g=await n.issueStates(T);if(e)return;if(g.connected===!1){z(!1);return}le(g.states??[])}catch(g){if(e)return;const fe=g instanceof Error?g.message:String(g);b.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:fe})}}catch(a){if(e)return;const i=a instanceof Error?a.message:String(a);b.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:i}),E(null)}finally{e||Me(!1)}})(),()=>{e=!0}},[n,J,t]),r.useEffect(()=>{G&&(E(G),L(null))},[G,L]);const We=r.useCallback(e=>{X(e),N(a=>Bt(a,e))},[]),Ne=r.useCallback(async(e,a)=>{if(!(!n?.issueUpdate||!l||B)&&l.state?.id!==e){Ke(!0);try{const i=await n.issueUpdate({id:l.id,stateId:e});if(i.connected===!1){z(!1),b.error(t(a));return}if(!i.issue){b.error(t(a));return}We(i.issue),b.success(t("contextPanel.linear.toast.statusUpdated"))}catch(i){const T=i instanceof Error?i.message:String(i);b.error(t(a),{description:T})}finally{Ke(!1)}}},[We,B,n,l,t]),ot=r.useCallback(()=>{const e=U.find(a=>a.type==="completed");if(!e){b.error(t("contextPanel.linear.error.noCompletedState"));return}Ne(e.id,"contextPanel.linear.toast.closeFailed")},[t,Ne,U]),ct=r.useCallback(async()=>{if(!(!l||ie)){De(!0);try{await Nt({linear:n,issueKey:l.id,createInWorktree:oe,t})}finally{De(!1)}}},[oe,ie,n,l,t]),ut=r.useCallback(async e=>{if(!(!n?.authActivate||!e||e===_||ue)){Oe(!0);try{const a=await n.authActivate(e);W(a),E(null),X(null),le([]),S(M),b.success(t("contextPanel.linear.toast.workspaceSwitched"))}catch(a){const i=a instanceof Error?a.message:String(a);b.error(t("contextPanel.linear.toast.workspaceSwitchFailed"),{description:i})}finally{Oe(!1)}}},[_,ue,n,W,S,t]),Pe=r.useMemo(()=>{const e=new Map(U.map(g=>[g.id,g])),a=l?.state?.id,i=l?.state?.name;return[...a&&i&&!e.has(a)?[{id:a,name:i,type:l.state?.type??null,position:0},...U]:U].sort(Ot)},[l,U]),dt=U.find(e=>e.type==="completed"),mt=l?.state?.type==="completed",Ve=c&&O===!1,pt=!n,Ge=!!J,qe=x==="all"&&w==="any"&&d===M&&k==="all",we=!!n&&O&&!Ve,ee=!we||ue,m=Ue>0&&Ue<Mt,ke=h.trim().length>0,ft=!qe||ke,Se=!m||j||ke,Le=r.useCallback(()=>{R(""),A(!1)},[]);r.useEffect(()=>{const e=je.current;if(!e||!globalThis.ResizeObserver)return;const a=new ResizeObserver(i=>{at(i[0]?.contentRect.width??0)});return a.observe(e),()=>a.disconnect()},[Ge]),r.useEffect(()=>{m&&j&&ze.current?.focus()},[m,j]);const xt=s.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",role:"button",tabIndex:0,"aria-pressed":oe,onClick:()=>ve(e=>!e),onKeyDown:e=>{(e.key===" "||e.key==="Enter")&&(e.preventDefault(),ve(a=>!a))},children:[s.jsx("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),ve(a=>!a)},"aria-label":t("session.linearIssuePicker.actions.toggleWorktreeAria"),className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:oe?s.jsx(u,{name:"checkbox",className:"h-4 w-4 text-primary"}):s.jsx(u,{name:"checkbox-blank",className:"h-4 w-4"})}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("session.linearIssuePicker.actions.createInWorktree")})]}),ht=e=>s.jsxs("div",{className:K("group flex items-center gap-2 py-1.5 px-1 rounded cursor-pointer hover:bg-interactive-hover/30 transition-colors",J===e.id&&"bg-interactive-selection/30"),onClick:()=>E(e.id),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:e.identifier}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:e.title}),s.jsx("div",{className:"flex-shrink-0 h-5 flex items-center mr-1",children:s.jsx("button",{type:"button",className:"hidden group-hover:flex h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground transition-colors",onClick:a=>{a.stopPropagation(),Ze(e.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})})})]},e.id);if(Ge){const e=l?.assignee?.displayName||l?.assignee?.name,a=l?.comments??[],i=l?.description?.trim()||"",T=l?.state?.id||"",g=zt(l?.priority),fe=l?.labels??[];return s.jsxs("div",{ref:je,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[s.jsxs(he,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>{E(null),X(null),le([])},"aria-label":t("contextPanel.linear.actions.backToList"),children:[s.jsx(u,{name:"arrow-left-s",className:"h-4 w-4"}),t("contextPanel.linear.actions.backToList")]}),l?s.jsx("button",{type:"button",className:"ml-auto flex h-7 w-7 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{Ze(l.url)},"aria-label":t("session.linearIssuePicker.actions.openInLinearAria"),children:s.jsx(u,{name:"external-link",className:"h-4 w-4"})}):null]}),s.jsxs(He,{as:Ye,outerClassName:"h-full min-h-0 flex-1",className:"px-4 py-3",disableHorizontal:!0,preventOverscroll:!0,children:[nt&&!l?s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}):null,l?s.jsx(r.Suspense,{fallback:s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-muted-foreground",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("contextPanel.linear.loading.issue")]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"typography-meta text-muted-foreground",children:l.identifier}),s.jsx("h2",{className:"typography-ui-header text-foreground mt-0.5",children:l.title})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Pe.length>0&&T?s.jsxs(Pt,{value:T,onValueChange:p=>{Ne(p,"contextPanel.linear.toast.statusUpdateFailed")},disabled:B,children:[s.jsx(wt,{size:"sm",className:"h-7 w-auto min-w-0","aria-label":t("contextPanel.linear.label.statusAria"),children:s.jsx(kt,{placeholder:t("contextPanel.linear.label.status"),children:p=>Pe.find(Ce=>Ce.id===p)?.name??p})}),s.jsx(St,{children:Pe.map(p=>s.jsx(Lt,{value:p.id,children:p.name},p.id))})]}):l.state?.name?s.jsx("span",{className:"typography-meta text-muted-foreground",children:l.state.name}):null,dt&&!mt?s.jsxs(he,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:ot,disabled:B,children:[B?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.closeIssue")]}):null]}),s.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 typography-meta",children:[l.team?.name?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.team")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:l.team.name})]}):null,s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.assignee")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:e||t("contextPanel.linear.label.unassigned")}),g?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.priority")}),s.jsx("dd",{className:"text-foreground min-w-0 truncate",children:t(g)})]}):null,fe.length>0?s.jsxs(s.Fragment,{children:[s.jsx("dt",{className:"text-muted-foreground",children:t("contextPanel.linear.label.labels")}),s.jsx("dd",{className:"min-w-0",children:s.jsx(Vt,{labels:fe})})]}):null]}),s.jsx("div",{children:i?s.jsx($e,{content:i,className:Je,enableFileReferences:!1}):s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noDescription")})}),s.jsxs("div",{children:[s.jsx("h3",{className:"typography-ui-label text-foreground mb-2",children:t("contextPanel.linear.label.comments")}),a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("contextPanel.linear.empty.noComments")}):s.jsx("div",{className:"relative pl-3",children:a.map((p,Ce)=>{const Re=p.user?.displayName||p.user?.name||t("contextPanel.linear.label.unassigned"),Be=p.user?.avatarUrl||null,gt=Re.charAt(0).toUpperCase(),yt=Ce===a.length-1,Qe=rt(p.createdAt);return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[yt?null:s.jsx("div",{className:"absolute left-4 top-[2.375rem] bottom-[0.375rem] w-px bg-border/60"}),s.jsx("div",{className:"absolute left-0 top-0 z-10 flex size-8 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-surface-elevated text-xs text-muted-foreground",children:Be?s.jsx("img",{src:Be,alt:Re,className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("span",{children:gt})}),s.jsxs("div",{className:"rounded-lg bg-surface-elevated px-3 pt-0 pb-3 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 typography-micro text-muted-foreground",children:[s.jsx("span",{className:"text-foreground whitespace-nowrap",children:Re}),Qe?s.jsx("span",{className:"whitespace-nowrap",children:Qe}):null]}),p.body.trim()?s.jsx($e,{content:p.body,className:K("typography-markdown-body text-foreground break-words",Je),enableFileReferences:!1}):null]})]},p.id)})})]})]})}):null]}),l?s.jsxs("div",{className:"shrink-0 border-t border-border px-4 py-3 flex flex-col gap-3",children:[xt,s.jsxs(he,{type:"button",onClick:()=>{ct()},disabled:ie||B,className:"w-full",children:[ie?s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}):null,t("contextPanel.linear.actions.startSession")]})]}):null]})}return s.jsxs("div",{ref:je,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("div",{className:"px-3 pt-3 space-y-2",children:[Se?s.jsxs("div",{className:"relative",children:[s.jsx(u,{name:"search",className:K("absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4",ke?"text-primary":"text-muted-foreground")}),s.jsx(Ct,{ref:ze,placeholder:t("session.linearIssuePicker.searchPlaceholder"),value:h,onChange:e=>R(e.target.value),onKeyDown:e=>{e.key==="Escape"&&m&&(e.preventDefault(),Le())},className:K("pl-9 w-full",m&&"pr-9")}),m?s.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","aria-label":t("contextPanel.linear.actions.closeSearch"),title:t("contextPanel.linear.actions.closeSearch"),onClick:Le,children:s.jsx(u,{name:"close",className:"size-3.5"})}):null]}):null,we||m&&!Se?s.jsxs("div",{className:K("flex min-w-0 items-center",m&&"gap-0.5"),children:[we?s.jsxs(s.Fragment,{children:[s.jsx(te,{icon:"task",label:t((ge.find(e=>e.value===x)??ge[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.statusAria"),value:x,active:x!=="all",disabled:ee,items:ge.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{Ut(e)&&F(e)}}),s.jsx(te,{icon:"error-warning",compact:m,label:t((ye.find(e=>e.value===k)??ye[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.priorityAria"),value:k,active:k!=="all",disabled:ee,items:ye.map(e=>({value:e.value,label:t(e.labelKey)})),onValueChange:e=>{_t(e)&&H(e)}}),s.jsx(te,{icon:"user-3",compact:m,label:t(w==="me"?"contextPanel.linear.filter.assignee.me":"contextPanel.linear.filter.assignee.any"),ariaLabel:t("contextPanel.linear.filter.assigneeAria"),value:w,active:w!=="any",disabled:ee,items:[{value:"any",label:t("contextPanel.linear.filter.assignee.any")},{value:"me",label:t("contextPanel.linear.filter.assignee.me")}],onValueChange:e=>{(e==="any"||e==="me")&&Z(e)}}),Q.length>0?s.jsx(te,{icon:"team",compact:m,label:d===M?t("contextPanel.linear.filter.team.all"):Q.find(e=>e.id===d)?.name??d,ariaLabel:t("contextPanel.linear.filter.teamAria"),value:d,active:d!==M,disabled:ee,items:[{value:M,label:t("contextPanel.linear.filter.team.all")},...Q.map(e=>({value:e.id,label:e.name}))],onValueChange:S}):null,pe.length>1&&_?s.jsx(te,{icon:"briefcase",compact:m,label:Xe(pe.find(e=>e.id===_)??{id:_,name:null,urlKey:null}),ariaLabel:t("contextPanel.linear.label.workspaceAria"),value:_,disabled:ue,items:pe.map(e=>({value:e.id,label:Xe(e)})),onValueChange:e=>{ut(e)}}):null,ft?s.jsxs("button",{type:"button",className:K(m?Ae:st,!m&&"flex-none"),"aria-label":t("contextPanel.linear.filter.clearAria"),title:t("contextPanel.linear.filter.clearAria"),disabled:ee,onClick:()=>{Y(),Le()},children:[s.jsx(u,{name:"close",className:"size-3.5 shrink-0 text-muted-foreground"}),m?null:s.jsx("span",{className:"min-w-0 truncate",children:t("contextPanel.linear.filter.clear")})]}):null]}):null,m&&!Se?s.jsx("button",{type:"button",className:Ae,"aria-label":t("contextPanel.linear.filter.searchAria"),title:t("contextPanel.linear.filter.searchAria"),onClick:()=>A(!0),children:s.jsx(u,{name:"search",className:"size-3.5 shrink-0 text-muted-foreground"})}):null]}):null]}),s.jsxs(He,{as:Ye,outerClassName:"h-full min-h-0 flex-1",className:"px-3 py-2",disableHorizontal:!0,preventOverscroll:!0,children:[pt?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:t("session.linearIssuePicker.empty.runtimeUnavailable")}):null,ae&&I.length===0?s.jsxs("div",{className:"text-center text-muted-foreground py-8 flex items-center justify-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.issues")]}):null,Ve?s.jsxs("div",{className:"text-center text-muted-foreground py-8 space-y-3",children:[s.jsx("div",{children:t("session.linearIssuePicker.empty.notConnected")}),s.jsx("div",{className:"flex justify-center",children:s.jsx(he,{variant:"outline",size:"sm",onClick:lt,children:t("session.linearIssuePicker.actions.openSettings")})})]}):null,Te?s.jsx("div",{className:"text-center text-muted-foreground py-8 break-words",children:Te}):null,de&&n&&O?s.jsxs("div",{className:"group flex items-center gap-2 py-1.5 px-1 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer",onClick:()=>E(de),children:[s.jsx("span",{className:"typography-meta text-muted-foreground w-16 text-right flex-shrink-0",children:de}),s.jsx("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:t("session.linearIssuePicker.actions.useIssue",{identifier:de})})]}):null,I.length===0&&!ae&&O&&n?s.jsx("div",{className:"text-center text-muted-foreground py-8",children:Ie.trim()?t("session.linearIssuePicker.empty.noIssuesFound"):t(qe?"session.linearIssuePicker.empty.noOpenIssuesFound":"contextPanel.linear.empty.noMatchingIssues")}):null,I.map(ht),be&&O&&n?s.jsx("div",{className:"py-2 flex justify-center",children:s.jsx("button",{type:"button",onClick:()=>{it()},disabled:$,className:K("typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4",$&&"opacity-50 cursor-not-allowed hover:text-muted-foreground"),children:$?s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx(u,{name:"loader-4",className:"h-4 w-4 animate-spin"}),t("session.linearIssuePicker.loading.more")]}):t("session.linearIssuePicker.actions.loadMore")})}):null]})]})};function Qt(t){return s.jsx("span",{className:"inline-flex h-5 max-w-[8rem] items-center truncate rounded-md px-1.5 typography-meta text-muted-foreground",style:Wt(t.color),children:t.name},t.id)}function Zt(t){return s.jsx(Rt,{value:t.value,children:t.label},t.value)}export{Nn as LinearIssuesView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as B,R as h,j as P}from"./vendor-react-BUCujlKS.js";import{toast as H}from"./vendor-sonner-DFyL3AvE.js";import{gG as K,gD as J,af as Z,f as Q,I as W}from"./useAppFontEffects-ne84JBVL.js";import{h as G,a4 as Y,O as ee,e as te,dM as re,dN as oe,a3 as ae}from"./index-Dqc6USl3.js";import{extractMarkdownImageCandidates as se,MAX_MARKDOWN_IMAGE_COUNT as ne}from"./markdownCore-CK48LG0z.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CgAdXWZO.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.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-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-Bx2EHc1O.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"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-marked-CX41MkDF.js";import"./vendor-marked-linkify-it-CXI_LHIE.js";import"./vendor-linkify-it-DZCzzDkK.js";import"./vendor-uc.micro-BAd0H0z4.js";import"./vendor-remend-BWYYytN3.js";import"./vendor-katex-CHD9BdDO.js";import"./vendor-dompurify-r8glNMJW.js";const D=10*1024*1024,ie=1024,le=3e4,ce=new Set(["image/png","image/jpeg","image/gif","image/webp"]),z=new WeakMap,L=r=>{if(r.aborted)throw new DOMException("Image load aborted","AbortError")},me=r=>{let e=r;if(/^file:\/\//i.test(e))try{const o=new URL(e);if(o.protocol!=="file:")return"";e=o.host&&o.host!=="localhost"?`//${o.host}${o.pathname}`:o.pathname,/^\/[A-Za-z]:\//.test(e)&&(e=e.slice(1))}catch{return""}const t=e.split(/[?#]/,1)[0]??"";try{return decodeURIComponent(t)}catch{return t}},ue=r=>new Promise((e,t)=>{const o=new FileReader;o.onload=()=>{typeof o.result=="string"?e(o.result):t(new Error("Unable to encode image"))},o.onerror=()=>t(o.error??new Error("Unable to encode image")),o.readAsDataURL(r)}),pe=async(r,e)=>{const t=new Uint8Array(await r.slice(0,12).arrayBuffer()),o=(n,u)=>String.fromCharCode(...t.slice(n,u));switch(e){case"image/png":return t[0]===137&&o(1,4)==="PNG"&&t[4]===13&&t[5]===10&&t[6]===26&&t[7]===10;case"image/jpeg":return t[0]===255&&t[1]===216&&t[2]===255;case"image/gif":{const n=o(0,6);return n==="GIF87a"||n==="GIF89a"}case"image/webp":return o(0,4)==="RIFF"&&o(8,12)==="WEBP";default:return!1}},V=async(r,e)=>{if(!ce.has(e))throw new Error("Unsupported image type");if(r.size>D)throw new Error("Image is too large");if(!await pe(r,e))throw new Error("Unsupported image data")},fe=async r=>{const e=/^data:(image\/(?:png|jpeg|gif|webp));base64,([\s\S]*)$/i.exec(r);if(!e?.[1]||e[2]===void 0)throw new Error("Invalid image data URL");if(e[2].length>Math.ceil(D*4/3)+4)throw new Error("Image is too large");let t;try{t=atob(e[2])}catch{throw new Error("Invalid image data URL")}const o=Uint8Array.from(t,n=>n.charCodeAt(0));await V(new Blob([o]),e[1].toLowerCase())},q=r=>!/^(?:https?:)?\/\//i.test(r)&&!/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(r),de=async({sources:r,directory:e,sessionId:t,messageId:o,signal:n})=>{const u=Y();let s=z.get(u);s||(s=new Map,z.set(u,s));const c=`${t}\0${o}\0${e}\0${r.join("\0")}`,i=s.get(c);if(i&&i.expiresAt>Date.now())return s.delete(c),s.set(c,i),i.result;i&&s.delete(c);const p=await G(`/api/openchamber/sessions/${encodeURIComponent(t)}/markdown-image-grants`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({directory:e,messageId:o,sources:r}),signal:n});if(!p.ok)throw new Error(`Unable to prepare images (${p.status})`);const m=await p.json(),l=new Map;for(const a of m.results??[])a.source&&(a.status==="ready"&&a.path?l.set(a.source,{status:"ready",path:a.path,outsideFileGrant:a.outsideFileGrant,expiresAt:a.expiresAt}):a.status==="missing"?l.set(a.source,{status:"missing"}):l.set(a.source,{status:"error"}));for(const a of r)l.has(a)||l.set(a,{status:"error"});for(;s.size>=ie;)s.delete(s.keys().next().value);const w=[...l.values()].every(a=>a.status==="ready"),y=Math.min(...[...l.values()].filter(a=>a.status==="ready").map(a=>a.expiresAt??Number.POSITIVE_INFINITY));return s.set(c,{result:l,expiresAt:w?y:Date.now()+le}),l},ge=async(r,e)=>{if(L(e),/^(?:https?:)?\/\//i.test(r))return r;if(/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(r))return await fe(r),L(e),r;throw new Error("Local image has not been prepared")},he=async(r,e,t)=>{L(t);const o=me(r),n=K(e,o);if(!e||!o||!J(n,e))throw new Error("Image path is outside the active workspace");const u=await G("/api/fs/stat",{query:{path:n,directory:e,optional:"true"},signal:t});if(!u.ok)throw new Error(`Unable to inspect image (${u.status})`);const s=await u.json();if(!s.isFile)throw new Error("Image path is not a file");if(typeof s.size=="number"&&s.size>D)throw new Error("Image is too large");const c=await G("/api/fs/raw",{query:{path:n,directory:e},signal:t});if(!c.ok)throw new Error(`Unable to load image (${c.status})`);const i=(c.headers.get("content-type")??"").split(";",1)[0]?.toLowerCase()??"",p=Number(c.headers.get("content-length"));if(Number.isFinite(p)&&p>D)throw new Error("Image is too large");const m=await c.blob();return await V(m,i),L(t),ue(m)},we=(r,e)=>Y().authenticatedAsset("/api/fs/raw",{path:r.path,directory:e,allowOutsideWorkspace:r.outsideFileGrant?"true":void 0,outsideFileGrant:r.outsideFileGrant}),be=r=>{const e=B.c(7),[t,o]=h.useState(!1),[n,u]=h.useState(0);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=te(),e[0]=s):s=e[0];const c=s;let i,p;e[1]!==r?(i=()=>{if(!r){o(!1);return}let w=!1,y;const a=re(c),g=oe(()=>{w||u(Ie)}),I=()=>{ae(c).then(()=>{w||o(!0)}).catch(()=>{w||(y=setTimeout(I,1e3))})};return I(),()=>{w=!0,y&&clearTimeout(y),a(),g()}},p=[c,r],e[1]=r,e[2]=i,e[3]=p):(i=e[2],p=e[3]),h.useEffect(i,p);const m=!r||t;let l;return e[4]!==n||e[5]!==m?(l={ready:m,nonce:n},e[4]=n,e[5]=m,e[6]=l):l=e[6],l},ye=r=>{const e=B.c(46),{candidate:t,preparation:o,directory:n,assetAuthReady:u,assetAuthNonce:s,useWorkspaceFsBridge:c,onShowPopup:i}=r,{t:p}=Q(),m=h.useRef(null),[l,w]=h.useState(!1);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={url:"",status:"loading"},e[0]=y):y=e[0];const[a,g]=h.useState(y);let I;e[1]!==t.source?(I=q(t.source),e[1]=t.source,e[2]=I):I=e[2];const b=I;let x,f;e[3]!==l?(x=()=>{const N=m.current;if(!N||l)return;if(typeof IntersectionObserver>"u"){w(!0);return}const E=new IntersectionObserver(F=>{F.some(Ee)&&(w(!0),E.disconnect())},{rootMargin:"200px"});return E.observe(N),()=>E.disconnect()},f=[l],e[3]=l,e[4]=x,e[5]=f):(x=e[4],f=e[5]),h.useEffect(x,f);let v;e[6]!==u||e[7]!==t.source||e[8]!==n||e[9]!==b||e[10]!==o||e[11]!==l||e[12]!==c?(v=()=>{if(!l||b&&!c&&!o)return;if(b&&c){const E=new AbortController;return g({url:"",status:"loading"}),he(t.source,n,E.signal).then(F=>{E.signal.aborted||g({url:F,status:"loading"})}).catch(()=>{E.signal.aborted||g({url:"",status:"error"})}),()=>E.abort()}if(b){if(o?.status!=="ready"){g({url:"",status:"error"});return}if(!u)return;g({url:we(o,n),status:"loading"});return}const N=new AbortController;return g({url:"",status:"loading"}),ge(t.source,N.signal).then(E=>{N.signal.aborted||g({url:E,status:"loading"})}).catch(()=>{N.signal.aborted||g({url:"",status:"error"})}),()=>N.abort()},e[6]=u,e[7]=t.source,e[8]=n,e[9]=b,e[10]=o,e[11]=l,e[12]=c,e[13]=v):v=e[13];let k;e[14]!==s||e[15]!==u||e[16]!==t.source||e[17]!==n||e[18]!==b||e[19]!==o||e[20]!==l||e[21]!==c?(k=[s,u,t.source,n,b,o,l,c],e[14]=s,e[15]=u,e[16]=t.source,e[17]=n,e[18]=b,e[19]=o,e[20]=l,e[21]=c,e[22]=k):k=e[22],h.useEffect(v,k);let R;e[23]!==t.filename||e[24]!==a.status||e[25]!==a.url||e[26]!==i||e[27]!==p?(R=()=>{if(a.status==="error"){H.error(p("filesView.error.previewUnavailable"));return}a.status!=="ready"||!i||i({open:!0,title:t.filename,content:"",metadata:{tool:"markdown-image-preview",filename:t.filename},image:{url:a.url,filename:t.filename}})},e[23]=t.filename,e[24]=a.status,e[25]=a.url,e[26]=i,e[27]=p,e[28]=R):R=e[28];const U=R,j=a.status==="loading";let A;e[29]!==t.filename||e[30]!==a.status||e[31]!==a.url?(A=P.jsx("span",{className:"flex h-[72px] w-[100px] items-center justify-center overflow-hidden rounded-lg border border-border/40 bg-muted/10",children:a.url&&a.status!=="error"?P.jsx("img",{src:a.url,alt:t.filename,className:"h-full w-full object-contain",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",onLoad:()=>g(Ae),onError:()=>g({url:"",status:"error"}),"data-openchamber-markdown-image":"true","data-openchamber-markdown-image-thumbnail":"true","data-openchamber-markdown-image-state":a.status}):P.jsx(W,{name:"file-image",className:"h-5 w-5 text-muted-foreground"})}),e[29]=t.filename,e[30]=a.status,e[31]=a.url,e[32]=A):A=e[32];let _;e[33]===Symbol.for("react.memo_cache_sentinel")?(_=P.jsx(W,{name:"file-image",className:"h-3 w-3 shrink-0"}),e[33]=_):_=e[33];let S;e[34]!==t.filename?(S=P.jsx("span",{className:"min-w-0 truncate typography-meta",children:t.filename}),e[34]=t.filename,e[35]=S):S=e[35];let C;e[36]!==t.filename||e[37]!==S?(C=P.jsxs("span",{className:"mt-1 flex w-[100px] items-center justify-center gap-1 text-muted-foreground",title:t.filename,"data-openchamber-markdown-image-caption":"true",children:[_,S]}),e[36]=t.filename,e[37]=S,e[38]=C):C=e[38];let M;return e[39]!==t.filename||e[40]!==t.source||e[41]!==U||e[42]!==C||e[43]!==j||e[44]!==A?(M=P.jsxs("button",{ref:m,type:"button",className:"w-[100px] shrink-0 text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t.filename,disabled:j,onClick:U,"data-openchamber-markdown-image-action":"true","data-openchamber-markdown-image-source":t.source,"data-openchamber-markdown-image-filename":t.filename,children:[A,C]}),e[39]=t.filename,e[40]=t.source,e[41]=U,e[42]=C,e[43]=j,e[44]=A,e[45]=M):M=e[45],M},pr=r=>{const e=B.c(34),{sessionId:t,messageId:o,contents:n,onShowPopup:u}=r,s=Z()??"",c=h.useRef(null),[i,p]=h.useState(!1),[m,l]=h.useState(null),[w,y]=h.useState(0);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=ee(),e[0]=a):a=e[0];const g=a;let I;e[1]!==n?(I=se(n,ne),e[1]=n,e[2]=I):I=e[2];const b=I;let x;e[3]!==b?(x=g?[]:b.filter(xe).map(ve),e[3]=b,e[4]=x):x=e[4];const f=x;let v,k;e[5]!==f.length||e[6]!==i?(v=()=>{if(f.length===0||i)return;const d=c.current;if(!d||typeof IntersectionObserver>"u"){p(!0);return}const T=new IntersectionObserver(X=>{X.some(ke)&&(p(!0),T.disconnect())},{rootMargin:"200px"});return T.observe(d),()=>T.disconnect()},k=[f.length,i],e[5]=f.length,e[6]=i,e[7]=v,e[8]=k):(v=e[7],k=e[8]),h.useEffect(v,k);let R;e[9]!==s||e[10]!==o||e[11]!==f||e[12]!==t||e[13]!==i?(R=()=>{if(!i||!t||f.length===0)return;const d=new AbortController;return de({sources:f,directory:s,sessionId:t,messageId:o,signal:d.signal}).then(T=>{d.signal.aborted||l(T)}).catch(()=>{d.signal.aborted||l(new Map(f.map(Re)))}),()=>d.abort()},e[9]=s,e[10]=o,e[11]=f,e[12]=t,e[13]=i,e[14]=R):R=e[14];let U;e[15]!==s||e[16]!==o||e[17]!==w||e[18]!==f||e[19]!==t||e[20]!==i?(U=[s,o,w,f,t,i],e[15]=s,e[16]=o,e[17]=w,e[18]=f,e[19]=t,e[20]=i,e[21]=U):U=e[21],h.useEffect(R,U);let j,A;e[22]!==m?(j=()=>{const d=Math.min(...[...m?.values()??[]].filter(_e).map(Se));if(!Number.isFinite(d))return;const T=setTimeout(()=>y(Me),Math.max(0,d-Date.now()));return()=>clearTimeout(T)},A=[m],e[22]=m,e[23]=j,e[24]=A):(j=e[23],A=e[24]),h.useEffect(j,A);let _;e[25]!==m?(_=d=>m?.get(d.source)?.status!=="missing",e[25]=m,e[26]=_):_=e[26];const S=b.filter(_),C=[...m?.values()??[]].some(Ne),M=be(C);if(S.length===0)return null;const N="mt-3 flex max-w-full gap-2 overflow-x-auto pb-1",E="true";let F;e[27]!==M||e[28]!==s||e[29]!==u||e[30]!==m?(F=d=>P.jsx(ye,{candidate:d,preparation:m?.get(d.source),directory:s,assetAuthReady:M.ready,assetAuthNonce:M.nonce,useWorkspaceFsBridge:g,onShowPopup:u},d.source),e[27]=M,e[28]=s,e[29]=u,e[30]=m,e[31]=F):F=e[31];const $=S.map(F);let O;return e[32]!==$?(O=P.jsx("div",{ref:c,className:N,"data-openchamber-markdown-image-gallery":E,children:$}),e[32]=$,e[33]=O):O=e[33],O};function Ie(r){return r+1}function Ee(r){return r.isIntersecting}function Ae(r){return{...r,status:"ready"}}function xe(r){return q(r.source)}function ve(r){return r.source}function ke(r){return r.isIntersecting}function Re(r){return[r,{status:"error"}]}function _e(r){return r.status==="ready"}function Se(r){return r.expiresAt??Number.POSITIVE_INFINITY}function Me(r){return r+1}function Ne(r){return r.status==="ready"}export{pr as MarkdownImageGallery};
|