@aiworker/web 1.22.0 → 1.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/bin/cli.js +7 -4
- package/bin/cli.test.js +165 -73
- package/bin/lib/cli-api-target.js +2 -2
- package/bin/lib/cli-args.js +119 -119
- package/bin/lib/cli-lifecycle.js +9 -9
- package/bin/lib/cli-network.js +3 -3
- package/bin/lib/cli-paths.js +3 -3
- package/bin/lib/cli-ports.js +2 -2
- package/bin/lib/cli-process.js +4 -4
- package/bin/lib/cli-startup.js +64 -15
- package/bin/lib/cli-tunnel-profiles.js +1 -1
- package/bin/lib/cli-tunnel-utils.js +2 -2
- package/bin/lib/commands-connect-url.js +19 -19
- package/bin/lib/commands-lifecycle.js +27 -27
- package/bin/lib/commands-logs.js +5 -5
- package/bin/lib/commands-models.js +1 -1
- package/bin/lib/commands-projects.js +1 -1
- package/bin/lib/commands-schedule.js +1 -1
- package/bin/lib/commands-serve.js +29 -29
- package/bin/lib/commands-session.js +1 -1
- package/bin/lib/commands-startup.js +45 -10
- package/bin/lib/commands-status.js +1 -1
- package/bin/lib/commands-tunnel.js +40 -40
- package/bin/lib/commands-update.js +1 -1
- package/bin/lib/commands-update.test.js +6 -6
- package/dist/assets/{CodeMirrorCommentWidgets-B3u7UIcE.js → CodeMirrorCommentWidgets-CSICpWQD.js} +1 -1
- package/dist/assets/{DiffView-DluiRSla.js → DiffView-hDBKesA_.js} +3 -3
- package/dist/assets/DirtyBranchSwitchDialog-C22HdWj4.js +1 -0
- package/dist/assets/FilesView-CdWzeOp9.js +17 -0
- package/dist/assets/GitView-VQQkYuUw.js +6 -0
- package/dist/assets/{JsonTreeView-B0BdZEHG.js → JsonTreeView-6lrhwD3q.js} +1 -1
- package/dist/assets/LinearIssuesView-Ba6Q9569.js +1 -0
- package/dist/assets/{MarkdownImageGallery-ClOvuZxC.js → MarkdownImageGallery-Czv_mhvS.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-BrMcswiy.js +12 -0
- package/dist/assets/{OnboardingScreen-D2DG7K6b.js → OnboardingScreen-ChxQoAkx.js} +1 -1
- package/dist/assets/{PatchDiff-DvfqDql7.js → PatchDiff-BzcZPlOq.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B7m3f0d7.js → PierreDiffViewer-BchBtZlp.js} +2 -2
- package/dist/assets/PlanView-DyDt_nZ_.js +5 -0
- package/dist/assets/SettingsView-BKf5xBsP.js +28 -0
- package/dist/assets/{SettingsWindow-i45U1Cy1.js → SettingsWindow-DDQYaKWQ.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BTwyh5OF.js → ToolOutputDialog-iYF8Y2bz.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-CdjbOVMM.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-DD8lDVej.js → VirtualizedFileDiff-fFFm2QgH.js} +1 -1
- package/dist/assets/{WalkthroughView-egQgxel3.js → WalkthroughView-DOeCsMju.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-BMIRgMHv.js → computeVirtualFileMetrics-CzgLum_K.js} +2 -2
- package/dist/assets/{contextPanelEmbeddedChat-C3fjDbdg.js → contextPanelEmbeddedChat-C0ZLAepL.js} +1 -1
- package/dist/assets/{de-C1P6X5Rs.js → de-B5JaA3SA.js} +6 -5
- package/dist/assets/{es-CDgaF1_t.js → es-EPIH88ii.js} +6 -5
- package/dist/assets/{fr-Bgxqvvz_.js → fr-CAMfxUdZ.js} +6 -5
- package/dist/assets/{index-CODwDsU_.js → index-Bl3LSbjn.js} +1 -1
- package/dist/assets/index-DF5kMP-i.js +39 -0
- package/dist/assets/index-Dl3xbAB_.css +1 -0
- package/dist/assets/{isDiffPlainText-BqayB8d3.js → isDiffPlainText-Dx-dB_8l.js} +1 -1
- package/dist/assets/{isFilePlainText-QfoiKJNY.js → isFilePlainText-CWFPwmnU.js} +1 -1
- package/dist/assets/{ja-BDRrEcNP.js → ja-CifOE1VN.js} +7 -6
- package/dist/assets/{ko-Ba8sQV79.js → ko-BBDyAyYQ.js} +7 -6
- package/dist/assets/{main-C5DVOxc6.js → main-DnBAoktx.js} +2 -2
- package/dist/assets/main-MhSaOZoB.js +930 -0
- package/dist/assets/{markdownCore-CZwzz5gw.js → markdownCore-BrBwOOMn.js} +2 -2
- package/dist/assets/{miniChat-DUJ4irZc.js → miniChat-BKyvLseN.js} +2 -2
- package/dist/assets/{mobile-CcaxB0n4.js → mobile-DKjeFgMN.js} +2 -2
- package/dist/assets/{patchFileDiff-yNfWXN4E.js → patchFileDiff-o8ms1me8.js} +1 -1
- package/dist/assets/pl-DgEHYfFM.js +16 -0
- package/dist/assets/{pt-BR-DIs6ElwV.js → pt-BR-DuWHojUw.js} +6 -5
- package/dist/assets/{renderElectronMiniChatApp-BcKLHXKe.js → renderElectronMiniChatApp-CDgBwwCS.js} +2 -2
- package/dist/assets/renderMobileApp-DJIKIK1r.js +25 -0
- package/dist/assets/runtimeEndpointReset-CYJ9O_xX.js +17 -0
- package/dist/assets/{scheduledTasksApi-DLW0mkQK.js → scheduledTasksApi-D8yamh1b.js} +1 -1
- package/dist/assets/{shikiHighlight-DYOWuY65.js → shikiHighlight-TEQCmzW8.js} +1 -1
- package/dist/assets/tr-D5m2yIWL.js +7 -0
- package/dist/assets/{uk-ZrCNjM7Y.js → uk-D_q60oog.js} +6 -5
- package/dist/assets/{useAppFontEffects-CjrntdL0.js → useAppFontEffects-D7sNpuL2.js} +161 -190
- package/dist/assets/useInlineCommentController-Brz_cLcQ.js +2 -0
- package/dist/assets/{useRootScrollLock-BHYPkrLv.js → useRootScrollLock-lXEnWlaU.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DFZik9R2.js → vendor-codemirror-language-data-Dp3KMRQG.js} +2 -2
- package/dist/assets/vendor-zod-CK21ihK-.js +39 -0
- package/dist/assets/{web-components-Bhg83tjf.js → web-components-_mNEMjFY.js} +1 -1
- package/dist/assets/{zh-CN-iv_AV4EC.js → zh-CN-D8QvsVeg.js} +6 -5
- package/dist/assets/{zh-TW-CzEUk38j.js → zh-TW-B9t7rQQO.js} +6 -5
- package/dist/index.html +22 -22
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +5 -5
- package/package.json +3 -3
- package/server/index.js +118 -85
- package/server/lib/agent-memory/actions.js +2 -2
- package/server/lib/agent-memory/feature-flag.js +1 -1
- package/server/lib/agent-memory/feature-flag.test.js +8 -8
- package/server/lib/agent-memory/routes.js +2 -2
- package/server/lib/agent-tool/runtime.js +37 -54
- package/server/lib/agent-tool/runtime.test.js +59 -59
- package/server/lib/browser-control/broker.js +3 -3
- package/server/lib/browser-control/broker.test.js +1 -1
- package/server/lib/changelog/update-notes.js +82 -0
- package/server/lib/changelog/update-notes.test.js +59 -0
- package/server/lib/client-auth/remote-clients.test.js +5 -5
- package/server/lib/context-obligatory/runtime.js +7 -7
- package/server/lib/context-obligatory/runtime.test.js +5 -5
- package/server/lib/dev-servers/parse.js +2 -2
- package/server/lib/dev-servers/parse.test.js +2 -2
- package/server/lib/dev-servers/routes.js +1 -1
- package/server/lib/dev-tunnel/DOCUMENTATION.md +13 -4
- package/server/lib/dev-tunnel/client.js +1 -1
- package/server/lib/dev-tunnel/runtime.js +5 -5
- package/server/lib/dev-tunnel/tunnel.test.js +21 -1
- package/server/lib/dictation/local/model-catalog.js +1 -1
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/event-stream/directory-ws-bridge.js +1 -1
- package/server/lib/event-stream/global-ws-bridge.js +1 -1
- package/server/lib/event-stream/protocol.test.js +4 -4
- package/server/lib/event-stream/runtime.test.js +6 -6
- package/server/lib/fs/DOCUMENTATION.md +2 -0
- package/server/lib/fs/routes.js +37 -26
- package/server/lib/fs/routes.test.js +98 -21
- package/server/lib/git/DOCUMENTATION.md +3 -1
- package/server/lib/git/identity-storage.js +1 -1
- package/server/lib/git/issue-2746-longpaths.test.js +4 -4
- package/server/lib/git/routes.js +17 -1
- package/server/lib/git/service.js +116 -26
- package/server/lib/git/service.test.js +174 -3
- package/server/lib/github/auth.js +8 -8
- package/server/lib/github/pr-status.js +1 -1
- package/server/lib/github/routes.js +2 -2
- package/server/lib/inherited-env.js +1 -1
- package/server/lib/inherited-env.test.js +2 -2
- package/server/lib/linear/auth.js +8 -8
- package/server/lib/linear/auth.test.js +24 -24
- package/server/lib/linear/issues.test.js +6 -6
- package/server/lib/linear/mapping.test.js +4 -4
- package/server/lib/linear/oauth.js +2 -2
- package/server/lib/linear/oauth.test.js +14 -14
- package/server/lib/linear/routes.js +5 -5
- package/server/lib/linear/routes.test.js +16 -16
- package/server/lib/linear/status-runtime.test.js +9 -9
- package/server/lib/linear/status.js +1 -1
- package/server/lib/linear/status.test.js +15 -15
- package/server/lib/linear/teams.test.js +4 -4
- package/server/lib/magic-prompts/routes.js +2 -2
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +55 -0
- package/server/lib/mcp-reconnect/runtime.js +122 -0
- package/server/lib/mcp-reconnect/runtime.test.js +140 -0
- package/server/lib/message-queue/DOCUMENTATION.md +158 -0
- package/server/lib/message-queue/runtime.js +870 -0
- package/server/lib/message-queue/runtime.test.js +482 -0
- package/server/lib/notifications/apns-runtime.js +17 -17
- package/server/lib/notifications/apns-runtime.test.js +11 -11
- package/server/lib/notifications/emitter-runtime.js +1 -1
- package/server/lib/notifications/emitter-runtime.test.js +1 -1
- package/server/lib/notifications/push-runtime.js +7 -7
- package/server/lib/notifications/routes.js +1 -1
- package/server/lib/notifications/runtime.js +1 -1
- package/server/lib/openchamber-control/action-resolution.test.js +10 -10
- package/server/lib/openchamber-control/actions.js +24 -24
- package/server/lib/openchamber-control/error.js +4 -4
- package/server/lib/openchamber-control/routes.js +2 -2
- package/server/lib/openchamber-control/routes.test.js +5 -5
- package/server/lib/openchamber-control/screenshots.js +1 -1
- package/server/lib/openchamber-control/screenshots.test.js +1 -1
- package/server/lib/openchamber-control/service.js +50 -50
- package/server/lib/openchamber-control/service.test.js +5 -5
- package/server/lib/openchamber-sessions/routes.js +124 -22
- package/server/lib/openchamber-sessions/routes.test.js +99 -11
- package/server/lib/opencode/DOCUMENTATION.md +13 -5
- package/server/lib/opencode/auth.js +1 -1
- package/server/lib/opencode/bootstrap-runtime.js +6 -6
- package/server/lib/opencode/cli-options.js +8 -8
- package/server/lib/opencode/config-paths.test.js +116 -0
- package/server/lib/opencode/core-routes.js +8 -7
- package/server/lib/opencode/core-routes.test.js +11 -11
- package/server/lib/opencode/env-config.js +5 -5
- package/server/lib/opencode/env-config.test.js +7 -7
- package/server/lib/opencode/env-runtime.js +10 -10
- package/server/lib/opencode/env-runtime.test.js +18 -18
- package/server/lib/opencode/feature-routes-runtime.js +17 -12
- package/server/lib/opencode/hmr-state-runtime.js +2 -2
- package/server/lib/opencode/hmr-state-runtime.test.js +1 -1
- package/server/lib/opencode/input-history-scope.js +14 -0
- package/server/lib/opencode/lifecycle.js +8 -8
- package/server/lib/opencode/lifecycle.test.js +4 -4
- package/server/lib/opencode/managed-plugin-config.js +35 -0
- package/server/lib/opencode/managed-process-registry.js +3 -3
- package/server/lib/opencode/mcp-oauth-callback.test.js +2 -2
- package/server/lib/opencode/openchamber-routes.js +15 -15
- package/server/lib/opencode/openchamber-routes.test.js +11 -11
- package/server/lib/opencode/plugins.js +2 -2
- package/server/lib/opencode/plugins.test.js +1 -1
- package/server/lib/opencode/project-icon-routes.js +2 -2
- package/server/lib/opencode/project-icon-routes.test.js +1 -1
- package/server/lib/opencode/providers.js +44 -2
- package/server/lib/opencode/providers.test.js +131 -4
- package/server/lib/opencode/proxy.js +2 -2
- package/server/lib/opencode/pwa-manifest-routes.js +1 -1
- package/server/lib/opencode/restart-session-recovery.test.js +1 -1
- package/server/lib/opencode/routes-upgrade.test.js +4 -4
- package/server/lib/opencode/routes.js +14 -14
- package/server/lib/opencode/server-startup-runtime.js +6 -6
- package/server/lib/opencode/session-runtime.js +3 -3
- package/server/lib/opencode/session-runtime.test.js +6 -6
- package/server/lib/opencode/settings-helpers.js +31 -3
- package/server/lib/opencode/settings-helpers.test.js +189 -12
- package/server/lib/opencode/settings-runtime.js +2 -2
- package/server/lib/opencode/settings-runtime.test.js +29 -0
- package/server/lib/opencode/shared.js +5 -2
- package/server/lib/opencode/shared.test.js +7 -7
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/skill-routes.js +2 -1
- package/server/lib/opencode/snippets.js +1 -2
- package/server/lib/opencode/startup-performance.js +1 -1
- package/server/lib/opencode/startup-performance.test.js +6 -6
- package/server/lib/opencode/static-routes-runtime.js +8 -8
- package/server/lib/opencode/static-routes-runtime.test.js +7 -7
- package/server/lib/opencode/upgrade-capability.js +2 -2
- package/server/lib/opencode/upgrade-capability.test.js +3 -3
- package/server/lib/package-manager.js +17 -42
- package/server/lib/package-manager.test.js +19 -19
- package/server/lib/permission-auto-accept/runtime.js +1 -1
- package/server/lib/project-context/routes.js +1 -1
- package/server/lib/projects/project-config.js +2 -2
- package/server/lib/quota/DOCUMENTATION.md +9 -1
- package/server/lib/quota/credentials/providers.js +4 -0
- package/server/lib/quota/credentials/store.js +4 -4
- package/server/lib/quota/credentials/store.test.js +8 -8
- package/server/lib/quota/index.js +1 -0
- package/server/lib/quota/providers/exe-dev.js +75 -0
- package/server/lib/quota/providers/exe-dev.test.js +47 -0
- package/server/lib/quota/providers/hyper.js +118 -0
- package/server/lib/quota/providers/hyper.test.js +126 -0
- package/server/lib/quota/providers/index.js +15 -0
- package/server/lib/quota/providers/ollama-cloud.js +1 -1
- package/server/lib/quota/providers/opencode-go.js +2 -1
- package/server/lib/quota/providers/opencode-go.test.js +9 -5
- package/server/lib/quota/providers/xai.js +1 -1
- package/server/lib/quota/routes.js +2 -0
- package/server/lib/quota/utils/auth.js +1 -1
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/host-client.js +1 -1
- package/server/lib/relay/host-client.test.js +9 -1
- package/server/lib/relay/host-lock.js +1 -1
- package/server/lib/relay/service.js +5 -5
- package/server/lib/relay/tunnel-host.js +3 -1
- package/server/lib/relay/tunnel-host.test.js +9 -1
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +2 -2
- package/server/lib/scheduled-tasks/routes.js +5 -5
- package/server/lib/scheduled-tasks/service.js +25 -25
- package/server/lib/scheduled-tasks/service.test.js +1 -1
- package/server/lib/security/bind-host.js +4 -4
- package/server/lib/security/bind-host.test.js +1 -1
- package/server/lib/security/request-security.js +11 -5
- package/server/lib/security/request-security.test.js +14 -14
- package/server/lib/session-assist/runtime.js +10 -9
- package/server/lib/session-folders/routes.js +2 -2
- package/server/lib/session-folders/routes.test.js +8 -8
- package/server/lib/session-goal/DOCUMENTATION.md +20 -7
- package/server/lib/session-goal/create.js +4 -2
- package/server/lib/session-goal/create.test.js +1 -1
- package/server/lib/session-goal/objectives.js +4 -4
- package/server/lib/session-goal/routes.js +1 -1
- package/server/lib/session-goal/runtime.js +88 -22
- package/server/lib/session-goal/runtime.test.js +428 -2
- package/server/lib/session-knowledge/runtime.js +11 -11
- package/server/lib/session-knowledge/runtime.test.js +5 -5
- package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
- package/server/lib/skills-catalog/cache.test.js +2 -2
- package/server/lib/skills-catalog/disk-cache.js +5 -5
- package/server/lib/skills-catalog/github-meta.test.js +2 -2
- package/server/lib/skills-catalog/install.js +3 -2
- package/server/lib/small-model/DOCUMENTATION.md +4 -0
- package/server/lib/small-model/call.js +9 -3
- package/server/lib/small-model/call.test.js +29 -6
- package/server/lib/small-model/index.js +8 -7
- package/server/lib/small-model/index.test.js +1 -1
- package/server/lib/small-model/resolve.js +1 -1
- package/server/lib/small-model/resolve.test.js +1 -1
- package/server/lib/small-model/routes.js +2 -1
- package/server/lib/system-prompt/runtime.js +3 -22
- package/server/lib/system-prompt/runtime.test.js +3 -3
- package/server/lib/terminal/DOCUMENTATION.md +11 -7
- package/server/lib/terminal/runtime.js +180 -26
- package/server/lib/terminal/runtime.test.js +554 -27
- package/server/lib/terminal/shells.js +20 -3
- package/server/lib/terminal/shells.test.js +33 -2
- package/server/lib/tts/base-url.js +3 -3
- package/server/lib/tts/routes.test.js +20 -20
- package/server/lib/ui-auth/ui-auth.js +12 -9
- package/server/lib/ui-auth/ui-auth.test.js +19 -3
- package/server/lib/ui-auth/ui-passkeys.js +7 -7
- package/server/lib/walkthrough/index.js +1 -0
- package/server/lib/walkthrough/jobs.test.js +1 -1
- package/server/lib/walkthrough/language.test.js +1 -1
- package/server/lib/walkthrough/model-settings.js +3 -3
- package/server/lib/walkthrough/model-settings.test.js +1 -1
- package/server/lib/walkthrough/pull-request.test.js +5 -5
- package/server/lib/walkthrough/reproduce-2607.test.js +2 -2
- package/server/lib/walkthrough/routes.test.js +26 -5
- package/server/lib/walkthrough/store.js +3 -3
- package/server/lib/walkthrough/store.test.js +1 -1
- package/server/opencode-proxy.test.js +2 -2
- package/server/proxy-headers.js +1 -1
- package/server/sse-routes.test.js +4 -4
- package/README.md.bak +0 -250
- package/bin/lib/DOCUMENTATION.md.bak +0 -163
- package/dist/assets/CommitSection-SGBCAW0w.js +0 -1
- package/dist/assets/FilesView-Bdq8ppva.js +0 -17
- package/dist/assets/GitView-Znn7VJcP.js +0 -6
- package/dist/assets/LinearIssuesView-jP-hXyac.js +0 -1
- package/dist/assets/MarkdownRendererImpl-Dt9mjTRN.js +0 -12
- package/dist/assets/PlanView-B0F3BtPZ.js +0 -5
- package/dist/assets/SettingsView-BBW-S-gh.js +0 -28
- package/dist/assets/ToolPartDiffPreview-CUNe28U1.js +0 -8
- package/dist/assets/index-C57jT0Sa.css +0 -1
- package/dist/assets/index-DW_E3rnL.js +0 -7
- package/dist/assets/main-Bv5Pkngh.js +0 -928
- package/dist/assets/pl-Dioz29BI.js +0 -15
- package/dist/assets/renderMobileApp-D9yQJy0L.js +0 -25
- package/dist/assets/runtimeEndpointReset-CjhvxLH0.js +0 -16
- package/dist/assets/tr-DFnMlPxY.js +0 -6
- package/dist/assets/useInlineCommentController-CDEuSlPH.js +0 -2
- package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
- package/server/index.d.ts.bak +0 -39
- package/server/lib/agent-tool/DOCUMENTATION.md.bak +0 -119
- package/server/lib/browser-control/DOCUMENTATION.md.bak +0 -50
- package/server/lib/context-obligatory/DOCUMENTATION.md.bak +0 -19
- package/server/lib/dev-tunnel/DOCUMENTATION.md.bak +0 -57
- package/server/lib/dictation/DOCUMENTATION.md.bak +0 -100
- package/server/lib/event-stream/DOCUMENTATION.md.bak +0 -62
- package/server/lib/fs/DOCUMENTATION.md.bak +0 -47
- package/server/lib/git/DOCUMENTATION.md.bak +0 -193
- package/server/lib/github/DOCUMENTATION.md.bak +0 -183
- package/server/lib/linear/DOCUMENTATION.md.bak +0 -97
- package/server/lib/linear/OAUTH-BROKER-HANDOFF.md.bak +0 -91
- package/server/lib/markdown-image-grants/DOCUMENTATION.md.bak +0 -40
- package/server/lib/notifications/APNS.md.bak +0 -135
- package/server/lib/notifications/DOCUMENTATION.md.bak +0 -138
- package/server/lib/openchamber-control/DOCUMENTATION.md.bak +0 -64
- package/server/lib/opencode/DOCUMENTATION.md.bak +0 -431
- package/server/lib/opencode/managed-process-registry.d.ts.bak +0 -13
- package/server/lib/opencode/provider-env-aliases.d.ts.bak +0 -3
- package/server/lib/permission-auto-accept/DOCUMENTATION.md.bak +0 -34
- package/server/lib/project-context/DOCUMENTATION.md.bak +0 -160
- package/server/lib/quota/DOCUMENTATION.md.bak +0 -123
- package/server/lib/relay/DOCUMENTATION.md.bak +0 -100
- package/server/lib/scheduled-tasks/DOCUMENTATION.md.bak +0 -182
- package/server/lib/session-assist/DOCUMENTATION.md.bak +0 -66
- package/server/lib/session-goal/DOCUMENTATION.md.bak +0 -213
- package/server/lib/session-knowledge/DOCUMENTATION.md.bak +0 -89
- package/server/lib/skills-catalog/DOCUMENTATION.md.bak +0 -151
- package/server/lib/small-model/DOCUMENTATION.md.bak +0 -212
- package/server/lib/system-prompt/DOCUMENTATION.md.bak +0 -36
- package/server/lib/terminal/DOCUMENTATION.md.bak +0 -50
- package/server/lib/text/DOCUMENTATION.md.bak +0 -35
- package/server/lib/tts/DOCUMENTATION.md.bak +0 -147
- package/server/lib/tunnels/DOCUMENTATION.md.bak +0 -21
- package/server/lib/ui-auth/DOCUMENTATION.md.bak +0 -44
- package/server/lib/walkthrough/DOCUMENTATION.md.bak +0 -411
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-CdWzeOp9.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-DF5kMP-i.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-zod-CK21ihK-.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-Dl3xbAB_.css","assets/useAppFontEffects-D7sNpuL2.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BeMD8X_w.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/contextPanelEmbeddedChat-C0ZLAepL.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-Dp3KMRQG.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-gg7YLRW7.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-CYJ9O_xX.js","assets/shikiHighlight-TEQCmzW8.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-6lrhwD3q.js","assets/web-components-_mNEMjFY.js","assets/computeVirtualFileMetrics-CzgLum_K.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-CWFPwmnU.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/Virtualizer-D_a8gKmg.js","assets/scheduledTasksApi-D8yamh1b.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-Brz_cLcQ.js","assets/CodeMirrorCommentWidgets-CSICpWQD.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as ue,r as Ns,j as t,R as l,c as jt,h as ho}from"./vendor-react-BUCujlKS.js";import{u as Je,a as Rt,b as ar,d as yn,i as Pe,e as Ye,s as bt,f as Gt,r as _s,h as go,j as lr,k as bo,p as xo,l as yo,m as it,n as vo,o as vn,q as wn,t as jn,v as wo,w as kn,M as Zt,x as jo,y as ko}from"./index-DF5kMP-i.js";import{u as Ds,a as So,b as Be,c as cr,d as ur,r as Ms,e as No,f as fe,t as le,o as Co,I as ee,B as we,g as Eo,O as st,h as J,P as Ro,i as Po,j as To,k as Ao,l as Oe,m as Io,n as ft,p as _o,q as Sn,s as Do,v as zs,w as Mo,x as zo,y as ke,z as Oo,A as dr,C as fr,D as mr,E as Bo,F as Os,G as Lo,H as pr,J as $o,K as Fo,L as Wo,M as Uo,N as hr,Q as gr,R as br,S as xr,T as Bs,U as Vo,V as Go,W as Ls,X as Ko,Y as Ho,Z as Dt,_ as bs,$ as qo,a0 as yr,a1 as Yo,a2 as $s,a3 as vr,a4 as wr,a5 as Ot,a6 as vt,a7 as Jo,a8 as Xo,a9 as Qo,aa as Zo,ab as ei,ac as Fs,ad as ti,ae as si,af as ni,ag as ri,ah as oi,ai as Ve,aj as ii,ak as ai,al as li,am as ci,an as Nn,ao as ui,ap as di,aq as Le,ar as fi,as as mi,at as pi,au as hi,av as gi,aw as bi,ax as xi,ay as jr,az as yi,aA as vi,aB as wi,aC as ji,aD as ki,aE as Si,aF as Ni,aG as Ci,aH as Ei,aI as Ri,aJ as Pi,aK as Ti,aL as Ai,aM as Ii,aN as _i,aO as Di,aP as Mi,aQ as zi,aR as Oi,aS as Bi,aT as Li,aU as $i,aV as Fi,aW as Wi,aX as Ui,aY as Vi,aZ as Gi,a_ as Ki,a$ as Hi,b0 as qi,b1 as Yi}from"./useAppFontEffects-D7sNpuL2.js";import{u as xt,S as kr,p as Ji,D as Xi,N as Qi,B as Zi,a as ea,b as ta,c as sa,d as na,T as ra,P as oa,r as ia,e as aa,f as la,g as ca,O as ua,C as da,h as fa,i as ma,j as pa}from"./runtimeEndpointReset-CYJ9O_xX.js";import{_ as kt}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as ha,A as ga}from"./SettingsView-BKf5xBsP.js";import{PlanView as ba}from"./PlanView-DyDt_nZ_.js";import{p as xa}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as ya}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as Cs,s as Sr,M as Ws,a as is,J as Es,p as va,_ as Cn,b as Nr,P as Cr,d as wa,f as Us,V as ja,K as En,c as ka,Q as Sa,r as Na,U as Ca,Z as Ea}from"./vendor-remixicon-react-Dil0zKKT.js";import{f as Vs,h as St,i as Gs,P as Ks,D as Hs,j as qs}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as Ys,S as Js,v as Xs,u as Qs}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as Zs}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as en,p as Er}from"./vendor-zustand-BAGL70zf.js";import{toast as Rn}from"./vendor-sonner-DFyL3AvE.js";import{C as Ra,a as Pa,D as Ta}from"./DirtyBranchSwitchDialog-C22HdWj4.js";import{P as Aa}from"./PierreDiffViewer-BchBtZlp.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-CK21ihK-.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BeMD8X_w.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"./contextPanelEmbeddedChat-C0ZLAepL.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.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-Dp3KMRQG.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-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-TEQCmzW8.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./useInlineCommentController-Brz_cLcQ.js";import"./CodeMirrorCommentWidgets-CSICpWQD.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./web-components-_mNEMjFY.js";import"./computeVirtualFileMetrics-CzgLum_K.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.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"./VirtualizedFileDiff-fFFm2QgH.js";import"./isDiffPlainText-Dx-dB_8l.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";let Rr=null,Pn=!1;const Ia=new Promise(n=>{Rr=n});function _a(){Pn||(Pn=!0,Rr?.())}const Da=6,Ma=n=>n.parentID??null,Tn=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},za=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Oa=(n,e)=>{if(!n)return"";let s=null,o=-1;for(const r of e){const i=za(r.path);(n===i||n.startsWith(`${i}/`))&&i.length>o&&(s=r,o=i.length)}return s?s.label?.trim()||Tn(s.path):Tn(n)},Ba=()=>{const n=Ds.getState().activeSessions,e=So.getState().index.session.unseenCount,s=Je.getState().notifyOnSubtasks,o=Be.getState().projects,r=cr.getState().ids,i=ur.getState().rankById;let c=0;const d=[];for(const a of n){const u=Ma(a)!==null,g=(e[a.id]??0)>0&&(!u||s);g&&(c+=1),u||d.push({session:a,unread:g,project:Oa(Ms(a),o)})}d.sort((a,u)=>No(a.session,u.session,r,i));const f=d.slice(0,Da).map(({session:a,unread:u,project:p})=>({id:a.id,title:a.title??"",unread:u,project:p}));return{runtimeKey:Rt(),attentionCount:c,recentSessions:f}},La="__AIWORKER_WIDGET_SNAPSHOT__",$a=()=>{typeof window>"u"||(window[La]=()=>{try{return JSON.stringify(Ba())}catch{return null}})},xs="mobile-app-update-available",An="mobile-app-update-toast-dismissed-version",Fa=()=>{const n=ue.c(8),{t:e}=fe(),s=xt(Wa),o=xt(Ua),r=xt(Va),i=xt(Ga);let c;n[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,n[0]=c):c=n[0];const d=Ns.useRef(c);let f,a;return n[1]!==s||n[2]!==i||n[3]!==o||n[4]!==e||n[5]!==r?(f=()=>{if(ar()!=="android"||o!=="mobile"||!s||!r||!i){le.dismiss(xs);return}yn().getItem(An)!==r&&(d.current.has(r)||(d.current.add(r),le.info(e("mobileUpdate.toast.available.title"),{id:xs,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(ee,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{Co(i)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{yn().setItem(An,r),le.dismiss(xs)}}})))},a=[s,i,o,e,r],n[1]=s,n[2]=i,n[3]=o,n[4]=e,n[5]=r,n[6]=f,n[7]=a):(f=n[6],a=n[7]),Ns.useEffect(f,a),null};function Wa(n){return n.available}function Ua(n){return n.runtimeType}function Va(n){return n.info?.version}function Ga(n){return n.info?.downloadUrl}const In=300,Ka="aiworker.mobile.connectLog.v1",yt=[];if(typeof window<"u")try{window.localStorage.removeItem(Ka)}catch{}const tn=(n,e)=>{yt.push({at:Date.now(),step:n,detail:e}),yt.length>In&&yt.splice(0,yt.length-In)};typeof window<"u"&&tn("app:launch","{}");const Ha=()=>[...yt],qa=n=>{const e=new Date(n),s=(o,r=2)=>String(o).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},Pr=n=>`${qa(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Ya=()=>yt.map(Pr).join(`
|
|
3
|
+
`),Tr=(n,e)=>{const s=ue.c(10),o=700,r=l.useRef(null),i=l.useRef(null),c=l.useRef(!1);let d;s[0]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,i.current=null},s[0]=d):d=s[0];const f=d;let a,u;s[1]===Symbol.for("react.memo_cache_sentinel")?(a=()=>f,u=[f],s[1]=a,s[2]=u):(a=s[1],u=s[2]),l.useEffect(a,u);let p;s[3]!==o||s[4]!==n?(p=N=>{c.current=!1,i.current={x:N.clientX,y:N.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,c.current=!0,n()},o)},s[3]=o,s[4]=n,s[5]=p):p=s[5];const g=p;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=N=>{const E=i.current;E&&(Math.abs(N.clientX-E.x)>10||Math.abs(N.clientY-E.y)>10)&&f()},s[6]=h):h=s[6];const b=h;let j;s[7]===Symbol.for("react.memo_cache_sentinel")?(j=N=>{c.current&&(c.current=!1,N.preventDefault(),N.stopPropagation())},s[7]=j):j=s[7];const y=j;let I;return s[8]!==g?(I={onPointerDown:g,onPointerMove:b,onPointerUp:f,onPointerCancel:f,onClickCapture:y},s[8]=g,s[9]=I):I=s[9],I},as="aiworker.mobile.connections.v1",Ja="aiworker.mobile.",_n="aiworker.mobile.deviceId",Xa=()=>{try{const n=window.localStorage.getItem(_n);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(_n,e),e}catch{return crypto.randomUUID()}},Dn=()=>`mobile:${Xa()}`,Mn=()=>{try{const n=ya.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},Ar=12,Ir=8e3,Qa=2500,Za=3e3,ls=2500,el=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},Pt=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,o=new URL(s);return o.hash="",o.search="",o.pathname=o.pathname.replace(/\/+$/,""),o.toString().replace(/\/+$/,"")},ns=n=>{try{return new URL(n).host}catch{return n}},Nt=n=>{try{return Pt(n)}catch{return n.trim().replace(/\/+$/g,"")}},_r=(n,e)=>Nt(n)===Nt(e),Dr=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,tl=n=>`relay://${n.serverId}`,fs=n=>n.candidates.filter(e=>e.kind==="direct"),at=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},Xe=n=>{const e=fs(n)[0];if(e)return e.url;const s=at(n);return s?tl(s):""},Re=n=>{const e=at(n);if(e)return Dr(e);const s=fs(n)[0];return s?Nt(s.url):""},cs=(n,e)=>{const s=n.find(i=>i.kind==="relay"),o=s&&s.kind==="relay"?s.relay.serverId:null,r=new Set(n.filter(i=>i.kind==="direct").map(i=>Nt(i.url)));return e.some(i=>i.kind==="relay"?o!==null&&i.relay.serverId===o:r.has(Nt(i.url)))},sn=n=>{const e=(()=>{try{return Pt(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},zn=n=>{if(n.candidates&&n.candidates.length>0)return n.candidates;const e=[];return typeof n.url=="string"&&n.url.trim()&&!/^relay:\/\//i.test(n.url.trim())&&e.push(...sn(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},nn=n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const e=n;if(typeof e.relayUrl!="string"||!e.relayUrl.trim()||typeof e.serverId!="string"||!e.serverId.trim())return null;const s=e.hostEncPubJwk;if(!s||typeof s!="object"||Array.isArray(s))return null;const o=s;return o.kty!=="EC"||o.crv!=="P-256"||typeof o.x!="string"||!o.x||typeof o.y!="string"||!o.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:o.x,y:o.y}}},Mr=n=>{try{return JSON.stringify(n)}catch{return String(n)}},be=(n,e={})=>{const s=Mr(e);console.info("[mobile-connect]",n,s),tn(n,s)},Mt=(n,e={})=>{be(n,e)},Ct=(n,e={})=>{const s=Mr(e);console.info("[mobile-storage]",n,s),tn(n,s)},sl=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},nl=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},rl=async(n,e)=>{if(!Pe())return null;try{const{CapacitorHttp:s}=await kt(async()=>{const{CapacitorHttp:i}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:i}},[]),o=bo(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(o.entries()),data:nl(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>sl(r.data)}}catch(s){return be("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},ol=async(n,e)=>{const s=await fetch(n,e).catch(o=>(be("browser-fetch:failed",{url:n,error:o instanceof Error?o.message:String(o)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},et=async(n,e,s)=>{let o;const r=new Promise(i=>{o=window.setTimeout(()=>{s?.(),i(null)},n)});try{return await Promise.race([e,r])}catch{return null}finally{o!==void 0&&window.clearTimeout(o)}},lt=async(n,e,s)=>{const o=s?.totalTimeoutMs??Ir,r=Date.now(),i=await et(Math.min(Qa,o),rl(n,e));if(i)return i;const c=new AbortController,d=Math.max(500,o-(Date.now()-r));return et(d,ol(n,{...e,signal:c.signal}),()=>c.abort())},ms=async n=>{if(!n)return null;const e=await n.json().catch(()=>null);if(!e||typeof e!="object")return null;const s=e;return{authenticated:typeof s.authenticated=="boolean"?s.authenticated:void 0,disabled:typeof s.disabled=="boolean"?s.disabled:void 0,scope:typeof s.scope=="string"?s.scope:void 0}},Et=15e3,il=async(n,e,s,o=Et,r)=>{const i=lr({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk}),c=d=>d==="ok"&&r?.keepTunnel?{outcome:d,tunnel:i}:(i.close(),{outcome:d});try{const d=e?{Authorization:`Bearer ${e}`}:void 0,f=await et(o,i.fetch("/auth/session",{headers:d}).catch(()=>null));if(be("relay:session",{ok:f?.ok===!0,status:f?.status??null,hasToken:!!e}),!f)return c("unreachable");if(f.status===401)return c(e?"auth-failed":"needs-login");if(!f.ok&&f.status!==404)return c("auth-failed");const a=await ms(f);return a&&a.disabled!==!0&&a.authenticated===!1?c(e?"auth-failed":"needs-login"):c("ok")}catch(d){throw i.close(),d}},al=(n,e,s,o,r)=>{const i=typeof window<"u"?window.location.origin:"",c={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&go(c,r),bt({apiBaseUrl:i,clientToken:e,runtimeKey:o??Dr(n),relay:c})},ll=n=>{if(!n||typeof n!="object")return null;const e=n;if(e.kind==="direct")return typeof e.url=="string"&&e.url.trim()?{kind:"direct",url:e.url}:null;if(e.kind==="relay"){const s=nn(e.relay);return s?{kind:"relay",relay:s}:null}return null},cl=n=>{if(n.mode==="relay"){const e=nn(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?sn(n.url):[]},ut=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(as)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Pe();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const o=s;if(typeof o.id!="string")return[];const r=Array.isArray(o.candidates)?o.candidates.map(ll).filter(f=>!!f):cl(o);if(r.length===0)return[];const i=typeof o.clientToken=="string"&&o.clientToken.trim()?o.clientToken:void 0,c=typeof o.label=="string"&&o.label.trim()?o.label:ns(Xe({candidates:r})),d={id:o.id,label:c,candidates:r,lastUsedAt:typeof o.lastUsedAt=="number"?o.lastUsedAt:0};return e?[{...d,hasToken:!!o.hasToken||!!i}]:[{...d,clientToken:i,hasToken:!!i}]}).sort((s,o)=>o.lastUsedAt-s.lastUsedAt)},Rs=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},rn=n=>{if(typeof window>"u")return;const e=Pe(),s=n.slice(0,Ar).map(o=>{const r={id:o.id,label:o.label,candidates:o.candidates.map(Rs),lastUsedAt:o.lastUsedAt};return e?{...r,hasToken:!!(o.hasToken||o.clientToken)}:{...r,clientToken:o.clientToken}});try{window.localStorage.setItem(as,JSON.stringify(s))}catch(o){console.warn("[mobile-storage] failed to persist connection metadata",o)}},zr=(n,e)=>{const s=n.find(i=>e.id&&i.id===e.id||cs(i.candidates,e.candidates)),o=Pe(),r={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...o?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[r,...n.filter(i=>i.id!==r.id&&!cs(i.candidates,e.candidates))].slice(0,Ar)},on=xa,ul=0,an=n=>`${Ja}token.${encodeURIComponent(n)}`,dl=async(n,e)=>{let s;const o=new Promise(r=>{s=window.setTimeout(()=>r(e),Za)});try{return await Promise.race([n.catch(()=>e),o])}finally{s!==void 0&&window.clearTimeout(s)}},ln=async(n,e,s)=>Pe()?dl(e().catch(o=>(console.warn(`[mobile-storage] ${n} failed`,o),s)),s):s,Kt=async n=>{Ct("secure:read-start",{key:n});const e=await ln("secure:read",async()=>(await on.internalGetItem({prefixedKey:an(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Ct("secure:read",{key:n,hasToken:!!s}),s},nt=async(n,e)=>{Ct("secure:write-start",{key:n});const s=await ln("secure:write",async()=>(await on.internalSetItem({prefixedKey:an(n),data:e,sync:!1,access:ul}),!0),!1);return Ct("secure:write",{key:n,ok:s}),s},fl=async n=>{await ln("secure:delete",async()=>(await on.internalRemoveItem({prefixedKey:an(n),sync:!1}),!0),!1)},ml=async(n,e)=>{let s=0,o=0;return{records:await Promise.all(n.map(async i=>{if(!i||typeof i!="object")return i;const c=i,d=typeof c.url=="string"?c.url:null,f=typeof c.clientToken=="string"?c.clientToken.trim():"";if(!d||!f)return i;if(!await e(d,f))return o+=1,i;s+=1;const{clientToken:a,...u}=c;return{...u,hasToken:!0}})),migrated:s,failed:o}},Or=async()=>{if(typeof window>"u"||!Pe())return;let n;try{n=JSON.parse(window.localStorage.getItem(as)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(o=>!!o&&typeof o=="object"&&typeof o.url=="string"&&typeof o.clientToken=="string"&&!!o.clientToken.trim());if(e.length===0)return;Ct("secure:migrate-start",{count:e.length});const s=await ml(n,async(o,r)=>{const i=Nt(o);return await nt(i,r)?await Kt(i)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(as,JSON.stringify(s.records))}catch(o){console.warn("[mobile-storage] failed to finalize secure token migration",o);return}Ct("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},pl=async()=>(await Or(),ut()),us=async n=>{const e=zr(ut(),n);return rn(e),Pe()&&n.clientToken&&await nt(Re({candidates:n.candidates}),n.clientToken),e},hl=async n=>{const e=ut(),s=e.find(r=>r.id===n)??null,o=e.filter(r=>r.id!==n);return rn(o),s&&Pe()&&await fl(Re(s)),o},gl=1500,ds=async(n,e,s)=>{const o=s?.fast?{totalTimeoutMs:ls}:void 0,r=at({candidates:n})?.serverId??null,i=n.find(a=>a.kind==="relay")??null,c=n.filter(a=>a.kind==="direct"),d=async()=>{for(const a of c){const u=Pt(a.url)||a.url,p=e?{Authorization:`Bearer ${e}`}:void 0,g=await lt(`${u}/health`,{method:"GET"},o);if(be("probe:direct:health",{url:u,ok:g?.ok===!0,status:g?.status??null,source:g?.source??null}),!g?.ok)continue;if(r){const y=await g.json().catch(()=>null),I=y&&typeof y=="object"?y.serverId:null;if(typeof I=="string"&&I&&I!==r){be("probe:server-id-mismatch",{url:u});continue}}const h=await lt(`${u}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:p},o);if(be("probe:direct:session",{url:u,ok:h?.ok===!0,status:h?.status??null,source:h?.source??null,hasToken:!!e}),h?.status===401)return{status:"needs-login"};if(!h||!h.ok&&h.status!==404)continue;const b=await ms(h);if(b&&b.disabled!==!0&&b.authenticated===!1)return{status:"needs-login"};const j=b?.disabled===!0;return!e&&Pe()&&!j&&b?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:u}}}return{status:"unreachable"}},f=async()=>{if(!i)return{status:"unreachable"};const{outcome:a,tunnel:u}=await il(i.relay,e,void 0,s?.fast?ls:Ir,{keepTunnel:!0});return a==="ok"?{status:"ok",transport:{kind:"relay",relay:i.relay,tunnel:u}}:a==="needs-login"||a==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return i?c.length===0?f():new Promise(a=>{let u=!1,p=!1,g,h=null,b=null;const j=N=>{N?.status==="ok"&&N.transport.kind==="relay"&&N.transport.tunnel?.close()},y=N=>{u||(u=!0,a(N))},I=()=>{p||u||(g!==void 0&&(window.clearTimeout(g),g=void 0),f().then(N=>{if(b=N,u||p){j(N);return}if(N.status==="ok"||N.status==="needs-login"){y(N);return}h&&y(h)}))};d().then(N=>{if(h=N,!u){if(N.status==="ok"||N.status==="needs-login"){p=!0,g!==void 0&&window.clearTimeout(g),j(b),y(N);return}if(b){y(b);return}I()}}),g=window.setTimeout(I,gl)}):d()},rt=(n,e,s)=>{n.kind==="relay"?al(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel):bt({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),Lr()},Bt=()=>{const n=ut()[0];return n?.label?.trim()?n.label:null},zt=async n=>{const e=n?.fast!==!1;await Or();const s=ut()[0];if(be("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let o;if(Pe()){if(s.hasToken&&(o=await Kt(Re(s)),!o))return{status:"no-candidate"}}else if(o=s.clientToken,!o&&s.hasToken)return{status:"no-candidate"};const r=await ds(s.candidates,o,{fast:e});return be("auto-connect:probe",{status:r.status,candidates:s.candidates.map(i=>i.kind)}),r.status==="needs-login"?{status:"needs-login",label:s.label}:r.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&Ye()?(r.transport.kind==="relay"&&r.transport.tunnel?.close(),be("auto-connect:superseded",{}),{status:"no-candidate"}):(await us({id:s.id,label:s.label,candidates:s.candidates}),rt(r.transport,o??null,{runtimeKey:Re(s)}),{status:"connected"})},bl=async(n,e)=>{let s="";try{s=Pt(n.url)}catch{return!1}if(!s)return!1;const o=n.clientToken?.trim()||void 0,r=o?{Authorization:`Bearer ${o}`}:void 0,i=e?.fast?{totalTimeoutMs:ls}:void 0;if(!(await lt(`${s}/health`,{method:"GET",headers:r},i))?.ok)return!1;const d=await lt(`${s}/auth/session`,{method:"GET",credentials:o?"omit":"include",headers:r},i);if(!d||!d.ok&&d.status!==404)return!1;const f=await ms(d);return!(f&&f.disabled!==!0&&f.authenticated===!1)},xl=n=>[...n].sort((e,s)=>{const o=(e.priority??100)-(s.priority??100);if(o!==0)return o;const r=i=>i.type==="relay"?2:i.url.startsWith("https://")?0:1;return r(e)-r(s)}).flatMap(e=>{if(e.type==="relay"){const s=nn({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return sn(e.url)}),On=async n=>{const e=at({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const i=lr(s.relay),c=await et(Et,i.fetch("/health").catch(()=>null));if(be("establish:relay:health",{ok:c?.ok===!0,status:c?.status??null}),c?.ok)return{kind:"relay",relay:s.relay,tunnel:i};i.close();continue}const o=Pt(s.url)||s.url,r=await lt(`${o}/health`,{method:"GET"});if(be("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const i=await r.json().catch(()=>null),c=i&&typeof i=="object"?i.serverId:null;if(typeof c=="string"&&c&&c!==e){be("establish:server-id-mismatch",{url:o});continue}}return{kind:"direct",url:o}}}return null},yl=async(n,e)=>{if(!Gt())return bl(n,e);const s=await et(e?.fast?ls:Et,_s("/auth/session").then(r=>r).catch(()=>null));if(!s)return!0;if(s.status===401)return!1;if(!s.ok&&s.status!==404)return!0;const o=await ms(s);return!(o&&o.disabled!==!0&&o.authenticated===!1)},vl=n=>n.kind==="relay"?Gt():!Gt()&&_r(n.url,Ye()),Br=()=>{const n=Rt();return n?ut().find(e=>Re(e)===n)??null:null},Bn=n=>{const e=Rt();return!!e&&Re(n)===e},rs=async n=>{const e=n?.fast!==!1,s=Br();if(!s)return be("reprobe:no-connection",{runtimeKey:!!Rt()}),"no-connection";let o;if(Pe()?o=s.hasToken?await Kt(Re(s)):void 0:o=s.clientToken,!o&&s.hasToken)return be("reprobe:no-token",{hasToken:!0}),"unreachable";be("reprobe:start",{candidates:s.candidates.map(a=>a.kind),fast:e,hasToken:!!o});const r=s.candidates.findIndex(a=>vl(a.kind==="relay"?{kind:"relay",relay:a.relay}:{kind:"direct",url:a.url})),i=r>=0?s.candidates.slice(0,r):s.candidates,c=await ds(i,o,{fast:e});if(be("reprobe:better",{status:c.status,probed:i.length}),c.status==="ok")return await us({id:s.id,label:s.label,candidates:s.candidates}),rt(c.transport,o??null,{runtimeKey:Re(s)}),"switched";if(c.status==="needs-login")return"needs-login";if(r>=0){const a=await yl({url:Ye(),clientToken:o},{fast:e});if(be("reprobe:current",{stillValid:a}),a)return Lr(),"unchanged"}const d=r>=0?s.candidates.slice(r+1):[],f=await ds(d,o,{fast:e});return be("reprobe:fallback",{status:f.status,probed:d.length}),f.status==="ok"?(await us({id:s.id,label:s.label,candidates:s.candidates}),rt(f.transport,o??null,{runtimeKey:Re(s)}),"switched"):f.status==="needs-login"?"needs-login":"unreachable"},wl=5e3;let ys=!1;const jl=async()=>{if(ys)return"skipped";const n=Br();if(!n)return be("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=at(n);if(!e)return be("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";ys=!0;try{const s=await et(Et,_s("/api/client-auth/connection/candidates").then(a=>a).catch(()=>null));if(!s?.ok)return be("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const o=await s.json().catch(()=>null);if(!o||o.serverId!==e.serverId)return be("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(o.candidates)?o.candidates:[],i=[];for(const a of r){if(!a||typeof a!="object")continue;const u=a;if(!(u.type!=="lan"||typeof u.url!="string"))try{const p=Pt(u.url);p&&!i.includes(p)&&i.push(p)}catch{}}if(i.length===0)return be("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const c=fs(n).filter(a=>a.url.startsWith("https://")),d=[...i.map(a=>({kind:"direct",url:a})),...c,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(Rs))===JSON.stringify(d.map(Rs))?"unchanged":(be("candidates:refreshed",{lanCount:i.length}),await us({id:n.id,label:n.label,candidates:d}),"updated")}finally{ys=!1}},Lr=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await jl().catch(()=>"skipped");be("candidates:refresh-result",{result:n}),n==="updated"&&Gt()&&await rs().catch(()=>null)})()},wl)},$r=n=>{const{t:e}=fe(),[s,o]=l.useState(()=>ut()),[r,i]=l.useState(null),[c,d]=l.useState(null),[f,a]=l.useState(null),u=l.useRef(s),p=l.useRef(null),g=l.useRef(el()),h=l.useCallback(x=>{u.current=x,o(x)},[]),b=l.useCallback(x=>{p.current=x,i(x)},[]),j=l.useCallback(x=>{p.current===x&&(p.current=null,i(null))},[]);l.useEffect(()=>{let x=!1;return pl().then(R=>{x||h(R)}),()=>{x=!0}},[h]);const y=l.useCallback(x=>{const R=zr(u.current,x);return h(R),rn(R),R},[h]),I=l.useCallback(async x=>{d(null),b("connect");try{const R=zn(x);if(R.length===0){d(e("mobile.connect.error.urlRequired"));return}const w=x.id?u.current.find(G=>G.id===x.id):u.current.find(G=>cs(G.candidates,R)),_=x.label?.trim()||w?.label||ns(Xe({candidates:R})),D=x.relayGrant;let C=x.clientToken?.trim()||void 0;const k=!!C;C||(Pe()?w?.hasToken&&(C=await Kt(Re({candidates:R}))):C=w?.clientToken),be("connect:start",{candidates:R.map(G=>G.kind),hasToken:!!C});const O=await ds(R,C);if(be("connect:probe",{status:O.status}),O.status==="unreachable"){d(e("mobile.connect.error.unreachable"));return}if(O.status==="needs-login"){y({id:w?.id,label:_,candidates:R}),a({id:w?.id??crypto.randomUUID(),label:_,candidates:R,relay:at({candidates:R})??void 0,relayGrant:D});return}C&&k&&Pe()&&await nt(Re({candidates:R}),C),y({id:w?.id,label:_,candidates:R,clientToken:C}),rt(O.transport,C??null,{runtimeKey:Re({candidates:R}),grant:D}),n()}catch(R){console.warn("[mobile-connect] connect threw",R),d(e("mobile.connect.error.invalidUrl"))}finally{j("connect")}},[b,j,n,y,e]),N=l.useCallback(async x=>{if(p.current==="pairing")return;d(null),b("pairing");const R=xl(x.candidates);let w=null,_=!1;try{if(w=await On(R),!w){d(e("mobile.connect.error.unreachable"));return}const D=JSON.stringify({pairingId:x.pairingId,secret:x.secret,clientLabel:"AiWorker Mobile",clientKind:"mobile",deviceName:"AiWorker Mobile",devicePlatform:Mn(),dedupeKey:Dn()}),C={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:D},k=w.kind==="relay"?await et(Et,w.tunnel.fetch("/api/client-auth/pairing/redeem",C).catch(()=>null)):await lt(`${w.url}/api/client-auth/pairing/redeem`,C);if(!k?.ok){d(e("mobile.connect.error.authRequired"));return}const O=await k.json().catch(()=>null),G=typeof O?.clientToken=="string"?O.clientToken.trim():"";if(!G){d(e("mobile.connect.error.authRequired"));return}const v=typeof O?.server?.label=="string"?O.server.label:"",A=x.label||v||ns(Xe({candidates:R}));if(Pe()&&!await nt(Re({candidates:R}),G)){d(e("mobile.connect.error.authRequired"));return}y({label:A,candidates:R,clientToken:G}),rt(w.kind==="relay"?{kind:"relay",relay:w.relay,tunnel:w.tunnel}:{kind:"direct",url:w.url},G,{runtimeKey:Re({candidates:R})}),_=w.kind==="relay",n()}catch(D){console.warn("[mobile-connect] pairing threw",D),d(e("mobile.connect.error.authRequired"))}finally{!_&&w?.kind==="relay"&&w.tunnel.close(),j("pairing")}},[b,j,n,y,e]),E=l.useCallback(async x=>{if(!f||!x.trim()||p.current==="password")return;d(null),b("password");const R=g.current.begin(),w=()=>g.current.isCurrent(R),{id:_,label:D,candidates:C}=f;let k=null,O=!1;try{if(k=await On(C),!w())return;if(!k){d(e("mobile.connect.error.unreachable"));return}const G={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:x,trustDevice:!0,issueClientToken:!0,clientLabel:"AiWorker Mobile",clientKind:"mobile",devicePlatform:Mn(),dedupeKey:Dn()})};be("password:start",{transport:k.kind});const v=k.kind==="relay"?await et(Et,k.tunnel.fetch("/auth/session",G).catch(()=>null)):await lt(`${k.url}/auth/session`,G);if(!w())return;if(be("password:done",{ok:v?.ok===!0,status:v?.status??null}),!v?.ok){d(e("mobile.connect.error.passwordFailed"));return}const A=await v.json().catch(()=>null);if(!w())return;const L=typeof A?.clientToken=="string"?A.clientToken.trim():"";if(be("password:token",{issued:!!L}),!L){if(k.kind==="direct"&&!Pe()){y({id:_,label:D,candidates:C}),a(null),rt({kind:"direct",url:k.url},null,{runtimeKey:Re({candidates:C})}),n();return}d(e("mobile.connect.error.authRequired"));return}if(Pe()&&(!w()||(await nt(Re({candidates:C}),L),!w()))||!w()||(y({id:_,label:D,candidates:C,clientToken:L}),a(null),rt(k.kind==="relay"?{kind:"relay",relay:k.relay,tunnel:k.tunnel}:{kind:"direct",url:k.url},L,{runtimeKey:Re({candidates:C})}),O=k.kind==="relay",!w()))return;n()}catch(G){if(!w())return;console.warn("[mobile-connect] password threw",G),d(e("mobile.connect.error.passwordFailed"))}finally{!O&&k?.kind==="relay"&&k.tunnel.close(),w()&&j("password")}},[b,j,n,f,y,e]),P=l.useCallback(()=>{g.current.cancel(),j("password"),a(null),d(null)},[j]),S=l.useCallback(async x=>{d(null);let R=zn(x);const w=x.id?u.current.find(k=>k.id===x.id)??null:null;if(w){const k=R.filter(v=>v.kind==="direct"),O=fs(w).filter(v=>v.url.startsWith("https://")&&!k.some(A=>_r(A.url,v.url))),G=at(w);R=[...k,...O,...G?[{kind:"relay",relay:G}]:[]]}if(R.length===0)return d(e("mobile.connect.error.urlRequired")),null;const _=x.clientToken?.trim()||void 0,D=x.label?.trim()||ns(Xe({candidates:R}));if(Pe()){const k=Re({candidates:R});if(_)await nt(k,_);else if(w?.hasToken){const O=Re(w);if(O&&k&&O!==k){const G=await Kt(O);G&&await nt(k,G)}}}return y({id:x.id,label:D,candidates:R,clientToken:_}).find(k=>cs(k.candidates,R))??null},[y,e]),T=l.useCallback(async x=>{const R=u.current.find(_=>_.id===x)??null,w=await hl(x);return h(w),R},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:c,pendingConnection:f,connect:I,redeemPairingConnection:N,submitPassword:E,cancelPassword:P,saveConnection:S,removeConnection:T,setError:d}},Fr=n=>{const e=ue.c(31),{onClose:s}=n,{t:o}=fe(),[r,i]=l.useState(!1);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=Ha(),e[0]=c):c=e[0];const d=c;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{Eo(Ya()).then(x=>{x.ok&&(i(!0),window.setTimeout(()=>i(!1),2e3))})},e[1]=f):f=e[1];const a=f;let u;e[2]!==o?(u=o("mobile.connectionDebug.title"),e[2]=o,e[3]=u):u=e[3];let p;e[4]!==u?(p=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:u}),e[4]=u,e[5]=p):p=e[5];const g=r?"check":"file-copy";let h;e[6]!==g?(h=t.jsx(ee,{name:g,className:"size-4"}),e[6]=g,e[7]=h):h=e[7];let b;e[8]!==r||e[9]!==o?(b=o(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=o,e[10]=b):b=e[10];let j;e[11]!==h||e[12]!==b?(j=t.jsxs(we,{type:"button",variant:"outline",size:"sm",onClick:a,disabled:d.length===0,children:[h,b]}),e[11]=h,e[12]=b,e[13]=j):j=e[13];let y;e[14]!==o?(y=o("mobile.connectionDebug.close"),e[14]=o,e[15]=y):y=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(ee,{name:"close",className:"size-[18px]"}),e[16]=I):I=e[16];let N;e[17]!==s||e[18]!==y?(N=t.jsx(we,{type:"button",variant:"ghost",size:"icon","aria-label":y,onClick:s,children:I}),e[17]=s,e[18]=y,e[19]=N):N=e[19];let E;e[20]!==N||e[21]!==j?(E=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[j,N]}),e[20]=N,e[21]=j,e[22]=E):E=e[22];let P;e[23]!==E||e[24]!==p?(P=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[p,E]}),e[23]=E,e[24]=p,e[25]=P):P=e[25];let S;e[26]!==o?(S=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:d.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:o("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:d.map(Pr).join(`
|
|
4
|
+
`)})}),e[26]=o,e[27]=S):S=e[27];let T;return e[28]!==P||e[29]!==S?(T=t.jsxs("div",{className:"fixed inset-0 z-[70] flex flex-col bg-background pb-[var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))] pt-[var(--safe-area-inset-top,env(safe-area-inset-top,0px))] text-foreground",children:[P,S]}),e[28]=P,e[29]=S,e[30]=T):T=e[30],T},Wr=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},kl=()=>window.Capacitor?.getPlatform?.()==="android",Ur=n=>{const e=n.trim();if(!e)return null;if(/^aiworker:\/\//i.test(e)){const s=xo(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Vr=(n,e)=>{const s=Ur(n);if(!s&&e?.pairingStringFallback){const o=yo(n);if(o)return{status:"pairing",pairing:o}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},Sl=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,o,r=!1,i=()=>{};const c=new Promise(a=>{i=a}),d=a=>{r||(r=!0,i(a))},f=()=>d({status:"cancelled"});e?.addEventListener("abort",f,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:u})=>{const p=u?.[0],g=(p?.rawValue??p?.displayValue??"").trim();g&&d(Vr(g,{pairingStringFallback:!0}))})).then(u=>{s=u}),Promise.resolve(n.addListener("scanError",()=>d({status:"failed"}))).then(u=>{o=u})])).some(({status:u})=>u==="rejected")?d({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>d({status:"failed"})),await c}finally{e?.removeEventListener("abort",f),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(o?.remove()),n.stopScan()])}},Ps=()=>Wr()!==null,Gr=async n=>{const e=Wr();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const c=(await e.requestPermissions())?.camera;if(c&&c!=="granted"&&c!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(kl())return Sl(e,n?.signal);if(!e.scan)return{status:"unsupported"};const o=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],r=(o?.rawValue??o?.displayValue??"").trim();return r?Vr(r):{status:"cancelled"}}catch{return{status:"failed"}}},wt={autoComplete:"off",autoCorrect:"off",spellCheck:!1},Lt="h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20",Kr=n=>{const e=ue.c(22),{onCancel:s}=n,{t:o}=fe(),r=l.useRef(null);let i,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const I={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},N={value:document.body.style.getPropertyValue("background-color"),priority:document.body.style.getPropertyPriority("background-color")};document.documentElement.style.setProperty("background-color","rgba(0, 0, 0, 0)","important"),document.body.style.setProperty("background-color","rgba(0, 0, 0, 0)","important");const E=new Map,P=T=>{!(T instanceof HTMLElement)||T===r.current||E.has(T)||(E.set(T,{opacity:T.style.opacity,pointerEvents:T.style.pointerEvents}),T.style.setProperty("opacity","0"),T.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(P);const S=new MutationObserver(T=>{T.forEach(x=>x.addedNodes.forEach(P))});return S.observe(document.body,{childList:!0}),()=>{S.disconnect(),E.forEach(Nl),I.value?document.documentElement.style.setProperty("background-color",I.value,I.priority):document.documentElement.style.removeProperty("background-color"),N.value?document.body.style.setProperty("background-color",N.value,N.priority):document.body.style.removeProperty("background-color")}},c=[],e[0]=i,e[1]=c):(i=e[0],c=e[1]),l.useLayoutEffect(i,c);let d,f;e[2]!==s?(d=()=>{const I=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",I),()=>document.removeEventListener("visibilitychange",I)},f=[s],e[2]=s,e[3]=d,e[4]=f):(d=e[3],f=e[4]),l.useEffect(d,f);let a;e[5]!==o?(a=o("mobile.connect.scanQr"),e[5]=o,e[6]=a):a=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("div",{className:"aspect-square w-full max-w-72 rounded-[28px] border-2 border-foreground/90 shadow-[0_0_0_9999px_color-mix(in_srgb,var(--surface-background)_18%,transparent)]","aria-hidden":!0}),e[7]=u):u=e[7];let p;e[8]!==o?(p=o("mobile.connect.welcome.scanHint"),e[8]=o,e[9]=p):p=e[9];let g;e[10]!==p?(g=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[u,t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-body text-foreground shadow-sm",children:p})]}),e[10]=p,e[11]=g):g=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(ee,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let b;e[13]!==o?(b=o("mobile.instances.cancelEdit"),e[13]=o,e[14]=b):b=e[14];let j;e[15]!==s||e[16]!==b?(j=t.jsxs(we,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,b]}),e[15]=s,e[16]=b,e[17]=j):j=e[17];let y;return e[18]!==j||e[19]!==a||e[20]!==g?(y=jt.createPortal(t.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":a,className:"fixed inset-0 z-[1000] flex flex-col bg-transparent px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+24px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+24px)] text-foreground",children:[g,j]}),document.body),e[18]=j,e[19]=a,e[20]=g,e[21]=y):y=e[21],y},Hr=()=>{const n=ue.c(6),{t:e}=fe();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(st,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(ee,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=o):o=n[1];let r;n[2]!==e?(r=e("mobile.connect.connecting"),n[2]=e,n[3]=r):r=n[3];let i;return n[4]!==r?(i=jt.createPortal(t.jsxs("div",{role:"status",className:"fixed inset-0 z-[1000] flex flex-col items-center justify-center gap-5 bg-background px-6 text-foreground",children:[s,t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[o,t.jsx("span",{children:r})]})]}),document.body),n[4]=r,n[5]=i):i=n[5],i};function Nl(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const Cl=({onConnected:n,notice:e=null})=>{const{t:s}=fe(),o=$r(n),{connections:r,isBusy:i,isPasswordBusy:c,error:d,pendingConnection:f}=o,[a,u]=l.useState(""),[p,g]=l.useState(""),[h,b]=l.useState(""),[j,y]=l.useState(!1),[I,N]=l.useState(!1),E=l.useRef(null),P=l.useMemo(()=>Ps(),[]),[S,T]=l.useState(()=>!Ps()),[x,R]=l.useState(null),[w,_]=l.useState(""),[D,C]=l.useState(!1),k=Tr(l.useCallback(()=>C(!0),[])),O=l.useCallback($=>{$.preventDefault(),o.connect({url:a,clientToken:h,label:p})},[h,o,p,a]),G=l.useCallback($=>{if(/^aiworker:\/\//i.test($.trim())){const B=Ur($);if(B){if("pairing"in B){o.redeemPairingConnection(B.pairing);return}u(B.url),B.label&&g(B.label),B.clientToken&&b(B.clientToken);return}}u($)},[o]),v=l.useCallback(async()=>{if(E.current||i)return;o.setError(null),y(!0);const $=new AbortController;E.current=$;try{const B=await Gr({signal:$.signal});switch(E.current===$&&(E.current=null,y(!1)),B.status){case"ok":N(!0),u(B.url),B.label&&g(B.label),B.clientToken&&b(B.clientToken),await o.connect({url:B.url,clientToken:B.clientToken,label:B.label});break;case"pairing":N(!0),await o.redeemPairingConnection(B.pairing);break;case"permission-denied":o.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":o.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":o.setError(s("mobile.connect.scan.unsupported"));break;case"failed":o.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{N(!1),E.current===$&&(E.current=null,y(!1))}},[o,i,s]);l.useEffect(()=>()=>E.current?.abort(),[]);const A=l.useCallback($=>{$.preventDefault(),o.submitPassword(w)},[o,w]),L=l.useCallback(()=>{_(""),o.cancelPassword()},[o]);return t.jsxs(t.Fragment,{children:[j?t.jsx(Kr,{onCancel:()=>E.current?.abort()}):null,I?t.jsx(Hr,{}):null,D?t.jsx(Fr,{onClose:()=>C(!1)}):null,t.jsx("main",{className:"oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground",children:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx("span",{...k,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(st,{width:72,height:72,className:"size-[72px]"})}),t.jsx("h1",{className:"typography-h2 text-foreground",children:s("mobile.connect.welcome.title")})]}),e?t.jsxs("div",{role:"status",className:"flex w-full items-center gap-3 rounded-[18px] border border-[color-mix(in_srgb,var(--status-warning)_35%,transparent)] bg-[color-mix(in_srgb,var(--status-warning)_10%,transparent)] px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-[color-mix(in_srgb,var(--status-warning)_16%,transparent)] text-[var(--status-warning)]",children:t.jsx(ee,{name:e.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),t.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:e.kind==="auth-expired"?s("mobile.connect.notice.authExpired",{label:e.label}):s("mobile.connect.notice.unreachable",{label:e.label})})]}):null,f?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:A,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(ee,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-left",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:f.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:f.candidates.some($=>$.kind==="direct")?Xe(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...wt,value:w,onChange:$=>_($.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:Lt}),d?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:d}):null,t.jsx(we,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:c||!w.trim(),children:s(c?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(we,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:L,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[P?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(we,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{v()},disabled:j||i,children:[t.jsx(ee,{name:"scan-2",className:J("size-[18px]",j&&"animate-pulse")}),s(i?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:s("mobile.connect.welcome.scanHint")})]}):null,d&&!S?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:d}):null,r.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map($=>{const B=x===$.id;return t.jsxs("button",{type:"button",disabled:i,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-70",onClick:()=>{R($.id),o.connect({id:$.id,candidates:$.candidates,clientToken:$.clientToken,label:$.label}).finally(()=>R(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(ee,{name:"server",className:"size-[18px]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:$.label}),t.jsx("span",{className:J("block truncate typography-small",B?"text-foreground":"text-muted-foreground"),children:B?s("mobile.connect.connecting"):$.candidates.some(ne=>ne.kind==="direct")?Xe($):s("mobile.connect.relay.badge")})]}),B?t.jsx(ee,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(ee,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},$.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[P?t.jsxs("button",{type:"button",onClick:()=>T($=>!$),"aria-expanded":S,className:"mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(ee,{name:"arrow-down-s",className:J("size-4 transition-transform duration-200",S&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:S?"1fr":"0fr"},children:t.jsx("div",{className:"min-h-0 overflow-hidden",children:t.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:O,children:[t.jsx("input",{...wt,value:a,onChange:$=>G($.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:S?void 0:-1,className:J(Lt,"text-center")}),t.jsx("input",{value:p,onChange:$=>g($.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:S?void 0:-1,className:J(Lt,"text-center")}),t.jsx("input",{...wt,value:h,onChange:$=>b($.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:S?void 0:-1,autoCapitalize:"none",className:J(Lt,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),d?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:d}):null,t.jsx(we,{type:"submit",variant:P?"outline":"default",size:"lg",className:"h-12 w-full",disabled:i||j||!a.trim(),children:s(i?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},El=n=>{const e=n.usedPercent;return typeof e!="number"||!Number.isFinite(e)?"text-foreground":e>=80?"text-[var(--status-error)]":e>=50?"text-[var(--status-warning)]":"text-foreground"},Rl=n=>{const e=ue.c(12),{groups:s,displayMode:o,timeFormatPreference:r,className:i}=n;let c;e[0]!==i?(c=J("space-y-1.5",i),e[0]=i,e[1]=c):c=e[1];let d;if(e[2]!==o||e[3]!==s||e[4]!==r){let a;e[6]!==o||e[7]!==r?(a=u=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ro,{providerId:u.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:u.providerName}),u.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:u.planLabel}):null,u.status&&u.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:u.status}):null]}),u.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:u.rows.map(p=>{const g=o==="remaining"?p.window.remainingPercent:p.window.usedPercent,h=Po(p.window.valueLabel,g),b=To(p.window.resetAt,p.window.resetAfterFormatted??p.window.resetAtFormatted,r);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:p.subtitle?`${p.subtitle} · ${p.label}`:p.label}),b?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:b}):null]}),t.jsx("span",{className:J("shrink-0 typography-ui-label font-semibold tabular-nums",El(p.window)),children:h==="-"?"":h})]},p.key)})}):null,u.status&&u.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:u.status}):null]},u.providerId),e[6]=o,e[7]=r,e[8]=a):a=e[8],d=s.map(a),e[2]=o,e[3]=s,e[4]=r,e[5]=d}else d=e[5];let f;return e[9]!==c||e[10]!==d?(f=t.jsx("div",{className:c,children:d}),e[9]=c,e[10]=d,e[11]=f):f=e[11],f},Ln=380,Pl=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},mt=n=>typeof n=="number"&&Number.isFinite(n)?n:0,$n=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),qr=n=>{const e=ue.c(19),{percentage:s}=n;let o,r,i,c,d,f,a;if(e[0]!==s){i=Mo(s)??0;const b=zo(s);r=b==="critical"?"var(--status-error)":b==="warn"?"var(--status-warning)":"var(--status-success)",o=2*Math.PI*7.5,c="0 0 18 18",d="size-[18px] -rotate-90",f="progressbar",a=Math.round(i),e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=c,e[5]=d,e[6]=f,e[7]=a}else o=e[1],r=e[2],i=e[3],c=e[4],d=e[5],f=e[6],a=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=u):u=e[8];const p=o*(1-i/100);let g;e[9]!==o||e[10]!==r||e[11]!==p?(g=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:r,strokeWidth:3,strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:p,className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=o,e[10]=r,e[11]=p,e[12]=g):g=e[12];let h;return e[13]!==c||e[14]!==d||e[15]!==f||e[16]!==a||e[17]!==g?(h=t.jsxs("svg",{viewBox:c,className:d,role:f,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,children:[u,g]}),e[13]=c,e[14]=d,e[15]=f,e[16]=a,e[17]=g,e[18]=h):h=e[18],h},Tl=n=>{const e=ue.c(13),{icon:s,iconNode:o,label:r,children:i}=n;let c;e[0]!==s||e[1]!==o?(c=o??(s?t.jsx(ee,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=o,e[2]=c):c=e[2];let d;e[3]!==c?(d=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:c}),e[3]=c,e[4]=d):d=e[4];let f;e[5]!==r?(f=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=f):f=e[6];let a;e[7]!==i?(a=t.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:i}),e[7]=i,e[8]=a):a=e[8];let u;return e[9]!==d||e[10]!==f||e[11]!==a?(u=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[d,f,a]}),e[9]=d,e[10]=f,e[11]=a,e[12]=u):u=e[12],u},Al=n=>{const e=ue.c(49),{open:s,onClose:o,anchorRef:r,contextDisplay:i,usageGroups:c,usageDisplayMode:d,isUsageLoading:f,timeFormatPreference:a}=n,{t:u}=fe(),p=l.useRef(null),[g,h]=l.useState(s),[b,j]=l.useState(!1),{enabled:y}=zs(),I=l.useRef(null),[N,E]=l.useState(null);let P,S;e[0]!==r||e[1]!==y||e[2]!==s||e[3]!==g?(P=()=>{if(!s||!y||!g)return;const K=()=>{const se=r.current?.getBoundingClientRect(),ie=I.current?.getBoundingClientRect();if(!se||!ie){E(null);return}const me=se.left-ie.left,ce=Math.min(Math.max(me,8),Math.max(8,ie.width-Ln-8));E(ce)};K();const H=I.current;if(typeof ResizeObserver>"u"||!H)return;const X=new ResizeObserver(K);return X.observe(H),()=>X.disconnect()},S=[r,y,s,g],e[0]=r,e[1]=y,e[2]=s,e[3]=g,e[4]=P,e[5]=S):(P=e[4],S=e[5]),l.useLayoutEffect(P,S);const T=y&&N!==null;let x,R;e[6]!==s||e[7]!==g?(x=()=>{if(s){h(!0),j(!1);return}if(!g)return;j(!0);const K=window.setTimeout(()=>{h(!1),j(!1)},140);return()=>window.clearTimeout(K)},R=[s,g],e[6]=s,e[7]=g,e[8]=x,e[9]=R):(x=e[8],R=e[9]),l.useEffect(x,R);let w,_;e[10]!==o||e[11]!==s?(w=()=>{if(!s)return;const K=H=>{H.key==="Escape"&&o()};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},_=[o,s],e[10]=o,e[11]=s,e[12]=w,e[13]=_):(w=e[12],_=e[13]),l.useEffect(w,_);let D,C;if(e[14]!==r||e[15]!==o||e[16]!==s?(D=()=>{if(!s)return;const K=H=>{const X=H.target;if(!(X instanceof Node)){o();return}p.current?.contains(X)||r.current?.contains(X)||o()};return document.addEventListener("pointerdown",K,!0),document.addEventListener("wheel",K,!0),()=>{document.removeEventListener("pointerdown",K,!0),document.removeEventListener("wheel",K,!0)}},C=[r,o,s],e[14]=r,e[15]=o,e[16]=s,e[17]=D,e[18]=C):(D=e[17],C=e[18]),l.useEffect(D,C),!g)return null;let k;e[19]!==u?(k=u("mobile.header.openMetadataAria"),e[19]=u,e[20]=k):k=e[20];const O=T?"absolute origin-top-left":"mx-3 mt-2",G=b?"pointer-events-none":"pointer-events-auto";let v;e[21]!==O||e[22]!==G?(v=J("overflow-y-auto overscroll-contain rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",O,G),e[21]=O,e[22]=G,e[23]=v):v=e[23];const A=`${b?"session-metadata-out":"session-metadata-in"} ${b?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let L;e[24]!==N||e[25]!==T?(L=T?{top:8,left:N??8,width:`min(${Ln}px, calc(100% - 16px))`}:null,e[24]=N,e[25]=T,e[26]=L):L=e[26];let $;e[27]!==A||e[28]!==L?($={animation:A,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...L},e[27]=A,e[28]=L,e[29]=$):$=e[29];let B;e[30]!==i||e[31]!==u?(B=i?t.jsx(Tl,{iconNode:t.jsx(qr,{percentage:i.percentage}),label:u("mobile.header.metadata.context"),children:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[t.jsxs("span",{className:J("font-semibold",i.colorClass),children:[i.percentage.toFixed(1),"%"]}),t.jsx("span",{className:"text-muted-foreground",children:i.tokens})]})}):null,e[30]=i,e[31]=u,e[32]=B):B=e[32];let ne;e[33]!==f||e[34]!==a||e[35]!==d||e[36]!==c?(ne=t.jsx(Il,{groups:c,displayMode:d,isLoading:f,timeFormatPreference:a}),e[33]=f,e[34]=a,e[35]=d,e[36]=c,e[37]=ne):ne=e[37];let Q;e[38]!==B||e[39]!==ne?(Q=t.jsxs("div",{className:"space-y-1",children:[B,ne]}),e[38]=B,e[39]=ne,e[40]=Q):Q=e[40];let te;e[41]!==v||e[42]!==$||e[43]!==Q||e[44]!==k?(te=t.jsx("div",{ref:p,role:"dialog","aria-label":k,className:v,style:$,children:Q}),e[41]=v,e[42]=$,e[43]=Q,e[44]=k,e[45]=te):te=e[45];let z;e[46]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("style",{children:`
|
|
5
|
+
@keyframes session-metadata-in {
|
|
6
|
+
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
7
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
8
|
+
}
|
|
9
|
+
@keyframes session-metadata-out {
|
|
10
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
11
|
+
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
12
|
+
}
|
|
13
|
+
`}),e[46]=z):z=e[46];let W;return e[47]!==te?(W=t.jsxs("div",{ref:I,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[te,z]}),e[47]=te,e[48]=W):W=e[48],W},Il=n=>{const e=ue.c(30),{groups:s,displayMode:o,isLoading:r,timeFormatPreference:i}=n,{t:c}=fe();let d;e[0]!==o||e[1]!==c?(d=c(o==="remaining"?"header.services.remaining":"header.services.used"),e[0]=o,e[1]=c,e[2]=d):d=e[2];const f=d;if(s.length===0){if(!r)return null;let N;e[3]===Symbol.for("react.memo_cache_sentinel")?(N=t.jsx(ee,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=N):N=e[3];let E;e[4]!==c?(E=c("common.loading"),e[4]=c,e[5]=E):E=e[5];let P;return e[6]!==E?(P=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[N,t.jsx("span",{className:"typography-ui-label",children:E})]}),e[6]=E,e[7]=P):P=e[7],P}let a;e[8]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(ee,{name:"timer",className:"size-[18px]"})}),e[8]=a):a=e[8];let u;e[9]!==c?(u=c("mobile.header.metadata.usage"),e[9]=c,e[10]=u):u=e[10];let p;e[11]!==u?(p=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:u}),e[11]=u,e[12]=p):p=e[12];let g;e[13]!==r?(g=r?t.jsx(ee,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=g):g=e[14];let h;e[15]!==f?(h=t.jsx("span",{className:"truncate",children:f}),e[15]=f,e[16]=h):h=e[16];let b;e[17]!==g||e[18]!==h?(b=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[g,h]}),e[17]=g,e[18]=h,e[19]=b):b=e[19];let j;e[20]!==p||e[21]!==b?(j=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[a,p,b]}),e[20]=p,e[21]=b,e[22]=j):j=e[22];let y;e[23]!==o||e[24]!==s||e[25]!==i?(y=t.jsx(Rl,{groups:s,displayMode:o,timeFormatPreference:i}),e[23]=o,e[24]=s,e[25]=i,e[26]=y):y=e[26];let I;return e[27]!==j||e[28]!==y?(I=t.jsxs("div",{className:"pt-2.5",children:[j,y]}),e[27]=j,e[28]=y,e[29]=I):I=e[29],I},_l=l.memo(function({open:e,onOpenChange:s,currentSessionId:o,effectiveDirectory:r,isNewSessionDraftOpen:i}){const{t:c}=fe(),d=l.useRef(null),f=Ao(o??"",r||void 0),a=Oe(A=>A.providers),u=Oe(A=>A.currentProviderId),p=Oe(A=>A.currentModelId),g=Oe(A=>A.getModelMetadata);Oe(A=>A.modelsMetadata.size);const h=Io(l.useCallback(A=>o?A.sessionModelSelections.get(o)??null:null,[o])),b=ft(A=>A.results),j=ft(A=>A.loadSettings),y=ft(A=>A.fetchAllQuotas),I=ft(A=>A.isLoading),N=ft(A=>A.displayMode),E=ft(A=>A.dropdownProviderIds),P=Je(A=>A.timeFormatPreference);_o(),l.useEffect(()=>{j()},[j]),l.useEffect(()=>{Sn(E)},[E]),l.useEffect(()=>{!e||I||!E.some(L=>!b.some($=>$.providerId===L))||y()},[E,y,I,e,b]);const T=l.useMemo(()=>{for(let A=f.length-1;A>=0;A-=1){const L=f[A];if(L.role!=="user")continue;const $=typeof L.model?.providerID=="string"&&L.model.providerID.trim().length>0?L.model.providerID:void 0,B=typeof L.model?.modelID=="string"&&L.model.modelID.trim().length>0?L.model.modelID:void 0;if($&&B)return{providerID:$,modelID:B}}return null},[f])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(u&&p?{providerID:u,modelID:p}:null),R=(T?a.find(A=>A.id===T.providerID):void 0)?.models.find(A=>A.id===T?.modelID),w=T?g(T.providerID,T.modelID):void 0,_=Pl(R?.limit,"context")??w?.limit?.context??0,D=l.useMemo(()=>{for(let A=f.length-1;A>=0;A-=1){const L=f[A];if(L.role!=="assistant"||!L.tokens)continue;const $=mt(L.tokens.total);if($>0)return $;const B=mt(L.tokens.input)+mt(L.tokens.output)+mt(L.tokens.reasoning)+mt(L.tokens.cache?.read)+mt(L.tokens.cache?.write);if(B>0)return B}return 0},[f]),C=!i&&D>0&&_>0?Math.min(D/_*100,999):null,k=C!==null?`${$n(D)}/${$n(_)}`:null,O=C===null?"":C>=90?"text-[var(--status-error)]":C>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",G=C!==null&&k?{percentage:C,tokens:k,colorClass:O}:null,v=Do();return l.useEffect(()=>{!e||v.length===0||Sn(v.map(A=>A.providerId))},[e,v]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:d,type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":c("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(A=>!A),style:{touchAction:"manipulation"},children:t.jsx(qr,{percentage:G?.percentage??0})}),t.jsx(Al,{open:e,onClose:()=>s(!1),anchorRef:d,contextDisplay:G,usageGroups:v,usageDisplayMode:N,isUsageLoading:I,timeFormatPreference:P})]})}),Dl=10,Fn=380,Ml=(n,e)=>n.title?.trim()||e,zl=n=>{const e=ue.c(32),{session:s,meta:o,active:r,onSelect:i}=n,{t:c}=fe(),d=dr(s.id),f=fr(s.id),a=d?.type??"idle",u=a==="busy"||a==="retry",p=!u&&f>0&&!r,g=mr(s.id,u),h=(u||p)&&g,b=s.time?.updated??s.time?.created??0;let j;e[0]!==b?(j=Bo(b),e[0]=b,e[1]=j):j=e[1];const y=j,I=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let N;e[2]!==I?(N=J("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",I),e[2]=I,e[3]=N):N=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E={touchAction:"manipulation"},e[4]=E):E=e[4];const P=r?"text-primary":"text-foreground";let S;e[5]!==P?(S=J("block truncate typography-ui-label",P),e[5]=P,e[6]=S):S=e[6];let T;e[7]!==s||e[8]!==c?(T=Ml(s,c("sessions.sidebar.session.untitled")),e[7]=s,e[8]=c,e[9]=T):T=e[9];let x;e[10]!==S||e[11]!==T?(x=t.jsx("span",{className:S,children:T}),e[10]=S,e[11]=T,e[12]=x):x=e[12];let R;e[13]!==o?(R=o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null,e[13]=o,e[14]=R):R=e[14];let w;e[15]!==R||e[16]!==x?(w=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[x,R]}),e[15]=R,e[16]=x,e[17]=w):w=e[17];let _;e[18]!==u||e[19]!==p?(_=u||p?t.jsx("span",{className:J("size-1.5 shrink-0 rounded-full",u?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):null,e[18]=u,e[19]=p,e[20]=_):_=e[20];let D;e[21]!==u||e[22]!==s.id||e[23]!==h||e[24]!==y?(D=h?t.jsx(kr,{sessionId:s.id,running:u,className:"typography-micro"}):y?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:y}):null,e[21]=u,e[22]=s.id,e[23]=h,e[24]=y,e[25]=D):D=e[25];let C;return e[26]!==i||e[27]!==w||e[28]!==_||e[29]!==D||e[30]!==N?(C=t.jsxs("button",{type:"button",className:N,onClick:i,style:E,children:[w,_,D]}),e[26]=i,e[27]=w,e[28]=_,e[29]=D,e[30]=N,e[31]=C):C=e[31],C},Ol=n=>{const e=ue.c(50),{open:s,onClose:o,anchorRef:r}=n,{t:i}=fe(),c=l.useRef(null),[d,f]=l.useState(s),[a,u]=l.useState(!1),{enabled:p}=zs(),g=l.useRef(null),[h,b]=l.useState(null);let j,y;e[0]!==r||e[1]!==p||e[2]!==s||e[3]!==d?(j=()=>{if(!s||!p||!d)return;const H=()=>{const ie=r.current?.getBoundingClientRect(),me=g.current?.getBoundingClientRect();if(!ie||!me){b(null);return}const ce=ie.left-me.left;b(Math.min(Math.max(ce,8),Math.max(8,me.width-Fn-8)))};H();const X=g.current;if(typeof ResizeObserver>"u"||!X)return;const se=new ResizeObserver(H);return se.observe(X),()=>se.disconnect()},y=[r,p,s,d],e[0]=r,e[1]=p,e[2]=s,e[3]=d,e[4]=j,e[5]=y):(j=e[4],y=e[5]),l.useLayoutEffect(j,y);const I=p&&h!==null,N=ke(Bl),E=ke(Ll),P=Be($l);let S;e[6]===Symbol.for("react.memo_cache_sentinel")?(S={maxParents:Dl},e[6]=S):S=e[6];const T=Oo(s||d,S);let x,R;e[7]!==s||e[8]!==d?(x=()=>{if(s){Os(),f(!0),u(!1);return}if(!d)return;u(!0);const H=window.setTimeout(()=>{f(!1),u(!1)},140);return()=>window.clearTimeout(H)},R=[s,d],e[7]=s,e[8]=d,e[9]=x,e[10]=R):(x=e[9],R=e[10]),l.useEffect(x,R);let w,_;e[11]!==o||e[12]!==s?(w=()=>{if(!s)return;const H=X=>{X.key==="Escape"&&o()};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},_=[o,s],e[11]=o,e[12]=s,e[13]=w,e[14]=_):(w=e[13],_=e[14]),l.useEffect(w,_);let D,C;e[15]!==r||e[16]!==o||e[17]!==s?(D=()=>{if(!s)return;const H=X=>{const se=X.target;if(!(se instanceof Node)){o();return}c.current?.contains(se)||r.current?.contains(se)||o()};return document.addEventListener("pointerdown",H,!0),()=>document.removeEventListener("pointerdown",H,!0)},C=[r,o,s],e[15]=r,e[16]=o,e[17]=s,e[18]=D,e[19]=C):(D=e[18],C=e[19]),l.useEffect(D,C);let k;e[20]!==o||e[21]!==E?(k=H=>{E(H.id,Ms(H)),o()},e[20]=o,e[21]=E,e[22]=k):k=e[22];const O=k;if(!d)return null;let G;e[23]!==i?(G=i("sessions.switcher.openAria"),e[23]=i,e[24]=G):G=e[24];const v=I?"absolute origin-top-left":"mx-3 mt-2",A=a?"pointer-events-none":"pointer-events-auto";let L;e[25]!==v||e[26]!==A?(L=J("flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",v,A),e[25]=v,e[26]=A,e[27]=L):L=e[27];const $=`${a?"session-switcher-out":"session-switcher-in"} ${a?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let B;e[28]!==h||e[29]!==I?(B=I?{top:8,left:h??8,width:`min(${Fn}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=I,e[30]=B):B=e[30];let ne;e[31]!==$||e[32]!==B?(ne={animation:$,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...B},e[31]=$,e[32]=B,e[33]=ne):ne=e[33];let Q;e[34]!==N||e[35]!==O||e[36]!==T||e[37]!==P||e[38]!==i?(Q=T.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:i("sessions.switcher.empty")}):T.map(H=>{const X=H.node.session,se=[H.secondaryMeta?.projectLabel,H.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(zl,{session:X,meta:se,active:X.id===N,onSelect:()=>{H.projectId&&P(H.projectId),O(X)}},X.id)}),e[34]=N,e[35]=O,e[36]=T,e[37]=P,e[38]=i,e[39]=Q):Q=e[39];let te;e[40]!==Q?(te=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:Q}),e[40]=Q,e[41]=te):te=e[41];let z;e[42]!==G||e[43]!==L||e[44]!==ne||e[45]!==te?(z=t.jsx("div",{ref:c,role:"dialog","aria-label":G,className:L,style:ne,children:te}),e[42]=G,e[43]=L,e[44]=ne,e[45]=te,e[46]=z):z=e[46];let W;e[47]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx("style",{children:`
|
|
14
|
+
@keyframes session-switcher-in {
|
|
15
|
+
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
16
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
17
|
+
}
|
|
18
|
+
@keyframes session-switcher-out {
|
|
19
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
20
|
+
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
21
|
+
}
|
|
22
|
+
`}),e[47]=W):W=e[47];let K;return e[48]!==z?(K=t.jsxs("div",{ref:g,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[z,W]}),e[48]=z,e[49]=K):K=e[49],K};function Bl(n){return n.currentSessionId}function Ll(n){return n.setCurrentSession}function $l(n){return n.setActiveProjectIdOnly}const Fl=n=>{const e=ue.c(71),{onOpenSessions:s,onOpenWorkspace:o,compactTitle:r}=n,i=r===void 0?!1:r,{t:c}=fe(),[d,f]=l.useState(!1),[a,u]=l.useState(!1),p=l.useRef(null),g=it(Wl),h=ke(Ul);let b;e[0]!==h?(b=xe=>h?xe.getDirectoryForSession(h):null,e[0]=h,e[1]=b):b=e[1];const y=ke(b)||g,I=Lo(h,y||void 0),N=ke(Vl);let E;e[2]!==I?.title?(E=I?.title?.trim(),e[2]=I?.title,e[3]=E):E=e[3];const P=E;let S;e[4]!==h||e[5]!==P||e[6]!==c?(S=P||c(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[4]=h,e[5]=P,e[6]=c,e[7]=S):S=e[7];const T=S;let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{f(!1),u(!1)},e[8]=x):x=e[8];let R;e[9]!==h||e[10]!==y?(R=[h,y],e[9]=h,e[10]=y,e[11]=R):R=e[11],l.useEffect(x,R);let w;e[12]!==s?(w=()=>{f(!1),u(!1),s()},e[12]=s,e[13]=w):w=e[13];const _=w;let D;e[14]===Symbol.for("react.memo_cache_sentinel")?(D=xe=>{f(_e=>{const Se=typeof xe=="function"?xe(_e):xe;return Se&&u(!1),Se})},e[14]=D):D=e[14];const C=D;let k;e[15]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{u(xe=>{const _e=!xe;return _e&&f(!1),_e})},e[15]=k):k=e[15];const O=k;let G;e[16]===Symbol.for("react.memo_cache_sentinel")?(G={paddingTop:"var(--oc-safe-area-top, 0px)"},e[16]=G):G=e[16];let v;e[17]!==c?(v=c("mobile.sessions.openSheetAria"),e[17]=c,e[18]=v):v=e[18];let A,L;e[19]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"manipulation"},L=t.jsx(ee,{name:"list-unordered",className:"size-5"}),e[19]=A,e[20]=L):(A=e[19],L=e[20]);let $;e[21]!==_||e[22]!==v?($=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":v,onClick:_,style:A,children:L}),e[21]=_,e[22]=v,e[23]=$):$=e[23];const B=i?"shrink":"flex-1";let ne;e[24]!==B?(ne=J("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",B),e[24]=B,e[25]=ne):ne=e[25];let Q;e[26]!==c?(Q=c("sessions.switcher.openAria"),e[26]=c,e[27]=Q):Q=e[27];let te;e[28]===Symbol.for("react.memo_cache_sentinel")?(te={touchAction:"manipulation"},e[28]=te):te=e[28];let z;e[29]!==T?(z=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:T}),e[29]=T,e[30]=z):z=e[30];const W=a&&"rotate-180";let K;e[31]!==W?(K=J("size-4 shrink-0 text-muted-foreground transition-transform duration-150",W),e[31]=W,e[32]=K):K=e[32];let H;e[33]!==K?(H=t.jsx(ee,{name:"arrow-down-s",className:K}),e[33]=K,e[34]=H):H=e[34];let X;e[35]!==z||e[36]!==H?(X=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[z,H]}),e[35]=z,e[36]=H,e[37]=X):X=e[37];let se;e[38]!==a||e[39]!==ne||e[40]!==Q||e[41]!==X?(se=t.jsx("button",{ref:p,type:"button",className:ne,"aria-label":Q,"aria-haspopup":"dialog","aria-expanded":a,onClick:O,style:te,children:X}),e[38]=a,e[39]=ne,e[40]=Q,e[41]=X,e[42]=se):se=e[42];let ie;e[43]!==i?(ie=i?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[43]=i,e[44]=ie):ie=e[44];let me;e[45]!==h||e[46]!==y||e[47]!==N||e[48]!==d?(me=t.jsx(_l,{open:d,onOpenChange:C,currentSessionId:h,effectiveDirectory:y,isNewSessionDraftOpen:N}),e[45]=h,e[46]=y,e[47]=N,e[48]=d,e[49]=me):me=e[49];let ce;e[50]!==c?(ce=c("mobile.header.openWorkspaceAria"),e[50]=c,e[51]=ce):ce=e[51];let q;e[52]!==o?(q=()=>{f(!1),u(!1),o()},e[52]=o,e[53]=q):q=e[53];let re,U;e[54]===Symbol.for("react.memo_cache_sentinel")?(re={touchAction:"manipulation"},U=t.jsx(ee,{name:"pencil-ruler-2",className:"size-5"}),e[54]=re,e[55]=U):(re=e[54],U=e[55]);let ae;e[56]!==ce||e[57]!==q?(ae=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":ce,onClick:q,style:re,children:U}),e[56]=ce,e[57]=q,e[58]=ae):ae=e[58];let Ee;e[59]!==$||e[60]!==se||e[61]!==ie||e[62]!==me||e[63]!==ae?(Ee=t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:G,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[$,se,ie,me,ae]})}),e[59]=$,e[60]=se,e[61]=ie,e[62]=me,e[63]=ae,e[64]=Ee):Ee=e[64];let ye;e[65]===Symbol.for("react.memo_cache_sentinel")?(ye=()=>u(!1),e[65]=ye):ye=e[65];let Te;e[66]!==a?(Te=t.jsx(Ol,{open:a,onClose:ye,anchorRef:p}),e[66]=a,e[67]=Te):Te=e[67];let $e;return e[68]!==Ee||e[69]!==Te?($e=t.jsxs(t.Fragment,{children:[Ee,Te]}),e[68]=Ee,e[69]=Te,e[70]=$e):$e=e[70],$e};function Wl(n){return n.currentDirectory}function Ul(n){return n.currentSessionId}function Vl(n){return!!n.newSessionDraft?.open}const Gl=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=fe(),o=$r(e),{connections:r,isBusy:i,isPasswordBusy:c,error:d,pendingConnection:f,connect:a,submitPassword:u,cancelPassword:p,saveConnection:g,removeConnection:h,setError:b}=o,[j,y]=l.useState(null),I=j?r.find(q=>q.id===j)??null:null,[N,E]=l.useState(null),[P,S]=l.useState(""),[T,x]=l.useState(""),[R,w]=l.useState(""),[_,D]=l.useState(""),[C,k]=l.useState(!1),[O,G]=l.useState(!1),v=l.useRef(null),A=l.useMemo(()=>Ps(),[]),[L,$]=l.useState(!1),[B,ne]=l.useState(null),[Q,te]=l.useState(!1),z=Tr(l.useCallback(()=>te(!0),[])),W=l.useCallback(()=>{y(null),S(""),x(""),w(""),b(null),$(!1)},[b]),K=l.useCallback(q=>{q.preventDefault(),g({id:j??void 0,url:P,label:T,clientToken:R}).then(re=>{re&&W()})},[R,j,T,W,g,P]),H=l.useCallback(async()=>{if(v.current)return;b(null),k(!0);const q=new AbortController;v.current=q;try{const re=await Gr({signal:q.signal});switch(v.current===q&&(v.current=null,k(!1)),re.status){case"ok":S(re.url),re.label&&x(re.label),re.clientToken&&w(re.clientToken),$(!0);break;case"pairing":G(!0),await o.redeemPairingConnection(re.pairing);break;case"permission-denied":b(s("mobile.connect.scan.permissionDenied"));break;case"invalid":b(s("mobile.connect.scan.invalid"));break;case"unsupported":b(s("mobile.connect.scan.unsupported"));break;case"failed":b(s("mobile.connect.scan.failed"));break;default:break}}finally{G(!1),v.current===q&&(v.current=null,k(!1))}},[o,b,s]);l.useEffect(()=>()=>v.current?.abort(),[]);const X=l.useCallback(q=>{q.preventDefault(),u(_)},[_,u]),se=l.useCallback(()=>{D(""),p()},[p]),ie=l.useCallback(q=>{E(re=>re===q?null:q)},[]),me=l.useCallback(q=>{E(null),j===q&&W();const re=r.length===1;h(q).then(U=>{U&&(re||Bn(U))&&n()})},[r.length,j,n,h,W]),ce=Lt;return f?t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("form",{className:"flex-1 overflow-y-auto px-5 py-4",onSubmit:X,children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(ee,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:f.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:f.candidates.some(q=>q.kind==="direct")?Xe(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...wt,value:_,onChange:q=>D(q.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:ce}),d?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:d}):null,t.jsx(we,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:c||!_.trim(),children:s(c?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(we,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:se,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[C?t.jsx(Kr,{onCancel:()=>v.current?.abort()}):null,O?t.jsx(Hr,{}):null,Q?t.jsx(Fr,{onClose:()=>te(!1)}):null,t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsxs("div",{className:"space-y-6",children:[r.length>0?t.jsx("div",{...z,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(q=>{const re=N===q.id,U=Bn(q),ae=B===q.id,Ee=ae?s("mobile.connect.connecting"):U?Gt()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):q.candidates.some(ye=>ye.kind==="direct")?Xe(q):s("mobile.connect.relay.badge");return t.jsxs("div",{className:J("flex items-center border-b border-border/70 transition-colors last:border-b-0",re&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-60",onClick:()=>{U||(ne(q.id),a({id:q.id,candidates:q.candidates,clientToken:q.clientToken,label:q.label}).finally(()=>ne(null)))},disabled:i&&!ae||re,children:[t.jsxs("span",{className:"relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:[t.jsx(ee,{name:"server",className:"size-[18px]"}),U?t.jsx("span",{className:"absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:q.label}),t.jsx("span",{className:J("block truncate typography-small",U&&!ae?"text-[var(--status-success)]":"text-muted-foreground"),children:Ee})]}),ae?t.jsx(ee,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pr-2",children:[re?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:q.label}),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive",onClick:()=>me(q.id),style:{touchAction:"manipulation"},children:[t.jsx(ee,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):q.candidates.some(ye=>ye.kind==="direct")?t.jsx("button",{type:"button","aria-label":s("mobile.instances.edit"),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>{y(q.id),S(Xe(q)),x(q.label),w(q.clientToken||""),b(null)},style:{touchAction:"manipulation"},children:t.jsx(ee,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":re?s("mobile.instances.cancelDeleteAria",{label:q.label}):s("mobile.instances.deleteAria",{label:q.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>ie(q.id),style:{touchAction:"manipulation"},children:t.jsx(ee,{name:re?"close":"delete-bin",className:"size-[18px]"})})]})]},q.id)})}):t.jsx("p",{...z,className:"rounded-[18px] border border-dashed border-border/70 px-4 py-6 text-center typography-small text-muted-foreground",children:s("mobile.connect.saved.empty")}),!L&&!I?t.jsxs("div",{className:"space-y-2",children:[A?t.jsxs(we,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{H()},disabled:C,children:[t.jsx(ee,{name:"scan-2",className:J("size-[18px]",C&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(we,{type:"button",variant:A?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{b(null),$(!0)},children:[t.jsx(ee,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),d?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:d}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:K,children:[t.jsxs("div",{className:"flex h-8 items-center justify-between gap-3 px-1",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:s(I?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(we,{type:"button",variant:"ghost",size:"xs",onClick:W,children:s("mobile.instances.cancelEdit")})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.url.label")}),t.jsx("input",{...wt,value:P,onChange:q=>S(q.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:ce})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.instances.label.label")}),t.jsx("input",{value:T,onChange:q=>x(q.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:ce})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.token.label")}),t.jsx("input",{...wt,value:R,onChange:q=>w(q.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:ce}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),d?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:d}):null,t.jsx(we,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(I?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Ce=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),vs=n=>{const e=Ce(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},Wn=en(n=>({expandedParents:{},toggleParent:e=>n(s=>{const o={...s.expandedParents};return o[e]?delete o[e]:o[e]=!0,{expandedParents:o}})})),es=en()(Er(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(o=>({projectExpanded:{...o.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(o=>({worktreeExpanded:{...o.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),Ts=en()(Er(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(o=>({orderByProject:{...o.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),Un=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Kl=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,i)=>[Un(r),i])),o=r=>s.get(Un(r.path))??Number.MAX_SAFE_INTEGER;return e.map((r,i)=>({worktree:r,index:i})).sort((r,i)=>{const c=o(r.worktree)-o(i.worktree);return c!==0?c:r.index-i.index}).map(r=>r.worktree)},$t=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Hl=n=>{const e=n;return $t(e.directory??e.project?.worktree??null)},Yr=({open:n,project:e,worktree:s,onClose:o,onDeleted:r})=>{const{t:i}=fe(),c=pr(),d=Ds(w=>w.activeSessions),f=ke(w=>w.archiveSessions),a=it(w=>w.currentDirectory),[u,p]=l.useState(!1),[g,h]=l.useState(!1),[b,j]=l.useState(!1),[y,I]=l.useState(!1),N=$t(s?.path),E=typeof s?.branch=="string"&&s.branch.trim().length>0,P=l.useMemo(()=>{if(!N)return[];const w=new Map;for(const _ of[...d,...c])Hl(_)===N&&w.set(_.id,_);return Array.from(w.values())},[d,c,N]);l.useEffect(()=>{if(!n){p(!1),h(!1),j(!1),I(!1);return}if(!s?.path)return;let w=!1;return $o(s.path).then(_=>{w||j(!!_?.isDirty)}).catch(()=>{w||j(!!s.status?.isDirty)}),()=>{w=!0}},[n,s?.path,s?.status?.isDirty]);const S=l.useCallback((w,_)=>{const D=Fo(w),C=le.loading(i("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:D}));(async()=>{try{if(_.length>0){const{failedIds:k}=await f(_);if(k.length>0){le.error(k.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:k.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:k.length}),{id:C,description:i("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}}await Wo(e,w,{deleteRemoteBranch:E&&g,deleteLocalBranch:E&&u}),$t(a)===N&&$t(e.path)&&it.getState().setDirectory($t(e.path),{showOverlay:!1}),le.success(i("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:D}),{id:C,description:i(E&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(k){le.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:D}),{id:C,description:k instanceof Error?k.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[f,a,u,g,E,r,e,i,N]),T=()=>{!s||y||(I(!0),S(s,P.map(w=>w.id)),o())};if(!s)return null;const x=s.branch||s.label||s.path,R=(w,_,D,C)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":w,disabled:C,onClick:()=>_(!w),className:J("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-left transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",C&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:D}),t.jsx("span",{className:J("relative h-6 w-10 shrink-0 rounded-full transition-colors",w?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:J("absolute top-0.5 size-5 rounded-full bg-white transition-transform",w?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(Uo,{open:n,onClose:o,title:i("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(we,{variant:"ghost",className:"flex-1",onClick:o,disabled:y,children:i("projectEditDialog.actions.cancel")}),t.jsx(we,{variant:"destructive",className:"flex-1",onClick:()=>{T()},disabled:y,children:i("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:i("mobile.projectEdit.deleteWorktreeConfirm",{name:x})}),b?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:i("mobile.projectEdit.deleteWorktreeDirty")}):null,P.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("mobile.projectEdit.deleteWorktreeArchiveNote",{count:P.length})}):null,E?t.jsxs("div",{className:"flex flex-col gap-2",children:[R(u,p,i("mobile.projectEdit.deleteLocalBranch"),y),R(g,h,i("mobile.projectEdit.deleteRemoteBranch"),y)]}):null]})})},Vn="mobile-surface-root",ws=16,ts=200,ql=()=>{if(typeof document>"u")return null;let n=document.getElementById(Vn);return n||(n=document.createElement("div"),n.id=Vn,document.body.appendChild(n)),n},Ft=({open:n,onClose:e,title:s,subtitle:o,trailing:r,disableEscapeDismiss:i=!1,headerless:c=!1,noHeaderBorder:d=!1,ariaLabel:f,variant:a="fullscreen",dialogAlign:u="chat",children:p})=>{const{t:g}=fe(),h=l.useRef(null),[b,j]=l.useState(!1),[y,I]=l.useState(!1),N=l.useRef(null),E=l.useRef(null),P=l.useRef(e);if(l.useEffect(()=>{P.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=ql()),l.useEffect(()=>{if(!n){j(!1);return}const x=window.setTimeout(()=>j(!0),ws);return()=>window.clearTimeout(x)},[n]),l.useEffect(()=>{if(!n){I(!1);return}const x=window.setTimeout(()=>I(!0),ws+ts+80);return()=>window.clearTimeout(x)},[n]),l.useEffect(()=>{if(!n)return;const x=document.body.style.overflow;E.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const R=()=>{const D=N.current;if(!D)return;(D.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??D).focus({preventScroll:!0})},w=window.setTimeout(R,ws),_=D=>{if(D.key==="Escape"&&!i){P.current();return}if(D.key!=="Tab")return;const C=N.current;if(!C)return;const k=Array.from(C.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(A=>!A.hasAttribute("disabled")&&A.getAttribute("aria-hidden")!=="true");if(k.length===0){D.preventDefault(),C.focus({preventScroll:!0});return}const O=k[0],G=k[k.length-1],v=document.activeElement;D.shiftKey&&v===O?(D.preventDefault(),G.focus({preventScroll:!0})):!D.shiftKey&&v===G&&(D.preventDefault(),O.focus({preventScroll:!0}))};return document.addEventListener("keydown",_),()=>{window.clearTimeout(w),document.body.style.overflow=x,document.removeEventListener("keydown",_),E.current?.focus?.({preventScroll:!0}),E.current=null}},[i,n]),!n||!h.current)return null;const S=a==="dialog",T=t.jsxs("section",{ref:N,role:"dialog","aria-modal":"true","aria-label":f,tabIndex:-1,className:J("flex flex-col bg-background text-foreground",S?"h-[min(88dvh,860px)] w-full max-w-[720px] overflow-hidden rounded-2xl border border-border/70 shadow-[0_24px_64px_rgb(0_0_0_/_0.32)]":"oc-keyboard-inset-surface fixed inset-0 z-50"),style:S?{opacity:b?1:0,transform:b?"none":"scale(0.97)",transition:`opacity ${ts}ms ease-out, transform ${ts}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:b?"none":"translateX(100%)",transition:`transform ${ts}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:x=>{b&&x.target===x.currentTarget&&x.propertyName==="transform"&&I(!0)},children:[c?null:t.jsxs("header",{className:J("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!d&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":g("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(ee,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,o?typeof o=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:o}):o:null]}),r?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:r}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:y?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:p}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return S?jt.createPortal(t.jsx("div",{className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200 ease-out",style:{background:"rgb(0 0 0 / 0.45)",opacity:b?1:0,paddingLeft:u==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:u==="chat"?"max(1rem, var(--oc-chat-inset-right, 0px))":"1rem",paddingTop:"max(1rem, var(--oc-safe-area-top, 0px))"},onClick:e,children:t.jsx("div",{className:"flex w-full max-w-[720px] justify-center",onClick:x=>x.stopPropagation(),children:T})}),h.current):jt.createPortal(T,h.current)},Yl=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Jl=n=>{const e=ue.c(36),{worktree:s,onDelete:o}=n,{t:r}=fe();let i;e[0]!==s.path?(i={id:s.path},e[0]=s.path,e[1]=i):i=e[1];const{attributes:c,listeners:d,setNodeRef:f,transform:a,transition:u,isDragging:p}=Qs(i);let g;e[2]!==a?(g=Zs.Transform.toString(a),e[2]=a,e[3]=g):g=e[3];const h=p?10:1;let b;e[4]!==g||e[5]!==h||e[6]!==u?(b={transform:g,transition:u,zIndex:h},e[4]=g,e[5]=h,e[6]=u,e[7]=b):b=e[7];const j=b,y=s.branch||s.label||s.path,I=p&&"shadow-lg shadow-black/20";let N;e[8]!==I?(N=J("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",I),e[8]=I,e[9]=N):N=e[9];let E;e[10]!==y||e[11]!==r?(E=r("mobile.projectEdit.dragWorktreeAria",{label:y}),e[10]=y,e[11]=r,e[12]=E):E=e[12];let P;e[13]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(Ws,{className:"size-4"}),e[13]=P):P=e[13];let S;e[14]!==c||e[15]!==d||e[16]!==E?(S=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":E,...c,...d,children:P}),e[14]=c,e[15]=d,e[16]=E,e[17]=S):S=e[17];let T;e[18]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(ee,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=T):T=e[18];let x;e[19]!==y?(x=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:y}),e[19]=y,e[20]=x):x=e[20];let R;e[21]!==y||e[22]!==r?(R=r("mobile.projectEdit.deleteWorktreeAria",{label:y}),e[21]=y,e[22]=r,e[23]=R):R=e[23];let w,_;e[24]===Symbol.for("react.memo_cache_sentinel")?(w={touchAction:"manipulation"},_=t.jsx(is,{className:"size-4"}),e[24]=w,e[25]=_):(w=e[24],_=e[25]);let D;e[26]!==o||e[27]!==R?(D=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":R,onClick:o,style:w,children:_}),e[26]=o,e[27]=R,e[28]=D):D=e[28];let C;return e[29]!==f||e[30]!==j||e[31]!==x||e[32]!==D||e[33]!==N||e[34]!==S?(C=t.jsxs("div",{ref:f,style:j,className:N,children:[S,T,x,D]}),e[29]=f,e[30]=j,e[31]=x,e[32]=D,e[33]=N,e[34]=S,e[35]=C):C=e[35],C},Xl=({open:n,project:e,onClose:s,onWorktreesChanged:o})=>{const{t:r}=fe(),{currentTheme:i}=hr(),c=Be(v=>v.updateProjectMeta),d=Be(v=>v.discoverProjectIcon),f=Be(v=>v.removeProjectIcon),a=Ts(v=>v.setWorktreeOrder),u=Be(v=>e?v.projects.find(A=>A.id===e.id)?.iconImage??null:null),[p,g]=l.useState(""),[h,b]=l.useState(null),[j,y]=l.useState(null),[I,N]=l.useState(!1),[E,P]=l.useState([]),[S,T]=l.useState(null),x=e?.id??null;l.useEffect(()=>{!n||!e||(g(e.label),b(e.icon??null),y(e.color??null),P(e.worktrees))},[n,x]),l.useEffect(()=>{!n||!e||P(v=>{const A=e.worktrees.map(B=>B.path),L=v.map(B=>B.path);return A.length===L.length&&A.every(B=>L.includes(B))?v:e.worktrees})},[e?.worktrees]);const R=Vs(St(Ks,{activationConstraint:{distance:8}}),St(Gs,{coordinateGetter:Ys})),w=()=>{if(!e)return;const v=p.trim();c(e.id,{label:v||e.label,icon:h,color:j}),s()},_=()=>{!e||I||(N(!0),d(e.id).then(v=>{if(!v.ok){le.error(v.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(v.skipped){le.success(r("projectEditDialog.toast.customIconAlreadySet"));return}le.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>N(!1)))},D=()=>{e&&f(e.id).then(v=>{if(!v.ok){le.error(v.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}le.success(r("projectEditDialog.toast.iconRemoved"))})},C=v=>{const{active:A,over:L}=v;if(!L||A.id===L.id||!e)return;const $=E.findIndex(te=>te.path===A.id),B=E.findIndex(te=>te.path===L.id);if($<0||B<0)return;const ne=[...E],[Q]=ne.splice($,1);ne.splice(B,0,Q),P(ne),a(e.id,ne.map(te=>Yl(te.path)))},k=j?gr[j]??null:null,O=h?br[h]:null,G=!!u;return t.jsxs(t.Fragment,{children:[t.jsx(Ft,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(we,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:w,disabled:!p.trim(),style:{touchAction:"manipulation"},children:[t.jsx(Sr,{className:"size-4"}),r("projectEditDialog.actions.save")]}),children:e?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:e.iconBackground?{backgroundColor:e.iconBackground}:void 0,children:G?t.jsx(xr,{project:{id:e.id,iconImage:u},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(Cs,{className:"size-7"})}):O?t.jsx(ee,{name:O,className:"size-7",style:k?{color:k}:void 0}):t.jsx(Cs,{className:"size-7",style:k?{color:k}:void 0})})}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.name")}),t.jsx(Bs,{value:p,onChange:v=>g(v.target.value),placeholder:r("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:e.path,children:e.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":r("projectEditDialog.option.none"),className:J("flex size-9 items-center justify-center rounded-xl border-2 transition-all",j===null?"border-foreground":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),Vo.map(v=>t.jsx("button",{type:"button",onClick:()=>y(v.key),"aria-label":v.label,title:v.label,className:J("size-9 rounded-xl border-2 transition-all",j===v.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:v.cssVar,touchAction:"manipulation"}},v.key))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>b(null),"aria-label":r("projectEditDialog.option.none"),className:J("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===null?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),Go.map(v=>t.jsx("button",{type:"button",onClick:()=>b(v.key),"aria-label":v.label,title:v.label,className:J("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===v.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(ee,{name:v.Icon,className:"size-4",style:k?{color:k}:void 0})},v.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(we,{size:"sm",variant:"outline",onClick:_,disabled:I,children:r(I?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),G?t.jsx(we,{size:"sm",variant:"outline",onClick:D,children:r("projectEditDialog.actions.removeProjectIcon")}):null]})]}),e.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("mobile.projectEdit.worktreesTitle")}),E.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.reorderHint")}),t.jsx(Hs,{sensors:R,collisionDetection:qs,onDragEnd:C,children:t.jsx(Js,{items:E.map(v=>v.path),strategy:Xs,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:E.map(v=>t.jsx(Jl,{worktree:v,onDelete:()=>T(v)},v.path))})})})]})]}):null]}):null}),e?t.jsx(Yr,{open:!!S,project:{id:e.id,path:e.path},worktree:S,onClose:()=>T(null),onDeleted:()=>{P(v=>v.filter(A=>A.path!==S?.path)),o?.()}}):null]})},Ql=new Set,js=7,ss=40,Zl=16,pt=n=>n.parentID??null,gt=n=>{const e=n;return Ce(e.directory??e.project?.worktree??null)},ec=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},tc=n=>{if(n<=0)return"";const e=Date.now()-n;if(e<6e4)return"now";const s=Math.floor(e/6e4);if(s<60)return`${s}m`;const o=Math.floor(s/60);if(o<24)return`${o}h`;const r=Math.floor(o/24);return r<7?`${r}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},sc=(n,e)=>{const s=Ce(n),o=Ce(e);return!!(s&&o&&(s===o||s.startsWith(`${o}/`)))},os=(n,e)=>n.worktrees.find(s=>Ce(s.path)===e)??null,As=(n,e)=>e===n.path||!!os(n,e),ks=(n,e)=>{const s=Ce(e);return s?n.find(o=>As(o,s))??null:null},Ss=(n,e,s)=>yr([n.title,n.id,gt(n),e],s),Is=n=>{const e=ue.c(17),{project:s,size:o}=n,r=o===void 0?"md":o,{currentTheme:i}=hr(),c=s.icon?br[s.icon]:null,d=s.color?gr[s.color]??null:null,f=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",a=r==="sm"?"size-3.5":"size-4";let u;e[0]!==c||e[1]!==d||e[2]!==a?(u=c?t.jsx(ee,{name:c,className:a,style:d?{color:d}:void 0}):t.jsx(Cs,{className:a,style:d?{color:d}:void 0}),e[0]=c,e[1]=d,e[2]=a,e[3]=u):u=e[3];const p=u;let g;e[4]!==f?(g=J("flex shrink-0 items-center justify-center overflow-hidden bg-[var(--surface-muted)] text-muted-foreground",f),e[4]=f,e[5]=g):g=e[5];let h;e[6]!==s.iconBackground?(h=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[6]=s.iconBackground,e[7]=h):h=e[7];let b;e[8]!==i||e[9]!==p||e[10]!==s.iconImage||e[11]!==s.id?(b=s.iconImage?t.jsx(xr,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:p}):p,e[8]=i,e[9]=p,e[10]=s.iconImage,e[11]=s.id,e[12]=b):b=e[12];let j;return e[13]!==g||e[14]!==h||e[15]!==b?(j=t.jsx("span",{className:g,style:h,children:b}),e[13]=g,e[14]=h,e[15]=b,e[16]=j):j=e[16],j},Gn=n=>{const e=ue.c(2),{ariaLabel:s}=n;let o;return e[0]!==s?(o=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=o):o=e[1],o},Kn=n=>{const e=ue.c(12),{onClick:s,className:o}=n,{t:r}=fe();let i;e[0]!==r?(i=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=i):i=e[1];const c=i;let d;e[2]!==o?(d=J("flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",o),e[2]=o,e[3]=d):d=e[3];let f;e[4]!==s?(f=g=>{g.stopPropagation(),s()},e[4]=s,e[5]=f):f=e[5];let a,u;e[6]===Symbol.for("react.memo_cache_sentinel")?(a={touchAction:"manipulation"},u=t.jsx(ee,{name:"node-tree",className:"size-4"}),e[6]=a,e[7]=u):(a=e[6],u=e[7]);let p;return e[8]!==c||e[9]!==d||e[10]!==f?(p=t.jsx("button",{type:"button",className:d,"aria-label":c,title:c,onClick:f,style:a,children:u}),e[8]=c,e[9]=d,e[10]=f,e[11]=p):p=e[11],p},ht=144,Jr=180,Hn=n=>{const e=ue.c(25),{actionsWidth:s,actions:o,revealed:r,onRevealedChange:i,children:c}=n,d=l.useRef(null),f=l.useRef(null),a=l.useRef(!1),u=l.useRef(0),p=l.useRef(r);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=(C,k)=>{const O=d.current;O&&(O.style.transition=k?`transform ${Jr}ms ease-out`:"none",O.style.transform=C===0?"none":`translateX(${C}px)`,u.current=C)},e[0]=g):g=e[0];const h=g;let b,j;e[1]!==s||e[2]!==r?(b=()=>{p.current=r,h(r?-s:0,!0)},j=[s,h,r],e[1]=s,e[2]=r,e[3]=b,e[4]=j):(b=e[3],j=e[4]),l.useEffect(b,j);let y;e[5]===Symbol.for("react.memo_cache_sentinel")?(y=C=>{if(C.touches.length!==1)return;const k=C.touches[0];f.current={x:k.clientX,y:k.clientY},a.current=!1},e[5]=y):y=e[5];const I=y;let N;e[6]!==s?(N=C=>{if(!f.current)return;const k=C.touches[0],O=k.clientX-f.current.x,G=k.clientY-f.current.y;if(!a.current){if(Math.abs(O)<8||Math.abs(O)<=Math.abs(G))return;a.current=!0}const v=p.current?-s:0;h(Math.min(0,Math.max(-s,v+O)),!1)},e[6]=s,e[7]=N):N=e[7];const E=N;let P;e[8]!==s||e[9]!==i?(P=()=>{if(f.current=null,!a.current)return;a.current=!1;const C=u.current<-s/2;h(C?-s:0,!0),C!==p.current&&i(C)},e[8]=s,e[9]=i,e[10]=P):P=e[10];const S=P;let T;e[11]===Symbol.for("react.memo_cache_sentinel")?(T={touchAction:"pan-y"},e[11]=T):T=e[11];let x;e[12]!==s?(x={width:s},e[12]=s,e[13]=x):x=e[13];const R=!r;let w;e[14]!==o||e[15]!==x||e[16]!==R?(w=t.jsx("div",{className:"absolute inset-y-0 right-0 flex items-stretch",style:x,"aria-hidden":R,children:o}),e[14]=o,e[15]=x,e[16]=R,e[17]=w):w=e[17];let _;e[18]!==c?(_=t.jsx("div",{ref:d,className:"relative flex w-full items-center bg-background",children:c}),e[18]=c,e[19]=_):_=e[19];let D;return e[20]!==S||e[21]!==E||e[22]!==w||e[23]!==_?(D=t.jsxs("div",{className:"relative overflow-hidden",onTouchStart:I,onTouchMove:E,onTouchEnd:S,onTouchCancel:S,style:T,children:[w,_]}),e[20]=S,e[21]=E,e[22]=w,e[23]=_,e[24]=D):D=e[24],D},nc=n=>{const e=ue.c(41),{initialTitle:s,indent:o,onSubmit:r,onCancel:i}=n,{t:c}=fe(),[d,f]=l.useState(s),a=dc;let u;e[0]!==s||e[1]!==i||e[2]!==r||e[3]!==d?(u=()=>{const k=d.trim();if(!k||k===s.trim()){i();return}r(k)},e[0]=s,e[1]=i,e[2]=r,e[3]=d,e[4]=u):u=e[4];const p=u;let g;e[5]!==o?(g={paddingLeft:o},e[5]=o,e[6]=g):g=e[6];let h;e[7]!==p?(h=k=>{k.preventDefault(),p()},e[7]=p,e[8]=h):h=e[8];let b;e[9]===Symbol.for("react.memo_cache_sentinel")?(b=k=>f(k.target.value),e[9]=b):b=e[9];let j;e[10]!==i?(j=k=>{k.stopPropagation(),k.key==="Escape"&&i()},e[10]=i,e[11]=j):j=e[11];let y;e[12]!==c?(y=c("sessions.sidebar.session.rename.save"),e[12]=c,e[13]=y):y=e[13];let I;e[14]!==c?(I=c("sessions.sidebar.session.menu.rename"),e[14]=c,e[15]=I):I=e[15];let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N={minHeight:0},e[16]=N):N=e[16];let E;e[17]!==j||e[18]!==y||e[19]!==I||e[20]!==d?(E=t.jsx("input",{ref:a,value:d,onChange:b,onKeyDown:j,"aria-label":y,placeholder:I,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:N,enterKeyHint:"done"}),e[17]=j,e[18]=y,e[19]=I,e[20]=d,e[21]=E):E=e[21];let P;e[22]!==c?(P=c("sessions.sidebar.session.rename.save"),e[22]=c,e[23]=P):P=e[23];let S,T;e[24]===Symbol.for("react.memo_cache_sentinel")?(S={touchAction:"manipulation",minHeight:0,minWidth:0},T=t.jsx(ee,{name:"check",className:"size-4"}),e[24]=S,e[25]=T):(S=e[24],T=e[25]);let x;e[26]!==P?(x=t.jsx("button",{type:"submit","aria-label":P,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",style:S,children:T}),e[26]=P,e[27]=x):x=e[27];let R;e[28]!==c?(R=c("sessions.sidebar.session.rename.cancel"),e[28]=c,e[29]=R):R=e[29];let w,_;e[30]===Symbol.for("react.memo_cache_sentinel")?(w={touchAction:"manipulation",minHeight:0,minWidth:0},_=t.jsx(ee,{name:"close",className:"size-4"}),e[30]=w,e[31]=_):(w=e[30],_=e[31]);let D;e[32]!==i||e[33]!==R?(D=t.jsx("button",{type:"button",onClick:i,"aria-label":R,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",style:w,children:_}),e[32]=i,e[33]=R,e[34]=D):D=e[34];let C;return e[35]!==x||e[36]!==D||e[37]!==g||e[38]!==h||e[39]!==E?(C=t.jsxs("form",{className:"flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",style:g,onSubmit:h,children:[E,x,D]}),e[35]=x,e[36]=D,e[37]=g,e[38]=h,e[39]=E,e[40]=C):C=e[40],C},qn=n=>{const e=ue.c(51),{session:s,active:o,indent:r,contextLabel:i,hasChildren:c,expanded:d,onToggleChildren:f,onSelect:a,revealed:u,onRevealedChange:p,confirmingDelete:g,onArchive:h,onRequestDelete:b,onConfirmDelete:j,renaming:y,onRequestRename:I,onSubmitRename:N,onCancelRename:E}=n,P=c===void 0?!1:c,S=d===void 0?!1:d,T=u===void 0?!1:u,x=g===void 0?!1:g,R=y===void 0?!1:y,{t:w}=fe();let _;e[0]!==s?(_=tc(ec(s)),e[0]=s,e[1]=_):_=e[1];const D=_,C=s.title?.trim()||w("mobile.sessions.untitled"),k=!!(p&&h),O=dr(s.id),G=fr(s.id),v=O?.type??"idle",A=v==="busy"||v==="retry",L=!A&&G>0&&!o,$=mr(s.id,A),B=(A||L)&&$,ne=l.useRef(null),Q=l.useRef(null),te=l.useRef(!1),z=l.useRef(0),W=l.useRef(T);let K;e[2]===Symbol.for("react.memo_cache_sentinel")?(K=(Ne,De)=>{const he=ne.current;he&&(he.style.transition=De?`transform ${Jr}ms ease-out`:"none",he.style.transform=Ne===0?"none":`translateX(${Ne}px)`,z.current=Ne)},e[2]=K):K=e[2];const H=K;let X,se;e[3]!==T?(X=()=>{W.current=T,H(T?-ht:0,!0)},se=[H,T],e[3]=T,e[4]=X,e[5]=se):(X=e[4],se=e[5]),l.useEffect(X,se);let ie;e[6]!==k?(ie=Ne=>{if(!k||Ne.touches.length!==1)return;const De=Ne.touches[0];Q.current={x:De.clientX,y:De.clientY},te.current=!1},e[6]=k,e[7]=ie):ie=e[7];const me=ie;let ce;e[8]!==k?(ce=Ne=>{if(!k||!Q.current)return;const De=Ne.touches[0],he=De.clientX-Q.current.x,Fe=De.clientY-Q.current.y;if(!te.current){if(Math.abs(he)<8||Math.abs(he)<=Math.abs(Fe))return;te.current=!0}const Qe=W.current?-ht:0,He=Math.min(0,Math.max(-ht,Qe+he));H(He,!1)},e[8]=k,e[9]=ce):ce=e[9];const q=ce;let re;e[10]!==p?(re=()=>{if(Q.current=null,!te.current)return;te.current=!1;const Ne=z.current<-ht/2;H(Ne?-ht:0,!0),Ne!==W.current&&p?.(Ne)},e[10]=p,e[11]=re):re=e[11];const U=re,ae=o||void 0,Ee="relative overflow-hidden";let ye;e[12]!==k?(ye=k?{touchAction:"pan-y"}:void 0,e[12]=k,e[13]=ye):ye=e[13];const Te=k?t.jsxs("div",{className:"absolute inset-y-0 right-0 flex items-stretch",style:{width:ht},"aria-hidden":!T,children:[t.jsx("button",{type:"button",tabIndex:T?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary","aria-label":w("mobile.sessions.renameSessionAria",{title:C}),onClick:I,style:{touchAction:"manipulation"},children:t.jsx(Es,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:T?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary","aria-label":w("mobile.sessions.archiveSessionAria",{title:C}),onClick:h,style:{touchAction:"manipulation"},children:t.jsx(wa,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:T?0:-1,className:J("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",x?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":x?w("mobile.sessions.confirmDeleteSessionAria",{title:C}):w("mobile.sessions.deleteSessionAria",{title:C}),onClick:x?j:b,style:{touchAction:"manipulation"},children:t.jsx(is,{className:"size-[18px]"})})]}):null,$e=k&&"bg-background",xe=o&&(k?"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]":"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]");let _e;e[14]!==$e||e[15]!==xe?(_e=J("relative flex items-center gap-1 transition-colors",$e,xe),e[14]=$e,e[15]=xe,e[16]=_e):_e=e[16];let Se;e[17]!==S||e[18]!==P||e[19]!==r||e[20]!==A||e[21]!==f||e[22]!==L||e[23]!==w?(Se=A||L||P&&f?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",style:{left:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":w(S?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!P||!f,onClick:Ne=>{Ne.stopPropagation(),f?.()},children:A||L?t.jsx("span",{className:J("size-1.5 rounded-full",A?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):t.jsx(Us,{className:J("size-[18px] transition-transform duration-150",S?"rotate-0":"-rotate-90")})}):null,e[17]=S,e[18]=P,e[19]=r,e[20]=A,e[21]=f,e[22]=L,e[23]=w,e[24]=Se):Se=e[24];let Me;e[25]!==o||e[26]!==i||e[27]!==r||e[28]!==A||e[29]!==E||e[30]!==p||e[31]!==a||e[32]!==N||e[33]!==R||e[34]!==s.id||e[35]!==B||e[36]!==D||e[37]!==C?(Me=R&&N&&E?t.jsx(nc,{initialTitle:C,indent:r,onSubmit:N,onCancel:E}):t.jsx("button",{type:"button",className:J("flex min-w-0 flex-1 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",i?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(W.current){p?.(!1);return}a()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{className:J("block min-w-0 flex-1 truncate typography-ui-label",o?"text-primary":"text-foreground"),children:C}),B?t.jsx(kr,{sessionId:s.id,running:A,className:"typography-micro"}):D?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:D}):null]}),i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null]})}),e[25]=o,e[26]=i,e[27]=r,e[28]=A,e[29]=E,e[30]=p,e[31]=a,e[32]=N,e[33]=R,e[34]=s.id,e[35]=B,e[36]=D,e[37]=C,e[38]=Me):Me=e[38];let Ge;e[39]!==_e||e[40]!==Se||e[41]!==Me?(Ge=t.jsxs("div",{ref:ne,className:_e,children:[Se,Me]}),e[39]=_e,e[40]=Se,e[41]=Me,e[42]=Ge):Ge=e[42];let Ke;return e[43]!==U||e[44]!==q||e[45]!==me||e[46]!==ae||e[47]!==ye||e[48]!==Te||e[49]!==Ge?(Ke=t.jsxs("div",{"data-active-session":ae,className:Ee,onTouchStart:me,onTouchMove:q,onTouchEnd:U,onTouchCancel:U,style:ye,children:[Te,Ge]}),e[43]=U,e[44]=q,e[45]=me,e[46]=ae,e[47]=ye,e[48]=Te,e[49]=Ge,e[50]=Ke):Ke=e[50],Ke},rc=n=>{const e=ue.c(11),{indent:s,onClick:o}=n,{t:r}=fe();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Us,{className:"size-4"}),e[2]=c):c=e[2];let d;e[3]!==r?(d=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=d):d=e[4];let f;e[5]!==d?(f=t.jsx("span",{className:"typography-micro",children:d}),e[5]=d,e[6]=f):f=e[6];let a;return e[7]!==o||e[8]!==i||e[9]!==f?(a=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[c,f]}),e[7]=o,e[8]=i,e[9]=f,e[10]=a):a=e[10],a},oc=n=>{const e=ue.c(11),{indent:s,onClick:o}=n,{t:r}=fe();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(ja,{className:"size-4"}),e[2]=c):c=e[2];let d;e[3]!==r?(d=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=d):d=e[4];let f;e[5]!==d?(f=t.jsx("span",{className:"typography-micro",children:d}),e[5]=d,e[6]=f):f=e[6];let a;return e[7]!==o||e[8]!==i||e[9]!==f?(a=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[c,f]}),e[7]=o,e[8]=i,e[9]=f,e[10]=a):a=e[10],a},ic=n=>{const e=ue.c(29),{worktree:s}=n,{t:o}=fe();let r;e[0]!==s.path?(r=Ce(s.path),e[0]=s.path,e[1]=r):r=e[1];const i=r;let c;e[2]!==i?(c={id:i},e[2]=i,e[3]=c):c=e[3];const{attributes:d,listeners:f,setNodeRef:a,transform:u,transition:p,isDragging:g}=Qs(c),h=s.branch||s.label||s.path;let b;e[4]!==u?(b=Zs.Transform.toString(u),e[4]=u,e[5]=b):b=e[5];const j=g?10:1;let y;e[6]!==b||e[7]!==j||e[8]!==p?(y={transform:b,transition:p,zIndex:j},e[6]=b,e[7]=j,e[8]=p,e[9]=y):y=e[9];const I=g&&"shadow-lg shadow-black/20";let N;e[10]!==I?(N=J("flex items-center gap-1 rounded-xl bg-background px-1 py-1",I),e[10]=I,e[11]=N):N=e[11];let E;e[12]!==h||e[13]!==o?(E=o("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=o,e[14]=E):E=e[14];let P;e[15]===Symbol.for("react.memo_cache_sentinel")?(P=t.jsx(Ws,{className:"size-4"}),e[15]=P):P=e[15];let S;e[16]!==d||e[17]!==f||e[18]!==E?(S=t.jsx("button",{type:"button",className:"flex size-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-lg text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":E,...d,...f,children:P}),e[16]=d,e[17]=f,e[18]=E,e[19]=S):S=e[19];let T;e[20]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(ee,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=T):T=e[20];let x;e[21]!==h?(x=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-bold text-muted-foreground",children:h}),e[21]=h,e[22]=x):x=e[22];let R;return e[23]!==a||e[24]!==S||e[25]!==x||e[26]!==y||e[27]!==N?(R=t.jsxs("div",{ref:a,style:y,className:N,children:[S,T,x]}),e[23]=a,e[24]=S,e[25]=x,e[26]=y,e[27]=N,e[28]=R):R=e[28],R},ac=n=>{const e=ue.c(61),{project:s,totalSessions:o,expanded:r,onToggleExpanded:i,onReorderWorktrees:c}=n,{t:d}=fe();let f;e[0]!==s.id?(f={id:s.id},e[0]=s.id,e[1]=f):f=e[1];const{attributes:a,listeners:u,setNodeRef:p,transform:g,transition:h,isDragging:b}=Qs(f);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={activationConstraint:{distance:8}},e[2]=j):j=e[2];let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:Ys},e[3]=y):y=e[3];const I=Vs(St(Ks,j),St(Gs,y)),N=s.worktrees.length>0;let E;e[4]!==c||e[5]!==s.worktrees?(E=z=>{const{active:W,over:K}=z;if(!K||W.id===K.id)return;const H=s.worktrees.map(fc),X=H.indexOf(String(W.id)),se=H.indexOf(String(K.id));if(X<0||se<0)return;const ie=[...H],[me]=ie.splice(X,1);ie.splice(se,0,me),c(ie)},e[4]=c,e[5]=s.worktrees,e[6]=E):E=e[6];const P=E;let S;e[7]!==g?(S=Zs.Transform.toString(g),e[7]=g,e[8]=S):S=e[8];const T=b?10:1;let x;e[9]!==S||e[10]!==T||e[11]!==h?(x={transform:S,transition:h,zIndex:T},e[9]=S,e[10]=T,e[11]=h,e[12]=x):x=e[12];const R=b&&"shadow-lg shadow-black/20";let w;e[13]!==R?(w=J("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",R),e[13]=R,e[14]=w):w=e[14];let _;e[15]!==s.label||e[16]!==d?(_=d("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=d,e[17]=_):_=e[17];let D;e[18]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(Ws,{className:"size-4"}),e[18]=D):D=e[18];let C;e[19]!==a||e[20]!==u||e[21]!==_?(C=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":_,...a,...u,children:D}),e[19]=a,e[20]=u,e[21]=_,e[22]=C):C=e[22];let k;e[23]!==r||e[24]!==s.label||e[25]!==d?(k=r?d("sessions.sidebar.group.collapseAria",{label:s.label}):d("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=d,e[26]=k):k=e[26];const O=!N;let G;e[27]===Symbol.for("react.memo_cache_sentinel")?(G={touchAction:"manipulation"},e[27]=G):G=e[27];let v;e[28]!==s?(v=t.jsx(Is,{project:s}),e[28]=s,e[29]=v):v=e[29];let A;e[30]!==s.label?(A=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s.label}),e[30]=s.label,e[31]=A):A=e[31];let L;e[32]!==o?(L=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:o}),e[32]=o,e[33]=L):L=e[33];let $;e[34]!==r||e[35]!==N?($=N?t.jsx(Us,{className:J("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=N,e[36]=$):$=e[36];let B;e[37]!==r||e[38]!==i||e[39]!==k||e[40]!==O||e[41]!==v||e[42]!==A||e[43]!==L||e[44]!==$?(B=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",onClick:i,"aria-expanded":r,"aria-label":k,disabled:O,style:G,children:[v,A,L,$]}),e[37]=r,e[38]=i,e[39]=k,e[40]=O,e[41]=v,e[42]=A,e[43]=L,e[44]=$,e[45]=B):B=e[45];let ne;e[46]!==C||e[47]!==B?(ne=t.jsxs("div",{className:"flex items-center gap-1",children:[C,B]}),e[46]=C,e[47]=B,e[48]=ne):ne=e[48];let Q;e[49]!==r||e[50]!==P||e[51]!==N||e[52]!==s.worktrees||e[53]!==I?(Q=r&&N?t.jsx(Hs,{sensors:I,collisionDetection:qs,onDragEnd:P,children:t.jsx(Js,{items:s.worktrees.map(mc),strategy:Xs,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map(pc)})})}):null,e[49]=r,e[50]=P,e[51]=N,e[52]=s.worktrees,e[53]=I,e[54]=Q):Q=e[54];let te;return e[55]!==p||e[56]!==ne||e[57]!==Q||e[58]!==x||e[59]!==w?(te=t.jsxs("div",{ref:p,style:x,className:w,children:[ne,Q]}),e[55]=p,e[56]=ne,e[57]=Q,e[58]=x,e[59]=w,e[60]=te):te=e[60],te},Yn=({open:n,onOpenChange:e,variant:s="drawer",footer:o})=>{const{t:r}=fe(),{git:i}=Ls(),c=pr(),d=Ds(m=>m.activeSessions),f=cr(l.useCallback(m=>n||s==="sidebar"?m.ids:Ql,[n,s])),a=ur(l.useCallback(m=>n||s==="sidebar"?m.rankById:Ko,[n,s])),u=Be(m=>m.projects),p=Be(m=>m.activeProjectId),g=it(m=>m.currentDirectory),h=ke(m=>m.currentSessionId),b=ke(m=>m.setCurrentSession),j=ke(m=>m.archiveSession),y=ke(m=>m.deleteSession),I=ke(m=>m.updateSessionTitle),N=ke(m=>m.openNewSessionDraft),E=Be(m=>m.setActiveProject),P=Be(m=>m.setActiveProjectIdOnly),S=Be(m=>m.reorderProjects),T=Be(m=>m.removeProject),x=es(m=>m.projectExpanded),R=es(m=>m.worktreeExpanded),w=es(m=>m.setProjectExpanded),_=es(m=>m.setWorktreeExpanded),D=Ts(m=>m.orderByProject),C=Ts(m=>m.setWorktreeOrder),k=Wn(m=>m.expandedParents),O=Wn(m=>m.toggleParent),[G,v]=l.useState(""),[A,L]=l.useState(null),[$,B]=l.useState(null),[ne,Q]=l.useState(null),[te,z]=l.useState(null),[W,K]=l.useState(null),[H,X]=l.useState(null),[se,ie]=l.useState(null),[me,ce]=l.useState(0),[q,re]=l.useState(!1),[U,ae]=l.useState(!1),[Ee,ye]=l.useState(null),[Te,$e]=l.useState(()=>new Map(ke.getState().availableWorktreesByProject)),[xe,_e]=l.useState(()=>{const m=new Set;for(const[V,Y]of ke.getState().availableWorktreesByProject)Y.length>0&&m.add(V);return m}),[Se,Me]=l.useState(!1),[Ge,Ke]=l.useState(new Set),[Ne,De]=l.useState(new Map);l.useEffect(()=>{if(!n){v(""),Me(!1),Ke(new Set),De(new Map),L(null),B(null),Q(null),z(null),K(null),X(null);return}Os(c)},[n]),l.useEffect(()=>{Se||Ke(new Set)},[Se]),l.useEffect(()=>{if(!n||u.length===0)return;let m=!1;return(async()=>{const Y=await Promise.all(u.map(async pe=>{const de=Ce(pe.path);if(!de)return null;const Ie=await i.checkIsGitRepository(de).catch(()=>!1),Ue=Ie?await vr({id:pe.id,path:de}).catch(()=>[]):[];return[de,Ue,Ie]}));if(m)return;const oe=new Map,ge=new Set;for(const pe of Y)pe&&(oe.set(pe[0],pe[1]),pe[2]&&ge.add(pe[0]));$e(wr(u,oe)),_e(ge)})(),()=>{m=!0}},[i,n,u,me]);const he=l.useMemo(()=>u.map(m=>({id:m.id,label:m.label?.trim()||vs(m.path),path:Ce(m.path),icon:m.icon,color:m.color,iconImage:m.iconImage,iconBackground:m.iconBackground,isGitRepo:xe.has(Ce(m.path)),worktrees:Kl(D[m.id],Te.get(Ce(m.path))??[])})),[xe,u,D,Te]),Fe=l.useMemo(()=>{const m=new Map(c.map(oe=>[oe.id,oe])),V=d.map(oe=>{const ge=m.get(oe.id);return ge?Ho(ge,oe):oe}),Y=new Set(V.map(oe=>oe.id));for(const oe of c)Y.has(oe.id)||V.push(oe);return V.filter(oe=>!oe.time?.archived)},[d,c]),{projectSessions:Qe,chatSessions:He}=l.useMemo(()=>Ji(Fe,!1),[Fe]),Ht=l.useMemo(()=>({key:Dt,label:"",path:"",worktree:null,sessions:bs(He,f,a)}),[He,f,a]),ps=`${Dt}::${Dt}`,qt=l.useMemo(()=>He.filter(m=>!pt(m)).length,[He]),Ae=G.trim().toLowerCase(),dt=l.useRef(null);l.useEffect(()=>{if(!n)return;const m=window.requestAnimationFrame(()=>{const V=dt.current;if(!V)return;(V.querySelector('[data-active-session="true"]')??V.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(m)},[n]);const M=l.useMemo(()=>{const m=he.map(Y=>({project:Y,buckets:[],totalSessions:0,isActive:Y.id===p})),V=(Y,oe,ge)=>{const pe=Ce(oe)||Y.project.path,de=pe||"__root__";let Ie=Y.buckets.find(Ue=>Ue.key===de);return Ie||(Ie={key:de,label:ge?.branch||vs(pe),path:pe,worktree:ge,sessions:[]},Y.buckets.push(Ie)),Ie};for(const Y of m){V(Y,Y.project.path,null);for(const oe of Y.project.worktrees)V(Y,oe.path,oe)}for(const Y of Qe){const oe=gt(Y);if(!oe)continue;const ge=Ce(oe),pe=m.find(Ue=>As(Ue.project,ge));if(!pe)continue;const de=os(pe.project,ge);(de?V(pe,de.path,de):V(pe,pe.project.path,null)).sessions.push(Y)}for(const Y of m)for(const oe of Y.buckets){oe.sessions=bs(oe.sessions,f,a);for(const ge of oe.sessions)pt(ge)||(Y.totalSessions+=1)}return m},[p,f,Qe,he,a]),F=Ce(g),Z=m=>m.isActive?F===m.project.path?m.project.path:m.project.worktrees.find(Y=>sc(F,Y.path))?.path??m.project.path:null,ve=m=>x[m.project.id]??!0,We=(m,V)=>R[`${m.project.id}::${V.key}`]??!0,Ze=m=>{De(V=>{if(!V.has(m))return V;const Y=new Map(V);return Y.delete(m),Y})},tt=m=>{De(V=>{let Y=!1;const oe=new Map(V),ge=`${m}::`;for(const pe of oe.keys())pe.startsWith(ge)&&(oe.delete(pe),Y=!0);return Y?oe:V})},Yt=(m,V)=>{De(Y=>{const oe=new Map(Y);return oe.set(m,V+js),oe})},Tt=(m,V,Y)=>{const oe=new Set(V.sessions.map(je=>je.id)),ge=new Map;for(const je of V.sessions){const qe=pt(je);if(qe&&oe.has(qe)){const It=ge.get(qe)??[];It.push(je),ge.set(qe,It)}}const pe=V.sessions.filter(je=>{const qe=pt(je);return!qe||!oe.has(qe)}),de=Ne.get(m)??js,Ie=pe.slice(0,de),Ue=pe.length-Ie.length,hs=pe.length>js&&Ue===0,bn=(je,qe)=>{const It=ge.get(je.id)??[],gs=It.length>0,xn=!!k[je.id];return t.jsxs(l.Fragment,{children:[t.jsx(qn,{session:je,active:h===je.id,indent:qe,hasChildren:gs,expanded:xn,onToggleChildren:gs?()=>O(je.id):void 0,onSelect:()=>dn(je),revealed:$===je.id,onRevealedChange:_t=>to(je.id,_t),confirmingDelete:ne===je.id,onArchive:()=>{so(je)},onRequestDelete:()=>Q(je.id),onConfirmDelete:()=>{no(je)},renaming:te===je.id,onRequestRename:()=>ro(je.id),onSubmitRename:_t=>{oo(je.id,_t)},onCancelRename:()=>z(null)}),gs&&xn?It.map(_t=>bn(_t,qe+Zl)):null]},je.id)};return t.jsxs("div",{children:[Ie.map(je=>bn(je,Y)),Ue>0?t.jsx(rc,{indent:Y,onClick:()=>Yt(m,Ie.length)}):null,hs?t.jsx(oc,{indent:Y,onClick:()=>Ze(m)}):null]})},un=(m,V)=>{w(m,!V),tt(m)},eo=(m,V,Y)=>{_(`${m}::${V}`,!Y),Ze(`${m}::${V}`)},dn=m=>{const V=gt(m)||null,Y=ks(he,V??"");if(Y){P(Y.id),w(Y.id,!0);const oe=os(Y,Ce(V??""));oe&&_(`${Y.id}::${Ce(oe.path)}`,!0)}b(m.id,V),e(!1)},to=(m,V)=>{B(V?m:null),Q(null),K(null),X(null)},At=(m,V)=>{K(V?m:null),X(null),B(null),Q(null)},so=async m=>{B(null),Q(null),await j(m.id)?le.success(r("sessions.sidebar.session.archive.success")):le.error(r("sessions.sidebar.session.archive.error"))},no=async m=>{B(null),Q(null),await y(m.id)?le.success(r("sessions.sidebar.session.delete.success")):le.error(r("sessions.sidebar.session.delete.error"))},ro=m=>{B(null),Q(null),z(m)},oo=async(m,V)=>{z(null);try{await I(m,V)}catch{le.error(r("mobile.sessions.renameError"))}},io=()=>{N(),e(!1)},fn=m=>{ye(m),P(m),ae(!0)},ao=Vs(St(Ks,{activationConstraint:{distance:8}}),St(Gs,{coordinateGetter:Ys})),lo=m=>{const{active:V,over:Y}=m;if(!Y||V.id===Y.id)return;const oe=he.findIndex(pe=>pe.id===V.id),ge=he.findIndex(pe=>pe.id===Y.id);oe<0||ge<0||S(oe,ge)},co=m=>{Ke(V=>{const Y=new Set(V);return Y.has(m)?Y.delete(m):Y.add(m),Y})},uo=l.useCallback(m=>{const V=gt(m);if(qo(V))return r("mobile.sessions.section.chats");const Y=ks(he,V);if(!Y)return vs(V)||V;const oe=os(Y,Ce(V));return oe?.branch?`${Y.label} · ${oe.branch}`:Y.label},[he,r]),fo=m=>{E(m.id),e(!1)},mo=l.useMemo(()=>Ae?M.filter(m=>yr([m.project.label,m.project.path],Ae)?!0:m.buckets.some(V=>V.sessions.some(Y=>Ss(Y,m.project.label,Ae)))):M,[Ae,M]),Jt=l.useMemo(()=>Ae?bs(Fe.filter(m=>{if(pt(m))return!1;const V=gt(m),Y=ks(he,V);return Ss(m,Y?.label??"",Ae)}),f,a):[],[Ae,f,he,a,Fe]),Xt=l.useMemo(()=>Ae?Yo(he,Ae,m=>[m.label,m.path]).map(m=>({...m,sessionCount:Fe.filter(V=>{if(pt(V))return!1;const Y=Ce(gt(V));return As(m,Y)}).length})):[],[Ae,he,Fe]),po=Ae&&Jt.length===0&&Xt.length===0,mn=!Ae&&he.length>1?t.jsx(we,{type:"button",variant:"chip",size:"sm","aria-label":r(Se?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":Se,onClick:()=>Me(m=>!m),style:{touchAction:"manipulation"},children:Se?t.jsx(Sr,{className:"size-4"}):t.jsx(Es,{className:"size-4"})}):null,pn=!Se&&he.length>0?t.jsxs(we,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:io,style:{touchAction:"manipulation"},children:[t.jsx(va,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,hn=Se?null:t.jsx(we,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>re(!0),style:{touchAction:"manipulation"},children:t.jsx(Cn,{className:"size-4"})}),Qt=pn||hn||mn?t.jsxs(t.Fragment,{children:[pn,hn,mn]}):null,gn=t.jsxs("div",{ref:dt,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs($s,{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:J("px-4 pb-2 pt-1",Se&&"hidden"),children:t.jsxs("div",{className:"relative",children:[t.jsx(Nr,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Bs,{value:G,onChange:m=>v(m.target.value),placeholder:r("mobile.sessions.search.placeholder"),className:J("h-11 pl-9",G&&"pr-10")}),G?t.jsx("button",{type:"button",className:"absolute right-1.5 top-1/2 flex size-8 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.sessions.clearSearchAria"),onClick:()=>v(""),style:{touchAction:"manipulation"},children:t.jsx(Cr,{className:"size-4"})}):null]})}),he.length===0&&He.length===0?t.jsx(Qn,{title:r("mobile.sessions.empty.noProjectsTitle"),description:r("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>re(!0),children:[t.jsx(Cn,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):po?t.jsx(Qn,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):Ae&&!Se?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[Jt.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Jt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Jt.map((m,V)=>t.jsx("div",{className:J(V>0&&"border-t border-border/70"),children:t.jsx(qn,{session:m,active:h===m.id,indent:12,contextLabel:uo(m),onSelect:()=>dn(m)})},m.id))})]}):null,Xt.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:Xt.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:Xt.map((m,V)=>t.jsxs("div",{className:J("flex items-center",V>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>fo(m),style:{touchAction:"manipulation"},children:[t.jsx(Is,{project:m}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:m.label}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:m.sessionCount})]}),m.isGitRepo?t.jsx(Kn,{className:"mr-2",onClick:()=>fn(m.id)}):null]},m.id))})]}):null]}):Se?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:r("mobile.sessions.editOrderHint")}),t.jsx(Hs,{sensors:ao,collisionDetection:qs,onDragEnd:lo,children:t.jsx(Js,{items:he.map(m=>m.id),strategy:Xs,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:he.map(m=>{const V=M.find(Y=>Y.project.id===m.id);return t.jsx(ac,{project:m,totalSessions:V?.totalSessions??0,expanded:Ge.has(m.id),onToggleExpanded:()=>co(m.id),onReorderWorktrees:Y=>C(m.id,Y)},m.id)})})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const m=x[Dt]??!0,V=r("mobile.sessions.section.chats");return t.jsxs("section",{children:[t.jsx("div",{className:"flex min-h-12 w-full items-center",children:t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(W){At(W,!1);return}un(Dt,m)},"aria-expanded":m,"aria-label":m?r("sessions.sidebar.group.collapseAria",{label:V}):r("sessions.sidebar.group.expandAria",{label:V}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(ee,{name:"chat-4",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:V}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:qt})]})}),m?t.jsx("div",{className:"pb-2",children:Ht.sessions.length>0?Tt(ps,Ht,ss):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingLeft:ss},children:r("sessions.sidebar.activity.chatsEmpty")})}):null]})})(),mo.map(m=>{const V=ve(m),Y=Ae?m.buckets.filter(ge=>ge.sessions.some(pe=>Ss(pe,m.project.label,Ae))):m.buckets,oe=Z(m);return t.jsxs("section",{className:"border-t border-border/70",children:[t.jsx(Hn,{actionsWidth:96,revealed:W===`project:${m.project.id}`,onRevealedChange:ge=>At(`project:${m.project.id}`,ge),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:W===`project:${m.project.id}`?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary","aria-label":r("mobile.sessions.editProjectAria",{label:m.project.label}),onClick:()=>{K(null),L(m.project.id)},style:{touchAction:"manipulation"},children:t.jsx(Es,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:W===`project:${m.project.id}`?0:-1,className:J("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",H===m.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":H===m.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:m.project.label}):r("mobile.sessions.removeProjectAria",{label:m.project.label}),onClick:()=>{if(H===m.project.id){K(null),X(null),T(m.project.id),le.success(r("mobile.sessions.toast.projectRemoved",{label:m.project.label}));return}X(m.project.id)},style:{touchAction:"manipulation"},children:t.jsx(is,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":m.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(W){At(W,!1);return}un(m.project.id,V)},"aria-expanded":V,"aria-label":V?r("sessions.sidebar.group.collapseAria",{label:m.project.label}):r("sessions.sidebar.group.expandAria",{label:m.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(Is,{project:m.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:m.project.label}),m.isActive?t.jsx(Gn,{ariaLabel:r("mobile.sessions.activeProjectAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:m.totalSessions})]}),m.project.isGitRepo?t.jsx(Kn,{className:"mr-2",onClick:()=>fn(m.project.id)}):null]})}),V?t.jsx("div",{className:"pb-2",children:(()=>{const ge=Y.find(de=>de.worktree===null),pe=Y.filter(de=>de.worktree!==null);return t.jsxs(t.Fragment,{children:[ge&&ge.sessions.length>0?Tt(`${m.project.id}::${ge.key}`,ge,ss):null,pe.map(de=>{const Ie=We(m,de),Ue=oe===de.path;return t.jsxs("div",{children:[t.jsx(Hn,{actionsWidth:48,revealed:W===`wt:${de.key}`,onRevealedChange:hs=>At(`wt:${de.key}`,hs),actions:t.jsx("button",{type:"button",tabIndex:W===`wt:${de.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:de.label}),onClick:()=>{K(null),de.worktree&&ie({project:m.project,worktree:de.worktree})},style:{touchAction:"manipulation"},children:t.jsx(is,{className:"size-[18px]"})}),children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(W){At(W,!1);return}eo(m.project.id,de.key,Ie)},"aria-expanded":Ie,"aria-label":Ie?r("sessions.sidebar.group.collapseAria",{label:de.label}):r("sessions.sidebar.group.expandAria",{label:de.label}),style:{touchAction:"manipulation"},children:[t.jsx(ee,{name:"git-branch",className:J("size-4 shrink-0",Ue?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:J("block min-w-0 flex-1 truncate typography-ui-label font-bold",Ue?"text-foreground":"text-muted-foreground"),children:de.label}),Ue?t.jsx(Gn,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:de.sessions.length})]})}),Ie?Tt(`${m.project.id}::${de.key}`,de,ss):null]},de.key)})]})})()}):null]},m.project.id)})]})]}),o?t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/70 px-2 pt-1.5",style:{paddingBottom:"calc(0.375rem + var(--oc-safe-area-bottom, 0px))"},children:[o.instanceLabel&&o.onOpenInstances?t.jsxs(we,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:o.onOpenInstances,"aria-label":r("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(ee,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:o.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.onOpenUpdate?t.jsxs(we,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenUpdate,"aria-label":r("mobile.menu.update"),title:r("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(ee,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(we,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenSettings,"aria-label":r("mobile.menu.settings"),title:r("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(ee,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(Xi,{open:q,onOpenChange:re}),t.jsx(Qi,{open:U,onOpenChange:m=>{ae(m),m||ye(null)},onWorktreeCreated:(m,V)=>{V?.sessionId?b(V.sessionId,m):N({selectedProjectId:Ee,directoryOverride:m,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(Xl,{open:A!==null,project:he.find(m=>m.id===A)??null,onClose:()=>L(null),onWorktreesChanged:()=>ce(m=>m+1)}),se?t.jsx(Yr,{open:!0,project:{id:se.project.id,path:se.project.path},worktree:se.worktree,onClose:()=>ie(null),onDeleted:()=>ce(m=>m+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[t.jsx("h2",{className:"truncate typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),Qt?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Qt}):null]}),gn]}):null:t.jsxs(uc,{open:n,onClose:()=>e(!1),ariaLabel:r("mobile.sessions.sheet.title"),children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(ee,{name:"close",className:"size-5"})}),t.jsx("h2",{className:"min-w-0 flex-1 truncate px-1 typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),Qt?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Qt}):null]}),gn]})},Jn="mobile-surface-root",lc=16,Xn=320,cc="cubic-bezier(0.22, 1, 0.36, 1)",uc=({open:n,onClose:e,ariaLabel:s,children:o})=>{const r=l.useRef(null),[i,c]=l.useState(!1),[d,f]=l.useState(n),a=l.useRef(e);if(l.useEffect(()=>{a.current=e},[e]),typeof document<"u"&&!r.current){let u=document.getElementById(Jn);u||(u=document.createElement("div"),u.id=Jn,document.body.appendChild(u)),r.current=u}return l.useEffect(()=>{if(n){f(!0);const p=window.setTimeout(()=>c(!0),lc);return()=>window.clearTimeout(p)}c(!1);const u=window.setTimeout(()=>f(!1),Xn+40);return()=>window.clearTimeout(u)},[n]),l.useEffect(()=>{if(!n)return;const u=document.body.style.overflow;document.body.style.overflow="hidden";const p=g=>{g.key==="Escape"&&a.current()};return document.addEventListener("keydown",p),()=>{document.body.style.overflow=u,document.removeEventListener("keydown",p)}},[n]),r.current?jt.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":s,"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:i?"none":"translateX(-100%)",transition:`transform ${Xn}ms ${cc}`,visibility:d?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:o})}),r.current):null},Qn=n=>{const e=ue.c(10),{title:s,description:o,action:r}=n;let i;e[0]!==s?(i=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let c;e[2]!==o?(c=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[2]=o,e[3]=c):c=e[3];let d;e[4]!==r?(d=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=d):d=e[5];let f;return e[6]!==i||e[7]!==c||e[8]!==d?(f=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[i,c,d]}),e[6]=i,e[7]=c,e[8]=d,e[9]=f):f=e[9],f};function dc(n){n&&(n.focus(),n.select())}function fc(n){return Ce(n.path)}function mc(n){return Ce(n.path)}function pc(n){return t.jsx(ic,{worktree:n},Ce(n.path))}const hc=(n,e)=>{if(!n)return e("mcpDropdown.status.unknown");switch(n.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:n.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");case"needs_client_registration":return e("mcpDropdown.status.needsRegistration",{error:n.error||""});default:return n.status}},gc=n=>{switch(n?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},bc=({active:n,className:e,headerAction:s,listClassName:o,hideHeader:r=!1,mobileListDensity:i=!1})=>{const{t:c}=fe(),f=it(S=>S.currentDirectory)??null,a=Ot(S=>S.getStatusForDirectory(f)),u=Ot(S=>S.refresh),p=Ot(S=>S.connect),g=Ot(S=>S.disconnect),h=vt(S=>S.mcpServers),b=vt(S=>S.loadMcpConfigs),[j,y]=l.useState(!1),[I,N]=l.useState(null);l.useEffect(()=>{u({directory:f,silent:!0})},[u,f]),l.useEffect(()=>{b({force:!0})},[b]),l.useEffect(()=>{n&&Promise.all([u({directory:f,silent:!0}),b({force:!0})])},[n,u,f,b]);const E=l.useMemo(()=>{const S=new Set(Object.keys(a));for(const T of h)T?.name&&S.add(T.name);return Array.from(S).sort((T,x)=>T.localeCompare(x))},[h,a]),P=l.useCallback(S=>{if(S?.preventDefault(),j)return;y(!0);const T=new Promise(x=>setTimeout(x,500));Promise.all([u({directory:f}),T]).finally(()=>{y(!1)})},[j,u,f]);return t.jsxs("div",{className:J("w-full",e),children:[r?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:c("mcpDropdown.title")}),f&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:f.split("/").pop()||f})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",disabled:j,onClick:P,"aria-label":c("mcpDropdown.actions.refreshAria"),children:t.jsx(ee,{name:"refresh",className:J("h-4 w-4",j&&"animate-spin")})})]})]})}),t.jsx("div",{className:J("max-h-64 overflow-y-auto",i?"space-y-1 py-3":"px-3 py-2.5",o),children:t.jsxs("div",{className:J(!i&&E.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[E.map(S=>{const T=a[S],x=gc(T),R=T?.status==="connected",w=I===S,_=hc(T,c);return t.jsxs("div",{className:J("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",i?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(Jo,{children:[t.jsx(Xo,{asChild:!0,children:t.jsx("span",{className:J("rounded-full flex-shrink-0",i?"h-2.5 w-2.5":"h-2 w-2",x==="success"&&"bg-status-success",x==="error"&&"bg-status-error",x==="warning"&&"bg-status-warning",x==="default"&&"bg-muted-foreground/40"),"aria-label":_})}),t.jsx(Qo,{side:"left",children:t.jsx("p",{children:_})})]}),t.jsx("span",{className:J("truncate",i?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:S})]})}),t.jsx(Zo,{checked:R,disabled:w,className:"data-[checked]:bg-status-info",onCheckedChange:async D=>{N(S);try{if(!D){await g(S,f);return}const C=a?.[S]?.status;if(C==="needs_auth"||C==="needs_client_registration"){const{opened:k}=await ei({name:S,directory:f});k||Rn.error(c("mcpDropdown.toast.authorizeOpenFailed"));return}await p(S,f)}catch(C){Rn.error(C instanceof Error?C.message:c("mcpDropdown.toast.authorizeFailed"))}finally{N(null)}}})]},S)}),E.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:c("mcpDropdown.empty.configureInConfig")})]})})]})},xc=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),yc=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},vc=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},Zn=(n,e)=>e?`${n}\0staged`:n,wc=({onClose:n,initialDiffPath:e,initialDiffStaged:s=!1})=>{const{t:o}=fe(),{git:r}=Ls(),i=xc(Fs()??null),{rootIsGitRepo:c,gitDirectory:d,nestedRepos:f}=ti(i||null),a=d??i,u=si(a||null),p=ni(a||null),g=ri(a||null),h=oi(a||null),b=Ve(M=>M.setActiveDirectory),j=Ve(M=>M.ensureAll),y=Ve(M=>M.ensureNestedRepos),I=Ve(M=>M.selectNestedRepo),N=Ve(M=>M.fetchStatus),E=Ve(M=>M.fetchBranches),P=Ve(M=>M.prefetchDiffs),S=Ve(M=>M.getDiff),T=Ve(M=>M.setDiff),[x,R]=l.useState(()=>e?{type:"diff",path:e,staged:s}:{type:"list"});l.useEffect(()=>{e&&R(M=>M.type==="diff"&&M.path===e&&M.staged===s?M:{type:"diff",path:e,staged:s})},[e,s]);const[w,_]=l.useState(null),[D,C]=l.useState(null),[k,O]=l.useState(""),[G,v]=l.useState(new Set),[A,L]=l.useState(!1),[$,B]=l.useState(!1),[ne,Q]=l.useState([]),[te,z]=l.useState([]),[W,K]=l.useState([]),[H,X]=l.useState(null),[se,ie]=l.useState(null),[me,ce]=l.useState(0),[q,re]=l.useState(null),U=l.useMemo(()=>{const M=u?.files??[],F=new Map;for(const Z of M)F.set(Z.path,Z);return Array.from(F.values()).sort((Z,ve)=>Z.path.localeCompare(ve.path))},[u?.files]),ae=l.useMemo(()=>U.filter(yc),[U]),Ee=l.useMemo(()=>U.filter(vc),[U]),ye=l.useMemo(()=>{if(W.length>0)return W;const M=u?.tracking?.includes("/")?u.tracking.split("/")[0]:null;return M||H?[{name:M||"origin",fetchUrl:H??"",pushUrl:H??""}]:[]},[H,W,u?.tracking]),Te=Ve(l.useCallback(M=>!a||x.type!=="diff"?null:M.directories.get(a)?.diffCache.get(Zn(x.path,x.staged))??null,[a,x])),$e=l.useMemo(()=>x.type!=="diff"?null:U.find(M=>M.path===x.path)??null,[U,x]),xe=l.useCallback(async(M=!0)=>{if(a)try{await Promise.all([N(a,r),E(a,r)])}catch(F){M&&le.error(F instanceof Error?F.message:o("gitView.toast.refreshRepositoryFailed"))}},[a,E,N,r,o]),_e=l.useMemo(()=>(p?.all??[]).filter(M=>!M.startsWith("remotes/")).sort(),[p]),Se=l.useMemo(()=>(p?.all??[]).filter(M=>M.startsWith("remotes/")).map(M=>M.replace(/^remotes\//,"")).sort(),[p]),Me=l.useCallback(async M=>{if(!a)return;const F=M.replace(/^remotes\//,"");try{const Z=await r.checkoutBranch(a,F);le.success(o("gitView.toast.checkedOut",{name:Z.branch||F})),await xe()}catch(Z){le.error(Z instanceof Error?Z.message:o("gitView.toast.checkoutFailed",{name:F}))}},[a,r,xe,o]),Ge=l.useCallback(M=>{const F=M.replace(/^remotes\//,"");if((u?.files?.length??0)>0){re(F);return}Me(F)},[Me,u?.files]),Ke=l.useCallback(async(M,F)=>{if(a)try{await r.createBranch(a,M,u?.current??"HEAD"),await r.checkoutBranch(a,M),F&&await r.gitPush(a,{remote:F.name,branch:M,options:["--set-upstream"]}),await xe()}catch(Z){throw le.error(Z instanceof Error?Z.message:o("gitView.toast.createBranchFailed")),Z}},[a,r,xe,u?.current,o]),Ne=l.useCallback(async()=>{if(!a){K([]),X(null);return}try{const[M,F]=await Promise.all([r.getRemotes(a).catch(()=>[]),r.getRemoteUrl?r.getRemoteUrl(a).catch(()=>null):Promise.resolve(null)]);K(M),X(F)}catch{K([]),X(null)}},[a,r]);l.useEffect(()=>{a&&(b(a),j(a,r))},[a,j,r,b]),l.useEffect(()=>{Ne()},[Ne]),l.useEffect(()=>{if(!a||U.length===0)return;const M=Array.from(new Set([...ae.map(Z=>Z.path),...te,...U.slice(0,20).map(Z=>Z.path)])).filter(Boolean);if(M.length===0)return;const F=window.setTimeout(()=>{P(a,r,M,{maxFiles:40})},120);return()=>window.clearTimeout(F)},[U,a,r,P,ae,te]),l.useEffect(()=>{if(x.type!=="diff"){ie(null);return}const M=Zn(x.path,x.staged);if(!a||S(a,M)){ie(null);return}let F=!1;const Z=Rt();return ie(null),r.getGitFileDiff(a,{path:x.path,staged:x.staged||void 0}).then(ve=>{F||T(a,M,{original:ve.original??"",modified:ve.modified??"",isBinary:ve.isBinary},Z)}).catch(ve=>{F||ie(ve instanceof Error?ve.message:String(ve))}),()=>{F=!0}},[a,me,S,r,x,T]);const De=async(M,F)=>{if(a){_(M);try{const Z=ve=>{const We=`${ve.name}/`,Ze=u?.tracking?.startsWith(We)?u.tracking.slice(We.length):void 0;return{remote:ve.name,branch:Ze,rebase:!0}};if(M==="fetch"){if(!F)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(a,{remote:F.name}),le.success(o("gitView.toast.fetchedFromRemote",{name:F.name}))}else if(M==="sync"){if(!F)throw new Error(o("mobile.changes.noRemote"));await r.gitFetch(a,{remote:F.name});const ve=await r.getGitStatus(a);if((ve.behind??0)>0){if((ve.files?.length??0)>0){le.error(o("gitView.toast.commitOrStashBeforeSync"));return}await r.gitPull(a,Z(F))}((await r.getGitStatus(a)).ahead??0)>0&&await r.gitPush(a),le.success(o("gitView.toast.alreadyUpToDate"))}await xe(!1),await Ne()}catch(Z){le.error(Z instanceof Error?Z.message:o("gitView.toast.syncActionFailed",{action:o("gitView.sync.syncChanges")}))}finally{_(null)}}},he=l.useCallback(async(M,F)=>{if(!(!a||M.length===0))try{F==="stage"?M.length>1?await ii(a,M):await ai(a,M[0]):M.length>1?await li(a,M):await ci(a,M[0]),await xe(!1)}catch(Z){le.error(Z instanceof Error?Z.message:o(F==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[a,xe,o]),Fe=l.useCallback((M,F=!1)=>{R({type:"diff",path:M,staged:F})},[]),Qe=l.useCallback(async M=>{if(a){v(F=>new Set(F).add(M));try{await r.revertGitFile(a,M),le.success(o("gitView.toast.revertedFile",{path:M})),await xe(!1)}catch(F){le.error(F instanceof Error?F.message:o("gitView.toast.revertFailed"))}finally{v(F=>{const Z=new Set(F);return Z.delete(M),Z})}}},[a,r,xe,o]),He=l.useCallback(async M=>{if(!a||M.length===0||A)return;const F=Array.from(new Set(M));L(!0),v(new Set(F));try{await Promise.all(F.map(Z=>r.revertGitFile(a,Z))),await xe(!1),le.success(F.length===1?o("gitView.toast.revertedFilesSingle",{count:F.length}):o("gitView.toast.revertedFilesPlural",{count:F.length}))}catch(Z){le.error(Z instanceof Error?Z.message:o("gitView.toast.revertFailed"))}finally{v(new Set),L(!1)}},[a,r,A,xe,o]),Ht=l.useCallback(M=>{const F=M.map(Z=>Z.trim()).filter(Boolean);if(F.length===0){Q([]);return}O(Z=>`${Z.trim()}${Z.trim()?`
|
|
23
|
+
|
|
24
|
+
`:""}${F.join(`
|
|
25
|
+
`)}`.trim()),Q([])},[]),ps=l.useCallback(async()=>{if(!a)return;const M=ae.map(F=>F.path).sort();if(M.length===0){le.error(o("gitView.toast.selectFileToDescribe"));return}B(!0);try{const{message:F}=await Nn(a,M);O(F.subject?.trim()??""),Q(Array.isArray(F.highlights)?F.highlights:[])}catch(F){le.error(F instanceof Error?F.message:o("gitView.toast.generateCommitMessageFailed"))}finally{B(!1)}},[a,ae,o]),qt=async(M={})=>{if(!a)return;if(!k.trim()){le.error(o("gitView.toast.enterCommitMessage"));return}const F=ae.map(Z=>Z.path).sort();if(F.length===0){le.error(o("gitView.toast.selectFileToCommit"));return}C(M.pushAfter?"commitAndPush":"commit");try{if(await r.createGitCommit(a,k.trim(),{files:F}),le.success(o("gitView.toast.commitCreated")),O(""),Q([]),M.pushAfter){const Z=u?.tracking?.split("/")[0],ve=ye.find(Tt=>Tt.name===Z)??ye[0];if(!ve)throw new Error(o("mobile.changes.noRemote"));_("sync");const We=`${ve.name}/`,Ze=u?.tracking?.startsWith(We)?u.tracking.slice(We.length):void 0;await r.gitFetch(a,{remote:ve.name}),((await r.getGitStatus(a)).behind??0)>0&&await r.gitPull(a,{remote:ve.name,branch:Ze,rebase:!0}),((await r.getGitStatus(a)).ahead??0)>0&&await r.gitPush(a),await xe(!1),await Ne()}else await xe(!1)}catch(Z){le.error(Z instanceof Error?Z.message:o("gitView.toast.createCommitFailed"))}finally{C(null),M.pushAfter&&_(null)}},Ae=l.useMemo(()=>{const M=[];return ae.length>0&&M.push({id:"staged",title:o("gitView.changes.stagedTitle"),entries:ae,actionSymbol:"-",actionAllLabel:o("gitView.changes.unstageAllAria"),getActionLabel:F=>o("gitView.changes.unstageFileAria",{path:F}),onActionFile:F=>{he([F],"unstage")},onActionAll:F=>{he(F,"unstage")},onViewDiff:F=>Fe(F,!0),onRevertFile:Qe,showRevertActions:!1,accent:!0}),Ee.length>0&&M.push({id:"unstaged",title:o("gitView.changes.title"),entries:Ee,actionSymbol:"+",actionAllLabel:o("gitView.changes.stageAllAria"),getActionLabel:F=>o("gitView.changes.stageFileAria",{path:F}),onActionFile:F=>{he([F],"stage")},onActionAll:F=>{he(F,"stage")},onViewDiff:F=>Fe(F,!1),onRevertFile:Qe}),M},[Qe,Fe,he,ae,o,Ee]),dt=M=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(ee,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:u?.current||a||""})]}),c===!1&&Array.isArray(f)&&f.length>0?t.jsx(ta,{repositories:f,selectedRepository:d??null,onSelectRepository:F=>{i&&I(i,F)},repositoryRoot:i??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:M})]});return a?c===!1&&g!==!0?dt(t.jsx(sa,{rootIsGitRepo:c,resolvedIsGitRepo:g,nestedRepos:f,onRetryDiscovery:()=>{i&&y(i,{force:!0})}})):h&&g===null?dt(t.jsx(ot,{loading:!0,message:o("gitView.loading.checkingRepository")})):x.type==="diff"?t.jsx(jc,{path:x.path,diff:Te,fileExists:!!$e,error:se,onBack:()=>R({type:"list"}),onRetry:()=>ce(M=>M+1)}):t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":o("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(ee,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:o("mobile.nav.changes")}),t.jsx(Zi,{currentBranch:u?.current,localBranches:_e,remoteBranches:Se,branchInfo:p?.branches,currentBranchAhead:u?.ahead,onCheckout:M=>{Ge(M)},onCreate:Ke,remotes:ye,disabled:h,directory:a,switchBlockedNotice:(u?.files?.length??0)>0?o("gitView.branch.switchBlockedNotice"):null})]}),t.jsx(ea,{syncAction:w,remotes:ye,onFetch:M=>{De("fetch",M)},onSync:M=>{De("sync",M)},disabled:D!==null||h,aheadCount:u?.ahead??0,behindCount:u?.behind??0,trackingRemoteName:u?.tracking?.split("/")[0],hasUncommittedChanges:U.length>0})]}),U.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(Ra,{groups:Ae,diffStats:u?.diffStats,revertingPaths:G,onRevertAll:He,isRevertingAll:A,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:z})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(Pa,{stagedCount:ae.length,commitMessage:k,onCommitMessageChange:O,generatedHighlights:ne,onInsertHighlights:Ht,onGenerateMessage:ps,isGeneratingMessage:$,onCommit:()=>{qt({pushAfter:!1})},onCommitAndPush:()=>{qt({pushAfter:!0})},commitAction:D,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(ot,{icon:!0,message:o("gitView.empty.cleanTitle"),description:o("mobile.changes.cleanDescription")})}),t.jsx(Ta,{open:q!==null,onOpenChange:M=>{M||re(null)},targetBranch:q??"",changedFileCount:u?.files?.length??0,onCommitAndSwitch:async(M,F)=>{const Z=q;if(!Z||!a)return;const ve=u?.current??null;await r.createGitCommit(a,M,{addAll:!0});let We=null;if(F){const Ze=u?.tracking?.split("/")[0],tt=ye.find(Yt=>Yt.name===Ze)??ye[0];try{if(!tt)throw new Error(o("mobile.changes.noRemote"));await r.gitPush(a,u?.tracking?{remote:tt.name}:{remote:tt.name,branch:ve??void 0,options:["--set-upstream"]}),We=tt.name}catch{le.error(o("gitView.dirtySwitch.pushFailed")),await xe(),re(null);return}}le.success(ve?We?o("gitView.toast.pushedToUpstream",{name:We}):o("gitView.dirtySwitch.committedNotPushed",{branch:ve}):o("gitView.toast.commitCreated")),await xe(),re(null),await Me(Z)},onGenerateMessage:async()=>{if(!a)return"";const M=(u?.files??[]).map(Z=>Z.path).sort(),{message:F}=await Nn(a,M);return F.subject?.trim()??""},onRevertAndSwitch:async()=>{const M=q;if(!M||!a)return;await He((u?.files??[]).map(Z=>Z.path));const F=await r.getGitStatus(a);if(!F.isClean&&(F.files?.length??0)>0){le.error(o("gitView.dirtySwitch.revertIncomplete"));return}re(null),await Me(M)}})]}):dt(t.jsx(ot,{message:o("gitView.empty.selectSessionOrDirectory")}))},ot=n=>{const e=ue.c(13),{message:s,description:o,loading:r,icon:i}=n,c=r===void 0?!1:r,d=i===void 0?!1:i;let f;e[0]!==c?(f=c?t.jsx(ee,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=c,e[1]=f):f=e[1];let a;e[2]!==d?(a=d?t.jsx(ee,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=d,e[3]=a):a=e[3];let u;e[4]!==s?(u=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=u):u=e[5];let p;e[6]!==o?(p=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[6]=o,e[7]=p):p=e[7];let g;return e[8]!==f||e[9]!==a||e[10]!==u||e[11]!==p?(g=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[f,a,u,p]})}),e[8]=f,e[9]=a,e[10]=u,e[11]=p,e[12]=g):g=e[12],g},jc=n=>{const e=ue.c(24),{path:s,diff:o,fileExists:r,error:i,onBack:c,onRetry:d}=n,{t:f}=fe();let a;e[0]!==s?(a=ui(s)||"text",e[0]=s,e[1]=a):a=e[1];const u=a;let p;e[2]!==f?(p=f("header.actions.backAria"),e[2]=f,e[3]=p):p=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(ee,{name:"arrow-left",className:"size-5"}),e[4]=g):g=e[4];let h;e[5]!==c||e[6]!==p?(h=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":p,onClick:c,children:g}),e[5]=c,e[6]=p,e[7]=h):h=e[7];let b;e[8]!==s?(b=t.jsx("div",{className:"min-w-0 flex-1 px-2",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s})}),e[8]=s,e[9]=b):b=e[9];let j;e[10]!==h||e[11]!==b?(j=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/70 px-3 text-foreground",children:[h,b]}),e[10]=h,e[11]=b,e[12]=j):j=e[12];let y;e[13]!==o||e[14]!==i||e[15]!==r||e[16]!==u||e[17]!==d||e[18]!==s||e[19]!==f?(y=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:r?i?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:f("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),t.jsx(we,{type:"button",size:"sm",variant:"outline",onClick:d,children:f("diffView.actions.retry")})]})}):o?o.isBinary?t.jsx(ot,{icon:!0,message:f("diffView.binary.unavailable")}):di(s)?t.jsx(ot,{icon:!0,message:f("mobile.changes.diffDetail.imageUnavailable")}):t.jsx($s,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(Aa,{original:o.original,modified:o.modified,language:u,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(ot,{loading:!0,message:f("diffView.state.loadingDiff")}):t.jsx(ot,{icon:!0,message:f("mobile.changes.diffDetail.missingTitle"),description:f("mobile.changes.diffDetail.missingDescription")})}),e[13]=o,e[14]=i,e[15]=r,e[16]=u,e[17]=d,e[18]=s,e[19]=f,e[20]=y):y=e[20];let I;return e[21]!==j||e[22]!==y?(I=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[j,y]}),e[21]=j,e[22]=y,e[23]=I):I=e[23],I},kc=l.lazy(()=>kt(()=>import("./FilesView-CdWzeOp9.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124])).then(n=>({default:n.FilesView}))),ct=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),Ut=n=>{const e=ct(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},Sc=n=>{const e=ct(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},Nc=(n,e)=>{const s=ct(n),o=ct(e);return!o||s===o?Ut(s):s.startsWith(`${o}/`)?s.slice(o.length+1):s},Cc=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const o of e){if(s<1024||o===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${o}`;s/=1024}return""},Ec=({onClose:n})=>{const{t:e}=fe(),{files:s}=Ls(),o=vo(v=>v.setSelectedPath),r=ct(Fs()??null),[i,c]=l.useState(()=>({type:"browser",directory:r})),[d,f]=l.useState([]),[a,u]=l.useState(!1),[p,g]=l.useState(null),[h,b]=l.useState(""),[j,y]=l.useState([]),[I,N]=l.useState(!1),E=l.useRef(0);l.useEffect(()=>{r&&c(v=>v.type==="browser"&&v.directory?v:{type:"browser",directory:r})},[r]);const P=i.type==="browser"?i.directory:i.returnDirectory,S=l.useCallback(async v=>{if(!v)return;const A=E.current+1;E.current=A,u(!0),g(null);try{const L=await s.listDirectory(v);if(E.current!==A)return;f(L.entries.slice().sort(($,B)=>$.isDirectory!==B.isDirectory?$.isDirectory?-1:1:$.name.localeCompare(B.name)))}catch(L){if(E.current!==A)return;f([]),g(L instanceof Error?L.message:e("mobile.files.error.listFailed"))}finally{E.current===A&&u(!1)}},[s,e]);l.useEffect(()=>{i.type==="browser"&&S(i.directory)},[S,i]),l.useEffect(()=>{if(i.type!=="browser")return;const v=h.trim();if(!v){y([]),N(!1);return}let A=!1;const L=window.setTimeout(()=>{N(!0),s.search({directory:i.directory,query:v,maxResults:40}).then($=>{A||y($)}).catch(()=>{A||y([])}).finally(()=>{A||N(!1)})},250);return()=>{A=!0,window.clearTimeout(L)}},[s,h,i]);const T=v=>{b(""),c({type:"browser",directory:v})},x=v=>{o(r,v),c({type:"file",path:v,returnDirectory:P||r})},R=Je(v=>v.pendingFileFocusPath),w=Je(v=>v.pendingFileNavigation);if(l.useEffect(()=>{const v=ct(w?.path??R??"");!v||!r||v!==r&&!v.startsWith(`${r}/`)||(o(r,v),c({type:"file",path:v,returnDirectory:r}),R&&Je.getState().setPendingFileFocusPath(null))},[R,w,r,o]),!r)return t.jsx(Vt,{message:e("mobile.files.empty.noDirectory")});if(i.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("header.actions.backAria"),onClick:()=>c({type:"browser",directory:i.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(En,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:Ut(i.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(Le,{children:t.jsx(l.Suspense,{fallback:t.jsx(Vt,{loading:!0,message:e("filesView.state.loading")}),children:t.jsx(kc,{mode:"editor-only"})})})})]});const _=i.directory===r?e("mobile.files.rootDirectory"):Ut(i.directory),D=h.trim()?j:[],C=Sc(i.directory),k=i.directory!==r&&C!==null&&(C===r||C.startsWith(`${r}/`)),O=k&&!h.trim(),G=k?C:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(Cr,{className:"size-5"})}):null,O&&G?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.files.backToParentAria",{name:Ut(G)}),onClick:()=>T(G),style:{touchAction:"manipulation"},children:t.jsx(En,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:_})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.files.refreshAria"),onClick:()=>{S(i.directory)},style:{touchAction:"manipulation"},children:t.jsx(ka,{className:J("size-5",a&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(Nr,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Bs,{value:h,onChange:v=>b(v.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx($s,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:p?t.jsx(Vt,{message:p}):h.trim()?t.jsx(Rc,{results:D,isSearching:I,onOpenFile:x}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[d.length===0&&!a?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,d.map(v=>t.jsx(Xr,{name:v.name,path:v.path,directory:v.isDirectory,meta:v.isDirectory?void 0:Cc(v.size),onClick:()=>v.isDirectory?T(v.path):x(v.path)},v.path))]})})]})},Xr=n=>{const e=ue.c(16),{name:s,path:o,directory:r,meta:i,onClick:c}=n;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},e[0]=d):d=e[0];let f;e[1]!==r||e[2]!==o?(f=r?t.jsx(Sa,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(fi,{filePath:o,className:"size-5 shrink-0"}),e[1]=r,e[2]=o,e[3]=f):f=e[3];let a;e[4]!==s?(a=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=a):a=e[5];let u;e[6]!==i?(u=i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,e[6]=i,e[7]=u):u=e[7];let p;e[8]!==r?(p=r?t.jsx(Na,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=p):p=e[9];let g;return e[10]!==c||e[11]!==f||e[12]!==a||e[13]!==u||e[14]!==p?(g=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:c,style:d,children:[f,a,u,p]}),e[10]=c,e[11]=f,e[12]=a,e[13]=u,e[14]=p,e[15]=g):g=e[15],g},Rc=n=>{const e=ue.c(10),{results:s,isSearching:o,onOpenFile:r}=n,{t:i}=fe(),c=ct(Fs()??null);if(o){let u;e[0]!==i?(u=i("common.loading"),e[0]=i,e[1]=u):u=e[1];let p;return e[2]!==u?(p=t.jsx(Vt,{loading:!0,message:u}),e[2]=u,e[3]=p):p=e[3],p}if(s.length===0){let u;e[4]!==i?(u=i("mobile.files.search.empty"),e[4]=i,e[5]=u):u=e[5];let p;return e[6]!==u?(p=t.jsx(Vt,{message:u}),e[6]=u,e[7]=p):p=e[7],p}const d="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",f=s.map(u=>t.jsx(Xr,{name:Ut(u.path),path:u.path,directory:!1,meta:Nc(u.path,c),onClick:()=>r(u.path)},u.path));let a;return e[8]!==f?(a=t.jsx("div",{className:d,children:f}),e[8]=f,e[9]=a):a=e[9],a},Vt=n=>{const e=ue.c(7),{message:s,loading:o}=n,r=o===void 0?!1:o;let i;e[0]!==r?(i=r?t.jsx(Ca,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(Ea,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=i):i=e[1];let c;e[2]!==s?(c=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=c):c=e[3];let d;return e[4]!==i||e[5]!==c?(d=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[i,c]})}),e[4]=i,e[5]=c,e[6]=d):d=e[6],d},er="mobile-surface-root",Pc=16,tr=320,Tc="cubic-bezier(0.22, 1, 0.36, 1)",Ac=n=>{const e=ue.c(36),{onOpenMcpSettings:s}=n,{t:o}=fe(),[r,i]=l.useState(!1),c=it(Ic),d=Ot(_c),f=vt(Dc);let a;e[0]!==c||e[1]!==r||e[2]!==f||e[3]!==d?(a=()=>{if(r)return;i(!0);const _=new Promise(Mc);Promise.all([d({directory:c||null,silent:!0}),f({force:!0}),_]).finally(()=>i(!1))},e[0]=c,e[1]=r,e[2]=f,e[3]=d,e[4]=a):a=e[4];const u=a;let p;e[5]!==o?(p=o("settings.mcp.sidebar.actions.addServerTitle"),e[5]=o,e[6]=p):p=e[6];let g;e[7]!==o?(g=o("settings.mcp.sidebar.actions.addServerTitle"),e[7]=o,e[8]=g):g=e[8];let h,b;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},b=t.jsx(ee,{name:"add",className:"size-5"}),e[9]=h,e[10]=b):(h=e[9],b=e[10]);let j;e[11]!==s||e[12]!==p||e[13]!==g?(j=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:s,"aria-label":p,title:g,style:h,children:b}),e[11]=s,e[12]=p,e[13]=g,e[14]=j):j=e[14];let y;e[15]!==o?(y=o("mcpDropdown.actions.refreshAria"),e[15]=o,e[16]=y):y=e[16];let I;e[17]!==o?(I=o("mcpDropdown.actions.refreshAria"),e[17]=o,e[18]=I):I=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N={touchAction:"manipulation"},e[19]=N):N=e[19];const E=r&&"animate-spin";let P;e[20]!==E?(P=J("size-5",E),e[20]=E,e[21]=P):P=e[21];let S;e[22]!==P?(S=t.jsx(ee,{name:"refresh",className:P}),e[22]=P,e[23]=S):S=e[23];let T;e[24]!==r||e[25]!==u||e[26]!==S||e[27]!==y||e[28]!==I?(T=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:u,disabled:r,"aria-label":y,title:I,style:N,children:S}),e[24]=r,e[25]=u,e[26]=S,e[27]=y,e[28]=I,e[29]=T):T=e[29];let x;e[30]!==T||e[31]!==j?(x=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[j,T]}),e[30]=T,e[31]=j,e[32]=x):x=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(bc,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=R):R=e[33];let w;return e[34]!==x?(w=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[x,R]}),e[34]=x,e[35]=w):w=e[35],w},sr=({open:n,onClose:e,tab:s,onTabChange:o,pendingChangesDiff:r,onOpenPlan:i,onOpenMcpSettings:c,variant:d="drawer"})=>{const{t:f}=fe(),a=l.useRef(null),[u,p]=l.useState(!1),[g,h]=l.useState(n),b=l.useRef(e);l.useEffect(()=>{b.current=e},[e]);const j=l.useRef(s);l.useEffect(()=>{j.current=s},[s]);const[y,I]=l.useState(()=>new Set);if(l.useEffect(()=>{n&&I(P=>{if(P.has(s))return P;const S=new Set(P);return S.add(s),S})},[n,s]),typeof document<"u"&&!a.current){let P=document.getElementById(er);P||(P=document.createElement("div"),P.id=er,document.body.appendChild(P)),a.current=P}if(l.useEffect(()=>{if(n){h(!0);const S=window.setTimeout(()=>p(!0),Pc);return()=>window.clearTimeout(S)}p(!1);const P=window.setTimeout(()=>h(!1),tr+40);return()=>window.clearTimeout(P)},[n]),l.useEffect(()=>{if(!n)return;const P=document.body.style.overflow;d==="drawer"&&(document.body.style.overflow="hidden");const S=T=>{T.key==="Escape"&&j.current!=="terminal"&&b.current()};return document.addEventListener("keydown",S),()=>{d==="drawer"&&(document.body.style.overflow=P),document.removeEventListener("keydown",S)}},[n,d]),d==="drawer"&&!a.current)return null;const N=[{id:"changes",label:f("mobile.menu.changes"),icon:t.jsx(ee,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:f("mobile.menu.files"),icon:t.jsx(ee,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:f("mobile.menu.terminal"),icon:t.jsx(ee,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:f("contextRail.surface.notes"),icon:t.jsx(ee,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:f("mobile.menu.mcp"),icon:t.jsx(mi,{className:"h-3.5 w-3.5"})}],E=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:g?t.jsx(na,{items:N,activeId:s,onSelect:P=>o(P),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-mr-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":f("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(ee,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[y.has("changes")?t.jsx("div",{className:J("h-full",s!=="changes"&&"hidden"),children:t.jsx(Le,{children:t.jsx(wc,{initialDiffPath:r?.path??null,initialDiffStaged:r?.staged===!0})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,y.has("files")?t.jsx("div",{className:J("h-full",s!=="files"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Ec,{})})}):null,y.has("terminal")?t.jsx("div",{className:J("h-full",s!=="terminal"&&"hidden"),children:t.jsx(Le,{children:t.jsx(ra,{visible:n&&s==="terminal"})})}):null,y.has("notes")?t.jsx("div",{className:J("h-full",s!=="notes"&&"hidden"),children:t.jsx(Le,{children:t.jsx(oa,{onActionComplete:e,onOpenPlan:i})})}):null,y.has("mcp")?t.jsx("div",{className:J("h-full",s!=="mcp"&&"hidden"),children:t.jsx(Le,{children:t.jsx(Ac,{onOpenMcpSettings:c})})}):null]})]});return d==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:E}):jt.createPortal(t.jsx("section",{role:"dialog","aria-modal":"true","aria-label":f("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:u?"none":"translateX(100%)",transition:`transform ${tr}ms ${Tc}`,visibility:g?"visible":"hidden",pointerEvents:n?"auto":"none"},children:E}),a.current)};function Ic(n){return n.currentDirectory}function _c(n){return n.refresh}function Dc(n){return n.loadMcpConfigs}function Mc(n){return window.setTimeout(n,500)}function zc(n){const e=ue.c(4),s=2500,{uiFont:o}=pi(),[r,i]=l.useState(!1);let c,d;return e[0]!==s||e[1]!==o?(c=()=>{let f=!1;const a=()=>{f||i(!0)},u=()=>{requestAnimationFrame(()=>requestAnimationFrame(a))},p=Promise.all([hi(o).catch(Fc),document.fonts?.ready?.then($c).catch(Lc)??Promise.resolve(),Ia.catch(Bc)]).then(Oc),g=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([p,g]).then(u),()=>{f=!0}},d=[o,s],e[0]=s,e[1]=o,e[2]=c,e[3]=d):(c=e[2],d=e[3]),l.useEffect(c,d),r}function Oc(){}function Bc(){}function Lc(){}function $c(){}function Fc(){}const Wc="aiworker",Uc=n=>n.replace(/^\/+|\/+$/g,""),Vc=n=>{const e=Uc(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Gc(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Wc}:`)return null;const s=Vc(e),o=(s[0]??"").toLowerCase(),r=s.slice(1),i=e.searchParams;switch(o){case"session":{const c=r[0]||i.get("id")||"";return c?{type:"session",sessionId:c,directory:i.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:i.get("dir")??void 0,projectId:i.get("project")??void 0,agent:i.get("agent")??void 0,model:i.get("model")??void 0};case"sessions":{const c=i.get("filter");return{type:"sessions",filter:c==="attention"||c==="recent"||c==="all"?c:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:r[0]||i.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||i.get("path")||void 0,staged:i.get("staged")==="true"};case"view":{const c=(r[0]||"").toLowerCase();return c==="changes"?{type:"changes"}:c==="files"||c==="mcp"||c==="instances"||c==="update"?{type:"view",target:c}:null}default:return null}}let ze={},Qr=!1,Wt=null;const Kc=n=>{switch(n.type){case"session":return ke.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=ke.getState();return e.openNewSessionDraft(),(n.directory||n.projectId)&&e.setNewSessionDraftTarget({directoryOverride:n.directory??null,projectId:n.projectId??null,selectedProjectId:n.projectId??null}),!0}case"sessions":return ze.openSessions?(ze.openSessions(n.filter),!0):!1;case"status":return ze.openSessions?(ze.openSessions(),!0):!1;case"view":return ze.openView?(ze.openView(n.target),!0):!1;case"changes":return ze.openChanges?(ze.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return ze.openSettings?(ze.openSettings(n.section),!0):!1}},cn=()=>{if(!Qr||!Wt)return;const n=Wt;Wt=null,Kc(n)||(Wt=n)},Zr=n=>{Wt=n,cn()},nr=n=>{const e=Gc(n);e&&Zr(e)},Hc=n=>{Qr=n,cn()},qc=n=>{const e=ue.c(3);let s,o;e[0]!==n?(s=()=>(ze=n,cn(),()=>{ze===n&&(ze={})}),o=[n],e[0]=n,e[1]=s,e[2]=o):(s=e[1],o=e[2]),l.useEffect(s,o)},Yc=n=>{const{ready:e}=n;l.useEffect(()=>{Hc(e)},[e]),l.useEffect(()=>{if(!Pe())return;let s=!1;const o=[];return kt(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([125,4,126])).then(async({App:r})=>{if(s)return;const i=await r.addListener("appUrlOpen",c=>{nr(c?.url)});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),kt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([127,126])).then(async({PushNotifications:r})=>{if(s)return;const i=await r.addListener("pushNotificationActionPerformed",c=>{const d=c?.notification?.data,f=typeof d?.url=="string"?d.url:typeof d?.deeplink=="string"?d.deeplink:void 0;if(f){nr(f);return}const a=typeof d?.sessionId=="string"?d.sessionId:void 0;a&&Zr({type:"session",sessionId:a})});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),()=>{s=!0,o.forEach(r=>r())}},[])},Jc=32,Xc=80,Qc=64,Zc=.7,eu=(n,e)=>{const s=l.useRef(e);s.current=e,l.useEffect(()=>{const o=n.current;if(!o)return;const i=window.Capacitor?.getPlatform?.()==="android"?Xc:Jc;let c=!1,d=!1,f=0,a=0;const u=g=>{if(g.touches.length!==1){c=!1;return}const h=g.touches[0],b=o.clientWidth,j=h.clientX<=i,y=h.clientX>=b-i;c=j||y,d=j,f=h.clientX,a=h.clientY},p=g=>{if(!c)return;c=!1;const h=g.changedTouches[0];if(!h)return;const b=h.clientX-f,j=h.clientY-a;Math.abs(b)<Qc||Math.abs(j)>Math.abs(b)*Zc||d&&b<=0||!d&&b>=0||(d?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return o.addEventListener("touchstart",u,{passive:!0}),o.addEventListener("touchend",p,{passive:!0}),()=>{o.removeEventListener("touchstart",u),o.removeEventListener("touchend",p)}},[n])},tu=()=>{if(typeof window>"u")return;const n=window.__AIWORKER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},su=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},nu=n=>{const{enabled:e}=n,s=Je(r=>r.nativeNotificationsEnabled),o=l.useRef(null);l.useEffect(()=>{if(!e||!s||!su())return;let r=!1;const i=[];return kt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([127,126])).then(async({PushNotifications:c})=>{if(r)return;let d=await c.checkPermissions().catch(()=>null);if(d?.receive!=="granted"&&(d=await c.requestPermissions().catch(()=>null)),d?.receive!=="granted")return;const f=await c.addListener("registration",u=>{o.current=u.value,vn()?.push?.registerApnsToken?.({token:u.value,platform:ar(),environment:tu()})}),a=await c.addListener("registrationError",u=>{console.warn("[Push] APNs registration error:",u)});if(await c.register().catch(()=>{}),r){f.remove(),a.remove();return}i.push(()=>{f.remove()},()=>{a.remove()})}).catch(()=>{}),()=>{r=!0,i.forEach(c=>c())}},[e,s]),l.useEffect(()=>{if(s)return;const r=o.current;if(!r)return;o.current=null,vn()?.push?.unregisterApnsToken?.({token:r})},[s])},rr=n=>{const e=ue.c(12),{side:s,isResizing:o,ariaLabel:r,handleProps:i}=n,c=s==="left"?"right-0":"left-0";let d;e[0]!==c?(d=J("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",c),e[0]=c,e[1]=d):d=e[1];const f=s==="left"?"right-0":"left-0",a=o&&"bg-[var(--interactive-border)]";let u;e[2]!==f||e[3]!==a?(u=J("absolute inset-y-0 w-[3px] transition-colors",f,a),e[2]=f,e[3]=a,e[4]=u):u=e[4];let p;e[5]!==u?(p=t.jsx("div",{className:u}),e[5]=u,e[6]=p):p=e[6];let g;return e[7]!==r||e[8]!==i||e[9]!==d||e[10]!==p?(g=t.jsx("div",{className:d,role:"separator","aria-orientation":"vertical","aria-label":r,...i,children:p}),e[7]=r,e[8]=i,e[9]=d,e[10]=p,e[11]=g):g=e[11],g},ru=320,ou=380,or=280,iu=560,au=900;function ir(n,e,s,o){const r=ue.c(23),i=o===void 0?iu:o,c=l.useRef(null);let d;r[0]!==s||r[1]!==i||r[2]!==e?(d=()=>{if(typeof window>"u")return s;const k=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(k)?Math.min(i,Math.max(or,k)):s},r[0]=s,r[1]=i,r[2]=e,r[3]=d):d=r[3];const[f,a]=l.useState(d),[u,p]=l.useState(!1),g=l.useRef(0),h=l.useRef(f),b=l.useRef(null),j=l.useRef(null);let y;r[4]!==i?(y=k=>Math.min(i,Math.max(or,Math.round(k))),r[4]=i,r[5]=y):y=r[5];const I=y;let N;r[6]===Symbol.for("react.memo_cache_sentinel")?(N=k=>{const O=c.current;O&&(O.style.width=`${k}px`,O.style.minWidth=`${k}px`,O.style.maxWidth=`${k}px`,O.style.setProperty("--oc-ipad-sidebar-width",`${k}px`))},r[6]=N):N=r[6];const E=N;let P;r[7]!==f?(P=k=>{try{k.currentTarget.setPointerCapture(k.pointerId)}catch{}j.current=k.pointerId,g.current=k.clientX,h.current=f,b.current=f,p(!0),k.preventDefault()},r[7]=f,r[8]=P):P=r[8];const S=P;let T;r[9]!==I||r[10]!==n?(T=k=>{if(j.current!==k.pointerId)return;const O=k.clientX-g.current,G=I(h.current+(n==="left"?O:-O));b.current!==G&&(b.current=G,E(G))},r[9]=I,r[10]=n,r[11]=T):T=r[11];const x=T;let R;r[12]!==I||r[13]!==e?(R=k=>{if(j.current!==k.pointerId)return;try{k.currentTarget.releasePointerCapture(k.pointerId)}catch{}const O=I(b.current??h.current);j.current=null,b.current=null,p(!1),a(O);try{window.localStorage.setItem(e,String(O))}catch{}},r[12]=I,r[13]=e,r[14]=R):R=r[14];const w=R;let _;r[15]!==S||r[16]!==w||r[17]!==x?(_={onPointerDown:S,onPointerMove:x,onPointerUp:w,onPointerCancel:w},r[15]=S,r[16]=w,r[17]=x,r[18]=_):_=r[18];const D=_;let C;return r[19]!==D||r[20]!==u||r[21]!==f?(C={asideRef:c,width:f,isResizing:u,handleProps:D},r[19]=D,r[20]=u,r[21]=f,r[22]=C):C=r[22],C}const lu=["general","appearance","chat","notifications","sessions","git","magic-prompts","behavior","mcp","providers","usage","voice","integrations","about"],cu=1e3,uu=({onActiveConnectionDeleted:n})=>{const{t:e}=fe();fa();const[s,o]=l.useState(!1),[r,i]=l.useState(null),[c,d]=l.useState(!1),[f,a]=l.useState("changes"),[u,p]=l.useState(null),[g,h]=l.useState("nav"),[b,j]=l.useState(null),y=Je(U=>U.setSettingsPage),I=Je(U=>U.wideChatLayoutEnabled),N=xt(U=>U.available),E=xt(U=>U.runtimeType),P=l.useMemo(()=>jr(),[]),S=vt(U=>U.mcpServers),T=vt(U=>U.setMcpDraft),x=vt(U=>U.setSelectedMcp),R=l.useCallback(()=>{i(null),p(null)},[]),w=l.useCallback(U=>{i(U)},[]),_=l.useCallback(()=>{d(!1)},[]),D=l.useCallback(U=>{h(U),w("settings")},[w]),{enabled:C,roomyForPanels:k}=zs(),G=Di()==="portrait",v=Mi(),[A,L]=l.useState(()=>zi().roomyForPanels),$=l.useCallback(()=>{L(U=>!U)},[]);l.useEffect(()=>{C||L(!1)},[C]);const B=l.useCallback(()=>{j(null),a("files"),d(!0)},[]),ne=l.useCallback((U=null)=>{j(U),a("changes"),d(!0)},[]),Q=ir("left","aiworker.ipad.leftSidebarWidth",ru),te=ir("right","aiworker.ipad.rightSidebarWidth",ou,au),z=k,W=z&&c?te.width:0,K=C&&A?Q.width:0;l.useEffect(()=>{if(typeof document>"u")return;const U=document.documentElement;return U.style.setProperty("--oc-chat-inset-left",`${K}px`),U.style.setProperty("--oc-chat-inset-right",`${W}px`),()=>{U.style.removeProperty("--oc-chat-inset-left"),U.style.removeProperty("--oc-chat-inset-right")}},[K,W]),l.useEffect(()=>{if(typeof document>"u")return;const U=document.documentElement;return U.classList.toggle("wide-chat-layout",I),()=>U.classList.remove("wide-chat-layout")},[I]),l.useEffect(()=>{if(typeof document>"u")return;const U=C&&(G||v),ae=document.documentElement;return ae.classList.toggle("oc-keep-draft-starters",U),()=>ae.classList.remove("oc-keep-draft-starters")},[v,C,G]);const H=l.useMemo(()=>({openChanges:({diffPath:U,staged:ae}={})=>{ne(U?{path:U,staged:ae===!0}:null)},openFiles:()=>B(),openSettings:()=>D("nav")}),[ne,B,D]),X=l.useMemo(()=>({openSessions:()=>{C?L(!0):o(!0)},openView:U=>{if(U==="files"){B();return}if(U==="mcp"){a("mcp"),d(!0);return}w(U)},openChanges:({path:U,staged:ae}={})=>{ne(U?{path:U,staged:ae===!0}:null)},openSettings:U=>{U&&y(U),D(U?"page-content":"nav")}}),[C,ne,B,D,w,y]);qc(X);const se=l.useRef(null);eu(se,{onLeftEdgeSwipe:()=>{C?L(!0):o(!0)},onRightEdgeSwipe:()=>d(!0)});const ie=l.useCallback(()=>u?(p(null),!0):r?(R(),!0):c?(_(),!0):s?(o(!1),!0):!1,[r,R,_,u,s,c]);Oi(ie);const me=!P&&N&&(E==="desktop"||E==="web"),ce=C?"dialog":"fullscreen",q=l.useMemo(()=>({instanceLabel:P?Bt():null,onOpenInstances:P?()=>w("instances"):void 0,onOpenSettings:()=>D("nav"),onOpenUpdate:me?()=>w("update"):void 0}),[D,w,P,me]),re=l.useCallback(()=>{const U="new-mcp-server";let ae=U,Ee=1;for(;S.some(Te=>Te.name===ae);)ae=`${U}-${Ee}`,Ee+=1;T({name:ae,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),x(ae),y("mcp"),D("page-content")},[S,D,T,x,y]);return t.jsx(Bi,{actions:H,children:t.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[C?t.jsxs("aside",{ref:Q.asideRef,className:J("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!A&&"border-r-0"),style:{width:A?Q.width:0,minWidth:A?Q.width:0,maxWidth:A?Q.width:0,"--oc-ipad-sidebar-width":`${Q.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:Q.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!A,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:J("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",Q.isResizing&&"pointer-events-none",!A&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Le,{children:t.jsx(Yn,{open:!0,variant:"sidebar",onOpenChange:U=>{!U&&!k&&L(!1)},footer:q})})}),A?t.jsx(rr,{side:"left",isResizing:Q.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:Q.handleProps}):null]}):null,t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[t.jsx(Fl,{onOpenSessions:()=>C?$():o(!0),onOpenWorkspace:()=>d(!0),compactTitle:C}),t.jsx("main",{ref:se,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:t.jsx("div",{className:"h-full w-full",children:t.jsx(Le,{children:t.jsx(ma,{})})})})]}),C?null:t.jsx(Yn,{open:s,onOpenChange:o,footer:q}),C?t.jsxs("aside",{ref:te.asideRef,className:J("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!W&&"border-l-0"),style:{width:W,minWidth:W,maxWidth:W,"--oc-ipad-sidebar-width":`${te.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:te.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!W,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:J("flex h-full min-h-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",te.isResizing&&"pointer-events-none",!W&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(Le,{children:t.jsx(sr,{open:c,onClose:_,tab:f,onTabChange:a,pendingChangesDiff:b,onOpenPlan:p,onOpenMcpSettings:re,variant:z?"panel":"drawer"})})}),W?t.jsx(rr,{side:"right",isResizing:te.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:te.handleProps}):null]}):t.jsx(sr,{open:c,onClose:_,tab:f,onTabChange:a,pendingChangesDiff:b,onOpenPlan:p,onOpenMcpSettings:re}),u?t.jsx(Ft,{open:!0,variant:ce,onClose:()=>p(null),ariaLabel:u.title,title:u.title,children:t.jsx(Le,{children:t.jsx(ba,{savedProjectPlan:{projectRef:u.projectRef,planId:u.id},onNavigatedToChat:()=>{R(),_()}})})}):null,r==="instances"&&P?t.jsx(Ft,{open:!0,variant:ce,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Gl,{onConnect:R,onActiveConnectionDeleted:n})}):null,r==="settings"?t.jsx(Ft,{open:!0,variant:ce,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(Le,{children:t.jsx(ha,{forceMobile:!0,isWindowed:!0,initialMobileStage:g,visiblePageSlugs:lu.filter(U=>!(P&&U==="about")),onClose:R})})}):null,r==="update"?t.jsx(Ft,{open:!0,variant:ce,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(Le,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(ga,{initialUpdateDialogOpen:!0})})})}):null]})})};function du({apis:n}){const{t:e}=fe(),s=Oe(z=>z.initializeApp),o=Oe(z=>z.isInitialized),r=Oe(z=>z.isConnected),i=Oe(z=>z.connectionPhase),c=Oe(z=>z.providers.length),d=Oe(z=>z.agents.length),f=Oe(z=>z.loadProviders),a=Oe(z=>z.loadAgents),u=it(z=>z.currentDirectory),p=ke(z=>z.error),g=ke(z=>z.clearError),h=Je(z=>z.setIsMobile),b=gi(z=>z.refreshStatus),j=bi(z=>z.refreshStatus),y=xi(z=>z.setPlanModeEnabled),I=Be(z=>z.projects),[N,E]=l.useState(0),[P,S]=l.useState(0),[T,x]=l.useState(!1),[R,w]=l.useState("pending"),[_,D]=l.useState(null),C=l.useMemo(()=>Bt(),[]),[,k]=l.useReducer(z=>z+1,0),O=l.useMemo(()=>jr(),[]),G=l.useRef(0),v=l.useRef(0),A=l.useCallback(()=>{const z=Ye(),W=v.current+1;if(v.current=W,!z){Mt("resume:auto-connect",{}),zt();return}Mt("resume:reprobe",{});const K=()=>{s(),b(n.github,{force:!0}),j(n.linear,{force:!0}),c===0&&f({source:"mobileApp:nativeResume"}),d===0&&a({source:"mobileApp:nativeResume"})},H=se=>{Mt("resume:disconnect",{reason:se}),bt({apiBaseUrl:"",clientToken:null,runtimeKey:Zt}),E(ie=>ie+1)};rs().then(se=>{if(v.current===W){if(se==="no-connection"){H("no-connection");return}if(se==="needs-login"){D({kind:"auth-expired",label:Bt()??""}),H("needs-login");return}if(se==="unreachable"){const ie=[4e3,1e4],me=ce=>{window.setTimeout(()=>{if(v.current!==W)return;const q=ce===ie.length-1;rs({fast:!q}).then(re=>{if(v.current===W&&re!=="switched"){if(re==="unchanged"){K();return}if(re==="needs-login"){D({kind:"auth-expired",label:Bt()??""}),H("retry-needs-login");return}if(!q){me(ce+1);return}H(`retry-${re}`)}})},ie[ce])};me(0);return}se!=="switched"&&K()}});const X=Date.now();X-G.current>=cu&&(G.current=X,window.dispatchEvent(new Event("aiworker:system-resume")))},[d,n.github,n.linear,s,a,f,c,b,j]);yi(),vi(A),l.useEffect(()=>{if(!O)return;let z;const W=()=>{window.clearTimeout(z),z=window.setTimeout(()=>A(),1500)};return window.addEventListener("online",W),()=>{window.removeEventListener("online",W),window.clearTimeout(z)}},[O,A]),l.useEffect(()=>{if(O)return wn.subscribe((z,W)=>{z.state==="expired"&&W.state!=="expired"&&(A(),wn.getState().markAuthenticated())})},[O,A]),l.useEffect(()=>(jn(n),()=>jn(null)),[n]),l.useEffect(()=>wo(z=>{if(Mt("endpoint:changed",{runtimeKey:z.runtimeKey||"none",previousRuntimeKey:z.previousRuntimeKey||"none",connected:!!z.apiBaseUrl}),!!z.runtimeKey&&z.runtimeKey===z.previousRuntimeKey){ia(),k();return}aa(z),S(K=>K+1),E(K=>K+1)}),[]),l.useEffect(()=>{if(!O||r||Ye()){w("done");return}let z=!1;return w("attempting"),(async()=>{const W=await zt().catch(()=>({status:"no-candidate"}));z||(W.status==="unreachable"?D({kind:"unreachable",label:W.label}):W.status==="needs-login"&&D({kind:"auth-expired",label:W.label}),w("done"),W.status==="unreachable"&&zt({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{z=!0}},[]),l.useEffect(()=>{if(!O||!Ye())return;let z=!1;const W=K=>{Mt("cold-launch:drop",{kind:K?.kind??"unknown"}),K&&D(K),bt({apiBaseUrl:"",clientToken:null,runtimeKey:Zt}),E(H=>H+1)};return rs().then(async K=>{if(z||K==="switched"||K==="unchanged")return;const H=Bt();if(K==="needs-login"){W({kind:"auth-expired",label:H??""});return}if(K==="unreachable"){W(H?{kind:"unreachable",label:H}:null),zt({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const X=await zt().catch(()=>({status:"no-candidate"}));z||X.status==="connected"||(X.status==="needs-login"?W({kind:"auth-expired",label:X.label}):X.status==="unreachable"?W({kind:"unreachable",label:X.label}):W(null))}),()=>{z=!0}},[]),l.useEffect(()=>{h(!0)},[h]),l.useEffect(()=>{O&&!Ye()||s()},[N,s,O]),l.useEffect(()=>{r&&(c===0&&f({source:"mobileApp:recovery"}),d===0&&a({source:"mobileApp:recovery"}))},[d,r,a,f,c]);const L=l.useRef(!1),[$,B]=l.useState(O);l.useEffect(()=>{if(!O||!r||L.current)return;if(ke.getState().currentSessionId){L.current=!0,B(!1);return}const z=Rt(),W=wi(z);if(!W){L.current=!0,B(!1);return}let K=!1;const H=window.setTimeout(()=>B(!1),6e3);return(async()=>{const X=await Os().catch(()=>null);if(K)return;if(!X){B(!1);return}L.current=!0;const se=X.activeSessions.find(me=>me.id===W.sessionId);if(!se){ji(z),B(!1);return}const ie=ke.getState();ie.currentSessionId||ie.setCurrentSession(se.id,Ms(se)??W.directory??void 0),B(!1)})(),()=>{K=!0,window.clearTimeout(H)}},[N,r,O]),l.useEffect(()=>{r&&kn.setDirectory(u)},[u,r]),l.useEffect(()=>{r&&(b(n.github,{force:!0}),j(n.linear,{force:!0}))},[n.github,n.linear,r,b,j]),l.useEffect(()=>{if(!r||I.length===0)return;let z=!1;return(async()=>{const K=new Map(ke.getState().availableWorktreesByProject);if(await Promise.all(I.map(async se=>{const ie=se.path.replace(/\\/g,"/").replace(/\/+$/,"");if(ie)try{if(!(Ve.getState().directories.get(ie)?.isGitRepo??await kt(()=>import("./useAppFontEffects-D7sNpuL2.js").then(re=>re.ii),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(re=>re.checkIsGitRepository(ie))))return;const q=await vr({id:se.id,path:ie});if(z)return;K.set(ie,q)}catch{}})),z)return;const H=wr(I,K),X=ke.getState().availableWorktreesByProject;_i(H,X)||ke.setState({availableWorktrees:[...H.values()].flat(),availableWorktreesByProject:H})})(),()=>{z=!0}},[r,I]),l.useEffect(()=>{let z=!1;return(async()=>{const K=await _s("/health",{method:"GET"}).catch(()=>null);if(!K||!K.ok||z)return;const H=await K.json().catch(()=>null);if(!H||z)return;const X=H.planModeExperimentalEnabled;y(X===!0||X===1||X==="1"||X==="true")})(),()=>{z=!0}},[y]),l.useEffect(()=>{if(!p)return;const z=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(z)},[g,p]),l.useEffect(()=>{if(!(!r&&(O?!!Ye():!0))){x(!1);return}const W=window.setTimeout(()=>{x(!0)},O?4e3:8e3);return()=>window.clearTimeout(W)},[r,O,N,P]),ki(),Si({enabled:!0}),la(),Ni(),ca(),nu({enabled:O&&r}),Yc({ready:O&&r&&o});const ne=zc(),Q=!r&&i==="reconnecting";if(!ne)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(st,{width:120,height:120,isAnimated:!0})});const te=!!Ye();return O&&(!te||!r&&!Q)?te?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(st,{width:120,height:120,isAnimated:!T}),T?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("mobile.connect.recovery.description")})]}),t.jsx(we,{type:"button",variant:"outline",onClick:()=>{bt({apiBaseUrl:"",clientToken:null,runtimeKey:Zt}),E(z=>z+1)},children:e("mobile.connect.cancelPassword")})]}):null]})}):R!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[t.jsx(st,{width:120,height:120,isAnimated:!0}),C?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:e("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[C,t.jsx(Ci,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(Cl,{onConnected:()=>E(z=>z+1),notice:_})}):!r&&!Q?T?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(st,{width:120,height:120,isAnimated:!0})}):t.jsx(Le,{children:t.jsx(Ei,{sdk:kn.getSdkClient(),directory:u||"",children:t.jsx(Ri,{apis:n,children:t.jsx(Pi,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[O&&$?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:t.jsx(st,{width:120,height:120,isAnimated:!0})}):null,t.jsx(Ti,{embeddedBackgroundWorkEnabled:o}),t.jsx(ua,{}),t.jsx(Fa,{}),t.jsx(uu,{onActiveConnectionDeleted:()=>{bt({apiBaseUrl:"",clientToken:null,runtimeKey:Zt}),E(z=>z+1)}}),t.jsx(Ai,{}),t.jsx(Ii,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),o?t.jsx(da,{}):null]})})})},P)})}const fu=()=>{Gi(),jo().then(()=>{Promise.all([ko(),Ki()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),Hi(),qi(),Yi()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{_a()})};function Lf(n){window.__AIWORKER_SURFACE__="mobile",Li(),fu(),$a(),$i();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const o=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=o?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,i=t.jsx(du,{apis:r});ho.createRoot(e).render(t.jsx(Ns.StrictMode,{children:t.jsx(Fi,{children:t.jsx(Wi,{children:t.jsx(Ui,{children:t.jsx(pa,{children:o?i:t.jsx(Vi,{children:i})})})})})}))}export{Lf as renderMobileApp};
|