@openchamber/web 1.14.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/bin/cli.test.js +8 -0
  2. package/bin/lib/DOCUMENTATION.md +3 -0
  3. package/bin/lib/cli-args.js +10 -0
  4. package/bin/lib/commands-connect-url.js +169 -22
  5. package/dist/assets/{DiagramView-CIaZCGUT.js → DiagramView-HR2xZxJ8.js} +1 -1
  6. package/dist/assets/MarkdownRendererImpl-sm01Q7R7.js +11 -0
  7. package/dist/assets/{MultiRunWindow-Bsbr3i8y.js → MultiRunWindow-DlFUaNQK.js} +1 -1
  8. package/dist/assets/OnboardingScreen-DVRz82mJ.js +1 -0
  9. package/dist/assets/{SessionSwitcherDropdown-CLm6tF5n.js → SessionSwitcherDropdown-DvoOalMY.js} +1 -1
  10. package/dist/assets/SettingsWindow-CkInZcj7.js +1 -0
  11. package/dist/assets/{TerminalView-DF7-jlam.js → TerminalView-D_9BAjtv.js} +3 -3
  12. package/dist/assets/es-cjUissX4.js +15 -0
  13. package/dist/assets/fr-DqbXnTdK.js +13 -0
  14. package/dist/assets/index-Dg0nmvQU.css +1 -0
  15. package/dist/assets/index-ltrmNGAf.js +2 -0
  16. package/dist/assets/ja-Cetyq6Eg.js +15 -0
  17. package/dist/assets/ko-DtunWisP.js +15 -0
  18. package/dist/assets/main-BC0m8s1v.js +236 -0
  19. package/dist/assets/main-DzNa8r0N.js +2 -0
  20. package/dist/assets/miniChat-BRYDE-Se.js +2 -0
  21. package/dist/assets/mobile-C3QJVA97.js +2 -0
  22. package/dist/assets/pl-DctGLgve.js +15 -0
  23. package/dist/assets/pt-BR-CXPhf78S.js +15 -0
  24. package/dist/assets/renderElectronMiniChatApp-CVFbDC5A.js +2 -0
  25. package/dist/assets/renderMobileApp-wkBjh5WR.js +16 -0
  26. package/dist/assets/runtimeEndpointReset-C42u8PvG.js +167 -0
  27. package/dist/assets/uk-Bdrc-kqF.js +15 -0
  28. package/dist/assets/{useAppFontEffects-DTO332li.js → useAppFontEffects-DzBg8hrC.js} +132 -116
  29. package/dist/assets/{vendor-.bun-C6iL44L9.js → vendor-.bun-BE757pvp.js} +1 -1
  30. package/dist/assets/zh-CN-CeCVKrHP.js +15 -0
  31. package/dist/assets/zh-TW-CoqiQING.js +15 -0
  32. package/dist/index.html +4 -4
  33. package/dist/mini-chat.html +4 -4
  34. package/dist/mobile.html +4 -4
  35. package/package.json +2 -2
  36. package/server/index.js +157 -6
  37. package/server/lib/client-auth/pairing.js +308 -0
  38. package/server/lib/client-auth/pairing.test.js +142 -0
  39. package/server/lib/client-auth/remote-clients.js +65 -3
  40. package/server/lib/notifications/apns-runtime.js +9 -16
  41. package/server/lib/opencode/bootstrap-runtime.js +10 -0
  42. package/server/lib/opencode/core-routes.js +247 -6
  43. package/server/lib/opencode/core-routes.test.js +248 -9
  44. package/server/lib/opencode/feature-routes-runtime.js +10 -0
  45. package/server/lib/opencode/models-metadata.js +61 -0
  46. package/server/lib/opencode/network-runtime.js +14 -1
  47. package/server/lib/opencode/network-runtime.test.js +29 -9
  48. package/server/lib/opencode/openchamber-routes.js +7 -40
  49. package/server/lib/opencode/proxy.js +47 -6
  50. package/server/lib/opencode/settings-helpers.js +16 -0
  51. package/server/lib/opencode/settings-helpers.test.js +11 -0
  52. package/server/lib/opencode/settings-normalization-runtime.js +2 -0
  53. package/server/lib/opencode/shutdown-runtime.js +2 -0
  54. package/server/lib/package-manager.js +18 -5
  55. package/server/lib/relay/DOCUMENTATION.md +78 -0
  56. package/server/lib/relay/cross-compat.test.js +135 -0
  57. package/server/lib/relay/e2ee.js +341 -0
  58. package/server/lib/relay/e2ee.test.js +124 -0
  59. package/server/lib/relay/host-client.js +389 -0
  60. package/server/lib/relay/host-client.test.js +280 -0
  61. package/server/lib/relay/identity.js +73 -0
  62. package/server/lib/relay/identity.test.js +78 -0
  63. package/server/lib/relay/service.js +247 -0
  64. package/server/lib/relay/signing-key.js +50 -0
  65. package/server/lib/relay/tunnel-codec.js +373 -0
  66. package/server/lib/relay/tunnel-codec.test.js +58 -0
  67. package/server/lib/relay/tunnel-host.js +462 -0
  68. package/server/lib/session-assist/DOCUMENTATION.md +66 -0
  69. package/server/lib/session-assist/runtime.js +394 -0
  70. package/server/lib/small-model/DOCUMENTATION.md +78 -0
  71. package/server/lib/small-model/call.js +380 -0
  72. package/server/lib/small-model/catalog.js +13 -0
  73. package/server/lib/small-model/index.js +167 -0
  74. package/server/lib/small-model/resolve.js +131 -0
  75. package/server/lib/small-model/resolve.test.js +197 -0
  76. package/server/lib/small-model/routes.js +44 -0
  77. package/server/lib/ui-auth/DOCUMENTATION.md +6 -0
  78. package/server/lib/ui-auth/ui-auth.js +10 -0
  79. package/server/opencode-proxy.test.js +38 -0
  80. package/dist/assets/MarkdownRendererImpl-DWgOeIpO.js +0 -7
  81. package/dist/assets/OnboardingScreen-3IAKkM5k.js +0 -1
  82. package/dist/assets/SettingsWindow-K-ErjehP.js +0 -1
  83. package/dist/assets/es-DQIFCjC2.js +0 -15
  84. package/dist/assets/fr-CJRav0LS.js +0 -13
  85. package/dist/assets/index-5eUDDB6w.js +0 -2
  86. package/dist/assets/index-CgpE7F8T.css +0 -1
  87. package/dist/assets/ja-CjAaqvHO.js +0 -15
  88. package/dist/assets/ko-BEbFxvrd.js +0 -15
  89. package/dist/assets/main-C2put7uQ.js +0 -2
  90. package/dist/assets/main-DuQEoz31.js +0 -214
  91. package/dist/assets/miniChat-o3AAQ-8r.js +0 -2
  92. package/dist/assets/mobile-X0421aWz.js +0 -2
  93. package/dist/assets/pl-D4kzai5T.js +0 -15
  94. package/dist/assets/pt-BR-9Sk3esQZ.js +0 -15
  95. package/dist/assets/renderElectronMiniChatApp-CdDj0ms1.js +0 -2
  96. package/dist/assets/renderMobileApp-cZ_HZKSe.js +0 -16
  97. package/dist/assets/runtimeEndpointReset-BYLVW9e7.js +0 -167
  98. package/dist/assets/uk-DW_dTfoO.js +0 -15
  99. package/dist/assets/zh-CN-r2_euV7U.js +0 -15
  100. package/dist/assets/zh-TW-BdPx3NWh.js +0 -15
