@openchambery/web 2.1.9 → 2.1.10-beta.10

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 (121) hide show
  1. package/dist/assets/AgentAvatar-HkvwOX6E.js +1 -0
  2. package/dist/assets/AssistantView-CPPxqPo7.js +3 -0
  3. package/dist/assets/{DiagramView-Da4NUKjs.js → DiagramView-CD0JRf9L.js} +1 -1
  4. package/dist/assets/FadeInOnReveal-BKvNCFE0.js +1 -0
  5. package/dist/assets/Icon-x0XTu231.js +1 -0
  6. package/dist/assets/{ImageLoadingPlaceholder-DEpMJXzV.js → ImageLoadingPlaceholder-Da1xKjxc.js} +1 -1
  7. package/dist/assets/{LoadingImage-BAT9D9wN.js → LoadingImage-DO_V7mRh.js} +1 -1
  8. package/dist/assets/MarkdownRenderer-BZZFoaPb.js +2 -0
  9. package/dist/assets/MarkdownRendererImpl-BwBPrsxq.js +10 -0
  10. package/dist/assets/{MarkstreamRendererImpl-84iNXlAL.js → MarkstreamRendererImpl-BeCY-mui.js} +1 -1
  11. package/dist/assets/{MobileDetailNavigation-DshnlWA6.js → MobileDetailNavigation-tDiUj5U0.js} +1 -1
  12. package/dist/assets/{MobileShareBridge-BVTR53DJ.js → MobileShareBridge-iApPj95w.js} +3 -3
  13. package/dist/assets/MobileTabPageHeader-DOpvXyuR.js +2 -0
  14. package/dist/assets/{MultiRunWindow-CZoSCvaH.js → MultiRunWindow-CAzMa1Nm.js} +1 -1
  15. package/dist/assets/{OnboardingScreen-CqcZEptL.js → OnboardingScreen-TFogoeFF.js} +1 -1
  16. package/dist/assets/{OverlayScrollbar-BY5HaNrb.js → OverlayScrollbar-DYyjRbut.js} +1 -1
  17. package/dist/assets/{SettingsView-DZOrr9ui.js → SettingsView-BSKkzr8d.js} +9 -9
  18. package/dist/assets/{SettingsWindow-BONQpZYo.js → SettingsWindow-BGmZ-fkc.js} +1 -1
  19. package/dist/assets/{TerminalView-ze4SM49I.js → TerminalView-BnHTLMST.js} +1 -1
  20. package/dist/assets/ToolOutputDialog-DAVZmdoA.css +1 -0
  21. package/dist/assets/ToolOutputDialog-Dm4ljddO.js +10 -0
  22. package/dist/assets/{rasterizePng-CpK-xCkB.js → agentColors-DWSbQXy2.js} +1 -1
  23. package/dist/assets/appThemeRegistry-w-Ebbmh5.js +1 -0
  24. package/dist/assets/{assistant-attachment-cache-B2UAUHUZ.js → assistant-attachment-cache-CecNXB7z.js} +1 -1
  25. package/dist/assets/{button-CWSs9Baz.js → button-Ca8Z9cOP.js} +1 -1
  26. package/dist/assets/{collapsible-ngtoKADo.js → collapsible-P03Lkmyr.js} +1 -1
  27. package/dist/assets/{diagram-DmlTCkmV.js → diagram-DIRYGkQv.js} +1 -1
  28. package/dist/assets/{dialog-BMa16qrs.js → dialog-DKsOQO4Y.js} +1 -1
  29. package/dist/assets/{dropdown-menu.styles-BNwZmBRp.js → dropdown-menu.styles-vl6a_Aes.js} +1 -1
  30. package/dist/assets/fileMentionTouchSelection-CtLKSOq0.js +2 -0
  31. package/dist/assets/{gitApi-Cu18p2BN.js → gitApi-D3JDHCiI.js} +4 -4
  32. package/dist/assets/{image-loading-Bj11k4gM.js → image-loading-DImQz00b.js} +1 -1
  33. package/dist/assets/{image-loading-CObM4tcX.css → image-loading-j2FgxzZQ.css} +1 -1
  34. package/dist/assets/{input-CALwaZEB.js → input-CGZVLev1.js} +1 -1
  35. package/dist/assets/insertionBoundaries-JP72UEgW.js +1 -0
  36. package/dist/assets/main-BnRW5v-z.js +2 -0
  37. package/dist/assets/main-Vubfe9XA.js +169 -0
  38. package/dist/assets/{markdownHeightCache-DXM_5jTe.js → markdownHeightCache-CYwP7eeh.js} +1 -1
  39. package/dist/assets/markdownTheme-BUfvCGAn.js +1 -0
  40. package/dist/assets/{mcpQueries-DFPcn_Qh.js → mcpQueries-B__Ge5kV.js} +1 -1
  41. package/dist/assets/miniChat-DGxEvelP.js +2 -0
  42. package/dist/assets/mobile-eGR6pZsC.js +2 -0
  43. package/dist/assets/mobileBackNavigation-CGH0aRvP.js +1 -0
  44. package/dist/assets/multirun-D0s4kPUs.js +3 -0
  45. package/dist/assets/platform-QykS5eAQ.js +7 -0
  46. package/dist/assets/{projectMeta-cJ7hUTYb.js → projectMeta-DPvDDfM0.js} +1 -1
  47. package/dist/assets/rasterizePng-056Poix7.js +1 -0
  48. package/dist/assets/relay-image-stream-CqgxIcA5.js +2 -0
  49. package/dist/assets/renderElectronMiniChatApp-DoJOOOvp.js +2 -0
  50. package/dist/assets/renderMobileApp-D8ARkO58.js +28 -0
  51. package/dist/assets/{runtimeConfig-BLS7W_q5.js → runtimeConfig-D0fGrt74.js} +1 -1
  52. package/dist/assets/runtimeEndpointReset-asSGzNnU.js +149 -0
  53. package/dist/assets/{scheduledTaskNavigation-DQcLqQ52.js → scheduledTaskNavigation-CgctKy2R.js} +1 -1
  54. package/dist/assets/sessionChangeSummary-BTJ_oAdX.js +1 -0
  55. package/dist/assets/{sessionChangeSummary-vC84qM3v.css → sessionChangeSummary-D_zsqekg.css} +1 -1
  56. package/dist/assets/{sessionLookup-C5W6GTm9.js → sessionLookup-CZWffaVD.js} +1 -1
  57. package/dist/assets/{sortable-tabs-strip-CscHgCaq.js → sortable-tabs-strip-MZyRcU60.js} +1 -1
  58. package/dist/assets/speechSettingsQueries-D9HkL9-8.js +4 -0
  59. package/dist/assets/src-Doy5O-1o.css +2 -0
  60. package/dist/assets/{store-CG7Ytsg9.js → store-D79UkOhB.js} +1 -1
  61. package/dist/assets/{terminalApi-rxsMWL0o.js → terminalApi-BeYpC7rG.js} +1 -1
  62. package/dist/assets/textarea-BfNgh87h.js +1 -0
  63. package/dist/assets/{tooltip-CV6dvLBp.js → tooltip-B7cKvIho.js} +1 -1
  64. package/dist/assets/{useAppFontEffects-Db1Q824F.js → useAppFontEffects-CN_sjO4l.js} +43 -43
  65. package/dist/assets/{useDesktopWindowControlsLayout-W4B87onU.js → useDesktopWindowControlsLayout-QxfqckBX.js} +1 -1
  66. package/dist/assets/{useEffectiveDirectory-A96lQo7K.js → useEffectiveDirectory-DXbRKe4_.js} +1 -1
  67. package/dist/assets/{useFontPreferences-DqEIKMEW.js → useFontPreferences-rSp7tOs0.js} +1 -1
  68. package/dist/assets/useMobileNavigationStore-BvJJ9SP1.js +417 -0
  69. package/dist/assets/useWorkerHighlightedLines-hl5s_wXd.js +7 -0
  70. package/dist/assets/vendor-fuzzysort-ukaRp9PC.js +1 -0
  71. package/dist/assets/{zh-CN-BH4APVTu.js → zh-CN-DdInLm-R.js} +1 -1
  72. package/dist/assets/{zh-TW-BEi6Yf50.js → zh-TW-QxWs2t3K.js} +1 -1
  73. package/dist/index.html +5 -5
  74. package/dist/mini-chat.html +5 -5
  75. package/dist/mobile.html +5 -5
  76. package/package.json +1 -1
  77. package/server/lib/content-search/DOCUMENTATION.md +5 -1
  78. package/server/lib/content-search/runtime.test.js +6 -2
  79. package/server/lib/content-search/service.js +7 -2
  80. package/server/lib/content-search/service.test.js +20 -0
  81. package/server/lib/fs/DOCUMENTATION.md +6 -0
  82. package/server/lib/fs/raw-video.test.js +41 -0
  83. package/server/lib/fs/routes.js +15 -1
  84. package/server/lib/opencode/proxy.js +2 -1
  85. package/server/lib/opencode/proxy.test.js +13 -0
  86. package/server/lib/relay/relay-server.e2e.test.ts +28 -5
  87. package/server/lib/session-turn-pages/DOCUMENTATION.md +8 -0
  88. package/server/lib/session-turn-pages/native-payload.d.ts +2 -0
  89. package/server/lib/session-turn-pages/native-payload.js +38 -0
  90. package/server/lib/session-turn-pages/native-payload.test.js +34 -0
  91. package/server/lib/session-turn-pages/routes.js +2 -1
  92. package/server/lib/session-turn-pages/routes.test.js +18 -0
  93. package/dist/assets/AgentAvatar-qLxaEaDh.js +0 -1
  94. package/dist/assets/AssistantView-DHSCy5gH.js +0 -3
  95. package/dist/assets/FadeInOnReveal-CX8Bkq-l.js +0 -1
  96. package/dist/assets/Icon-BCFeHDWx.js +0 -1
  97. package/dist/assets/MarkdownRenderer-CT4442A0.js +0 -2
  98. package/dist/assets/MarkdownRendererImpl-BHsfx6ED.js +0 -10
  99. package/dist/assets/MobileTabPageHeader-CwKmllLB.js +0 -2
  100. package/dist/assets/ToolOutputDialog-DesCcdFD.css +0 -1
  101. package/dist/assets/ToolOutputDialog-xTzsvgSH.js +0 -10
  102. package/dist/assets/appThemeRegistry-yPeRO8pM.js +0 -1
  103. package/dist/assets/fileMentionTouchSelection-Dq7j3zBe.js +0 -2
  104. package/dist/assets/insertionBoundaries-CHdfgL02.js +0 -1
  105. package/dist/assets/main-CFFeMLQm.js +0 -2
  106. package/dist/assets/main-xMuHp5qm.js +0 -169
  107. package/dist/assets/markdownTheme-CV7_0QAL.js +0 -1
  108. package/dist/assets/miniChat-BVaLWch7.js +0 -2
  109. package/dist/assets/mobile-B-guH7UC.js +0 -2
  110. package/dist/assets/multirun-DVH5nme1.js +0 -3
  111. package/dist/assets/platform-CgwxwfA4.js +0 -7
  112. package/dist/assets/relay-image-stream-SV0lH6aG.js +0 -2
  113. package/dist/assets/renderElectronMiniChatApp-CSAQ90Rs.js +0 -2
  114. package/dist/assets/renderMobileApp-C3vEMjim.js +0 -28
  115. package/dist/assets/runtimeEndpointReset-Clsv0T9B.js +0 -149
  116. package/dist/assets/sessionChangeSummary-hheGPvDz.js +0 -1
  117. package/dist/assets/speechSettingsQueries-CcKa1uT2.js +0 -4
  118. package/dist/assets/src-Cq3Axl32.css +0 -2
  119. package/dist/assets/textarea-D_tvJ-Lw.js +0 -1
  120. package/dist/assets/useMobileNavigationStore-B4XAjLFo.js +0 -417
  121. package/dist/assets/useWorkerHighlightedLines-POG4Xahb.js +0 -7
@@ -35,6 +35,12 @@ Own filesystem API behavior for the web server runtime, including file operation
35
35
  - `index.js` no longer owns FS route handlers or FS exec job state.
36
36
 
37
37
  ## Notes for contributors
38
+ - `/api/fs/raw` serves video MIME types (MP4/M4V/MOV/WebM/OGV) using Express's
39
+ streamed `sendFile` after the existing path authorization/realpath checks.
40
+ Explicit Range requests and HEAD use the same path: 206/Content-Range,
41
+ suffix/open-ended reads, 416 and disconnect cancellation are transport-neutral.
42
+ `raw-video.test.js` exercises the real route; the compiled Relay E2E test checks
43
+ that authorized ranges retain metadata/bytes across the encrypted tunnel.
38
44
  - Keep filesystem policy (read access, workspace root checks for mutations, error mapping, exec timeout behavior) inside this module, not in the composition root.
39
45
  - Optional `GET /api/fs/read` responses retain their `text/plain` body and set `x-openchamber-file-exists` to `true` or `false` so empty files remain distinguishable from missing files.
40
46
  - If adding new `/api/fs/*` endpoints, add them in `routes.js` and extend this document.
