@openchamber/web 1.24.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.test.js +22 -0
- package/bin/lib/commands-connect-url.js +3 -8
- package/bin/lib/commands-status.js +5 -0
- package/bin/lib/commands-tunnel.js +3 -0
- package/dist/assets/{CodeMirrorCommentWidgets-DvUH815P.js → CodeMirrorCommentWidgets-hJbl3JX4.js} +1 -1
- package/dist/assets/DiffView-BucGEJYa.js +4 -0
- package/dist/assets/FilesView-CQcaaAVP.js +17 -0
- package/dist/assets/{GitView-Bxuv3dfP.js → GitView-DY4pelsO.js} +4 -4
- package/dist/assets/{GuestAttachDialog-B0u3Q5uO.js → GuestAttachDialog-D6mHDTB2.js} +1 -1
- package/dist/assets/GuestSurfacePane--DJ7rsmY.js +1 -0
- package/dist/assets/{JsonTreeView-BBVPFM5K.js → JsonTreeView-DEXI2NvJ.js} +1 -1
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/LinearIssuesView-BTNc-4dN.js +1 -0
- package/dist/assets/MarkdownImageGallery-wcUUcf8l.js +1 -0
- package/dist/assets/MarkdownRendererImpl-BPe2TVV2.js +12 -0
- package/dist/assets/OnboardingScreen-FJUreEgI.js +1 -0
- package/dist/assets/{PatchDiff-C4rE5k6z.js → PatchDiff-C0oOkKnO.js} +1 -1
- package/dist/assets/PierreDiffViewer-asuSQAsf.js +210 -0
- package/dist/assets/PlanView-DGbasNHP.js +5 -0
- package/dist/assets/PluginPane-DImv8hV2.js +3 -0
- package/dist/assets/SettingsView-DOjuOljf.js +29 -0
- package/dist/assets/SettingsWindow-By4cqnqy.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-C0P2tXLU.js +1 -0
- package/dist/assets/ToolOutputDialog-Cayc-yIM.js +15 -0
- package/dist/assets/ToolPartDiffPreview-B0jmpPQz.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-CZgXWHjU.js → VirtualizedFileDiff-DsOpvWZD.js} +4 -4
- package/dist/assets/{WalkthroughView-wSpED5L4.js → WalkthroughView-CCakjyn9.js} +2 -2
- package/dist/assets/appThemeRegistry-Bw5oTm41.js +1 -0
- package/dist/assets/{commitAndPush-DZnzlhvc.js → commitAndPush-sGEelpjh.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-VYnT_A2h.js → computeVirtualFileMetrics-B-4aLf4A.js} +1 -1
- package/dist/assets/de-CD9utsNj.js +10 -0
- package/dist/assets/es-NNum2rX8.js +16 -0
- package/dist/assets/fr-CJLGmduQ.js +14 -0
- package/dist/assets/index-B6r0Kv-B.js +1 -0
- package/dist/assets/index-DjGPR5vW.js +41 -0
- package/dist/assets/index-fCXJ-8Qt.css +1 -0
- package/dist/assets/{isDiffPlainText-ImDG3Uhg.js → isDiffPlainText-Ok-kgtJA.js} +1 -1
- package/dist/assets/{isFilePlainText-D_YDVYDb.js → isFilePlainText-0dLnkYm8.js} +1 -1
- package/dist/assets/ja-BuddHNi6.js +16 -0
- package/dist/assets/ko-BrwMbHmf.js +16 -0
- package/dist/assets/main-CjXBM_Xe.js +2 -0
- package/dist/assets/main-CxVyUDU_.js +896 -0
- package/dist/assets/markdownCore-B6PpX409.js +5 -0
- package/dist/assets/miniChat-DZ3OAeLN.js +2 -0
- package/dist/assets/mobile-CH0LOIF-.js +2 -0
- package/dist/assets/{patchFileDiff-DDQ6Rq5e.js → patchFileDiff-BFRGKaGH.js} +3 -3
- package/dist/assets/pl-BwN4TNlP.js +16 -0
- package/dist/assets/pt-BR-BhMtownO.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-CB1uLYvh.js +2 -0
- package/dist/assets/renderMobileApp-nQ4sjQtb.js +25 -0
- package/dist/assets/runtimeEndpointReset-9ZGlXU4J.js +27 -0
- package/dist/assets/scheduledTasksApi-6DsL_SwM.js +1 -0
- package/dist/assets/{shikiHighlight-1imXsir9.js → shikiHighlight-CocY80VR.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-Dgqc63LZ.js → textMateThemeFromAppTheme-CF77r8FA.js} +1 -1
- package/dist/assets/tr-DRzvqMdi.js +7 -0
- package/dist/assets/uk-b2aYOSNh.js +16 -0
- package/dist/assets/useAppFontEffects-Dc5nTHi8.js +7337 -0
- package/dist/assets/useInlineCommentController-Dbza5c8l.js +2 -0
- package/dist/assets/useRootScrollLock-CSCLv396.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-BDyxuqK4.js → vendor-codemirror-language-data-CkmYWcRI.js} +2 -2
- package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
- package/dist/assets/vendor-katex-Cp579UoJ.css +1 -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-fZppILAM.js → vendor-zod-Gea9uBlY.js} +4 -4
- package/dist/assets/{web-components-D7FinaeH.js → web-components-nsStrYq9.js} +2 -2
- package/dist/assets/zh-CN-DZeUThm_.js +16 -0
- package/dist/assets/zh-TW-2fRE7uc6.js +16 -0
- package/dist/index.html +15 -7
- package/dist/mini-chat.html +7 -5
- package/dist/mobile.html +7 -5
- package/package.json +8 -7
- package/server/index.d.ts +1 -0
- package/server/index.js +248 -90
- package/server/lib/agent-tool/DOCUMENTATION.md +45 -15
- package/server/lib/agent-tool/runtime.js +189 -61
- package/server/lib/agent-tool/runtime.test.js +229 -75
- 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 +6 -3
- 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 +103 -46
- package/server/lib/fs/routes.test.js +239 -18
- package/server/lib/git/DOCUMENTATION.md +2 -2
- package/server/lib/git/service.js +106 -9
- package/server/lib/git/service.test.js +18 -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 +36 -22
- package/server/lib/message-queue/runtime.js +170 -100
- package/server/lib/message-queue/runtime.test.js +184 -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 +5 -0
- 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 +786 -700
- 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 +450 -30
- 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/bootstrap-runtime.js +1 -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 +0 -1
- 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 +79 -0
- package/server/lib/opencode/session-runtime.test.js +43 -0
- 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/permission-auto-accept/runtime.js +38 -22
- package/server/lib/permission-auto-accept/runtime.test.js +39 -17
- package/server/lib/projects/project-config.js +2 -2
- package/server/lib/quota/DOCUMENTATION.md +4 -0
- package/server/lib/quota/providers/xai.js +4 -4
- package/server/lib/realtime-proxy-terminal.test.js +150 -0
- package/server/lib/realtime-proxy.js +2 -0
- 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 -19
- 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 +83 -76
- package/server/lib/scheduled-tasks/runtime.test.js +67 -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 -196
- 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 +137 -0
- package/server/lib/spaces/tools.test.js +153 -0
- package/server/lib/terminal/DOCUMENTATION.md +21 -2
- package/server/lib/terminal/runtime.js +10 -3
- package/server/lib/terminal/runtime.test.js +22 -0
- package/server/lib/terminal/shutdown.js +106 -0
- package/server/lib/terminal/shutdown.test.js +84 -0
- package/server/lib/tts/openai-sdk.js +11 -0
- package/server/lib/tts/service.js +7 -5
- package/server/lib/tts/service.test.js +78 -0
- 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-DkC3xlRJ.js +0 -4
- package/dist/assets/FilesView-D0bM9FVB.js +0 -13
- package/dist/assets/LinearIssuesView-UI1FcSC8.js +0 -1
- package/dist/assets/MarkdownImageGallery-CUJxH8Le.js +0 -1
- package/dist/assets/MarkdownRendererImpl-D5BZOg8X.js +0 -12
- package/dist/assets/OnboardingScreen-5Gou9cGD.js +0 -1
- package/dist/assets/PierreDiffViewer-ByRVu6ss.js +0 -161
- package/dist/assets/PlanView-u2yi5XGJ.js +0 -5
- package/dist/assets/PluginPane-QxjsKYeO.js +0 -3
- package/dist/assets/SettingsView-Fo5ZqMaT.js +0 -29
- package/dist/assets/SettingsWindow-HVDVANjJ.js +0 -1
- package/dist/assets/SubmoduleDiffSummary-D3hzkybB.js +0 -1
- package/dist/assets/ToolOutputDialog-3J6IRayW.js +0 -15
- package/dist/assets/ToolPartDiffPreview-DarxPjSd.js +0 -8
- package/dist/assets/appThemeRegistry-Cf8KitzT.js +0 -1
- package/dist/assets/de-BM_8EDD3.js +0 -10
- package/dist/assets/es-CxZjlqpo.js +0 -16
- package/dist/assets/fr-VCixCnMW.js +0 -14
- package/dist/assets/index-3U4CtS9b.js +0 -1
- package/dist/assets/index-B9Hvzjwl.css +0 -1
- package/dist/assets/index-DLHQogv8.js +0 -40
- package/dist/assets/ja-CZ5k_GyD.js +0 -16
- package/dist/assets/ko-7YM3A1Xh.js +0 -16
- package/dist/assets/main-CycplCph.js +0 -2
- package/dist/assets/main-DFYTCx5o.js +0 -896
- package/dist/assets/markdownCore-DHvqMxPn.js +0 -5
- package/dist/assets/miniChat-DIQKfY2V.js +0 -2
- package/dist/assets/mobile-BMwz5q-m.js +0 -2
- package/dist/assets/pl-BcgDO_w5.js +0 -16
- package/dist/assets/pt-BR-CU2u_1q5.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-3_d6g6CU.js +0 -2
- package/dist/assets/renderMobileApp-D0Y8DtkA.js +0 -25
- package/dist/assets/runtimeEndpointReset-DhC3REb2.js +0 -25
- package/dist/assets/scheduledTasksApi-D8pq6gQz.js +0 -1
- package/dist/assets/tr-DuYhOzNe.js +0 -7
- package/dist/assets/uk-Cuk7-uvq.js +0 -16
- package/dist/assets/useAppFontEffects-BItUWdo4.js +0 -7333
- package/dist/assets/useInlineCommentController-CkbKsm7m.js +0 -2
- package/dist/assets/useRootScrollLock-vmzxZjWA.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-CUWoiRHd.js +0 -16
- package/dist/assets/zh-TW-CQ8EBSBN.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 -820
- package/server/lib/small-model/call.test.js +0 -1110
- package/server/lib/small-model/catalog.js +0 -13
- package/server/lib/small-model/resolve.js +0 -131
- package/server/lib/small-model/resolve.test.js +0 -197
- package/server/lib/small-model/runtime-providers.js +0 -164
- package/server/lib/small-model/runtime-providers.test.js +0 -118
- package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
- package/server/lib/system-prompt/runtime.js +0 -49
- package/server/lib/system-prompt/runtime.test.js +0 -76
- package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
- /package/dist/assets/{vendor-katex-k3Ppq1Ha.js → vendor-katex-CHD9BdDO.js} +0 -0
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{R as i,f as Ye,j as t}from"./vendor-react-BUCujlKS.js";import{u as ae,O as Ce,a as Re,G as Fn}from"./index-DLHQogv8.js";import{c as Dn,b as An,u as Vn,a as En,B as Ln,C as Tn,P as Tt,h as Mn,e as Bn,g as In,i as Pn,f as zn}from"./patchFileDiff-DDQ6Rq5e.js";import{c as On,b as _n,i as Kn,u as Gn,a as Hn,d as $n,S as qn}from"./SubmoduleDiffSummary-D3hzkybB.js";import{f as ze,B as fe,I as T,h as je,Z as $t,af as Wn,K as ne,ag as Un,bg as Jn,J as Xn,ah as Yn,aj as Qn,z as Mt,k as Zn,d5 as qt,t as Je,kj as es,aw as Xe,aa as ts,ab as ns,ac as ss,k9 as Wt,kk as rs,ax as Ut,gC as is,au as Ue,av as os,c5 as Jt,aq as as,as as ls,at as cs,ap as us}from"./useAppFontEffects-BItUWdo4.js";import{f as ds,d as fs}from"./runtimeEndpointReset-DhC3REb2.js";import{P as ms}from"./PierreDiffViewer-ByRVu6ss.js";import{u as ps,v as hs,g as gs,W as xs}from"./main-DFYTCx5o.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-CZgXWHjU.js";import"./web-components-D7FinaeH.js";import"./computeVirtualFileMetrics-VYnT_A2h.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-ImDG3Uhg.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-BDyxuqK4.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-B0u3Q5uO.js";import"./PluginPane-QxjsKYeO.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-CkbKsm7m.js";import"./appThemeRegistry-Cf8KitzT.js";import"./textMateThemeFromAppTheme-Dgqc63LZ.js";import"./useRootScrollLock-vmzxZjWA.js";import"./scheduledTasksApi-D8pq6gQz.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const ys=i.memo(function(e){const s=Ye.c(13),{index:c,staged:x,busyHunk:p,disabled:y,onAction:j}=e,{t:C}=ze();let l;s[0]!==x?(l=x?["unstage"]:["discard","stage"],s[0]=x,s[1]=l):l=s[1];const b=l;let R;s[2]===Symbol.for("react.memo_cache_sentinel")?(R={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=R):R=s[2];let d;s[3]!==b||s[4]!==p||s[5]!==y||s[6]!==c||s[7]!==j||s[8]!==C?(d=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:b.map(w=>{const K=C(w==="stage"?"diffView.hunk.stageTitle":w==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:c+1}),P=p?.index===c&&p.action===w;return t.jsx(fe,{variant:"ghost",size:"xs",className:je("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:y||p!==null,title:K,"aria-label":K,onPointerDown:ws,onClick:f=>{f.stopPropagation(),j(c,w)},children:t.jsx(T,{name:P?"loader-4":w==="stage"?"add":"arrow-go-back",className:je(w==="stage"?"size-4":"size-3.5",P&&"animate-spin")})},w)})}),s[3]=b,s[4]=p,s[5]=y,s[6]=c,s[7]=j,s[8]=C,s[9]=d):d=s[9];let M;return s[10]!==c||s[11]!==d?(M=t.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:R,"data-hunk-actions":c,children:d}),s[10]=c,s[11]=d,s[12]=M):M=s[12],M});function ws(a){return a.stopPropagation()}const Bt=(a,e)=>{if(e.length===0)return null;let s=null,c=null;for(const p of e)p.top<=a?(!s||p.top>s.top)&&(s=p):(!c||p.top<c.top)&&(c=p);const x=s??c;return x?{path:x.path,topOffset:x.top-a}:null},bs=(a,e,s,c)=>Math.min(Math.max(0,c),Math.max(0,a+s-e)),It=a=>{if(!a)return null;const e=a.split(`
|
|
2
|
-
`);let s=null;for(const c of e){const x=c.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(x){const p=Number.parseInt(x[1]??"",10);s=Number.isFinite(p)&&p>=1?p:null;continue}if(s!==null){if(c.startsWith(" ")){s+=1;continue}if(c.startsWith("+"))return s;if(c.startsWith("-"))return Math.max(1,s)}}return null},js=1100,vs=15e3,Pt=500,zt=300,Xt=1e6,yt=3,ks=a=>a<=6?a:a<=12?6:a<=25?4:2,Ot={status:"loading"},Ss=3,Ns=i.memo(()=>{const a=Ye.c(4),{t:e}=ze();let s;a[0]!==e?(s=e("diffView.binary.unavailable"),a[0]=e,a[1]=s):s=a[1];let c;return a[2]!==s?(c=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})}),a[2]=s,a[3]=c):c=a[3],c}),Yt={"?":{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"}},Cs=Yt.M,Rs=a=>{const e=a.index?.trim(),s=a.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Qt=a=>{const e=Rs(a);return Yt[e]??Cs},Fs=a=>{const{index:e,working_dir:s}=a;return e==="A"||s==="A"||e==="?"||s==="?"},_t=a=>{const e=a.index?.trim();return!!(e&&e!=="?")},Kt=a=>!!a.working_dir?.trim()||a.index==="?",Ds=(a,e)=>is(a,e),Gt=a=>(a||"").replace(/\\/g,"/").replace(/\/+$/,""),Ht=(a,e)=>{const s=a.split(`
|
|
3
|
-
`),c=e.split(`
|
|
4
|
-
`),x=Math.min(s.length,c.length);for(let p=0;p<x;p+=1)if(s[p]!==c[p])return p+1;return c.length>s.length?s.length+1:s.length>c.length?Math.max(1,c.length):1},As=a=>Array.isArray(a)?a.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],Vs=a=>a==="added"?"A":a==="deleted"?"D":"M",wt=(a,e,s)=>Pn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:zn(a,e),contextMode:s},Zt=(a,e,s)=>{const c=a??0,x=e??0;return!c&&!x?null:t.jsxs("span",{className:je("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[c?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",c]}):null,x?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",x]}):null]})},Es=i.memo(a=>{const e=Ye.c(68),{scope:s,workingCount:c,stagedCount:x,turnCount:p,branchCount:y,commitCount:j,prCount:C,showCommitOption:l,showBranchOption:b,onScopeChange:R}=a,{t:d}=ze(),[M,w]=i.useState(!1),K=s==="pr"?C??0:s==="staged"?x:s==="turn"?p:s==="branch"?y??0:s==="commit"?j??0:c;let P;e[0]!==s||e[1]!==d?(P=d(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]=d,e[2]=P):P=e[2];const f=P;let me;e[3]!==d?(me=d("diffView.scope.selectorAria"),e[3]=d,e[4]=me):me=e[4];let pe;e[5]!==K?(pe=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",K]}),e[5]=K,e[6]=pe):pe=e[6];let te;e[7]!==f||e[8]!==pe?(te=t.jsxs("span",{className:"whitespace-nowrap",children:[f,pe]}),e[7]=f,e[8]=pe,e[9]=te):te=e[9];let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(T,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=v):v=e[10];let E;e[11]!==me||e[12]!==te?(E=t.jsx(as,{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":me,children:[te,v]})}),e[11]=me,e[12]=te,e[13]=E):E=e[13];let k;e[14]!==R?(k=Q=>{(Q==="working"||Q==="staged"||Q==="turn"||Q==="branch"||Q==="commit"||Q==="pr")&&(R?.(Q),w(!1))},e[14]=R,e[15]=k):k=e[15];let se;e[16]!==d?(se=d("diffView.scope.changed"),e[16]=d,e[17]=se):se=e[17];let J;e[18]!==se?(J=t.jsx("span",{children:se}),e[18]=se,e[19]=J):J=e[19];let le;e[20]!==c?(le=t.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),e[20]=c,e[21]=le):le=e[21];let re;e[22]!==le||e[23]!==J?(re=t.jsx(Ue,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[J,le]})}),e[22]=le,e[23]=J,e[24]=re):re=e[24];let ce;e[25]!==d?(ce=d("diffView.scope.staged"),e[25]=d,e[26]=ce):ce=e[26];let X;e[27]!==ce?(X=t.jsx("span",{children:ce}),e[27]=ce,e[28]=X):X=e[28];let $;e[29]!==x?($=t.jsx("span",{className:"typography-meta text-muted-foreground",children:x}),e[29]=x,e[30]=$):$=e[30];let ue;e[31]!==X||e[32]!==$?(ue=t.jsx(Ue,{value:"staged",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[X,$]})}),e[31]=X,e[32]=$,e[33]=ue):ue=e[33];let B;e[34]!==d?(B=d("diffView.scope.lastTurn"),e[34]=d,e[35]=B):B=e[35];let D;e[36]!==B?(D=t.jsx("span",{children:B}),e[36]=B,e[37]=D):D=e[37];let q;e[38]!==p?(q=t.jsx("span",{className:"typography-meta text-muted-foreground",children:p}),e[38]=p,e[39]=q):q=e[39];let G;e[40]!==D||e[41]!==q?(G=t.jsx(Ue,{value:"turn",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[D,q]})}),e[40]=D,e[41]=q,e[42]=G):G=e[42];let de;e[43]!==y||e[44]!==b||e[45]!==d?(de=b?t.jsx(Ue,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:y??"…"})]})}):null,e[43]=y,e[44]=b,e[45]=d,e[46]=de):de=e[46];let Y;e[47]!==j||e[48]!==l||e[49]!==d?(Y=l&&t.jsx(Ue,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}),e[47]=j,e[48]=l,e[49]=d,e[50]=Y):Y=e[50];let L;e[51]!==C||e[52]!==l||e[53]!==d?(L=l&&t.jsx(Ue,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("session.githubIntegration.tabs.pullRequests")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:C??"…"})]})}),e[51]=C,e[52]=l,e[53]=d,e[54]=L):L=e[54];let W;e[55]!==s||e[56]!==re||e[57]!==ue||e[58]!==G||e[59]!==de||e[60]!==Y||e[61]!==L||e[62]!==k?(W=t.jsx(ls,{align:"start",className:"w-40",children:t.jsxs(cs,{value:s,onValueChange:k,children:[re,ue,G,de,Y,L]})}),e[55]=s,e[56]=re,e[57]=ue,e[58]=G,e[59]=de,e[60]=Y,e[61]=L,e[62]=k,e[63]=W):W=e[63];let ve;return e[64]!==M||e[65]!==W||e[66]!==E?(ve=t.jsxs(us,{open:M,onOpenChange:w,children:[E,W]}),e[64]=M,e[65]=W,e[66]=E,e[67]=ve):ve=e[67],ve}),Ls=i.memo(a=>{const e=Ye.c(11),{changedFiles:s,selectedFile:c,onSelectFile:x}=a,{t:p}=ze();if(s.length===0)return null;let y;if(e[0]!==s||e[1]!==x||e[2]!==c||e[3]!==p){let C;e[5]!==x||e[6]!==c||e[7]!==p?(C=l=>{const b=Qt(l),R=c===l.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>x(l.path),className:je("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",R?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(Ut,{filePath:l.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:b.color},title:p(b.descriptionKey),"aria-label":p(b.descriptionKey),children:b.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:l.path,children:l.path}),Zt(l.insertions,l.deletions)]})},l.path)},e[5]=x,e[6]=c,e[7]=p,e[8]=C):C=e[8],y=s.map(C),e[0]=s,e[1]=x,e[2]=c,e[3]=p,e[4]=y}else y=e[4];let j;return e[9]!==y?(j=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:y})}),e[9]=y,e[10]=j):j=e[10],j}),Ts=i.memo(a=>{const e=Ye.c(20),{filePath:s,diff:c,renderSideBySide:x}=a,{t:p}=ze(),y=c.original.length>0,j=c.modified.length>0,C=x?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",l=x?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={contain:"layout"},e[0]=b):b=e[0];let R;e[1]!==c.original||e[2]!==s||e[3]!==y||e[4]!==l||e[5]!==x||e[6]!==p?(R=y&&t.jsxs("div",{className:l,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p("diffView.image.original")}),t.jsx("img",{src:c.original,alt:p("diffView.image.originalAlt",{path:s}),className:x?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=c.original,e[2]=s,e[3]=y,e[4]=l,e[5]=x,e[6]=p,e[7]=R):R=e[7];let d;e[8]!==c.modified||e[9]!==s||e[10]!==j||e[11]!==y||e[12]!==l||e[13]!==x||e[14]!==p?(d=j&&t.jsxs("div",{className:l,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:p(y?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:c.modified,alt:p("diffView.image.modifiedAlt",{path:s}),className:x?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=c.modified,e[9]=s,e[10]=j,e[11]=y,e[12]=l,e[13]=x,e[14]=p,e[15]=d):d=e[15];let M;return e[16]!==C||e[17]!==R||e[18]!==d?(M=t.jsx("div",{className:"w-full overflow-auto p-4",style:b,children:t.jsxs("div",{className:C,children:[R,d]})}),e[16]=C,e[17]=R,e[18]=d,e[19]=M):M=e[19],M}),Ms=i.memo(a=>{const e=Ye.c(20),{filePath:s,diff:c,staged:x,renderSideBySide:p,wrapLines:y,hunkActions:j}=a;let C;e[0]!==s?(C=os(s)||"text",e[0]=s,e[1]=C):C=e[1];const l=C;if(c.submodule){let d;return e[2]!==c.submodule||e[3]!==x?(d=t.jsx(qn,{state:c.submodule,staged:x}),e[2]=c.submodule,e[3]=x,e[4]=d):d=e[4],d}if(c.isBinary){let d;return e[5]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(Ns,{}),e[5]=d):d=e[5],d}if(Xe(s)){let d;return e[6]!==c||e[7]!==s||e[8]!==p?(d=t.jsx(Ts,{filePath:s,diff:c,renderSideBySide:p}),e[6]=c,e[7]=s,e[8]=p,e[9]=d):d=e[9],d}let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b={contain:"layout"},e[10]=b):b=e[10];let R;return e[11]!==c.fileDiff||e[12]!==c.modified||e[13]!==c.original||e[14]!==s||e[15]!==j||e[16]!==l||e[17]!==p||e[18]!==y?(R=t.jsx("div",{className:"w-full",style:b,children:t.jsx(ms,{original:c.original,modified:c.modified,fileDiff:c.fileDiff,language:l,fileName:s,renderSideBySide:p,wrapLines:y,layout:"inline",hunkActions:j})}),e[11]=c.fileDiff,e[12]=c.modified,e[13]=c.original,e[14]=s,e[15]=j,e[16]=l,e[17]=p,e[18]=y,e[19]=R):R=e[19],R}),Bs=i.memo(({visible:a=!0,directory:e,file:s,layout:c,wrapLines:x,isSelected:p,isExpanded:y,isMounted:j,onSelect:C,onExpandedChange:l,registerSectionRef:b,showOpenInEditorAction:R=!1,isOpeningInEditor:d=!1,onOpenInEditor:M,staged:w=!1,loadFullFiles:K=!1,initialDiffData:P=null,comparisonDiff:f,onRetryComparisonDiff:me,readOnlyActions:pe=!1,hunkActionsEnabled:te=!1})=>{const{t:v}=ze(),{git:E}=$t(),k=ne(i.useCallback(g=>g.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),se=ne(g=>g.setDiff),J=ne(g=>g.fetchStatus),le=ae(g=>g.setDiffFileLayout),[re,ce]=i.useState(0),[X,$]=i.useState(null),[ue,B]=i.useState(!1),D=i.useMemo(()=>f?f.status==="error"?{kind:"error",message:f.message}:null:X,[f,X]),q=f?f.status==="loading":ue,[G,de]=i.useState(null),Y=i.useRef(!1),[L,W]=i.useState(null),[ve,Q]=i.useState(!1),[ie,Qe]=i.useState(null),[lt,Fe]=i.useState(null),he=i.useRef(null),mt=i.useRef(null),Oe=i.useMemo(()=>Qt(s),[s]),_e=c==="side-by-side",De=K?"full":"patch",ge=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,o=te&&!pe&&!P&&!f&&!Xe(s.path),xe=JSON.stringify([Re(),e,s.path,w,ge,re]),z=L?.scope===xe?L.patch:null,Ze=L?.scope===xe?L.submodule:null,U=i.useMemo(()=>f?f.status==="ready"?f.data:null:P||(w?lt:ie||(k?{original:k.original,modified:k.modified,isBinary:k.isBinary,submodule:k.submodule,contextMode:"full"}:null)),[f,k,P,ie,w,lt]),et=U?.contextMode===De,tt=i.useCallback(g=>{mt.current=g,b(s.path,g)},[s.path,b]),nt=i.useCallback(g=>{l(s.path,g)},[s.path,l]),st=i.useCallback(()=>{C(s.path)},[s.path,C]),rt=i.useRef({fileStatusKey:ge,staged:w});i.useEffect(()=>{if(!a)return;const g=rt.current;g.fileStatusKey===ge&&g.staged===w||(rt.current={fileStatusKey:ge,staged:w},w?Fe(null):Qe(null),$(null),he.current=null)},[ge,w,a]),i.useEffect(()=>{if(!a||!y||!j||X)return;if(!e||f||P||U&&et&&(!o||z!==null)){he.current=null,B(!1);return}const g=`${e}::${s.path}::${w?"staged":"unstaged"}::${ge}::${De}::${re}`;if(he.current===g)return;he.current=g,$(null),B(!0);let O=!1;const ye=Re(),Ge=K?Xt:yt,Z=Xe(s.path)?E.getGitFileDiff(e,{path:s.path,staged:w}):!K&&z!==null?Promise.resolve({diff:z,submodule:Ze}):E.getGitDiff(e,{path:s.path,staged:w,contextLines:Ge}),Ve=o&&K&&z===null?E.getGitDiff(e,{path:s.path,staged:w,contextLines:yt}).then(S=>S.diff):Promise.resolve(z),Ie=Promise.all([Z,Ve]),we=vs;let _;const Ee=new Promise((S,He)=>{_=setTimeout(()=>He(new Error(`Timed out after ${we}ms`)),we)});return Promise.race([Ie,Ee]).then(([S,He])=>{if(O||ye!==Re())return;const be="diff"in S&&!K?S.diff:He;if(o&&K&&be!==null&&/^@@\s/m.test(be)&&"diff"in S&&S.diff!==be&&!Mn(S.diff,be))throw W(null),new Error(v("diffView.hunk.unavailable"));if(o&&be!==null&&W({scope:xe,patch:be,submodule:S.submodule}),"diff"in S){const Se={...wt(s.path,S.diff,De),submodule:S.submodule};w?Fe(Se):Qe(Se)}else{const Se={original:S.original??"",modified:S.modified??"",isBinary:S.isBinary,submodule:S.submodule,contextMode:"full"};w?Fe(Se):se(e,s.path,Se,ye)}B(!1)}).catch(S=>{if(!(O||ye!==Re())){if(B(!1),S instanceof Fn){$({kind:"unavailable",reason:S.reason}),S.reason==="path_not_found"&&J(e,E,{force:!0,silent:!0});return}$({kind:"error",message:S instanceof Error?S.message:String(S)})}}).finally(()=>clearTimeout(_)),()=>{O=!0,clearTimeout(_),he.current===g&&(he.current=null)}},[z,Ze,o,xe,f,De,U,et,re,e,J,s.path,ge,E,P,y,j,K,X,se,w,v,a]);const ct=i.useCallback(()=>{nt(!y),st()},[nt,st,y]),Ae=i.useCallback(()=>{$(null),W(null),Qe(null),Fe(null),he.current=null,ce(g=>g+1)},[]),ke=i.useCallback(async(g,O)=>{if(!e||!o||q||D||Y.current||G!==null)return;const ye=z?Bn(z,g):null;if(!ye){Je.error(v("diffView.hunk.unavailable"));return}if(w&&O!=="unstage"||!w&&O==="unstage")return;Y.current=!0;const Ge=Re();de({index:g,action:O});try{const Z=O==="stage"?E.stageGitHunk:O==="unstage"?E.unstageGitHunk:E.revertGitHunk;if(!Z){Je.error(v("diffView.hunk.unsupported"));return}if(await Z(e,s.path,ye),Ge!==Re())return;Ae(),qt.requestGitRefresh({directory:e,paths:[s.path]}),await J(e,E)}catch(Z){if(Ge!==Re())return;Ae(),Je.error(Z instanceof Error&&Z.message?Z.message:v("diffView.hunk.unavailable"))}finally{Y.current=!1,de(Z=>Z?.index===g&&Z.action===O?null:Z)}},[z,o,q,D,e,J,s.path,E,G,Ae,w,v]),Be=i.useMemo(()=>o&&z!==null?In(z):[],[z,o]),Ke=i.useCallback(g=>t.jsx(ys,{index:g,staged:w,busyHunk:G,disabled:q||!!D,onAction:ke}),[D,ke,G,q,w]),it=i.useMemo(()=>Be.length>0?{anchors:Be,render:Ke}:void 0,[Be,Ke]);return t.jsxs("div",{ref:tt,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:ct,onKeyDown:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),ct())},className:je("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:y?t.jsx(T,{name:"arrow-down-s",className:"size-4"}):t.jsx(T,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Oe.color},title:v(Oe.descriptionKey),"aria-label":v(Oe.descriptionKey),children:Oe.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(Ut,{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 O=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:O}),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:[Zt(s.insertions,s.deletions),R&&M?t.jsx(fe,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:v("diffView.actions.openFileInEditorAtChange"),onClick:g=>{g.stopPropagation(),M(s.path,U)},disabled:d,children:d?t.jsx(T,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(T,{name:"edit",className:"size-3.5"})}):null,t.jsx(Wt,{mode:_e?"side-by-side":"unified",onModeChange:g=>{const O=g==="side-by-side"?"side-by-side":"inline";le(s.path,O)},className:"opacity-70"})]})]})}),y&&t.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!j&&!D?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,D?.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:D.reason==="nested_repository"?v("diffView.unavailable.nestedRepositoryTitle"):D.reason==="untracked_directory"?v("diffView.unavailable.untrackedDirectoryTitle"):v("diffView.unavailable.missingTitle")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:D.reason==="nested_repository"?v("diffView.unavailable.nestedRepositoryDescription"):D.reason==="untracked_directory"?v("diffView.unavailable.untrackedDirectoryDescription"):v("diffView.unavailable.missingDescription")}),D.reason==="path_not_found"?t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:Ae,children:v("diffView.actions.retry")}):null]}):null,D?.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:v("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:D.message}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>f?me?.():Ae(),children:v("diffView.actions.retry")})]}):null,j&&q&&!U&&!D?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),v("diffView.state.loadingDiff")]}):null,j&&U&&!ve&&s.insertions+s.deletions>Pt?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:v("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:v("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Q(!0),children:v("diffView.actions.renderAnyway")})]}):null,j&&U&&(ve||s.insertions+s.deletions<=Pt)?t.jsx(t.Fragment,{children:t.jsx(Ms,{filePath:s.path,diff:U,staged:w,renderSideBySide:_e,wrapLines:x,hunkActions:it})}):null]})]})}),to=({visible:a=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:c=!1,showOpenInEditorAction:x=!1,diffScope:p="all",onDiffScopeChange:y,targetFilePath:j=null,flushContent:C=!1})=>{const{t:l}=ze(),{git:b,files:R}=$t(),d=Wn(),M=ne(n=>n.runtimeKey),{rootIsGitRepo:w,gitDirectory:K,nestedRepos:P}=Un(d??null,{enabled:a}),f=K??d,me=ae(n=>n.openContextSurface),pe=ps(n=>n.requestSource),{screenWidth:te,isMobile:v}=Jn(),E=Xn(f??null),k=Yn(f??null),se=Qn(f??null),J=ne(n=>n.setActiveDirectory),le=ne(n=>n.ensureStatus),re=ne(n=>n.selectNestedRepo),ce=ne(n=>n.fetchStatus),X=ne(n=>n.fetchBranches),$=ne(n=>n.clearDiffCache),ue=ne(n=>n.setDiff),[B,D]=i.useState(null),[q,G]=i.useState(!1),[de,Y]=i.useState(null),[L,W]=i.useState(()=>new Set),[ve,Q]=i.useState(()=>new Set),[ie,Qe]=i.useState(!1),[lt,Fe]=i.useState(0),[he,mt]=i.useState(()=>new Map),[Oe,_e]=i.useState(!1),[De,ge]=i.useState(!1),[o,xe]=i.useState(p);i.useEffect(()=>{xe(p)},[p]);const z=ae(n=>n.pendingDiffFile),Ze=ae(n=>n.pendingDiffStaged),U=ae(n=>n.pendingDiffScope),et=ae(n=>n.setPendingDiffFile),tt=ae(n=>n.diffLayoutPreference),nt=ae(n=>n.diffFileLayout),st=ae(n=>n.setDiffFileLayout),rt=ae(n=>n.diffWrapLines),ct=ae(n=>n.setDiffWrapLines),Ae=ae(n=>n.openContextFileAtLine),ke=Mt(n=>n.currentSessionId),Be=Zn(o==="turn"?ke??"":"",d??void 0),Ke=rt,it=o==="staged"?!0:o==="working"?!1:null,g=it??q,O=v||te<=768,ye=!!ke&&o!=="turn"&&o!=="commit"&&o!=="pr"&&!O&&!Ce(),Ge=o!=="turn"&&!O&&!Ce(),Z=!e&&!O&&te>=1024,Ve=i.useRef(null),Ie=i.useRef(new Map),we=i.useRef(null),_=i.useRef(null),Ee=i.useRef(!1),S=i.useRef(null),He=i.useRef(null),be=i.useRef(null),Se=i.useRef(null),bt=i.useCallback(()=>{const n=Ve.current;if(!n)return null;const r=n.getBoundingClientRect().top,m=[];for(const[u,h]of Ie.current)h&&m.push({path:u,top:h.getBoundingClientRect().top});return Bt(r,m)},[]),$e=i.useCallback(()=>{we.current=null,Ee.current=!1,Y(null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)},[]),qe=i.useCallback(n=>{W(r=>{if(r.has(n))return r;const m=new Set(r);return m.add(n),m})},[]),ot=i.useMemo(()=>{for(let n=Be.length-1;n>=0;n-=1){const r=Be[n];if(r.role==="user")return As(r.summary?.diffs)}return[]},[Be]),en=i.useMemo(()=>{const n=new Map;for(const r of ot)if(r.file){if(typeof r.patch=="string"){n.set(r.file,wt(r.file,r.patch,"patch"));continue}n.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return n},[ot]),tn=i.useMemo(()=>k?.files?k.files.filter(Kt).length:0,[k]),nn=i.useMemo(()=>k?.files?k.files.filter(_t).length:0,[k]),sn=ot.length,H=k?.current??null,Le=Dn(f??null,H,a&&o==="pr"&&!Ce()),Te=Le.selectedSource,Me=An(f??null,H,a&&o==="commit"&&!Ce()),Pe=Me.selectedCommit?.hash??null;i.useEffect(()=>{(o==="commit"||o==="pr")&&Ce()&&(xe("working"),y?.("working"))},[o,y]);const We=ne(n=>f?n.directories.get(f)?.branches??null:null),rn=ne(n=>f?n.directories.get(f)?.isLoadingBranches??!1:!1),on=i.useCallback(()=>{f&&X(f,b)},[f,X,b]),an=On(f??null,a&&E!==!1,rn,!!We,on,Ss),jt=i.useMemo(()=>{const n=k?.tracking?.trim().split("/")[0];return(n&&We?.defaultBranches?.[n])??We?.defaultBranches?.origin??null},[We,k?.tracking]),vt=!Ce()&&_n(H,jt),ln=k!==null,kt=Ce()||an||Kn(H,jt,ln,We!==null),cn=Vn(n=>n.setOverride),{base:Ne,resolved:un,revision:St}=En(f??null,H,a&&vt&&o==="branch"),[dn,fn]=i.useState(0);i.useEffect(()=>{const n=$n(o,!kt);n!==o&&(xe(n),n==="working"&&y?.("working"))},[o,kt,y]);const mn=i.useMemo(()=>o==="pr"?Te:o==="commit"&&Pe?{kind:"commit",hash:Pe}:o==="branch"&&Ne&&H?{kind:"branch",baseRef:Ne,headRef:H}:null,[o,Ne,H,Pe,Te]),V=Gn(f??null,mn,a&&!Ce(),o==="branch"?St:""),{fetchDiff:Nt}=V,Ct=o==="commit"?V.files:null,Rt=o==="commit"?V.error:null,ut=o==="branch"?V.files:null,Ft=o==="branch"?V.error:null,Dt=V.files?o==="pr"?JSON.stringify([V.key,V.revision]):V.key:null,pn=i.useMemo(()=>o==="branch"||o==="commit"||o==="pr"?Array.from(L).sort().join("\0"):"",[o,L]),hn=i.useCallback(async n=>{try{const r=ie&&o!=="pr",m=await Nt(n,r?Xt:yt);return{status:"ready",data:wt(n,m.diff,r?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:l("diffView.state.failedToLoadDiff")}}},[o,Nt,ie,l]),gn=Hn(Dt,a?pn:"",Dt?hn:null,Ot,JSON.stringify([o==="branch"?St:"",o==="pr"?V.revision:0,dn,ie])),xn=ut?.length??null,N=i.useMemo(()=>{if(o==="commit"||o==="pr")return(V.files??[]).map(u=>({path:u.path,index:"",working_dir:u.status,insertions:u.insertions,deletions:u.deletions,isNew:u.status==="A"}));if(o==="branch")return(ut??[]).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(o==="turn")return ot.map(u=>({path:u.file??"",index:"",working_dir:Vs(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(!k?.files)return[];const n=k.diffStats,r=o==="staged"?_t:o==="working"?Kt:()=>!0,m=u=>{const h=n?.staged?.[u],A=n?.working?.[u];return o==="staged"?{insertions:h?.insertions??0,deletions:h?.deletions??0}:o==="working"?{insertions:A?.insertions??0,deletions:A?.deletions??0}:{insertions:(h?.insertions??0)+(A?.insertions??0),deletions:(h?.deletions??0)+(A?.deletions??0)}};return k.files.filter(r).map(u=>{const h=m(u.path);return{...u,insertions:h.insertions,deletions:h.deletions,isNew:Fs(u)}}).sort((u,h)=>u.path.localeCompare(h.path))},[o,ut,V.files,ot,k]),pt=i.useMemo(()=>N.map(n=>n.path).join("\0"),[N]);i.useEffect(()=>{const n=pt?pt.split("\0"):[],r=new Set(n),m=`${f??""}:${o}:${s?"collapsed":"default"}`,u=He.current!==m;He.current=m,W(h=>{if(u){const I=s?0:ks(n.length);return new Set(n.slice(0,I))}let A=!1;const F=new Set;for(const I of h){if(!r.has(I)){A=!0;continue}F.add(I)}return A?F:h}),Q(h=>{if(u)return new Set;let A=!1;const F=new Set;for(const I of h){if(!r.has(I)){A=!0;continue}F.add(I)}return A?F:h})},[o,pt,f,s]);const At=i.useCallback(()=>{if(S.current=null,!a)return;const n=Ve.current;if(!n)return;const r=n.getBoundingClientRect(),m=r.top-zt,u=r.bottom+zt,h={},A=[];for(const[F,I]of Ie.current){if(!I)continue;const ee=I.getBoundingClientRect();A.push({path:F,top:ee.top}),L.has(F)&&(ee.bottom<m||ee.top>u||(h[F]=!0))}be.current=Bt(r.top,A),Q(F=>{let I=!1;const ee=new Set(F);for(const at of Object.keys(h))ee.has(at)||(ee.add(at),I=!0);return I?ee:F})},[L,a]),oe=i.useCallback(()=>{a&&(typeof window>"u"||S.current===null&&(S.current=window.requestAnimationFrame(At)))},[At,a]);i.useEffect(()=>{const n=Ve.current;if(!(!a||!n))return oe(),n.addEventListener("scroll",oe,{passive:!0}),window.addEventListener("resize",oe),()=>{n.removeEventListener("scroll",oe),window.removeEventListener("resize",oe),S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null)}},[N,L,oe,a]);const ht=i.useCallback(n=>{const r=nt[n.path];if(r)return r;if(tt==="inline")return"inline";if(tt==="side-by-side")return"side-by-side";const m=te<js;return n.isNew||m?"inline":"side-by-side"},[nt,tt,te]),Vt=i.useMemo(()=>N.length===0?null:N.every(n=>ht(n)==="side-by-side")?"side-by-side":"inline",[N,ht]);i.useEffect(()=>{a&&f&&(J(f),le(f,b))},[f,J,le,b,a]);const dt=JSON.stringify([M,f]),gt=i.useRef({scope:dt,paths:new Set,dirty:!1}),Et=i.useRef(a);i.useEffect(()=>{const n=a&&!Et.current;if(Et.current=a,gt.current.scope!==dt&&(gt.current={scope:dt,paths:new Set,dirty:!1}),!f)return;const r=u=>{u?.length&&(Se.current=bt()??be.current,$(f,u),mt(h=>{const A=new Map(h);for(const F of u)A.set(F,(A.get(F)??0)+1);return A})),ce(f,b,{silent:!0})},m=gt.current;return a&&(n||m.dirty)&&(r([...m.paths]),m.paths.clear(),m.dirty=!1),qt.onGitRefreshHint(u=>{if(Gt(u.directory)===Gt(f)){if(!a){m.dirty=!0;for(const h of u.paths??[])m.paths.add(h);return}r(u.paths)}})},[bt,$,f,ce,b,dt,a]),i.useLayoutEffect(()=>{const n=Se.current;if(!n)return;Se.current=null;const r=Ve.current,m=Ie.current.get(n.path);if(!r||!m)return;const u=r.getBoundingClientRect().top,h=m.getBoundingClientRect().top-u;r.scrollTop=bs(r.scrollTop,n.topOffset,h,r.scrollHeight-r.clientHeight),be.current=n},[he]),i.useEffect(()=>{!a||o!=="all"&&!U||z&&(U&&xe(U),D(z),G(U==="staged"||!U&&Ze),et(null),Ee.current=!0,we.current=z,qe(z),Fe(n=>n+1))},[o,qe,z,U,Ze,et,a]),i.useEffect(()=>{if(o==="all")return;const n=j?.trim();n&&(D(n),G(o==="staged"),Ee.current=!0,we.current=n,qe(n),Fe(r=>r+1))},[o,qe,j]),i.useEffect(()=>{if(!B)return;N.some(r=>r.path===B)||(D(null),G(!1))},[N,B]);const yn=i.useCallback((n,r)=>{const m=Ie.current;r?m.set(n,r):m.delete(n),oe()},[oe]),wn=i.useCallback((n,r)=>{$e(),W(m=>{const u=m.has(n);if(r===u)return m;const h=new Set(m);return r?h.add(n):h.delete(n),h}),r||Q(m=>{if(!m.has(n))return m;const u=new Set(m);return u.delete(n),u}),oe()},[$e,oe]),bn=i.useCallback(()=>{$e(),W(n=>n.size>0?new Set:new Set(N.map(r=>r.path))),Q(new Set),oe()},[$e,N,oe]),jn=i.useCallback(async n=>{if(!ke)return;const r=Mt.getState().getDirectoryForSession(ke)||d||"";if(!r){Je.error(l("diffView.reviewDialog.toast.noSessionDirectory"));return}ge(!0);try{await es({originalSessionID:ke,directory:r,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}),_e(!1)}catch(m){console.error("[review-flow] failed to start review flow",m),Je.error(m instanceof Error?m.message:l("diffView.reviewDialog.toast.startFailed"))}finally{ge(!1)}},[ke,d,l]),ft=i.useCallback(n=>{const r=Ie.current.get(n),m=Ve.current;if(!r||!m)return!1;const u=r.getBoundingClientRect().top-m.getBoundingClientRect().top;return m.scrollTo({top:m.scrollTop+u,behavior:"auto"}),!0},[]);i.useEffect(()=>{const n=we.current;if(!a||!n)return;let r=0;const m=20;let u=!1;const h=(F=!0)=>{u||(u=!0,we.current=null,Ee.current=!1,F&&Y(null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null))},A=()=>{if(u){_.current=null;return}const F=we.current;if(!F){h(),_.current=null;return}if(!ft(F)){r+=1,r<m?_.current=window.requestAnimationFrame(A):(h(),_.current=null);return}if(c&&Ee.current){Y(F),h(!1);return}h()};return _.current=window.requestAnimationFrame(A),()=>{u=!0,_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)}},[c,lt,ft,a]);const vn=i.useCallback(n=>{},[]),xt=i.useCallback(n=>{$e(),D(n),G(!1),Ee.current=!0,we.current=n,qe(n),Fe(r=>r+1),ft(n)},[$e,qe,ft]);i.useEffect(()=>{const n=r=>{if(!a||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const m=r.target;if(m instanceof HTMLElement&&(m.isContentEditable||m.tagName==="INPUT"||m.tagName==="TEXTAREA"||m.closest('[role="dialog"]'))||N.length===0)return;const u=r.key==="ArrowDown"?1:-1,h=B?N.findIndex(I=>I.path===B):-1,A=h===-1?u>0?0:N.length-1:h+u,F=N[A];F&&(r.preventDefault(),xt(F.path))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[N,B,xt,a]);const kn=i.useCallback(n=>{const r=n==="side-by-side"?"side-by-side":"inline";N.forEach(m=>{st(m.path,r)})},[N,st]),[Sn,Lt]=i.useState(null),Nn=i.useCallback(async(n,r)=>{if(!f||!n)return;Lt(n);const m=Re();try{let u=null;if(r?.patch&&!r.isBinary&&!Xe(n)?u=It(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Xe(n)&&(u=Ht(r.original,r.modified)),u===null)try{const ee=await b.getGitDiff(f,{path:n,staged:g,contextLines:3});u=It(ee.diff)}catch{u=null}let h=r;if(u===null||!h){const ee=await b.getGitFileDiff(f,{path:n,staged:g}),at={original:ee.original??"",modified:ee.modified??"",isBinary:ee.isBinary,submodule:ee.submodule};h=at,g||ue(f,n,at,m)}const A=u??(h.isBinary||Xe(n)?1:Ht(h.original,h.modified)),F=Ds(f,n),I=await hs(R,F,{directory:f});if(!I.ok){Je.error(gs(I.reason));return}Ae(f,F,A,1)}finally{Lt(u=>u===n?null:u)}},[g,f,R,b,Ae,ue]),Cn=()=>{if(!f)return null;const n=r=>it!==null?it:q&&r===B;return t.jsxs("div",{className:je("flex min-w-0 flex-1 min-h-0 h-full",C?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Z&&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:l("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),t.jsx(Ls,{changedFiles:N,selectedFile:null,onSelectFile:xt})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsx(Jt,{ref:Ve,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(r=>t.jsx(Bs,{visible:a,directory:f,file:r,layout:ht(r),wrapLines:Ke,isSelected:!1,isExpanded:L.has(r.path),isMounted:ve.has(r.path)||r.path===de,onSelect:vn,onExpandedChange:wn,registerSectionRef:yn,showOpenInEditorAction:x&&o!=="turn",isOpeningInEditor:Sn===r.path,onOpenInEditor:(m,u)=>{Nn(m,u)},staged:n(r.path),loadFullFiles:ie&&o!=="pr",readOnlyActions:o==="branch"||o==="commit"||o==="pr",hunkActionsEnabled:o==="all"||o==="working"||o==="staged",comparisonDiff:o==="branch"||o==="commit"||o==="pr"?gn.get(r.path)??Ot:void 0,onRetryComparisonDiff:()=>fn(m=>m+1),initialDiffData:o==="turn"?en.get(r.path)??null:null},`${Re()}:${f}:${r.path}:${he.get(r.path)??0}`))})})})]})},Rn=()=>{if(!f)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l("diffView.state.selectSessionDirectory")});if(o!=="turn"&&se&&!k)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingRepositoryStatus")]});if(o!=="turn"&&E===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:l("diffView.state.notGitRepository")});if(o==="pr"){if(!Te||V.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:V.error??Le.error??(Le.loading?l("session.githubPrPicker.loading.pullRequests"):l("pullRequestComparison.select"))}),(V.error||Le.error)&&t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{Te?V.refresh():Le.refresh()},children:l("diffView.actions.retry")}),!Te&&!Le.loading&&t.jsx(Tt,{comparison:Le})]});if(!V.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingDiff")]})}if(o==="commit"){if(Rt)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:Rt}),t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{V.refresh()},children:l("diffView.actions.retry")})]});if(!Pe&&!Me.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Me.error??l("commitComparison.noCommits")});if(!Ct)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.state.loadingDiff")]})}if(o==="branch"){if(!un)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.branch.resolvingBase")]});if(!Ne)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(T,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:l("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:l("gitView.pr.toast.baseBranchRequired")})]});if(Ft)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:l("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ft}),t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{V.refresh()},children:l("diffView.actions.retry")})]});if(ut===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}),l("diffView.branch.loadingFiles")]})}return N.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:o==="turn"?l("diffView.state.noLastTurnChanges"):o==="pr"?l("walkthrough.blocked.emptyDiff.description"):o==="commit"?l("commitComparison.emptyDiff"):o==="branch"&&Ne?l("diffView.branch.empty",{base:fs(Ne)}):l("diffView.state.cleanWorkingTree")}):Cn()};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(ds,{repositories:P,selectedRepository:K??null,onSelectRepository:n=>{d&&re(d,n)},repositoryRoot:d??void 0}):null,!v&&(o!=="all"?t.jsx(Es,{scope:o,workingCount:tn,stagedCount:nn,turnCount:sn,branchCount:xn,commitCount:o==="commit"?Ct?.length??null:null,prCount:o==="pr"?V.files?.length??null:null,showCommitOption:!Ce(),showBranchOption:vt,onScopeChange:n=>{xe(n),y?.(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:se&&!k?l("diffView.state.loadingChanges"):N.length===1?l("diffView.summary.changedFilesSingle",{count:N.length}):l("diffView.summary.changedFilesPlural",{count:N.length})})})),o==="branch"&&t.jsx(Ln,{branches:We?.all??[],currentBranch:H,base:Ne,onSelect:n=>{f&&H&&cn(f,H,n)}},JSON.stringify([f,H])),o==="commit"&&t.jsx(Tn,{commits:Me.commits,selectedHash:Pe,loading:Me.loading,error:Me.error,onSelect:Me.select,onRefresh:()=>{Me.refresh()}},JSON.stringify([f,H])),o==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{comparison:Le},JSON.stringify([M,f,H])),Te&&t.jsx(fe,{variant:"ghost",size:"sm",disabled:V.loading,"aria-label":l("session.githubIssuePicker.actions.refresh"),title:l("session.githubIssuePicker.actions.refresh"),onClick:()=>{V.refresh()},children:t.jsx(T,{name:"refresh",className:"size-4"})})]}),N.length>0&&t.jsxs(fe,{variant:"ghost",size:"sm",onClick:bn,className:je("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:L.size>0?l("diffView.actions.collapseAll"):l("diffView.actions.expandAll"),children:[t.jsx(T,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:L.size>0?l("diffView.actions.collapseAll"):l("diffView.actions.expandAll")})]}),N.length>0&&ye&&t.jsxs(fe,{variant:"default",size:"sm",onClick:()=>_e(!0),disabled:De,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":l("diffView.actions.reviewAria"),children:[De?t.jsx(T,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(T,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:l("diffView.actions.review")})]}),N.length>0&&Ge&&t.jsxs(fe,{variant:"outline",size:"sm",onClick:()=>{const n=f??"";pe(n,o==="pr"&&Te?Te:o==="commit"&&Pe?{kind:"commit",hash:Pe}:o==="branch"&&Ne&&H?{kind:"branch",baseRef:Ne,headRef:H}:{kind:"working-tree",scope:o==="staged"||o==="working"?o:"all"}),me(d??n,"walkthrough")},className:je("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",xs),"aria-label":l("walkthrough.action.open"),children:[t.jsx(T,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:l("walkthrough.action.open")})]}),N.length>0&&o!=="pr"&&t.jsxs(ts,{children:[t.jsx(ns,{asChild:!0,children:t.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>Qe(n=>!n),"aria-pressed":ie,"aria-label":l(ie?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:je("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",ie&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(T,{name:"file-download",className:"size-4"})})}),t.jsx(ss,{children:t.jsx("p",{children:l(ie?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&t.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>ct(!rt),className:je("h-5 w-5 p-0 transition-opacity",Ke?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:l(Ke?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(T,{name:"text-wrap",className:"size-4"})}),Vt&&t.jsx(Wt,{mode:Vt==="side-by-side"?"side-by-side":"unified",onModeChange:kn})]}),t.jsx(rs,{open:Oe,onOpenChange:_e,projectDirectory:f??null,submitting:De,onConfirm:jn}),Rn()]})};export{to as DiffView,Bs 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 Ye,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 Ya,a3 as Za,dN as Qa}from"./index-DLHQogv8.js";import{f as tr,z as si,af as Si,cc as eo,h as K,jZ as to,g0 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,cx as lo,eM as ii,j_ as ai,j$ as co,i7 as uo,gc as fo,t as J,l as oi,av as Cn,cq as pr,d5 as mo,b as po,k0 as hr,b_ as ho,aw as Sn,k1 as li,cr as ci,cs as ui,h8 as go,k2 as vo,k3 as xo,k4 as wo,b$ as ki,c0 as Ri,c1 as Ti,c2 as Ei,c3 as Vi,c4 as Pi,ap as Pn,aq as Mn,ax as Gr,as as Dn,be as Xr,c5 as kn,ay as Rn,cm as di,aa as Xt,ab as Jt,ac as Yt,bY as bo,bZ as yo,g as Yr,bf as jo,cw as Fo}from"./useAppFontEffects-BItUWdo4.js";import{ag as No,R as Co,V as So,W as ko,X as Ro,Y as To}from"./runtimeEndpointReset-DhC3REb2.js";import{c as fi,s as Eo,P as Tn,C as Vo}from"./shikiHighlight-1imXsir9.js";import{a as Po}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Tt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Mo,J as Do,F as zo}from"./JsonTreeView-BBVPFM5K.js";import{ensurePierreThemeRegistered as mi,getResolvedShikiTheme as Lo}from"./appThemeRegistry-Cf8KitzT.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-D8pq6gQz.js";import{D as qo}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Ko,u as Ho,n as Go}from"./useInlineCommentController-CkbKsm7m.js";import{b as Xo}from"./CodeMirrorCommentWidgets-DvUH815P.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.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-BDyxuqK4.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-B0u3Q5uO.js";import"./PluginPane-QxjsKYeO.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-D7FinaeH.js";import"./computeVirtualFileMetrics-VYnT_A2h.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-D_YDVYDb.js";import"./textMateThemeFromAppTheme-Dgqc63LZ.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),M=s.useRef(null),[T,D]=s.useState(null);let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{j(null),R(""),E(!1),y.current=!1,M.current=null,D(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();M.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(Zo).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=M.current;if(!q){D(null);return}D(to(q))},e[6]=ue):ue=e[6];const de=ue;let Y,Z;e[7]!==S?(Y=()=>{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)}},Z=[S,de],e[7]=S,e[8]=Y,e[9]=Z):(Y=e[8],Z=e[9]),s.useEffect(Y,Z);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(Yo)},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 Me;e[30]!==S||e[31]!==o||e[32]!==We||e[33]!==pe||e[34]!==H||e[35]!==h?(Me=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]=Me):Me=e[36];let be;return e[37]!==te||e[38]!==he||e[39]!==Me?(be=ei.createPortal(n.jsxs("div",{ref:c,className:"fixed z-50",style:te,children:[he,Me]}),document.body),e[37]=te,e[38]=he,e[39]=Me,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 Yo(){ro()}function Zo(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=M=>{const T=m.current,D=M.target;!T||!(D instanceof Node)||T.contains(D)||R(!1)},c=M=>{M.key==="Escape"&&(M.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",Mi="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)),Di=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)=>{Di(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=Mi,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]),M=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))||M(S.current,!0)});return L.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{L.disconnect(),Di(k)}},[i,e,M]),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=Mi}),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 D=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():D()):k.key==="Escape"&&(k.preventDefault(),T())},[T,D,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),M(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:D,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 Zt=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 Mo&&(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=Zt.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(),M=x.line&&c?.getLinePosition(x.line.number),T=x.line&&f(x.line.number);let D=x.top;x.line&&M&&(D=(c?.top??0)+M.top-x.line.offset),x.line&&T&&(D=e.scrollTop+T.getBoundingClientRect().top-e.getBoundingClientRect().top-x.line.offset),e.scrollTop=D,e.scrollLeft=x.left,(!x.line||T)&&Math.abs(e.scrollTop-D)<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(),M=c?.getNumericScrollAnchor(e.scrollTop-(c.top??0)),T=M&&f(M.lineNumber),D=T?T.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(Zt.delete(i),Zt.set(i,{top:e.scrollTop,left:e.scrollLeft,line:M&&D!==null&&D>=0&&D<e.clientHeight?{number:M.lineNumber,offset:D}:void 0}),Zt.size>gl){const P=Zt.keys().next().value;P!==void 0&&Zt.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 M=new MutationObserver(c);return M.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>M.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,Zr=(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(!Zr(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||!Zr(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),Ml=i=>{const e=U(i);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Dl=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:M,onRevealPath:T,onOpenDialog:D}=i,{t:P}=tr(),V=r.type==="directory",{canRename:k,canCreateFile:L,canCreateFolder:B,canDelete:$,canReveal:ue}=j,de=!V&&!!N,Y=ue&&!x,Z=k||L||B||$||de||Y;let ae;e[0]!==Z||e[1]!==r.path||e[2]!==y?(ae=Te=>{Z&&(Te?.preventDefault(),y(r.path))},e[0]=Z,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]!==M?(oe=()=>{V?M(r.path):c(r)},e[4]=V,e[5]=r,e[6]=c,e[7]=M,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]!==Y||e[18]!==N||e[19]!==x||e[20]!==V||e[21]!==r||e[22]!==D||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(),D("rename",r)},children:[n.jsx(F,{name:"edit",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.rename")]}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),Yr(r.path).then(Ze=>{if(Ze.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 Ze=Jr(o,r.path)||r.path;Yr(Ze).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(Ze=>{console.error("Download failed:",Ze),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")]}),Y&&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(),D("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(),D("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(),D("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]=Y,e[18]=N,e[19]=x,e[20]=V,e[21]=r,e[22]=D,e[23]=T,e[24]=o,e[25]=P,e[26]=te):te=e[26];const he=te,Me=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]!==Z||e[60]!==b||e[61]!==r.path||e[62]!==he||e[63]!==S?(xe=Z&&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(Mn,{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(Dn,{align:"end",side:"bottom",onCloseAutoFocus:()=>S(null),children:he({Item:Xr,Separator:jo})})]})}),e[56]=v,e[57]=R,e[58]=We,e[59]=Z,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]!==Me||e[74]!==be?(Et=n.jsxs(To,{open:Me,onOpenChange:be,children:[Re,Ue]}),e[71]=Re,e[72]=Ue,e[73]=Me,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 M;e[19]!==r||e[20]!==o?.path||e[21]!==f?(M=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]=M):M=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 D;e[27]!==r||e[28]!==o?.name||e[29]!==f?(D=r==="rename"&&f("filesView.dialog.rename.description",{name:o?.name??""}),e[27]=r,e[28]=o?.name,e[29]=f,e[30]=D):D=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]!==D||e[36]!==P||e[37]!==M||e[38]!==T?(V=n.jsxs(Vi,{children:[M,T,D,P]}),e[35]=D,e[36]=P,e[37]=M,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 Y;e[58]!==r||e[59]!==w||e[60]!==b?(Y=b||r!=="delete"&&!w.trim(),e[58]=r,e[59]=w,e[60]=b,e[61]=Y):Y=e[61];let Z;e[62]!==r||e[63]!==b||e[64]!==f?(Z=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]=Z):Z=e[65];let ae;e[66]!==ue||e[67]!==de||e[68]!==Y||e[69]!==Z?(ae=n.jsx(I,{variant:ue,onClick:de,disabled:Y,children:Z}),e[66]=ue,e[67]=de,e[68]=Y,e[69]=Z,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=Ya(N);Za(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()),M=m||i==="full",T=M&&e,D=ao(t=>t.runtimeKey),P=JSON.stringify([D,c]),V=s.useRef(P);V.current=P;const k=JSON.stringify([D,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),[Y,Z]=s.useState(""),ae=lo(Y,200),pe=s.useRef(null),[oe,H]=s.useState(!1),[G,We]=s.useState(!0),[te,he]=s.useState(!1),[Me,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({}),Ze=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(Ze),mi(Pt)},[Ze,Pt]);const vr=s.useMemo(()=>[],[]),je=Ye(t=>c?t.byRoot[c]?.openPaths??vr:vr),bt=Ye(t=>c?t.byRoot[c]?.selectedPath??null:null),Qe=Ye(t=>c?t.byRoot[c]?.expandedPaths??vr:vr),Ii=s.useMemo(()=>new Set(Qe),[Qe]),Mt=Ye(t=>t.removeOpenPath),dt=Ye(t=>t.removeOpenPathsByPrefix),zn=Ye(t=>t.removeExpandedPathsByPrefix),Fe=Ye(t=>t.setSelectedPath),Ln=Ye(t=>t.toggleExpandedPath),xr=Ye(t=>t.expandPaths),Dt=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(Dt),[je,Dt]),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?Dt(en):null,[en,Dt]),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&&!Zr(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(),[De,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),[Yi,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,Zi]=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,Yn]=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),Zn=!!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),Zi(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:Mr,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&&!Mr)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,Mr,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]),Dr=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 Dr();return}const a=U(t);Oe.current=new Set(Oe.current),Oe.current.delete(a),await Ve(a,!0)},[Ve,Dr]),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||!Ml(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:De,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&&Zr(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,De,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:De,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,De,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),Yn(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=Ye.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(Dl(z)){if(ft(!1),c&&Fe(c,null),we(null),me(""),Ce(""),ce(null),Ke.current=null,Y.trim().length>0&&Z(""),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,Y,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&&Mt(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,Mt,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&&Mt(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,Mt,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&&Mt(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,Mt,c,u?.path,Fe]),Fs=s.useMemo(()=>new Set(je),[je]),Ir=s.useMemo(()=>Uo(M?de?.files??[]:[]),[de?.files,M]),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:Zn,canCreateFolder:Qn,canDelete:ts,canReveal:rs}),[es,Zn,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&&!De&&!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"&&!De?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&&Ye.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(Dt(l));return}if(De||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,Yi,tt,De,ke,_e,it,Ne,Pe,nt,c,u?.path,Vr,_,Dt]),s.useEffect(()=>{if(!mn||!c)return;const t=U(mn);if(!t){pn(null);return}u?.path===t&&(De||Ne!==t||(!tt&&!ke&&!_e&&!it&&Xe&&_==="edit"&&He.current?.focus(),pn(null)))},[Xe,tt,De,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:Ze.metadata.id,dark:Pt.metadata.id}),[Ze.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:Ms,nonce:Ds}=Ci(mr,we,Vs),Ma=!!(Wr&&Ps!==Wr),zs=!!(mr&&Ms!==mr),Ls=u?.path&&ke?Or?`data:${wo(u.path)};utf8,${encodeURIComponent(O)}`:Ui:"",As=u?.path&&_e&&mr&&Ms===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},Ds)}),[As,Ds]);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 Da=s.useCallback(()=>cn(null),[]),za=s.useMemo(()=>Xo({drafts:os,editingDraftId:Mr,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,Mr,os,ps,ss,W,u?.path,ls,fs]),Os=xi(),Bs=xi(),$s=!De&&!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(Yt,{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(Mn,{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(Yt,{side:"bottom",sideOffset:6,children:r("filesView.editor.openInDesktopApp")})]}),n.jsxs(Dn,{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(!Me),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),Yn(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(Yt,{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 Yr(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 Yr(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(Mn,{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(Dn,{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?De||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(Do,{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"?Ma?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:Me,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]),Ys=c?br[c]:null,Zs=M?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:Y,onChange:t=>Z(t.target.value),placeholder:r("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),Y.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:()=>{Z(""),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(Yt,{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(Yt,{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:()=>{Dr()},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(Yt,{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)}):Ys?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:Ys}),n.jsxs(I,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Dr()},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:De||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:Da,inputRef:Ki}),Wa,m?oe?Fn:Zs: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:Zs}),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 yt,Z as vt,aE as xe,cx as jt,cb as It,t as y,kI as Nt,I as u,B as he,o as Ze,c5 as He,a5 as Ye,cg as Pt,ch as wt,ci as kt,cj as St,ck as Lt,cm 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-BItUWdo4.js";import{u as f,dQ as M}from"./index-DLHQogv8.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.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-BDyxuqK4.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),be=[{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=>be.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 b;return n[2]!==c?(b=s.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:c}),n[2]=c,n[3]=b):b=n[3],b},te=t=>{const n=tt.c(31),{icon:o,label:c,ariaLabel:b,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]!==b||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":b,title:H,children:[C,h]})}),n[10]=b,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}=yt(),{linear:n}=vt(),o=xe(e=>e.status),c=xe(e=>e.hasChecked),b=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),[ye,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&&b(n)},[n,c,b]),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||!ye||!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);y.error(t("session.linearIssuePicker.toast.loadMoreFailed"),{description:i})}finally{e===P.current&&Ee(!1)}},[D,ye,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){y.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);y.error(t("session.linearIssuePicker.toast.loadIssueDetailsFailed"),{description:fe})}}catch(a){if(e)return;const i=a instanceof Error?a.message:String(a);y.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),y.error(t(a));return}if(!i.issue){y.error(t(a));return}We(i.issue),y.success(t("contextPanel.linear.toast.statusUpdated"))}catch(i){const T=i instanceof Error?i.message:String(i);y.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){y.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),y.success(t("contextPanel.linear.toast.workspaceSwitched"))}catch(a){const i=a instanceof Error?a.message:String(a);y.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(),bt=Ce===a.length-1,Qe=rt(p.createdAt);return s.jsxs("div",{className:"relative pl-10 pb-5 last:pb-0",children:[bt?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((be.find(e=>e.value===k)??be[0]).labelKey),ariaLabel:t("contextPanel.linear.filter.priorityAria"),value:k,active:k!=="all",disabled:ee,items:be.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),ye&&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{gC as K,gz as J,af as Z,f as Q,I as W}from"./useAppFontEffects-BItUWdo4.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-DLHQogv8.js";import{extractMarkdownImageCandidates as se,MAX_MARKDOWN_IMAGE_COUNT as ne}from"./markdownCore-DHvqMxPn.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.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-BDyxuqK4.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-k3Ppq1Ha.js";import"./vendor-dompurify-r8glNMJW.js";const L=10*1024*1024,ie=1024,le=3e4,ce=new Set(["image/png","image/jpeg","image/gif","image/webp"]),z=new WeakMap,$=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>L)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(L*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($(e),/^(?:https?:)?\/\//i.test(r))return r;if(/^data:image\/(?:png|jpeg|gif|webp);base64,/i.test(r))return await fe(r),$(e),r;throw new Error("Local image has not been prepared")},he=async(r,e,t)=>{$(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>L)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>L)throw new Error("Image is too large");const m=await c.blob();return await V(m,i),$(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 D=S.map(F);let O;return e[32]!==D?(O=P.jsx("div",{ref:c,className:N,"data-openchamber-markdown-image-gallery":E,children:D}),e[32]=D,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};
|