@yuriai/web 0.2.38-beta.3 → 0.2.38-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-CAC4rKO_.js → AgentAvatar-CjZAr6nn.js} +1 -1
- package/dist/assets/AssistantContactStatus-DoZk9r1D.js +3 -0
- package/dist/assets/AssistantUnreadBadge-BJHZUf6Z.js +1 -0
- package/dist/assets/AssistantView-DkjXm6xL.js +1 -0
- package/dist/assets/DiagramView-Byel_g4U.js +1 -0
- package/dist/assets/{FadeInOnReveal--aVey7kZ.js → FadeInOnReveal-BrPG6IFE.js} +1 -1
- package/dist/assets/GuiPluginPage-C6iXAYM8.js +1 -0
- package/dist/assets/GuiPluginSurface-DPXPl4xG.js +1 -0
- package/dist/assets/GuiPluginWindow-BdtIwEmZ.js +1 -0
- package/dist/assets/{Icon-h0JiZMjp.js → Icon-C5rHjO1K.js} +1 -1
- package/dist/assets/ImageLoadingPlaceholder-Cdj2zS3j.js +1 -0
- package/dist/assets/LoadingImage-Gh9OduKR.js +1 -0
- package/dist/assets/MarkdownRenderer-DErp8UoS.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-MYwBFYBA.js → MarkdownRendererImpl-H41Q6Ds9.js} +3 -3
- package/dist/assets/MarkstreamRendererImpl-CJcHC4Ts.js +3 -0
- package/dist/assets/MobileDetailNavigation-fdYiFD76.js +1 -0
- package/dist/assets/MobileResizableSheet-DDzgYZmt.js +1 -0
- package/dist/assets/MobileShareBridge-BNPPhHGf.js +3 -0
- package/dist/assets/MobileTabPageHeader-ZZPrTJl4.js +2 -0
- package/dist/assets/MultiRunWindow-DoeszXM5.js +1 -0
- package/dist/assets/OnboardingScreen-BrYqOlrO.js +1 -0
- package/dist/assets/{OverlayScrollbar-DMbq1jNO.js → OverlayScrollbar-8lCP3DZq.js} +1 -1
- package/dist/assets/SettingsView-UuXi7Uya.js +29 -0
- package/dist/assets/SettingsWindow-DIYoXakh.js +1 -0
- package/dist/assets/SetupTourDialog-BF50uUTW.js +1 -0
- package/dist/assets/TerminalView-uVsRpvjV.js +8 -0
- package/dist/assets/ToolOutputDialog-Bz23N8ob.js +10 -0
- package/dist/assets/VoiceSettings-DbbeM4JG.js +2 -0
- package/dist/assets/YuriLogo-DcoYyXzq.js +1 -0
- package/dist/assets/YuriWordmark-Dlsq3scd.js +1 -0
- package/dist/assets/appThemeRegistry-DE7vwd6j.js +1 -0
- package/dist/assets/{assistant-attachment-cache-C-SlEpSB.js → assistant-attachment-cache-Cmzt4xXE.js} +1 -1
- package/dist/assets/bootstrap-BhC95qVC.js +1 -0
- package/dist/assets/{capgoAdapter-C1AUTwaK.js → capgoAdapter-BPZyUAQO.js} +1 -1
- package/dist/assets/{checkbox-DR7tyhFb.js → checkbox-Dgn0NjAK.js} +1 -1
- package/dist/assets/{collapsible-C8DgipZf.js → collapsible-DbkDwHwV.js} +1 -1
- package/dist/assets/{context-menu-BfLJgbjE.js → context-menu-HomYNhkr.js} +1 -1
- package/dist/assets/desktopHosts-DovfbQPm.js +1 -0
- package/dist/assets/desktopRelayRestore-D4pbpNKN.js +1 -0
- package/dist/assets/device-DNG0cNwQ.js +2 -0
- package/dist/assets/{diagram-0lT2w7uS.js → diagram-if-ktgjK.js} +1 -1
- package/dist/assets/dialog-0fjbRGoX.js +1 -0
- package/dist/assets/{es-CrVDn7XV.js → es-30Wqm-Bx.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-BhQqAWYa.js → fileMentionTouchSelection-OwF_hr-t.js} +1 -1
- package/dist/assets/{fileQueries-BaEKb7SZ.js → fileQueries-D9l0crnM.js} +1 -1
- package/dist/assets/fileReferenceActions-BRF8f7uA.js +1 -0
- package/dist/assets/{fileReferenceParser-BayaidRM.js → fileReferenceParser-1HHDBUum.js} +1 -1
- package/dist/assets/{fr-CCwt5AOu.js → fr-BbWLXNYa.js} +1 -1
- package/dist/assets/{gitApi-CWUhy6kY.js → gitApi-dAPSCbXA.js} +8 -8
- package/dist/assets/gitApiHttp-B1mApXwC.js +9 -0
- package/dist/assets/{gui-CFdPKvfq.js → gui-DN2sVP96.js} +1 -1
- package/dist/assets/{historyImportQueries-BrhVXQhP.js → historyImportQueries-DkB2_92i.js} +1 -1
- package/dist/assets/host-kMLXU0hK.js +1 -0
- package/dist/assets/i18n-BU14awhU.js +1 -0
- package/dist/assets/image-loading-DEXNCcCm.js +1 -0
- package/dist/assets/{input-Baq2dV0C.js → input-DYmLJuhI.js} +1 -1
- package/dist/assets/insertionBoundaries-CYfwgLf1.js +1 -0
- package/dist/assets/{ja-BfwjUNPc.js → ja-BI7m9bgW.js} +1 -1
- package/dist/assets/{ko-CZQZFkal.js → ko-B89SVFZa.js} +1 -1
- package/dist/assets/main-CaueNFt7.js +169 -0
- package/dist/assets/main-DrIci_pj.js +2 -0
- package/dist/assets/{markdownHeightCache-BEb1XAlf.js → markdownHeightCache-D8yqNy2h.js} +1 -1
- package/dist/assets/mcpQueries-DO2TKARf.js +1 -0
- package/dist/assets/miniChat-BTI2ObZ2.js +2 -0
- package/dist/assets/mobile-Cf_sQtW6.js +2 -0
- package/dist/assets/mobile-html-network-CsjZ_Ur0.js +2 -0
- package/dist/assets/mobile-network-bridge-B_h92A-9.js +1 -0
- package/dist/assets/mobileBackNavigation-DxG3cz8q.js +1 -0
- package/dist/assets/mobileConnections-CK4dMDCg.js +2 -0
- package/dist/assets/modulepreload-polyfill-P2Xu9kJm.js +1 -0
- package/dist/assets/multirun-Cd2-PUEk.js +3 -0
- package/dist/assets/native-config-C_nB8tLu.js +1 -0
- package/dist/assets/pages-CYkE04ml.js +1 -0
- package/dist/assets/path-utils-jGozTg9d.js +1 -0
- package/dist/assets/pathNormalization-ewtPqJWn.js +1 -0
- package/dist/assets/{pl-B6C3vXqv.js → pl-B55Lf3HE.js} +1 -1
- package/dist/assets/platform-DMsFWy1a.js +1 -0
- package/dist/assets/projectMeta-apTlCt8d.js +1 -0
- package/dist/assets/{pt-BR-BUDTNopP.js → pt-BR-CFZj-ECy.js} +1 -1
- package/dist/assets/pwa-wwvKWKhX.js +2 -0
- package/dist/assets/queue-abort-optimistic-BnynR3mX.js +1 -0
- package/dist/assets/react-B-mb0CtR.js +1 -0
- package/dist/assets/readiness-0tATst8c.js +1 -0
- package/dist/assets/reasoning-projection-client-BEhVknv9.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-xQdVdaLB.js +2 -0
- package/dist/assets/renderMobileApp-D95eHLRE.js +29 -0
- package/dist/assets/{runtime-auth-Bh3htXtG.js → runtime-auth-mjIpsk3N.js} +1 -1
- package/dist/assets/runtime-fetch-DKZOpfzo.js +1 -0
- package/dist/assets/runtime-file-download-DMY1k1af.js +1 -0
- package/dist/assets/runtime-file-resource-CL7EVzOG.js +2 -0
- package/dist/assets/runtime-switch-BMjl5Y5W.js +1 -0
- package/dist/assets/runtimeAPIRegistry-C2VogTny.js +1 -0
- package/dist/assets/runtimeConfig-BfzZj4LK.js +2 -0
- package/dist/assets/runtimeEndpointReset-CjKHwDvh.js +149 -0
- package/dist/assets/{scheduledTaskNavigation-C8tBjNoP.js → scheduledTaskNavigation-PH-etFzZ.js} +1 -1
- package/dist/assets/select-B9Km1pk9.js +1 -0
- package/dist/assets/sessionLookup-8gdDN8Tx.js +1 -0
- package/dist/assets/sortable-tabs-strip-BU0Puyy0.js +1 -0
- package/dist/assets/{speechSettingsQueries-C4eOkV7q.js → speechSettingsQueries-C9LCquzH.js} +1 -1
- package/dist/assets/src-BFQde2OG.css +2 -0
- package/dist/assets/{store-Myt_Fv8d.js → store-BNNIbb4k.js} +3 -3
- package/dist/assets/terminalApi-BXKIVBPo.js +1 -0
- package/dist/assets/textarea-bB6aD-GS.js +1 -0
- package/dist/assets/{tooltip-CxneNjeR.js → tooltip-DgWHbKz2.js} +1 -1
- package/dist/assets/{types-hxNDOWGs.js → types-CnJjf4tP.js} +1 -1
- package/dist/assets/{uk-Ct9y1Y2t.js → uk-CS2c4Dtj.js} +1 -1
- package/dist/assets/{useAppFontEffects-C9muit_c.js → useAppFontEffects-DJp1u2mc.js} +35 -35
- package/dist/assets/{useAssistantUIStore-CVSFSgJV.js → useAssistantUIStore-Du8puXWz.js} +1 -1
- package/dist/assets/useDesktopWindowControlsLayout-DOmb8EnW.js +1 -0
- package/dist/assets/useDictation-CyWtsxSn.js +1 -0
- package/dist/assets/useEffectiveDirectory-DmGrksdp.js +1 -0
- package/dist/assets/{useFontPreferences-DqBoLHp6.js → useFontPreferences-CAdw6cBK.js} +1 -1
- package/dist/assets/useMobileHtmlPreviewStore-C03uVLfX.js +1 -0
- package/dist/assets/useMobileNavigationStore-CJBLQxTz.js +17 -0
- package/dist/assets/usePluginsStore-El9Tx9Q3.js +1 -0
- package/dist/assets/useStreamingTextThrottle-BbUkYQhX.js +1 -0
- package/dist/assets/useUIStore-BF882_0b.js +1 -0
- package/dist/assets/useWorkerHighlightedLines-CZ8YG-Hi.js +7 -0
- package/dist/assets/{zh-CN-BegPizz4.js → zh-CN-BpiwUUs4.js} +1 -1
- package/dist/assets/{zh-TW-4xftqQQG.js → zh-TW-Bl9CnlGi.js} +1 -1
- package/dist/index.html +26 -21
- package/dist/mini-chat.html +26 -21
- package/dist/mobile.html +4 -32
- package/package.json +1 -1
- package/server/index.js +10 -0
- package/server/lib/gui-customization/skill/references/global-pages.md +18 -3
- package/server/lib/gui-network/DOCUMENTATION.md +123 -0
- package/server/lib/gui-network/native-ios.test.js +127 -0
- package/server/lib/gui-network/runtime.js +146 -0
- package/server/lib/gui-network/runtime.test.js +129 -0
- package/server/lib/preview/proxy-runtime.js +1 -1
- package/server/lib/preview/proxy-runtime.test.js +4 -0
- package/server/lib/relay/DOCUMENTATION.md +5 -0
- package/server/lib/relay/tunnel-host.js +2 -1
- package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
- package/server/lib/ui-auth/ui-auth.js +6 -0
- package/server/lib/ui-auth/ui-auth.test.js +10 -0
- package/dist/assets/AssistantContactStatus-Co_TnYMc.js +0 -3
- package/dist/assets/AssistantUnreadBadge-DqJFhaNg.js +0 -1
- package/dist/assets/AssistantView-D6fdLgFj.js +0 -1
- package/dist/assets/DiagramView-tx4upWOs.js +0 -1
- package/dist/assets/GuiPluginSurface-Bd3v_5A8.js +0 -1
- package/dist/assets/GuiPluginWindow-fy3lT5ns.js +0 -1
- package/dist/assets/ImageLoadingPlaceholder-A2tjfBfo.js +0 -1
- package/dist/assets/LoadingImage-C4DsIEui.js +0 -1
- package/dist/assets/MarkdownRenderer-BfAZBFzv.js +0 -2
- package/dist/assets/MarkstreamRendererImpl-13XA9vlX.js +0 -3
- package/dist/assets/MobileDetailNavigation-UU1cGYp2.js +0 -1
- package/dist/assets/MobileResizableSheet-nUZzBOmQ.js +0 -1
- package/dist/assets/MobileShareBridge-IWtj1SYy.js +0 -4
- package/dist/assets/MobileTabPageHeader-Diplic-W.js +0 -2
- package/dist/assets/MultiRunWindow-CHdpFi_v.js +0 -1
- package/dist/assets/OnboardingScreen-CeQxPD6C.js +0 -1
- package/dist/assets/SettingsView-CxHpCSsu.js +0 -29
- package/dist/assets/SettingsWindow-DEEHLurG.js +0 -1
- package/dist/assets/SetupTourDialog-5w42fqYN.js +0 -1
- package/dist/assets/TerminalView-DAx8JZmn.js +0 -8
- package/dist/assets/ToolOutputDialog-CbGuK5bP.css +0 -1
- package/dist/assets/ToolOutputDialog-CoKt-9rk.js +0 -10
- package/dist/assets/VoiceSettings-BFCJ8d-d.js +0 -2
- package/dist/assets/YuriLogo-BFawEKZ2.js +0 -1
- package/dist/assets/YuriWordmark-CJ8qJ14A.js +0 -1
- package/dist/assets/appThemeRegistry-CbyMACnN.js +0 -1
- package/dist/assets/bootstrap-BzeQds0D.js +0 -9
- package/dist/assets/desktop-Brp3xDpd.js +0 -1
- package/dist/assets/desktopHosts-qQ2Rz26_.js +0 -1
- package/dist/assets/desktopRelayRestore-DifJHAur.js +0 -1
- package/dist/assets/device-Db_TcRdX.js +0 -2
- package/dist/assets/dialog-Kz0pw-SO.js +0 -1
- package/dist/assets/fileReferenceActions-D06_lyuL.js +0 -1
- package/dist/assets/host-D_6AN-1g.js +0 -1
- package/dist/assets/image-loading-D1DfK_bJ.js +0 -1
- package/dist/assets/insertionBoundaries-Bfzw2QQw.js +0 -1
- package/dist/assets/main-CeqfStCn.js +0 -2
- package/dist/assets/main-c0X9U5aG.js +0 -169
- package/dist/assets/mcpQueries-DtBlC0VK.js +0 -1
- package/dist/assets/miniChat-TSOpbP39.js +0 -2
- package/dist/assets/mobile-W2QaGheB.js +0 -2
- package/dist/assets/mobileBackNavigation-Dy-OW7DB.js +0 -1
- package/dist/assets/multirun-O7LH-36l.js +0 -3
- package/dist/assets/native-config-CGAqvpqz.js +0 -1
- package/dist/assets/path-utils-HRmerlyU.js +0 -1
- package/dist/assets/platform-Dids8J9D.js +0 -1
- package/dist/assets/projectMeta-B2LbasoM.js +0 -1
- package/dist/assets/pwa-BHki-tGS.js +0 -2
- package/dist/assets/queue-abort-optimistic-DaJr8CmG.js +0 -1
- package/dist/assets/react-a6PrrNTm.js +0 -1
- package/dist/assets/readiness-DqfcV8R2.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-Dlt2LoM5.js +0 -2
- package/dist/assets/renderMobileApp-BqUbrWSg.js +0 -28
- package/dist/assets/runtime-fetch-9B8F_rKW.js +0 -1
- package/dist/assets/runtime-file-download-D4WGSMk-.js +0 -1
- package/dist/assets/runtime-file-resource-tDTBpJT_.js +0 -2
- package/dist/assets/runtime-switch-ibQIZnws.js +0 -1
- package/dist/assets/runtimeConfig-k2t218IT.js +0 -2
- package/dist/assets/runtimeEndpointReset-_8oYno9l.js +0 -149
- package/dist/assets/select-DV9UcboH.js +0 -1
- package/dist/assets/sessionLookup-BBH2jvTL.js +0 -1
- package/dist/assets/sortable-tabs-strip-M-5RVko_.js +0 -1
- package/dist/assets/src-Bc4Nf__6.css +0 -2
- package/dist/assets/terminalApi-BXf0a2VZ.js +0 -1
- package/dist/assets/textarea-DWw42WmZ.js +0 -1
- package/dist/assets/url-DO6Zrx1P.js +0 -1
- package/dist/assets/useDesktopWindowControlsLayout-3SlaV4G-.js +0 -1
- package/dist/assets/useDictation-CgUBTlk5.js +0 -1
- package/dist/assets/useEffectiveDirectory-Dn3Z6Sbz.js +0 -1
- package/dist/assets/useMobileNavigationStore-ywElU2fl.js +0 -17
- package/dist/assets/usePluginsStore-BD47b67P.js +0 -1
- package/dist/assets/useStreamingTextThrottle-BDPkHk3Z.js +0 -1
- package/dist/assets/useUIStore-BsCfUWQw.js +0 -1
- package/dist/assets/useWorkerHighlightedLines-D9HhL0-T.js +0 -7
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import net from 'node:net';
|
|
2
|
+
import { WebSocketServer } from 'ws';
|
|
3
|
+
|
|
4
|
+
const PATH = '/api/gui-network/ws';
|
|
5
|
+
const CHUNK = 16 * 1024;
|
|
6
|
+
const WINDOW = 128 * 1024;
|
|
7
|
+
const MAX_STREAMS = 32;
|
|
8
|
+
|
|
9
|
+
// One authenticated socket owns the whole proxy lifetime. Website bytes are opaque:
|
|
10
|
+
// TLS and website credentials remain browser-owned, never Yuri-authenticated upstream.
|
|
11
|
+
export function attachGuiNetwork({ server, uiAuthController, isRequestOriginAllowed, isClientActive = async () => true }) {
|
|
12
|
+
const wss = new WebSocketServer({ noServer: true, maxPayload: CHUNK + 4, perMessageDeflate: false });
|
|
13
|
+
const reject = (socket, status) => socket.end(`HTTP/1.1 ${status} Rejected\r\nConnection: close\r\nContent-Length: 0\r\n\r\n`);
|
|
14
|
+
let stopped = false;
|
|
15
|
+
wss.on('connection', (ws, auth) => {
|
|
16
|
+
const streams = new Map();
|
|
17
|
+
let closed = false;
|
|
18
|
+
let lastSeen = Date.now();
|
|
19
|
+
const send = (value) => {
|
|
20
|
+
if (closed || ws.readyState !== 1) return;
|
|
21
|
+
if (ws.bufferedAmount > MAX_STREAMS * WINDOW) { ws.close(1009, 'backpressure'); return; }
|
|
22
|
+
ws.send(Buffer.isBuffer(value) ? value : JSON.stringify(value));
|
|
23
|
+
};
|
|
24
|
+
const closeStream = (id, notify = true) => {
|
|
25
|
+
const stream = streams.get(id);
|
|
26
|
+
if (!stream) return;
|
|
27
|
+
streams.delete(id);
|
|
28
|
+
clearTimeout(stream.timeout);
|
|
29
|
+
stream.socket.destroy();
|
|
30
|
+
if (notify) send({ type: 'close', id });
|
|
31
|
+
};
|
|
32
|
+
const cleanup = () => {
|
|
33
|
+
if (closed) return;
|
|
34
|
+
closed = true;
|
|
35
|
+
clearInterval(timer);
|
|
36
|
+
for (const id of streams.keys()) closeStream(id, false);
|
|
37
|
+
};
|
|
38
|
+
const invalid = () => { ws.close(1008, 'invalid_message'); cleanup(); };
|
|
39
|
+
const pump = (stream) => {
|
|
40
|
+
if (!stream.connected || streams.get(stream.id) !== stream) return;
|
|
41
|
+
while (stream.credit > 0) {
|
|
42
|
+
const available = Math.min(stream.socket.readableLength, CHUNK, stream.credit);
|
|
43
|
+
if (!available) break;
|
|
44
|
+
const bytes = stream.socket.read(available);
|
|
45
|
+
if (!bytes) break;
|
|
46
|
+
stream.credit -= bytes.length;
|
|
47
|
+
const frame = Buffer.allocUnsafe(bytes.length + 4);
|
|
48
|
+
frame.writeUInt32BE(stream.id);
|
|
49
|
+
bytes.copy(frame, 4);
|
|
50
|
+
send(frame);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
ws.on('message', (bytes, binary) => {
|
|
54
|
+
lastSeen = Date.now();
|
|
55
|
+
if (closed) return;
|
|
56
|
+
if (binary) {
|
|
57
|
+
if (bytes.length <= 4 || bytes.length > CHUNK + 4) return invalid();
|
|
58
|
+
const id = bytes.readUInt32BE(0);
|
|
59
|
+
const stream = streams.get(id);
|
|
60
|
+
if (!stream) return;
|
|
61
|
+
const length = bytes.length - 4;
|
|
62
|
+
if (!stream.connected || stream.fin || stream.pending + length > WINDOW) return invalid();
|
|
63
|
+
stream.pending += length;
|
|
64
|
+
stream.socket.write(bytes.subarray(4), () => {
|
|
65
|
+
stream.pending -= length;
|
|
66
|
+
if (streams.get(id) === stream) send({ type: 'credit', id, bytes: length });
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let message;
|
|
71
|
+
try { message = JSON.parse(bytes.toString()); } catch { return invalid(); }
|
|
72
|
+
if (!message || typeof message !== 'object') return invalid();
|
|
73
|
+
if (message.type === 'ping') { send({ type: 'pong' }); return; }
|
|
74
|
+
const { id } = message;
|
|
75
|
+
if (!Number.isInteger(id) || id <= 0 || id > 0xffffffff) return invalid();
|
|
76
|
+
if (message.type === 'open') {
|
|
77
|
+
const { hostname, port } = message;
|
|
78
|
+
if (streams.has(id) || streams.size >= MAX_STREAMS || typeof hostname !== 'string'
|
|
79
|
+
|| !hostname.length || hostname.length > 253 || /[\s/\\@\0]/.test(hostname)
|
|
80
|
+
|| !Number.isInteger(port) || port < 1 || port > 65535) return invalid();
|
|
81
|
+
const socket = new net.Socket({ allowHalfOpen: true });
|
|
82
|
+
const stream = { id, socket, connected: false, fin: false, pending: 0, credit: WINDOW,
|
|
83
|
+
timeout: setTimeout(() => closeStream(id), 15_000) };
|
|
84
|
+
streams.set(id, stream);
|
|
85
|
+
socket.setNoDelay(true);
|
|
86
|
+
socket.setTimeout(120_000, () => closeStream(id));
|
|
87
|
+
socket.on('error', () => closeStream(id));
|
|
88
|
+
socket.on('close', () => closeStream(id));
|
|
89
|
+
socket.on('readable', () => pump(stream));
|
|
90
|
+
socket.on('end', () => send({ type: 'fin', id }));
|
|
91
|
+
socket.connect({ host: hostname, port }, () => {
|
|
92
|
+
if (streams.get(id) !== stream) return socket.destroy();
|
|
93
|
+
clearTimeout(stream.timeout);
|
|
94
|
+
stream.connected = true;
|
|
95
|
+
send({ type: 'opened', id, credit: WINDOW });
|
|
96
|
+
pump(stream);
|
|
97
|
+
});
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const stream = streams.get(id);
|
|
101
|
+
if (!stream) return;
|
|
102
|
+
if (message.type === 'close') { closeStream(id, false); return; }
|
|
103
|
+
if (message.type === 'fin' && !stream.fin) { stream.fin = true; stream.socket.end(); return; }
|
|
104
|
+
if (message.type === 'credit' && Number.isInteger(message.bytes) && message.bytes > 0
|
|
105
|
+
&& stream.credit + message.bytes <= WINDOW) {
|
|
106
|
+
stream.credit += message.bytes;
|
|
107
|
+
pump(stream);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
invalid();
|
|
111
|
+
});
|
|
112
|
+
const timer = setInterval(() => {
|
|
113
|
+
if (Date.now() - lastSeen > 60_000) { ws.terminate(); cleanup(); return; }
|
|
114
|
+
if (auth.type === 'client') void isClientActive(auth.clientId ?? auth.client?.id).then(active => {
|
|
115
|
+
if (!active) { ws.close(4001, 'authentication_required'); cleanup(); }
|
|
116
|
+
}).catch(() => { ws.terminate(); cleanup(); });
|
|
117
|
+
}, 20_000);
|
|
118
|
+
timer.unref?.();
|
|
119
|
+
ws.on('error', cleanup);
|
|
120
|
+
ws.on('close', cleanup);
|
|
121
|
+
const address = server.address();
|
|
122
|
+
send({ type: 'ready', version: 1, chunk: CHUNK, window: WINDOW, streams: MAX_STREAMS,
|
|
123
|
+
...(address && typeof address === 'object' ? { httpOrigin: `http://localhost:${address.port}` } : {}) });
|
|
124
|
+
});
|
|
125
|
+
const upgrade = (req, socket, head) => {
|
|
126
|
+
let path;
|
|
127
|
+
try { path = new URL(req.url, 'http://localhost').pathname; } catch { return; }
|
|
128
|
+
if (path !== PATH) return;
|
|
129
|
+
void (async () => {
|
|
130
|
+
try {
|
|
131
|
+
const auth = await uiAuthController.resolveAuthContext(req, null, { allowClientAuth: true, allowUrlToken: true });
|
|
132
|
+
if (!auth || (auth.type !== 'client' && !uiAuthController.enabled)) return reject(socket, 401);
|
|
133
|
+
if (!await isRequestOriginAllowed(req)) return reject(socket, 403);
|
|
134
|
+
if (stopped || wss.clients.size >= 8) return reject(socket, 503);
|
|
135
|
+
if (!socket.destroyed) wss.handleUpgrade(req, socket, head, ws => wss.emit('connection', ws, auth));
|
|
136
|
+
} catch { reject(socket, 401); }
|
|
137
|
+
})();
|
|
138
|
+
};
|
|
139
|
+
server.on('upgrade', upgrade);
|
|
140
|
+
return { stop() {
|
|
141
|
+
stopped = true;
|
|
142
|
+
server.off('upgrade', upgrade);
|
|
143
|
+
for (const ws of wss.clients) ws.terminate();
|
|
144
|
+
wss.close();
|
|
145
|
+
} };
|
|
146
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import http from 'node:http';
|
|
4
|
+
import net from 'node:net';
|
|
5
|
+
import { once } from 'node:events';
|
|
6
|
+
import * as fsPromises from 'node:fs/promises';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import crypto from 'node:crypto';
|
|
10
|
+
import { WebSocket } from 'ws';
|
|
11
|
+
import request from 'supertest';
|
|
12
|
+
import { createUiAuth } from '../ui-auth/ui-auth.js';
|
|
13
|
+
import { createRemoteClientAuthRuntime } from '../client-auth/remote-clients.js';
|
|
14
|
+
import { createRequestSecurityRuntime } from '../security/request-security.js';
|
|
15
|
+
import { createTunnelHost } from '../relay/tunnel-host.js';
|
|
16
|
+
import { decodeTunnelFrame, encodeJsonPayload, encodeTunnelFrame, TunnelFrameType } from '../relay/tunnel-codec.js';
|
|
17
|
+
import { attachGuiNetwork } from './runtime.js';
|
|
18
|
+
|
|
19
|
+
let root, auth, clients, client, server, port, runtime, token;
|
|
20
|
+
const sockets = new Set();
|
|
21
|
+
const destinations = new Set();
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
root = await fsPromises.mkdtemp(path.join(os.tmpdir(), 'gui-network-'));
|
|
24
|
+
clients = createRemoteClientAuthRuntime({ fsPromises, path, crypto, storePath: path.join(root, 'clients.json') });
|
|
25
|
+
client = await clients.createClient({ label: 'GUI fixture', clientKind: 'mobile', authMethod: 'pairing', pairingId: 'gui-fixture', usesRelay: true });
|
|
26
|
+
auth = createUiAuth({ password: null, clientAuthController: clients, readSettingsFromDiskMigrated: async () => ({}) });
|
|
27
|
+
const security = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) });
|
|
28
|
+
const app = express();
|
|
29
|
+
app.post('/auth/url-token', auth.handleUrlAuthToken);
|
|
30
|
+
server = http.createServer(app);
|
|
31
|
+
runtime = attachGuiNetwork({ server, uiAuthController: auth, isRequestOriginAllowed: security.isRequestOriginAllowed });
|
|
32
|
+
server.listen(0, '127.0.0.1'); await once(server, 'listening'); port = server.address().port;
|
|
33
|
+
token = (await request(app).post('/auth/url-token').set('Authorization', `Bearer ${client.token}`)).body.token;
|
|
34
|
+
});
|
|
35
|
+
afterEach(async () => {
|
|
36
|
+
for (const socket of sockets) { if (socket.terminate) socket.terminate(); else socket.destroy(); }
|
|
37
|
+
sockets.clear();
|
|
38
|
+
runtime.stop(); auth.dispose();
|
|
39
|
+
await Promise.all([new Promise(resolve => server.close(resolve)), ...[...destinations].map(target => new Promise(resolve => target.close(resolve)))]);
|
|
40
|
+
destinations.clear();
|
|
41
|
+
await fsPromises.rm(root, { recursive: true, force: true });
|
|
42
|
+
});
|
|
43
|
+
function connect(query = `?yuri_url_token=${encodeURIComponent(token)}`, origin = `http://127.0.0.1:${port}`) {
|
|
44
|
+
const ws = new WebSocket(`ws://127.0.0.1:${port}/api/gui-network/ws${query}`, { headers: { Origin: origin } });
|
|
45
|
+
ws.on('error', () => {}); sockets.add(ws);
|
|
46
|
+
return ws;
|
|
47
|
+
}
|
|
48
|
+
async function denied(ws) {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
ws.on('unexpected-response', (_req, res) => { res.resume(); ws.terminate(); resolve(res.statusCode); });
|
|
51
|
+
ws.on('open', () => reject(new Error('unexpected connection')));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async function target(handler) {
|
|
55
|
+
const destination = net.createServer({ allowHalfOpen: true }, socket => { sockets.add(socket); handler(socket); });
|
|
56
|
+
destinations.add(destination);
|
|
57
|
+
destination.listen(0, '127.0.0.1'); await once(destination, 'listening');
|
|
58
|
+
return destination.address().port;
|
|
59
|
+
}
|
|
60
|
+
const packet = (id, bytes) => {
|
|
61
|
+
const frame = Buffer.alloc(bytes.length + 4); frame.writeUInt32BE(id); bytes.copy(frame, 4); return frame;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
it('rejects unauthenticated, forged-token and hostile-origin upgrades through real auth gates', async () => {
|
|
65
|
+
expect(await denied(connect(''))).toBe(401);
|
|
66
|
+
expect(await denied(connect(`?yuri_url_token=${client.token}`))).toBe(401);
|
|
67
|
+
expect(await denied(connect(undefined, 'https://untrusted.example'))).toBe(403);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('relays opaque bytes bidirectionally, preserves half-close and closes remaining targets on disconnect', async () => {
|
|
71
|
+
const received = [];
|
|
72
|
+
let destination;
|
|
73
|
+
const targetPort = await target(socket => {
|
|
74
|
+
destination = socket;
|
|
75
|
+
socket.on('data', bytes => received.push(bytes));
|
|
76
|
+
socket.on('end', () => socket.end(Buffer.from('after-fin')));
|
|
77
|
+
});
|
|
78
|
+
const ws = connect();
|
|
79
|
+
const controls = [], data = [];
|
|
80
|
+
ws.on('message', (bytes, binary) => { if (binary) data.push(bytes); else controls.push(JSON.parse(bytes)); });
|
|
81
|
+
await once(ws, 'open');
|
|
82
|
+
await vi.waitFor(() => expect(controls).toContainEqual(expect.objectContaining({ type: 'ready', httpOrigin: `http://localhost:${port}` })));
|
|
83
|
+
ws.send(JSON.stringify({ type: 'open', id: 1, hostname: '127.0.0.1', port: targetPort }));
|
|
84
|
+
await vi.waitFor(() => expect(controls).toContainEqual({ type: 'opened', id: 1, credit: 131072 }));
|
|
85
|
+
const payload = crypto.randomBytes(16384);
|
|
86
|
+
ws.send(packet(1, payload));
|
|
87
|
+
ws.send(JSON.stringify({ type: 'fin', id: 1 }));
|
|
88
|
+
await vi.waitFor(() => expect(Buffer.concat(received)).toEqual(payload));
|
|
89
|
+
await vi.waitFor(() => expect(data.length).toBe(1));
|
|
90
|
+
expect(data[0].subarray(4).toString()).toBe('after-fin');
|
|
91
|
+
expect(data[0].readUInt32BE()).toBe(1);
|
|
92
|
+
expect(controls).toContainEqual({ type: 'credit', id: 1, bytes: payload.length });
|
|
93
|
+
ws.close(); await once(ws, 'close');
|
|
94
|
+
await vi.waitFor(() => expect(destination.destroyed).toBe(true));
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('bounds outbound bytes by credit until the native consumer acknowledges them', async () => {
|
|
98
|
+
const targetPort = await target(socket => socket.write(Buffer.alloc(256 * 1024, 7)));
|
|
99
|
+
const ws = connect(); const data = [];
|
|
100
|
+
ws.on('message', (bytes, binary) => { if (binary) data.push(bytes.subarray(4)); });
|
|
101
|
+
await once(ws, 'open');
|
|
102
|
+
ws.send(JSON.stringify({ type: 'open', id: 2, hostname: '127.0.0.1', port: targetPort }));
|
|
103
|
+
await vi.waitFor(() => expect(Buffer.concat(data).length).toBe(128 * 1024));
|
|
104
|
+
ws.send(JSON.stringify({ type: 'credit', id: 2, bytes: 128 * 1024 }));
|
|
105
|
+
await vi.waitFor(() => expect(Buffer.concat(data)).toEqual(Buffer.alloc(256 * 1024, 7)));
|
|
106
|
+
ws.send(JSON.stringify({ type: 'credit', id: 2, bytes: 128 * 1024 + 1 }));
|
|
107
|
+
expect((await once(ws, 'close'))[0]).toBe(1008);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('uses the existing Relay dispatcher for TCP, with immediate data flush and unchanged website bytes', async () => {
|
|
111
|
+
const targetPort = await target(socket => socket.on('data', bytes => socket.write(bytes)));
|
|
112
|
+
const frames = [];
|
|
113
|
+
const host = createTunnelHost({ connectionId: 'gui-network', getLocalPort: () => port,
|
|
114
|
+
authorizeRequest: auth.authorizeRelayRequest,
|
|
115
|
+
sendFrame: (frame, immediate) => frames.push({ ...decodeTunnelFrame(frame), immediate }), getBufferedAmount: () => 0 });
|
|
116
|
+
const control = value => host.handleFrame(encodeTunnelFrame(TunnelFrameType.WsText, 2, Buffer.from(JSON.stringify(value))));
|
|
117
|
+
try {
|
|
118
|
+
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.WsOpen, 2, encodeJsonPayload({ path: '/api/gui-network/ws', query: `yuri_url_token=${token}` })));
|
|
119
|
+
await vi.waitFor(() => expect(frames.some(frame => frame.frameType === TunnelFrameType.WsOpened)).toBe(true));
|
|
120
|
+
await control({ type: 'open', id: 3, hostname: '127.0.0.1', port: targetPort });
|
|
121
|
+
await vi.waitFor(() => expect(frames.filter(frame => frame.frameType === TunnelFrameType.WsText).map(frame => JSON.parse(Buffer.from(frame.payload)))).toContainEqual({ type: 'opened', id: 3, credit: 131072 }));
|
|
122
|
+
const payload = packet(3, crypto.randomBytes(8192));
|
|
123
|
+
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.WsBinary, 2, payload));
|
|
124
|
+
await vi.waitFor(() => expect(frames.some(frame => frame.frameType === TunnelFrameType.WsBinary)).toBe(true));
|
|
125
|
+
const result = frames.find(frame => frame.frameType === TunnelFrameType.WsBinary);
|
|
126
|
+
expect(Buffer.from(result.payload)).toEqual(payload);
|
|
127
|
+
expect(result.immediate).toBe(true);
|
|
128
|
+
} finally { host.close(); }
|
|
129
|
+
});
|
|
@@ -1008,7 +1008,7 @@ export const normalizeProxyTargetUrl = (rawUrl, { allowExternal = false } = {})
|
|
|
1008
1008
|
|
|
1009
1009
|
// Normalize common loopback hostnames to IPv4 to avoid environments where
|
|
1010
1010
|
// `localhost` resolves to ::1 but the dev server only binds IPv4.
|
|
1011
|
-
if (LOOPBACK_HOSTS.has(hostname) && (hostname === '0.0.0.0' || hostname === 'localhost'
|
|
1011
|
+
if (LOOPBACK_HOSTS.has(hostname) && (hostname === '0.0.0.0' || hostname === 'localhost')) {
|
|
1012
1012
|
url.hostname = '127.0.0.1';
|
|
1013
1013
|
}
|
|
1014
1014
|
|
|
@@ -18,6 +18,10 @@ const rewrite = (bodyText, kind) => rewritePreviewBody({
|
|
|
18
18
|
targetOrigin: 'http://127.0.0.1:3000',
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
it('preserves an explicit IPv6 loopback service instead of dialing IPv4', () => {
|
|
22
|
+
expect(normalizeProxyTargetUrl('http://[::1]:3000/app')).toEqual({ ok: true, origin: 'http://[::1]:3000' });
|
|
23
|
+
});
|
|
24
|
+
|
|
21
25
|
describe('preview Inertia header passthrough', () => {
|
|
22
26
|
it('forwards Inertia request headers to the preview target', () => {
|
|
23
27
|
const forwarded = new Map();
|
|
@@ -58,6 +58,11 @@ Everything a client normally sends to the single Yuri origin:
|
|
|
58
58
|
- **Events** — relay `auto` uses SSE (bearer), the same path mobile uses. Desktop WebSocket upgrades over the tunnel close and drop assistant deltas; an explicit `ws` setting is unchanged.
|
|
59
59
|
- **SSE** — streamed responses opened through `runtimeFetch`, including `/api/yuri/events` and SDK global SSE. Relay carries these HTTP response body frames through the tunnel.
|
|
60
60
|
- **WebSocket** — the endpoints that use a real socket (the global event stream on platforms that support WS, terminal I/O, dictation, and Preview/Browser HMR under `/api/preview/proxy/<id>/...`).
|
|
61
|
+
- **Mobile GUI TCP egress** — `/api/gui-network/ws` carries bounded SOCKS TCP
|
|
62
|
+
streams to the authenticated Host. It uses a separate client connection to the
|
|
63
|
+
same paired Relay identity, with a native wire so the WebView proxy needs no
|
|
64
|
+
hostname bypass. E2EE and tunnel framing are unchanged; both senders immediately
|
|
65
|
+
flush this path. Scope, auth and native probe evidence: `../gui-network/DOCUMENTATION.md`.
|
|
61
66
|
|
|
62
67
|
The host dispatcher restricts tunneled traffic to explicit path allowlists (one for HTTP, one for WS). WS allowlist is exact-match for app sockets and **prefix** `/api/preview/proxy/` for Vite/dev-server HMR only (`isTunnelWsPathAllowed`).
|
|
63
68
|
|
|
@@ -33,6 +33,7 @@ const ALLOWED_WS_PATHS = new Set([
|
|
|
33
33
|
'/api/event/ws',
|
|
34
34
|
'/api/terminal/ws',
|
|
35
35
|
'/api/remote-desktop/ws',
|
|
36
|
+
'/api/gui-network/ws',
|
|
36
37
|
'/api/dictation/ws',
|
|
37
38
|
]);
|
|
38
39
|
|
|
@@ -402,7 +403,7 @@ export const createTunnelHost = ({
|
|
|
402
403
|
for (const frame of encodeFragmentedMessage(frameType, streamId, bytes)) {
|
|
403
404
|
await waitForBackpressure(null);
|
|
404
405
|
if (streams.get(streamId) !== stream || closed) return;
|
|
405
|
-
await send(frame, open.path === '/api/remote-desktop/ws');
|
|
406
|
+
await send(frame, open.path === '/api/remote-desktop/ws' || open.path === '/api/gui-network/ws');
|
|
406
407
|
}
|
|
407
408
|
});
|
|
408
409
|
});
|
|
@@ -27,6 +27,14 @@ Remote desktop uses the exact `/api/remote-desktop/ws` scoped URL-token path, mi
|
|
|
27
27
|
- `packages/web/server/lib/client-auth/pairing.js`: short-lived Pairing v2 sessions and one-time secret redemption into trusted-device client tokens.
|
|
28
28
|
|
|
29
29
|
## Public exports (ui-auth.js)
|
|
30
|
+
|
|
31
|
+
Browser URL auth also permits GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS beneath an
|
|
32
|
+
exact `/api/preview/proxy/<hex-id>/...` target. This lets framed websites submit
|
|
33
|
+
forms and fetch through the Host without Yuri bearer headers. The preview runtime
|
|
34
|
+
independently requires its short-lived target token and strips Yuri credentials
|
|
35
|
+
before forwarding. Target registration and arbitrary Yuri write routes still
|
|
36
|
+
reject URL tokens; filesystem URL access remains GET-only.
|
|
37
|
+
|
|
30
38
|
- `isUrlAuthWebSocketPath(pathname)`: true when a WebSocket upgrade may authenticate with `yuri_url_token` (exact terminal/dictation/event/realtime-proxy paths, plus prefix `/api/preview/proxy/` for Preview HMR). Keep in sync with tunnel-host `isTunnelWsPathAllowed`.
|
|
31
39
|
- `createUiAuth({ password, cookieName, sessionTtlMs, readSettingsFromDiskMigrated })`: creates UI auth controller with methods:
|
|
32
40
|
- `authorizeRelayRequest(req)`
|
|
@@ -320,6 +320,7 @@ export const isUrlAuthWebSocketPath = (pathname) => {
|
|
|
320
320
|
|| pathname === '/api/yuri/realtime-proxy/ws'
|
|
321
321
|
|| pathname === '/api/terminal/ws'
|
|
322
322
|
|| pathname === '/api/remote-desktop/ws'
|
|
323
|
+
|| pathname === '/api/gui-network/ws'
|
|
323
324
|
|| pathname === '/api/dictation/ws'
|
|
324
325
|
|| pathname.startsWith('/api/preview/proxy/');
|
|
325
326
|
};
|
|
@@ -330,6 +331,11 @@ const canUseUrlAuthTokenForRequest = (req) => {
|
|
|
330
331
|
if (isWebSocketUpgrade(req)) {
|
|
331
332
|
return isUrlAuthWebSocketPath(pathname);
|
|
332
333
|
}
|
|
334
|
+
// Browser-owned preview forms/fetch cannot attach Yuri headers. The proxy also
|
|
335
|
+
// requires its separate target token and strips both tokens before forwarding.
|
|
336
|
+
if (/^\/api\/preview\/proxy\/[a-f0-9]{16,64}(?:\/|$)/i.test(pathname)) {
|
|
337
|
+
return ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'].includes(method);
|
|
338
|
+
}
|
|
333
339
|
return method === 'GET' && isUrlAuthReadableHttpPath(pathname);
|
|
334
340
|
};
|
|
335
341
|
|
|
@@ -334,6 +334,16 @@ describe('ui auth client credential seam', () => {
|
|
|
334
334
|
expect(arbitraryGetCalled).toBe(false);
|
|
335
335
|
expect(arbitraryGetRes.statusCode).toBe(401);
|
|
336
336
|
|
|
337
|
+
for (const method of ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']) {
|
|
338
|
+
const proxyPath = '/api/preview/proxy/1234567890abcdef/form';
|
|
339
|
+
const proxyReq = { method, path: proxyPath, url: `${proxyPath}?yuri_url_token=${encodeURIComponent(urlToken)}`, headers: {} };
|
|
340
|
+
let allowed = false;
|
|
341
|
+
await auth.requireAuth(proxyReq, createResponse(), () => { allowed = true; });
|
|
342
|
+
expect(allowed, `browser preview ${method}`).toBe(true);
|
|
343
|
+
}
|
|
344
|
+
const registerReq = { method: 'POST', path: '/api/preview/targets', url: `/api/preview/targets?yuri_url_token=${encodeURIComponent(urlToken)}`, headers: {} };
|
|
345
|
+
expect(await auth.ensureSessionToken(registerReq, createResponse())).toBe(null);
|
|
346
|
+
|
|
337
347
|
for (const method of ['POST', 'PUT', 'PATCH', 'DELETE']) {
|
|
338
348
|
const writeReq = { method, path: '/api/fs/raw', url: `/api/fs/raw?path=%2Ftmp%2Fimage.png&yuri_url_token=${encodeURIComponent(urlToken)}`, headers: { accept: 'application/json' } };
|
|
339
349
|
const writeRes = createResponse();
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-CoKt-9rk.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-Bh3htXtG.js","assets/runtime-switch-ibQIZnws.js","assets/runtime-fetch-9B8F_rKW.js","assets/desktop-Brp3xDpd.js","assets/path-utils-HRmerlyU.js","assets/vendor-base-ui-CzHs0bHY.js","assets/useUIStore-BsCfUWQw.js","assets/vendor-zustand-vDaAPGfl.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/vendor-react-DlzBev0S.js","assets/vendor-tanstack-react-query-B-Wpqq5J.js","assets/vendor-tanstack-query-core-Y_YoRHtC.js","assets/runtime-file-resource-tDTBpJT_.js","assets/fileQueries-BaEKb7SZ.js","assets/runtime-file-store-BVRgEtI-.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/platform-Dids8J9D.js","assets/vendor-pathe-vBmvQE8f.js","assets/runtime-file-download-D4WGSMk-.js","assets/vendor-pierre-diffs-BFiZ3IhI.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-CuTmqEMK.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/useMobileNavigationStore-ywElU2fl.js","assets/bootstrap-BzeQds0D.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/runtime-ead7P81A.js","assets/vendor-sonner-BEHGipm5.js","assets/store-Myt_Fv8d.js","assets/tour-DDI0Zg7l.js","assets/useAssistantUIStore-CVSFSgJV.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-CNzUUkFn.js","assets/vendor-framer-motion-DDMKlXiP.js","assets/Icon-h0JiZMjp.js","assets/dialog-Kz0pw-SO.js","assets/dialog-CTYD3Sbr.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MobileWindowStack-DGLdgoGr.js","assets/appThemeRegistry-CbyMACnN.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/MarkdownRenderer-BfAZBFzv.js","assets/useEffectiveDirectory-Dn3Z6Sbz.js","assets/markdownHeightCache-BEb1XAlf.js","assets/dualLimitLru-D8Sphgua.js","assets/toolHelpers-iEHVHQ9p.js","assets/image-loading-D1DfK_bJ.js","assets/image-loading-D9Z_BASK.css","assets/ImageLoadingPlaceholder-A2tjfBfo.js","assets/vendor-tanstack-react-virtual-DSFNK3qc.js","assets/useWorkerHighlightedLines-D9HhL0-T.js","assets/markdownTheme-CHNl6tUv.js","assets/markdown-worker-oBGEB9Eg.js","assets/mobileBackNavigation-Dy-OW7DB.js","assets/touch-gestures-CErgaXZ7.js","assets/ToolOutputDialog-CbGuK5bP.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-ibQIZnws.js";import{a as r}from"./vendor-zustand-vDaAPGfl.js";import{d as i,f as a,g as o,h as s,m as c,ot as l,p as u,st as d,u as f}from"./vendor-base-ui-CzHs0bHY.js";import{An as p,Cn as m,Dn as h,Tn as g,_n as _,bn as v,gn as y,wn as b,zr as x}from"./bootstrap-BzeQds0D.js";import{r as S}from"./useUIStore-BsCfUWQw.js";import{n as C}from"./vendor-react-DlzBev0S.js";import{s as w}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{o as T}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as E,r as D}from"./platform-Dids8J9D.js";import{a as O,f as k,i as A,o as j,p as ee,r as M}from"./vendor-reactuses-core-CuTmqEMK.js";import{Ba as te,Ct as ne,Jn as N,K as P,Kn as F,Va as I,oi as re,or as ie,s as L,si as R}from"./useMobileNavigationStore-ywElU2fl.js";import{i as z,n as B}from"./MobileShareBridge-IWtj1SYy.js";import{N as V,T as H,_ as U,f as ae,g as W,h as oe,j as G,n as K,r as se,u as ce,v as le,w as ue}from"./MobileDetailNavigation-UU1cGYp2.js";import{n as de}from"./useAssistantUIStore-CVSFSgJV.js";import{a as fe}from"./fileMentionAutocompleteState-BZJqfgae.js";import{o as pe,p as me,t as he}from"./AgentAvatar-CAC4rKO_.js";import{d as ge,o as _e,t as ve}from"./vendor-framer-motion-DDMKlXiP.js";import{n as q}from"./Icon-h0JiZMjp.js";import{t as ye}from"./scheduledTaskNavigation-C8tBjNoP.js";import{D as be,E as xe,O as Se,a as J,c as Ce,d as we,f as Te,g as Ee,h as De,l as Oe,m as ke,o as Y,s as Ae,t as X,u as je,w as Me,x as Ne}from"./sessionLookup-BBH2jvTL.js";import{a as Pe,n as Fe,r as Ie,t as Le}from"./fileMentionTouchSelection-BhQqAWYa.js";import{a as Re,o as ze,t as Be}from"./MarkdownRenderer-BfAZBFzv.js";import{c as Ve,s as He}from"./image-loading-D1DfK_bJ.js";import{t as Ue}from"./ImageLoadingPlaceholder-A2tjfBfo.js";import{t as We}from"./LoadingImage-C4DsIEui.js";import{n as Ge}from"./textarea-DWw42WmZ.js";import{t as Ke}from"./vendor-motion-C9oiAdx-.js";import{i as qe,n as Je,r as Ye}from"./assistant-attachment-cache-C-SlEpSB.js";var Z=C(),Q=e(d(),1),$=l();function Xe(e){let r=(0,Z.c)(12),{assistantID:i,position:a}=e,o=Q.useRef(null),s=Q.useRef(!1),c;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={busy:!1,done:!1,retryAt:0},r[0]=c):c=r[0];let l=Q.useRef(c),[u]=Q.useState(nt),d;r[1]!==i||r[2]!==a||r[3]!==u?(d=()=>{let e=o.current;if(!e||!s.current||l.current.busy||l.current.done||Date.now()<l.current.retryAt||u.transport!==t()||u.generation!==n()||document.visibilityState!==`visible`||(E()?!document.documentElement.classList.contains(`yuri-native-app-active`):!document.hasFocus())||e.parentElement?.closest(`[inert], [aria-hidden="true"]`))return;let r=e.closest(`[data-assistant-contact-transcript]`);if(!r||r.scrollHeight-r.scrollTop-r.clientHeight>2)return;let c=e.getBoundingClientRect(),d=r.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,ce(i,a).then(()=>{l.current.done=!0}).catch(()=>{l.current.retryAt=Date.now()+15e3}).finally(()=>{l.current.busy=!1}))},r[1]=i,r[2]=a,r[3]=u,r[4]=d):d=r[4];let f=M(d),p;r[5]===f?p=r[6]:(p=e=>{s.current=e.some(tt),f()},r[5]=f,r[6]=p);let m;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(m={threshold:1},r[7]=m):m=r[7],O(o,M(p),m),A(`visibilitychange`,f,et),A(`focus`,f,$e),A(`resize`,f,Qe);let h,g;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>o.current?.closest(`[data-assistant-contact-transcript]`),g={passive:!0},r[8]=h,r[9]=g):(h=r[8],g=r[9]),A(`scroll`,f,h,g);let _;r[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={attributes:!0,attributeFilter:[`class`]},r[10]=_):_=r[10],k(f,Ze,_),j(f,15e3);let v;return r[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{ref:o,"aria-hidden":`true`,className:`absolute bottom-0 left-0 block h-px w-px`,"data-assistant-read-marker":``}),r[11]=v):v=r[11],v}function Ze(){return document.documentElement}function Qe(){return window.visualViewport}function $e(){return window}function et(){return document}function tt(e){return e.isIntersecting&&e.intersectionRatio===1}function nt(){return{transport:t(),generation:n()}}var rt=()=>{},it=Q.memo(Se),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,ot=Q.forwardRef(({query:e,isMobile:t,listId:n,onHighlightChange:r,onSelect:i,onClose:a},o)=>{let{t:s}=I(),c=Ve(),l=w({...R(c),select:at}),u=Q.useMemo(()=>fe({sessions:l.data??[],currentSessionId:null,searchQuery:e,limit:e.trim()?10:3}),[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(Le,[]);A(`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 _=M(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)(Fe,{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)(F,{type:`button`,size:`xs`,variant:`ghost`,"aria-label":s(`dialog.common.actions.close`),onClick:a,children:(0,$.jsx)(q,{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)(F,{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)(Ge,{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:N(`flex min-h-10 cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 typography-ui-label`,Ie(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)(q,{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`)})]})}),st=e=>{let t=(0,Z.c)(120),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({active:n,onChange:r,onVoiceSend:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{t:o}=I(),s=Q.useRef(null),c=n&&!!a.isMobile&&!!i,l;t[5]===c?l=t[6]:(l={available:c},t[5]=c,t[6]=l);let{enabled:u,hint:d,onHintChange:f}=be(l),p;t[7]!==d||t[8]!==a.placeholder||t[9]!==o?(p=d===null?a.placeholder:o(d===`recording`?`chat.dictation.releaseSend`:d===`cancelling`?`chat.dictation.releaseCancel`:d===`editing`?`chat.dictation.releaseEdit`:`chat.dictation.processing`),t[7]=d,t[8]=a.placeholder,t[9]=o,t[10]=p):p=t[10];let h=p,S;t[11]===a.value?S=t[12]:(S=()=>({canonical:a.value,document:v(a.value,new Map)}),t[11]=a.value,t[12]=S);let[C,w]=Q.useState(S),T;t[13]!==C.canonical||t[14]!==C.document||t[15]!==a.value?(T=C.canonical===a.value?C.document:v(a.value,new Map),t[13]=C.canonical,t[14]=C.document,t[15]=a.value,t[16]=T):T=t[16];let E=T,[D,O]=Q.useState(0),[k,A]=Q.useState(!0),[j,ee]=Q.useState(!1),[te,ne]=Q.useState(),P=Q.useRef(null),F=Q.useRef(null),re=Q.useRef(null),ie=Q.useRef(null),L;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(L=Ce(),t[17]=L):L=t[17];let R=Q.useRef(L),z=Q.useId(),B;t[18]!==n||t[19]!==j||t[20]!==D||t[21]!==k||t[22]!==E.text||t[23]!==a.disabled||t[24]!==a.pending?(B=n&&!a.pending&&!a.disabled&&!k&&!j?Pe({text:E.text,cursor:D}):null,t[18]=n,t[19]=j,t[20]=D,t[21]=k,t[22]=E.text,t[23]=a.disabled,t[24]=a.pending,t[25]=B):B=t[25];let V=B,H=V?.kind===`mention`?V:null,U;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{ie.current!==null&&(P.current?.focus({preventScroll:!0}),P.current?.setSelectionRange(ie.current,ie.current),ie.current=null)},t[26]=U):U=t[26];let ae;t[27]===E?ae=t[28]:(ae=[E],t[27]=E,t[28]=ae),Q.useLayoutEffect(U,ae);let W;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>A(!0),t[29]=W):W=t[29];let oe=M(W),G;t[30]!==j||t[31]!==D||t[32]!==E||t[33]!==r?(G=(e,t,n)=>{let i=n===void 0||n,a=g(e);a.ok&&(i&&(R.current=Oe(R.current,{before:Ae(E,[],{start:P.current?.selectionStart??D,end:P.current?.selectionEnd??D}),after:Ae(e,[],{start:t,end:t})})),j||(ie.current=t),O(t),w({canonical:a.text,document:e}),r(a.text))},t[30]=j,t[31]=D,t[32]=E,t[33]=r,t[34]=G):G=t[34];let K=M(G),se;t[35]!==K||t[36]!==E||t[37]!==H||t[38]!==o?(se=e=>{if(!H)return;let t=e.title||o(`chat.fileMentionAutocomplete.untitledSession`),n=_(E,H.tokenStart,H.tokenEnd,{id:`session:${e.id}:${crypto.randomUUID()}`,kind:`session`,sessionId:e.id,display:x({trigger:`@`,icon:`chat-thread`,label:t})},{inlineBoundaries:!0,padDocumentEdges:!0}),r=n.caret+ +(n.document.text[n.caret]===` `);A(!0),K(n.document,r)},t[35]=K,t[36]=E,t[37]=H,t[38]=o,t[39]=se):se=t[39];let ce=M(se),le;t[40]!==n||t[41]!==K||t[42]!==E||t[43]!==a.disabled||t[44]!==a.pending?(le=e=>{if(!n||a.pending||a.disabled||!e.trim())return;let t=E.text?`${E.text} ${e}`:e,r=m(E,t,t.length,t.length);K(r.document,r.caret),A(!0)},t[40]=n,t[41]=K,t[42]=E,t[43]=a.disabled,t[44]=a.pending,t[45]=le):le=t[45];let ue=M(le),de;t[46]!==n||t[47]!==E.text||t[48]!==ue||t[49]!==r||t[50]!==i||t[51]!==a.disabled||t[52]!==a.pending?(de=e=>{if(!(!n||a.pending||a.disabled||!e.trim())){if(E.text){ue(e);return}r(e),i?.(e)}},t[46]=n,t[47]=E.text,t[48]=ue,t[49]=r,t[50]=i,t[51]=a.disabled,t[52]=a.pending,t[53]=de):de=t[53];let fe=M(de),pe;t[54]!==K||t[55]!==E?(pe=(e,t)=>{let n=e.currentTarget;if(n.selectionStart===n.selectionEnd||!e.clipboardData||!E.references.some(e=>e.start<n.selectionEnd&&e.end>n.selectionStart))return;let r=y(n.selectionStart,n.selectionEnd,E.references)??{start:n.selectionStart,end:n.selectionEnd},i=g({text:E.text.slice(r.start,r.end),references:E.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=m(E,E.text.slice(0,r.start)+E.text.slice(r.end),r.start,r.start);K(e.document,e.caret)}},t[54]=K,t[55]=E,t[56]=pe):pe=t[56];let me=M(pe),he;t[57]!==E.references||t[58]!==E.text?(he=Ee(E.text,E.references.map(ct))?.map(lt),t[57]=E.references,t[58]=E.text,t[59]=he):he=t[59];let ge=he,_e=u&&E.text.length===0?`true`:void 0,ve;t[60]!==u||t[61]!==ue||t[62]!==a.disabled||t[63]!==a.pending||t[64]!==fe||t[65]!==f?(ve=u&&(0,$.jsx)(it,{containerRef:s,disabled:!!(a.pending||a.disabled),onInsert:ue,onSend:fe,onRelease:rt,onHintChange:f}),t[60]=u,t[61]=ue,t[62]=a.disabled,t[63]=a.pending,t[64]=fe,t[65]=f,t[66]=ve):ve=t[66];let q=E.text,ye=a.pending,xe;t[67]===a?xe=t[68]:(xe=()=>{a.pending||a.onSubmit()},t[67]=a,t[68]=xe);let Se=a.layout===`inline`?`py-3 leading-6`:`pt-4 pb-2`,J;t[69]!==a.textLayoutClassName||t[70]!==Se?(J=N(`whitespace-pre-wrap break-words overflow-hidden px-3 typography-markdown md:typography-ui-label`,Se,a.textLayoutClassName),t[69]=a.textLayoutClassName,t[70]=Se,t[71]=J):J=t[71];let Te;t[72]!==K||t[73]!==E?(Te=(e,t)=>{let n=m(E,e,t?.target.selectionStart??e.length,t?.target.selectionEnd??e.length);K(n.document,n.caret),A(t?.nativeEvent?.inputType===`insertFromPaste`)},t[72]=K,t[73]=E,t[74]=Te):Te=t[74];let De=H?z:void 0,ke=H?te:void 0,Y;t[75]===a.textareaProps?Y=t[76]:(Y=e=>{a.textareaProps?.onScroll?.(e),F.current&&(F.current.scrollTop=e.currentTarget.scrollTop,F.current.scrollLeft=e.currentTarget.scrollLeft)},t[75]=a.textareaProps,t[76]=Y);let X,Fe;t[77]!==me||t[78]!==a.textareaProps?(X=e=>{a.textareaProps?.onCopy?.(e),e.defaultPrevented||me(e,!1)},Fe=e=>{a.textareaProps?.onCut?.(e),e.defaultPrevented||me(e,!0)},t[77]=me,t[78]=a.textareaProps,t[79]=X,t[80]=Fe):(X=t[79],Fe=t[80]);let Ie;t[81]===a.textareaProps?Ie=t[82]:(Ie=e=>{O(e.currentTarget.selectionStart),a.textareaProps?.onSelect?.(e)},t[81]=a.textareaProps,t[82]=Ie);let Le,Re;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(Le=()=>{ee(!0)},Re=e=>{ee(!1),O(e.currentTarget.selectionStart)},t[83]=Le,t[84]=Re):(Le=t[83],Re=t[84]);let ze;t[85]!==K||t[86]!==j||t[87]!==E||t[88]!==H||t[89]!==a.textareaProps?(ze=e=>{if(a.textareaProps?.onKeyDown?.(e),!(e.defaultPrevented||Me(e))){if(j){e.key===`Enter`&&e.preventDefault();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`){let t=e.shiftKey?je(R.current,E):we(R.current,E);t&&(e.preventDefault(),R.current=t.history,K(t.snapshot.document,t.snapshot.selection.end,!1),A(!0));return}if(e.key===`Backspace`||e.key===`Delete`){let t=b(E,{key:e.key,selectionStart:e.currentTarget.selectionStart,selectionEnd:e.currentTarget.selectionEnd,altKey:e.altKey});if(t){e.preventDefault(),K(t.document,t.caret),A(!0);return}}H&&[`ArrowDown`,`ArrowUp`,`Enter`,`Tab`,`Escape`].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),re.current?.keyDown(e.key))}},t[85]=K,t[86]=j,t[87]=E,t[88]=H,t[89]=a.textareaProps,t[90]=ze):ze=t[90];let Be;t[91]!==a.textareaProps||t[92]!==De||t[93]!==ke||t[94]!==Y||t[95]!==X||t[96]!==Fe||t[97]!==Ie||t[98]!==ze?(Be={...a.textareaProps,"aria-controls":De,"aria-activedescendant":ke,"aria-autocomplete":`list`,onScroll:Y,onCopy:X,onCut:Fe,onSelect:Ie,onCompositionStart:Le,onCompositionEnd:Re,onKeyDown:ze},t[91]=a.textareaProps,t[92]=De,t[93]=ke,t[94]=Y,t[95]=X,t[96]=Fe,t[97]=Ie,t[98]=ze,t[99]=Be):Be=t[99];let Ve;t[100]!==oe||t[101]!==z||t[102]!==H||t[103]!==a.isMobile||t[104]!==ce?(Ve=H?(0,$.jsx)(ot,{ref:re,query:H.query,isMobile:a.isMobile??!1,listId:z,onHighlightChange:ne,onSelect:ce,onClose:oe}):null,t[100]=oe,t[101]=z,t[102]=H,t[103]=a.isMobile,t[104]=ce,t[105]=Ve):Ve=t[105];let He;t[106]!==E.text||t[107]!==ge||t[108]!==h||t[109]!==a||t[110]!==xe||t[111]!==J||t[112]!==Te||t[113]!==Be||t[114]!==Ve?(He=(0,$.jsx)(Ne,{...a,value:q,pending:ye,placeholder:h,disableInputWhilePending:!1,inputRef:P,onSubmit:xe,highlightedContent:ge,highlightRef:F,textLayoutClassName:J,onChange:Te,textareaProps:Be,children:Ve}),t[106]=E.text,t[107]=ge,t[108]=h,t[109]=a,t[110]=xe,t[111]=J,t[112]=Te,t[113]=Be,t[114]=Ve,t[115]=He):He=t[115];let Ue;return t[116]!==_e||t[117]!==ve||t[118]!==He?(Ue=(0,$.jsxs)(`div`,{ref:s,className:`yuri-hold-to-talk-container`,"data-hold-to-talk-empty":_e,children:[ve,He]}),t[116]=_e,t[117]=ve,t[118]=He,t[119]=Ue):Ue=t[119],Ue};function ct(e){return{start:e.start,end:e.end,priority:103,...h(e)}}function lt(e,t){return(0,$.jsx)(`span`,{className:e.className,children:e.visual?(0,$.jsx)(De,{visual:e.visual,text:e.text}):e.text},`${t}-${e.text.length}`)}var ut=`rounded-[1.35rem] border border-border/40 cursor-zoom-in`;function dt({assistantID:e,descriptor:t,onShowPopup:n}){let{t:r}=I(),i=Ve(),{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=Re(l??``,c),[p,m]=Q.useState(0),[h,g]=Q.useState(``),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x=Q.useRef(null),S=Q.useRef([]);Q.useEffect(()=>{g(``),v(!1);let t=new AbortController,n;return d&&Ye(e,u,{signal:t.signal}).then(e=>{if(t.signal.aborted){e.release();return}n=e.release,g(e.url)}).catch(()=>{t.signal.aborted||v(!0)}),()=>{t.abort(),n?.()}},[e,u,i,d,p]),Q.useEffect(()=>()=>{x.current?.abort(),S.current.forEach(e=>URL.revokeObjectURL(e)),S.current=[]},[e,u,i]);let C=M(async(t=!1)=>{if(x.current)return;let i=new AbortController;x.current=i,b(!0),v(!1);try{let a=await Je(e,u,{signal:i.signal});if(i.signal.aborted)return;S.current.forEach(e=>URL.revokeObjectURL(e));let o=URL.createObjectURL(a);if(S.current=[o],t&&n){n({open:!0,title:l||r(`assistants.contact.attachment.file`),content:``,video:{url:o,mimeType:c,filename:l}});return}let s=document.createElement(`a`);s.href=o,s.download=l||r(`assistants.contact.attachment.file`),document.body.appendChild(s),s.click(),s.remove()}catch{i.signal.aborted||v(!0)}finally{x.current===i&&(x.current=null),i.signal.aborted||b(!1)}}),w=l||r(d?`assistants.contact.attachment.image`:`assistants.contact.attachment.file`),T=M(e=>{!n||!h||n({open:!0,title:w,content:``,metadata:{tool:`image-preview`,filename:w,mime:c},previewSource:e.currentTarget,image:{url:h,mimeType:c,filename:w,size:s,gallery:[{url:h,mimeType:c,filename:w,size:s}],index:0}})});return d&&h&&!_?(0,$.jsx)(We,{src:h,alt:w,contentFrame:!0,className:ut,onError:()=>v(!0),onClick:T,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T(e))},role:`button`,tabIndex:0,"data-assistant-contact-image":``}):d&&!_?(0,$.jsx)(Ue,{className:`h-[var(--yuri-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)(q,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:w})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:r(`assistants.contact.attachment.loadFailed`)}):null,d&&!_||y?(0,$.jsx)(`span`,{role:`status`,className:`typography-micro text-muted-foreground`,children:r(`common.loading`)}):(0,$.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,onClick:d?()=>m(e=>e+1):()=>void C(f&&!!n),children:r(_?`chat.history.retry`:f&&n?`contextPanel.mode.preview`:`assistants.contact.attachment.download`)})]})}function ft(e){let t=(0,Z.c)(39),{part:n,onShowPopup:r}=e,{t:i}=I(),a=/^(?:https?:|data:|blob:)/i.test(n.url)?n.url:``,o=He(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=M(d);if(Re(a,n.mime)&&a&&r){let e;t[7]!==r||t[8]!==n.filename||t[9]!==n.mime||t[10]!==a||t[11]!==i?(e=()=>r({open:!0,title:n.filename||i(`assistants.contact.attachment.file`),content:``,video:{url:a,filename:n.filename,mimeType:n.mime}}),t[7]=r,t[8]=n.filename,t[9]=n.mime,t[10]=a,t[11]=i,t[12]=e):e=t[12];let o;t[13]!==n.filename||t[14]!==i?(o=n.filename||i(`contextPanel.mode.preview`),t[13]=n.filename,t[14]=i,t[15]=o):o=t[15];let s;return t[16]!==e||t[17]!==o?(s=(0,$.jsx)(F,{variant:`secondary`,size:`sm`,onClick:e,children:o}),t[16]=e,t[17]=o,t[18]=s):s=t[18],s}if(n.mime.startsWith(`image/`)&&o&&!s){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>c(!0),t[19]=e):e=t[19];let n;t[20]===f?n=t[21]:(n=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f(e))},t[20]=f,t[21]=n);let r;return t[22]!==u||t[23]!==f||t[24]!==o||t[25]!==n?(r=(0,$.jsx)(We,{src:o,alt:u,contentFrame:!0,className:ut,onError:e,onClick:f,onKeyDown:n,role:`button`,tabIndex:0,"data-assistant-contact-image":``}),t[22]=u,t[23]=f,t[24]=o,t[25]=n,t[26]=r):r=t[26],r}let p;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(q,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),t[27]=p):p=t[27];let m;t[28]!==n.filename||t[29]!==i?(m=n.filename||i(`assistants.contact.attachment.file`),t[28]=n.filename,t[29]=i,t[30]=m):m=t[30];let h;t[31]===m?h=t[32]:(h=(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:m}),t[31]=m,t[32]=h);let g;t[33]!==s||t[34]!==i?(g=s?(0,$.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>c(!1),children:i(`chat.history.retry`)}):null,t[33]=s,t[34]=i,t[35]=g):g=t[35];let _;return t[36]!==h||t[37]!==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[36]=h,t[37]=g,t[38]=_):_=t[38],_}function pt(e){let t=(0,Z.c)(5),{assistantID:n,part:r,onShowPopup:i}=e,a=Ve(),o;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a?(o=`attachmentID`in r?(0,$.jsx)(dt,{assistantID:n,descriptor:r,onShowPopup:i},`${a}:${n}:${r.attachmentID}:${r.sha256}`):(0,$.jsx)(ft,{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 mt=Q.memo(e=>{let t=(0,Z.c)(32),{turn:n,retryDisabled:r,onRetry:l}=e,{t:d}=I(),p;t[0]===d?p=t[1]:(p=d(`assistants.contact.sendError.viewDetails`),t[0]=d,t[1]=p);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(q,{name:`exclamation-fill`,className:`size-[18px] text-[var(--status-error)]`,"data-assistant-contact-error-dot":``}),t[2]=m):m=t[2];let h;t[3]===p?h=t[4]:(h=(0,$.jsx)(s,{type:`button`,"aria-label":p,"data-assistant-contact-send-error":``,className:`absolute right-full top-1/2 mr-1.5 flex size-9 -translate-y-1/2 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-0 shadow-none outline-none focus-visible:opacity-70`,children:m}),t[3]=p,t[4]=h);let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g={side:`flip`,align:`shift`,fallbackAxisSide:`end`},t[5]=g):g=t[5];let _;t[6]===d?_=t[7]:(_=d(`assistants.contact.sendError.title`),t[6]=d,t[7]=_);let v;t[8]===_?v=t[9]:(v=(0,$.jsx)(i,{className:`typography-ui-label font-medium`,children:_}),t[8]=_,t[9]=v);let y;t[10]!==d||t[11]!==n.error?(y=n.error||d(`assistants.contact.sendFailed`),t[10]=d,t[11]=n.error,t[12]=y):y=t[12];let b;t[13]===y?b=t[14]:(b=(0,$.jsx)(f,{role:`alert`,className:`mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap typography-meta leading-relaxed [overflow-wrap:anywhere]`,children:y}),t[13]=y,t[14]=b);let x;t[15]!==l||t[16]!==n.messageID?(x=()=>l(n.messageID),t[15]=l,t[16]=n.messageID,t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(q,{name:`refresh`,className:`size-3`}),t[18]=S):S=t[18];let C;t[19]===d?C=t[20]:(C=d(`chat.history.retry`),t[19]=d,t[20]=C);let w;t[21]!==r||t[22]!==C||t[23]!==x?(w=(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(F,{type:`button`,size:`xs`,disabled:r,onClick:x,children:[S,C]})}),t[21]=r,t[22]=C,t[23]=x,t[24]=w):w=t[24];let T;t[25]!==w||t[26]!==v||t[27]!==b?(T=(0,$.jsx)(c,{children:(0,$.jsx)(u,{side:`left`,align:`center`,sideOffset:6,collisionPadding:12,collisionAvoidance:g,className:`z-50`,children:(0,$.jsxs)(a,{className:`yuri-mobile-overlay-surface w-72 max-w-[calc(100vw-2rem)] rounded-xl p-4 text-foreground outline-none`,"data-assistant-contact-send-error-popup":``,children:[v,b,w]})})}),t[25]=w,t[26]=v,t[27]=b,t[28]=T):T=t[28];let E;return t[29]!==T||t[30]!==h?(E=(0,$.jsxs)(o,{children:[h,T]}),t[29]=T,t[30]=h,t[31]=E):E=t[31],E});function ht(e){let t=(0,Z.c)(7),{children:n,failedTurn:r,retryDisabled:i,onRetry:a}=e,o;t[0]!==r||t[1]!==a||t[2]!==i?(o=r?.status===`failed`?(0,$.jsx)(mt,{turn:r,retryDisabled:i,onRetry:a}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o):o=t[3];let s;return t[4]!==n||t[5]!==o?(s=(0,$.jsxs)(`div`,{className:`relative min-w-0 max-w-full`,"data-assistant-contact-user-part":``,children:[n,o]}),t[4]=n,t[5]=o,t[6]=s):s=t[6],s}var gt=[],_t=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}),yt=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},bt=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},xt=(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:[]}),St=(e,t,n)=>{let r=e.bubbles.filter(e=>!t.has(e.bubbleIndex)).map((t,r)=>xt(e,t,n+r,t.done?`complete`:`streaming`));return e.status===`failed`?[...r,xt(e,null,n+r.length,`failed`)]:e.status===`admitted`||e.status===`streaming`?[...r,xt(e,null,n+r.length,`admitted`)]:r},Ct=(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:_t(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=St(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)},wt=(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},Tt=(e,t)=>e.map(e=>e.messageID===t?{...e,status:`admitted`}:e),Et=(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}]},Dt=(e,t,n)=>!t?.turnID||!t.assistantID||n?.has(t.turnID)?e:Et(e,t.assistantID,t.turnID,t.admittedAt),Ot=(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=Dt(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=At(u,{assistantID:n,turnID:e.turnID,status:`error`,error:e.text||`upstream_error`,occurredAt:s})));if(u=jt(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},kt=(e,t)=>Et(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}}),At=(e,t,n={})=>n.requireExisting&&!e.some(e=>e.assistantID===t.assistantID&&e.turnID===t.turnID)?e:Et(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}:{}}),jt=(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},Mt=(e,t,n)=>e.map(e=>e.messageID===t?{...e,status:`failed`,error:n}:e),Nt=(e,t)=>e instanceof G?e.code===`no_provider`?t.noProvider:e.code===`admission_timeout`||e.code===`generate_timeout`?t.timedOut:e.message&&e.message!==e.code?e.message:`${t.sendFailed}\n\n${e.code} (HTTP ${e.status})`:V(e)?t.timedOut:e instanceof Error&&e.message.trim()?e.message:t.sendFailed,Pt=()=>{let e=!1;return{tryAcquire:()=>!e&&(e=!0,!0),release:()=>{e=!1}}},Ft=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)}},It=e=>e.some(e=>e.status===`sending`),Lt=e=>e.some(e=>e.status===`admitted`||e.status===`streaming`),Rt=r(e=>({workingByID:{},setWorking:(t,n)=>e(e=>({workingByID:{...e.workingByID,[t]:n}}))})),zt=({sending:e=!1,processing:t=!1,serverWorking:n=!1})=>e||t||n,Bt=(e,t)=>{let n=(0,Z.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=Rt(i),o;return n[2]!==a||n[3]!==r?(o=zt({processing:a,serverWorking:r}),n[2]=a,n[3]=r,n[4]=o):o=n[4],o},Vt=e=>{let t=(0,Z.c)(25),{name:n,avatarSeed:r,size:i,label:a,working:o,showWorkingDot:s,className:c,hoverTarget:l,followPointer:u,blinkOnMount:d}=e,f=i===void 0?24:i,p=s===void 0||s,m=d===void 0||d,{t:h}=I(),g;t[0]!==n||t[1]!==o?(g=e=>o!==void 0&&!!e.workingByID[n],t[0]=n,t[1]=o,t[2]=g):g=t[2];let _=Rt(g),v=!!(o||_),y=`calc(${f}px * var(--dpt-n, 1))`,b;t[3]===c?b=t[4]:(b=N(`relative inline-block shrink-0 align-middle leading-none`,c),t[3]=c,t[4]=b);let x;t[5]===y?x=t[6]:(x={width:y,minWidth:y,maxWidth:y,height:y,minHeight:y,maxHeight:y},t[5]=y,t[6]=x);let S=o===void 0?void 0:v?`working`:`idle`,C=r??n,w;t[7]!==m||t[8]!==u||t[9]!==l||t[10]!==a||t[11]!==n||t[12]!==f||t[13]!==S||t[14]!==C?(w=(0,$.jsx)(he,{kind:`assistant`,motion:S,name:C,size:f,label:a,hoverTarget:l,followPointer:u,animationKey:n,blinkOnMount:m}),t[7]=m,t[8]=u,t[9]=l,t[10]=a,t[11]=n,t[12]=f,t[13]=S,t[14]=C,t[15]=w):w=t[15];let T;t[16]!==p||t[17]!==h||t[18]!==o?(T=o&&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-background`,"data-assistant-working-dot":``,"aria-label":h(`assistants.contact.working`)}):null,t[16]=p,t[17]=h,t[18]=o,t[19]=T):T=t[19];let E;return t[20]!==T||t[21]!==b||t[22]!==x||t[23]!==w?(E=(0,$.jsxs)(`span`,{className:b,style:x,"data-assistant-working-avatar":``,children:[w,T]}),t[20]=T,t[21]=b,t[22]=x,t[23]=w,t[24]=E):E=t[24],E};function Ht(e){let t=(0,Z.c)(6),{value:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(q,{name:`brain`,weight:`medium`,className:`size-3.5 shrink-0`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),t[1]=n,t[2]=i);let a;return t[3]!==i||t[4]!==n?(a=(0,$.jsxs)(`p`,{"data-contact-card-model":``,className:`flex min-w-0 flex-1 items-center gap-1.5 text-[0.75em] leading-4 text-muted-foreground`,title:n,children:[r,i]}),t[3]=i,t[4]=n,t[5]=a):a=t[5],a}var Ut=Q.createContext(null),Wt=[`grid h-[calc(148px*var(--padding-scale,1))] w-[19rem] min-w-0 max-w-full shrink-0 grid-rows-[calc(40px*var(--padding-scale,1))_calc(20px*var(--padding-scale,1))_calc(20px*var(--padding-scale,1))_calc(48px*var(--padding-scale,1))] content-start cursor-pointer rounded-[1.35rem] bg-[var(--surface-muted)]`,`px-4 py-2.5 text-left typography-ui-label transition-colors duration-150 motion-reduce:transition-none`,`hover:bg-interactive-hover/45`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`].join(` `),Gt=Wt,Kt=Wt,qt=`row-start-1 mb-2 flex h-8 min-w-0 items-center gap-2`,Jt=`row-start-2 min-w-0 self-start truncate font-medium leading-5 text-foreground`,Yt=`row-start-4 flex h-12 min-w-0 flex-col justify-center`;function Xt(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}var Zt=e=>{let t=(0,Z.c)(36),{card:n,assistant:r,active:i}=e,a=i===void 0||i,{t:o}=I(),s=xe(),c;t[0]===s?c=t[1]:(c=s&&!D(),t[0]=s,t[1]=c);let l=!!c,u=n.name,d=`${n.providerID}/${n.modelID}`,f=Q.useContext(Ut),p;t[2]!==n.assistantID||t[3]!==l||t[4]!==f?(p=()=>{if(f)return f({assistantID:n.assistantID});if(l){L.getState().openAssistant(n.assistantID);return}de(n.assistantID)},t[2]=n.assistantID,t[3]=l,t[4]=f,t[5]=p):p=t[5];let m=M(p),h;t[6]===m?h=t[7]:(h=e=>{Xt(e,m)},t[6]=m,t[7]=h);let g=M(h),_;t[8]!==o||t[9]!==u?(_=o(`assistants.contact.card.assistant.aria`,{name:u}),t[8]=o,t[9]=u,t[10]=_):_=t[10];let v=r?.avatarSeed,y=a?!!(r?.working||r?.activeContactTurn):void 0,b;t[11]!==n.assistantID||t[12]!==v||t[13]!==y?(b=(0,$.jsx)(`span`,{className:`relative inline-block shrink-0 leading-none`,"aria-hidden":!0,children:(0,$.jsx)(Vt,{name:n.assistantID,avatarSeed:v,size:32,working:y,showWorkingDot:!1,followPointer:!1})}),t[11]=n.assistantID,t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;t[15]===o?x=t[16]:(x=o(`assistants.contact.card.assistant.label`),t[15]=o,t[16]=x);let S;t[17]===x?S=t[18]:(S=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[0.8em] leading-4 text-muted-foreground`,children:x}),t[17]=x,t[18]=S);let C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(q,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[19]=C):C=t[19];let w;t[20]!==S||t[21]!==b?(w=(0,$.jsxs)(`div`,{className:qt,children:[b,S,C]}),t[20]=S,t[21]=b,t[22]=w):w=t[22];let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=N(Jt,`row-span-2 self-center`),t[23]=T):T=t[23];let E;t[24]===u?E=t[25]:(E=(0,$.jsx)(`h3`,{className:T,title:u,children:u}),t[24]=u,t[25]=E);let O;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(O=N(Yt,`justify-end pb-1`),t[26]=O):O=t[26];let k;t[27]===d?k=t[28]:(k=(0,$.jsx)(`div`,{className:O,children:(0,$.jsx)(`div`,{className:`flex h-4 min-w-0 items-center`,children:(0,$.jsx)(Ht,{value:d})})}),t[27]=d,t[28]=k);let A;return t[29]!==g||t[30]!==m||t[31]!==w||t[32]!==E||t[33]!==k||t[34]!==_?(A=(0,$.jsxs)(`article`,{className:Gt,role:`button`,tabIndex:0,"aria-label":_,"data-assistant-contact-card":`assistant`,onClick:m,onKeyDown:g,children:[w,E,k]}),t[29]=g,t[30]=m,t[31]=w,t[32]=E,t[33]=k,t[34]=_,t[35]=A):A=t[35],A},Qt=e=>!!(e&&typeof e==`object`&&!Array.isArray(e)),$t=e=>typeof e==`string`&&/^([01]\d|2[0-3]):[0-5]\d$/.test(e),en=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6,tn=e=>e.kind===`cron`?e.cron===void 0:e.kind===`once`?e.date===void 0:e.kind===`weekly`?e.times===void 0||e.weekdays===void 0:e.kind===`daily`&&e.times===void 0,nn=e=>{if(!Qt(e)||e.timezone!==void 0&&typeof e.timezone!=`string`)return!1;if(e.kind===`cron`)return typeof e.cron==`string`&&!!e.cron.trim();if(e.kind===`once`)return typeof e.date==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e.date)&&$t(e.time);let t=Array.isArray(e.times)&&e.times.length>0&&e.times.every($t);return e.kind===`daily`?t||$t(e.time):e.kind===`weekly`&&(t||$t(e.time))&&Array.isArray(e.weekdays)&&e.weekdays.length>0&&e.weekdays.every(en)},rn=(e,t)=>{if(!tn(e)||!nn(t?.schedule))return e;let n=t.schedule;return{...e,kind:n.kind,time:n.time??n.times?.[0]??null,timezone:n.timezone??e.timezone,cron:n.cron??null,date:n.date??null,times:n.times??null,weekdays:n.weekdays??null}},an=(e,t)=>{let n=e.kind===`daily`||e.kind===`weekly`||e.kind===`once`||e.kind===`cron`?t(`sessions.scheduledTasks.editor.scheduleType.${e.kind}`):e.kind||``,r=[...new Set((e.times?.length?e.times:e.time?[e.time]:[]).filter($t))].sort(),i=r.join(`, `),a=n,o=r.length===1;if(e.kind===`cron`)i=e.cron?.trim()||n,a=e.cron?.trim()?n:``,o=!1;else if(e.kind===`once`)i=[e.date?.trim(),i].filter(Boolean).join(` `),o=!1;else if(e.kind===`weekly`&&e.weekdays?.length){let n=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`];a=[...new Set(e.weekdays.filter(en))].sort((e,t)=>e-t).map(e=>t(`sessions.scheduledTasks.dialog.schedule.weekdayShort.${n[e]}`)).join(`, `)}return{value:i||t(`assistants.contact.card.schedule.timeUnavailable`),cadence:a,clock:o,timezone:e.timezone}},on=e=>{let t=(0,Z.c)(44),{card:n,task:r}=e,{t:i}=I(),a=n.name,o;t[0]!==n||t[1]!==i||t[2]!==r?(o=an(rn(n,r),i),t[0]=n,t[1]=i,t[2]=r,t[3]=o):o=t[3];let s=o,c;t[4]===n.prompt?c=t[5]:(c=n.prompt?.trim(),t[4]=n.prompt,t[5]=c);let l=c,u=Q.useContext(Ut),d;t[6]!==n.projectID||t[7]!==n.taskID||t[8]!==u?(d=()=>{if(u)return u({projectID:n.projectID,taskID:n.taskID});ye(n.projectID,n.taskID)},t[6]=n.projectID,t[7]=n.taskID,t[8]=u,t[9]=d):d=t[9];let f=M(d),p;t[10]===f?p=t[11]:(p=e=>{Xt(e,f)},t[10]=f,t[11]=p);let m=M(p),h;t[12]!==i||t[13]!==a?(h=i(`assistants.contact.card.schedule.aria`,{name:a}),t[12]=i,t[13]=a,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(q,{name:`calendar`,weight:`medium`,className:`size-4 shrink-0`}),t[15]=g):g=t[15];let _;t[16]===i?_=t[17]:(_=i(`assistants.contact.card.schedule.label`),t[16]=i,t[17]=_);let v;t[18]===_?v=t[19]:(v=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-[0.8em] leading-4 text-muted-foreground`,children:[g,(0,$.jsx)(`span`,{className:`truncate`,children:_})]}),t[18]=_,t[19]=v);let y;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(q,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[20]=y):y=t[20];let b;t[21]===v?b=t[22]:(b=(0,$.jsxs)(`div`,{className:qt,children:[v,y]}),t[21]=v,t[22]=b);let x;t[23]===a?x=t[24]:(x=(0,$.jsx)(`h3`,{className:Jt,title:a,children:a}),t[23]=a,t[24]=x);let S;t[25]===l?S=t[26]:(S=l?(0,$.jsx)(`p`,{className:`row-start-3 mt-1 min-w-0 truncate text-[0.8em] leading-4 text-muted-foreground`,title:l,children:l}):null,t[25]=l,t[26]=S);let C;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(C=N(Yt,`justify-end`),t[27]=C):C=t[27];let w;t[28]===s.cadence?w=t[29]:(w=s.cadence?(0,$.jsx)(`span`,{"data-contact-schedule-cadence":``,className:`min-w-0 max-w-[36%] flex-[0_1_auto] truncate text-[0.75em] leading-4 text-muted-foreground`,title:s.cadence,children:s.cadence}):null,t[28]=s.cadence,t[29]=w);let T=`min-w-0 flex-[0_1_auto] truncate leading-[22px] text-foreground tabular-nums ${s.clock?`text-[1.25em] font-normal tracking-[-0.3px]`:`text-[0.85em]`}`,E;t[30]!==s.value||t[31]!==T?(E=(0,$.jsx)(`p`,{className:T,title:s.value,children:s.value}),t[30]=s.value,t[31]=T,t[32]=E):E=t[32];let D;t[33]!==w||t[34]!==E?(D=(0,$.jsx)(`div`,{className:C,children:(0,$.jsxs)(`div`,{"data-contact-schedule-time":``,className:`flex min-w-0 flex-none items-baseline gap-1.5`,children:[w,E]})}),t[33]=w,t[34]=E,t[35]=D):D=t[35];let O;return t[36]!==m||t[37]!==f||t[38]!==b||t[39]!==x||t[40]!==S||t[41]!==D||t[42]!==h?(O=(0,$.jsxs)(`article`,{className:Gt,role:`button`,tabIndex:0,"aria-label":h,"data-assistant-contact-card":`schedule`,onClick:f,onKeyDown:m,children:[b,x,S,D]}),t[36]=m,t[37]=f,t[38]=b,t[39]=x,t[40]=S,t[41]=D,t[42]=h,t[43]=O):O=t[43],O},sn=(e,t)=>t===`cancelled`?t:e===`busy`||e===`retry`?e:t===`error`||t===`question`||t===`complete`||t===`busy`||t===`retry`?t:e===`idle`?`complete`:t===`idle`?t:t||`busy`,cn=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,ln=e=>e===`busy`?`text-[var(--status-info)]`:e===`retry`||e===`question`?`text-[var(--status-warning)]`:e===`error`?`text-[var(--status-error)]`:e===`idle`||e===`complete`?`text-[var(--status-success)]`:`text-muted-foreground`,un=e=>e.split(/[/\\]/u).filter(Boolean).at(-1)||e,dn=e=>{let t=(0,Z.c)(57),{card:n}=e,{t:r}=I(),i=xe(),a;t[0]===i?a=t[1]:(a=i&&!D(),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=re(s),l=P(n.sessionID),u=(typeof c?.title==`string`&&c.title.trim()?c.title.trim():null)||n.title||r(`assistants.contact.card.session.untitled`),d=sn(l?.type,n.status),f=cn(d),p;t[4]!==n.directory||t[5]!==c?(p=typeof c?.directory==`string`&&c.directory.trim()?c.directory.trim():n.directory,t[4]=n.directory,t[5]=c,t[6]=p):p=t[6];let m=p,h;t[7]===m?h=t[8]:(h=un(m),t[7]=m,t[8]=h);let g=h,_=ie(m).data?.current?.trim()||null,v;t[9]===c?v=t[10]:(v=Y(c),t[9]=c,t[10]=v);let y=v,b=d===`complete`||d===`idle`?J(c):null,x=Q.useContext(Ut),C;t[11]!==n.directory||t[12]!==n.sessionID||t[13]!==o||t[14]!==x?(C=()=>{let e=X(n.sessionID)?.directory||n.directory;if(x)return x({sessionId:n.sessionID,directory:e});ne(n.sessionID,e,{phoneShell:o,switchToChat:!0}),o||S.getState().setActiveMainTab(`chat`)},t[11]=n.directory,t[12]=n.sessionID,t[13]=o,t[14]=x,t[15]=C):C=t[15];let w=M(C),T;t[16]===w?T=t[17]:(T=e=>{Xt(e,w)},t[16]=w,t[17]=T);let E=M(T),O=Kt,k=r(`assistants.contact.card.session.aria`,{title:u}),A;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(q,{name:`chat-thread`,weight:`medium`,className:`size-4 shrink-0`}),t[18]=A):A=t[18];let j;t[19]===r?j=t[20]:(j=r(`assistants.contact.card.session.label`),t[19]=r,t[20]=j);let ee;t[21]===j?ee=t[22]:(ee=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-[0.8em] leading-4 text-muted-foreground`,children:[A,(0,$.jsx)(`span`,{className:`truncate`,children:j})]}),t[21]=j,t[22]=ee);let te=f?(0,$.jsxs)(`span`,{"data-assistant-session-status":``,className:N(`ml-auto inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[0.75em] leading-4`,ln(d)),children:[(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}),r(f)]}):null,F;t[23]!==ee||t[24]!==te?(F=(0,$.jsxs)(`div`,{className:qt,children:[ee,te]}),t[23]=ee,t[24]=te,t[25]=F):F=t[25];let L;t[26]===u?L=t[27]:(L=(0,$.jsx)(`h3`,{className:Jt,title:u,children:u}),t[26]=u,t[27]=L);let R=N(`flex min-w-0 items-center gap-1.5 text-foreground`,_&&`max-w-[45%] shrink-0`),z;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(q,{name:`folder`,weight:`medium`,className:`size-3.5 shrink-0 text-muted-foreground`}),t[28]=z):z=t[28];let B;t[29]===g?B=t[30]:(B=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:g}),t[29]=g,t[30]=B);let V;t[31]!==m||t[32]!==R||t[33]!==B?(V=(0,$.jsxs)(`p`,{className:R,title:m,children:[z,B]}),t[31]=m,t[32]=R,t[33]=B,t[34]=V):V=t[34];let H;t[35]===_?H=t[36]:(H=_?(0,$.jsxs)(`p`,{"data-contact-session-branch":``,className:`flex min-w-0 items-center gap-1 text-muted-foreground`,title:_,children:[(0,$.jsx)(q,{name:`git-branch`,weight:`medium`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:_})]}):null,t[35]=_,t[36]=H);let U;t[37]!==V||t[38]!==H?(U=(0,$.jsxs)(`div`,{"data-contact-session-project":``,className:`flex h-4 min-w-0 flex-none items-center gap-2 text-[0.8em] leading-4`,children:[V,H]}),t[37]=V,t[38]=H,t[39]=U):U=t[39];let ae=b?(0,$.jsxs)(`p`,{"data-contact-session-changes":``,className:`flex h-4 min-w-0 flex-none items-center gap-1.5 overflow-hidden whitespace-nowrap text-[0.8em] leading-4 text-muted-foreground tabular-nums`,children:[(0,$.jsx)(q,{name:`code`,weight:`medium`,className:`size-3.5 shrink-0`}),b.additions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,b.additions]}),b.deletions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-error)]`,children:[`−`,b.deletions]}),b.files===void 0?null:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:b.files===1?r(`assistants.contact.card.session.changes.filesSingle`,{count:b.files}):r(`assistants.contact.card.session.changes.filesPlural`,{count:b.files})})]}):null,W;t[40]===y?W=t[41]:(W=y?(0,$.jsx)(Ht,{value:y}):null,t[40]=y,t[41]=W);let oe;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(q,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[42]=oe):oe=t[42];let G;t[43]===W?G=t[44]:(G=(0,$.jsxs)(`div`,{"data-contact-session-bottom":``,className:`mt-auto flex h-4 min-w-0 flex-none items-center gap-2`,children:[W,oe]}),t[43]=W,t[44]=G);let K;t[45]!==U||t[46]!==ae||t[47]!==G?(K=(0,$.jsxs)(`div`,{"data-contact-session-details":``,className:`row-start-3 row-end-5 flex min-w-0 flex-col gap-1.5 py-1`,children:[U,ae,G]}),t[45]=U,t[46]=ae,t[47]=G,t[48]=K):K=t[48];let se;return t[49]!==E||t[50]!==w||t[51]!==k||t[52]!==F||t[53]!==L||t[54]!==K||t[55]!==O?(se=(0,$.jsxs)(`article`,{className:O,role:`button`,tabIndex:0,"aria-label":k,"data-assistant-contact-card":`session`,onClick:w,onKeyDown:E,children:[F,L,K]}),t[49]=E,t[50]=w,t[51]=k,t[52]=F,t[53]=L,t[54]=K,t[55]=O,t[56]=se):se=t[56],se},fn=3e5,pn=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();function mn(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(`yuri.settle.`)&&!e.text.trim().startsWith(`oc.settle.`))))continue;let e=new Date(r.createdAt);Number.isFinite(e.getTime())&&((!n||!pn(n,e)||e.getTime()-n.getTime()>fn)&&t.set(r.messageID,r.createdAt),n=e)}return t}function hn(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`${pn(o,n)?t:(o.getFullYear()===n.getFullYear()?i:a).format(o)} ${r.format(o)}`}}var gn=2,_n=1500,vn=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),yn=e=>e.scrollHeight-e.scrollTop-e.clientHeight,bn=e=>yn(e)<=gn,xn=(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},Sn=e=>e.altKey||e.ctrlKey||e.metaKey?!1:e.key===`ArrowDown`||e.key===`PageDown`||e.key===`End`,Cn=({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 _=ve(),v=Q.useRef(!1),y=Q.useRef(null),b=Q.useRef(null),x=M(()=>{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=M(()=>{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=M(()=>{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}}),E=M(()=>{x(),l.current=!1,p.current=i.current?.scrollTop??0,w()}),D=Q.useRef(null),O=M(e=>{let t=i.current;!g.current||!t||(D.current=e??null,l.current=!0,u.current=null,h.current=null,p.current=t.scrollTop)}),k=M(()=>{if(!g.current||!l.current)return!1;let e=i.current;if(!e)return!1;let t=vn(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),bn(t))return x(),p.current=t.scrollTop,!1;let a=Math.max(0,t.scrollHeight-t.clientHeight);if(!r&&!_){if(b.current===a)return!1;x(),b.current=a;let t=D.current;return D.current=null,y.current=_e(e.scrollTop,a,{duration:t?.duration??.22,ease:t?[...t.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}return x(),e.scrollTop=a,p.current=e.scrollTop,!0}),j=M(e=>{h.current={direction:e,expiresAt:performance.now()+_n}}),te=M(()=>{let e=h.current;return e?performance.now()>e.expiresAt?(h.current=null,null):e.direction:null}),ne=M(()=>{x(),l.current=!1,w()}),N=M(()=>{if(!g.current)return;let e=i.current;if(!e)return;let t=vn(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&&ne();return}let o=te();T(),t.scrollTop<=80&&o===`up`&&r?.(),n&&bn(t)&&(o===`down`||o===`scrollbar`)&&(l.current=!0)}),P=M(e=>{let t=i.current;if(!(!t||e.deltaY===0)){if(e.deltaY<0){if(ke(t,e.target))return;j(`up`),ne(),t.scrollTop<=80&&r?.();return}xn(t,e.target)||j(`down`)}}),F=M(e=>{h.current=null;let t=e.touches.item(0);m.current=t?{x:t.clientX,y:t.clientY,deltaX:0,deltaY:0}:null}),I=M(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&&ke(t,e.target)||l<0&&xn(t,e.target)){m.current.deltaX=0,m.current.deltaY=0;return}j(l>0?`up`:`down`),l>2&&(ne(),t.scrollTop<=80&&r?.())}}),re=M(()=>{m.current=null}),ie=M(e=>{if(Te(e)){j(`up`),ne(),(i.current?.scrollTop??1/0)<=80&&r?.();return}Sn(e)&&j(`down`)}),L=M(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&&(k(),T())},[e,t,n,a,_]),Q.useLayoutEffect(()=>()=>{x()},[e,t,a,x]);let R=Q.useMemo(()=>()=>void 0,[]),z=e&&a?a:R,B=Q.useMemo(()=>({passive:!0}),[]);A(`scroll`,N,z,B),A(`wheel`,P,z,B),A(`touchstart`,F,z,B),A(`touchmove`,I,z,B),A(`touchend`,re,z,B),A(`touchcancel`,re,z,B),A(`keydown`,ie,z),A(`pointerdown`,L,z,B);let V=M(()=>{k(),T()});return ee(typeof ResizeObserver<`u`&&e?s:null,V),{scrollRef:S,contentRef:C,preparePrepend:E,followLatest:O}},wn=.3,Tn=[.19919472913616398,.010644531250000006,.27920937042459737,.91025390625],En=[.23,1,.32,1],Dn=ge(...Tn),On=ge(...En),kn=.15,An=.1,jn=.08,Mn=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),Nn=e=>Number.parseFloat(e)||0,Pn=(e,t,n)=>e+(t-e)*n,Fn=e=>[e.borderTopLeftRadius,e.borderTopRightRadius,e.borderBottomRightRadius,e.borderBottomLeftRadius],In=e=>{let t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=t.left+Nn(n.borderLeftWidth)+Nn(n.paddingLeft),i=t.top+Nn(n.borderTopWidth)+Nn(n.paddingTop);return{left:r,top:i,width:t.right-Nn(n.borderRightWidth)-Nn(n.paddingRight)-r,height:t.bottom-Nn(n.borderBottomWidth)-Nn(n.paddingBottom)-i}},Ln=e=>({color:e.color,fontFamily:e.fontFamily,fontSize:e.fontSize,fontWeight:e.fontWeight,fontFeatureSettings:e.fontFeatureSettings,letterSpacing:e.letterSpacing,lineHeight:e.lineHeight,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`}),Rn=(e,t,n=!1)=>{if(!t.value.trim())return null;let r=window.getComputedStyle(e),i=In(t),a=t.parentElement?.querySelector(`[data-composer-highlight]`),o=Ln(window.getComputedStyle(t));return a&&(o.color=window.getComputedStyle(a).color),{compact:n,background:Mn(e.getBoundingClientRect()),backgroundColor:r.backgroundColor,radii:Fn(r),text:t.value,textBox:{...i,top:i.top-t.scrollTop},textStyle:o}},zn=e=>{let t=document.createElement(`div`);return Object.assign(t.style,{position:`absolute`,pointerEvents:`none`,margin:`0px`,...e}),t},Bn=(e,t,n,r)=>(e.style.opacity=String(t),_e(e,{opacity:[t,n]},{duration:r,ease:`linear`})),Vn=(e,t,n=t,r)=>{let i=window.getComputedStyle(t),a=Fn(i),o=Mn(t.getBoundingClientRect()),s=In(t),c=e.compact?{...e.background,left:e.textBox.left-Nn(i.paddingLeft),width:Math.min(e.background.width,Math.max(120,o.width+32))}:e.background,l={left:c.left,top:c.top+c.height-o.height},u={x:e.textBox.left-l.left-(s.left-o.left),y:e.textBox.top-l.top-(s.top-o.top)},d=zn({position:`fixed`,left:`0px`,top:`0px`,overflow:`hidden`,zIndex:`60`,willChange:`transform, width, height`});d.setAttribute(`aria-hidden`,`true`),d.setAttribute(`data-assistant-contact-send-flight`,``),d.style.backgroundColor=e.backgroundColor;let f=zn({...e.textStyle,left:`0px`,top:`0px`,width:`${e.textBox.width}px`});f.textContent=e.text;let p=zn({...Ln(i),left:`0px`,top:`0px`,width:`${s.width}px`});p.textContent=t.textContent??``,d.append(f,p);let m=n=>{let r=Dn(n),i=On(n),m=Mn(t.getBoundingClientRect()),h=c,g=Pn(h.left,m.left,i),_=Pn(h.left+h.width,m.left+m.width,i),v=Pn(h.top+h.height,m.top+m.height,r),y=Pn(h.height,m.height,r),b=v-y;d.style.transform=`translate3d(${g}px, ${b}px, 0)`,d.style.width=`${_-g}px`,d.style.height=`${y}px`,d.style.borderRadius=a.map((t,n)=>`${Pn(Nn(e.radii[n]),Nn(t),r)}px`).join(` `);let x=m.left+(l.left-o.left)*(1-i),S=m.top+(l.top-o.top)*(1-r),C=`translate3d(${x+(s.left-o.left)+u.x*(1-r)-g}px, ${S+(s.top-o.top)+u.y*(1-r)-b}px, 0)`;f.style.transform=C,p.style.transform=C},h=!1,g=[],_=()=>{h||(h=!0,g.forEach(e=>e.stop()),d.remove(),n.style.visibility=``,r?.())};return n.style.visibility=`hidden`,m(0),document.body.appendChild(d),g.push(_e(d,{backgroundColor:[e.backgroundColor,i.backgroundColor]},{duration:kn,ease:`linear`}),Bn(f,1,0,An),Bn(p,0,1,jn),_e(0,1,{duration:wn,ease:`linear`,onUpdate:m,onComplete:_})),_},Hn=64,Un=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)},Wn=e=>Array.from(e?.files||[]),Gn=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}},Kn=(e,t)=>{let n=[...e,...t];for(let e of n.slice(Hn))e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url);return n.slice(0,Hn)},qn=ze(()=>T(()=>import(`./ToolOutputDialog-CoKt-9rk.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73]))),Jn=e=>e.trim().startsWith(`yuri.settle.`)||e.trim().startsWith(`oc.settle.`),Yn=e=>e.status===`error`||e.status===`failed`&&e.messageID.endsWith(`:preview:failed`),Xn=e=>e.role===`assistant`&&e.status!==`error`&&e.parts.some(e=>e.type===`text`)?`${e.turnID}:assistant:${e.bubbleIndex}`:e.messageID,Zn=({assistant:e,warning:t,active:n,overlayHeader:r=!1})=>{let{t:i,locale:a}=I(),o=Ve(),s=S(e=>e.isMobile),c=oe(),l=le(),u=W(e.id,n),d=S(e=>e.isSettingsDialogOpen),f=n&&!d&&!u.hasMessageGap?ue(e,u.data):null,m=z(e.name).displayName||e.name,h=pe(me(e.avatarSeed??e.id).color),g=(e,t)=>{let n=e?l.data?.assistants.find(t=>t.id===e):void 0;return n?z(n.name).displayName||n.name:t||i(`assistants.contact.peer.unknown`)},[_,v]=Q.useState(``),[y,b]=Q.useState([]),x=Q.useRef(new Map),C=Q.useRef(new Map),w=Q.useRef(new AbortController);Q.useEffect(()=>{let e=new AbortController;return w.current=e,()=>e.abort()},[e.id,o]);let T=Q.useRef(new Set),[E,D]=Q.useState([]);Q.useEffect(()=>{let e=new Set(y.map(e=>e.url));for(let t of x.current.values())for(let n of t.attachments)e.add(n.url);for(let t of T.current)e.has(t)||URL.revokeObjectURL(t);T.current=e},[y,E]),Q.useEffect(()=>()=>{for(let e of T.current)URL.revokeObjectURL(e)},[]);let[O,k]=Q.useState([]),[A,j]=Q.useState(null),[ee,ne]=Q.useState({open:!1,title:``,content:``}),P=S(e=>e.setImagePreviewOpen),re=M(e=>{(e.image||e.mermaid||e.video)&&(ne(e),P(!0))}),ie=M(e=>{ne(t=>({...t,open:e})),P(e)});Q.useEffect(()=>()=>{P(!1)},[P]),Q.useEffect(()=>{C.current.clear(),x.current.clear(),D([]),k([]),j(null)},[o]);let L=Q.useMemo(()=>Pt(),[]),R=Q.useRef(new Set),V=Q.useRef(new Map),H=Rt(e=>e.setWorking),K=u.data?.messages??gt,ce=Q.useMemo(()=>K.some(e=>e.parts.some(e=>e.type===`card`&&e.cardType===`schedule`&&tn(e))),[K]),de=U(e.id,n&&ce),fe=Q.useMemo(()=>{let e=new Map;for(let t of de.data?.tasks??[]){if(!t.task)continue;let n=e.get(t.projectID);n||(n=new Map,e.set(t.projectID,n)),n.set(t.taskID,t.task)}return e},[de.data]),he=yt(E,e.id),ge=bt(O,e.id),_e=Ct(K,he,e.id,ge).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`&&Jn(e.text)))}),ye=_e.length-1;for(;ye>=0&&Yn(_e[ye]);)--ye;let be=_e.filter((e,t)=>!Yn(e)||t>ye),xe=mn(be),Se=ve(),J=`${o}:${e.id}`,Ce=Q.useRef(null),we=Ce.current,Te=we?.lastID?be.findIndex(e=>Xn(e)===we.lastID):-1,Ee=n&&!Se&&we?.scope===J&&we.ready&&(we.lastID===null||Te>=0);Q.useLayoutEffect(()=>{let e=be.at(-1);Ce.current={scope:J,ready:n&&u.isSuccess,lastID:e?Xn(e):null}});let De=new Date().toDateString(),Oe=i(`common.date.today`),ke=Q.useMemo(()=>hn(a,Oe,new Date(De)),[a,Oe,De]),Y=It(he),Ae=Lt(ge),X=!!(e.working||e.activeContactTurn),je=l.data?.revision??null,Me=ge.reduce((e,t)=>e+t.bubbles.reduce((e,t)=>e+t.text.length,0),0),Ne=new Map(ge.map(e=>[e.turnID,e])),Pe=Q.useRef(!1),Fe=M(async(e=!1)=>{if(!(!n||Pe.current||u.isFetchingPreviousPage||u.isFillingMessageGap)&&!(e&&u.previousPageError)&&!(!u.hasPreviousPage&&!u.hasMessageGap)){Pe.current=!0,Re();try{u.hasMessageGap?await u.retryMessageGap():await u.fetchPreviousPage()}catch{}finally{Pe.current=!1}}}),{scrollRef:Ie,contentRef:Le,preparePrepend:Re,followLatest:ze}=Cn({active:n,assistantID:e.id,contentRevision:`${be[0]?.messageID}:${be.length}:${Me}:${u.isFetchingPreviousPage}:${u.hasPreviousPage}:${u.isFillingMessageGap}`,onLoadEarlier:()=>{Fe(!0)}}),He=Q.useRef(null),Ue=Q.useRef(null),We=Q.useRef(null),Ge=Q.useRef(null),Je=Q.useRef(null),[Ye,Z]=Q.useState(null),Ze=()=>{let e=Ue.current?.querySelector(`[data-assistant-contact-composer-surface]`),t=e?.querySelector(`textarea`);return e&&t?Rn(e,t,!s):null};Q.useLayoutEffect(()=>{let e=We.current;if(!e)return;We.current=null;let t=Array.from(He.current?.querySelectorAll(`[data-message-id]`)??[]).find(t=>t.dataset.messageId===e.messageID)?.querySelector(`[data-assistant-contact-text]`),n=()=>Z(t=>t?.messageID===e.messageID?null:t);if(!t){n();return}Je.current?.(),Je.current=Vn(e.source,t,t,n)}),Q.useEffect(()=>()=>{We.current=null,Je.current?.(),Je.current=null},[n,e.id,o]),Q.useEffect(()=>{j(null),x.current.clear(),C.current.clear(),R.current.clear(),V.current=new Map,D(t=>yt(t,e.id)),k(t=>bt(t,e.id)),ne({open:!1,title:``,content:``}),P(!1)},[e.id,P]),Q.useEffect(()=>{for(let e of K){let t=x.current.get(e.messageID);if(t){for(let e of t.attachments)C.current.delete(`${t.assistantID}:${e.id}`);x.current.delete(e.messageID)}}D(e=>wt(e,K))},[K]),Q.useEffect(()=>{let t=new Set(he.filter(e=>e.status===`sending`).map(e=>e.messageID));k(n=>Ot(n,{assistantID:e.id,activeContactTurn:e.activeContactTurn?{turnID:e.activeContactTurn.turnID,admittedAt:e.activeContactTurn.admittedAt}:null,serverWorking:X,snapshotRevision:je,admissionRevisionByTurnID:V.current,pendingSendTurnIDs:t,messages:K,settledTurnIDs:R.current}))},[e.activeContactTurn,e.id,K,he,X,je]),Q.useEffect(()=>{H(e.id,Y||Ae||X)},[e.id,Ae,Y,X,H]),Q.useEffect(()=>{let t=e.id;return()=>{H(t,!1)}},[e.id,H]);let Qe=M(t=>{if(!(!(`assistantID`in t)||t.assistantID!==e.id)){if(t.type===`contact-turn-start`){R.current.delete(t.turnID),k(e=>Et(e,t.assistantID,t.turnID,t.occurredAt));return}if(t.type===`contact-bubble-delta`){if(R.current.has(t.turnID))return;k(e=>kt(e,t));return}t.type===`contact-turn-end`&&(R.current.add(t.turnID),k(e=>jt(At(e,t,{requireExisting:!0}),K)))}});Q.useEffect(()=>{if(n)return te(Qe)},[n,e.id]);let $e=M(async e=>{if(Y)return;let t=w.current,n=await Gn(e);if(t.signal.aborted){n.attachments.forEach(e=>URL.revokeObjectURL(e.url));return}n.skippedTooLarge>0&&j(i(`assistants.contact.attachment.tooLarge`)),n.attachments.length!==0&&b(e=>Kn(e,n.attachments))}),et=M(e=>{let t=Un(e.clipboardData);t.length!==0&&(e.preventDefault(),$e(t))}),tt=M(e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),nt=M(e=>{let t=Wn(e.dataTransfer);t.length!==0&&(e.preventDefault(),$e(t))}),rt=M(async(t,r)=>{let a=w.current,o=e.id,s=r?x.current.get(r):void 0;if(r&&(!s||s.assistantID!==o))return;let l=s?.text??t??_,u=s?.attachments??y,d=Ft({gate:L,sending:It(he),text:l,attachments:u,assistantID:o,createMessageID:()=>r||`yuri_contact_${p()}`});if(!d.ok)return;H(o,!0),x.current.set(d.messageID,{assistantID:o,text:l,attachments:u});let f=u.length===0&&t===void 0&&!r&&n&&!Se?Ze():null;We.current=f?{messageID:d.messageID,source:f}:null,Z(f?{scope:J,messageID:d.messageID}:null),Ge.current=f?d.messageID:Ge.current,r||(ze(f?{duration:wn,ease:Tn}:void 0),v(e=>e===l?``:e),b(e=>e.filter(e=>!u.includes(e)))),D(e=>e.some(e=>e.messageID===d.messageID)?e.map(e=>e.messageID===d.messageID?{...d.turn,createdAt:e.createdAt}:e):[...e,d.turn]),j(null);let h=()=>{u.forEach(e=>C.current.delete(`${o}:${e.id}`)),x.current.delete(d.messageID)};try{let t=[];for(let e of u){let n=`${o}:${e.id}`,r=C.current.get(n);if(!r){if(r=await qe(o,e.file,e.id,a.signal),a.signal.aborted)return;C.current.set(n,r)}t.push(r)}if(a.signal.aborted)return;let n=[...d.parts.filter(e=>e.type===`text`),...t];D(e=>e.map(e=>e.messageID===d.messageID?{...e,parts:n}:e));let r=await ae(o,d.messageID,{parts:n});if(a.signal.aborted)return;h(),typeof r.revision==`number`&&V.current.set(d.messageID,r.revision),D(e=>Tt(e,d.messageID)),R.current.has(d.messageID)||k(e=>Et(e,o,d.messageID)),c.data?.serverInstanceID&&B({serverInstanceID:c.data.serverInstanceID,assistantID:o,name:m,avatarSeed:e.avatarSeed??o}).catch(()=>void 0)}catch(e){if(a.signal.aborted)return;if(e instanceof G&&e.code===`admission_timeout`)try{let e=await se(o,d.messageID);if(a.signal.aborted)return;if(e){h(),typeof e.revision==`number`&&V.current.set(d.messageID,e.revision),D(e=>Tt(e,d.messageID)),R.current.has(d.messageID)||k(e=>Et(e,o,d.messageID));return}}catch{}let t=Nt(e,{noProvider:i(`assistants.contact.noProvider`),sendFailed:i(`assistants.contact.sendFailed`),timedOut:i(`assistants.contact.timedOut`)});D(e=>Mt(e,d.messageID,t))}finally{L.release()}}),it=M(e=>{rt(void 0,e)}),at=u.isError&&be.length===0,ot=u.isSuccess&&be.length===0,ct=new Map(he.map(e=>[e.messageID,e]));return(0,$.jsxs)(`div`,{ref:He,className:`flex min-h-0 flex-1 flex-col bg-background`,children:[(0,$.jsxs)(`div`,{ref:Ie,className:N(`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 sm:px-8`,s&&`pb-11`,r?`pt-[calc(max(0.625rem,var(--yuri-safe-area-top,0px))+var(--yuri-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,at?(0,$.jsxs)(`div`,{ref:Le,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)(Vt,{name:e.id,avatarSeed:e.avatarSeed,size:44,label:m,working:n?X:void 0,showWorkingDot:!1,followPointer:!1}),(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)(q,{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)(F,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void u.refetch(),children:i(`chat.history.retry`)})]}):ot?(0,$.jsxs)(`div`,{ref:Le,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)(Vt,{name:e.id,avatarSeed:e.avatarSeed,size:48,label:m,className:`opacity-90`,working:n?X:void 0,showWorkingDot:!1,followPointer:!1}),(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:Le,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)(F,{type:`button`,size:`sm`,variant:`ghost`,disabled:u.isFetchingPreviousPage||u.isFillingMessageGap,onClick:()=>void Fe(),children:i(u.isFetchingPreviousPage||u.isFillingMessageGap?`chat.history.loadingMore`:u.previousPageError||u.hasMessageGap?`chat.history.retry`:`chat.history.loadOlder`)})]}):null,be.map((t,r)=>{let a=`${J}:${Xn(t)}`,c=r>0?be[r-1]:null,u=xe.get(t.messageID),d=u!==void 0,p=d?(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(u).toISOString(),className:`text-[11px] font-normal leading-4 tabular-nums text-muted-foreground/70`,children:ke(u)})}):null,_=t.role===`user`,v=t.role===`peer`,y=t.role===`assistant`&&!d&&c?.role===`assistant`&&c.turnID===t.turnID,b=c?.turnID!==t.turnID,x=!_&&(v||!y),S=v?g(t.fromAssistantID,t.fromAssistantName):m,C=v&&t.fromAssistantID?l.data?.assistants.find(e=>e.id===t.fromAssistantID):e,w=ct.get(t.messageID),T=Ne.get(t.turnID),E=t.status===`failed`&&t.messageID.endsWith(`:preview:failed`),D=(e,t)=>_?(0,$.jsx)(ht,{failedTurn:n?w:void 0,retryDisabled:Y,onRetry:it,children:e},t):e;return t.status===`error`||E?(0,$.jsxs)(Q.Fragment,{children:[p,(0,$.jsxs)(`div`,{"data-message-id":t.messageID,"data-assistant-contact-error":``,className:N(`relative px-1`,!d&&`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||T?.error||i(`assistants.contact.sendFailed`)}),f?.messageID===t.messageID?(0,$.jsx)(Xe,{assistantID:e.id,position:f},`${o}:${e.id}:${f.generation}:${f.ordinal}`):null]})]},a):(0,$.jsxs)(Q.Fragment,{children:[p,(0,$.jsxs)(Ke.div,{"data-message-id":t.messageID,initial:Ee&&r>Te&&t.messageID!==Ge.current?{opacity:0,y:4}:!1,animate:{opacity:1,y:0},transition:{duration:Se?0:.18,ease:`easeOut`},className:N(`flex w-full`,_?`justify-end`:`justify-start`,d?`mt-0`:b?`mt-6 first:mt-0`:y?`mt-1.5`:`mt-3`),"data-assistant-contact-role":t.role,"data-assistant-contact-turn-status":w?.status??t.status,"data-assistant-contact-run-start":t.role===`assistant`&&!y?``:void 0,children:[_?null:(0,$.jsx)(`div`,{className:`mr-2.5 flex w-9 shrink-0 justify-center pt-0.5`,children:x?(0,$.jsx)(Vt,{name:C?.id||t.fromAssistantID||e.id,avatarSeed:C?.avatarSeed??(t.fromAssistantID?void 0:e.avatarSeed),size:32,label:S,working:n?!!(C?.working||C?.activeContactTurn):void 0,showWorkingDot:!1,followPointer:!1}):(0,$.jsx)(`span`,{className:`size-8`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:N(`relative flex min-w-0 flex-col gap-1.5`,_?`max-w-[min(82%,30rem)] items-end`:`max-w-[min(84%,34rem)] items-start`),children:[v?(0,$.jsx)(`span`,{className:`mb-0.5 px-1 typography-micro text-muted-foreground/75`,children:i(`assistants.contact.peer.from`,{name:S})}):null,t.parts.map((r,o)=>{if(r.type===`card`&&r.cardType===`session`)return(0,$.jsx)(dn,{card:r},`${a}:card:${o}`);if(r.type===`card`&&r.cardType===`assistant`)return(0,$.jsx)(Zt,{card:r,assistant:l.data?.assistants.find(e=>e.id===r.assistantID),active:n},`${a}:card:${o}`);if(r.type===`card`&&r.cardType===`schedule`)return(0,$.jsx)(on,{card:r,task:fe.get(r.projectID)?.get(r.taskID)},`${a}:card:${o}`);if(r.type===`file`)return D((0,$.jsx)(pt,{assistantID:e.id,part:r,onShowPopup:re},`${a}:file:${o}`),`${a}:file:${o}`);if(r.type===`text`&&Jn(r.text))return null;if(r.type===`text`&&(r.text.trim()||t.status===`streaming`)){let e=!_,n=e&&/^!\[(?:\\.|[^\]\\\n])*\]\(\s*(?:<[^>\n]+>|[^\s()]+)(?:\s+"[^"\n]*")?\s*\)$/.test(r.text.trim());return D((0,$.jsx)(`div`,{"aria-label":v?i(`assistants.contact.peer.aria`,{name:S}):void 0,"data-assistant-contact-text":``,"data-assistant-contact-media":n||void 0,style:_?{backgroundColor:h.background,color:h.foreground}:void 0,className:N(`min-w-0 max-w-full [overflow-wrap:anywhere] rounded-[1.35rem] typography-markdown leading-6`,s&&!n&&`touch-manipulation [-webkit-user-select:all] [user-select:all]`,n?`p-0`:`px-4 py-2.5`,e?null:`whitespace-pre-wrap`,n?`text-foreground`:_?`rounded-[1.15rem] rounded-br-lg`:v?`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)(Be,{content:r.text,messageId:a,isAnimated:!1,isStreaming:t.status===`streaming`,variant:`assistant`,enableFileReferences:!1,onShowPopup:re,className:`w-full min-w-0 [overflow-wrap:anywhere]`}):r.text},`${a}:text:${o}`),`${a}:text:${o}`)}return null}),w?.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,f?.messageID===t.messageID?(0,$.jsx)(Xe,{assistantID:e.id,position:f},`${o}:${e.id}:${f.generation}:${f.ordinal}`):null]})]})]},a)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 left-[2.875rem] flex h-10 items-center`,"data-assistant-contact-status-slot":``,children:!Y&&Ye?.scope!==J&&(Ae||X)?(0,$.jsxs)(Ke.div,{role:`status`,"aria-label":i(`assistants.contact.processing`),initial:!Se&&{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:Se?0:.18,ease:`easeOut`},className:`relative inline-flex h-9 origin-bottom-left items-center gap-1 rounded-[1.35rem] bg-[var(--surface-muted)] px-4 text-muted-foreground/70`,"data-assistant-contact-processing":``,children:[(0,$.jsx)(`div`,{className:`absolute -left-[2.875rem] top-0.5 flex w-9 justify-center`,"data-assistant-contact-processing-avatar":``,children:(0,$.jsx)(Vt,{name:e.id,avatarSeed:e.avatarSeed,size:32,label:m,working:n?X:void 0,showWorkingDot:!1,followPointer:!1})}),(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`,{ref:Ue,className:`relative z-10 shrink-0 bg-background pt-1`,"data-assistant-contact-composer":``,children:[A?(0,$.jsx)(`div`,{className:`chat-input-column mb-2`,children:(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:A})}):null,(0,$.jsx)(`form`,{className:N(`relative w-full pt-1.5 pb-4`,s&&`bottom-safe-area yuri-mobile-composer`),onSubmit:e=>{e.preventDefault(),rt()},onDragOver:tt,onDrop:nt,children:(0,$.jsx)(`div`,{className:`chat-input-column relative overflow-visible`,children:(0,$.jsx)(st,{active:n,layout:`inline`,value:_,attachments:y,pending:Y,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=>v(e),onVoiceSend:e=>{rt(e)},onSubmit:()=>{rt()},onAddFiles:e=>{$e(e)},onRemoveAttachment:t=>{Y||(C.current.delete(`${e.id}:${t}`),b(e=>e.filter(e=>e.id!==t)))},onPaste:et,onDragOver:tt,onDrop:nt,className:N(`relative z-10`,s&&`yuri-mobile-composer-surface`),style:{borderRadius:`1.5rem`},"data-assistant-contact-composer-surface":``,textareaProps:{"aria-label":i(`assistants.contact.placeholder`,{name:m})}},`${o}:${e.id}`)})})]}),ee.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(qn,{popup:ee,onOpenChange:ie,isMobile:s})}):null]})},Qn=e=>{for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n.parts.some(H)&&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}},$n=(e,t)=>{let n=(0,Z.c)(5),r;n[0]!==e||n[1]!==t?(r=K(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:Qn},n[3]=r,n[4]=i),w(i)},er=Q.memo(e=>{let t=(0,Z.c)(17),{assistantID:n,serverWorking:r,lastContactAt:i}=e,{t:a,locale:o}=I(),s=Bt(n,r),c=$n(n,Ve()),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=hn(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});export{Bt as a,Vt as i,Zn as n,Ut as r,er as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ot as e}from"./vendor-base-ui-CzHs0bHY.js";import{n as t}from"./vendor-react-DlzBev0S.js";import{Jn as n,Va as r}from"./useMobileNavigationStore-ywElU2fl.js";import{y as i}from"./MobileDetailNavigation-UU1cGYp2.js";function a(e){return[...e].sort((e,t)=>{let n=e.latestMessagePreview?.createdAt??-1/0,r=t.latestMessagePreview?.createdAt??-1/0;return n===r?0:r-n})}function o(e){let t;for(let n of e)n.pinnedAt!=null&&(!t||n.pinnedAt>t.pinnedAt)&&(t=n);return{pinned:t?[t]:[],unpinned:a(e.filter(e=>e!==t))}}var s=t(),c=e();function l(e){let t=(0,s.c)(10),{count:i,className:a}=e,{t:o}=r();if(!(i>0))return null;let l;t[0]===a?l=t[1]:(l=n(`inline-flex h-[18px] min-w-[18px] shrink-0 items-center justify-center rounded-full bg-[var(--status-info)] px-1.5 typography-micro font-semibold leading-none text-[var(--status-info-foreground)] tabular-nums shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--status-info-foreground)_15%,transparent)]`,a),t[0]=a,t[1]=l);let u;t[2]!==i||t[3]!==o?(u=o(`assistants.unread.label`,{count:i}),t[2]=i,t[3]=o,t[4]=u):u=t[4];let d=i>99?`99+`:i,f;return t[5]!==i||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,c.jsx)(`span`,{className:l,"aria-label":u,"data-assistant-unread-count":i,children:d}),t[5]=i,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function u(e){let t=(0,s.c)(3),{className:n}=e,r=i(),a;return t[0]!==n||t[1]!==r?(a=(0,c.jsx)(l,{count:r,className:n}),t[0]=n,t[1]=r,t[2]=a):a=t[2],a}export{a as i,l as n,o as r,u as t};
|