@@ -0,0 +1,41 @@
1
+ import { afterEach, expect, test } from 'vitest';
2
+ import express from 'express';
3
+ import * as fs from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ import os from 'node:os';
6
+ import { registerFsRoutes } from './routes.js';
7
+
8
+ const cleanups = [];
9
+ afterEach(async () => { for (const cleanup of cleanups.splice(0).reverse()) await cleanup(); });
10
+
11
+ test('raw video supports first-byte probing, tail seeking, HEAD and unsatisfiable ranges', async () => {
12
+ const directory = await fs.mkdtemp(path.join(os.tmpdir(), 'oc-video-range-'));
13
+ cleanups.push(() => fs.rm(directory, { recursive: true, force: true }));
14
+ const file = path.join(directory, 'clip.mov');
15
+ await fs.writeFile(file, Buffer.from('0123456789'));
16
+ const app = express();
17
+ registerFsRoutes({ get: (route, handler) => { if (route === '/api/fs/raw') app.get(route, handler); }, post() {}, put() {} }, {
18
+ os, path, fsPromises: fs, spawn() {}, crypto: globalThis.crypto,
19
+ normalizeDirectoryPath: value => value, resolveProjectDirectory: async () => ({ directory }),
20
+ buildAugmentedPath: () => '', resolveGitBinaryForSpawn: () => 'git', openchamberUserConfigRoot: directory,
21
+ });
22
+ const server = app.listen(0, '127.0.0.1');
23
+ await new Promise(resolve => server.once('listening', resolve));
24
+ cleanups.push(() => new Promise(resolve => { server.close(resolve); server.closeAllConnections(); }));
25
+ const url = `http://127.0.0.1:${server.address().port}/api/fs/raw?path=${encodeURIComponent(file)}`;
26
+ for (const [range, expected, contentRange] of [['bytes=0-1', '01', 'bytes 0-1/10'], ['bytes=7-', '789', 'bytes 7-9/10'], ['bytes=-3', '789', 'bytes 7-9/10']]) {
27
+ const response = await fetch(url, { headers: { Range: range } });
28
+ expect(response.status).toBe(206);
29
+ expect(response.headers.get('content-type')).toBe('video/quicktime');
30
+ expect(response.headers.get('content-range')).toBe(contentRange);
31
+ expect(response.headers.get('accept-ranges')).toBe('bytes');
32
+ expect(await response.text()).toBe(expected);
33
+ }
34
+ const head = await fetch(url, { method: 'HEAD' });
35
+ expect(head.status).toBe(200);
36
+ expect(head.headers.get('content-length')).toBe('10');
37
+ expect(await head.text()).toBe('');
38
+ const invalid = await fetch(url, { headers: { Range: 'bytes=20-' } });
39
+ expect(invalid.status).toBe(416);
40
+ expect(invalid.headers.get('content-range')).toBe('bytes */10');
41
+ });
@@ -109,6 +109,10 @@ const FILE_MIME_MAP = Object.freeze({
109
109
  '.eot': 'application/vnd.ms-fontobject',
110
110
  '.mp3': 'audio/mpeg',
111
111
  '.mp4': 'video/mp4',
112
+ '.m4v': 'video/mp4',
113
+ '.mov': 'video/quicktime',
114
+ '.webm': 'video/webm',
115
+ '.ogv': 'video/ogg',
112
116
  '.png': 'image/png',
113
117
  '.jpg': 'image/jpeg',
114
118
  '.jpeg': 'image/jpeg',
@@ -885,6 +889,11 @@ export const registerFsRoutes = (app, dependencies) => {
885
889
  '.bmp': 'image/bmp',
886
890
  '.avif': 'image/avif',
887
891
  '.pdf': 'application/pdf',
892
+ '.mp4': 'video/mp4',
893
+ '.m4v': 'video/mp4',
894
+ '.mov': 'video/quicktime',
895
+ '.webm': 'video/webm',
896
+ '.ogv': 'video/ogg',
888
897
  };
889
898
  const mimeType = mimeMap[ext] || 'application/octet-stream';
890
899
 
@@ -900,11 +909,16 @@ export const registerFsRoutes = (app, dependencies) => {
900
909
  res.setHeader('Content-Disposition', `attachment; filename="${fallback}"; filename*=UTF-8''${encoded}`);
901
910
  }
902
911
 
903
- const content = await fsPromises.readFile(canonicalPath);
904
912
  res.setHeader('Cache-Control', 'no-store');
905
913
  if (resolved.granted) {
906
914
  res.setHeader('Referrer-Policy', 'no-referrer');
907
915
  }
916
+ if (mimeType.startsWith('video/') || req.headers?.range || req.method === 'HEAD') {
917
+ // Path authorization above remains authoritative; Express owns range parsing,
918
+ // 206/416, stream backpressure and cancellation when the player seeks away.
919
+ return res.type(mimeType).sendFile(canonicalPath, { acceptRanges: true, dotfiles: 'allow', cacheControl: false });
920
+ }
921
+ const content = await fsPromises.readFile(canonicalPath);
908
922
  return res.type(mimeType).send(content);
909
923
  } catch (error) {
910
924
  const err = error;
@@ -1,6 +1,7 @@
1
1
  import { createProxyMiddleware } from 'http-proxy-middleware';
2
2
  import { isSensitiveCredentialResponse } from './credential-boundary.js';
3
3
  import { registerSessionDeliveryRoute } from './session-delivery-runtime.js';
4
+ import { stripSessionMessageNativePayload } from '../session-turn-pages/native-payload.js';
4
5
 
5
6
  import {
6
7
  applyForwardProxyResponseHeaders,
@@ -927,7 +928,7 @@ export const registerOpenCodeProxy = (app, deps) => {
927
928
  }
928
929
 
929
930
  res.setHeader('content-type', result.contentType);
930
- res.json(projectMessagesPayloadForReasoning(result.payload, includeReasoning));
931
+ res.json(projectMessagesPayloadForReasoning(stripSessionMessageNativePayload(result.payload), includeReasoning));
931
932
  } catch (error) {
932
933
  if (isAbortError(error)) {
933
934
  return;
@@ -412,6 +412,19 @@ describe('registerOpenCodeProxy runtime contract gate (ticket 11)', () => {
412
412
  });
413
413
 
414
414
  describe('registerOpenCodeProxy reasoning projection routes', () => {
415
+ it.each(['message', 'context'])('strips native replay fields from %s without hiding reasoning', async (surface) => {
416
+ globalThis.fetch = vi.fn(async () => new Response(JSON.stringify({
417
+ data: [{ id: 'm', type: 'assistant', native: { replay: 'opaque' }, content: [
418
+ { type: 'reasoning', text: 'keep', native: { reasoningEncryptedContent: 'encrypted' } },
419
+ { type: 'tool', native: { itemId: 'upstream' }, input: { native: 'business' } },
420
+ ] }], cursor: { next: 'older' },
421
+ }), { headers: { 'content-type': 'application/json' } }));
422
+ const res = await request(mountProxy()).get(`/api/session/ses_1/${surface}`);
423
+ expect(res.status).toBe(200);
424
+ expect(res.body).toEqual({ data: [{ id: 'm', type: 'assistant', content: [
425
+ { type: 'reasoning', text: 'keep' }, { type: 'tool', input: { native: 'business' } },
426
+ ] }], cursor: { next: 'older' } });
427
+ });
415
428
  it('strips includeReasoning from SSE upstream and drops reasoning events when false', async () => {
416
429
  const upstreamUrls = [];
417
430
  globalThis.fetch = vi.fn(async (url) => {
@@ -4,6 +4,7 @@ import { spawn, type ChildProcess } from 'node:child_process';
4
4
  import crypto from 'node:crypto';
5
5
  import { once } from 'node:events';
6
6
  import { mkdtemp, rm } from 'node:fs/promises';
7
+ import * as fsPromises from 'node:fs/promises';
7
8
  import http from 'node:http';
8
9
  import net from 'node:net';
9
10
  import os from 'node:os';
@@ -25,7 +26,8 @@ import { setRuntimeBearerToken } from '../../../../ui/src/lib/runtime-auth.ts';
25
26
  import { adoptRelayTunnel, deactivateRelayTunnel } from '../../../../ui/src/lib/relay/runtime-tunnel.ts';
26
27
  import { acquireRuntimeImage } from '../../../../ui/src/lib/runtime-image-cache.ts';
27
28
  import { NATIVE_RELAY_ASSET_BRIDGE_KEY } from '../../../../ui/src/lib/relay/native-asset-bridge.ts';
28
- import { resetRelayImageStreamForTests } from '../../../../ui/src/lib/relay/relay-image-stream.ts';
29
+ import { readRelayImageDisplayBlob, resetRelayImageStreamForTests } from '../../../../ui/src/lib/relay/relay-image-stream.ts';
30
+ import { registerFsRoutes } from '../fs/routes.js';
29
31
  import { runtimeFetch } from '../../../../ui/src/lib/runtime-fetch.ts';
30
32
  import { registerTtsRoutes } from '../tts/routes.js';
31
33
  import { createDictationRuntime } from '../dictation/runtime.js';
@@ -156,6 +158,15 @@ const readBody = async (req: http.IncomingMessage) => {
156
158
  };
157
159
 
158
160
  const startOrigin = async () => {
161
+ const mediaDirectory = await mkdtemp(path.join(os.tmpdir(), 'relay-video-'));
162
+ const videoPath = path.join(mediaDirectory, 'clip.mp4');
163
+ await fsPromises.writeFile(videoPath, Buffer.from('0123456789'));
164
+ const rawFiles = express();
165
+ registerFsRoutes({ get: (route: string, handler: express.RequestHandler) => { if (route === '/api/fs/raw') rawFiles.get(route, handler); }, post() {}, put() {} }, {
166
+ fsPromises, os, path, spawn, crypto: globalThis.crypto, normalizeDirectoryPath: (value: string) => value,
167
+ resolveProjectDirectory: async () => ({ directory: mediaDirectory }), buildAugmentedPath: () => '',
168
+ resolveGitBinaryForSpawn: () => 'git', openchamberUserConfigRoot: mediaDirectory,
169
+ });
159
170
  const bearerRequests: string[] = [];
160
171
  const observedOrigins: string[] = [];
161
172
  const sockets = new Set<net.Socket>();
@@ -236,6 +247,7 @@ const startOrigin = async () => {
236
247
  if (pathname === '/api/fs/raw' && req.method === 'GET') {
237
248
  await uiAuth.requireAuth(req, res, () => {
238
249
  const filePath = new URL(req.url ?? '/', 'http://origin').searchParams.get('path');
250
+ if (filePath === videoPath) { rawFiles(req, rawRes); return; }
239
251
  if (filePath !== '/remote/icons-zoom.png' || !req.headers['x-openchamber-relay-connection']) {
240
252
  res.status(404).end(); return;
241
253
  }
@@ -289,7 +301,7 @@ const startOrigin = async () => {
289
301
  await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve));
290
302
  const port = (server.address() as net.AddressInfo).port;
291
303
  return {
292
- port, bearerRequests, observedOrigins, getHostSubscriptions: () => hostSubscriptions,
304
+ port, videoPath, bearerRequests, observedOrigins, getHostSubscriptions: () => hostSubscriptions,
293
305
  stop: async () => {
294
306
  dictation.stop();
295
307
  for (const client of wss.clients) client.terminate();
@@ -297,6 +309,7 @@ const startOrigin = async () => {
297
309
  await Promise.race([new Promise<void>((resolve) => wss.close(() => resolve())), wait(1_000)]);
298
310
  await Promise.race([new Promise<void>((resolve) => server.close(() => resolve())), wait(1_000)]);
299
311
  uiAuth.dispose();
312
+ await rm(mediaDirectory, { recursive: true, force: true });
300
313
  },
301
314
  };
302
315
  };
@@ -386,9 +399,9 @@ describe('private relay compiled-process boundary', () => {
386
399
  vi.stubEnv('OPENCHAMBER_DATA_DIR', path.join(temp, 'host-data'));
387
400
  const binary = path.join(temp, 'openchamber-relay');
388
401
  let relay: Awaited<ReturnType<typeof startCompiledRelay>> | undefined;
389
- let origin: Awaited<ReturnType<typeof startOrigin>> | undefined;
390
- let host: ReturnType<typeof startRelayHost> | undefined;
391
- let client: ReturnType<typeof createRelayTunnelClient> | undefined;
402
+ let origin: Awaited<ReturnType<typeof startOrigin>> | undefined = undefined;
403
+ let host: ReturnType<typeof startRelayHost> | undefined = undefined;
404
+ let client: ReturnType<typeof createRelayTunnelClient> | undefined = undefined;
392
405
  cleanup = async () => {
393
406
  const results = await Promise.allSettled([Promise.resolve(client?.close()), Promise.resolve(host?.stop()), origin?.stop(), stopRelay(relay)]);
394
407
  await rm(temp, { recursive: true, force: true });
@@ -608,9 +621,19 @@ describe('private relay compiled-process boundary', () => {
608
621
  expect(image.url).toMatch(/^openchamber-asset:\/\/v\//);
609
622
  await eventually(() => ended, 'relay image did not finish writing to native bridge');
610
623
  expect(Buffer.concat(received)).toEqual(previewPng);
624
+ const savedImage = await readRelayImageDisplayBlob(image.url);
625
+ expect(Buffer.from(await savedImage!.arrayBuffer())).toEqual(previewPng);
611
626
  image.release();
612
627
  await eventually(() => released, 'native image lease was not released');
613
628
  }
629
+ for (const [range, expectedRange, bytes] of [['bytes=0-1', 'bytes 0-1/10', '01'], ['bytes=7-', 'bytes 7-9/10', '789']]) {
630
+ const response = await runtimeFetch('/api/fs/raw', { query: { path: origin.videoPath }, headers: { Range: range } });
631
+ expect(response.status).toBe(206);
632
+ expect(response.headers.get('content-range')).toBe(expectedRange);
633
+ expect(response.headers.get('accept-ranges')).toBe('bytes');
634
+ expect(response.headers.get('content-type')).toBe('video/mp4');
635
+ expect(await response.text()).toBe(bytes);
636
+ }
614
637
  } finally {
615
638
  resetRelayImageStreamForTests();
616
639
  Reflect.deleteProperty(globalThis, NATIVE_RELAY_ASSET_BRIDGE_KEY);
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Purpose
4
4
 
5
+ HTTP message list/context and exact-message responses strip provider replay
6
+ payloads through the shared `native-payload.js` projection. Only message-level
7
+ `native` (including the `info` carrier of exact records) and `content[]` item-level
8
+ `native` are removed. Tool input/output, metadata, pagination envelopes and cursors
9
+ are opaque and preserved; upstream objects are never mutated. Web proxy and VS
10
+ Code bridge share this helper. Reasoning text and token totals remain governed
11
+ by the existing reasoning projection. SSE events retain their existing payloads.
12
+
5
13
  OpenChamber-owned turn-window pagination and anchor reconcile for session messages.
6
14
 
7
15
  1. **Turn pages** — clients request the last N **authored user turns** (default 3) rather than a raw message count. The host loops OpenCode v2 `message.list` pages (first page `limit` + `order=desc`; continuation `limit` + `cursor` from the previous body `cursor.next` — upstream rejects `order` together with `cursor` with 400) until the turn budget is met or history is exhausted.
@@ -0,0 +1,2 @@
1
+ /** HTTP projection; only message/content-item provider replay fields are removed. */
2
+ export function stripSessionMessageNativePayload(payload: unknown): unknown;
@@ -0,0 +1,38 @@
1
+ /** HTTP-only projection of provider replay data. Business input/output is opaque. */
2
+ const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
3
+
4
+ const withoutNative = (value) => {
5
+ if (!isRecord(value) || !Object.hasOwn(value, 'native')) return value;
6
+ const next = { ...value };
7
+ delete next.native;
8
+ return next;
9
+ };
10
+
11
+ const projectMessage = (value) => {
12
+ if (!isRecord(value)) return value;
13
+ let next = withoutNative(value);
14
+ if (Array.isArray(value.content)) {
15
+ const content = value.content.map(withoutNative);
16
+ if (content.some((item, index) => item !== value.content[index])) next = { ...next, content };
17
+ }
18
+ // Exact responses may already wrap the message in { info, parts }.
19
+ if (isRecord(value.info)) {
20
+ const info = projectMessage(value.info);
21
+ if (info !== value.info) next = { ...next, info };
22
+ }
23
+ return next;
24
+ };
25
+
26
+ /** Strip only message.native and message.content[].native; preserve envelope/cursors. */
27
+ export const stripSessionMessageNativePayload = (payload) => {
28
+ if (Array.isArray(payload)) {
29
+ const next = payload.map(projectMessage);
30
+ return next.some((item, index) => item !== payload[index]) ? next : payload;
31
+ }
32
+ if (!isRecord(payload)) return payload;
33
+ if (Array.isArray(payload.data)) {
34
+ const data = stripSessionMessageNativePayload(payload.data);
35
+ return data === payload.data ? payload : { ...payload, data };
36
+ }
37
+ return projectMessage(payload);
38
+ };
@@ -0,0 +1,34 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { stripSessionMessageNativePayload } from './native-payload.js';
3
+
4
+ describe('HTTP message native payload projection', () => {
5
+ it('strips only provider replay fields, preserving business fields and upstream objects', () => {
6
+ const message = {
7
+ id: 'm', native: { replay: 'x'.repeat(234 * 1024) },
8
+ metadata: { native: 'business' },
9
+ content: [
10
+ { type: 'reasoning', text: 'visible', native: { reasoningEncryptedContent: 'encrypted' } },
11
+ { type: 'tool', native: { itemId: 'provider-item' }, input: { native: 'input' }, output: { native: 'output' } },
12
+ { type: 'text', text: 'keep' },
13
+ ],
14
+ };
15
+ const before = JSON.stringify(message);
16
+ const payload = { data: [message], cursor: { next: 'opaque', native: 'cursor-business' }, native: 'envelope-business' };
17
+ const projected = stripSessionMessageNativePayload(payload);
18
+ expect(projected).toEqual({
19
+ ...payload, data: [{ id: 'm', metadata: { native: 'business' }, content: [
20
+ { type: 'reasoning', text: 'visible' },
21
+ { type: 'tool', input: { native: 'input' }, output: { native: 'output' } },
22
+ { type: 'text', text: 'keep' },
23
+ ] }],
24
+ });
25
+ expect(JSON.stringify(message)).toBe(before);
26
+ expect(projected.cursor).toBe(payload.cursor);
27
+ expect(projected.data[0].content[2]).toBe(message.content[2]);
28
+ expect(JSON.stringify(payload).length - JSON.stringify(projected).length).toBeGreaterThan(234 * 1024);
29
+ expect(stripSessionMessageNativePayload(projected)).toBe(projected);
30
+ expect(stripSessionMessageNativePayload([message])).toEqual(projected.data);
31
+ expect(stripSessionMessageNativePayload({ info: message, parts: [{ input: { native: 'kept' } }] }))
32
+ .toEqual({ info: projected.data[0], parts: [{ input: { native: 'kept' } }] });
33
+ });
34
+ });
@@ -1,5 +1,6 @@
1
1
  import { makeOpenCodeV2Client } from '../opencode/v2-client.js';
2
2
  import { projectMessageSummaryDiffCounts } from '../event-stream/diff-summary.js';
3
+ import { stripSessionMessageNativePayload } from './native-payload.js';
3
4
  import {
4
5
  projectMessagesPayloadForReasoning,
5
6
  readIncludeReasoningQuery,
@@ -718,7 +719,7 @@ export const registerSessionTurnPageRoutes = (app, dependencies = {}) => {
718
719
  });
719
720
  const includeReasoning = readIncludeReasoningQuery(req.query);
720
721
  return res.status(200).json(
721
- projectMessagesPayloadForReasoning(projectExactMessagePayload(payload), includeReasoning),
722
+ projectMessagesPayloadForReasoning(projectExactMessagePayload(stripSessionMessageNativePayload(payload)), includeReasoning),
722
723
  );
723
724
  } catch (error) {
724
725
  if (isAbortError(error) || error?.code === 'aborted') {
@@ -1061,6 +1061,24 @@ const EXACT_MESSAGE_ROUTE = '/api/session/:sessionID/message/:messageID';
1061
1061
  const CHANGES_ROUTE = '/api/openchamber/sessions/:sessionID/changes';
1062
1062
 
1063
1063
  describe('registerSessionTurnPageRoutes — exact message GET', () => {
1064
+ it('removes message/content native fields at the exact serialization boundary', async () => {
1065
+ const payload = { id: 'msg_1', type: 'assistant', native: { replay: 'opaque' }, content: [
1066
+ { type: 'reasoning', text: 'keep', native: { reasoningEncryptedContent: 'encrypted' } },
1067
+ { type: 'tool', native: { itemId: 'upstream' }, input: { native: 'business' } },
1068
+ ] };
1069
+ const { app, route } = registry();
1070
+ registerSessionTurnPageRoutes(app, {
1071
+ sessionTurnPageService: { loadPage: vi.fn() },
1072
+ fetchExactMessage: async () => payload,
1073
+ });
1074
+ const res = response();
1075
+ await route('GET', EXACT_MESSAGE_ROUTE)({ params: { sessionID: 'ses_1', messageID: 'msg_1' }, query: {}, headers: {} }, res);
1076
+ expect(res.statusCode).toBe(200);
1077
+ expect(res.body).toEqual({ id: 'msg_1', type: 'assistant', content: [
1078
+ { type: 'reasoning', text: 'keep' }, { type: 'tool', input: { native: 'business' } },
1079
+ ] });
1080
+ expect(payload).toHaveProperty('native');
1081
+ });
1064
1082
  it('registers GET /api/session/:sessionID/message/:messageID', () => {
1065
1083
  const { app, route } = registry();
1066
1084
  registerSessionTurnPageRoutes(app, {
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{n as r}from"./vendor-react-BP2cRVqX.js";import{r as i}from"./button-CWSs9Baz.js";import{n as a}from"./rasterizePng-CpK-xCkB.js";import{n as o,t as s}from"./vendor-dicebear-core-CV95S5Pg.js";import{n as c,t as l}from"./vendor-dicebear-styles-7lEG-JsF.js";import{t as u}from"./dualLimitLru-D8Sphgua.js";import{t as d}from"./useThemeSystem-8jhE4Zyk.js";var f=e(t(),1),p=r(),m={background:`#c1f2c4`},h={assistant:new o(c),agent:new o(l)},g=new u({maxEntries:128,maxBytes:1048576});function _(e,t,n=!1,r){let i=e===`agent`?t?.trim().toLowerCase()||`default`:t||`default`,a=e===`agent`?(r??m).background.replace(`#`,``):`00000000`,o=JSON.stringify([e,i,a,e===`assistant`&&n]),c=g.get(o);if(c!==void 0)return c;let l;return l=e===`agent`?new s(h.agent,{seed:i,size:128,idRandomization:!1,borderRadius:0,backgroundColor:[a]}).toDataUri():new s(h.assistant,{seed:i,size:128,scale:1.2,backgroundColor:[`00000000`],idRandomization:!1,animationVariant:n?`fastest`:`none`}).toDataUri(),g.set(o,l,(o.length+l.length)*2),l}var v=(e,t)=>({background:t(e)||m.background}),y=e=>{let t=(0,p.c)(5),n;t[0]===e?n=t[1]:(n=a(e),t[0]=e,t[1]=n);let r=n.var,i=d()?.currentTheme.colors,o;if(t[2]!==r||t[3]!==i){let e=i?{"--status-success":i.status.success,"--status-info":i.status.info,"--status-warning":i.status.warning,"--syntax-keyword":i.syntax.base.keyword,"--syntax-type":i.syntax.base.type,"--syntax-function":i.syntax.base.function,"--syntax-number":i.syntax.base.number,"--syntax-variable":i.syntax.base.variable}:{};o=v(r,t=>e[t]??``),t[2]=r,t[3]=i,t[4]=o}else o=t[4];return o},b=n(),x=f.memo(e=>{let t=(0,p.c)(33),{name:n,kind:r,animated:o,emoji:s,size:c,shape:l,className:u,label:d}=e,f=r===void 0?`agent`:r,m=o!==void 0&&o,h=c===void 0?16:c,g=l===void 0?`rounded`:l,v=a(n),x=y(n),S;bb0:{if(s){S=void 0;break bb0}if(f!==`agent`){let e;t[0]!==m||t[1]!==f||t[2]!==n?(e=_(f,n,m),t[0]=m,t[1]=f,t[2]=n,t[3]=e):e=t[3],S=e;break bb0}let e;t[4]!==m||t[5]!==f||t[6]!==n||t[7]!==x?(e=_(f,n,m,x),t[4]=m,t[5]=f,t[6]=n,t[7]=x,t[8]=e):e=t[8],S=e}let C=S,w=i(`inline-flex aspect-square shrink-0 overflow-clip`,g===`square`?`rounded-none`:g===`circle`?`rounded-full`:`rounded-sm`,s&&`items-center justify-center select-none`,v.class,u),T=`calc(${h}px * var(--dpt-n, 1))`,E=`calc(${h}px * var(--dpt-n, 1))`,D=`calc(${h}px * var(--dpt-n, 1))`,O=`calc(${h}px * var(--dpt-n, 1))`,k=`calc(${h}px * var(--dpt-n, 1))`,A=`calc(${h}px * var(--dpt-n, 1))`,j=`var(${v.var})`,M;t[9]===s?M=t[10]:(M=s?{display:`inline-flex`,alignItems:`center`,justifyContent:`center`}:null,t[9]=s,t[10]=M);let N;t[11]!==O||t[12]!==k||t[13]!==A||t[14]!==j||t[15]!==M||t[16]!==T||t[17]!==E||t[18]!==D?(N={width:T,minWidth:E,maxWidth:D,height:O,minHeight:k,maxHeight:A,color:j,...M},t[11]=O,t[12]=k,t[13]=A,t[14]=j,t[15]=M,t[16]=T,t[17]=E,t[18]=D,t[19]=N):N=t[19];let P=d?`img`:void 0,F=!d||void 0,I;t[20]!==C||t[21]!==s||t[22]!==h?(I=s?(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`flex h-full w-full items-center justify-center leading-none`,style:{fontSize:`calc(${h*.75}px * var(--dpt-n, 1))`,lineHeight:1,transform:`translateY(0.06em)`},children:s}):(0,b.jsx)(`img`,{src:C,alt:``,draggable:!1,className:`block h-full w-full max-h-full max-w-full object-contain`,"aria-hidden":`true`}),t[20]=C,t[21]=s,t[22]=h,t[23]=I):I=t[23];let L;return t[24]!==f||t[25]!==d||t[26]!==g||t[27]!==N||t[28]!==P||t[29]!==F||t[30]!==I||t[31]!==w?(L=(0,b.jsx)(`span`,{className:w,style:N,"data-agent-avatar":``,"data-avatar-kind":f,"data-agent-avatar-shape":g,role:P,"aria-label":d,"aria-hidden":F,children:I}),t[24]=f,t[25]=d,t[26]=g,t[27]=N,t[28]=P,t[29]=F,t[30]=I,t[31]=w,t[32]=L):L=t[32],L});export{y as n,_ as r,x as t};
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-xTzsvgSH.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-fetch-WgH0pROs.js","assets/runtime-auth-BpCQ-dPr.js","assets/runtime-switch-CMiMO5Yj.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-CEqU9Ujv.js","assets/vendor-zustand-o69pgTEK.js","assets/vendor-react-BP2cRVqX.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-CWSs9Baz.js","assets/persistence-BKszKaoQ.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/store-CG7Ytsg9.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-8jhE4Zyk.js","assets/Icon-BCFeHDWx.js","assets/dialog-BMa16qrs.js","assets/image-loading-Bj11k4gM.js","assets/fileQueries-DVpZC5ha.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/useRuntimeAPIs-Cx8S1HLz.js","assets/relay-image-stream-SV0lH6aG.js","assets/image-loading-CObM4tcX.css","assets/MobileWindowStack-DGLdgoGr.js","assets/appThemeRegistry-yPeRO8pM.js","assets/platform-CgwxwfA4.js","assets/vendor-opencode-client-MF2GBrFx.js","assets/useMobileNavigationStore-B4XAjLFo.js","assets/vendor-sonner-ZS8XIOVl.js","assets/useAssistantUIStore-OyPm_4M_.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/rasterizePng-CpK-xCkB.js","assets/MarkdownRenderer-CT4442A0.js","assets/markdownHeightCache-DXM_5jTe.js","assets/dualLimitLru-D8Sphgua.js","assets/markdown-worker-DFNZ3KJ_.js","assets/useEffectiveDirectory-A96lQo7K.js","assets/markdownTheme-CV7_0QAL.js","assets/ImageLoadingPlaceholder-DEpMJXzV.js","assets/useWorkerHighlightedLines-POG4Xahb.js","assets/tooltip-CV6dvLBp.js","assets/vendor-tanstack-react-virtual-B_EO--9t.js","assets/ToolOutputDialog-DesCcdFD.css"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{c as n,i as r,n as i}from"./runtime-switch-CMiMO5Yj.js";import{$ as a,G as o,K as s,Q as c,Y as l,et as u,ht as d,nt as f,st as p}from"./persistence-BKszKaoQ.js";import{a as m}from"./vendor-zustand-o69pgTEK.js";import{it as h,rt as g}from"./vendor-base-ui-CdzJ6My_.js";import{n as _,r as v}from"./platform-CgwxwfA4.js";import{n as y}from"./useUIStore-CEqU9Ujv.js";import{n as b}from"./vendor-react-BP2cRVqX.js";import{o as x}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{s as S}from"./vendor-tanstack-react-query-CdqCAt40.js";import{r as C}from"./vendor-sonner-ZS8XIOVl.js";import{a as w,d as T,f as E,i as D,n as O,r as k}from"./vendor-reactuses-core-BpfIZ1tg.js";import{f as A,r as j,t as M}from"./button-CWSs9Baz.js";import{a as N,n as P}from"./MobileShareBridge-BVTR53DJ.js";import{D as F,E as I,F as L,N as R,_ as z,b as B,c as V,d as H,i as U,n as ee,o as W,p as te,r as ne,t as re,u as G,v as ie}from"./MobileDetailNavigation-DshnlWA6.js";import{Cn as ae,Jt as K,Mr as oe,Nr as se,So as q,ct as ce,o as le}from"./useMobileNavigationStore-B4XAjLFo.js";import{i as ue,n as J,r as de}from"./useAssistantUIStore-OyPm_4M_.js";import{t as Y}from"./AgentAvatar-qLxaEaDh.js";import{n as X}from"./Icon-BCFeHDWx.js";import{a as fe,i as pe,n as me,o as he,r as ge,t as _e}from"./dialog-BMa16qrs.js";import{i as ve}from"./OverlayScrollbar-BY5HaNrb.js";import{c as ye,l as be}from"./image-loading-Bj11k4gM.js";import{n as xe}from"./textarea-D_tvJ-Lw.js";import{C as Se,D as Z,E as Ce,T as we,a as Te,b as Ee,d as De,f as Oe,h as ke,i as Ae,l as je,m as Me,n as Ne,p as Pe,r as Fe,s as Ie,t as Le,u as Re}from"./sessionChangeSummary-hheGPvDz.js";import{o as ze,t as Be}from"./vendor-framer-motion-D-oiwsxL.js";import{a as Ve,n as He,r as Ue,t as We}from"./fileMentionTouchSelection-Dq7j3zBe.js";import{o as Ge,t as Ke}from"./MarkdownRenderer-CT4442A0.js";import{t as qe}from"./ImageLoadingPlaceholder-DEpMJXzV.js";import{t as Je}from"./LoadingImage-BAT9D9wN.js";import{t as Ye}from"./vendor-motion-88WXBOBf.js";import{a as Xe,c as Ze,l as Qe,o as $e,s as et,t as tt}from"./scheduledTaskNavigation-DQcLqQ52.js";import{a as nt,t as rt}from"./sessionLookup-C5W6GTm9.js";import{i as it,n as at,r as ot}from"./assistant-attachment-cache-B2UAUHUZ.js";var st=b();function ct(e){return[...e].sort((e,t)=>{let n=Number((t.unreadCount??0)>0)-Number((e.unreadCount??0)>0);if(n)return n;let r=e.latestMessagePreview?.createdAt??-1/0,i=t.latestMessagePreview?.createdAt??-1/0;return r===i?0:i-r})}var Q=t(h(),1),$=g();function lt({snapshot:e,rowClassName:t}){let{t:n}=A(),[r,i]=Q.useState(!1),a=Q.useRef(!1),o=O(async()=>{if(!a.current){a.current=!0,i(!0);try{(await G(e)).failed&&C.error(n(`assistants.unread.markAllFailed`))}catch{C.error(n(`assistants.unread.markAllFailed`))}finally{a.current=!1,i(!1)}}});return e.assistants.some(e=>(e.unreadCount??0)>0)?(0,$.jsx)(`div`,{className:t,children:(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`xs`,onClick:o,className:`max-w-full whitespace-normal text-right`,disabled:r||!e.assistants.some(e=>(e.unreadCount??0)>0&&e.readTip),"aria-busy":r,children:n(`assistants.unread.markAll`)})}):null}var ut=m(e=>({workingByID:{},setWorking:(t,n)=>e(e=>({workingByID:{...e.workingByID,[t]:n}}))})),dt=({sending:e=!1,processing:t=!1,serverWorking:n=!1})=>e||t||n,ft=(e,t)=>{let n=(0,st.c)(5),r=t!==void 0&&t,i;n[0]===e?i=n[1]:(i=t=>!!t.workingByID[e],n[0]=e,n[1]=i);let a=ut(i),o;return n[2]!==a||n[3]!==r?(o=dt({processing:a,serverWorking:r}),n[2]=a,n[3]=r,n[4]=o):o=n[4],o},pt=e=>{let t=(0,st.c)(21),{name:n,avatarSeed:r,size:i,label:a,working:o,showWorkingDot:s,className:c}=e,l=i===void 0?24:i,u=s===void 0||s,{t:d}=A(),f;t[0]!==n||t[1]!==o?(f=e=>o!==void 0&&!!e.workingByID[n],t[0]=n,t[1]=o,t[2]=f):f=t[2];let p=ut(f),m=!!(o||p),h=`calc(${l}px * var(--dpt-n, 1))`,g;t[3]===c?g=t[4]:(g=j(`relative inline-block shrink-0 align-middle leading-none`,c),t[3]=c,t[4]=g);let _;t[5]===h?_=t[6]:(_={width:h,minWidth:h,maxWidth:h,height:h,minHeight:h,maxHeight:h},t[5]=h,t[6]=_);let v=r??n,y;t[7]!==m||t[8]!==a||t[9]!==l||t[10]!==v?(y=(0,$.jsx)(Y,{kind:`assistant`,animated:m,name:v,size:l,label:a,shape:`rounded`,className:`rounded-[0.5rem]`}),t[7]=m,t[8]=a,t[9]=l,t[10]=v,t[11]=y):y=t[11];let b;t[12]!==u||t[13]!==d||t[14]!==o?(b=o&&u?(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2.5 translate-x-0.5 translate-y-0.5 rounded-full bg-[var(--status-success)] ring-2 ring-background`,"data-assistant-working-dot":``,"aria-label":d(`assistants.contact.working`)}):null,t[12]=u,t[13]=d,t[14]=o,t[15]=b):b=t[15];let x;return t[16]!==g||t[17]!==_||t[18]!==y||t[19]!==b?(x=(0,$.jsxs)(`span`,{className:g,style:_,"data-assistant-working-avatar":``,children:[y,b]}),t[16]=g,t[17]=_,t[18]=y,t[19]=b,t[20]=x):x=t[20],x},mt=e=>{for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n.parts.some(F)&&Number.isFinite(new Date(n.createdAt).getTime()))return{timestamp:n.createdAt,empty:!1}}return{timestamp:void 0,empty:e.generation>=0&&e.olderComplete&&!e.hasMessageGap}},ht=(e,t)=>{let n=(0,st.c)(5),r;n[0]!==e||n[1]!==t?(r=ne(e,t),n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;return n[3]===r?i=n[4]:(i={...r,enabled:!1,select:mt},n[3]=r,n[4]=i),S(i)},gt=3e5,_t=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();function vt(e){let t=new Map,n=null;for(let r of e){if(!(r.status===`error`||r.status===`failed`||r.parts.some(e=>e.type!==`text`||e.text.trim()&&!e.text.trim().startsWith(`oc.settle.`))))continue;let e=new Date(r.createdAt);Number.isFinite(e.getTime())&&((!n||!_t(n,e)||e.getTime()-n.getTime()>gt)&&t.set(r.messageID,r.createdAt),n=e)}return t}function yt(e,t,n){let r=new Intl.DateTimeFormat(e,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),i=new Intl.DateTimeFormat(e,{month:`long`,day:`numeric`}),a=new Intl.DateTimeFormat(e,{year:`numeric`,month:`long`,day:`numeric`});return e=>{let o=new Date(e);return`${_t(o,n)?t:(o.getFullYear()===n.getFullYear()?i:a).format(o)} ${r.format(o)}`}}var bt=Q.memo(e=>{let t=(0,st.c)(17),{assistantID:n,serverWorking:r,lastContactAt:i}=e,{t:a,locale:o}=A(),s=ft(n,r),c=ht(n,be()),l;t[0]!==c||t[1]!==i?(l=i!==void 0&&Number.isFinite(new Date(i).getTime())?i:c.data?.timestamp,t[0]=c,t[1]=i,t[2]=l):l=t[2];let u=l,d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=new Date().toDateString(),t[3]=d):d=t[3];let f=d,p;t[4]===a?p=t[5]:(p=a(`common.date.today`),t[4]=a,t[5]=p);let m=p,h;bb0:{if(u===void 0){h=null;break bb0}let e;t[6]!==o||t[7]!==u||t[8]!==m?(e=yt(o,m,new Date(f))(u),t[6]=o,t[7]=u,t[8]=m,t[9]=e):e=t[9],h=e}let g=h,_;t[10]!==c||t[11]!==g||t[12]!==a||t[13]!==s?(_=s?a(`assistants.conversation.typing`):g?a(`assistants.conversation.lastContact`,{time:g}):c.data?.empty?a(`assistants.conversation.neverContacted`):c.isError?a(`assistants.contact.loadFailed`):a(`common.loading`),t[10]=c,t[11]=g,t[12]=a,t[13]=s,t[14]=_):_=t[14];let v=_,y;return t[15]===v?y=t[16]:(y=(0,$.jsx)(`span`,{className:`mt-1 block truncate typography-micro font-normal leading-4 text-muted-foreground/70`,"aria-live":`polite`,title:v,children:v}),t[15]=v,t[16]=y),y});function xt(e){let t=(0,st.c)(12),{assistantID:n,position:a}=e,o=Q.useRef(null),s=Q.useRef(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={busy:!1,done:!1,retryAt:0},t[0]=c):c=t[0];let l=Q.useRef(c),[u]=Q.useState(Dt),d;t[1]!==n||t[2]!==a||t[3]!==u?(d=()=>{let e=o.current;if(!e||!s.current||l.current.busy||l.current.done||Date.now()<l.current.retryAt||u.transport!==r()||u.generation!==i()||document.visibilityState!==`visible`||(_()?!document.documentElement.classList.contains(`oc-native-app-active`):!document.hasFocus())||e.parentElement?.closest(`[inert], [aria-hidden="true"]`))return;let t=e.closest(`[data-assistant-contact-transcript]`);if(!t||t.scrollHeight-t.scrollTop-t.clientHeight>2)return;let c=e.getBoundingClientRect(),d=t.getBoundingClientRect(),f=window.visualViewport,p=f?.offsetTop??0,m=p+(f?.height??window.innerHeight);c.height<=0||c.width<=0||c.bottom>Math.min(d.bottom,m)||c.top<Math.max(d.top,p)||c.right<=Math.max(d.left,0)||c.left>=Math.min(d.right,window.innerWidth)||(l.current.busy=!0,H(n,a).then(()=>{l.current.done=!0}).catch(()=>{l.current.retryAt=Date.now()+15e3}).finally(()=>{l.current.busy=!1}))},t[1]=n,t[2]=a,t[3]=u,t[4]=d):d=t[4];let f=O(d),p;t[5]===f?p=t[6]:(p=e=>{s.current=e.some(Et),f()},t[5]=f,t[6]=p);let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m={threshold:1},t[7]=m):m=t[7],D(o,O(p),m),k(`visibilitychange`,f,Tt),k(`focus`,f,wt),k(`resize`,f,Ct);let h,g;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>o.current?.closest(`[data-assistant-contact-transcript]`),g={passive:!0},t[8]=h,t[9]=g):(h=t[8],g=t[9]),k(`scroll`,f,h,g);let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v={attributes:!0,attributeFilter:[`class`]},t[10]=v):v=t[10],T(f,St,v),w(f,15e3);let y;return t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{ref:o,"aria-hidden":`true`,className:`absolute bottom-0 left-0 block h-px w-px`,"data-assistant-read-marker":``}),t[11]=y):y=t[11],y}function St(){return document.documentElement}function Ct(){return window.visualViewport}function wt(){return window}function Tt(){return document}function Et(e){return e.isIntersecting&&e.intersectionRatio===1}function Dt(){return{transport:r(),generation:i()}}var Ot=()=>{},kt=Q.memo(Z),At=e=>e?.directories.flatMap(({directory:e,sessions:t})=>e?t.filter(e=>!e.time.archived).map(t=>({...t,directory:e||t.location?.directory||t.directory||``})).filter(e=>e.directory.length>0):[])??null,jt=Q.forwardRef(({query:e,isMobile:t,listId:n,onHighlightChange:r,onSelect:i,onClose:a},o)=>{let{t:s}=A(),c=be(),l=S({...se(c),select:At}),u=Q.useMemo(()=>ce({sessions:l.data??[],currentSessionId:null,searchQuery:e}),[l.data,e]),[d,f]=Q.useState({query:e,index:0}),p=Math.min(d.query===e?d.index:0,Math.max(0,u.length-1)),m=Q.useRef(null),h=Q.useRef([]),g=Q.useMemo(We,[]);k(`pointerdown`,e=>{e.target instanceof Node&&!m.current?.contains(e.target)&&a()},void 0,{capture:!0}),Q.useLayoutEffect(()=>{h.current[p]?.scrollIntoView?.({block:`nearest`})},[p]),Q.useLayoutEffect(()=>{r(u.length?`${n}-${p}`:void 0)},[p,n,u.length,r]);let _=O(t=>{if(t===`Escape`){a();return}u.length&&(t===`ArrowDown`&&f({query:e,index:(p+1)%u.length}),t===`ArrowUp`&&f({query:e,index:(p-1+u.length)%u.length}),(t===`Enter`||t===`Tab`)&&i(u[p]))});return Q.useImperativeHandle(o,()=>({keyDown:_}),[_]),(0,$.jsxs)(He,{ref:m,isMobile:t,className:`max-w-[640px] max-h-64`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-3 py-1`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`assistants.contact.sessionMention.scope`)}),(0,$.jsx)(M,{type:`button`,size:`xs`,variant:`ghost`,"aria-label":s(`dialog.common.actions.close`),onClick:a,children:(0,$.jsx)(X,{name:`close`,className:`size-4`})})]}),l.isPending?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(`common.loading`)}):null,l.isError?(0,$.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 typography-meta text-[var(--status-error)]`,children:[s(`assistants.contact.sessionMention.loadFailed`),(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void l.refetch(),children:s(`chat.history.retry`)})]}):null,l.isSuccess&&!u.length?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(l.data===null?`common.unavailable`:`sessions.sidebar.empty.noMatches.title`)}):null,(0,$.jsx)(xe,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsx)(`div`,{id:n,role:`listbox`,"aria-label":s(`chat.fileMentionAutocomplete.groups.sessions`),className:`p-1.5`,children:u.map((r,a)=>(0,$.jsxs)(`div`,{id:`${n}-${a}`,role:`option`,"aria-selected":a===p,ref:e=>{h.current[a]=e},className:j(`flex min-h-10 cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 typography-ui-label`,Ue(t,a===p)),onMouseDown:e=>e.preventDefault(),onMouseMove:()=>f({query:e,index:a}),onPointerDown:e=>{e.pointerType===`touch`&&g.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&g.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&g.pointerUp(()=>i(r))&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>g.pointerCancel(),onClick:()=>g.click(()=>i(r)),children:[(0,$.jsx)(X,{name:`chat-thread`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium leading-5`,title:r.title,children:r.title||s(`chat.fileMentionAutocomplete.untitledSession`)}),(0,$.jsx)(`div`,{className:`truncate text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,title:r.directory,children:r.directory})]})]},`${r.directory}:${r.id}`))})}),t?null:(0,$.jsx)(`div`,{className:`mx-1.5 shrink-0 border-t px-1.5 py-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`chat.autocomplete.keyboardHint`)})]})}),Mt=e=>{let t=(0,st.c)(120),n,r,i,f,p;t[0]===e?(n=t[1],r=t[2],i=t[3],f=t[4],p=t[5]):({active:n,working:p,onChange:r,onVoiceSend:i,...f}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=f,t[5]=p);let m=p!==void 0&&p,{t:h}=A(),g=Q.useRef(null),_=n&&!!f.isMobile&&!!i,v;t[6]===_?v=t[7]:(v={available:_},t[6]=_,t[7]=v);let{enabled:y,hint:b,onHintChange:x}=Ce(v),S;t[8]!==b||t[9]!==f.placeholder||t[10]!==h?(S=b===null?f.placeholder:h(b===`recording`?`chat.dictation.releaseSend`:b===`cancelling`?`chat.dictation.releaseCancel`:b===`editing`?`chat.dictation.releaseEdit`:`chat.dictation.processing`),t[8]=b,t[9]=f.placeholder,t[10]=h,t[11]=S):S=t[11];let C=S,w;t[12]===f.value?w=t[13]:(w=()=>({canonical:f.value,document:l(f.value,new Map)}),t[12]=f.value,t[13]=w);let[T,E]=Q.useState(w),D;t[14]!==T.canonical||t[15]!==T.document||t[16]!==f.value?(D=T.canonical===f.value?T.document:l(f.value,new Map),t[14]=T.canonical,t[15]=T.document,t[16]=f.value,t[17]=D):D=t[17];let k=D,[M,N]=Q.useState(0),[P,F]=Q.useState(!0),[I,L]=Q.useState(!1),[R,z]=Q.useState(),B=Q.useRef(null),V=Q.useRef(null),H=Q.useRef(null),U=Q.useRef(null),ee;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ee=Re(),t[18]=ee):ee=t[18];let W=Q.useRef(ee),te=Q.useId(),ne;t[19]!==n||t[20]!==I||t[21]!==M||t[22]!==P||t[23]!==k.text||t[24]!==f.disabled||t[25]!==f.pending?(ne=n&&!f.pending&&!f.disabled&&!P&&!I?Ve({text:k.text,cursor:M}):null,t[19]=n,t[20]=I,t[21]=M,t[22]=P,t[23]=k.text,t[24]=f.disabled,t[25]=f.pending,t[26]=ne):ne=t[26];let re=ne,G=re?.kind===`mention`?re:null,ie;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>{U.current!==null&&(B.current?.focus({preventScroll:!0}),B.current?.setSelectionRange(U.current,U.current),U.current=null)},t[27]=ie):ie=t[27];let ae;t[28]===k?ae=t[29]:(ae=[k],t[28]=k,t[29]=ae),Q.useLayoutEffect(ie,ae);let K;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>F(!0),t[30]=K):K=t[30];let oe=O(K),se;t[31]!==I||t[32]!==M||t[33]!==k||t[34]!==r?(se=(e,t,n)=>{let i=n===void 0||n,a=u(e);a.ok&&(i&&(W.current=De(W.current,{before:je(k,[],{start:B.current?.selectionStart??M,end:B.current?.selectionEnd??M}),after:je(e,[],{start:t,end:t})})),I||(U.current=t),N(t),E({canonical:a.text,document:e}),r(a.text))},t[31]=I,t[32]=M,t[33]=k,t[34]=r,t[35]=se):se=t[35];let q=O(se),ce;t[36]!==q||t[37]!==k||t[38]!==G||t[39]!==h?(ce=e=>{if(!G)return;let t=e.title||h(`chat.fileMentionAutocomplete.untitledSession`),n=s(k,G.tokenStart,G.tokenEnd,{id:`session:${e.id}:${crypto.randomUUID()}`,kind:`session`,sessionId:e.id,display:d({trigger:`@`,icon:`chat-thread`,label:t})},{inlineBoundaries:!0,padDocumentEdges:!0}),r=n.caret+ +(n.document.text[n.caret]===` `);F(!0),q(n.document,r)},t[36]=q,t[37]=k,t[38]=G,t[39]=h,t[40]=ce):ce=t[40];let le=O(ce),ue;t[41]!==n||t[42]!==q||t[43]!==k||t[44]!==f.disabled||t[45]!==f.pending?(ue=e=>{if(!n||f.pending||f.disabled||!e.trim())return;let t=k.text?`${k.text} ${e}`:e,r=c(k,t,t.length,t.length);q(r.document,r.caret),F(!0)},t[41]=n,t[42]=q,t[43]=k,t[44]=f.disabled,t[45]=f.pending,t[46]=ue):ue=t[46];let J=O(ue),de;t[47]!==n||t[48]!==k.text||t[49]!==J||t[50]!==r||t[51]!==i||t[52]!==f.disabled||t[53]!==f.pending?(de=e=>{if(!(!n||f.pending||f.disabled||!e.trim())){if(k.text){J(e);return}r(e),i?.(e)}},t[47]=n,t[48]=k.text,t[49]=J,t[50]=r,t[51]=i,t[52]=f.disabled,t[53]=f.pending,t[54]=de):de=t[54];let Y=O(de),X;t[55]!==q||t[56]!==k?(X=(e,t)=>{let n=e.currentTarget;if(n.selectionStart===n.selectionEnd||!e.clipboardData||!k.references.some(e=>e.start<n.selectionEnd&&e.end>n.selectionStart))return;let r=o(n.selectionStart,n.selectionEnd,k.references)??{start:n.selectionStart,end:n.selectionEnd},i=u({text:k.text.slice(r.start,r.end),references:k.references.filter(e=>e.start>=r.start&&e.end<=r.end).map(e=>({...e,start:e.start-r.start,end:e.end-r.start}))});if(i.ok&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,i.text),t)){let e=c(k,k.text.slice(0,r.start)+k.text.slice(r.end),r.start,r.start);q(e.document,e.caret)}},t[55]=q,t[56]=k,t[57]=X):X=t[57];let fe=O(X),pe;t[58]!==k.references||t[59]!==k.text?(pe=ke(k.text,k.references.map(Nt))?.map(Pt),t[58]=k.references,t[59]=k.text,t[60]=pe):pe=t[60];let me=pe,he=y&&k.text.length===0?`true`:void 0,ge;t[61]!==y||t[62]!==J||t[63]!==f.disabled||t[64]!==f.pending||t[65]!==Y||t[66]!==x?(ge=y&&(0,$.jsx)(kt,{containerRef:g,disabled:!!(f.pending||f.disabled),onInsert:J,onSend:Y,onRelease:Ot,onHintChange:x}),t[61]=y,t[62]=J,t[63]=f.disabled,t[64]=f.pending,t[65]=Y,t[66]=x,t[67]=ge):ge=t[67];let _e=k.text,ve=f.pending||m,ye=f.pending===!0,be=f.layout===`inline`?`py-3 leading-6`:`pt-4 pb-2`,xe;t[68]!==f.textLayoutClassName||t[69]!==be?(xe=j(`whitespace-pre-wrap break-words overflow-hidden px-3 typography-markdown md:typography-ui-label`,be,f.textLayoutClassName),t[68]=f.textLayoutClassName,t[69]=be,t[70]=xe):xe=t[70];let Z;t[71]!==q||t[72]!==k?(Z=(e,t)=>{let n=c(k,e,t?.target.selectionStart??e.length,t?.target.selectionEnd??e.length);q(n.document,n.caret),F(t?.nativeEvent?.inputType===`insertFromPaste`)},t[71]=q,t[72]=k,t[73]=Z):Z=t[73];let we=G?te:void 0,Te=G?R:void 0,Ae;t[74]===f.textareaProps?Ae=t[75]:(Ae=e=>{f.textareaProps?.onScroll?.(e),V.current&&(V.current.scrollTop=e.currentTarget.scrollTop,V.current.scrollLeft=e.currentTarget.scrollLeft)},t[74]=f.textareaProps,t[75]=Ae);let Me,Ne;t[76]!==fe||t[77]!==f.textareaProps?(Me=e=>{f.textareaProps?.onCopy?.(e),e.defaultPrevented||fe(e,!1)},Ne=e=>{f.textareaProps?.onCut?.(e),e.defaultPrevented||fe(e,!0)},t[76]=fe,t[77]=f.textareaProps,t[78]=Me,t[79]=Ne):(Me=t[78],Ne=t[79]);let Fe;t[80]===f.textareaProps?Fe=t[81]:(Fe=e=>{N(e.currentTarget.selectionStart),f.textareaProps?.onSelect?.(e)},t[80]=f.textareaProps,t[81]=Fe);let Ie,Le;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=()=>{L(!0)},Le=e=>{L(!1),N(e.currentTarget.selectionStart)},t[82]=Ie,t[83]=Le):(Ie=t[82],Le=t[83]);let ze;t[84]!==q||t[85]!==I||t[86]!==k||t[87]!==G||t[88]!==f.textareaProps?(ze=e=>{if(f.textareaProps?.onKeyDown?.(e),!(e.defaultPrevented||Se(e))){if(I){e.key===`Enter`&&e.preventDefault();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`){let t=e.shiftKey?Oe(W.current,k):Pe(W.current,k);t&&(e.preventDefault(),W.current=t.history,q(t.snapshot.document,t.snapshot.selection.end,!1),F(!0));return}if(e.key===`Backspace`||e.key===`Delete`){let t=a(k,{key:e.key,selectionStart:e.currentTarget.selectionStart,selectionEnd:e.currentTarget.selectionEnd,altKey:e.altKey});if(t){e.preventDefault(),q(t.document,t.caret),F(!0);return}}G&&[`ArrowDown`,`ArrowUp`,`Enter`,`Tab`,`Escape`].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),H.current?.keyDown(e.key))}},t[84]=q,t[85]=I,t[86]=k,t[87]=G,t[88]=f.textareaProps,t[89]=ze):ze=t[89];let Be;t[90]!==f.textareaProps||t[91]!==we||t[92]!==Te||t[93]!==Ae||t[94]!==Me||t[95]!==Ne||t[96]!==Fe||t[97]!==ze?(Be={...f.textareaProps,"aria-controls":we,"aria-activedescendant":Te,"aria-autocomplete":`list`,onScroll:Ae,onCopy:Me,onCut:Ne,onSelect:Fe,onCompositionStart:Ie,onCompositionEnd:Le,onKeyDown:ze},t[90]=f.textareaProps,t[91]=we,t[92]=Te,t[93]=Ae,t[94]=Me,t[95]=Ne,t[96]=Fe,t[97]=ze,t[98]=Be):Be=t[98];let He;t[99]!==oe||t[100]!==te||t[101]!==G||t[102]!==f.isMobile||t[103]!==le?(He=G?(0,$.jsx)(jt,{ref:H,query:G.query,isMobile:f.isMobile??!1,listId:te,onHighlightChange:z,onSelect:le,onClose:oe}):null,t[99]=oe,t[100]=te,t[101]=G,t[102]=f.isMobile,t[103]=le,t[104]=He):He=t[104];let Ue;t[105]!==k.text||t[106]!==me||t[107]!==C||t[108]!==f||t[109]!==ve||t[110]!==ye||t[111]!==xe||t[112]!==Z||t[113]!==Be||t[114]!==He?(Ue=(0,$.jsx)(Ee,{...f,value:_e,pending:ve,placeholder:C,disableInputWhilePending:ye,inputRef:B,highlightedContent:me,highlightRef:V,textLayoutClassName:xe,onChange:Z,textareaProps:Be,children:He}),t[105]=k.text,t[106]=me,t[107]=C,t[108]=f,t[109]=ve,t[110]=ye,t[111]=xe,t[112]=Z,t[113]=Be,t[114]=He,t[115]=Ue):Ue=t[115];let We;return t[116]!==he||t[117]!==ge||t[118]!==Ue?(We=(0,$.jsxs)(`div`,{ref:g,className:`oc-hold-to-talk-container`,"data-hold-to-talk-empty":he,children:[ge,Ue]}),t[116]=he,t[117]=ge,t[118]=Ue,t[119]=We):We=t[119],We};function Nt(e){return{start:e.start,end:e.end,priority:103,...f(e)}}function Pt(e,t){return(0,$.jsx)(`span`,{className:e.className,children:e.visual?(0,$.jsx)(Me,{visual:e.visual,text:e.text}):e.text},`${t}-${e.text.length}`)}var Ft=`rounded-[1.35rem] border border-border/40 cursor-zoom-in`;function It({assistantID:e,descriptor:t,onShowPopup:n}){let{t:r}=A(),i=be(),{attachmentID:a,sha256:o,size:s,mime:c,filename:l}=t,u=Q.useMemo(()=>({type:`file`,attachmentID:a,sha256:o,size:s,mime:c,filename:l}),[a,o,s,c,l]),d=c.startsWith(`image/`),[f,p]=Q.useState(0),[m,h]=Q.useState(``),[g,_]=Q.useState(!1),[v,y]=Q.useState(!1),b=Q.useRef(null),x=Q.useRef([]);Q.useEffect(()=>{h(``),_(!1);let t=new AbortController,n;return d&&ot(e,u,{signal:t.signal}).then(e=>{if(t.signal.aborted){e.release();return}n=e.release,h(e.url)}).catch(()=>{t.signal.aborted||_(!0)}),()=>{t.abort(),n?.()}},[e,u,i,d,f]),Q.useEffect(()=>()=>{b.current?.abort(),x.current.forEach(e=>URL.revokeObjectURL(e)),x.current=[]},[e,u,i]);let S=O(async()=>{if(b.current)return;let t=new AbortController;b.current=t,y(!0),_(!1);try{let n=await at(e,u,{signal:t.signal});if(t.signal.aborted)return;x.current.forEach(e=>URL.revokeObjectURL(e));let i=URL.createObjectURL(n);x.current=[i];let a=document.createElement(`a`);a.href=i,a.download=l||r(`assistants.contact.attachment.file`),document.body.appendChild(a),a.click(),a.remove()}catch{t.signal.aborted||_(!0)}finally{b.current===t&&(b.current=null),t.signal.aborted||y(!1)}}),C=l||r(d?`assistants.contact.attachment.image`:`assistants.contact.attachment.file`),w=O(e=>{!n||!m||n({open:!0,title:C,content:``,metadata:{tool:`image-preview`,filename:C,mime:c},previewSource:e.currentTarget,image:{url:m,mimeType:c,filename:C,size:s,gallery:[{url:m,mimeType:c,filename:C,size:s}],index:0}})});return d&&m&&!g?(0,$.jsx)(Je,{src:m,alt:C,contentFrame:!0,className:Ft,onError:()=>_(!0),onClick:w,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w(e))},role:`button`,tabIndex:0,"data-assistant-contact-image":``}):d&&!g?(0,$.jsx)(qe,{className:`h-[var(--oc-content-image-height)] w-[min(20rem,100%)] rounded-[1.35rem]`}):(0,$.jsxs)(`div`,{className:`flex max-w-full flex-col gap-1 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5 ring-1 ring-inset ring-[var(--surface-subtle)]`,"data-assistant-contact-file":``,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(X,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:C})]}),g?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:r(`assistants.contact.attachment.loadFailed`)}):null,d&&!g||v?(0,$.jsx)(`span`,{role:`status`,className:`typography-micro text-muted-foreground`,children:r(`common.loading`)}):(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:d?()=>p(e=>e+1):()=>void S(),children:r(g?`chat.history.retry`:`assistants.contact.attachment.download`)})]})}function Lt(e){let t=(0,st.c)(27),{part:n,onShowPopup:r}=e,{t:i}=A(),a=/^(?:https?:|data:|blob:)/i.test(n.url)?n.url:``,o=ye(a,``),[s,c]=Q.useState(!1),l;t[0]!==n.filename||t[1]!==i?(l=n.filename||i(`assistants.contact.attachment.image`),t[0]=n.filename,t[1]=i,t[2]=l):l=t[2];let u=l,d;t[3]!==u||t[4]!==r||t[5]!==o?(d=e=>{!r||!o||r({open:!0,title:u,content:``,metadata:{tool:`image-preview`,filename:u},previewSource:e.currentTarget,image:{url:o,filename:u,gallery:[{url:o,filename:u}],index:0}})},t[3]=u,t[4]=r,t[5]=o,t[6]=d):d=t[6];let f=O(d);if(n.mime.startsWith(`image/`)&&o&&!s){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>c(!0),t[7]=e):e=t[7];let n;t[8]===f?n=t[9]:(n=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f(e))},t[8]=f,t[9]=n);let r;return t[10]!==u||t[11]!==f||t[12]!==o||t[13]!==n?(r=(0,$.jsx)(Je,{src:o,alt:u,contentFrame:!0,className:Ft,onError:e,onClick:f,onKeyDown:n,role:`button`,tabIndex:0,"data-assistant-contact-image":``}),t[10]=u,t[11]=f,t[12]=o,t[13]=n,t[14]=r):r=t[14],r}let p;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(X,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),t[15]=p):p=t[15];let m;t[16]!==n.filename||t[17]!==i?(m=n.filename||i(`assistants.contact.attachment.file`),t[16]=n.filename,t[17]=i,t[18]=m):m=t[18];let h;t[19]===m?h=t[20]:(h=(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:m}),t[19]=m,t[20]=h);let g;t[21]!==s||t[22]!==i?(g=s?(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>c(!1),children:i(`chat.history.retry`)}):null,t[21]=s,t[22]=i,t[23]=g):g=t[23];let _;return t[24]!==h||t[25]!==g?(_=(0,$.jsxs)(`div`,{className:`flex max-w-full items-center gap-2.5 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5`,"data-assistant-contact-file":``,children:[p,h,g]}),t[24]=h,t[25]=g,t[26]=_):_=t[26],_}function Rt(e){let t=(0,st.c)(5),{assistantID:n,part:r,onShowPopup:i}=e,a=be(),o;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a?(o=`attachmentID`in r?(0,$.jsx)(It,{assistantID:n,descriptor:r,onShowPopup:i},`${a}:${n}:${r.attachmentID}:${r.sha256}`):(0,$.jsx)(Lt,{part:r,onShowPopup:i},`${a}:${r.url}`),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var zt=[],Bt=e=>e.flatMap(e=>e.type===`text`&&e.text.trim()?[e.text]:[]).join(`
3
- `),Vt=(e,t,n,r=Date.now())=>({assistantID:e,messageID:t,parts:n,status:`sending`,createdAt:r}),Ht=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},Ut=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},Wt=(e,t,n,r)=>({messageID:t?`${e.turnID}:preview:${t.bubbleIndex}`:`${e.turnID}:preview:${r}`,assistantID:e.assistantID,role:`assistant`,turnID:e.turnID,bubbleIndex:t?.bubbleIndex??0,createdAt:t?.occurredAt??e.occurredAt,ordinal:n,status:r,fromAssistantID:null,fromAssistantName:null,parts:t?[{type:`text`,text:t.text}]:[],text:t?.text??``,cards:[]}),Gt=(e,t,n)=>{let r=e.bubbles.filter(e=>!t.has(e.bubbleIndex)).map((t,r)=>Wt(e,t,n+r,t.done?`complete`:`streaming`));return e.status===`failed`?[...r,Wt(e,null,n+r.length,`failed`)]:e.status===`admitted`||e.status===`streaming`?[...r,Wt(e,null,n+r.length,`admitted`)]:r},Kt=(e,t,n,r=[])=>{let i=new Set(e.map(e=>e.messageID)),a=t.flatMap((t,r)=>t.assistantID!==n||i.has(t.messageID)?[]:[{messageID:t.messageID,assistantID:n,role:`user`,turnID:t.messageID,bubbleIndex:0,createdAt:t.createdAt,ordinal:e.length+r,status:t.status,fromAssistantID:null,fromAssistantName:null,parts:[...t.parts],text:Bt(t.parts),cards:[]}]),o=a.length===0?e:[...e,...a],s=r.filter(e=>e.assistantID===n);if(s.length===0)return o;let c=new Map,l=new Map;o.forEach((e,t)=>{if(c.set(e.turnID,t),e.role!==`assistant`||e.messageID.includes(`:preview:`))return;let n=l.get(e.turnID)??new Set;n.add(e.bubbleIndex),l.set(e.turnID,n)});let u=new Map,d=[];for(let e of s){let t=Gt(e,l.get(e.turnID)??new Set,o.length+d.length);if(t.length===0)continue;let n=c.get(e.turnID);if(n===void 0){if(e.status===`failed`&&o.some(t=>t.turnID!==e.turnID))continue;d.push(...t);continue}let r=u.get(n)??[];r.push(...t),u.set(n,r)}return u.size===0&&d.length===0?o:o.flatMap((e,t)=>[e,...u.get(t)??[]]).concat(d)},qt=(e,t)=>{let n=new Set(t.map(e=>e.messageID)),r=e.filter(e=>!n.has(e.messageID));return r.length===e.length?e:r},Jt=(e,t)=>e.map(e=>e.messageID===t?{...e,status:`admitted`}:e),Yt=(e,t,n,r=Date.now())=>{let i=e.filter(e=>e.assistantID!==t||e.status!==`failed`||e.turnID===n);return i.some(e=>e.assistantID===t&&e.turnID===n)?i.length===e.length?e:i:[...i,{assistantID:t,turnID:n,status:`admitted`,bubbles:[],occurredAt:r}]},Xt=(e,t,n)=>!t?.turnID||!t.assistantID||n?.has(t.turnID)?e:Yt(e,t.assistantID,t.turnID,t.admittedAt),Zt=(e,t)=>{let n=t.assistantID,r=t.pendingSendTurnIDs??new Set,i=t.settledTurnIDs??new Set,a=typeof t.snapshotRevision==`number`&&Number.isFinite(t.snapshotRevision)?t.snapshotRevision:null,o=t.admissionRevisionByTurnID instanceof Map?t.admissionRevisionByTurnID:new Map(Object.entries(t.admissionRevisionByTurnID??{}).map(([e,t])=>[e,Number(t)])),s=t.occurredAt??Date.now(),c=t.activeContactTurn&&t.activeContactTurn.turnID?t.activeContactTurn:null,l=!!(t.serverWorking||c),u=Xt(e,c?{assistantID:n,turnID:c.turnID,admittedAt:c.admittedAt}:null,i),d=Array.isArray(t.messages)?t.messages:[];for(let e of d)e.role===`assistant`&&e.status===`error`&&(r.has(e.turnID)||i.has(e.turnID)||(u=$t(u,{assistantID:n,turnID:e.turnID,status:`error`,error:e.text||`upstream_error`,occurredAt:s})));if(u=en(u,d),l){let t=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID)||c&&e.turnID===c.turnID)return!0;let t=o.get(e.turnID);return typeof t==`number`&&a!=null&&a<t?!0:typeof t==`number`&&a!=null&&a>=t&&e.turnID!==c?.turnID?!1:!c||e.turnID===c.turnID});return t.length===e.length&&t.every((t,n)=>t===e[n])?e:t}if(a==null)return u.length===e.length&&u.every((t,n)=>t===e[n])?e:u;let f=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID))return!0;if(i.has(e.turnID))return!1;let t=o.get(e.turnID);return typeof t==`number`&&a<t});return f.length===e.length&&f.every((t,n)=>t===e[n])?e:f.length===u.length?u:f},Qt=(e,t)=>Yt(e,t.assistantID,t.turnID,t.occurredAt).map(e=>{if(e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`failed`||e.status===`complete`)return e;let n=e.bubbles.find(e=>e.bubbleIndex===t.bubbleIndex);if(n?.done)return e;let r=n?{...n,text:`${n.text}${t.delta}`,done:t.done,occurredAt:t.occurredAt}:{bubbleIndex:t.bubbleIndex,text:t.delta,done:t.done,occurredAt:t.occurredAt},i=n?e.bubbles.map(e=>e.bubbleIndex===t.bubbleIndex?r:e):[...e.bubbles,r].sort((e,t)=>e.bubbleIndex-t.bubbleIndex);return{...e,status:`streaming`,bubbles:i}}),$t=(e,t,n={})=>n.requireExisting&&!e.some(e=>e.assistantID===t.assistantID&&e.turnID===t.turnID)?e:Yt(e,t.assistantID,t.turnID,t.occurredAt).map(e=>e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`complete`||e.status===`failed`?e:{...e,status:t.status===`error`?`failed`:`complete`,...t.error?{error:t.error}:{}}),en=(e,t)=>{let n=new Set(t.map(e=>e.turnID).filter(Boolean)),r=t.length>0?t[t.length-1]?.turnID??null:null,i=[...e].reverse().find(e=>e.status===`admitted`||e.status===`streaming`)?.turnID??r,a=new Set(t.flatMap(e=>e.role===`assistant`?[e.turnID]:[])),o=e.filter(e=>e.status===`admitted`||e.status===`streaming`||!(e.status===`complete`&&a.has(e.turnID)||!n.has(e.turnID)||e.status===`failed`&&(i&&i!==e.turnID||r&&r!==e.turnID)));return o.length===e.length?e:o},tn=(e,t,n)=>e.map(e=>e.messageID===t?{...e,status:`failed`,error:n}:e),nn=(e,t)=>{if(e instanceof R){if(e.code===`no_provider`)return t.noProvider;if(e.code===`admission_timeout`||e.code===`generate_timeout`)return t.timedOut;if(e.message&&e.message!==e.code)return e.message}return L(e)?t.timedOut:t.sendFailed},rn=()=>{let e=!1;return{tryAcquire:()=>!e&&(e=!0,!0),release:()=>{e=!1}}},an=e=>{let t=e.text.trim();if(e.sending||!t&&e.attachments.length===0||!e.gate.tryAcquire())return{ok:!1};let n=[...t?[{type:`text`,text:t}]:[],...e.attachments.map(e=>({type:`file`,mime:e.mime,url:e.url,filename:e.name}))],r=e.createMessageID();return{ok:!0,messageID:r,parts:n,turn:Vt(e.assistantID,r,n,e.createdAt)}},on=e=>e.some(e=>e.status===`sending`),sn=e=>e.some(e=>e.status===`admitted`||e.status===`streaming`),cn=[`cursor-pointer rounded-[1.35rem] bg-[var(--surface-elevated)] ring-1 ring-inset ring-[var(--surface-subtle)]`,`px-3.5 py-3 text-left transition-[background-color,box-shadow,transform] duration-200 ease-out motion-reduce:transition-none`,`hover:-translate-y-px hover:bg-interactive-hover/45 hover:shadow-sm active:translate-y-0 motion-reduce:hover:translate-y-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`].join(` `),ln=`${cn} w-fit min-w-0 max-w-[min(100%,15rem)]`,un=`${cn} w-fit min-w-0 max-w-[min(100%,20rem)]`;function dn(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}var fn=e=>{let t=(0,st.c)(23),{card:n}=e,{t:r}=A(),i=we(),a;t[0]===i?a=t[1]:(a=i&&!v(),t[0]=i,t[1]=a);let o=!!a,s=n.name,c=`${n.providerID}/${n.modelID}`,l;t[2]!==n.assistantID||t[3]!==o?(l=()=>{if(o){le.getState().openAssistant(n.assistantID);return}J(n.assistantID)},t[2]=n.assistantID,t[3]=o,t[4]=l):l=t[4];let u=O(l),d;t[5]===u?d=t[6]:(d=e=>{dn(e,u)},t[5]=u,t[6]=d);let f=O(d),p;t[7]!==r||t[8]!==s?(p=r(`assistants.contact.card.assistant.aria`,{name:s}),t[7]=r,t[8]=s,t[9]=p):p=t[9];let m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`span`,{className:`relative inline-block size-10 shrink-0 leading-none`,"aria-hidden":!0,children:(0,$.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-xl bg-[var(--surface-muted)] text-foreground`,children:(0,$.jsx)(X,{name:`robot-2`,className:`size-5`})})}),t[10]=m):m=t[10];let h;t[11]===s?h=t[12]:(h=(0,$.jsx)(`h3`,{className:`min-w-0 line-clamp-2 break-words typography-ui-label font-medium leading-5 text-foreground`,children:s}),t[11]=s,t[12]=h);let g;t[13]===c?g=t[14]:(g=(0,$.jsx)(`p`,{className:`truncate typography-micro font-normal leading-4 text-muted-foreground`,children:c}),t[13]=c,t[14]=g);let _;t[15]!==h||t[16]!==g?(_=(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[h,g]})]}),t[15]=h,t[16]=g,t[17]=_):_=t[17];let y;return t[18]!==f||t[19]!==u||t[20]!==p||t[21]!==_?(y=(0,$.jsx)(`article`,{className:ln,role:`button`,tabIndex:0,"aria-label":p,"data-assistant-contact-card":`assistant`,onClick:u,onKeyDown:f,children:_}),t[18]=f,t[19]=u,t[20]=p,t[21]=_,t[22]=y):y=t[22],y},pn=e=>{let t=(0,st.c)(30),{card:n}=e,{t:r}=A(),i=n.name,a;t[0]!==n.kind||t[1]!==r?(a=n.kind===`daily`||n.kind===`weekly`||n.kind===`once`||n.kind===`cron`?r(`sessions.scheduledTasks.editor.scheduleType.${n.kind}`):n.kind,t[0]=n.kind,t[1]=r,t[2]=a):a=t[2];let o=a,s;t[3]!==n.time||t[4]!==o?(s=[o,n.time].filter(Boolean),t[3]=n.time,t[4]=o,t[5]=s):s=t[5];let c=s.join(` · `),l;t[6]!==n.prompt||t[7]!==c?(l=c.trim()||(typeof n.prompt==`string`?n.prompt.trim():``),t[6]=n.prompt,t[7]=c,t[8]=l):l=t[8];let u=l,d;t[9]!==n.projectID||t[10]!==n.taskID?(d=()=>{tt(n.projectID,n.taskID)},t[9]=n.projectID,t[10]=n.taskID,t[11]=d):d=t[11];let f=O(d),p;t[12]===f?p=t[13]:(p=e=>{dn(e,f)},t[12]=f,t[13]=p);let m=O(p),h;t[14]!==r||t[15]!==i?(h=r(`assistants.contact.card.schedule.aria`,{name:i}),t[14]=r,t[15]=i,t[16]=h):h=t[16];let g;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`relative inline-block size-10 shrink-0 leading-none`,"aria-hidden":!0,children:(0,$.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-xl bg-[var(--surface-muted)] text-foreground`,children:(0,$.jsx)(X,{name:`calendar`,className:`size-5`})})}),t[17]=g):g=t[17];let _;t[18]===i?_=t[19]:(_=(0,$.jsx)(`h3`,{className:`min-w-0 line-clamp-2 break-words typography-ui-label font-medium leading-5 text-foreground`,children:i}),t[18]=i,t[19]=_);let v;t[20]===u?v=t[21]:(v=u?(0,$.jsx)(`p`,{className:`truncate typography-micro font-normal leading-4 text-muted-foreground`,children:u}):null,t[20]=u,t[21]=v);let y;t[22]!==_||t[23]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[g,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[_,v]})]}),t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;return t[25]!==m||t[26]!==f||t[27]!==y||t[28]!==h?(b=(0,$.jsx)(`article`,{className:ln,role:`button`,tabIndex:0,"aria-label":h,"data-assistant-contact-card":`schedule`,onClick:f,onKeyDown:m,children:y}),t[25]=m,t[26]=f,t[27]=y,t[28]=h,t[29]=b):b=t[29],b},mn=(e,t)=>t===`cancelled`?t:e===`busy`||e===`retry`?e:t===`error`||t===`question`||t===`complete`?t:e===`idle`?`complete`:t===`busy`||t===`retry`||t===`idle`?t:t||`busy`,hn=e=>e===`cancelled`?`assistants.contact.card.session.status.cancelled`:e===`busy`?`assistants.contact.card.session.status.busy`:e===`retry`?`assistants.contact.card.session.status.retry`:e===`idle`?`assistants.contact.card.session.status.idle`:e===`complete`?`assistants.contact.card.session.status.complete`:e===`error`?`assistants.contact.card.session.status.error`:e===`question`?`assistants.contact.card.session.status.question`:null,gn=e=>e===`busy`?`bg-[var(--status-info)]/10 text-[var(--status-info)]`:e===`retry`||e===`question`?`bg-[var(--status-warning)]/10 text-[var(--status-warning)]`:e===`error`?`bg-[var(--status-error)]/10 text-[var(--status-error)]`:e===`idle`||e===`complete`?`bg-[var(--status-success)]/10 text-[var(--status-success)]`:`bg-[var(--surface-muted)] text-muted-foreground`,_n=e=>e.split(/[/\\]/u).filter(Boolean).at(-1)||e,vn=e=>{let t=(0,st.c)(35),{card:n}=e,{t:r}=A(),i=we(),a;t[0]===i?a=t[1]:(a=i&&!v(),t[0]=i,t[1]=a);let o=!!a,s;t[2]===n.sessionID?s=t[3]:(s=e=>e.activeSessions.find(e=>e.id===n.sessionID)??e.archivedSessions.find(e=>e.id===n.sessionID)??null,t[2]=n.sessionID,t[3]=s);let c=oe(s),l=K(n.sessionID),u=(typeof c?.title==`string`&&c.title.trim()?c.title.trim():null)||n.title||r(`assistants.contact.card.session.untitled`),d=mn(l?.type,n.status),f=hn(d),p=d===`busy`||d===`retry`,m=_n(typeof c?.directory==`string`&&c.directory.trim()?c.directory.trim():n.directory),h=Ne(c)||n.branch,g=Ae(c),_=Fe(c),b=Le(_),x=[m,g,h].filter(yn),S;t[4]!==n.directory||t[5]!==n.sessionID||t[6]!==o?(S=()=>{let e=rt(n.sessionID)?.directory||n.directory;ae(n.sessionID,e,{phoneShell:o,switchToChat:!0}),o||y.getState().setActiveMainTab(`chat`)},t[4]=n.directory,t[5]=n.sessionID,t[6]=o,t[7]=S):S=t[7];let C=O(S),w;t[8]===C?w=t[9]:(w=e=>{dn(e,C)},t[8]=C,t[9]=w);let T=O(w),E=un,D=r(`assistants.contact.card.session.aria`,{title:u}),k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-xl bg-[var(--surface-muted)] text-foreground`,children:(0,$.jsx)(X,{name:`chat-3`,className:`size-5`})}),t[10]=k):k=t[10];let M;t[11]===p?M=t[12]:(M=p?(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2.5 translate-x-0.5 translate-y-0.5 rounded-full bg-[var(--status-success)] ring-2 ring-[var(--surface-elevated)]`,"data-assistant-working-dot":``,"aria-hidden":!0}):null,t[11]=p,t[12]=M);let N;t[13]===M?N=t[14]:(N=(0,$.jsxs)(`span`,{className:`relative inline-block size-10 shrink-0 leading-none`,"aria-hidden":!0,children:[k,M]}),t[13]=M,t[14]=N);let P;t[15]===u?P=t[16]:(P=(0,$.jsx)(`h3`,{className:`min-w-0 flex-1 line-clamp-2 break-words typography-ui-label font-medium leading-5 text-foreground`,children:u}),t[15]=u,t[16]=P);let F=f?(0,$.jsx)(`span`,{className:j(`shrink-0 rounded-full px-1.5 py-0.5 typography-micro leading-none`,gn(d)),children:r(f)}):null,I;t[17]!==P||t[18]!==F?(I=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[P,F]}),t[17]=P,t[18]=F,t[19]=I):I=t[19];let L;t[20]===x?L=t[21]:(L=x.length>0?(0,$.jsx)(`p`,{className:`truncate typography-micro font-normal leading-4 text-muted-foreground`,children:x.join(` · `)}):null,t[20]=x,t[21]=L);let R=b||_?.files!==void 0&&_.files>0?(0,$.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-1.5 typography-micro tabular-nums`,children:[_?.additions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,_.additions]}),_?.deletions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-error)]`,children:[`−`,_.deletions]}),_?.files===void 0?null:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:_.files===1?r(`assistants.contact.card.session.changes.filesSingle`,{count:_.files}):r(`assistants.contact.card.session.changes.filesPlural`,{count:_.files})})]}):null,z;t[22]!==I||t[23]!==L||t[24]!==R?(z=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[I,L,R]}),t[22]=I,t[23]=L,t[24]=R,t[25]=z):z=t[25];let B;t[26]!==N||t[27]!==z?(B=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[N,z]}),t[26]=N,t[27]=z,t[28]=B):B=t[28];let V;return t[29]!==T||t[30]!==C||t[31]!==B||t[32]!==E||t[33]!==D?(V=(0,$.jsx)(`article`,{className:E,role:`button`,tabIndex:0,"aria-label":D,"data-assistant-contact-card":`session`,onClick:C,onKeyDown:T,children:B}),t[29]=T,t[30]=C,t[31]=B,t[32]=E,t[33]=D,t[34]=V):V=t[34],V};function yn(e){return!!(e&&e.trim())}var bn=2,xn=1500,Sn=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),Cn=e=>e.scrollHeight-e.scrollTop-e.clientHeight,wn=e=>Cn(e)<=bn,Tn=(e,t)=>{let n=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;n&&n!==e;){if(n instanceof HTMLElement&&n.scrollHeight>n.clientHeight+1&&n.scrollTop+n.clientHeight<n.scrollHeight-1)return!0;n=n.parentElement}return!1},En=e=>e.altKey||e.ctrlKey||e.metaKey?!1:e.key===`ArrowDown`||e.key===`PageDown`||e.key===`End`,Dn=({active:e,assistantID:t,contentRevision:n,onLoadEarlier:r})=>{let i=Q.useRef(null),[a,o]=Q.useState(null),[s,c]=Q.useState(null),l=Q.useRef(!0),u=Q.useRef(null),d=Q.useRef(null),f=Q.useRef(null),p=Q.useRef(0),m=Q.useRef(null),h=Q.useRef(null),g=Q.useRef(e);g.current=e;let _=Be(),v=Q.useRef(!1),y=Q.useRef(null),b=Q.useRef(null),x=O(()=>{y.current?.stop(),y.current=null,b.current=null}),S=Q.useMemo(()=>e=>{i.current=e,o(t=>t===e?t:e)},[]),C=Q.useMemo(()=>e=>{c(t=>t===e?t:e)},[]),w=O(()=>{let e=i.current;if(!e||!g.current||l.current)return;let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.getBoundingClientRect().bottom>t);u.current=n?{id:n.dataset.messageId,offset:n.getBoundingClientRect().top-t,scrollTop:e.scrollTop}:null}),T=O(()=>{let e=i.current,t=u.current;if(!e||!g.current||l.current)return;if(!t){w();return}let n=e.scrollTop-t.scrollTop;if(Math.abs(n)>.5&&m.current){p.current=e.scrollTop,w();return}let r=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.dataset.messageId===t.id);if(!r){w();return}let a=r.getBoundingClientRect().top-e.getBoundingClientRect().top-(t.offset-n);Math.abs(a)>.5&&(e.scrollTop+=a),p.current=e.scrollTop,u.current={id:t.id,offset:r.getBoundingClientRect().top-e.getBoundingClientRect().top,scrollTop:e.scrollTop}}),D=O(()=>{x(),l.current=!1,p.current=i.current?.scrollTop??0,w()}),A=O(()=>{if(!g.current||!l.current)return!1;let e=i.current;if(!e)return!1;let t=Sn(e),n=Math.min(p.current,Math.max(0,t.scrollHeight-t.clientHeight));if(t.scrollTop<n-.5)return x(),l.current=!1,p.current=t.scrollTop,w(),!1;let r=!v.current;if(r&&e.querySelector(`[data-message-id]`)&&(v.current=!0),wn(t))return x(),p.current=t.scrollTop,!1;let a=Math.max(0,t.scrollHeight-t.clientHeight);return!r&&!_?b.current!==a&&(x(),b.current=a,y.current=ze(e.scrollTop,a,{duration:.22,ease:`easeOut`,onUpdate:t=>{if(!g.current||!l.current||i.current!==e)return;let n=Math.max(0,e.scrollHeight-e.clientHeight);if(e.scrollTop<Math.min(p.current,n)-.5){l.current=!1,x(),p.current=e.scrollTop,w();return}e.scrollTop=Math.min(Math.max(e.scrollTop,t),n),p.current=e.scrollTop},onComplete:()=>{y.current=null,b.current=null}}),!0):(x(),e.scrollTop=a,p.current=e.scrollTop,!0)}),j=O(e=>{h.current={direction:e,expiresAt:performance.now()+xn}}),M=O(()=>{let e=h.current;return e?performance.now()>e.expiresAt?(h.current=null,null):e.direction:null}),N=O(()=>{x(),l.current=!1,w()}),P=O(()=>{if(!g.current)return;let e=i.current;if(!e)return;let t=Sn(e),n=t.scrollTop>p.current,a=Math.min(p.current,Math.max(0,t.scrollHeight-t.clientHeight));if(p.current=t.scrollTop,l.current){t.scrollTop<a-.5&&N();return}let o=M();T(),t.scrollTop<=80&&o===`up`&&r?.(),n&&wn(t)&&(o===`down`||o===`scrollbar`)&&(l.current=!0)}),F=O(e=>{let t=i.current;if(!(!t||e.deltaY===0)){if(e.deltaY<0){if(Ie(t,e.target))return;j(`up`),N(),t.scrollTop<=80&&r?.();return}Tn(t,e.target)||j(`down`)}}),I=O(e=>{h.current=null;let t=e.touches.item(0);m.current=t?{x:t.clientX,y:t.clientY,deltaX:0,deltaY:0}:null}),L=O(e=>{let t=i.current,n=e.touches.item(0);if(!t||!n){m.current=null;return}let a=m.current;if(!a)return;let o=n.clientY-a.y,s=o*a.deltaY<0,c=(s?0:a.deltaX)+n.clientX-a.x,l=(s?0:a.deltaY)+o;if(m.current={x:n.clientX,y:n.clientY,deltaX:c,deltaY:l},!(Math.abs(c)>=Math.abs(l))){if(l>0&&Ie(t,e.target)||l<0&&Tn(t,e.target)){m.current.deltaX=0,m.current.deltaY=0;return}j(l>0?`up`:`down`),l>2&&(N(),t.scrollTop<=80&&r?.())}}),R=O(()=>{m.current=null}),z=O(e=>{if(Te(e)){j(`up`),N(),(i.current?.scrollTop??1/0)<=80&&r?.();return}En(e)&&j(`down`)}),B=O(e=>{let t=i.current;e.pointerType===`mouse`&&e.target===t&&j(`scrollbar`)});Q.useLayoutEffect(()=>{let n=e?t:null,r=i.current;(d.current!==n||f.current!==r)&&(x(),v.current=!1,d.current=n,f.current=r,l.current=!0,u.current=null,h.current=null,m.current=null,p.current=r?.scrollTop??0),e&&(A(),T())},[e,t,n,a,_]),Q.useLayoutEffect(()=>()=>{x()},[e,t,a,x]);let V=Q.useMemo(()=>()=>void 0,[]),H=e&&a?a:V,U=Q.useMemo(()=>({passive:!0}),[]);k(`scroll`,P,H,U),k(`wheel`,F,H,U),k(`touchstart`,I,H,U),k(`touchmove`,L,H,U),k(`touchend`,R,H,U),k(`touchcancel`,R,H,U),k(`keydown`,z,H),k(`pointerdown`,B,H,U);let ee=O(()=>{A(),T()});return E(typeof ResizeObserver<`u`&&e?s:null,ee),{scrollRef:S,contentRef:C,preparePrepend:D}},On=64,kn=e=>{if(!e)return[];let t=Array.from(e.files||[]);return t.length>0?t:Array.from(e.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e instanceof File)},An=e=>Array.from(e?.files||[]),jn=async(e,t=p)=>{let n=[],r=0;for(let i of Array.from(e||[])){if(!i||i.size<=0)continue;if(i.size>26214400){r+=1;continue}let e=URL.createObjectURL(i);n.push({id:t(),url:e,name:i.name.trim()||`attachment`,mime:i.type.trim()||`application/octet-stream`,file:i})}return{attachments:n,skippedTooLarge:r}},Mn=(e,t)=>{let n=[...e,...t];for(let e of n.slice(On))e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url);return n.slice(0,On)},Nn=Ge(()=>x(()=>import(`./ToolOutputDialog-xTzsvgSH.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]))),Pn=e=>e.trim().startsWith(`oc.settle.`),Fn=e=>e.status===`error`||e.status===`failed`&&e.messageID.endsWith(`:preview:failed`),In=e=>e.role===`assistant`&&e.status!==`error`&&e.parts.some(e=>e.type===`text`)?`${e.turnID}:assistant:${e.bubbleIndex}`:e.messageID,Ln=({assistant:e,warning:t,active:n,overlayHeader:r=!1})=>{let{t:i,locale:a}=A(),o=be(),s=y(e=>e.isMobile),c=z(),l=B(),u=ie(e.id,n),d=y(e=>e.isSettingsDialogOpen),f=n&&!d&&!u.hasMessageGap?I(e,u.data):null,m=N(e.name).displayName||e.name,h=(e,t)=>{let n=e?l.data?.assistants.find(t=>t.id===e):void 0;return n?N(n.name).displayName||n.name:t||i(`assistants.contact.peer.unknown`)},[g,_]=Q.useState(``),[v,b]=Q.useState([]),x=Q.useRef(null),S=Q.useRef(new Map),C=Q.useRef(new AbortController);Q.useEffect(()=>{let e=new AbortController;return C.current=e,()=>e.abort()},[e.id,o]);let w=Q.useRef(new Set);Q.useEffect(()=>{let e=new Set(v.map(e=>e.url));for(let t of w.current)e.has(t)||URL.revokeObjectURL(t);w.current=e},[v]),Q.useEffect(()=>()=>{for(let e of w.current)URL.revokeObjectURL(e)},[]);let[T,E]=Q.useState([]),[D,k]=Q.useState([]),[F,L]=Q.useState(null),[V,H]=Q.useState({open:!1,title:``,content:``}),W=y(e=>e.setImagePreviewOpen),ne=O(e=>{(e.image||e.mermaid)&&(H(e),W(!0))}),re=O(e=>{H(t=>({...t,open:e})),W(e)});Q.useEffect(()=>()=>{W(!1)},[W]);let G=Q.useRef(!1);Q.useEffect(()=>{S.current.clear(),x.current=null,E([]),k([]),L(null)},[o]);let ae=Q.useMemo(()=>rn(),[]),K=Q.useRef(new Set),oe=Q.useRef(new Map),se=ut(e=>e.setWorking),ce=u.data?.messages??zt,le=Ht(T,e.id),ue=Ut(D,e.id),J=Kt(ce,le,e.id,ue).filter(e=>{if(e.status===`admitted`&&e.messageID.endsWith(`:preview:admitted`))return!1;let t=Array.isArray(e.parts)?e.parts:[];return t.length===0||t.some(e=>!(e.type===`text`&&Pn(e.text)))}),de=J.length-1;for(;de>=0&&Fn(J[de]);)--de;let Y=J.filter((e,t)=>!Fn(e)||t>de),fe=vt(Y),pe=Be(),me=`${o}:${e.id}`,he=Q.useRef(null),ge=he.current,_e=ge?.lastID?Y.findIndex(e=>In(e)===ge.lastID):-1,ve=n&&!pe&&ge?.scope===me&&ge.ready&&(ge.lastID===null||_e>=0);Q.useLayoutEffect(()=>{let e=Y.at(-1);he.current={scope:me,ready:n&&u.isSuccess,lastID:e?In(e):null}});let ye=new Date().toDateString(),xe=i(`common.date.today`),Se=Q.useMemo(()=>yt(a,xe,new Date(ye)),[a,xe,ye]),Z=on(le),Ce=sn(ue),we=!!(e.working||e.activeContactTurn),Te=l.data?.revision??null,Ee=ue.reduce((e,t)=>e+t.bubbles.reduce((e,t)=>e+t.text.length,0),0),De=new Map(ue.map(e=>[e.turnID,e])),Oe=Q.useRef(!1),ke=O(async(e=!1)=>{if(!(!n||Oe.current||u.isFetchingPreviousPage||u.isFillingMessageGap)&&!(e&&u.previousPageError)&&!(!u.hasPreviousPage&&!u.hasMessageGap)){Oe.current=!0,Me();try{u.hasMessageGap?await u.retryMessageGap():await u.fetchPreviousPage()}catch{}finally{Oe.current=!1}}}),{scrollRef:Ae,contentRef:je,preparePrepend:Me}=Dn({active:n,assistantID:e.id,contentRevision:`${Y[0]?.messageID}:${Y.length}:${Ee}:${u.isFetchingPreviousPage}:${u.hasPreviousPage}:${u.isFillingMessageGap}`,onLoadEarlier:()=>{ke(!0)}});Q.useEffect(()=>{L(null),K.current.clear(),oe.current=new Map,E(t=>Ht(t,e.id)),k(t=>Ut(t,e.id)),H({open:!1,title:``,content:``}),W(!1)},[e.id,W]),Q.useEffect(()=>{E(e=>qt(e,ce))},[ce]),Q.useEffect(()=>{let t=new Set(le.filter(e=>e.status===`sending`).map(e=>e.messageID));k(n=>Zt(n,{assistantID:e.id,activeContactTurn:e.activeContactTurn?{turnID:e.activeContactTurn.turnID,admittedAt:e.activeContactTurn.admittedAt}:null,serverWorking:we,snapshotRevision:Te,admissionRevisionByTurnID:oe.current,pendingSendTurnIDs:t,messages:ce,settledTurnIDs:K.current}))},[e.activeContactTurn,e.id,ce,le,we,Te]),Q.useEffect(()=>{se(e.id,Z||Ce||we)},[e.id,Ce,Z,we,se]),Q.useEffect(()=>{let t=e.id;return()=>{se(t,!1)}},[e.id,se]);let Ne=O(t=>{if(!(!(`assistantID`in t)||t.assistantID!==e.id)){if(t.type===`contact-turn-start`){K.current.delete(t.turnID),k(e=>Yt(e,t.assistantID,t.turnID,t.occurredAt));return}if(t.type===`contact-bubble-delta`){if(K.current.has(t.turnID))return;k(e=>Qt(e,t));return}t.type===`contact-turn-end`&&(K.current.add(t.turnID),k(e=>en($t(e,t,{requireExisting:!0}),ce)))}});Q.useEffect(()=>{if(n)return q(Ne)},[n,e.id]);let Pe=O(async e=>{if(Z)return;let t=C.current,n=await jn(e);if(t.signal.aborted){n.attachments.forEach(e=>URL.revokeObjectURL(e.url));return}n.skippedTooLarge>0&&L(i(`assistants.contact.attachment.tooLarge`)),n.attachments.length!==0&&b(e=>Mn(e,n.attachments))}),Fe=O(e=>{let t=kn(e.clipboardData);t.length!==0&&(e.preventDefault(),Pe(t))}),Ie=O(e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),Le=O(e=>{let t=An(e.dataTransfer);t.length!==0&&(e.preventDefault(),Pe(t))}),Re=O(async t=>{let n=C.current,r=t??g,a=v,o=e.id,s=x.current,l=s?.assistantID===o&&s.text===r&&s.attachments===a?s.messageID:null,u=an({gate:ae,sending:on(le),text:r,attachments:a,assistantID:o,createMessageID:()=>l||`oc_contact_${p()}`});if(!u.ok)return;se(o,!0),x.current={assistantID:o,text:r,attachments:a,messageID:u.messageID},E(e=>[...e.filter(e=>e.messageID!==u.messageID),u.turn]),L(null);let d=()=>{_(e=>e===r?``:e),b(e=>e.filter(e=>!a.includes(e))),a.forEach(e=>S.current.delete(`${o}:${e.id}`)),x.current=null};try{let t=[];for(let e of a){let r=`${o}:${e.id}`,i=S.current.get(r);if(!i){if(i=await it(o,e.file,e.id,n.signal),n.signal.aborted)return;S.current.set(r,i)}t.push(i)}if(n.signal.aborted)return;let r=[...u.parts.filter(e=>e.type===`text`),...t];E(e=>e.map(e=>e.messageID===u.messageID?{...e,parts:r}:e));let i=await te(o,u.messageID,{parts:r});if(n.signal.aborted)return;d(),typeof i.revision==`number`&&oe.current.set(u.messageID,i.revision),E(e=>Jt(e,u.messageID)),K.current.has(u.messageID)||k(e=>Yt(e,o,u.messageID)),c.data?.serverInstanceID&&P({serverInstanceID:c.data.serverInstanceID,assistantID:o,name:m,avatarSeed:e.avatarSeed??o}).catch(()=>void 0)}catch(e){if(n.signal.aborted)return;if(e instanceof R&&e.code===`admission_timeout`)try{let e=await U(o,u.messageID);if(n.signal.aborted)return;if(e){d(),typeof e.revision==`number`&&oe.current.set(u.messageID,e.revision),E(e=>Jt(e,u.messageID)),K.current.has(u.messageID)||k(e=>Yt(e,o,u.messageID));return}}catch{}let t=nn(e,{noProvider:i(`assistants.contact.noProvider`),sendFailed:i(`assistants.contact.sendFailed`),timedOut:i(`assistants.contact.timedOut`)});E(e=>tn(e,u.messageID,t)),L(t)}finally{ae.release()}}),ze=O(async()=>{if(G.current)return;G.current=!0;let t=C.current;L(null);try{await ee(e.id,e)}catch(e){t.signal.aborted||L(e instanceof Error?e.message:i(`settings.mcp.page.toast.unexpectedError`))}finally{G.current=!1}}),Ve=u.isError&&Y.length===0,He=u.isSuccess&&Y.length===0,Ue=new Map(le.map(e=>[e.messageID,e]));return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,children:[(0,$.jsxs)(`div`,{ref:Ae,className:j(`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 sm:px-8`,r?`pt-[calc(max(0.625rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height)+1.25rem)]`:`pt-5 sm:pt-7`),style:{overflowAnchor:`none`,overscrollBehavior:`contain`,overscrollBehaviorY:`contain`},"data-assistant-contact-transcript":``,children:[t?(0,$.jsx)(`p`,{className:`mb-3 typography-micro text-[var(--status-warning)]`,children:t}):null,Ve?(0,$.jsxs)(`div`,{ref:je,className:`mx-auto flex h-full min-h-56 max-w-xs flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-error":``,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(pt,{name:e.id,avatarSeed:e.avatarSeed,size:44,label:m}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -bottom-1 flex size-5 items-center justify-center rounded-full bg-[var(--surface-elevated)] text-[var(--status-error)] ring-2 ring-background`,children:(0,$.jsx)(X,{name:`error-warning`,className:`size-3`})})]}),(0,$.jsx)(`p`,{className:`mt-4 typography-ui-label font-medium text-foreground`,children:m}),(0,$.jsx)(`p`,{className:`mt-1.5 typography-ui leading-6 text-muted-foreground`,children:i(`assistants.contact.loadFailed`)}),(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void u.refetch(),children:i(`chat.history.retry`)})]}):He?(0,$.jsxs)(`div`,{ref:je,className:`mx-auto flex h-full min-h-56 max-w-sm flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-empty":``,children:[(0,$.jsx)(pt,{name:e.id,avatarSeed:e.avatarSeed,size:48,label:m,className:`opacity-90`}),(0,$.jsx)(`p`,{className:`mt-5 typography-ui-header font-medium tracking-[-0.01em] text-foreground`,children:i(`assistants.conversation.emptyTitle`,{name:m})}),(0,$.jsx)(`p`,{className:`mt-2 max-w-xs typography-ui leading-6 text-muted-foreground/80`,children:i(`assistants.contact.empty`)})]}):(0,$.jsxs)(`div`,{ref:je,className:`relative mx-auto flex w-full max-w-[42rem] flex-col pb-12`,"data-assistant-contact-content":``,children:[u.isPending?(0,$.jsx)(`p`,{role:`status`,className:`py-3 text-center typography-micro text-muted-foreground`,children:i(`common.loading`)}):null,u.hasPreviousPage||u.hasMessageGap?(0,$.jsxs)(`div`,{className:`mb-3 flex flex-col items-center gap-1`,"data-assistant-contact-pagination":``,"aria-busy":u.isFetchingPreviousPage||u.isFillingMessageGap,children:[u.previousPageError?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:i(`chat.history.loadOlderFailed`)}):null,u.hasMessageGap?(0,$.jsx)(`p`,{role:`status`,className:`typography-micro text-muted-foreground`,children:i(`assistants.contact.history.gap`)}):null,(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,disabled:u.isFetchingPreviousPage||u.isFillingMessageGap,onClick:()=>void ke(),children:i(u.isFetchingPreviousPage||u.isFillingMessageGap?`chat.history.loadingMore`:u.previousPageError||u.hasMessageGap?`chat.history.retry`:`chat.history.loadOlder`)})]}):null,Y.map((t,n)=>{let r=`${me}:${In(t)}`,a=n>0?Y[n-1]:null,s=fe.get(t.messageID),c=s!==void 0,u=c?(0,$.jsx)(`div`,{className:`flex w-full justify-center px-4 pt-7 pb-4 first:pt-1`,"data-assistant-contact-time":``,children:(0,$.jsx)(`time`,{dateTime:new Date(s).toISOString(),className:`text-[11px] font-normal leading-4 tabular-nums text-muted-foreground/70`,children:Se(s)})}):null,d=t.role===`user`,p=t.role===`peer`,g=t.role===`assistant`&&!c&&a?.role===`assistant`&&a.turnID===t.turnID,_=a?.turnID!==t.turnID,v=!d&&(p||!g),y=p?h(t.fromAssistantID,t.fromAssistantName):m,b=p&&t.fromAssistantID?l.data?.assistants.find(e=>e.id===t.fromAssistantID):e,x=Ue.get(t.messageID),S=De.get(t.turnID),C=t.status===`failed`&&t.messageID.endsWith(`:preview:failed`);return t.status===`error`||C?(0,$.jsxs)(Q.Fragment,{children:[u,(0,$.jsxs)(`div`,{"data-message-id":t.messageID,"data-assistant-contact-error":``,className:j(`relative px-1`,!c&&`mt-3`),children:[(0,$.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap text-center text-[11px] font-normal leading-4 text-muted-foreground [overflow-wrap:anywhere]`,children:t.text||S?.error||i(`assistants.contact.sendFailed`)}),f?.messageID===t.messageID?(0,$.jsx)(xt,{assistantID:e.id,position:f},`${o}:${e.id}:${f.generation}:${f.ordinal}`):null]})]},r):(0,$.jsxs)(Q.Fragment,{children:[u,(0,$.jsxs)(Ye.div,{"data-message-id":t.messageID,initial:ve&&n>_e?{opacity:0,y:4}:!1,animate:{opacity:1,y:0},transition:{duration:pe?0:.18,ease:`easeOut`},className:j(`flex w-full`,d?`justify-end`:`justify-start`,c?`mt-0`:_?`mt-6 first:mt-0`:g?`mt-1.5`:`mt-3`),"data-assistant-contact-role":t.role,"data-assistant-contact-turn-status":x?.status??t.status,"data-assistant-contact-run-start":t.role===`assistant`&&!g?``:void 0,children:[d?null:(0,$.jsx)(`div`,{className:`mr-2.5 flex w-8 shrink-0 justify-center pt-0.5`,children:v?(0,$.jsx)(pt,{name:b?.id||t.fromAssistantID||e.id,avatarSeed:b?.avatarSeed??(t.fromAssistantID?void 0:e.avatarSeed),size:28,label:y,working:t.status===`streaming`||void 0,showWorkingDot:!1}):(0,$.jsx)(`span`,{className:`size-7`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:j(`relative flex min-w-0 flex-col gap-1.5`,d?`max-w-[min(82%,30rem)] items-end`:`max-w-[min(84%,34rem)] items-start`),children:[p?(0,$.jsx)(`span`,{className:`mb-0.5 px-1 typography-micro text-muted-foreground/75`,children:i(`assistants.contact.peer.from`,{name:y})}):null,t.parts.map((n,a)=>{if(n.type===`card`&&n.cardType===`session`)return(0,$.jsx)(vn,{card:n},`${r}:card:${a}`);if(n.type===`card`&&n.cardType===`assistant`)return(0,$.jsx)(fn,{card:n},`${r}:card:${a}`);if(n.type===`card`&&n.cardType===`schedule`)return(0,$.jsx)(pn,{card:n},`${r}:card:${a}`);if(n.type===`file`)return(0,$.jsx)(Rt,{assistantID:e.id,part:n,onShowPopup:ne},`${r}:file:${a}`);if(n.type===`text`&&Pn(n.text))return null;if(n.type===`text`&&(n.text.trim()||t.status===`streaming`)){let e=!d;return(0,$.jsx)(`div`,{"aria-label":p?i(`assistants.contact.peer.aria`,{name:y}):void 0,"data-assistant-contact-text":``,className:j(`min-w-0 max-w-full [overflow-wrap:anywhere] rounded-[1.35rem] px-4 py-2.5 typography-markdown leading-6`,e?null:`whitespace-pre-wrap`,d?`rounded-[1.15rem] rounded-br-lg bg-[var(--primary-base)]/90 text-[var(--primary-foreground)]`:p?`rounded-[1.25rem] border border-dashed border-border/50 bg-[var(--surface-muted)]/70 text-foreground`:`bg-[var(--surface-muted)] text-foreground`),children:e?(0,$.jsx)(Ke,{content:n.text,messageId:r,isAnimated:!1,isStreaming:t.status===`streaming`,variant:`assistant`,enableFileReferences:!1,onShowPopup:ne,className:`w-full min-w-0 [overflow-wrap:anywhere]`}):n.text},`${r}:text:${a}`)}return null}),x?.status===`sending`?(0,$.jsx)(`p`,{className:`absolute right-1 top-full mt-1 typography-micro text-muted-foreground/75`,children:i(`assistants.contact.sending`)}):null,x?.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 typography-micro text-[var(--status-error)]`,children:x.error||i(`assistants.contact.sendFailed`)}):null,f?.messageID===t.messageID?(0,$.jsx)(xt,{assistantID:e.id,position:f},`${o}:${e.id}:${f.generation}:${f.ordinal}`):null]})]})]},r)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 left-[2.625rem] flex h-8 items-center`,"data-assistant-contact-status-slot":``,children:Z||Ce||we?(0,$.jsxs)(`div`,{role:`status`,"aria-label":i(`assistants.contact.processing`),className:`inline-flex items-center gap-1 px-4 text-muted-foreground/70`,"data-assistant-contact-processing":``,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.45s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.22s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-duration:1.4s] motion-reduce:animate-none`})]}):null})]})]}),(0,$.jsxs)(`footer`,{className:`relative z-10 shrink-0 bg-background pt-1`,"data-assistant-contact-composer":``,children:[F?(0,$.jsxs)(`div`,{className:`chat-input-column mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:F}),x.current?(0,$.jsx)(M,{type:`button`,size:`sm`,variant:`ghost`,disabled:Z,onClick:()=>void Re(),children:i(`chat.history.retry`)}):null]}):null,(0,$.jsx)(`form`,{className:j(`relative w-full pt-1.5 pb-4`,s&&`bottom-safe-area oc-mobile-composer`),onSubmit:e=>{e.preventDefault(),Re()},onDragOver:Ie,onDrop:Le,children:(0,$.jsx)(`div`,{className:`chat-input-column relative overflow-visible`,children:(0,$.jsx)(Mt,{active:n,layout:`inline`,value:g,attachments:v,pending:Z,working:Ce||we,onStop:Ce||we?()=>{ze()}:void 0,stopLabel:i(`chat.chatInput.actions.stopGeneratingAria`),isMobile:s,placeholder:i(`assistants.contact.placeholder`,{name:m}),sendLabel:i(`assistants.contact.send`),addFilesLabel:i(`assistants.contact.addFiles`),removeAttachmentLabel:i(`assistants.contact.removeAttachment`),fileAccept:`*/*`,onChange:e=>_(e),onVoiceSend:e=>{Re(e)},onSubmit:()=>{Re()},onAddFiles:e=>{Pe(e)},onRemoveAttachment:t=>{Z||(S.current.delete(`${e.id}:${t}`),x.current=null,b(e=>e.filter(e=>e.id!==t)))},onPaste:Fe,onDragOver:Ie,onDrop:Le,className:j(`relative z-10`,s&&`oc-mobile-composer-surface`),style:{borderRadius:`1.5rem`},"data-assistant-contact-composer-surface":``,textareaProps:{"aria-label":i(`assistants.contact.placeholder`,{name:m})}},`${o}:${e.id}`)})})]}),V.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Nn,{popup:V,onOpenChange:re,isMobile:s})}):null]})};async function Rn(e){await W(e);let t=ue.getState().defaultShareAssistant;if(t?.assistantID!==e.id)return;let n=await V();n.serverInstanceID&&t.serverInstanceID===n.serverInstanceID&&ue.getState().setDefaultShareAssistant(null)}function zn({assistant:e,open:t,onOpenChange:n,onDeleted:r}){let{t:i}=A(),[a,o]=Q.useState(!1),s=e?N(e.name).displayName||e.name:``,c=O(e=>{a&&!e||n(e)}),l=O(()=>{a||n(!1)}),u=O(async()=>{if(!(!e||a)){o(!0);try{await Rn(e),r?.(e.id),n(!1),C.success(i(`assistants.settings.toast.deleted`))}catch{C.error(i(`assistants.settings.toast.deleteFailed`))}finally{o(!1)}}});return(0,$.jsx)(_e,{open:t&&e!==null,onOpenChange:c,children:(0,$.jsxs)(me,{className:`max-w-md`,children:[(0,$.jsxs)(fe,{children:[(0,$.jsx)(he,{children:i(`assistants.settings.delete`)}),(0,$.jsx)(ge,{children:i(`assistants.settings.deleteConfirm`,{name:s})})]}),(0,$.jsxs)(pe,{children:[(0,$.jsx)(M,{size:`sm`,variant:`ghost`,onClick:l,disabled:a,children:i(`settings.common.actions.cancel`)}),(0,$.jsx)(M,{size:`sm`,variant:`destructive`,onClick:u,disabled:a,children:i(`settings.common.actions.delete`)})]})]})})}var Bn=`block min-w-0 max-w-full truncate typography-micro text-muted-foreground`,Vn={image:`assistants.contact.attachment.image`,file:`assistants.contact.attachment.file`,session:`assistants.contact.card.session.untitled`,assistant:`assistants.title`,schedule:`assistants.settings.scheduledTasks.title`};function Hn(e,t){return e?.text.replace(/\s+/gu,` `).trim()||t(e?.fallbackKind?Vn[e.fallbackKind]:`assistants.contact.empty`)}var Un=e=>e.capabilityPending?`loading`:e.capabilityError||e.supported!==!0||e.capabilityEnabled!==!0?`unavailable`:e.snapshotPending?`loading`:e.snapshotEnabled===!0?e.assistantCount===0?`onboarding`:e.hasAssistant?`ready`:e.snapshotSettled?`unavailable`:`loading`:`unavailable`,Wn=e({AssistantView:()=>qn}),Gn=e=>{let t=(0,st.c)(21),{assistant:n,onBack:r,onOpenSettings:i}=e,{t:a}=A(),o=we(),s;t[0]===n?s=t[1]:(s=n?N(n.name):null,t[0]=n,t[1]=s);let c=s,l=n&&c?c.displayName||n.name:``,u;t[2]!==n||t[3]!==o||t[4]!==i?(u=()=>{if(n){if(i){i(n.id);return}de(n.id,o?{openMobileSettings:o.openSettings}:void 0)}},t[2]=n,t[3]=o,t[4]=i,t[5]=u):u=t[5];let d=O(u),f;t[6]!==n||t[7]!==l||t[8]!==a?(f=n?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(pt,{name:n.id,avatarSeed:n.avatarSeed,size:40,label:l,working:!!(n.working||n.activeContactTurn),showWorkingDot:!1}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate font-medium leading-5 tracking-[-0.01em]`,children:l||a(`assistants.title`)}),(0,$.jsx)(bt,{assistantID:n.id,serverWorking:!!(n.working||n.activeContactTurn),lastContactAt:n.latestMessagePreview?.createdAt})]})]}):l||a(`assistants.title`),t[6]=n,t[7]=l,t[8]=a,t[9]=f):f=t[9];let p;t[10]===a?p=t[11]:(p=a(`assistants.actions.backToChat`),t[10]=a,t[11]=p);let m;t[12]!==n||t[13]!==d||t[14]!==a?(m=n?[{icon:`settings-3`,ariaLabel:a(`assistants.conversation.openSettings`),onClick:d}]:[],t[12]=n,t[13]=d,t[14]=a,t[15]=m):m=t[15];let h;return t[16]!==r||t[17]!==f||t[18]!==p||t[19]!==m?(h=(0,$.jsx)(re,{title:f,backAriaLabel:p,onBack:r,actions:m,overlay:!0}),t[16]=r,t[17]=f,t[18]=p,t[19]=m,t[20]=h):h=t[20],h},Kn=e=>{let t=(0,st.c)(53),{avatarSeed:n,unreadCount:r,summary:i,assistantID:a,displayName:o,selected:s,enabled:c,editLabel:l,deleteLabel:u,onSelect:d,onEdit:f,onDelete:p,serverWorking:m}=e,h=ft(a,m!==void 0&&m),[g,_]=Q.useState(!1),v;t[0]===d?v=t[1]:(v=()=>d(),t[0]=d,t[1]=v);let y=O(v),b;t[2]===f?b=t[3]:(b=()=>{_(!1),f()},t[2]=f,t[3]=b);let x=O(b),S;t[4]===p?S=t[5]:(S=()=>{_(!1),p()},t[4]=p,t[5]=S);let C=O(S),w;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>{e.preventDefault(),_(!0)},t[6]=w):w=t[6];let T=s?`border-border/50 bg-[var(--surface-elevated)]`:`border-transparent hover:bg-interactive-hover`,E=!c&&`opacity-65`,D;t[7]!==T||t[8]!==E?(D=j(`flex w-full min-h-11 items-center gap-3 rounded-xl border px-3 py-3 text-left outline-none transition-[background-color,border-color,opacity] duration-150 ease-out active:bg-interactive-active focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,T,E),t[7]=T,t[8]=E,t[9]=D):D=t[9];let k;t[10]!==y||t[11]!==s||t[12]!==D?(k=(0,$.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":s,onClick:y,onContextMenu:w,className:D}),t[10]=y,t[11]=s,t[12]=D,t[13]=k):k=t[13];let A;t[14]!==a||t[15]!==n||t[16]!==o||t[17]!==h?(A=(0,$.jsx)(pt,{name:a,avatarSeed:n,size:44,label:o,working:h}),t[14]=a,t[15]=n,t[16]=o,t[17]=h,t[18]=A):A=t[18];let M=s?`font-semibold`:`font-medium`,N;t[19]===M?N=t[20]:(N=j(`block truncate typography-ui-label leading-5`,M),t[19]=M,t[20]=N);let P;t[21]!==o||t[22]!==N?(P=(0,$.jsx)(`span`,{className:N,children:o}),t[21]=o,t[22]=N,t[23]=P):P=t[23];let F;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(F=j(Bn,`mt-1 leading-5`),t[24]=F):F=t[24];let I;t[25]===i?I=t[26]:(I=(0,$.jsx)(`span`,{className:F,children:i}),t[25]=i,t[26]=I);let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]===r?R=t[31]:(R=(0,$.jsx)(nt,{count:r}),t[30]=r,t[31]=R);let z;t[32]!==A||t[33]!==L||t[34]!==R||t[35]!==k?(z=(0,$.jsxs)(Qe,{render:k,children:[A,L,R]}),t[32]=A,t[33]=L,t[34]=R,t[35]=k,t[36]=z):z=t[36];let B;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(X,{name:`edit`,className:`size-4`}),t[37]=B):B=t[37];let V;t[38]!==l||t[39]!==x?(V=(0,$.jsxs)(et,{onClick:x,children:[B,l]}),t[38]=l,t[39]=x,t[40]=V):V=t[40];let H;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(Ze,{}),t[41]=H):H=t[41];let U;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),t[42]=U):U=t[42];let ee;t[43]!==u||t[44]!==C?(ee=(0,$.jsxs)(et,{onClick:C,className:`text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,children:[U,u]}),t[43]=u,t[44]=C,t[45]=ee):ee=t[45];let W;t[46]!==V||t[47]!==ee?(W=(0,$.jsxs)($e,{className:`min-w-[10rem]`,children:[V,H,ee]}),t[46]=V,t[47]=ee,t[48]=W):W=t[48];let te;return t[49]!==g||t[50]!==z||t[51]!==W?(te=(0,$.jsxs)(Xe,{open:g,onOpenChange:_,children:[z,W]}),t[49]=g,t[50]=z,t[51]=W,t[52]=te):te=t[52],te},qn=e=>{let t=(0,st.c)(118),{activeOverride:i,onMobileBack:a,onMobileOpenSettings:o}=e,{t:s}=A(),{isMobile:c}=ve(),l=we(),u=Q.useSyncExternalStore(n,r,r),d=y(Jn),f=i??d,p=y(Yn),m=c||p,h=z(),g=B(),_=g.data;_?.assistants;let v;t[0]===_?.assistants?v=t[1]:(v=_?.assistants??[],t[0]=_?.assistants,t[1]=v);let b;t[2]===v?b=t[3]:(b=ct(v),t[2]=v,t[3]=b);let x=b,S;t[4]===u?S=t[5]:(S=e=>e.assistantByTransport[u]??null,t[4]=u,t[5]=S);let C=ue(S),w=ue(Xn),T=ue(Zn),E;t[6]!==C||t[7]!==_?.assistants?(E=_?.assistants.find(e=>e.id===C)??null,t[6]=C,t[7]=_?.assistants,t[8]=E):E=t[8];let D=E,k;t[9]!==w||t[10]!==C||t[11]!==_?(k=()=>{!C&&_?.assistants[0]&&w(_.assistants[0].id)},t[9]=w,t[10]=C,t[11]=_,t[12]=k):k=t[12];let P=_?.assistants,F;t[13]!==w||t[14]!==C||t[15]!==P?(F=[w,C,P],t[13]=w,t[14]=C,t[15]=P,t[16]=F):F=t[16],Q.useEffect(k,F);let I;t[17]!==D||t[18]!==w||t[19]!==C||t[20]!==_?.assistants||t[21]!==g.isSuccess?(I=()=>{g.isSuccess&&C&&!D&&w(_?.assistants[0]?.id??null)},t[17]=D,t[18]=w,t[19]=C,t[20]=_?.assistants,t[21]=g.isSuccess,t[22]=I):I=t[22];let L=_?.assistants,R;t[23]!==D||t[24]!==w||t[25]!==C||t[26]!==g.isSuccess||t[27]!==L?(R=[D,w,C,L,g.isSuccess],t[23]=D,t[24]=w,t[25]=C,t[26]=g.isSuccess,t[27]=L,t[28]=R):R=t[28],Q.useEffect(I,R);let V;t[29]!==l||t[30]!==T?(V=()=>{if(T(),l){l.openSettings();return}let e=y.getState();e.setSettingsPage(`assistants`),e.setSettingsDialogOpen(!0)},t[29]=l,t[30]=T,t[31]=V):V=t[31];let H=O(V),U;t[32]===l?U=t[33]:(U=e=>{de(e,l?{openMobileSettings:l.openSettings}:void 0)},t[32]=l,t[33]=U);let ee=O(U),W;t[34]!==D||t[35]!==l?(W=()=>{D&&de(D.id,l?{openMobileSettings:l.openSettings}:void 0)},t[34]=D,t[35]=l,t[36]=W):W=t[36];let te=O(W),[ne,re]=Q.useState(null),G;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(G=e=>{re(e)},t[37]=G):G=t[37];let ie=O(G),ae;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{e||re(null)},t[38]=ae):ae=t[38];let K=O(ae),oe=O(Qn),se;t[39]!==a||t[40]!==oe?(se=()=>{if(a){a();return}oe()},t[39]=a,t[40]=oe,t[41]=se):se=t[41];let q=O(se),ce=Un({capabilityPending:h.isPending,snapshotPending:g.isPending,capabilityError:h.isError,supported:h.data?.supported,capabilityEnabled:h.data?.enabled,snapshotEnabled:_?.enabled,snapshotSettled:g.isSuccess,assistantCount:_?.assistants.length??0,hasAssistant:!!D}),le;t[42]!==D||t[43]!==q||t[44]!==m||t[45]!==o?(le=(e,t,n,r)=>(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[m?(0,$.jsx)(Gn,{assistant:D,onBack:q,onOpenSettings:o}):null,(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,children:[(0,$.jsx)(X,{name:e,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`mt-4 typography-ui-header font-semibold`,children:t}),n?(0,$.jsx)(`p`,{className:`mt-2 max-w-md typography-ui text-muted-foreground`,children:n}):null,r?(0,$.jsx)(`div`,{className:`mt-5`,children:r}):null]})]}),t[42]=D,t[43]=q,t[44]=m,t[45]=o,t[46]=le):le=t[46];let J=le;if(ce===`loading`){let e;t[47]!==D||t[48]!==q||t[49]!==m||t[50]!==o?(e=m?(0,$.jsx)(Gn,{assistant:D,onBack:q,onOpenSettings:o}):null,t[47]=D,t[48]=q,t[49]=m,t[50]=o,t[51]=e):e=t[51];let n;t[52]===s?n=t[53]:(n=s(`common.loading`),t[52]=s,t[53]=n);let r;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(X,{name:`loader-4`,className:`size-6 animate-spin text-muted-foreground`}),t[54]=r):r=t[54];let i;t[55]===n?i=t[56]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,"aria-busy":`true`,"aria-label":n,"data-assistant-workspace-loading":``,children:r}),t[55]=n,t[56]=i);let a;return t[57]!==e||t[58]!==i?(a=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[e,i]}),t[57]=e,t[58]=i,t[59]=a):a=t[59],a}if(ce===`unavailable`){let e;return t[60]!==J||t[61]!==s?(e=J(`cloud-off`,s(`assistants.state.unavailable`)),t[60]=J,t[61]=s,t[62]=e):e=t[62],e}if(ce===`onboarding`){let e;if(t[63]!==H||t[64]!==J||t[65]!==s){let n=s(`assistants.onboarding.title`),r=s(`assistants.onboarding.description`),i;t[67]===s?i=t[68]:(i=s(`assistants.onboarding.action`),t[67]=s,t[68]=i);let a;t[69]!==H||t[70]!==i?(a=(0,$.jsx)(M,{onClick:H,children:i}),t[69]=H,t[70]=i,t[71]=a):a=t[71],e=J(`ai-agent`,n,r,a),t[63]=H,t[64]=J,t[65]=s,t[66]=e}else e=t[66];return e}if(!_||!D){let e;return t[72]!==J||t[73]!==s?(e=J(`cloud-off`,s(`assistants.state.unavailable`)),t[72]=J,t[73]=s,t[74]=e):e=t[74],e}let Y;t[75]===D.name?Y=t[76]:(Y=N(D.name),t[75]=D.name,t[76]=Y);let fe=Y,pe;t[77]!==D.enabled||t[78]!==g.isError||t[79]!==s?(pe=D.enabled?g.isError?s(`assistants.state.staleSnapshot`):null:s(`assistants.state.assistantDisabled`),t[77]=D.enabled,t[78]=g.isError,t[79]=s,t[80]=pe):pe=t[80];let me=pe,he;t[81]!==x||t[82]!==m||t[83]!==H||t[84]!==ee||t[85]!==ie||t[86]!==w||t[87]!==C||t[88]!==_||t[89]!==s?(he=m?null:(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 w-[clamp(16rem,22vw,20rem)] shrink-0 flex-col overflow-hidden`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 px-4 pb-3 pt-4 sm:px-5`,children:[(0,$.jsx)(`h1`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:s(`assistants.title`)}),(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":s(`assistants.settings.create`),onClick:H,children:(0,$.jsx)(X,{name:`add`,className:`size-4`})})]}),(0,$.jsx)(lt,{snapshot:_,rowClassName:`flex justify-end px-4 pb-2 sm:px-5`}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4 sm:px-4`,role:`listbox`,"aria-label":s(`assistants.listAria`),children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1 border-t border-border/40 pt-3`,children:x.map(e=>{let t=e.id===C,n=N(e.name);return(0,$.jsx)(Kn,{assistantID:e.id,avatarSeed:e.avatarSeed,unreadCount:e.unreadCount??0,summary:Hn(e.latestMessagePreview,s),displayName:n.displayName,selected:t,enabled:e.enabled,editLabel:s(`assistants.menu.edit`),deleteLabel:s(`assistants.settings.delete`),assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onSelect:()=>w(e.id),onEdit:()=>ee(e.id),onDelete:()=>ie(e)},e.id)})})})]}),t[81]=x,t[82]=m,t[83]=H,t[84]=ee,t[85]=ie,t[86]=w,t[87]=C,t[88]=_,t[89]=s,t[90]=he):he=t[90];let ge=ne!==null,_e;t[91]!==ne||t[92]!==K||t[93]!==ge?(_e=(0,$.jsx)(zn,{assistant:ne,open:ge,onOpenChange:K}),t[91]=ne,t[92]=K,t[93]=ge,t[94]=_e):_e=t[94];let ye=!m&&`border-l border-[var(--surface-subtle)]`,be;t[95]===ye?be=t[96]:(be=j(`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background`,ye),t[95]=ye,t[96]=be);let xe;t[97]!==D||t[98]!==q||t[99]!==m||t[100]!==o||t[101]!==te||t[102]!==fe||t[103]!==s?(xe=m?(0,$.jsx)(Gn,{assistant:D,onBack:q,onOpenSettings:o}):(0,$.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-3.5 border-b border-[var(--surface-subtle)]/70 px-5 sm:px-7`,children:[(0,$.jsx)(pt,{name:D.id,avatarSeed:D.avatarSeed,size:40,label:fe.displayName||D.name,working:!!(D.working||D.activeContactTurn),showWorkingDot:!1}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate typography-ui-label font-semibold leading-5 tracking-[-0.01em] text-foreground`,children:fe.displayName}),(0,$.jsx)(bt,{assistantID:D.id,serverWorking:!!(D.working||D.activeContactTurn),lastContactAt:D.latestMessagePreview?.createdAt})]}),(0,$.jsx)(M,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 rounded-full text-muted-foreground/65 transition-colors hover:text-foreground`,onClick:te,"aria-label":s(`assistants.conversation.openSettings`),children:(0,$.jsx)(X,{name:`settings-3`,className:`size-4`})})]}),t[97]=D,t[98]=q,t[99]=m,t[100]=o,t[101]=te,t[102]=fe,t[103]=s,t[104]=xe):xe=t[104];let Se;t[105]!==f||t[106]!==D||t[107]!==m||t[108]!==me?(Se=(0,$.jsx)(Ln,{assistant:D,warning:me,active:f,overlayHeader:m}),t[105]=f,t[106]=D,t[107]=m,t[108]=me,t[109]=Se):Se=t[109];let Z;t[110]!==be||t[111]!==xe||t[112]!==Se?(Z=(0,$.jsxs)(`div`,{className:be,children:[xe,Se]}),t[110]=be,t[111]=xe,t[112]=Se,t[113]=Z):Z=t[113];let Ce;return t[114]!==he||t[115]!==_e||t[116]!==Z?(Ce=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 overflow-hidden bg-background`,"data-presentation":`workspace`,children:[he,_e,Z]}),t[114]=he,t[115]=_e,t[116]=Z,t[117]=Ce):Ce=t[117],Ce};function Jn(e){return e.activeMainTab===`assistant`}function Yn(e){return e.isMobile}function Xn(e){return e.selectAssistant}function Zn(e){return e.requestCreate}function Qn(){y.getState().setActiveMainTab(`chat`)}export{zn as a,lt as c,Hn as i,ct as l,Wn as n,pt as o,Bn as r,ft as s,qn as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,rt as n}from"./vendor-base-ui-CdzJ6My_.js";import{n as r}from"./vendor-react-BP2cRVqX.js";import{r as i}from"./button-CWSs9Baz.js";var a=500,o=12,s=(e={})=>{let t=e.delayMs??a,n=(e.moveThresholdPx??o)**2,r=e.schedule??((e,t)=>setTimeout(e,t)),i=e.clear??(e=>clearTimeout(e)),s=null,c=null,l=(t=!1)=>{s&&(i(s.timer),s=null,t||e.onPressedKeyChange?.(null))};return{start:({pointerId:n,key:i,clientX:a,clientY:o,onTrigger:u})=>{l(),e.onPressedKeyChange?.(i),s={pointerId:n,key:i,startX:a,startY:o,timer:r(()=>{!s||s.pointerId!==n||s.key!==i||(s.triggered=!0,c=i,u())},t),triggered:!1}},move:(e,t,r)=>{if(s?.pointerId!==e||s.triggered)return;let i=t-s.startX,a=r-s.startY;i*i+a*a>n&&l()},end:e=>{s?.pointerId===e&&l(s.triggered)},cancel:e=>{s?.pointerId===e&&l()},openFromContextMenu:(t,n)=>{l(),c=t,e.onPressedKeyChange?.(t),n()},consumeClick:e=>c===e&&(c=null,!0),reset:()=>{l(),c=null,e.onPressedKeyChange?.(null)}}},c=`#openchamber-skill:`,l=`#openchamber-agent:`,u=e=>`https://opencode.ai/docs/agents/#${encodeURIComponent(e)}`,d=e=>`${c}${encodeURIComponent(e)}`,f=e=>`${l}${encodeURIComponent(e)}`,p=e=>{if(!e?.startsWith(c))return null;try{return decodeURIComponent(e.slice(19))}catch{return null}},m=e=>{if(!e?.startsWith(l))return null;try{return decodeURIComponent(e.slice(19))}catch{return null}},h=[`user-blocking`,`visible`,`background`],g=e=>{let t={"user-blocking":{head:null,tail:null},visible:{head:null,tail:null},background:{head:null,tail:null}},n=Math.max(1,Math.floor(e.maxTasksPerFrame)),r=Math.max(1,e.frameBudgetMs),i=null,a=!1,o=0,s=e=>{let n=t[e.priority];e.previous=n.tail,n.tail?n.tail.next=e:n.head=e,n.tail=e},c=e=>{let n=t[e.priority];e.previous?e.previous.next=e.next:n.head=e.next,e.next?e.next.previous=e.previous:n.tail=e.previous,e.next=null,e.previous=null},l=()=>{for(let e of h){let n=t[e].head;if(n)return c(n),n.consumed=!0,--o,n}return null},u=()=>{i===null&&o!==0&&(i=e.requestFrame(d))},d=()=>{i=null;let t=e.now(),a=0;for(;o>0&&a<n;){let n=l();if(!n||(n.run(),a+=1,e.now()-t>=r))break}u()},f=()=>{i!==null||a||o===0||(a=!0,i=e.requestFrame(()=>{i=null,a=!1,u()}))};return{enqueue(t,n){let r={cancelled:!1,consumed:!1,next:null,previous:null,priority:n?.priority??`background`,run:t};return s(r),o+=1,!a&&i===null&&f(),()=>{r.cancelled||r.consumed||(r.cancelled=!0,c(r),--o,o===0&&(i!==null&&(e.cancelFrame(i),i=null),a=!1))}},clear(){for(let e of h){let n=t[e],r=n.head;for(;r;){let e=r.next;r.cancelled=!0,r.next=null,r.previous=null,r=e}n.head=null,n.tail=null}o=0,i!==null&&(e.cancelFrame(i),i=null),a=!1}}},_=null,v=()=>typeof window>`u`?null:_||(_=g({requestFrame:e=>window.requestAnimationFrame(e),cancelFrame:e=>window.cancelAnimationFrame(e),now:()=>performance.now(),maxTasksPerFrame:2,frameBudgetMs:6}),_),y=(e,t)=>{let n=v();return n?n.enqueue(e,t):(e(),()=>{})},b={textThrottleMs:20,markdownPaceMs:64},x={textThrottleMs:100,markdownPaceMs:128},S=e=>e===`android`?x:b,C=r(),w=e(t(),1),T=n(),E=w.createContext(!1),D=e=>{let t=(0,C.c)(3),{disabled:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,T.jsx)(E.Provider,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i},O=e=>{let t=(0,C.c)(8),{children:n,className:r}=e,[a,o]=w.useState(!1),s,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=null,t=()=>o(!0);return typeof window<`u`&&typeof window.requestAnimationFrame==`function`?e=window.requestAnimationFrame(t):t(),()=>{e!==null&&typeof window<`u`&&typeof window.cancelAnimationFrame==`function`&&window.cancelAnimationFrame(e)}},c=[],t[0]=s,t[1]=c):(s=t[0],c=t[1]),w.useEffect(s,c);let l=a?`opacity-100 translate-y-0`:`opacity-0 translate-y-2`,u;t[2]!==r||t[3]!==l?(u=i(`w-full transition-all duration-300 ease-out`,l,r),t[2]=r,t[3]=l,t[4]=u):u=t[4];let d;return t[5]!==n||t[6]!==u?(d=(0,T.jsx)(`div`,{className:u,children:n}),t[5]=n,t[6]=u,t[7]=d):d=t[7],d},k=e=>{let t=(0,C.c)(5),{children:n,className:r,skipAnimation:i,forceAnimation:a,ignoreContextDisabled:o,respectReducedMotion:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,u=s!==void 0&&s,d=w.useContext(E),f=u&&typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;if(!c||i||!l&&d||f){let e;return t[0]===n?e=t[1]:(e=(0,T.jsx)(T.Fragment,{children:n}),t[0]=n,t[1]=e),e}let p;return t[2]!==n||t[3]!==r?(p=(0,T.jsx)(O,{className:r,children:n}),t[2]=n,t[3]=r,t[4]=p):p=t[4],p};export{f as a,m as c,y as i,p as l,k as n,u as o,S as r,d as s,D as t,s as u};