@@ -0,0 +1,197 @@
1
+ import { describe, it, expect } from 'bun:test';
2
+ import { resolveSmallModel, parseModelRef, isUsableAuthEntry } from './resolve.js';
3
+
4
+ const catalog = {
5
+ google: {
6
+ id: 'google',
7
+ models: {
8
+ 'gemini-2.5-flash': { id: 'gemini-2.5-flash', family: 'gemini-flash', release_date: '2025-06-01' },
9
+ 'gemini-2.0-flash': { id: 'gemini-2.0-flash', family: 'gemini-flash', release_date: '2024-12-01' },
10
+ 'gemini-2.5-pro': { id: 'gemini-2.5-pro', family: 'gemini-pro', release_date: '2025-06-01' },
11
+ },
12
+ },
13
+ anthropic: {
14
+ id: 'anthropic',
15
+ models: {
16
+ 'claude-haiku-4-5': { id: 'claude-haiku-4-5', family: 'claude-haiku', release_date: '2025-10-01' },
17
+ 'claude-sonnet-4-5': { id: 'claude-sonnet-4-5', family: 'claude-sonnet', release_date: '2025-09-01' },
18
+ },
19
+ },
20
+ };
21
+
22
+ describe('parseModelRef', () => {
23
+ it('splits provider/model on the first slash', () => {
24
+ expect(parseModelRef('anthropic/claude-haiku-4-5')).toEqual({
25
+ providerID: 'anthropic',
26
+ modelID: 'claude-haiku-4-5',
27
+ });
28
+ });
29
+
30
+ it('keeps slashes inside the model id', () => {
31
+ expect(parseModelRef('openrouter/google/gemini-2.5-flash')).toEqual({
32
+ providerID: 'openrouter',
33
+ modelID: 'google/gemini-2.5-flash',
34
+ });
35
+ });
36
+
37
+ it('rejects values without a provider or model part', () => {
38
+ expect(parseModelRef('anthropic/')).toBeNull();
39
+ expect(parseModelRef('/model')).toBeNull();
40
+ expect(parseModelRef('plain')).toBeNull();
41
+ expect(parseModelRef(undefined)).toBeNull();
42
+ });
43
+ });
44
+
45
+ describe('isUsableAuthEntry', () => {
46
+ it('accepts api keys, oauth tokens, and wellknown tokens', () => {
47
+ expect(isUsableAuthEntry({ type: 'api', key: 'sk-x' })).toBe(true);
48
+ expect(isUsableAuthEntry({ type: 'oauth', access: 'a', refresh: 'r', expires: 0 })).toBe(true);
49
+ expect(isUsableAuthEntry({ type: 'wellknown', key: 'k', token: 't' })).toBe(true);
50
+ });
51
+
52
+ it('rejects empty or malformed entries', () => {
53
+ expect(isUsableAuthEntry({ type: 'api', key: '' })).toBe(false);
54
+ expect(isUsableAuthEntry({ type: 'oauth' })).toBe(false);
55
+ expect(isUsableAuthEntry(null)).toBe(false);
56
+ });
57
+ });
58
+
59
+ describe('resolveSmallModel', () => {
60
+ it('gives the OpenChamber settings override top priority', () => {
61
+ const result = resolveSmallModel({
62
+ auth: { anthropic: { type: 'api', key: 'sk-x' } },
63
+ catalog,
64
+ settingsSmallModel: 'anthropic/claude-haiku-4-5',
65
+ configSmallModel: 'openai/gpt-4o-mini',
66
+ preferredProviderID: 'anthropic',
67
+ });
68
+ expect(result).toEqual({ providerID: 'anthropic', modelID: 'claude-haiku-4-5', source: 'settings' });
69
+ });
70
+
71
+ it('prefers the configured small_model', () => {
72
+ const result = resolveSmallModel({
73
+ auth: { anthropic: { type: 'api', key: 'sk-x' } },
74
+ catalog,
75
+ configSmallModel: 'openai/gpt-4o-mini',
76
+ });
77
+ expect(result).toEqual({ providerID: 'openai', modelID: 'gpt-4o-mini', source: 'config' });
78
+ });
79
+
80
+ it('scans authenticated providers by family priority, newest first', () => {
81
+ const result = resolveSmallModel({
82
+ auth: {
83
+ google: { type: 'api', key: 'g-key' },
84
+ anthropic: { type: 'api', key: 'sk-x' },
85
+ },
86
+ catalog,
87
+ configSmallModel: null,
88
+ });
89
+ expect(result).toEqual({ providerID: 'google', modelID: 'gemini-2.5-flash', source: 'family-scan' });
90
+ });
91
+
92
+ it('skips providers without a usable credential', () => {
93
+ const result = resolveSmallModel({
94
+ auth: {
95
+ google: { type: 'api', key: '' },
96
+ anthropic: { type: 'api', key: 'sk-x' },
97
+ },
98
+ catalog,
99
+ configSmallModel: null,
100
+ });
101
+ expect(result).toEqual({ providerID: 'anthropic', modelID: 'claude-haiku-4-5', source: 'family-scan' });
102
+ });
103
+
104
+ it('falls back to Copilot utility models when only Copilot is logged in', () => {
105
+ const result = resolveSmallModel({
106
+ auth: { 'github-copilot': { type: 'oauth', access: 't', refresh: 't', expires: 0 } },
107
+ catalog,
108
+ configSmallModel: null,
109
+ });
110
+ expect(result?.providerID).toBe('github-copilot');
111
+ expect(result?.source).toBe('copilot-utility');
112
+ });
113
+
114
+ it('returns null when nothing is authenticated', () => {
115
+ expect(resolveSmallModel({ auth: {}, catalog, configSmallModel: null })).toBeNull();
116
+ });
117
+
118
+ it('prefers the session provider over other authenticated providers', () => {
119
+ const result = resolveSmallModel({
120
+ auth: {
121
+ google: { type: 'api', key: 'g-key' },
122
+ anthropic: { type: 'api', key: 'sk-x' },
123
+ },
124
+ catalog,
125
+ configSmallModel: null,
126
+ preferredProviderID: 'anthropic',
127
+ });
128
+ expect(result).toEqual({ providerID: 'anthropic', modelID: 'claude-haiku-4-5', source: 'family-scan' });
129
+ });
130
+
131
+ it('ignores a preferred provider without a usable login', () => {
132
+ const result = resolveSmallModel({
133
+ auth: { google: { type: 'api', key: 'g-key' } },
134
+ catalog,
135
+ configSmallModel: null,
136
+ preferredProviderID: 'anthropic',
137
+ });
138
+ expect(result).toEqual({ providerID: 'google', modelID: 'gemini-2.5-flash', source: 'family-scan' });
139
+ });
140
+
141
+ it('never uses a session provider without a login (opencode free models)', () => {
142
+ // Vanilla setups default the picker to opencode/big-pickle with no
143
+ // opencode token — those free models only work through OpenCode itself
144
+ // and must never be called directly, so the session context is ignored.
145
+ const result = resolveSmallModel({
146
+ auth: { openai: { type: 'oauth', access: 'a', refresh: 'r', expires: Date.now() + 60_000 } },
147
+ catalog,
148
+ configSmallModel: null,
149
+ preferredProviderID: 'opencode',
150
+ preferredModelID: 'big-pickle',
151
+ });
152
+ expect(result).toEqual({ providerID: 'openai', modelID: 'gpt-5.4-mini', source: 'codex-small' });
153
+ });
154
+
155
+ it('resolves nothing on a vanilla setup with no logins at all', () => {
156
+ const result = resolveSmallModel({
157
+ auth: {},
158
+ catalog,
159
+ configSmallModel: null,
160
+ preferredProviderID: 'opencode',
161
+ preferredModelID: 'big-pickle',
162
+ });
163
+ expect(result).toBeNull();
164
+ });
165
+
166
+ it('falls back to the session model instead of scanning other providers', () => {
167
+ const result = resolveSmallModel({
168
+ auth: {
169
+ 'opencode-go': { type: 'api', key: 'oc-key' },
170
+ openai: { type: 'oauth', access: 'a', refresh: 'r', expires: Date.now() + 60_000 },
171
+ },
172
+ catalog: {
173
+ 'opencode-go': {
174
+ id: 'opencode-go',
175
+ models: {
176
+ 'deepseek-v4-flash': { id: 'deepseek-v4-flash', family: 'deepseek-flash', release_date: '2026-01-01' },
177
+ },
178
+ },
179
+ },
180
+ configSmallModel: null,
181
+ preferredProviderID: 'opencode-go',
182
+ preferredModelID: 'deepseek-v4-flash',
183
+ });
184
+ expect(result).toEqual({ providerID: 'opencode-go', modelID: 'deepseek-v4-flash', source: 'session-model' });
185
+ });
186
+
187
+ it('falls back to the session model itself when nothing resolves', () => {
188
+ const result = resolveSmallModel({
189
+ auth: { mistral: { type: 'api', key: 'm-key' } },
190
+ catalog,
191
+ configSmallModel: null,
192
+ preferredProviderID: 'mistral',
193
+ preferredModelID: 'mistral-large-latest',
194
+ });
195
+ expect(result).toEqual({ providerID: 'mistral', modelID: 'mistral-large-latest', source: 'session-model' });
196
+ });
197
+ });
@@ -0,0 +1,44 @@
1
+ export function registerSmallModelRoutes(app, { getSmallModelService }) {
2
+ app.get('/api/small-model', async (req, res) => {
3
+ try {
4
+ const { describeSmallModel, listAuthenticatedProviders } = await getSmallModelService();
5
+ const resolved = await describeSmallModel({
6
+ directory: typeof req.query.directory === 'string' ? req.query.directory : undefined,
7
+ preferredProviderID: typeof req.query.providerID === 'string' ? req.query.providerID : undefined,
8
+ preferredModelID: typeof req.query.modelID === 'string' ? req.query.modelID : undefined,
9
+ });
10
+ res.json({
11
+ available: Boolean(resolved),
12
+ model: resolved,
13
+ authenticatedProviders: listAuthenticatedProviders(),
14
+ });
15
+ } catch (error) {
16
+ console.error('Failed to resolve small model:', error);
17
+ res.status(500).json({ error: error.message || 'Failed to resolve small model' });
18
+ }
19
+ });
20
+
21
+ app.post('/api/small-model/generate', async (req, res) => {
22
+ try {
23
+ const { generateSmallModelText } = await getSmallModelService();
24
+ const { prompt, system, maxOutputTokens, model, directory, preferredProviderID, preferredModelID, restrictToPreferredProvider } = req.body || {};
25
+ const result = await generateSmallModelText({
26
+ prompt,
27
+ system,
28
+ maxOutputTokens,
29
+ model,
30
+ directory,
31
+ preferredProviderID,
32
+ preferredModelID,
33
+ restrictToPreferredProvider: restrictToPreferredProvider === true,
34
+ });
35
+ res.json(result);
36
+ } catch (error) {
37
+ const statusCode = Number(error?.statusCode) || 500;
38
+ if (statusCode >= 500) {
39
+ console.error('Small model generation failed:', error);
40
+ }
41
+ res.status(statusCode).json({ error: error.message || 'Small model generation failed' });
42
+ }
43
+ });
44
+ }
@@ -3,9 +3,15 @@
3
3
  ## Purpose
4
4
  This module owns OpenChamber UI authentication for browser access, including password session auth, WebAuthn passkeys, and trusted-device session handling.
5
5
 
6
+ Trusted-device access has one durable credential model: a remote client bearer token stored by `packages/web/server/lib/client-auth/remote-clients.js`. Password, passkey, and Pairing v2 are issuance methods for that credential, not separate credential systems. Issued client tokens are returned once, stored server-side only as hashes, and are later authenticated via `Authorization: Bearer oc_client_...`.
7
+
8
+ Pairing v2 is implemented by `packages/web/server/lib/client-auth/pairing.js`. It stores short-lived one-time pairing sessions with hashed secrets, exposes create/cancel/redeem routes under `/api/client-auth/pairing/*`, and redeems a valid pairing secret into the same remote client token used by password/passkey trusted-device flows.
9
+
6
10
  ## Entrypoints and structure
7
11
  - `packages/web/server/lib/ui-auth/ui-auth.js`: UI auth controller runtime, cookie/session issuance, rate limiting, and auth route handlers.
8
12
  - `packages/web/server/lib/ui-auth/ui-passkeys.js`: passkey store and WebAuthn registration/authentication verification helpers.
13
+ - `packages/web/server/lib/client-auth/remote-clients.js`: trusted-device client token storage, bearer authentication, last-used tracking, and revocation.
14
+ - `packages/web/server/lib/client-auth/pairing.js`: short-lived Pairing v2 sessions and one-time secret redemption into trusted-device client tokens.
9
15
 
10
16
  ## Public exports (ui-auth.js)
11
17
  - `createUiAuth({ password, cookieName, sessionTtlMs, readSettingsFromDiskMigrated })`: creates UI auth controller with methods:
@@ -829,6 +829,11 @@ export const createUiAuth = ({
829
829
  expiresAt: new Date(Date.now() + ttlMs).toISOString(),
830
830
  clientKind: req.body?.clientKind,
831
831
  dedupeKey: req.body?.dedupeKey,
832
+ authMethod: 'password',
833
+ deviceName: req.body?.deviceName,
834
+ devicePlatform: req.body?.devicePlatform,
835
+ deviceModel: req.body?.deviceModel,
836
+ appVersion: req.body?.appVersion,
832
837
  });
833
838
  }
834
839
  res.setHeader('Cache-Control', 'no-store');
@@ -892,6 +897,11 @@ export const createUiAuth = ({
892
897
  expiresAt: new Date(Date.now() + ttlMs).toISOString(),
893
898
  clientKind: req.body?.clientKind,
894
899
  dedupeKey: req.body?.dedupeKey,
900
+ authMethod: 'passkey',
901
+ deviceName: req.body?.deviceName,
902
+ devicePlatform: req.body?.devicePlatform,
903
+ deviceModel: req.body?.deviceModel,
904
+ appVersion: req.body?.appVersion,
895
905
  });
896
906
  }
897
907
  res.json({
@@ -536,4 +536,42 @@ describe('OpenCode proxy SSE forwarding', () => {
536
536
  expect(data.body).toEqual(payload);
537
537
  expect(Number(data.contentLength)).toBeGreaterThan(0);
538
538
  });
539
+
540
+ it('uses the long proxy timeout budget for slow upstream responses', async () => {
541
+ const upstream = express();
542
+ upstream.get('/slow', (_req, _res) => {
543
+ // Leave the response open so the proxy timeout path is exercised.
544
+ });
545
+ upstreamServer = await listen(upstream);
546
+ const upstreamPort = upstreamServer.address().port;
547
+ const externalBaseUrl = `http://127.0.0.1:${upstreamPort}`;
548
+
549
+ const app = express();
550
+ registerOpenCodeProxy(app, {
551
+ fs: {},
552
+ os: {},
553
+ path,
554
+ OPEN_CODE_READY_GRACE_MS: 0,
555
+ LONG_REQUEST_TIMEOUT_MS: 50,
556
+ getRuntime: () => ({
557
+ openCodePort: upstreamPort,
558
+ openCodeBaseUrl: externalBaseUrl,
559
+ isOpenCodeReady: true,
560
+ openCodeNotReadySince: 0,
561
+ isRestartingOpenCode: false,
562
+ }),
563
+ getOpenCodeAuthHeaders: () => ({}),
564
+ buildOpenCodeUrl: (requestPath) => `${externalBaseUrl}${requestPath}`,
565
+ ensureOpenCodeApiPrefix: () => {},
566
+ });
567
+ proxyServer = await listen(app);
568
+ const proxyPort = proxyServer.address().port;
569
+
570
+ const response = await fetch(`http://127.0.0.1:${proxyPort}/api/slow`, {
571
+ signal: AbortSignal.timeout(2000),
572
+ });
573
+
574
+ expect(response.status).toBe(504);
575
+ await expect(response.json()).resolves.toMatchObject({ error: 'OpenCode upstream timed out' });
576
+ });
539
577
  });
@@ -1,7 +0,0 @@
1
- import{ce as $e,cf as Pe,cg as re,ch as it,R as C,b as B,ci as ct,cj as lt,ck as dt,j as X}from"./vendor-.bun-C6iL44L9.js";import{eU as ut,eV as mt,eW as ft,eX as pt,eY as Oe,eZ as ht,e_ as bt,w as ce,cY as gt,cZ as wt,d as De,e as Be,e$ as He,p as qe,dC as yt,y as ye,c as kt,f0 as Et,f1 as At,f2 as vt,aD as Ct,f3 as ke,f4 as St,f5 as xt,f6 as Nt,f7 as Mt,ca as Lt}from"./useAppFontEffects-DTO332li.js";import{y as be,u as ge,l as Tt,m as Rt,h as _t}from"./index-5eUDDB6w.js";const G=t=>t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Ft=t=>/^\[[^\]]+\]:\s+\S+/m.test(t)||/^\[\^[^\]]+\]:\s+/m.test(t),It=t=>{const e=t.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!e)return!1;const n=e[1];if(!n)return!1;const r=n[0],s=n.length,o=t.trimEnd().split(`
2
- `).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${r}{${s},}[\\t ]*$`).test(o)},Z=t=>{try{return it(t,{linkMode:"text-only"})}catch{return t}},$t=(t,e)=>{if(!e)return[{raw:t,src:t,mode:"full",highlight:!0}];if(Ft(t))return[{raw:t,src:Z(t),mode:"live",highlight:!0}];let n;try{n=$e.lexer(t)}catch{return[{raw:t,src:Z(t),mode:"live",highlight:!0}]}let r=-1;for(let o=n.length-1;o>=0;o-=1)if(n[o]?.type!=="space"){r=o;break}if(r<0)return[{raw:t,src:Z(t),mode:"live",highlight:!0}];const s=[];for(let o=0;o<n.length;o+=1){const i=n[o];if(!i||i.type==="space")continue;const a=i.raw??"",c=o===r,l=i.type==="code"&&It(a);s.push({raw:a,src:l?a:Z(a),mode:c?"live":"full",highlight:!l})}return s.length===0?[{raw:t,src:Z(t),mode:"live",highlight:!0}]:s},We=(t,e,n)=>{try{return Pe.renderToString(t,{displayMode:n,throwOnError:!1})}catch{return e}},Pt={name:"inlineMath",level:"inline",start(t){const e=t.indexOf("\\(");return e<0?void 0:e},tokenizer(t){const e=/^\\\(([\s\S]+?)\\\)/.exec(t);if(e)return{type:"inlineMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return We(e.text,e.raw,!1)}},Ot={name:"blockMath",level:"block",start(t){const e=t.indexOf("\\[");return e<0?void 0:e},tokenizer(t){const e=/^\\\[([\s\S]+?)\\\]/.exec(t);if(e)return{type:"blockMath",raw:e[0],text:e[1]??""}},renderer(t){const e=t;return We(e.text,e.raw,!0)}},je=$e.use({gfm:!0,breaks:!1,extensions:[Pt,Ot],renderer:{link({href:t,title:e,text:n}){const r=t??"",s=ut(r);if(s)return`<a href="${G(ft(s))}" data-openchamber-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${n}</a>`;const o=mt(r);if(o)return`<a href="${G(r)}" data-skill-name="${G(o)}" class="text-primary hover:underline">${n}</a>`;const i=e?` title="${G(e)}"`:"";return`<a href="${G(r)}"${i} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}}}),Dt=t=>t.replace(/\$\$([\s\S]*?)\$\$/g,(e,n)=>{try{return Pe.renderToString(n,{displayMode:!0,throwOnError:!1})}catch{return`$$${n}$$`}}),ze=t=>{if(t.indexOf("$")===-1)return t;const e=/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi;return t.split(e).map((n,r)=>r%2===1?n:Dt(n)).join("")},Bt=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,Ht=1200,qt=200,Wt=(t,e)=>{let n=1;for(let r=0;r<t.length;r+=1)if(t.charCodeAt(r)===10&&++n>e)return!0;return!1},jt=t=>t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&"),zt=async t=>{const e=[...t.matchAll(Bt)];if(e.length===0)return t;const n=be()?qt:Ht;let r=t;for(const s of e){const[o,i,a]=s,c=(i||"text").toLowerCase();if(c==="mermaid")continue;const l=jt(a??"");if(Wt(l,n)){r=r.replace(o,()=>o.replace("<pre",`<pre data-md-lang="${c}"`));continue}const d=await pt(l,c);if(d){const m=d.replace(/^<pre/,`<pre data-md-lang="${c}"`);r=r.replace(o,()=>m)}}return r},Kt={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:["svg","path","g","rect","line","polygon","polyline","circle","ellipse","text","tspan","defs","marker"],ADD_ATTR:["d","viewBox","preserveAspectRatio","xmlns","target","fill","stroke","stroke-width","transform","points","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","style"],FORBID_TAGS:["script"],FORBID_CONTENTS:["script"]};let Ee=!1;const Vt=()=>{Ee||typeof window>"u"||!re.isSupported||(Ee=!0,re.addHook("afterSanitizeAttributes",t=>{t instanceof HTMLAnchorElement&&t.target==="_blank"&&t.setAttribute("rel","noopener noreferrer")}))},Ke=t=>re.isSupported?(Vt(),re.sanitize(t,Kt)):"",Ut=240,K=new Map,Gt=t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0).toString(36)},Ae=(t,e)=>{if(K.delete(t),K.set(t,e),K.size<=Ut)return;const n=K.keys().next().value;n&&K.delete(n)},Zt=async t=>{const e=await Promise.resolve(je.parse(t.src)),n=ze(e),r=t.highlight?await zt(n):n;return Ke(r)},Xt=t=>{if(!t)return"";const e=je.parse(t),n=ze(e);return Ke(n)},Yt=async(t,e,n)=>{if(!t)return[];const r=$t(t,e);return Promise.all(r.map(async(s,o)=>{const i=Gt(s.raw),a=`${i}:${s.mode}:${s.highlight?1:0}`,c=`${n}:${o}:${s.mode}`,l=K.get(c);if(l&&l.hash===i)return Ae(c,l),{id:a,html:l.html};const d=await Zt(s);return Ae(c,{hash:i,html:d}),{id:a,html:d}}))},le=t=>`<svg class="remixicon size-3.5" viewBox="0 0 24 24" aria-hidden="true"><use href="#oc-${t}"></use></svg>`,oe={copy:le("file-copy"),check:le("check"),download:le("download")},Ve="p-1 rounded hover:bg-interactive-hover/60 text-muted-foreground hover:text-foreground transition-colors",Y=(t,e)=>{t.innerHTML=e},U=(t,e,n)=>{const r=document.createElement("button");return r.type="button",r.className=Ve,r.setAttribute("data-md-action",n),r.setAttribute("title",e),r.setAttribute("aria-label",e),Y(r,oe[t]),r},ve=(t,e,n,r)=>{Y(t,oe.check),t.setAttribute("title",e),window.setTimeout(()=>{Y(t,oe[n]),t.setAttribute("title",r)},2e3)},Jt=t=>{const e=t.querySelectorAll(":not(pre) > code");for(const n of Array.from(e))n.getAttribute("data-markdown")!=="inline-code"&&n.setAttribute("data-markdown","inline-code")},Qt=(t,e)=>{const n=t.querySelectorAll("pre");for(const r of Array.from(n)){if(r.querySelector("code.language-mermaid"))continue;const s=r.parentElement;if(!s||s.closest('[data-component="markdown-code"]'))continue;const o=r.querySelector("code")?.className.match(/language-([\w+#.-]+)/)?.[1],i=r.getAttribute("data-md-lang")??o??"text",a=document.createElement("div");a.setAttribute("data-component","markdown-code"),a.className="my-4 group overflow-hidden rounded-2xl border border-border/80 bg-[var(--surface-elevated)]";const c=document.createElement("div");c.className="flex items-center justify-between border-b border-border/70 px-3 py-1.5";const l=document.createElement("span");l.className="font-mono text-[13px] text-muted-foreground",l.textContent=i;const d=U("copy",e.copy,"copy-code");c.appendChild(l),c.appendChild(d);const m=document.createElement("div");m.className="px-3 py-2.5 overflow-x-auto",s.replaceChild(a,r),r.style.margin="0",r.style.background="transparent",m.appendChild(r),a.appendChild(c),a.appendChild(m)}},Ce=t=>{const e=[],n=[],r=t.querySelectorAll("thead th");for(const o of Array.from(r))e.push((o.textContent??"").trim());const s=t.querySelectorAll("tbody tr");for(const o of Array.from(s)){const i=Array.from(o.querySelectorAll("td")).map(a=>(a.textContent??"").trim());i.length>0&&n.push(i)}return{headers:e,rows:n}},en=t=>/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t,Se=({headers:t,rows:e})=>[t,...e].map(n=>n.map(en).join(",")).join(`
3
- `),tn=({headers:t,rows:e})=>[t,...e].map(n=>n.join(" ")).join(`
4
- `),xe=({headers:t,rows:e})=>{const n=`| ${t.join(" | ")} |`,r=`| ${t.map(()=>"---").join(" | ")} |`,s=e.map(o=>`| ${o.join(" | ")} |`).join(`
5
- `);return`${n}
6
- ${r}
7
- ${s}`},Ne=(t,e)=>{const n=document.createElement("div");n.className=`absolute top-full right-0 mt-1 hidden ${gt}`,n.style.backgroundColor="var(--surface-elevated)",n.style.color="var(--surface-elevated-foreground)",n.setAttribute("data-md-menu",t);for(const r of e){const s=document.createElement("button");s.type="button",s.className=`w-full text-left ${wt}`,s.setAttribute("data-md-action",`${t}-${r.key}`),s.textContent=r.label,n.appendChild(s)}return n},nn=(t,e)=>{const n=t.querySelectorAll("table");for(const r of Array.from(n)){if(r.closest('[data-markdown="table-wrapper"]'))continue;const o=document.createElement("div");o.className="group my-4 flex flex-col space-y-2",o.setAttribute("data-markdown","table-wrapper");const i=document.createElement("div");i.className="flex items-center justify-end gap-1";const a=document.createElement("div");a.className="relative",a.appendChild(U("copy",e.copyTable,"table-copy-toggle")),a.appendChild(Ne("table-copy",[{key:"csv",label:"CSV"},{key:"tsv",label:"TSV"},{key:"markdown",label:"Markdown"}]));const c=document.createElement("div");c.className="relative",c.appendChild(U("download",e.downloadTable,"table-download-toggle")),c.appendChild(Ne("table-download",[{key:"csv",label:"CSV"},{key:"markdown",label:"Markdown"}])),i.appendChild(a),i.appendChild(c);const l=document.createElement("div");l.className="overflow-x-auto rounded-lg border border-border/80 bg-[var(--surface-elevated)]";const d=r.parentElement;if(!d)continue;d.replaceChild(o,r),r.setAttribute("data-markdown","table"),r.classList.add("w-full","border-collapse","text-sm");for(const p of Array.from(r.querySelectorAll("tr")))p.classList.add("border-b","border-border/60");const m=r.querySelector("tbody tr:last-child");m?.classList.remove("border-b"),m?.classList.add("border-0");for(const p of Array.from(r.querySelectorAll("th")))p.classList.add("border-r","border-border/60","px-4","py-2.5","text-left","align-middle","font-semibold","text-foreground","last:border-r-0");for(const p of Array.from(r.querySelectorAll("td")))p.classList.add("border-r","border-border/60","px-4","py-2.5","align-middle","text-foreground/90","last:border-r-0");l.appendChild(r),o.appendChild(i),o.appendChild(l)}},rn=(t,e)=>{const n=t.querySelectorAll("pre > code.language-mermaid");for(const r of Array.from(n)){const s=r.parentElement;if(!s)continue;const o=(r.textContent??"").replace(/\s+$/,""),i=e.renderMermaid(o),a=document.createElement("div");a.setAttribute("data-markdown","mermaid-block"),a.className="group relative";const c=document.createElement("div");c.setAttribute("data-markdown","mermaid-scroll");const l=document.createElement("div");if(l.className="absolute top-1 right-2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",i.svg){const m=document.createElement("div");m.setAttribute("data-markdown","mermaid"),Y(m,i.svg),c.appendChild(m);const p=U("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",o);const g=U("download",e.labels.downloadDiagram,"mermaid-download");g.setAttribute("data-md-svg","1"),l.appendChild(p),l.appendChild(g)}else{const m=document.createElement("pre");m.setAttribute("data-markdown","mermaid-ascii"),m.textContent=i.ascii||o,c.appendChild(m);const p=U("copy",e.labels.copyDiagram,"mermaid-copy");p.setAttribute("data-md-source",i.ascii||o),l.appendChild(p)}a.appendChild(c),a.appendChild(l);const d=s.parentElement;d&&d.replaceChild(a,s)}},on=(t,e)=>{const n=t.querySelectorAll("a[href]");for(const r of Array.from(n)){if(r.getAttribute("data-md-link-decorated")==="true"||r.getAttribute("data-openchamber-file-link")==="true")continue;const s=r.getAttribute("href")??"";if(!Oe(s))continue;r.setAttribute("data-md-link-decorated","true");const o=ht(s);if(o){const i=document.createElement("span");i.className="mr-1 inline-flex size-[18px] items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)] align-middle";const a=document.createElement("img");a.src=o,a.alt="",a.setAttribute("aria-hidden","true"),a.loading="lazy",a.decoding="async",a.className="size-3.5 rounded-sm",a.addEventListener("error",()=>i.remove(),{once:!0}),i.appendChild(a),r.parentNode?.insertBefore(i,r)}if(e.onPreviewLoopback&&bt(s)){const i=document.createElement("button");i.type="button",i.className=`ml-1 align-middle ${Ve}`,i.setAttribute("data-md-action","preview-loopback"),i.setAttribute("data-md-url",s),i.setAttribute("title",e.labels.previewTitle),i.setAttribute("aria-label",e.labels.previewLabel),Y(i,oe.download),r.parentNode?.insertBefore(i,r.nextSibling)}}},Me=(t,e)=>{Jt(t),rn(t,e),Qt(t,e.labels),nn(t,e.labels),on(t,e)},Le=(t,e,n)=>{const r=new Blob([e],{type:n}),s=URL.createObjectURL(r),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)},te=t=>{for(const e of Array.from(t.querySelectorAll("[data-md-menu]")))e.classList.add("hidden")},an=(t,e)=>{const n=r=>{const s=r.target;if(!(s instanceof Element))return;const o=s.closest("[data-md-action]");if(!o){te(t);return}const i=o.getAttribute("data-md-action")??"";if(i==="copy-code"){const c=o.closest('[data-component="markdown-code"]')?.querySelector("code")?.textContent??"";c&&ce(c).then(()=>ve(o,e.labels.copied,"copy",e.labels.copy));return}if(i==="table-copy-toggle"||i==="table-download-toggle"){r.preventDefault();const a=o.parentElement?.querySelector("[data-md-menu]")??null,c=a?.classList.contains("hidden")??!1;te(t),a&&c&&a.classList.remove("hidden");return}if(i.startsWith("table-copy-")){const a=i.replace("table-copy-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ce(c),d=a==="csv"?Se(l):a==="tsv"?tn(l):xe(l);ce(d)}te(t);return}if(i.startsWith("table-download-")){const a=i.replace("table-download-",""),c=o.closest('[data-markdown="table-wrapper"]')?.querySelector("table");if(c instanceof HTMLTableElement){const l=Ce(c),d=a==="csv"?Se(l):xe(l);Le(a==="csv"?"table.csv":"table.md",d,a==="csv"?"text/csv":"text/markdown")}te(t);return}if(i==="mermaid-copy"){const a=o.getAttribute("data-md-source")??"";a&&ce(a).then(()=>ve(o,e.labels.copied,"copy",e.labels.copyDiagram));return}if(i==="mermaid-download"){const c=o.closest('[data-markdown="mermaid-block"]')?.querySelector('[data-markdown="mermaid"]')?.innerHTML??"";c&&Le("diagram.svg",c,"image/svg+xml;charset=utf-8");return}if(i==="preview-loopback"){r.preventDefault();const a=o.getAttribute("data-md-url")??"";a&&e.onPreviewLoopback?.(a);return}};return t.addEventListener("click",n),()=>t.removeEventListener("click",n)},Ue=()=>{const t=B.c(4),e=yt();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=ye(!1),t[0]=n):n=t[0];const r=n;let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=ye(!0),t[1]=s):s=t[1];const o=s;let i;return t[2]!==e?.currentTheme?(i=e?.currentTheme??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?o:r),t[2]=e?.currentTheme,t[3]=i):i=t[3],i},Ge=t=>{const e=B.c(4),{containerRef:n,enabled:r}=t;let s,o;e[0]!==n||e[1]!==r?(s=()=>{if(r===!1)return;const i=n.current;if(!i)return;const a=In;return i.addEventListener("click",a),()=>{i.removeEventListener("click",a)}},o=[n,r],e[0]=n,e[1]=r,e[2]=s,e[3]=o):(s=e[2],o=e[3]),C.useEffect(s,o)},Ze=t=>{if(!t.includes("mermaid"))return[];const e=[],n=/(?:^|\r?\n)(`{3,}|~{3,})mermaid[^\n\r]*\r?\n([\s\S]*?)\r?\n\1(?=\r?\n|$)/gi;let r=n.exec(t);for(;r;){const s=(r[2]??"").replace(/\s+$/,"");e.push(s),r=n.exec(t)}return e},sn=t=>{const e=t.match(/^(?:\uFEFF)?(---|\+\+\+)[^\S\r\n]*\r?\n[\s\S]*?\r?\n\1[^\S\r\n]*(?:\r?\n|$)/);return e?t.slice(e[0].length):t},de='[data-markdown="mermaid-block"]',Te='[data-openchamber-file-link="true"]',Xe="data-openchamber-block-path-token",Ye=`[${Xe}]`,V="data-openchamber-block-paths-scanned",ue=/(?:[A-Za-z]:[\\/])?[\w.\-/@+]*[\w\-/@+]\.[A-Za-z0-9]{1,8}(?::\d+){0,2}/g,cn=2e5,ln=4,dn=1e3,un=200,mn=80,fn=40,Re=160,O=new Map;let ne=0;const _e=[],pn=()=>be()?un:dn,hn=()=>be()?fn:mn,Je=new Set(["dockerfile","makefile","readme","license",".env",".gitignore",".npmrc"]),Fe=Array.from(Je).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),we=t=>Mt(t),bn=t=>Nt(t),gn=(t,e)=>Lt(t,e),ae=t=>{let e=(t||"").trim();return e?((e.startsWith("`")&&e.endsWith("`")||e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1).trim()),e=e.replace(/[.,;!?]+$/g,""),e.endsWith(")")&&!e.includes("(")&&(e=e.slice(0,-1)),e.endsWith("]")&&!e.includes("[")&&(e=e.slice(0,-1)),e):""},me=t=>{let e=ae(t);if(!e)return"";const n=e.indexOf(";");n>=0&&(e=e.slice(0,n)),e=e.replace(/#.*$/,"");const r=e.match(/^(.*\.[A-Za-z0-9_-]{1,16}):.*$/);r&&(e=r[1]??e);const s=Fe.length>0?e.match(new RegExp(`^(.*(?:/|^)(${Fe})):.*$`,"i")):null;return s&&(e=s[1]??e),ae(e)},Qe=t=>{const e=ae(t);if(!e)return null;const n=e.indexOf(";"),r=n>=0?ae(e.slice(0,n)):e;if(!r)return null;const s=r.match(/^(.*)#L(\d+)(?:C(\d+))?$/i);if(s){const a=me(s[1]??""),c=Number.parseInt(s[2]??"",10),l=s[3]?Number.parseInt(s[3],10):void 0;return!a||!Number.isFinite(c)?null:{path:a,line:c,column:Number.isFinite(l??Number.NaN)?l:void 0}}const o=r.match(/^(.*):(\d+)(?::(\d+))?$/);if(o){const a=me(o[1]??""),c=Number.parseInt(o[2]??"",10),l=o[3]?Number.parseInt(o[3],10):void 0;return!a||!Number.isFinite(c)?null:{path:a,line:c,column:Number.isFinite(l??Number.NaN)?l:void 0}}const i=me(r);return i?{path:i}:null},wn=t=>{const e=t.split("/").filter(Boolean).pop()??"";return!e||e.endsWith(".")?!1:/\.[A-Za-z0-9_-]{1,16}$/.test(e)},et=t=>{if(!t||t.startsWith("--")||t.includes("://")||/[<>]/.test(t)||/\s{2,}/.test(t))return!1;const e=we(t),n=e.split("/").filter(Boolean).pop()??e;if(!n||n==="."||n==="..")return!1;const r=n.toLowerCase();return Je.has(r)||r.startsWith(".")&&r.length>1?!0:wn(e)},tt=t=>{const e=Qe(t);return e?et(e.path):!1},Ie=(t,e)=>{let n=0;for(const s of t){const o=n+s.data.length;if(e<=o)return{node:s,offset:Math.max(0,e-n)};n=o}const r=t.at(-1);return r?{node:r,offset:r.data.length}:null},yn=t=>{const e=t.querySelectorAll(Ye);for(const r of Array.from(e))r.replaceWith(t.ownerDocument.createTextNode(r.textContent??""));const n=t.querySelectorAll(`code[${V}]`);for(const r of Array.from(n))r.removeAttribute(V),r.normalize()},fe=t=>{if(t.tagName.toLowerCase()==="a"){const e=t.getAttribute("href")?.trim();if(e&&tt(e))return e}return(t.textContent||"").trim()},kn=t=>{const e=t.querySelectorAll("pre code");if(e.length===0)return;const n=t.ownerDocument;if(n)for(const r of Array.from(e)){if(r.getAttribute(V)==="true")continue;if((r.textContent??"").length>cn){r.setAttribute(V,"true");continue}const s=n.createTreeWalker(r,NodeFilter.SHOW_TEXT),o=[];let i=s.nextNode();for(;i;)o.push(i),i=s.nextNode();const a=r.textContent??"";if(!a.includes(".")){r.setAttribute(V,"true");continue}ue.lastIndex=0;const c=[];let l=ue.exec(a);for(;l;){const d=l[0];d&&tt(d)&&c.push({start:l.index,end:l.index+d.length,raw:d}),l=ue.exec(a)}for(const{start:d,end:m,raw:p}of c.reverse()){const g=Ie(o,d),E=Ie(o,m);if(!g||!E)continue;const k=n.createRange();k.setStart(g.node,g.offset),k.setEnd(E.node,E.offset);const w=n.createElement("span");w.setAttribute(Xe,"true"),w.textContent=p,k.deleteContents(),k.insertNode(w)}r.setAttribute(V,"true")}},pe=(t,e)=>{const n=Qe(t);if(!n||!et(n.path))return null;const r=bn(n.path)?we(n.path):gn(e,n.path);return r?{...n,resolvedPath:r}:null},En=t=>{const e=we(t);if(!e)return Promise.resolve(!1);const n=O.get(e);if(n)return O.delete(e),O.set(e,n),n;const r=new Promise(o=>{const i=()=>{ne+=1,_t(`/api/fs/stat?path=${encodeURIComponent(e)}&optional=true`,{method:"GET",cache:"no-store"}).then(async a=>{if(!a.ok){o(!1);return}const c=await a.json().catch(()=>null);o(c?.exists!==!1)}).catch(()=>o(!1)).finally(()=>{ne=Math.max(0,ne-1),_e.shift()?.()})};if(ne<ln){i();return}_e.push(i)}),s=pn();for(;O.size>=s;){const o=O.keys().next().value;if(typeof o!="string")break;O.delete(o)}return O.set(e,r),r},An=(t,e)=>t||xt(t,e),nt=t=>{const e=B.c(7),{containerRef:n,effectiveDirectory:r,editor:s,preferRuntimeEditor:o,enabled:i}=t,a=C.useRef(null);let c,l;e[0]!==n||e[1]!==s||e[2]!==r||e[3]!==i||e[4]!==o?(c=()=>{const d=n.current;if(!d)return;let m=!1;const p=hn(),g=i&&!At(),E=$n,k=()=>{const f=d.querySelectorAll(Te);for(const h of Array.from(f))E(h);yn(d)};if(!g){k();return}const w=f=>{const h=f;if(a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),typeof window>"u"){b();return}a.current=window.setTimeout(()=>{a.current=null,window.requestAnimationFrame(()=>{m||b()})},h)},b=()=>{g&&kn(d);const f=d.querySelectorAll(`[data-markdown="inline-code"], a, ${Ye}`);let h=0;for(const u of Array.from(f)){const S=fe(u),N=pe(S,r);if(E(u),!N||h>=p)continue;h=h+1,(Tt()&&Rt()&&!ke(N.resolvedPath,r)?Promise.resolve(!0):En(N.resolvedPath)).then(_=>{if(m||!_||!d.contains(u))return;const F=fe(u),M=pe(F,r);!M||M.resolvedPath!==N.resolvedPath||(u.setAttribute("data-openchamber-file-link","true"),u.setAttribute("data-openchamber-file-ref",F),u.setAttribute("data-openchamber-file-path",M.resolvedPath),u.setAttribute("title","Open file"),u.tagName.toLowerCase()!=="a"&&(u.setAttribute("role","button"),u.setAttribute("tabindex","0")))})}},A=async f=>{const h=f.getAttribute("data-openchamber-file-ref")||fe(f),u=pe(h,r);if(!u)return;const S=An(r,u.resolvedPath);if(o&&s){s.openFile(u.resolvedPath,Number.isFinite(u.line??Number.NaN)?Math.max(1,Math.trunc(u.line)):void 0,Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):void 0);return}ke(u.resolvedPath,r)||await St(u.resolvedPath,r);const N=ge.getState();Number.isFinite(u.line??Number.NaN)?N.openContextFileAtLine(S,u.resolvedPath,Math.max(1,Math.trunc(u.line)),Number.isFinite(u.column??Number.NaN)?Math.max(1,Math.trunc(u.column)):1):N.openContextFile(S,u.resolvedPath)},y=f=>{const h=f.target;if(!(h instanceof Element))return;const u=h.closest(Te);u instanceof HTMLElement&&(f.preventDefault(),f.stopPropagation(),A(u))},v=f=>{if(f.key!=="Enter"&&f.key!==" ")return;const h=f.target;!(h instanceof HTMLElement)||h.getAttribute("data-openchamber-file-link")!=="true"||(f.preventDefault(),f.stopPropagation(),A(h))};w(Re);const x=new MutationObserver(()=>{w(Re)});return x.observe(d,{childList:!0,subtree:!0}),d.addEventListener("click",y),d.addEventListener("keydown",v),()=>{m=!0,a.current!==null&&typeof window<"u"&&window.clearTimeout(a.current),a.current=null,x.disconnect(),d.removeEventListener("click",y),d.removeEventListener("keydown",v)}},l=[n,s,r,o,i],e[0]=n,e[1]=s,e[2]=r,e[3]=i,e[4]=o,e[5]=c,e[6]=l):(c=e[5],l=e[6]),C.useEffect(c,l)},rt=t=>{const e=B.c(6),{containerRef:n,mermaidBlocks:r,onShowPopup:s,allowWheelZoom:o}=t;let i,a;e[0]!==o||e[1]!==n||e[2]!==r||e[3]!==s?(i=()=>{const c=n.current;if(!c)return;const l=m=>{if(!s)return;const p=m.target;if(!(p instanceof Element)||p.closest('button, a, [role="button"]'))return;const g=p.closest(de);if(!g)return;const k=Array.from(c.querySelectorAll(de)).indexOf(g);if(k<0)return;const w=r[k];if(!w||w.trim().length===0)return;const b=`Diagram ${k+1}`;s({open:!0,title:b,content:"",metadata:{tool:"mermaid-preview",filename:b},mermaid:{url:`data:text/plain;charset=utf-8,${encodeURIComponent(w)}`,source:w,filename:b}})},d=m=>{if(o)return;const p=m.target;!(p instanceof Element)||!p.closest(de)||m.stopPropagation()};return c.addEventListener("click",l),c.addEventListener("wheel",d,{capture:!0,passive:!0}),()=>{c.removeEventListener("click",l),c.removeEventListener("wheel",d,!0)}},a=[o,n,r,s],e[0]=o,e[1]=n,e[2]=r,e[3]=s,e[4]=i,e[5]=a):(i=e[4],a=e[5]),C.useEffect(i,a)},he=64,vn=24,Cn=he/vn,Sn=/[\s.,!?;:)\]]/,xn=t=>{const e=t<=12?2:t<=48?4:t<=96?8:Math.min(24,Math.ceil(t/8));return Math.max(1,Math.round(e*Cn))},Nn=(t,e)=>{const n=Math.min(t.length,e+xn(t.length-e));for(let r=n;r<Math.min(t.length,n+8);r+=1)if(Sn.test(t[r]??""))return r+1;return n},Mn=(t,e)=>{const[n,r]=C.useState(()=>e?0:t.length),s=C.useRef(n);return s.current=n,C.useEffect(()=>{if(!e||typeof window>"u"){r(t.length);return}s.current>t.length&&r(t.length);let o=null;const i=()=>{const a=Math.min(s.current,t.length);if(a>=t.length){o=null;return}r(Nn(t,a)),o=window.setTimeout(i,he)};return s.current<t.length&&(o=window.setTimeout(i,he)),()=>{o!==null&&window.clearTimeout(o)}},[t,e]),e?t.slice(0,Math.min(n,t.length)):t},D=new Map,Ln=100,Tn=(t,e)=>{const n=D.get(t);if(n)return D.delete(t),D.set(t,n),n;const r=e();if(D.set(t,r),D.size>Ln){const s=D.keys().next().value;s&&D.delete(s)}return r},Rn=t=>({bg:t.colors.surface.elevated,fg:t.colors.surface.foreground,line:t.colors.interactive.border,accent:t.colors.primary.base,muted:t.colors.surface.mutedForeground,surface:t.colors.surface.muted,border:t.colors.interactive.border,transparent:!0,font:"system-ui, sans-serif"}),ot=(t,e)=>{const{t:n}=kt(),r=C.useMemo(()=>({copy:"Copy code",copied:"Copied",copyTable:n("markdownRenderer.table.actions.copyTitle"),downloadTable:n("markdownRenderer.table.actions.downloadTitle"),copyDiagram:n("markdownRenderer.mermaid.actions.copySourceTitle"),downloadDiagram:n("markdownRenderer.mermaid.actions.downloadSvgTitle"),previewLabel:n("terminalView.preview.open"),previewTitle:n("terminalView.preview.openTitle")}),[n]);return C.useMemo(()=>{const s=Rn(t),o=ge.getState().mermaidRenderingMode,i=t.metadata?.id??"theme";return{labels:r,renderMermaid:c=>Tn(`${i}:${o}:${c}`,()=>{try{return o==="ascii"?{ascii:ct(c)}:{svg:lt(c,s)}}catch{return{}}}),onPreviewLoopback:e}},[t,r,e])},at=t=>{const e=B.c(21),{containerRef:n,text:r,streaming:s,cacheKey:o,syntaxVars:i,ctx:a}=t;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0],C.useEffect(Pn,c);let l,d;e[1]!==n||e[2]!==a||e[3]!==r?(l=()=>{const b=n.current,A=b?.querySelector("[data-markdown-content]")??b;if(A&&r&&A.childNodes.length===0){const y=document.createElement("div");y.setAttribute("data-md-block",""),y.style.display="contents",y.innerHTML=Xt(r),Me(y,a),A.appendChild(y)}},d=[n,r,a],e[1]=n,e[2]=a,e[3]=r,e[4]=l,e[5]=d):(l=e[4],d=e[5]),C.useLayoutEffect(l,d);let m,p;e[6]!==o||e[7]!==n||e[8]!==a||e[9]!==s||e[10]!==r?(m=()=>{const b=n.current;if(!b)return;const A=b.querySelector("[data-markdown-content]")??b;let y=!0;return Yt(r,s,o).then(v=>{if(!y)return;const x=Array.from(A.children);v.forEach((f,h)=>{let u=x[h];if(u||(u=document.createElement("div"),u.setAttribute("data-md-block",""),u.style.display="contents",A.appendChild(u)),u.getAttribute("data-md-id")===f.id)return;const S=document.createElement("div");S.innerHTML=f.html,Me(S,a),dt(u,S,{childrenOnly:!0,onBeforeElUpdated:On}),u.setAttribute("data-md-id",f.id)});for(let f=x.length-1;f>=v.length;f=f-1,f)x[f]?.remove()}),()=>{y=!1}},p=[n,r,s,o,a],e[6]=o,e[7]=n,e[8]=a,e[9]=s,e[10]=r,e[11]=m,e[12]=p):(m=e[11],p=e[12]),C.useEffect(m,p);let g,E;e[13]!==n||e[14]!==a?(g=()=>{const b=n.current;if(b)return an(b,a)},E=[n,a],e[13]=n,e[14]=a,e[15]=g,e[16]=E):(g=e[15],E=e[16]),C.useEffect(g,E);let k,w;e[17]!==n||e[18]!==i?(k=()=>{const b=n.current,A=b?.querySelector("[data-markdown-content]")??b;if(A)for(const[y,v]of Object.entries(i))A.style.setProperty(y,v)},w=[n,i],e[17]=n,e[18]=i,e[19]=k,e[20]=w):(k=e[19],w=e[20]),C.useEffect(k,w)},st=t=>t==="tool"?"markdown-content markdown-tool":t==="reasoning"?"markdown-content markdown-reasoning":"markdown-content leading-relaxed",_n=t=>{const e=B.c(35),{content:n,part:r,messageId:s,isAnimated:o,skipFadeIn:i,className:a,isStreaming:c,disableStreamAnimation:l,variant:d,onShowPopup:m,enableFileReferences:p}=t,g=o===void 0?!0:o,E=i===void 0?!1:i,k=c===void 0?!1:c,w=l===void 0?!1:l,b=d===void 0?"assistant":d,A=p===void 0?!0:p,y=Ue(),{editor:v,runtime:x}=De(),f=C.useRef(null),h=Be()??"",u=ge(Dn);let S;e[0]!==h||e[1]!==u?(S=z=>{h&&u(h,z)},e[0]=h,e[1]=u,e[2]=S):S=e[2];const N=S,R=k&&!w,P=Mn(n,R);let _;e[3]!==n?(_=Ze(n),e[3]=n,e[4]=_):_=e[4];const F=_;let M;e[5]!==F||e[6]!==m?(M={containerRef:f,mermaidBlocks:F,onShowPopup:m},e[5]=F,e[6]=m,e[7]=M):M=e[7],rt(M);const I=A&&!k;let L;e[8]!==v||e[9]!==h||e[10]!==x.isVSCode||e[11]!==I?(L={containerRef:f,effectiveDirectory:h,editor:v,preferRuntimeEditor:x.isVSCode,enabled:I},e[8]=v,e[9]=h,e[10]=x.isVSCode,e[11]=I,e[12]=L):L=e[12],nt(L);let T;e[13]===Symbol.for("react.memo_cache_sentinel")?(T={containerRef:f},e[13]=T):T=e[13],Ge(T);let $;e[14]!==y?($=He(y),e[14]=y,e[15]=$):$=e[15];const se=$,ie=ot(y,h?N:void 0),H=`markdown-${r?.id?`part-${r.id}`:`message-${s}`}`;let J;e[16]!==H||e[17]!==ie||e[18]!==R||e[19]!==P||e[20]!==se?(J={containerRef:f,text:P,streaming:R,cacheKey:H,syntaxVars:se,ctx:ie},e[16]=H,e[17]=ie,e[18]=R,e[19]=P,e[20]=se,e[21]=J):J=e[21],at(J);let q;e[22]!==a?(q=qe("break-words w-full min-w-0",a),e[22]=a,e[23]=q):q=e[23];let W;e[24]!==b?(W=st(b),e[24]=b,e[25]=W):W=e[25];let j;e[26]!==W?(j=X.jsx("div",{className:W,"data-markdown-content":!0}),e[26]=W,e[27]=j):j=e[27];let Q;e[28]!==q||e[29]!==j?(Q=X.jsx("div",{className:q,ref:f,children:j}),e[28]=q,e[29]=j,e[30]=Q):Q=e[30];const ee=Q;if(g){let z;return e[31]!==H||e[32]!==ee||e[33]!==E?(z=X.jsx(vt,{skipAnimation:E,children:ee},H),e[31]=H,e[32]=ee,e[33]=E,e[34]=z):z=e[34],z}return ee},Wn=C.memo(_n,(t,e)=>t.content===e.content&&t.isStreaming===e.isStreaming&&t.disableStreamAnimation===e.disableStreamAnimation&&t.variant===e.variant&&t.isAnimated===e.isAnimated&&t.skipFadeIn===e.skipFadeIn&&t.className===e.className&&t.messageId===e.messageId&&t.onShowPopup===e.onShowPopup&&t.enableFileReferences===e.enableFileReferences&&t.part?.id===e.part?.id),Fn=t=>{const e=B.c(32),{content:n,className:r,variant:s,disableLinkSafety:o,stripFrontmatter:i,onShowPopup:a,allowMermaidWheelZoom:c,enableFileReferences:l}=t,d=s===void 0?"assistant":s,m=i===void 0?!1:i,p=c===void 0?!1:c,g=l===void 0?!0:l,{editor:E,runtime:k}=De(),w=Ue(),b=C.useRef(null),A=Be()??"";let y;e[0]!==n||e[1]!==m?(y=m?sn(n):n,e[0]=n,e[1]=m,e[2]=y):y=e[2];const v=y;let x;e[3]!==v?(x=Ze(v),e[3]=v,e[4]=x):x=e[4];const f=x;let h;e[5]!==p||e[6]!==f||e[7]!==a?(h={containerRef:b,mermaidBlocks:f,onShowPopup:a,allowWheelZoom:p},e[5]=p,e[6]=f,e[7]=a,e[8]=h):h=e[8],rt(h);let u;e[9]!==E||e[10]!==A||e[11]!==g||e[12]!==k.isVSCode?(u={containerRef:b,effectiveDirectory:A,editor:E,preferRuntimeEditor:k.isVSCode,enabled:g},e[9]=E,e[10]=A,e[11]=g,e[12]=k.isVSCode,e[13]=u):u=e[13],nt(u);const S=!o;let N;e[14]!==S?(N={containerRef:b,enabled:S},e[14]=S,e[15]=N):N=e[15],Ge(N);let R;e[16]!==w?(R=He(w),e[16]=w,e[17]=R):R=e[17];const P=R,_=ot(w),F=`simple:${d}`;let M;e[18]!==_||e[19]!==v||e[20]!==P||e[21]!==F?(M={containerRef:b,text:v,streaming:!1,cacheKey:F,syntaxVars:P,ctx:_},e[18]=_,e[19]=v,e[20]=P,e[21]=F,e[22]=M):M=e[22],at(M);let I;e[23]!==r?(I=qe("break-words w-full min-w-0",r),e[23]=r,e[24]=I):I=e[24];let L;e[25]!==d?(L=st(d),e[25]=d,e[26]=L):L=e[26];let T;e[27]!==L?(T=X.jsx("div",{className:L,"data-markdown-content":!0}),e[27]=L,e[28]=T):T=e[28];let $;return e[29]!==I||e[30]!==T?($=X.jsx("div",{className:I,ref:b,children:T}),e[29]=I,e[30]=T,e[31]=$):$=e[31],$},jn=C.memo(Fn,(t,e)=>t.content===e.content&&t.variant===e.variant&&t.className===e.className&&t.disableLinkSafety===e.disableLinkSafety&&t.stripFrontmatter===e.stripFrontmatter&&t.onShowPopup===e.onShowPopup&&t.allowMermaidWheelZoom===e.allowMermaidWheelZoom&&t.enableFileReferences===e.enableFileReferences);function In(t){if(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=t.target;if(!(e instanceof Element))return;const n=e.closest("a[href]");if(!(n instanceof HTMLAnchorElement)||n.getAttribute("data-openchamber-file-link")==="true")return;const r=n.getAttribute("href")??"";Oe(r)&&(t.preventDefault(),t.stopPropagation(),Ct(r))}function $n(t){t.removeAttribute("data-openchamber-file-link"),t.removeAttribute("data-openchamber-file-ref"),t.removeAttribute("data-openchamber-file-path"),t.getAttribute("title")==="Open file"&&t.removeAttribute("title"),t.tagName.toLowerCase()!=="a"&&(t.removeAttribute("role"),t.removeAttribute("tabindex"))}function Pn(){Et()}function On(t,e){return!t.isEqualNode(e)}function Dn(t){return t.openContextPreview}export{Wn as MarkdownRenderer,jn as SimpleMarkdownRenderer};
@@ -1 +0,0 @@
1
- import{H as I,j as t,R as a,b as z}from"./vendor-.bun-C6iL44L9.js";import{l as O,a2 as M,h as B,B as re,E as ae,k as le}from"./index-5eUDDB6w.js";import{c as V,ef as me,f8 as oe,aP as Z,ee,B as U,q as W,w as ce,p as J,I as T,aS as Q}from"./useAppFontEffects-DTO332li.js";function pe(r){switch(r){case"ok":return null;case"auth":return"onboarding.remoteConnection.probe.authMessage";case"update-recommended":return"onboarding.remoteConnection.probe.updateRecommendedMessage";case"incompatible":return"onboarding.remoteConnection.probe.incompatibleMessage";case"wrong-service":return"onboarding.remoteConnection.probe.wrongServiceMessage";case"unreachable":return"onboarding.remoteConnection.probe.unreachableMessage";default:return null}}function Y(r){return r==="wrong-service"||r==="unreachable"||r==="incompatible"}function ie({onBack:r,showBackButton:e=!0,initialUrl:c="",initialLabel:n="",isRecoveryMode:o=!1,onConnect:b,onSwitchToLocal:i}){const{t:s}=V(),[h,y]=I.useState(c),[x,R]=I.useState(n),[N,f]=I.useState("idle"),[m,v]=I.useState(null),[S,C]=I.useState(""),j=me(h),p=j?.persistedUrl??null,w=I.useCallback(d=>{y(d.target.value),f("idle"),v(null),C("")},[]),g=I.useCallback(d=>{R(d.target.value)},[]),k=I.useCallback(async()=>{if(p){f("testing"),v(null),C("");try{const d=await oe(p);v(d),f(d.status==="ok"||d.status==="update-recommended"?"success":"error")}catch(d){C(d instanceof Error?d.message:s("onboarding.remoteConnection.errors.connectionTestFailed")),f("error")}}},[p,s]),K=I.useCallback(async()=>{if(!j)return;const d=j.persistedUrl;f("testing"),v(null),C("");try{const D=await oe(d);if(v(D),Y(D.status)){f("error");return}const F=await Z(),de=x.trim()||d,q=F.hosts.find($=>$.url===d),G=q?q.id:`host-${Date.now().toString(16)}`,te={id:G,label:de,url:d,apiUrl:d},ue=q?F.hosts.map($=>$.id===G?te:$):[...F.hosts,te];if(await ee({hosts:ue,defaultHostId:G,initialHostChoiceCompleted:!0}),b?.(),j.redeemUrl){window.location.assign(j.redeemUrl);return}O()&&await M()}catch(D){C(D instanceof Error?D.message:s("onboarding.remoteConnection.errors.failedToSaveConnection")),f("error")}},[j,x,b,s]),L=N==="testing",A=p!==null&&!L,E=p!==null&&!L&&!Y(m?.status??null),P=pe(m?.status??null),H=m?.status==="ok",u=m?.status==="update-recommended",_=m?.status==="auth",l=Y(m?.status??null);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[e&&t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:s("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-2 text-center",children:[t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(o?"onboarding.remoteConnection.titleRecovery":"onboarding.remoteConnection.title")}),t.jsx("p",{className:"text-muted-foreground text-sm",children:s("onboarding.remoteConnection.description")})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-url",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx(W,{id:"remote-url",type:"url",value:h,onChange:w,placeholder:s("onboarding.remoteConnection.field.serverAddressPlaceholder"),disabled:L})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"remote-label",className:"text-sm text-foreground",children:s("onboarding.remoteConnection.field.nameOptional")}),t.jsx(W,{id:"remote-label",type:"text",value:x,onChange:g,placeholder:s("onboarding.remoteConnection.field.namePlaceholder"),disabled:L})]})]}),m&&H&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-success)",color:"var(--status-success)"},children:s("onboarding.remoteConnection.status.connectedSuccessfully",{latencyMs:m.latencyMs})}),m&&_&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:s("onboarding.remoteConnection.status.authWarning")}),m&&u&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-warning)",color:"var(--status-warning)"},children:P?s(P):null}),m&&l&&t.jsxs("div",{className:"rounded-lg border p-3 text-sm space-y-3",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold mb-1",children:s("onboarding.remoteConnection.status.connectionFailed")}),t.jsx("div",{className:"opacity-90",children:P?s(P):null})]}),t.jsx("div",{className:"text-xs opacity-80",children:m.status==="unreachable"?s("onboarding.remoteConnection.status.suggestionsUnreachable"):s("onboarding.remoteConnection.status.suggestionsWrongService")})]}),S&&t.jsx("div",{className:"rounded-lg border p-3 text-sm",style:{borderColor:"var(--status-error)",color:"var(--status-error)"},children:S}),t.jsxs("div",{className:"flex gap-3",children:[t.jsx(U,{variant:"outline",onClick:k,disabled:!A,children:s(L?"onboarding.remoteConnection.actions.testing":"onboarding.remoteConnection.actions.testConnection")}),t.jsx(U,{onClick:K,disabled:!E,children:s("onboarding.remoteConnection.actions.connectAndRestart")})]}),l&&t.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-border",children:[t.jsx("div",{className:"text-xs text-muted-foreground text-center",children:s("onboarding.remoteConnection.actions.whatToDo")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(U,{variant:"outline",size:"sm",onClick:r,className:"flex-1",children:s("onboarding.remoteConnection.actions.chooseDifferentServer")}),!o&&i&&t.jsx(U,{variant:"outline",size:"sm",onClick:i,className:"flex-1",children:s("onboarding.remoteConnection.actions.useLocalInstead")})]})]})]})})}const he="curl -fsSL https://opencode.ai/install | bash",fe="https://opencode.ai/docs",se=2500;function be(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{className:"flex-1 text-left overflow-x-auto whitespace-nowrap",children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors shrink-0",title:n,"aria-label":n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}function xe({onCliAvailable:r}){const{t:e}=V(),[c,n]=a.useState(!1),[o,b]=a.useState(!1),[i,s]=a.useState(!1),[h,y]=a.useState(!1),[x,R]=a.useState(""),[N,f]=a.useState("unknown"),[m,v]=a.useState("local"),[S,C]=a.useState(!1),[j,p]=a.useState(!1);a.useEffect(()=>{b(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){f("unknown");return}const l=navigator.userAgent||"";/Windows/i.test(l)?f("windows"):/Macintosh|Mac OS X/i.test(l)?f("macos"):/Linux/i.test(l)?f("linux"):f("unknown")},[]),a.useEffect(()=>{let l=!1;return(async()=>{try{const d=await B("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!d.ok)return;const D=await d.json().catch(()=>null);if(!D||l)return;const F=typeof D.opencodeBinary=="string"?D.opencodeBinary.trim():"";F&&R(F)}catch{}})(),()=>{l=!0}},[]);const w=a.useCallback(async l=>{const d=l.target;d.closest(".app-region-no-drag")||d.closest("button, a, input, select, textarea, code, summary, details")||l.button===0&&o&&await re()},[o]),g=a.useCallback(async()=>{try{const l=await B("/health");if(!l.ok)return!1;const d=await l.json();return d.openCodeRunning===!0||d.isOpenCodeReady===!0}catch{return!1}},[]),k=a.useCallback(async l=>{if(!o)return;const d=await Z();await ee({...d,...l==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})},[o]),K=a.useCallback(async()=>{o&&await k("local"),r?.()},[o,r,k]);a.useEffect(()=>{if(m!=="local")return;let l=!1,d=null;const D=async()=>{if(!l){try{const F=await g();if(l)return;if(F){await K();return}}catch{}l||(d=setTimeout(D,se))}};return d=setTimeout(D,se),()=>{l=!0,d&&clearTimeout(d)}},[m,g,K]);const L=a.useCallback(async()=>{y(!0);try{await g()&&await K()}finally{y(!1)}},[g,K]),A=a.useCallback(async()=>{if(!(typeof window>"u")&&o)try{const l=await ae();l.success&&l.path&&l.path.trim().length>0&&R(l.path.trim())}catch{}},[o]),E=a.useCallback(async()=>{s(!0);try{if(await le({opencodeBinary:x.trim()}),o){await k("local"),await M();return}await B("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>s(!1),1e3)}},[o,x,k]),P=a.useCallback(async()=>{const l=await ce(he);l.ok?(n(!0),setTimeout(()=>n(!1),2e3)):console.error("Failed to copy:",l.error)},[]),H=fe,u=N==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":N==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode",_=!o||m==="local";return t.jsx("div",{className:"app-region-drag h-full flex items-center justify-center bg-transparent p-8 cursor-default select-none overflow-y-auto",onMouseDown:w,children:t.jsxs("div",{className:"w-full max-w-md space-y-7",children:[t.jsxs("header",{className:"text-center space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:e("onboarding.chooser.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("onboarding.chooser.description")})]}),o&&t.jsxs("div",{className:"app-region-no-drag flex gap-1.5",children:[t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="local"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("local"),children:e("onboarding.chooser.tabs.localInstall")}),t.jsx("button",{type:"button",className:J("flex-1 px-4 py-2 rounded-lg border transition-colors text-sm",m==="remote"?"border-[var(--interactive-selection)] text-foreground bg-[var(--interactive-selection)]/10":"border-border text-muted-foreground hover:text-foreground hover:border-muted-foreground"),onClick:()=>v("remote"),children:e("onboarding.chooser.tabs.connectRemote")})]}),o&&m==="remote"?t.jsx("div",{className:"app-region-no-drag",children:t.jsx(ie,{onBack:()=>v("local"),showBackButton:!1,onSwitchToLocal:()=>v("local")})}):null,_&&t.jsxs("div",{className:"space-y-4",children:[N==="windows"&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-4",children:[t.jsx("div",{className:"text-sm text-foreground",children:e("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:e("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:e("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("p",{className:"text-sm text-muted-foreground text-center leading-relaxed",children:e("onboarding.localSetup.intro")}),t.jsx("div",{className:"app-region-no-drag rounded-lg border border-border bg-background/60 backdrop-blur-sm px-4 py-3 font-mono text-sm",children:c?t.jsxs("div",{className:"flex items-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),e("onboarding.common.status.copiedToClipboard")]}):t.jsx(be,{onCopy:P,copyTitle:e("onboarding.common.copyToClipboard")})}),t.jsxs("div",{className:"app-region-no-drag flex items-center justify-between",children:[t.jsxs("a",{href:H,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1",children:[e(N==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),t.jsx("button",{type:"button",onClick:L,disabled:h,className:"text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:e(h?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkNow")})]}),t.jsxs("div",{className:"rounded-lg border px-4 py-3 flex items-center gap-3",style:{borderColor:"color-mix(in srgb, var(--primary-base) 20%, transparent)",backgroundColor:"color-mix(in srgb, var(--primary-base) 6%, transparent)"},role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"relative inline-flex h-2.5 w-2.5 shrink-0","aria-hidden":!0,children:[t.jsx("span",{className:"absolute inset-0 rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity 1.6s ease-in-out infinite"}}),t.jsx("span",{className:"absolute inset-[-4px] rounded-full",style:{backgroundColor:"var(--primary-base)",animation:"pulse-opacity-dim 1.6s ease-in-out infinite",opacity:0}})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-foreground leading-tight",children:e("onboarding.localSetup.status.watching")}),t.jsx("div",{className:"text-xs text-muted-foreground leading-tight mt-0.5",children:e("onboarding.localSetup.status.autoContinue")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:S,onToggle:l=>C(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.advanced.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsxs("div",{className:"pb-4 space-y-2",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:x,onChange:l=>R(l.target.value),placeholder:u,disabled:i,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:A,disabled:i||!o,children:e("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",size:"sm",onClick:E,disabled:i||!x.trim(),children:e("onboarding.localSetup.actions.apply")})]}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:e("onboarding.localSetup.helper.saveAndReload")})]})]}),t.jsxs("details",{className:"app-region-no-drag group rounded-lg border border-border/60 px-4 open:bg-background/40 transition-colors",open:j,onToggle:l=>p(l.currentTarget.open),children:[t.jsxs("summary",{className:"flex items-center justify-between cursor-pointer py-2.5 text-sm text-muted-foreground hover:text-foreground transition-colors list-none [&::-webkit-details-marker]:hidden",children:[t.jsx("span",{children:e("onboarding.localSetup.troubleshoot.title")}),t.jsx(T,{name:"arrow-down-s",className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),t.jsx("ul",{className:"pb-4 space-y-1.5 text-xs text-muted-foreground list-disc pl-4",children:N==="windows"?t.jsx(t.Fragment,{children:t.jsx("li",{children:e("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("li",{children:e("onboarding.localSetup.hint.ensurePath")}),t.jsx("li",{children:e("onboarding.localSetup.hint.setEnv")}),t.jsx("li",{children:e("onboarding.localSetup.hint.missingRuntime")})]})})]})]})]})})}const ge="curl -fsSL https://opencode.ai/install | bash",ye="https://opencode.ai/docs";function ve(r){const e=z.c(5),{onCopy:c,copyTitle:n}=r;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsxs("code",{children:[t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"curl"}),t.jsx("span",{className:"text-muted-foreground",children:" -fsSL "}),t.jsx("span",{style:{color:"var(--syntax-string)"},children:"https://opencode.ai/install"}),t.jsx("span",{className:"text-muted-foreground",children:" | "}),t.jsx("span",{style:{color:"var(--syntax-keyword)"},children:"bash"})]}),e[0]=o):o=e[0];let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(T,{name:"file-copy",className:"h-4 w-4"}),e[1]=b):b=e[1];let i;return e[2]!==n||e[3]!==c?(i=t.jsxs("div",{className:"flex items-center justify-center gap-3",children:[o,t.jsx("button",{onClick:c,className:"inline-flex items-center text-muted-foreground hover:text-foreground transition-colors",title:n,children:b})]}),e[2]=n,e[3]=c,e[4]=i):i=e[4],i}const we=3e4;function je({onBack:r,onCliAvailable:e,isFromRecovery:c=!1,onSwitchToRemote:n}){const{t:o}=V(),[b,i]=a.useState(!1),[s,h]=a.useState(!1),[y,x]=a.useState(!1),[R,N]=a.useState(!1),[f,m]=a.useState(!1),[v,S]=a.useState(null),[C,j]=a.useState(""),[p,w]=a.useState("unknown");a.useEffect(()=>{const u=setTimeout(()=>h(!0),we);return()=>clearTimeout(u)},[]),a.useEffect(()=>{x(O())},[]),a.useEffect(()=>{if(typeof navigator>"u"){w("unknown");return}const u=navigator.userAgent||"";if(/Windows/i.test(u)){w("windows");return}if(/Macintosh|Mac OS X/i.test(u)){w("macos");return}if(/Linux/i.test(u)){w("linux");return}w("unknown")},[]),a.useEffect(()=>{let u=!1;return(async()=>{try{const _=await B("/api/config/settings",{method:"GET",headers:{Accept:"application/json"}});if(!_.ok)return;const l=await _.json().catch(()=>null);if(!l||u)return;const d=typeof l.opencodeBinary=="string"?l.opencodeBinary.trim():"";d&&j(d)}catch{}})(),()=>{u=!0}},[]);const g=a.useCallback(async u=>{u.target.closest("button, a, input, select, textarea, code")||u.button===0&&y&&await re()},[y]),k=a.useCallback(async()=>{try{const u=await B("/health");if(!u.ok)return!1;const _=await u.json();return _.openCodeRunning===!0||_.isOpenCodeReady===!0}catch{return!1}},[]),K=a.useCallback(async()=>{if(!(typeof window>"u")&&y)try{const u=await ae();u.success&&u.path&&u.path.trim().length>0&&j(u.path.trim())}catch{}},[y]),L=a.useCallback(async()=>{N(!0);try{if(await le({opencodeBinary:C.trim()}),y){await M();return}await B("/api/config/reload",{method:"POST"})}finally{setTimeout(()=>N(!1),1e3)}},[y,C]),A=a.useCallback(async()=>{const u=await ce(ge);u.ok?(i(!0),setTimeout(()=>i(!1),2e3)):console.error("Failed to copy:",u.error)},[]),E=a.useCallback(async()=>{m(!0),S(null);try{await k()?e?.():S(o("onboarding.localSetup.errors.cliNotReady"))}catch(u){S(u instanceof Error?u.message:o("onboarding.localSetup.errors.detectionFailed"))}finally{m(!1)}},[k,e,o]),P=ye,H=p==="windows"?"C:\\Users\\you\\AppData\\Roaming\\npm\\opencode.cmd":p==="linux"?"/home/you/.bun/bin/opencode":"/Users/you/.bun/bin/opencode";return t.jsxs("div",{className:"h-full flex items-center justify-center bg-transparent p-8 relative cursor-default select-none",onMouseDown:g,children:[t.jsxs("div",{className:"w-full max-w-lg space-y-4 text-center",children:[t.jsx("div",{className:"flex items-center",children:t.jsx(U,{variant:"ghost",onClick:r,className:"p-0 text-muted-foreground hover:text-foreground",children:o("onboarding.common.actions.back")})}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-foreground",children:o("onboarding.localSetup.title")}),t.jsx("p",{className:"text-muted-foreground",children:o("onboarding.localSetup.description")})]}),p==="windows"&&t.jsxs("div",{className:"mx-auto max-w-2xl rounded-lg border border-border bg-background/50 p-4 text-left",children:[t.jsx("div",{className:"text-sm text-foreground",children:o("onboarding.localSetup.windows.title")}),t.jsxs("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[t.jsx("li",{children:o("onboarding.localSetup.windows.stepRunInstallInWsl")}),t.jsx("li",{children:o("onboarding.localSetup.windows.stepSetBinaryPath")})]})]}),t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"bg-background/60 backdrop-blur-sm border border-border rounded-lg px-5 py-3 font-mono text-sm w-fit",children:b?t.jsxs("div",{className:"flex items-center justify-center gap-2",style:{color:"var(--status-success)"},children:[t.jsx(T,{name:"check",className:"h-4 w-4"}),o("onboarding.common.status.copiedToClipboard")]}):t.jsx(ve,{onCopy:A,copyTitle:o("onboarding.common.copyToClipboard")})})}),t.jsxs("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1 justify-center",children:[o(p==="windows"?"onboarding.localSetup.docs.windows":"onboarding.localSetup.docs.default"),t.jsx(T,{name:"external-link",className:"h-3 w-3"})]}),v&&t.jsx("div",{className:"mx-auto max-w-md rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-sm text-destructive",children:v}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(U,{type:"button",onClick:E,disabled:f,className:"w-full max-w-xs",size:"lg",children:o(f?"onboarding.localSetup.actions.checking":"onboarding.localSetup.actions.checkAndContinue")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:o("onboarding.localSetup.helper.checkAndContinue")})]}),t.jsx("div",{className:"mx-auto w-full max-w-xl pt-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-sm text-muted-foreground",children:o("onboarding.localSetup.field.alreadyInstalled")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(W,{value:C,onChange:u=>j(u.target.value),placeholder:H,disabled:R,className:"flex-1 font-mono text-xs"}),t.jsx(U,{type:"button",variant:"secondary",onClick:K,disabled:R||!y,children:o("onboarding.localSetup.actions.browse")}),t.jsx(U,{type:"button",onClick:L,disabled:R,children:o("onboarding.localSetup.actions.apply")})]}),t.jsx("div",{className:"text-xs text-muted-foreground/70",children:o("onboarding.localSetup.helper.saveAndReload")})]})}),c&&n&&t.jsxs("div",{className:"text-center pt-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:o("onboarding.localSetup.remotePreference")}),t.jsx(U,{variant:"link",onClick:n,children:o("onboarding.localSetup.actions.connectRemoteServer")})]})]}),s&&t.jsx("div",{className:"absolute bottom-8 left-0 right-0 text-center space-y-1",children:p==="windows"?t.jsx(t.Fragment,{children:t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.windows.hintDetectionFailed")})}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.ensurePath")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.setEnv")}),t.jsx("p",{className:"text-sm text-muted-foreground/70",children:o("onboarding.localSetup.hint.missingRuntime")})]})})]})}function X(r,e){if(r?.trim())return Q(r.trim());if(e)return Q(e)}function ke(r,e,c){switch(r){case"local-unavailable":return{title:"Local OpenCode Unavailable",description:"OpenCode CLI could not be started or is not installed. Install OpenCode or connect to a remote server instead.",titleKey:"onboarding.desktopRecovery.localUnavailable.title",descriptionKey:"onboarding.desktopRecovery.localUnavailable.description",iconKey:"local",showRetry:!0,retryLabel:"Retry Local",retryLabelKey:"onboarding.desktopRecovery.localUnavailable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Set Up Local",useLocalLabelKey:"onboarding.desktopRecovery.localUnavailable.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-missing":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};case"remote-unreachable":{const n=X(e,c);return{title:"Remote Server Unreachable",description:`Could not connect to "${n||"the remote server"}". Check your network connection and verify the server address.`,titleKey:"onboarding.desktopRecovery.remoteUnreachable.title",descriptionKey:"onboarding.desktopRecovery.remoteUnreachable.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-wrong-service":{const n=X(e,c);return{title:"Incompatible Server",description:`The server at "${n||"unknown"}" is not running OpenChamber. Verify the address points to an OpenChamber server.`,titleKey:"onboarding.desktopRecovery.incompatibleServer.title",descriptionKey:"onboarding.desktopRecovery.incompatibleServer.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"remote-incompatible":{const n=X(e,c);return{title:"Server Update Required",description:`The OpenChamber server at "${n||"unknown"}" is not compatible with this app version. Update OpenChamber on the server, then try again.`,titleKey:"onboarding.desktopRecovery.remoteIncompatible.title",descriptionKey:"onboarding.desktopRecovery.remoteIncompatible.description",descriptionParams:n?{host:n}:void 0,iconKey:"remote",showRetry:!0,retryLabel:"Retry Connection",retryLabelKey:"onboarding.desktopRecovery.remoteUnreachable.retry",showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"}}case"missing-default-host":return{title:"No Default Connection",description:"Your saved default connection could not be found. Choose how you want to connect.",titleKey:"onboarding.desktopRecovery.noDefaultConnection.title",descriptionKey:"onboarding.desktopRecovery.noDefaultConnection.description",iconKey:"local",showRetry:!1,showUseLocal:!0,showUseRemote:!0,useLocalLabel:"Use Local",useLocalLabelKey:"onboarding.desktopRecovery.common.useLocal",useRemoteLabel:"Use Remote",useRemoteLabelKey:"onboarding.desktopRecovery.common.useRemote"};default:{const n=r;throw new Error(`Unknown recovery variant: ${n}`)}}}function Ce(r){switch(r){case"local":return t.jsx(T,{name:"macbook",className:"h-8 w-8"});case"remote":return t.jsx(T,{name:"server",className:"h-8 w-8"})}}function Ne({variant:r,hostLabel:e,hostUrl:c,onRetry:n,onUseLocal:o,onUseRemote:b,isRetrying:i=!1}){const{t:s}=V(),h=ke(r,e,c),y=h.retryLabelKey??"onboarding.desktopRecovery.actions.retryConnection",x=a.useMemo(()=>{if(h.descriptionParams?.host)return h.descriptionParams;if(r==="remote-unreachable")return{host:s("onboarding.desktopRecovery.placeholders.remoteServer")};if(r==="remote-wrong-service"||r==="remote-incompatible")return{host:s("onboarding.desktopRecovery.placeholders.unknownServer")}},[h.descriptionParams,s,r]);return t.jsx("div",{className:"flex flex-col items-center justify-center h-full p-8",children:t.jsxs("div",{className:"w-full max-w-md space-y-6",children:[t.jsxs("div",{className:"flex flex-col items-center space-y-3 text-center",children:[t.jsx("div",{className:"p-3 rounded-full",style:{backgroundColor:"var(--status-warning)",opacity:.15},children:t.jsx("div",{style:{color:"var(--status-warning)"},children:Ce(h.iconKey)})}),t.jsx("h1",{className:"typography-ui-header text-xl font-semibold text-foreground",children:s(h.titleKey)}),t.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:s(h.descriptionKey,x)})]}),c&&(r==="remote-unreachable"||r==="remote-wrong-service"||r==="remote-incompatible")&&t.jsxs("div",{className:"rounded-lg border border-border bg-background/50 p-3",children:[t.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:s("onboarding.remoteConnection.field.serverAddress")}),t.jsx("div",{className:"font-mono text-sm text-foreground truncate",children:Q(c)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[h.showRetry&&n&&t.jsxs(U,{onClick:n,disabled:i,className:"w-full",children:[t.jsx(T,{name:"refresh",className:J("h-4 w-4",i&&"animate-spin")}),s(i?"onboarding.desktopRecovery.actions.retrying":y)]}),t.jsxs("div",{className:"flex gap-2",children:[h.showUseLocal&&o&&t.jsxs(U,{variant:"outline",onClick:o,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"macbook",className:"h-4 w-4"}),s(h.useLocalLabelKey)]}),h.showUseRemote&&b&&t.jsxs(U,{variant:"outline",onClick:b,disabled:i,className:"flex-1",children:[t.jsx(T,{name:"server",className:"h-4 w-4"}),s(h.useRemoteLabelKey)]})]})]})]})})}function ne(r,e){if(e==="use-remote")return{kind:"remote-form"};switch(r){case"local-unavailable":return{kind:"local-setup"};case"remote-unreachable":case"remote-incompatible":case"remote-wrong-service":case"remote-missing":case"missing-default-host":return{kind:"switch-default-to-local"};default:{const c=r;throw new Error(`Unhandled RecoveryVariant: ${c}`)}}}function Se(r){const e=z.c(27),{variant:c,hostUrl:n,hostLabel:o,onRetry:b,onChooseRemote:i,showRemoteForm:s,onCloseRemoteForm:h,onSwitchToLocalFromRemote:y,onEnterLocalSetup:x,isRetrying:R}=r,N=s===void 0?!1:s,f=R===void 0?!1:R,m=Re;let v;e[0]!==b?(v=async()=>{if(O()){await M();return}await B("/api/config/reload",{method:"POST"}),b?.()},e[0]=b,e[1]=v):v=e[1];const S=v;let C;e[2]!==x||e[3]!==c?(C=async()=>{if(ne(c,"use-local").kind==="local-setup"){x?.();return}if(await m("local"),O()){await M();return}window.location.reload()},e[2]=x,e[3]=c,e[4]=C):C=e[4];const j=C;let p;e[5]!==i||e[6]!==c?(p=()=>{ne(c,"use-remote").kind==="remote-form"&&i?.()},e[5]=i,e[6]=c,e[7]=p):p=e[7];const w=p;if(N){const k=c==="remote-wrong-service"?"":n||"",K=c==="remote-wrong-service"?"":o||"";let L;e[8]!==i||e[9]!==h?(L=h||(()=>i?.()),e[8]=i,e[9]=h,e[10]=L):L=e[10];let A;e[11]!==x||e[12]!==y?(A=y||(()=>{m("local").then(()=>{O()?M():x?.()})}),e[11]=x,e[12]=y,e[13]=A):A=e[13];let E;return e[14]!==K||e[15]!==k||e[16]!==L||e[17]!==A?(E=t.jsx(ie,{onBack:L,initialUrl:k,initialLabel:K,isRecoveryMode:!0,onSwitchToLocal:A}),e[14]=K,e[15]=k,e[16]=L,e[17]=A,e[18]=E):E=e[18],E}let g;return e[19]!==S||e[20]!==j||e[21]!==w||e[22]!==o||e[23]!==n||e[24]!==f||e[25]!==c?(g=t.jsx(Ne,{variant:c,hostLabel:o,hostUrl:n,onRetry:S,onUseLocal:j,onUseRemote:w,isRetrying:f}),e[19]=S,e[20]=j,e[21]=w,e[22]=o,e[23]=n,e[24]=f,e[25]=c,e[26]=g):g=e[26],g}async function Re(r){if(!O())return;const e=await Z();await ee({...e,...r==="local"?{defaultHostId:"local"}:{},initialHostChoiceCompleted:!0})}function Ke(r){const e=z.c(26),{onBack:c,onCliAvailable:n,mode:o,recoveryVariant:b,recoveryHostUrl:i,recoveryHostLabel:s,onEnterLocalSetup:h}=r,y=o===void 0?"first-launch":o,x=b===void 0?"missing-default-host":b,[R,N]=a.useState(!1),[f,m]=a.useState(!1);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(!1),N(!1)},e[0]=v):v=e[0];let S;e[1]!==y||e[2]!==s||e[3]!==i||e[4]!==x?(S=[y,x,i,s],e[1]=y,e[2]=s,e[3]=i,e[4]=x,e[5]=S):S=e[5],a.useEffect(v,S);const C=f?"local-setup":y;if(C==="recovery"){let p,w;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>N(!1),w=()=>{N(!1),m(!0)},e[6]=p,e[7]=w):(p=e[6],w=e[7]);let g;e[8]!==h?(g=()=>{m(!0),h?.()},e[8]=h,e[9]=g):g=e[9];let k;return e[10]!==s||e[11]!==i||e[12]!==x||e[13]!==R||e[14]!==g?(k=t.jsx(Se,{variant:x,hostUrl:i,hostLabel:s,showRemoteForm:R,onCloseRemoteForm:p,onSwitchToLocalFromRemote:w,onEnterLocalSetup:g}),e[10]=s,e[11]=i,e[12]=x,e[13]=R,e[14]=g,e[15]=k):k=e[15],k}if(C==="local-setup"){let p;e[16]!==c||e[17]!==f?(p=()=>{f?m(!1):c?.()},e[16]=c,e[17]=f,e[18]=p):p=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>N(!0),e[19]=w):w=e[19];let g;return e[20]!==n||e[21]!==f||e[22]!==p?(g=t.jsx(je,{onBack:p,onCliAvailable:n,isFromRecovery:f,onSwitchToRemote:w}),e[20]=n,e[21]=f,e[22]=p,e[23]=g):g=e[23],g}let j;return e[24]!==n?(j=t.jsx(xe,{onCliAvailable:n}),e[24]=n,e[25]=j):j=e[25],j}export{Ke as OnboardingScreen};
@@ -1 +0,0 @@
1
- import{b,R as h,j as t,bk as j,bi as w,bj as v,bg as k,be as D}from"./vendor-.bun-C6iL44L9.js";import{c as R,p as g}from"./useAppFontEffects-DTO332li.js";import{h as S}from"./runtimeEndpointReset-BYLVW9e7.js";import"./index-5eUDDB6w.js";import"./mobileLayoutPreference-Dio-WWkI.js";const B=x=>{const e=b.c(19),{open:m,onOpenChange:n}=x,{t:f}=R(),s=h.useId(),y=_;let a;e[0]!==n?(a=u=>{!u&&y()||n(u)},e[0]=n,e[1]=a):a=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(j,{className:g("fixed inset-0 z-50 bg-black/50 dark:bg-black/75","transition-opacity duration-150 ease-out","data-[starting-style]:opacity-0 data-[ending-style]:opacity-0")}),e[2]=c):c=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=g("relative pointer-events-auto","w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden origin-center","bg-background","transition-all duration-150 ease-out","data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]","data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]"),e[3]=d):d=e[3];let o;e[4]!==f?(o=f("settings.window.description"),e[4]=f,e[5]=o):o=e[5];let i;e[6]!==s||e[7]!==o?(i=t.jsx(w,{id:s,className:"sr-only",children:o}),e[6]=s,e[7]=o,e[8]=i):i=e[8];let l;e[9]!==n?(l=t.jsx(S,{onClose:()=>n(!1),isWindowed:!0}),e[9]=n,e[10]=l):l=e[10];let r;e[11]!==s||e[12]!==i||e[13]!==l?(r=t.jsxs(v,{children:[c,t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center pointer-events-none",children:t.jsxs(k,{"aria-describedby":s,className:d,children:[i,l]})})]}),e[11]=s,e[12]=i,e[13]=l,e[14]=r):r=e[14];let p;return e[15]!==m||e[16]!==a||e[17]!==r?(p=t.jsx(D,{open:m,onOpenChange:a,children:r}),e[15]=m,e[16]=a,e[17]=r,e[18]=p):p=e[18],p};function _(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]')}export{B as SettingsWindow};