@yuriai/web 0.3.2-beta.7 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-Dy2D4-W_.js → AgentAvatar-DmvbnnMh.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-BZwQoBD0.js → AssistantConversationSurface-DxmQrzax.js} +3 -3
- package/dist/assets/{AssistantSessionCard-Cb5O68ez.js → AssistantSessionCard-CsZIdhOH.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-Dv9HXPrS.js → AssistantUnreadBadge-0K84uUof.js} +1 -1
- package/dist/assets/{AssistantView-3fIzHGoU.js → AssistantView-eo7zU0tW.js} +1 -1
- package/dist/assets/{DiagramView-zlrPK3wP.js → DiagramView-CwgPnPU8.js} +1 -1
- package/dist/assets/{FadeInOnReveal-Cb2cgQyM.js → FadeInOnReveal-CIabuv8E.js} +1 -1
- package/dist/assets/{GuiPluginPage-DX446Fgg.js → GuiPluginPage-CBWlpM7-.js} +1 -1
- package/dist/assets/{GuiPluginSurface-C34vXd2R.js → GuiPluginSurface-4piMFmC2.js} +1 -1
- package/dist/assets/{GuiPluginWindow-BUM2P90L.js → GuiPluginWindow-D02tLdop.js} +1 -1
- package/dist/assets/{Icon-o1bRhUil.js → Icon-Br-W35tz.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BS9Swwfz.js → ImageLoadingPlaceholder-EHe_20yz.js} +1 -1
- package/dist/assets/{LoadingImage-DDafrpn6.js → LoadingImage-DNt-_HCJ.js} +1 -1
- package/dist/assets/MarkdownRenderer-BjRyxBUx.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-BWmWJyQD.js → MarkdownRendererImpl-CxfAdy1l.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-MwrM60DK.js → MarkstreamRendererImpl-B1ALcl04.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CS3FdXMF.js → MobileDetailNavigation-DNLOs1n6.js} +1 -1
- package/dist/assets/MobileResizableSheet-Bp_8Cf4j.js +1 -0
- package/dist/assets/{MobileShareBridge-C7SsPeA-.js → MobileShareBridge-9zfdEyQ_.js} +1 -1
- package/dist/assets/{MobileSurface-BkMJ0lqS.js → MobileSurface-B1O-lCca.js} +1 -1
- package/dist/assets/{MultiRunWindow-BkVFZYQl.js → MultiRunWindow-DMvB8O02.js} +1 -1
- package/dist/assets/{OnboardingScreen-EMj1BesS.js → OnboardingScreen-DgxRaKDc.js} +1 -1
- package/dist/assets/{OverlayScrollbar-mTdNvI2t.js → OverlayScrollbar-CcX4ZP8W.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-CNBayb0p.js → RemoteAssistantSessionCard-BJz_SKef.js} +1 -1
- package/dist/assets/{SettingsView-BkXX1yqx.js → SettingsView-D7Kb5iGY.js} +3 -3
- package/dist/assets/{SettingsWindow-DEVIOawn.js → SettingsWindow-YzVAr8Bo.js} +1 -1
- package/dist/assets/{SetupTourDialog-DpDXKEev.js → SetupTourDialog-Dw9q3oII.js} +1 -1
- package/dist/assets/{TerminalView-BwZd8np-.js → TerminalView-DZChxb-F.js} +1 -1
- package/dist/assets/{ToolOutputDialog-C7FT1uPc.js → ToolOutputDialog-2F74CchZ.js} +1 -1
- package/dist/assets/{VoiceSettings-BrAyJv-I.js → VoiceSettings-CJh5q7QP.js} +1 -1
- package/dist/assets/{YuriLogo-DNvrroBa.js → YuriLogo-BKdnDJwl.js} +1 -1
- package/dist/assets/{YuriWordmark-bJX68f2Y.js → YuriWordmark-D2e-o9nW.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-zu9sz4ex.js → assistant-attachment-cache-BYvIyn1x.js} +1 -1
- package/dist/assets/{capgoAdapter-CPyV4o5H.js → capgoAdapter-Q9jzJN69.js} +1 -1
- package/dist/assets/{checkbox-BcJaF7Fw.js → checkbox-CqeGKP3Z.js} +1 -1
- package/dist/assets/{client-CgAFd1ew.js → client-CzjApAA4.js} +4 -4
- package/dist/assets/{collapsible-ChjJre3f.js → collapsible-BSOetNHq.js} +1 -1
- package/dist/assets/{context-menu-BRBPOV2F.js → context-menu-r_DjszgU.js} +1 -1
- package/dist/assets/{desktopHosts-135cuRCE.js → desktopHosts-BsTrBVja.js} +1 -1
- package/dist/assets/{desktopRelayRestore-1aUztDPU.js → desktopRelayRestore-BxbRKak_.js} +1 -1
- package/dist/assets/{device-C8ZHblkr.js → device-BlmHHWT1.js} +1 -1
- package/dist/assets/{diagram-BhOF-6FQ.js → diagram-CxwT-HHn.js} +1 -1
- package/dist/assets/{dialog-BSyXr9ua.js → dialog-rXqw-6ab.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-DSXpR_Hq.js → fileMentionTouchSelection-C0O4_Efn.js} +1 -1
- package/dist/assets/{fileReferenceActions-DX-Stroq.js → fileReferenceActions-DLTUzjwi.js} +1 -1
- package/dist/assets/{gitApi--F7MdPg9.js → gitApi-BA93t0ww.js} +1 -1
- package/dist/assets/gitApiHttp-BgUDBfaJ.js +3 -0
- package/dist/assets/{gui-BMN3-WPc.js → gui-KxRdG4j0.js} +1 -1
- package/dist/assets/{historyImportQueries-eR7Bj6VN.js → historyImportQueries-DiGQ8duS.js} +1 -1
- package/dist/assets/{host-iM7aLAip.js → host-BBp7NPZz.js} +1 -1
- package/dist/assets/{i18n-OsFhnlRH.js → i18n-BvjeIWrT.js} +1 -1
- package/dist/assets/{image-loading-ZB1bYt51.js → image-loading-Dlh4FIPJ.js} +1 -1
- package/dist/assets/{input-Daki_y8O.js → input-9Y3tNEd9.js} +1 -1
- package/dist/assets/{input-store-DRTu4uZc.js → input-store-wWToFdzi.js} +1 -1
- package/dist/assets/{insertionBoundaries-CnhjXWsd.js → insertionBoundaries-Dl5RMmA3.js} +1 -1
- package/dist/assets/main-Cli25Koo.js +169 -0
- package/dist/assets/{main-CALE45ey.js → main-Dj1N_rUJ.js} +2 -2
- package/dist/assets/{markdownHeightCache-Dn_Jkp0n.js → markdownHeightCache-CaBnqn2C.js} +1 -1
- package/dist/assets/{mcpQueries-DB6aJ5RI.js → mcpQueries-DCgOzZ7g.js} +1 -1
- package/dist/assets/miniChat-Ct0NeLs3.js +2 -0
- package/dist/assets/mobile-Kg6aWex1.js +2 -0
- package/dist/assets/{mobileBackNavigation-CeY46TEx.js → mobileBackNavigation-XjzoONfU.js} +1 -1
- package/dist/assets/{mobileConnections-BjLYzK32.js → mobileConnections-plT2Z1fc.js} +2 -2
- package/dist/assets/{multirun-DV_l3huB.js → multirun-1YatqupB.js} +1 -1
- package/dist/assets/{native-config-CaDwggks.js → native-config-C0CpO-0Q.js} +1 -1
- package/dist/assets/{navigation-BjCFktgT.js → navigation-Bz_aROXw.js} +2 -2
- package/dist/assets/{openRemoteProjectSession-C3jFz6kb.js → openRemoteProjectSession-9kfNj2Jy.js} +1 -1
- package/dist/assets/{platform-wF65ZFgV.js → platform-CiUKDeXd.js} +1 -1
- package/dist/assets/{project-preview-BhNspxqe.js → project-preview-BjTq299L.js} +1 -1
- package/dist/assets/{projectActions-50e_f9dI.js → projectActions-BPmI9_mW.js} +1 -1
- package/dist/assets/{projectMeta-CwdDc3V4.js → projectMeta-CBxwAjHm.js} +1 -1
- package/dist/assets/{prompt-attachment-upload-8bssUUT3.js → prompt-attachment-upload-Bem87nmm.js} +1 -1
- package/dist/assets/{pwa-QoTHytgl.js → pwa-1EqcEjis.js} +2 -2
- package/dist/assets/qoder-zGvP_RLr.svg +5 -0
- package/dist/assets/queue-abort-optimistic-C6AsLSmI.js +1 -0
- package/dist/assets/{react-ChbBD2fG.js → react-B_qpic0Y.js} +1 -1
- package/dist/assets/readiness-DcOz5lOE.js +2 -0
- package/dist/assets/{reference-history-BBLJypsd.js → reference-history-DOMZlJml.js} +1 -1
- package/dist/assets/{remote-input-store-DFBMyVS-.js → remote-input-store-BvlOGMu_.js} +1 -1
- package/dist/assets/{remoteProjectQueries-8giIAvzL.js → remoteProjectQueries-yX3kOkR6.js} +1 -1
- package/dist/assets/{remoteSessionReference-BHBerOUy.js → remoteSessionReference-Cn7Wzrg6.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-Yryt2r9g.js → renderElectronMiniChatApp-B-hPtyBl.js} +2 -2
- package/dist/assets/renderMobileApp-CuOXMDN3.js +29 -0
- package/dist/assets/{runtime-auth-mjIpsk3N.js → runtime-auth-DA-qfGHk.js} +1 -1
- package/dist/assets/{runtime-fetch-DKZOpfzo.js → runtime-fetch-V-iMWR8t.js} +1 -1
- package/dist/assets/{runtime-file-download-Dc459c9e.js → runtime-file-download-DxL4XbME.js} +1 -1
- package/dist/assets/{runtime-file-resource-DnhWnndu.js → runtime-file-resource-CKQQEwNv.js} +1 -1
- package/dist/assets/{runtime-switch-BMjl5Y5W.js → runtime-switch-DEPKHgdL.js} +1 -1
- package/dist/assets/{runtimeConfig-CsJ6iub-.js → runtimeConfig-C1A5pejN.js} +1 -1
- package/dist/assets/runtimeEndpointReset-oiLvIGYI.js +151 -0
- package/dist/assets/{scheduledTaskNavigation-Bi7sRiFW.js → scheduledTaskNavigation-CdBHn9ti.js} +1 -1
- package/dist/assets/{select-D_jd65HO.js → select-CK1DjdEi.js} +1 -1
- package/dist/assets/{sessionLookup-BUyzfxAJ.js → sessionLookup-CmckqEe_.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DMwkOrM-.js → sortable-tabs-strip-Bd9uV_sY.js} +1 -1
- package/dist/assets/{speechSettingsQueries-CJ3jPRqV.js → speechSettingsQueries-BHZs2Dyf.js} +1 -1
- package/dist/assets/src-aLILBedG.css +2 -0
- package/dist/assets/{terminalApi-eR_918UZ.js → terminalApi-CwTOFYhX.js} +1 -1
- package/dist/assets/{textarea-DwisQCE_.js → textarea-DvCd0eUo.js} +1 -1
- package/dist/assets/{tooltip-DloXgI9f.js → tooltip-B93KmoPh.js} +1 -1
- package/dist/assets/types-ClAbMq1_.js +2 -0
- package/dist/assets/{useAppFontEffects-zienz2u_.js → useAppFontEffects-EXiDcoNt.js} +62 -62
- package/dist/assets/{useAssistantUIStore-CphyXHEY.js → useAssistantUIStore-CI42fWZh.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-VfqGsgdB.js → useDesktopWindowControlsLayout-4TLDMOLv.js} +1 -1
- package/dist/assets/{useDictation-Do12BpsS.js → useDictation-OLmxagFb.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DtDqspBR.js → useEffectiveDirectory-DFe0GivQ.js} +1 -1
- package/dist/assets/{useFontPreferences-DFF-uEAD.js → useFontPreferences-DN1mCOsX.js} +1 -1
- package/dist/assets/{useMobileHtmlPreviewStore-DUquFMmd.js → useMobileHtmlPreviewStore-DzzgY1eS.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BkVbj6Lg.js → useMobileNavigationStore-BtHQN423.js} +12 -12
- package/dist/assets/{usePluginsStore-BRtWcKUj.js → usePluginsStore-Ch1DaoBM.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-BbjZTtP4.js → useProjectRuntimeAPIs-CnTyVRex.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-DMhoKnTy.js → useStreamingTextThrottle-DAr0FPKI.js} +1 -1
- package/dist/assets/{useUIStore-CYex4rbF.js → useUIStore-DjizmHAt.js} +1 -1
- package/dist/index.html +20 -20
- package/dist/mini-chat.html +20 -20
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/gui-network/DOCUMENTATION.md +9 -1
- package/server/lib/realtime-proxy.js +4 -2
- package/server/lib/realtime-proxy.test.js +5 -4
- package/server/lib/relay/tunnel-host.js +15 -5
- package/server/lib/relay/tunnel-host.test.js +24 -0
- package/server/lib/remote-hosts/DOCUMENTATION.md +15 -2
- package/server/lib/remote-hosts/gateway.js +14 -4
- package/server/lib/remote-hosts/routes.js +9 -1
- package/server/lib/remote-hosts/routes.test.js +137 -7
- package/server/lib/remote-hosts/transport.js +1 -1
- package/server/lib/session-index/DOCUMENTATION.md +3 -0
- package/server/lib/session-index/service.js +4 -4
- package/server/lib/ui-auth/ui-auth.js +1 -1
- package/server/lib/ui-auth/ui-auth.test.js +3 -0
- package/dist/assets/MarkdownRenderer-BOLzT07h.js +0 -2
- package/dist/assets/MobileResizableSheet-Dkx27OGR.js +0 -1
- package/dist/assets/gitApiHttp-BEMPJCIG.js +0 -3
- package/dist/assets/main-DEQdAD0s.js +0 -169
- package/dist/assets/miniChat-VUMSA5V6.js +0 -2
- package/dist/assets/mobile-CiuyBKXM.js +0 -2
- package/dist/assets/queue-abort-optimistic-Bvno7WIB.js +0 -1
- package/dist/assets/readiness-C9buUgS7.js +0 -2
- package/dist/assets/renderMobileApp-f7DiCkl1.js +0 -29
- package/dist/assets/runtimeEndpointReset-CWAGENV5.js +0 -151
- package/dist/assets/src-DRyZ4dLj.css +0 -2
- package/dist/assets/types-sn47BK8u.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from '
|
|
1
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import http from 'node:http';
|
|
4
4
|
import { WebSocket, WebSocketServer } from 'ws';
|
|
@@ -190,7 +190,7 @@ describe('realtime proxy', () => {
|
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
it('
|
|
193
|
+
it.each(['/api/global/event/ws', '/api/gui-network/ws', '/api/hosts/remote-a/api/gui-network/ws'])('proxies %s with runtime headers and target Origin', async pathname => {
|
|
194
194
|
let upstreamRequest = null;
|
|
195
195
|
const upstreamServer = http.createServer();
|
|
196
196
|
const upstreamWs = new WebSocketServer({ server: upstreamServer });
|
|
@@ -204,7 +204,7 @@ describe('realtime proxy', () => {
|
|
|
204
204
|
const { origin, runtime } = await startProxyServer({ apiBaseUrl: upstreamOrigin });
|
|
205
205
|
|
|
206
206
|
try {
|
|
207
|
-
const target = `${upstreamOrigin.replace(/^http:/, 'ws:')}
|
|
207
|
+
const target = `${upstreamOrigin.replace(/^http:/, 'ws:')}${pathname}?lastEventId=evt-1`;
|
|
208
208
|
const client = new WebSocket(buildRealtimeProxyWsUrl(origin, target), {
|
|
209
209
|
headers: { Origin: 'yuri-ui://app' },
|
|
210
210
|
});
|
|
@@ -219,8 +219,9 @@ describe('realtime proxy', () => {
|
|
|
219
219
|
});
|
|
220
220
|
|
|
221
221
|
expect(message).toBe('echo:ping');
|
|
222
|
-
expect(upstreamRequest?.url).toBe(
|
|
222
|
+
expect(upstreamRequest?.url).toBe(`${pathname}?lastEventId=evt-1`);
|
|
223
223
|
expect(upstreamRequest?.headers['x-proxy-auth']).toBe('secret');
|
|
224
|
+
expect(upstreamRequest?.headers.origin).toBe(upstreamOrigin);
|
|
224
225
|
client.close();
|
|
225
226
|
upstreamWs.close();
|
|
226
227
|
} finally {
|
|
@@ -28,6 +28,8 @@ const isAllowedHttpPath = (pathname) =>
|
|
|
28
28
|
|| pathname === '/auth'
|
|
29
29
|
|| pathname.startsWith('/auth/');
|
|
30
30
|
|
|
31
|
+
const PREVIEW_TARGETS_PATH = /^\/api\/preview\/targets(?:\/[^/]+)?\/?$/;
|
|
32
|
+
|
|
31
33
|
const ALLOWED_WS_PATHS = new Set([
|
|
32
34
|
'/api/global/event/ws',
|
|
33
35
|
'/api/event/ws',
|
|
@@ -49,7 +51,7 @@ const PREVIEW_PROXY_WS_PATH_PREFIX = '/api/preview/proxy/';
|
|
|
49
51
|
*/
|
|
50
52
|
export const isTunnelWsPathAllowed = (path) => {
|
|
51
53
|
if (typeof path !== 'string' || !path) return false;
|
|
52
|
-
if (/^\/api\/hosts\/[^/]+\/api\/(?:terminal\/ws(?:\?|$)|preview\/proxy\/)/.test(path)) return true;
|
|
54
|
+
if (/^\/api\/hosts\/[^/]+\/api\/(?:(?:terminal|gui-network)\/ws(?:\?|$)|preview\/proxy\/)/.test(path)) return true;
|
|
53
55
|
// Path only (no query) — tunnel open payload already splits query.
|
|
54
56
|
if (ALLOWED_WS_PATHS.has(path)) return true;
|
|
55
57
|
try {
|
|
@@ -191,7 +193,7 @@ export const createTunnelHost = ({
|
|
|
191
193
|
// HTTP
|
|
192
194
|
// -------------------------------------------------------------------------
|
|
193
195
|
|
|
194
|
-
const buildRequestHeaders = (rawHeaders) => {
|
|
196
|
+
const buildRequestHeaders = (rawHeaders, path = '') => {
|
|
195
197
|
const headers = {};
|
|
196
198
|
for (const [name, value] of Object.entries(rawHeaders)) {
|
|
197
199
|
if (typeof name !== 'string' || typeof value !== 'string') continue;
|
|
@@ -201,6 +203,13 @@ export const createTunnelHost = ({
|
|
|
201
203
|
headers[lower] = value;
|
|
202
204
|
}
|
|
203
205
|
headers['x-yuri-relay-connection'] = connectionId;
|
|
206
|
+
// Tunneled renderer fetches cannot set Origin (forbidden header), but the
|
|
207
|
+
// preview target routes require an allowed Origin. Present the loopback
|
|
208
|
+
// origin we dial, as the WS path does; scoped to these routes only so other
|
|
209
|
+
// same-origin checks keep treating tunneled requests as origin-less.
|
|
210
|
+
if (!headers.origin && PREVIEW_TARGETS_PATH.test(path)) {
|
|
211
|
+
headers.origin = `http://127.0.0.1:${getLocalPort()}`;
|
|
212
|
+
}
|
|
204
213
|
return headers;
|
|
205
214
|
};
|
|
206
215
|
|
|
@@ -245,7 +254,7 @@ export const createTunnelHost = ({
|
|
|
245
254
|
try {
|
|
246
255
|
response = await fetch(url, {
|
|
247
256
|
method,
|
|
248
|
-
headers: buildRequestHeaders(request.headers),
|
|
257
|
+
headers: buildRequestHeaders(request.headers, request.path),
|
|
249
258
|
body: requestBody,
|
|
250
259
|
duplex: hasBody ? 'half' : undefined,
|
|
251
260
|
signal: stream.abort.signal,
|
|
@@ -404,7 +413,8 @@ export const createTunnelHost = ({
|
|
|
404
413
|
for (const frame of encodeFragmentedMessage(frameType, streamId, bytes)) {
|
|
405
414
|
await waitForBackpressure(null);
|
|
406
415
|
if (streams.get(streamId) !== stream || closed) return;
|
|
407
|
-
await send(frame, open.path === '/api/remote-desktop/ws' || open.path === '/api/gui-network/ws'
|
|
416
|
+
await send(frame, open.path === '/api/remote-desktop/ws' || open.path === '/api/gui-network/ws'
|
|
417
|
+
|| /^\/api\/hosts\/[^/]+\/api\/gui-network\/ws$/.test(open.path));
|
|
408
418
|
}
|
|
409
419
|
});
|
|
410
420
|
});
|
|
@@ -480,7 +490,7 @@ export const createTunnelHost = ({
|
|
|
480
490
|
url: `${request.path}${request.query ? `?${request.query}` : ''}`,
|
|
481
491
|
headers: websocket
|
|
482
492
|
? { upgrade: 'websocket', 'x-yuri-relay-connection': connectionId }
|
|
483
|
-
: buildRequestHeaders(request.headers),
|
|
493
|
+
: buildRequestHeaders(request.headers, request.path),
|
|
484
494
|
}) === true;
|
|
485
495
|
} catch {
|
|
486
496
|
authorized = false;
|
|
@@ -43,6 +43,30 @@ describe('relay admission before loopback access', () => {
|
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
describe('tunneled HTTP Origin for preview target routes', () => {
|
|
47
|
+
const origins = async (method, path, headers = {}) => {
|
|
48
|
+
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(new Response('{}'));
|
|
49
|
+
const frames = [];
|
|
50
|
+
const host = createTunnelHost({ authorizeRequest: async () => true, connectionId: 'origin-test', getLocalPort: () => 4321,
|
|
51
|
+
sendFrame: (frame) => { frames.push(decodeTunnelFrame(frame)); }, getBufferedAmount: () => 0 });
|
|
52
|
+
try {
|
|
53
|
+
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.HttpRequest, 1, encodeJsonPayload({ method, path, query: '', headers })));
|
|
54
|
+
await waitFor(() => frames.some((frame) => frame.frameType === TunnelFrameType.StreamEnd));
|
|
55
|
+
return fetchMock.mock.calls[0][1].headers.origin;
|
|
56
|
+
} finally { host.close(); fetchMock.mockRestore(); }
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
it('presents the dialed loopback origin for preview target registration', async () => {
|
|
60
|
+
expect(await origins('POST', '/api/preview/targets')).toBe('http://127.0.0.1:4321');
|
|
61
|
+
expect(await origins('DELETE', '/api/preview/targets/abc123')).toBe('http://127.0.0.1:4321');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('leaves other routes origin-less and keeps an explicit origin', async () => {
|
|
65
|
+
expect(await origins('POST', '/api/system/dev-shutdown')).toBeUndefined();
|
|
66
|
+
expect(await origins('POST', '/api/preview/targets', { origin: 'yuri-ui://app' })).toBe('yuri-ui://app');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
46
70
|
/** Minimal EventEmitter-shaped fake used only by createTunnelHost tests. */
|
|
47
71
|
class FakeWebSocket {
|
|
48
72
|
static OPEN = 1;
|
|
@@ -59,6 +59,13 @@ task status callbacks.
|
|
|
59
59
|
the existing session-index service and its newest-20 directory bound. Each
|
|
60
60
|
partition hashes `hub:<stable Hub ID>:remote-host:<host ID>`; no mutable local
|
|
61
61
|
runtime endpoint or local filesystem resolution participates.
|
|
62
|
+
Remote pin membership also belongs to this Hub partition. Existing persisted
|
|
63
|
+
pins are retained; refresh never imports or clears pins from a Host snapshot.
|
|
64
|
+
`POST`/`DELETE /api/hosts/:hostId/api/yuri/session-index/session/:id/pin`
|
|
65
|
+
terminate on the Hub before the generic proxy, use the existing index DB and
|
|
66
|
+
emit the existing host-scoped index-change tip. Unpin is idempotent, requires no
|
|
67
|
+
remote connection, and cannot modify the same session ID on another Host.
|
|
68
|
+
The target-instance fence and aggregate client authorization still apply.
|
|
62
69
|
- `transport.js` owns authenticated direct/SSH-forwarded requests and reuses the
|
|
63
70
|
normative E2EE Relay client. `build:remote-host-relay` compiles that client once;
|
|
64
71
|
normal web build/prepack and `build:llm-bridge` include the build. The generated
|
|
@@ -185,7 +192,8 @@ short reads in `finally` and retain background watch demand until settlement.
|
|
|
185
192
|
`x-yuri-mime` and `x-yuri-filename` along with their original body bytes; size
|
|
186
193
|
and digest validation still execute on the Remote. These allowlisted metadata
|
|
187
194
|
headers never replace Remote authentication or forward Hub credentials.
|
|
188
|
-
- `/api/hosts/:hostId/api/terminal/ws
|
|
195
|
+
- `/api/hosts/:hostId/api/terminal/ws`, `/api/hosts/:hostId/api/gui-network/ws`
|
|
196
|
+
and `/api/hosts/:hostId/api/preview/proxy/*`
|
|
189
197
|
mount real upgrades, mirrored in Relay and URL-token allowlists. Host removal
|
|
190
198
|
closes direct sockets and Relay substreams, including pending handshakes.
|
|
191
199
|
Client revocation tracks the raw upgrade socket before waiting for the upstream;
|
|
@@ -198,7 +206,12 @@ short reads in `finally` and retain background watch demand until settlement.
|
|
|
198
206
|
authorization check and client upgrade. Overflow fails the upgrade and closes
|
|
199
207
|
the upstream; revocation, socket closure and failure discard the queue.
|
|
200
208
|
Direct and E2EE Relay use the same admission path. No greeting is synthesized
|
|
201
|
-
|
|
209
|
+
and no terminal handshake timeout is extended to conceal missing frames.
|
|
210
|
+
GUI TCP routes reuse the same credential, Origin and revocation gates for
|
|
211
|
+
Browser sessions belonging to a Remote Project. Direct server-to-server
|
|
212
|
+
upgrades set Origin to the admitted target's origin, never the Hub page's
|
|
213
|
+
origin. Hub URL tokens are stripped; the Remote transport supplies its own
|
|
214
|
+
saved credential. This does not open generic GUI-network HTTP forwarding.
|
|
202
215
|
|
|
203
216
|
The target-side local authority is `GET/POST /api/projects` and `PATCH
|
|
204
217
|
/api/projects/:id`. It only returns local projects. Authenticated
|
|
@@ -358,10 +358,8 @@ export function createRemoteHostGateway({ store, indexDbPath, adapter, broadcast
|
|
|
358
358
|
if (status?.type) service.updateStatus(session.id, status.type, status.changedAt || Date.now());
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
for (const pin of previousPins) if (!pins.has(pin)) service.clearPinned(pin);
|
|
364
|
-
for (const pin of pins) service.setPinned(pin);
|
|
361
|
+
// Pins belong to this Hub's existing host-partitioned index. Remote
|
|
362
|
+
// snapshots must not overwrite a user's pin or resurrect a cleared pin.
|
|
365
363
|
const remote = await json(connection.host.id, '/api/projects', { signal: controller.signal }, { refresh: true });
|
|
366
364
|
if (!Array.isArray(remote.projects) || !current(connection) || controller.signal.aborted) return;
|
|
367
365
|
for (const reference of references) {
|
|
@@ -658,6 +656,18 @@ export function createRemoteHostGateway({ store, indexDbPath, adapter, broadcast
|
|
|
658
656
|
...(!adapter ? { reason: 'pc_hub_required' } : {}) };
|
|
659
657
|
},
|
|
660
658
|
async connect(id) { const connection = await ensure(id); startStatus(connection); return hostView(connection.host); },
|
|
659
|
+
setSessionPinned(id, sessionId, pinned, instanceId) {
|
|
660
|
+
if (stopped) throw remoteFailure('host_unavailable', 404);
|
|
661
|
+
if (!store.projects(id).length) throw remoteFailure('project_not_found', 404);
|
|
662
|
+
if (instanceId !== undefined && instanceId !== store.instanceFor(id)) throw remoteFailure('remote_instance_mismatch', 409);
|
|
663
|
+
if (typeof sessionId !== 'string' || !sessionId.trim() || sessionId.length > 512 || /[\u0000-\u001f]/.test(sessionId)) {
|
|
664
|
+
throw remoteFailure('validation_error', 400);
|
|
665
|
+
}
|
|
666
|
+
const service = indexFor(id);
|
|
667
|
+
if (pinned) service.setPinned(sessionId.trim());
|
|
668
|
+
else service.clearPinned(sessionId.trim());
|
|
669
|
+
emit(id, { type: 'yuri:session-index-changed', properties: { cause: 'change' } });
|
|
670
|
+
},
|
|
661
671
|
summaries(id) {
|
|
662
672
|
if (stopped) throw remoteFailure('host_unavailable', 404);
|
|
663
673
|
const references = new Set(store.projects(id).map((p) => directoryKey(p.path)));
|
|
@@ -10,7 +10,7 @@ import { projectRemoteConfiguration } from './configuration.js';
|
|
|
10
10
|
import { RUNTIME_CONTRACT_MIN_VERIFIED } from '../opencode/runtime-contract.js';
|
|
11
11
|
import { parseFilePreviewPath, replaceFilePreviewUrlAuthToken } from '../preview/file-preview-path.js';
|
|
12
12
|
|
|
13
|
-
const websocketPath = (path) => path === '/api/terminal/ws' || path.startsWith('/api/preview/proxy/');
|
|
13
|
+
const websocketPath = (path) => path === '/api/terminal/ws' || path === '/api/gui-network/ws' || path.startsWith('/api/preview/proxy/');
|
|
14
14
|
const safeRoute = (route, method) => {
|
|
15
15
|
if (!route.startsWith('/api/') || /[\\\r\n]/.test(route)) return false;
|
|
16
16
|
const pathname = new URL(route, 'http://remote.invalid').pathname;
|
|
@@ -224,6 +224,14 @@ export function registerRemoteHostRoutes(app, { gateway, getAuth, server, isRequ
|
|
|
224
224
|
app.get('/api/hosts/:hostId/summaries', (req, res) => {
|
|
225
225
|
try { res.json(gateway.summaries(req.params.hostId)); } catch (error) { report(res, error); }
|
|
226
226
|
});
|
|
227
|
+
for (const method of ['post', 'delete']) {
|
|
228
|
+
app[method]('/api/hosts/:hostId/api/yuri/session-index/session/:id/pin', (req, res) => {
|
|
229
|
+
try {
|
|
230
|
+
gateway.setSessionPinned(req.params.hostId, req.params.id, method === 'post', req.get('x-yuri-target-instance') || undefined);
|
|
231
|
+
res.status(204).end();
|
|
232
|
+
} catch (error) { report(res, error); }
|
|
233
|
+
});
|
|
234
|
+
}
|
|
227
235
|
app.post('/api/hosts/:hostId/connect', async (req, res) => {
|
|
228
236
|
try { res.json({ host: await gateway.connect(req.params.hostId) }); } catch (error) { report(res, error); }
|
|
229
237
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import http from 'node:http';
|
|
4
|
+
import net from 'node:net';
|
|
4
5
|
import fs from 'node:fs/promises';
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
import os from 'node:os';
|
|
@@ -19,6 +20,7 @@ import { createRemoteClientAuthRuntime } from '../client-auth/remote-clients.js'
|
|
|
19
20
|
import { createGlobalUiEventBroadcaster } from '../event-stream/runtime.js';
|
|
20
21
|
import { createRemoteHostStore } from './store.js';
|
|
21
22
|
import { createRemoteHostGateway } from './gateway.js';
|
|
23
|
+
import { createSessionIndexService } from '../session-index/service.js';
|
|
22
24
|
import { registerRemoteHostRoutes } from './routes.js';
|
|
23
25
|
import { registerTranscriptCacheRoutes } from '../transcript-cache/routes.js';
|
|
24
26
|
import { registerFsRoutes } from '../fs/routes.js';
|
|
@@ -26,6 +28,9 @@ import { createTerminalRuntime } from '../terminal/runtime.js';
|
|
|
26
28
|
import { readTerminalWsControlFrame, createTerminalWsControlFrame } from '../terminal/terminal-ws-protocol.js';
|
|
27
29
|
import { createTranscriptCacheService } from '../transcript-cache/service.js';
|
|
28
30
|
import { runRemoteProjectOperation } from '../gui-customization/projects-remote.js';
|
|
31
|
+
import { attachGuiNetwork } from '../gui-network/runtime.js';
|
|
32
|
+
import { createRequestSecurityRuntime } from '../security/request-security.js';
|
|
33
|
+
import { createBrowserSocksGateway } from '../../../../electron/browser-socks-gateway.mjs';
|
|
29
34
|
|
|
30
35
|
const require = createRequire(import.meta.url);
|
|
31
36
|
const disposers = [];
|
|
@@ -33,7 +38,7 @@ afterEach(async () => { for (const dispose of disposers.splice(0).reverse()) awa
|
|
|
33
38
|
const wait = async (test) => { await vi.waitFor(test, { timeout: 5000, interval: 10 }); };
|
|
34
39
|
|
|
35
40
|
async function host({ adapter = null, supportedRemote = true, failHubWrite = false, requestTimeoutMs = 500,
|
|
36
|
-
operationTimeoutMs = requestTimeoutMs, indexStats, requireClientAuth = false, productionTerminal = false, terminalFrames = [] } = {}) {
|
|
41
|
+
operationTimeoutMs = requestTimeoutMs, indexStats, requireClientAuth = false, productionTerminal = false, terminalFrames = [], productionGuiNetwork = false } = {}) {
|
|
37
42
|
const directory = await fs.mkdtemp(path.join(os.tmpdir(), 'yuri-remote-host-test-'));
|
|
38
43
|
const clients = createRemoteClientAuthRuntime({ fsPromises: fs, path, crypto, storePath: path.join(directory, 'clients.json') });
|
|
39
44
|
const issued = await clients.createClient({ clientKind: 'desktop-local', authMethod: 'pairing', pairingId: 'test-pairing' });
|
|
@@ -73,8 +78,9 @@ async function host({ adapter = null, supportedRemote = true, failHubWrite = fal
|
|
|
73
78
|
app.get('/auth/session', auth.handleSessionStatus);
|
|
74
79
|
app.post('/auth/url-token', auth.handleUrlAuthToken);
|
|
75
80
|
app.use('/api', auth.requireAuth);
|
|
81
|
+
const security = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) });
|
|
76
82
|
runtime = registerRemoteHostRoutes(app, { gateway, getAuth: () => auth, server,
|
|
77
|
-
isRequestOriginAllowed: () => true, remoteClientAuthRuntime: clients,
|
|
83
|
+
isRequestOriginAllowed: productionGuiNetwork ? security.isRequestOriginAllowed : () => true, remoteClientAuthRuntime: clients,
|
|
78
84
|
readSettings: async () => settings,
|
|
79
85
|
persistSettings: async (update) => { settings = { ...settings, ...update(settings) }; return settings; },
|
|
80
86
|
validateDirectoryPath: async (value) => typeof value === 'string' && value.startsWith('/')
|
|
@@ -90,6 +96,7 @@ async function host({ adapter = null, supportedRemote = true, failHubWrite = fal
|
|
|
90
96
|
isRequestOriginAllowed: async () => true, rejectWebSocketUpgrade: (socket) => socket.destroy(),
|
|
91
97
|
TERMINAL_INPUT_WS_HEARTBEAT_INTERVAL_MS: 30000, TERMINAL_INPUT_WS_REBIND_WINDOW_MS: 1000,
|
|
92
98
|
TERMINAL_INPUT_WS_MAX_REBINDS_PER_WINDOW: 3 }) : null;
|
|
99
|
+
const guiNetwork = productionGuiNetwork ? attachGuiNetwork({ server, uiAuthController: auth, isRequestOriginAllowed: security.isRequestOriginAllowed }) : null;
|
|
93
100
|
const terminal = new WebSocketServer({ noServer: true });
|
|
94
101
|
server.on('upgrade', async (req, socket, head) => {
|
|
95
102
|
if (productionTerminal) return;
|
|
@@ -148,7 +155,7 @@ async function host({ adapter = null, supportedRemote = true, failHubWrite = fal
|
|
|
148
155
|
const url = `http://127.0.0.1:${server.address().port}`;
|
|
149
156
|
const headers = { Authorization: `Bearer ${issued.token}`, 'Content-Type': 'application/json' };
|
|
150
157
|
disposers.push(async () => {
|
|
151
|
-
runtime.stop(); terminal.close(); transcript.close(); auth.dispose();
|
|
158
|
+
guiNetwork?.stop(); runtime.stop(); terminal.close(); transcript.close(); auth.dispose();
|
|
152
159
|
await terminalRuntime?.shutdown();
|
|
153
160
|
for (const socket of sockets) socket.destroy();
|
|
154
161
|
await new Promise((resolve) => server.close(resolve));
|
|
@@ -174,7 +181,7 @@ async function host({ adapter = null, supportedRemote = true, failHubWrite = fal
|
|
|
174
181
|
|
|
175
182
|
async function aggregate(options = {}) {
|
|
176
183
|
const remote = await host({ requireClientAuth: options.requireClientAuth, productionTerminal: options.productionTerminal,
|
|
177
|
-
terminalFrames: options.terminalFrames });
|
|
184
|
+
terminalFrames: options.terminalFrames, productionGuiNetwork: options.productionGuiNetwork });
|
|
178
185
|
let hosts = [{ id: 'remote-1', label: 'Remote', source: 'direct', apiUrl: remote.url, clientToken: remote.issued.token }];
|
|
179
186
|
const listeners = new Set();
|
|
180
187
|
const adapter = { listHosts: async () => hosts, subscribe(fn) { listeners.add(fn); return () => listeners.delete(fn); } };
|
|
@@ -182,7 +189,129 @@ async function aggregate(options = {}) {
|
|
|
182
189
|
return { hub, remote, setHosts(next) { hosts = next; for (const fn of listeners) fn(); } };
|
|
183
190
|
}
|
|
184
191
|
|
|
192
|
+
async function assertBrowserTcp(hub, route, remote) {
|
|
193
|
+
const token = (await (await hub.call('/auth/url-token', 'POST')).json()).token;
|
|
194
|
+
const address = `${hub.url.replace('http:', 'ws:')}${route}?yuri_url_token=${token}`;
|
|
195
|
+
const rejectUpgrade = (url, origin) => new Promise((resolve, reject) => {
|
|
196
|
+
const ws = new WebSocket(url, { headers: { Origin: origin } });
|
|
197
|
+
ws.on('error', () => {});
|
|
198
|
+
ws.on('unexpected-response', (_req, res) => { res.resume(); ws.terminate(); resolve(res.statusCode); });
|
|
199
|
+
ws.on('open', () => { ws.terminate(); reject(new Error('Unexpected admission')); });
|
|
200
|
+
});
|
|
201
|
+
expect(await rejectUpgrade(address, 'https://untrusted.example')).toBe(403);
|
|
202
|
+
expect(await rejectUpgrade(address.replace(token, 'invalid'), hub.url)).toBe(403);
|
|
203
|
+
const ws = new WebSocket(address, { headers: { Origin: hub.url } });
|
|
204
|
+
ws.on('error', () => {});
|
|
205
|
+
let ready;
|
|
206
|
+
const socks = createBrowserSocksGateway({ send: value => {
|
|
207
|
+
if (ws.readyState !== WebSocket.OPEN) return false;
|
|
208
|
+
ws.send(Buffer.isBuffer(value) ? value : JSON.stringify(value)); return true;
|
|
209
|
+
} });
|
|
210
|
+
ws.on('message', (bytes, binary) => {
|
|
211
|
+
if (!binary && JSON.parse(bytes).type === 'ready') { ready = JSON.parse(bytes); return; }
|
|
212
|
+
socks.receive(binary ? bytes : bytes.toString());
|
|
213
|
+
});
|
|
214
|
+
let browser;
|
|
215
|
+
const connections = new Set();
|
|
216
|
+
const destination = net.createServer(socket => {
|
|
217
|
+
connections.add(socket); socket.once('close', () => connections.delete(socket));
|
|
218
|
+
socket.on('data', bytes => socket.write(bytes));
|
|
219
|
+
});
|
|
220
|
+
try {
|
|
221
|
+
destination.listen(0, '127.0.0.1'); await once(destination, 'listening');
|
|
222
|
+
if (ws.readyState === WebSocket.CONNECTING) await once(ws, 'open');
|
|
223
|
+
await wait(() => expect(ready?.httpOrigin).toBe(`http://localhost:${remote.server.address().port}`));
|
|
224
|
+
const { port } = await socks.start();
|
|
225
|
+
browser = net.connect(port, '127.0.0.1');
|
|
226
|
+
browser.on('error', () => {});
|
|
227
|
+
await once(browser, 'connect');
|
|
228
|
+
const read = length => new Promise(resolve => {
|
|
229
|
+
const receive = () => { const bytes = browser.read(length); if (bytes) { browser.off('readable', receive); resolve(bytes); } };
|
|
230
|
+
browser.on('readable', receive); receive();
|
|
231
|
+
});
|
|
232
|
+
browser.write(Buffer.from([5, 1, 0]));
|
|
233
|
+
expect(await read(2)).toEqual(Buffer.from([5, 0]));
|
|
234
|
+
const request = Buffer.from([5, 1, 0, 1, 127, 0, 0, 1, 0, 0]);
|
|
235
|
+
request.writeUInt16BE(destination.address().port, 8); browser.write(request);
|
|
236
|
+
expect((await read(10))[1]).toBe(0);
|
|
237
|
+
const bytes = crypto.randomBytes(512 * 1024);
|
|
238
|
+
browser.write(bytes);
|
|
239
|
+
expect(await read(bytes.length)).toEqual(bytes);
|
|
240
|
+
ws.close();
|
|
241
|
+
await wait(() => expect(connections.size).toBe(0));
|
|
242
|
+
} finally {
|
|
243
|
+
browser?.destroy(); await socks.close(); ws.terminate();
|
|
244
|
+
for (const socket of connections) socket.destroy();
|
|
245
|
+
await new Promise(resolve => destination.close(resolve));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
185
249
|
describe('Remote Host production HTTP contract', () => {
|
|
250
|
+
it('pins and unpins remote sessions in the Hub DB without remote mutations or refresh resurrection', async () => {
|
|
251
|
+
const { hub, remote } = await aggregate();
|
|
252
|
+
const remotePin = vi.fn((_req, res) => res.status(204).end());
|
|
253
|
+
remote.app.post('/api/yuri/session-index/session/:id/pin', remotePin);
|
|
254
|
+
remote.app.delete('/api/yuri/session-index/session/:id/pin', remotePin);
|
|
255
|
+
const session = { id: 'pin-session', directory: '/same/path', title: 'Pin target', time: { created: 1, updated: 2 } };
|
|
256
|
+
remote.setSummaries({ directories: [{ directory: '/same/path', hasMore: false, sessions: [session] }], pinnedSessionIds: [] });
|
|
257
|
+
await hub.call('/api/hosts/remote-1/projects', 'POST', { path: '/same/path' });
|
|
258
|
+
const abort = new AbortController();
|
|
259
|
+
const stream = await fetch(`${hub.url}/api/global/event`, { headers: hub.headers, signal: abort.signal });
|
|
260
|
+
const read = async () => (await hub.call('/api/hosts/remote-1/summaries')).json();
|
|
261
|
+
const persistedPins = () => {
|
|
262
|
+
const index = createSessionIndexService({ dbPath: path.join(hub.directory, 'session-index.sqlite'),
|
|
263
|
+
getRuntimeConfig: () => ({ apiBaseUrl: `hub:${hub.store.hubId}:remote-host:remote-1` }) });
|
|
264
|
+
try { return index.snapshot().pinnedSessionIds; } finally { index.close(); }
|
|
265
|
+
};
|
|
266
|
+
const refresh = async (snapshot) => {
|
|
267
|
+
const before = (await read()).lastSyncedAt;
|
|
268
|
+
remote.setSummaries(snapshot);
|
|
269
|
+
remote.emit({ type: 'yuri:session-index-changed', properties: { cause: 'change' } });
|
|
270
|
+
await wait(async () => expect((await read()).lastSyncedAt).toBeGreaterThan(before));
|
|
271
|
+
};
|
|
272
|
+
const pinPath = '/api/hosts/remote-1/api/yuri/session-index/session/pin-session/pin';
|
|
273
|
+
try {
|
|
274
|
+
await wait(async () => expect((await read()).directories[0]?.sessions[0]?.id).toBe('pin-session'));
|
|
275
|
+
expect((await hub.call(pinPath, 'POST')).status).toBe(204);
|
|
276
|
+
expect(remotePin.mock.calls.length).toBe(0);
|
|
277
|
+
expect((await read()).pinnedSessionIds).toEqual(['pin-session']);
|
|
278
|
+
expect(persistedPins()).toEqual(['pin-session']);
|
|
279
|
+
hub.store.saveProject('remote-2', { id: 'other-project', path: '/same/path' });
|
|
280
|
+
const otherPinPath = pinPath.replace('remote-1', 'remote-2');
|
|
281
|
+
expect((await hub.call(otherPinPath, 'POST')).status).toBe(204);
|
|
282
|
+
await refresh({ directories: [{ directory: '/same/path', sessions: [session] }], pinnedSessionIds: [] });
|
|
283
|
+
expect((await read()).pinnedSessionIds).toEqual(['pin-session']);
|
|
284
|
+
const Database = require('better-sqlite3');
|
|
285
|
+
const failureDb = new Database(path.join(hub.directory, 'session-index.sqlite'));
|
|
286
|
+
try {
|
|
287
|
+
failureDb.exec("CREATE TRIGGER reject_pin_delete BEFORE UPDATE OF pinned_at ON session_summary BEGIN SELECT RAISE(ABORT, 'injected storage failure'); END");
|
|
288
|
+
expect((await hub.call(pinPath, 'DELETE')).status).toBe(503);
|
|
289
|
+
expect((await read()).pinnedSessionIds).toEqual(['pin-session']);
|
|
290
|
+
expect(persistedPins()).toEqual(['pin-session']);
|
|
291
|
+
} finally {
|
|
292
|
+
failureDb.exec('DROP TRIGGER IF EXISTS reject_pin_delete');
|
|
293
|
+
failureDb.close();
|
|
294
|
+
}
|
|
295
|
+
expect((await hub.call(pinPath, 'DELETE')).status).toBe(204);
|
|
296
|
+
expect((await hub.call(pinPath, 'DELETE')).status).toBe(204);
|
|
297
|
+
expect((await read()).pinnedSessionIds).toEqual([]);
|
|
298
|
+
expect(persistedPins()).toEqual([]);
|
|
299
|
+
expect((await (await hub.call('/api/hosts/remote-2/summaries')).json()).pinnedSessionIds).toEqual(['pin-session']);
|
|
300
|
+
await refresh({ directories: [{ directory: '/same/path', sessions: [{ ...session, time: { ...session.time, pinned: 123 } }] }], pinnedSessionIds: ['pin-session'] });
|
|
301
|
+
const snapshot = await read();
|
|
302
|
+
expect(snapshot.pinnedSessionIds).toEqual([]);
|
|
303
|
+
expect(snapshot.directories[0].sessions[0].time.pinned).toBeUndefined();
|
|
304
|
+
expect(persistedPins()).toEqual([]);
|
|
305
|
+
expect(remotePin.mock.calls.length).toBe(0);
|
|
306
|
+
const mismatched = await fetch(`${hub.url}${pinPath}`, { method: 'POST', headers: { ...hub.headers, 'x-yuri-target-instance': 'other-instance' } });
|
|
307
|
+
expect(mismatched.status).toBe(409);
|
|
308
|
+
expect(persistedPins()).toEqual([]);
|
|
309
|
+
} finally { abort.abort(); await stream.body.cancel().catch(() => {}); }
|
|
310
|
+
});
|
|
311
|
+
it('routes Browser SOCKS to the Remote Project Host with URL auth and real Origin checks', async () => {
|
|
312
|
+
const { hub, remote } = await aggregate({ productionGuiNetwork: true, requireClientAuth: true, requestTimeoutMs: 5000 });
|
|
313
|
+
await assertBrowserTcp(hub, '/api/hosts/remote-1/api/gui-network/ws', remote);
|
|
314
|
+
});
|
|
186
315
|
it('forwards metadata writes with their directory and patch, but rejects other methods and stale targets', async () => {
|
|
187
316
|
const { hub, remote } = await aggregate();
|
|
188
317
|
const writes = [];
|
|
@@ -1407,7 +1536,7 @@ describe('Remote Host production HTTP contract', () => {
|
|
|
1407
1536
|
|
|
1408
1537
|
it.each([0, 1, 2])('uses the real E2EE Relay client for Relay-only hosts, including terminal forwarding (%i)', async (iteration) => {
|
|
1409
1538
|
const productionTerminal = iteration === 2;
|
|
1410
|
-
const remote = await host({ requireClientAuth: true, productionTerminal });
|
|
1539
|
+
const remote = await host({ requireClientAuth: true, productionTerminal, productionGuiNetwork: true });
|
|
1411
1540
|
const relay = createPrivateRelayServer({ host: '127.0.0.1', port: 0 });
|
|
1412
1541
|
await relay.start();
|
|
1413
1542
|
const encryption = await generateEcdhKeyPair();
|
|
@@ -1428,7 +1557,8 @@ describe('Remote Host production HTTP contract', () => {
|
|
|
1428
1557
|
const paired = await remote.clients.createClient({ clientKind: 'desktop', authMethod: 'pairing', pairingId: 'relay-pair', usesRelay: true });
|
|
1429
1558
|
const descriptor = { id: 'relay-only', name: 'Relay Host', source: 'relay', clientToken: paired.token,
|
|
1430
1559
|
relay: { relayUrl, serverId, hostEncPubJwk: identity.hostEncPubJwk } };
|
|
1431
|
-
const hub = await host({ adapter: { listHosts: async () => [descriptor] }, requestTimeoutMs: 5000 });
|
|
1560
|
+
const hub = await host({ adapter: { listHosts: async () => [descriptor] }, requestTimeoutMs: 5000, productionGuiNetwork: true });
|
|
1561
|
+
if (iteration === 1) await assertBrowserTcp(hub, '/api/hosts/relay-only/api/gui-network/ws', remote);
|
|
1432
1562
|
if (productionTerminal) {
|
|
1433
1563
|
const authorize = hub.auth.resolveAuthContext;
|
|
1434
1564
|
let upgrades = 0;
|
|
@@ -1458,7 +1588,7 @@ describe('Remote Host production HTTP contract', () => {
|
|
|
1458
1588
|
.toMatchObject({ created: true, session: { sessionID: 'ses_relay_new', directory: registered.project.path, target } });
|
|
1459
1589
|
expect(createSession).toHaveBeenCalledOnce();
|
|
1460
1590
|
await wait(() => expect(remote.statusStreams).toBe(1));
|
|
1461
|
-
const socket = new WebSocket(`${hub.url.replace('http:', 'ws:')}/api/hosts/relay-only/api/terminal/ws`, { headers: hub.headers });
|
|
1591
|
+
const socket = new WebSocket(`${hub.url.replace('http:', 'ws:')}/api/hosts/relay-only/api/terminal/ws`, { headers: { ...hub.headers, Origin: hub.url } });
|
|
1462
1592
|
disposers.push(() => socket.terminate());
|
|
1463
1593
|
const frames = [];
|
|
1464
1594
|
if (productionTerminal) socket.on('message', (data) => frames.push(readTerminalWsControlFrame(data)));
|
|
@@ -69,7 +69,7 @@ export async function createRemoteTransport(host, { fetchImpl = fetch, signal }
|
|
|
69
69
|
if (closed) throw failure('stale_host', 409);
|
|
70
70
|
const url = new URL(route, base);
|
|
71
71
|
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
72
|
-
const socket = new WebSocket(url, protocols, { headers });
|
|
72
|
+
const socket = new WebSocket(url, protocols, { headers: { ...headers, Origin: base.origin } });
|
|
73
73
|
socket.onmessage = onMessage || null;
|
|
74
74
|
sockets.add(socket);
|
|
75
75
|
socket.once('close', () => sockets.delete(socket));
|
|
@@ -69,6 +69,9 @@ development index without changing settings or authentication storage.
|
|
|
69
69
|
Rows are partitioned by a runtime key derived from the desktop
|
|
70
70
|
`apiBaseUrl` (Electron falls back to the local sidecar URL so the key stays
|
|
71
71
|
stable between server listen and window activation).
|
|
72
|
+
Pin/unpin updates the independent pin record and summary `pinned_at` in one
|
|
73
|
+
transaction. A failed second write rolls both back; reopening cannot resurrect
|
|
74
|
+
a partially cleared pin from legacy summary backfill.
|
|
72
75
|
`service.js` exclusively owns the WAL database and stores at most the
|
|
73
76
|
newest 20 root-session summaries per runtime and directory. It also retains the
|
|
74
77
|
minimal session `model: { providerID, id, variant? }` reference (each string is
|
|
@@ -717,7 +717,7 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
|
|
|
717
717
|
return result.changes > 0;
|
|
718
718
|
};
|
|
719
719
|
|
|
720
|
-
const setPinned = (sessionID, pinnedAt = Date.now()) => {
|
|
720
|
+
const setPinned = db.transaction((sessionID, pinnedAt = Date.now()) => {
|
|
721
721
|
if (typeof sessionID !== 'string' || !sessionID) return false;
|
|
722
722
|
const timestamp = toTimestamp(pinnedAt);
|
|
723
723
|
if (!timestamp) return false;
|
|
@@ -725,15 +725,15 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
|
|
|
725
725
|
upsertPin.run(key, sessionID, timestamp);
|
|
726
726
|
writeSummaryPinnedAt.run(timestamp, key, sessionID);
|
|
727
727
|
return true;
|
|
728
|
-
};
|
|
728
|
+
});
|
|
729
729
|
|
|
730
|
-
const clearPinned = (sessionID) => {
|
|
730
|
+
const clearPinned = db.transaction((sessionID) => {
|
|
731
731
|
if (typeof sessionID !== 'string' || !sessionID) return false;
|
|
732
732
|
const key = runtimeKey();
|
|
733
733
|
const pinResult = deletePin.run(key, sessionID);
|
|
734
734
|
const summaryResult = writeSummaryPinnedAt.run(null, key, sessionID);
|
|
735
735
|
return pinResult.changes > 0 || summaryResult.changes > 0;
|
|
736
|
-
};
|
|
736
|
+
});
|
|
737
737
|
|
|
738
738
|
const replaceChildSessions = db.transaction((directory, parentSessionID, children) => {
|
|
739
739
|
const normalizedDirectory = normalizeDirectory(directory);
|
|
@@ -320,7 +320,7 @@ const isUrlAuthReadableHttpPath = (pathname) => {
|
|
|
320
320
|
export const isUrlAuthWebSocketPath = (pathname) => {
|
|
321
321
|
if (typeof pathname !== 'string' || !pathname) return false;
|
|
322
322
|
if (parseFilePreviewPath(pathname)) return false;
|
|
323
|
-
const remote = /^\/api\/hosts\/[^/]+(\/api\/(?:terminal\/ws|preview\/proxy\/.*))$/.exec(pathname);
|
|
323
|
+
const remote = /^\/api\/hosts\/[^/]+(\/api\/(?:terminal\/ws|gui-network\/ws|preview\/proxy\/.*))$/.exec(pathname);
|
|
324
324
|
if (remote) return isUrlAuthWebSocketPath(remote[1]);
|
|
325
325
|
return pathname === '/api/event/ws'
|
|
326
326
|
|| pathname === '/api/global/event/ws'
|
|
@@ -58,6 +58,9 @@ describe('isUrlAuthWebSocketPath', () => {
|
|
|
58
58
|
expect(isUrlAuthWebSocketPath('/api/preview/proxy/abc123/')).toBe(true);
|
|
59
59
|
expect(isUrlAuthWebSocketPath('/api/preview/proxy/abc123/@vite')).toBe(true);
|
|
60
60
|
expect(isUrlAuthWebSocketPath('/api/terminal/ws')).toBe(true);
|
|
61
|
+
expect(isUrlAuthWebSocketPath('/api/hosts/remote-a/api/gui-network/ws')).toBe(true);
|
|
62
|
+
expect(isUrlAuthWebSocketPath('/api/hosts/remote-a/api/gui-network/ws/extra')).toBe(false);
|
|
63
|
+
expect(isUrlAuthWebSocketPath('/api/hosts/remote-a/api/hosts/remote-b/api/gui-network/ws')).toBe(false);
|
|
61
64
|
expect(isUrlAuthWebSocketPath('/api/dictation/ws')).toBe(true);
|
|
62
65
|
expect(isUrlAuthWebSocketPath('/api/event/ws')).toBe(true);
|
|
63
66
|
expect(isUrlAuthWebSocketPath('/api/global/event/ws')).toBe(true);
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-MwrM60DK.js","assets/rolldown-runtime-hePW80VL.js","assets/platform-wF65ZFgV.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-fom6orB6.js","assets/vendor-react-D5BntRmA.js","assets/runtime-file-resource-DnhWnndu.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/vendor-tanstack-react-query-ChSd65dm.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-B8s-Rcd-.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-CYex4rbF.js","assets/vendor-zustand-CNn3HHhT.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-DUquFMmd.js","assets/vendor-markstream-react-Cwc-VXWM.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/useMobileNavigationStore-BkVbj6Lg.js","assets/gitApiHttp-BEMPJCIG.js","assets/client-CgAFd1ew.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-8bssUUT3.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-Y-KPX915.js","assets/i18n-OsFhnlRH.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-Dj5cSf8B.js","assets/tour-CMXP3Kif.js","assets/useAssistantUIStore-CphyXHEY.js","assets/input-store-DRTu4uZc.js","assets/remoteProjectQueries-8giIAvzL.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/toolHelpers-iEHVHQ9p.js","assets/useThemeSystem-D2YBbLma.js","assets/vendor-framer-motion-DiGWHm7K.js","assets/tooltip-DloXgI9f.js","assets/useEffectiveDirectory-DtDqspBR.js","assets/image-loading-ZB1bYt51.js","assets/image-loading-DA9JEHD8.css","assets/LoadingImage-DDafrpn6.js","assets/ImageLoadingPlaceholder-BS9Swwfz.js","assets/FadeInOnReveal-Cb2cgQyM.js","assets/markdownHeightCache-Dn_Jkp0n.js","assets/dualLimitLru-D8Sphgua.js","assets/useStreamingTextThrottle-DMhoKnTy.js","assets/MarkdownRendererImpl-BWmWJyQD.js","assets/vendor-katex-DNVSTX6g.js","assets/themes-BgDJcxRc.js","assets/vendor-marked-S3gCOYp1.js","assets/markdownTheme-C2LJ3cJo.js","assets/vendor-pierre-diffs-HJfPTtu2.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/markdown-worker-oBGEB9Eg.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-remend-C3cXc-tf.js","assets/fileReferenceActions-DX-Stroq.js","assets/fileReferenceParser-1HHDBUum.js","assets/MarkstreamRendererImpl-C6aiJnjl.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-CNn3HHhT.js";import{ot as n,st as r}from"./vendor-base-ui-fom6orB6.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-D5BntRmA.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{Rn as o}from"./useMobileNavigationStore-BkVbj6Lg.js";import{t as s}from"./useEffectiveDirectory-DtDqspBR.js";import{i as c,n as l,t as u}from"./markdownHeightCache-Dn_Jkp0n.js";var d=e(r(),1),f=i(),p=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},m=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},h=`yuri:markstream-react`,g=e=>p(h,e),_=t(e=>({markstreamReactEnabled:g(),setMarkstreamReactEnabled:t=>{m(h,t),e({markstreamReactEnabled:t})}})),v=null,y=()=>(v??=a(()=>import(`./MarkstreamRendererImpl-MwrM60DK.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85])).catch(e=>{throw v=null,e}),v),b=()=>{y().catch(()=>void 0)},x=null,S=()=>(x??=a(()=>import(`./MarkdownRendererImpl-BWmWJyQD.js`).then(e=>e.n),__vite__mapDeps([63,1,4,3,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,64,38,39,40,41,42,30,31,32,33,34,35,36,37,43,44,45,46,47,48,49,50,61,51,65,54,55,56,59,60,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84])).catch(e=>{throw x=null,e}),x),C=()=>{S().catch(()=>void 0),g()&&b()},w=`yuri:chunk-import-reload`,T=250,E=3e4,D=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function O(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function k(e){let t=O(e);return D.some(e=>e.test(t))}function A(e){return`0.3.2-beta.7:${O(e).slice(0,500)}`}function j(e){if(typeof window>`u`)return;let t=Date.now(),n=A(e),r=null;try{let e=window.sessionStorage.getItem(w);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<E)){try{window.sessionStorage.setItem(w,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:O(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function M(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!k(e)||t>=n)break;await new Promise(e=>setTimeout(e,T*(t+1)))}throw k(r)&&j(r),r}var N=e=>(0,d.lazy)(()=>M(e)),P=(e,t)=>!!t?.toLowerCase().startsWith(`video/`)||/^data:video\//i.test(e)||/\.(?:mp4|m4v|webm|mov|ogv|ogg)(?:[?#]|$)/i.test(e),F=class extends d.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},I=d.createContext(!0),L=()=>d.useContext(I),R=n(),z=N(()=>S().then(e=>({default:e.MarkdownRenderer}))),B=N(()=>y().then(e=>({default:e.MarkstreamRenderer}))),V=N(()=>S().then(e=>({default:e.SimpleMarkdownRenderer}))),H=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,U=e=>{let t=(0,f.c)(15),n=_(K),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?l(u(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let s=a,d;t[5]!==e.className||t[6]!==e.variant?(d=o(`relative break-words w-full min-w-0`,H(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=d):d=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==s?(p=(0,R.jsx)(c,{animated:e.animated,content:r,reservedHeight:s}),t[8]=r,t[9]=e.animated,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==d||t[13]!==p?(m=(0,R.jsx)(`div`,{className:d,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=d,t[13]=p,t[14]=m):m=t[14],m},W=e=>{let t=(0,f.c)(13),n=L(),r=_(q);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,R.jsx)(d.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(z,{...e})}),t[2]=e,t[3]=i);let a=i,o;t[4]!==a||t[5]!==r||t[6]!==e?(o=r?(0,R.jsx)(F,{fallback:a,children:(0,R.jsx)(d.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(B,{...e})})}):a,t[4]=a,t[5]=r,t[6]=e,t[7]=o):o=t[7];let c=o,l;t[8]===e?l=t[9]:(l=t=>{if(!e.onShowPopup||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null,r=n?.getAttribute(`href`);if(!r||!P(r))return;t.preventDefault(),t.stopPropagation();let i=n?.textContent?.trim()||r.split(/[/?#]/).filter(Boolean).pop()||r;e.onShowPopup({open:!0,title:i,content:``,video:{url:r,filename:i,directory:s()??``}})},t[8]=e,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,R.jsx)(`div`,{className:`contents`,onClickCapture:l,children:c}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},G=e=>{let t=(0,f.c)(4);if(!L()){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(d.Suspense,{fallback:(0,R.jsx)(U,{...e}),children:(0,R.jsx)(V,{...e})}),t[2]=e,t[3]=n),n};function K(e){return e.markstreamReactEnabled}function q(e){return e.markstreamReactEnabled}export{N as a,P as i,G as n,C as o,I as r,W as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,ot as n,st as r}from"./vendor-base-ui-fom6orB6.js";import{n as i}from"./vendor-react-D5BntRmA.js";import{r as a}from"./vendor-reactuses-core-B8s-Rcd-.js";import{In as o,Rn as s}from"./useMobileNavigationStore-BkVbj6Lg.js";import{a as c,c as l}from"./vendor-framer-motion-DiGWHm7K.js";import{n as u}from"./Icon-o1bRhUil.js";import{t as d}from"./MobileWindowStack-DGLdgoGr.js";var f=e(r(),1),p=i(),m=n(),h=e(t(),1),g=0,_=()=>{g=Date.now()+800},v=()=>Date.now()<g;function y(e){let t=(0,p.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=s(`flex cursor-ns-resize touch-none justify-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,m.jsx)(`div`,{className:`pointer-events-none h-1.5 w-11 rounded-full bg-[var(--interactive-border)]`}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,m.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`horizontal`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}var b=100,x=.35;function S(e,t,n){let r=e.at(-1),i=e.at(-2);for(r&&i&&Math.abs(t-r.height)>2&&(t-r.height)*(r.height-i.height)<0&&e.splice(0,e.length-1),e.push({height:t,time:n});e.length>2&&(e.length>16||e[1].time<n-b);)e.shift()}function C(e,t){let n=e.at(-1);if(!n||t-n.time>=b)return 0;let r=e.find(e=>e.time>=t-b);return!r||n.time<=r.time?0:Math.max(-4,Math.min(4,(n.height-r.height)/Math.max(1,t-r.time)))}function w(e,t,n,r,i){let a=Math.abs(r)>=x&&Math.abs(i)>=8,o=n+(a?r*180:0),s=e.reduce((e,t)=>Math.abs(t.height-o)<Math.abs(e.height-o)?t:e),c=e.find(e=>e.id===t)??s;return!a||Math.abs(s.height-c.height)>1?s.id:[...e].sort((e,t)=>r>0?e.height-t.height:t.height-e.height).find(e=>r>0?e.height>c.height+1:e.height<c.height-1)?.id??s.id}function T(e,t,n){let r=e<t?t:e>n?n:e,i=e-r;return r+Math.sign(i)*48*(1-1/(1+Math.abs(i)*.55/48))}function E(e){let t=(0,p.c)(82),{surfaceRef:n,initialPoint:r,getPoints:i,minimumHeight:o,onRelease:s,onCommit:u,renderMode:d}=e,m=d===void 0?`height`:d,[h,g]=(0,f.useState)(r),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),x=(0,f.useRef)(r),E=(0,f.useRef)(null),A=(0,f.useRef)(null),j=(0,f.useRef)(null),M=(0,f.useRef)(null),N=(0,f.useRef)(!1),P=(0,f.useRef)(null),F;t[0]===n?F=t[1]:(F=()=>{let e=n.current;if(!e)return 0;if(!P.current)return e.getBoundingClientRect().height;let t=parseFloat(getComputedStyle(e).translate.split(` `)[1])||0;return P.current.layoutHeight-t},t[0]=n,t[1]=F);let I=a(F),L;t[2]===n?L=t[3]:(L=e=>{let t=n.current;t&&(P.current?t.style.translate=`0 ${P.current.layoutHeight-e}px`:t.style.height=`${e}px`)},t[2]=n,t[3]=L);let R=a(L),z;t[4]!==m||t[5]!==n||t[6]!==R?(z=(e,t)=>{let r=n.current;if(r){if(m===`translate`&&!P.current){let e=Math.max(...t.map(k))+144,{maxHeight:n,position:i,bottom:a,left:o,right:s}=r.style;P.current={layoutHeight:e,styles:{maxHeight:n,position:i,bottom:a,left:o,right:s}},Object.assign(r.style,{position:`absolute`,bottom:`0px`,left:`0px`,right:`0px`}),r.style.maxHeight=`none`,r.style.height=`${e}px`}r.setAttribute(`data-height-snap-active`,``),r.style.willChange=P.current?`translate`:`height`,R(e)}},t[4]=m,t[5]=n,t[6]=R,t[7]=z):z=t[7];let B=a(z),V;t[8]===n?V=t[9]:(V=()=>{let e=n.current;e&&(P.current&&(e.style.translate=``,Object.assign(e.style,P.current.styles),e.style.height=``),e.style.willChange=``,e.removeAttribute(`data-height-snap-active`)),P.current=null},t[8]=n,t[9]=V);let H=a(V),ae;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(ae=()=>{A.current!==null&&cancelAnimationFrame(A.current),A.current=null,j.current=null,M.current?.cancel(),M.current=null},t[10]=ae):ae=t[10];let U=a(ae),W;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{let e=E.current;E.current=null,e?.handle.hasPointerCapture?.(e.pointerId)&&e.handle.releasePointerCapture(e.pointerId)},t[11]=W):W=t[11];let G=a(W),oe;t[12]!==U||t[13]!==H||t[14]!==i||t[15]!==u||t[16]!==B||t[17]!==I||t[18]!==G||t[19]!==n||t[20]!==R?(oe=(e,t,r,a)=>{let o=r===void 0||r,s=a===void 0?0:a,d=n.current;if(!d)return;let f=t??I();U(),R(f);let p=i(),m=p.find(t=>t.id===e);if(!m)return;if(B(f,p),G(),v(!1),b(!1),x.current=e,g(e),R(m.height),u?.(e),!o||Math.abs(f-m.height)<1||typeof d.animate!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches){H();return}b(!0);let h=P.current?.layoutHeight,_=m.height-f,y=c([d],h===void 0?{height:[`${f}px`,`${m.height}px`]}:{translate:[`0 ${h-f}px`,`0 ${h-m.height}px`]},{type:l,stiffness:576,damping:48,mass:1,velocity:s*1e3*100/_,restDelta:20/Math.abs(_),restSpeed:500/Math.abs(_)});M.current=y,y.finished.catch(ie).then(()=>{M.current===y&&(M.current=null,H(),b(!1))})},t[12]=U,t[13]=H,t[14]=i,t[15]=u,t[16]=B,t[17]=I,t[18]=G,t[19]=n,t[20]=R,t[21]=oe):oe=t[21];let K=a(oe),se;t[22]!==U||t[23]!==i||t[24]!==o||t[25]!==B||t[26]!==I||t[27]!==n||t[28]!==R?(se=e=>{if(E.current||!e.isPrimary||e.pointerType===`mouse`&&e.button!==0||!n.current)return;let t=I();U(),R(t);let r=i();r.length&&(b(!1),E.current={pointerId:e.pointerId,startY:e.clientY,height:t,point:x.current,points:r,handle:e.currentTarget,minimum:o??Math.min(...r.map(re)),maximum:Math.max(...r.map(O)),samples:[{height:t,time:e.timeStamp}]},N.current=!1,B(t,r),v(!0),e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault())},t[22]=U,t[23]=i,t[24]=o,t[25]=B,t[26]=I,t[27]=n,t[28]=R,t[29]=se):se=t[29];let ce=a(se),le;t[30]!==m||t[31]!==R?(le=e=>{let t=E.current;if(!t||t.pointerId!==e.pointerId)return;let n=t.startY-e.clientY;Math.abs(n)>3&&(N.current=!0),S(t.samples,t.height+n,e.timeStamp);let r=T(t.height+n,t.minimum,t.maximum);j.current=m===`height`?Math.max(t.minimum,r):r,A.current===null&&(A.current=requestAnimationFrame(()=>{A.current=null,j.current!==null&&R(j.current)})),e.preventDefault()},t[30]=m,t[31]=R,t[32]=le):le=t[32];let ue=a(le),de;t[33]!==U||t[34]!==s||t[35]!==I||t[36]!==G||t[37]!==K||t[38]!==n?(de=(e,t)=>{let r=E.current;if(!r||r.pointerId!==e.pointerId)return;let i=j.current??I(),a=r.height+r.startY-e.clientY;t||S(r.samples,a,e.timeStamp);let o=t?0:C(r.samples,e.timeStamp);if(G(),!t&&N.current&&s?.(i,o,r.height))U(),v(!1),n.current&&(n.current.style.willChange=``);else{let e=t||!N.current?r.point:w(r.points,r.point,i,o,a-r.height);K(e,i,!0,o)}e.preventDefault()},t[33]=U,t[34]=s,t[35]=I,t[36]=G,t[37]=K,t[38]=n,t[39]=de):de=t[39];let q=a(de),fe;t[40]!==i||t[41]!==K?(fe=e=>{let t=[...i()].sort(ne),n=t.find(e=>e.id===x.current);if(!n)return;let r=e>0?t.find(e=>e.height>n.height+1):t.sort(D).find(e=>e.height<n.height-1);r&&K(r.id)},t[40]=i,t[41]=K,t[42]=fe):fe=t[42];let J=a(fe),pe;t[43]!==i||t[44]!==K||t[45]!==J?(pe=()=>{if(N.current){N.current=!1;return}let e=[...i()].sort(te);x.current===e.at(-1)?.id?K(e[0].id):J(1)},t[43]=i,t[44]=K,t[45]=J,t[46]=pe):pe=t[46];let me=a(pe),Y;t[47]!==i||t[48]!==me||t[49]!==K||t[50]!==J?(Y=e=>{if(![`ArrowUp`,`ArrowDown`,`Home`,`End`,`Enter`,` `].includes(e.key))return;e.preventDefault();let t=[...i()].sort(ee);t.length&&(e.key===`ArrowUp`?J(1):e.key===`ArrowDown`?J(-1):e.key===`Home`?K(t.at(-1).id):e.key===`End`?K(t[0].id):me())},t[47]=i,t[48]=me,t[49]=K,t[50]=J,t[51]=Y):Y=t[51];let X=a(Y),he;t[52]!==U||t[53]!==H||t[54]!==r||t[55]!==G||t[56]!==n?(he=()=>{U(),G(),H(),x.current=r,g(r),v(!1),b(!1),N.current=!1,n.current&&(n.current.style.height=``,n.current.style.willChange=``)},t[52]=U,t[53]=H,t[54]=r,t[55]=G,t[56]=n,t[57]=he):he=t[57];let Z=a(he),Q,ge;t[58]!==U||t[59]!==H||t[60]!==G?(Q=()=>()=>{U(),G(),H()},ge=[U,G,H],t[58]=U,t[59]=H,t[60]=G,t[61]=Q,t[62]=ge):(Q=t[61],ge=t[62]),(0,f.useLayoutEffect)(Q,ge);let $;t[63]===q?$=t[64]:($=e=>q(e,!1),t[63]=q,t[64]=$);let _e=a($),ve;t[65]===q?ve=t[66]:(ve=e=>q(e,!0),t[65]=q,t[66]=ve);let ye=a(ve),be;t[67]===q?be=t[68]:(be=e=>q(e,!0),t[67]=q,t[68]=be);let xe=a(be),Se;return t[69]!==_||t[70]!==me||t[71]!==X||t[72]!==ce||t[73]!==ue||t[74]!==Z||t[75]!==K||t[76]!==y||t[77]!==h||t[78]!==_e||t[79]!==ye||t[80]!==xe?(Se={snapPoint:h,dragging:_,settling:y,settleAt:K,reset:Z,handlePointerDown:ce,handlePointerMove:ue,handlePointerUp:_e,handlePointerCancel:ye,handleLostPointerCapture:xe,handleClick:me,handleKeyDown:X},t[69]=_,t[70]=me,t[71]=X,t[72]=ce,t[73]=ue,t[74]=Z,t[75]=K,t[76]=y,t[77]=h,t[78]=_e,t[79]=ye,t[80]=xe,t[81]=Se):Se=t[81],Se}function ee(e,t){return e.height-t.height}function te(e,t){return e.height-t.height}function D(e,t){return t.height-e.height}function ne(e,t){return e.height-t.height}function O(e){return e.height}function re(e){return e.height}function ie(){}function k(e){return e.height}var A=.72,j=.98,M=64,N=()=>Math.max(1,window.innerHeight),P=(e,t)=>{let n=Math.max(1,e)*A;return t==null||!Number.isFinite(t)?n:Math.min(n,Math.max(0,t))},F=e=>{let t=(0,p.c)(20),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{initialSnapPoint:r,fitContent:i,onDismiss:o,dismissThresholdPx:s}=n,c=r===void 0?A:r,l=i!==void 0&&i,u=s===void 0?M:s,d=f.useRef(null),m=f.useRef(null),h=f.useRef(c),g=o?0:void 0,_;t[2]===l?_=t[3]:(_=()=>{let e=N(),t=d.current?.parentElement?.clientHeight||e;return l&&h.current===.72&&d.current&&!d.current.hasAttribute(`data-height-snap-active`)&&(m.current=P(e,d.current.getBoundingClientRect().height)),[{id:A,height:Math.min(t,P(e,l?m.current:void 0))},{id:j,height:Math.min(t,e*j)}]},t[2]=l,t[3]=_);let v;t[4]!==u||t[5]!==l||t[6]!==o?(v=(e,t,n)=>{let r=d.current?.parentElement?.clientHeight||N(),i=Math.min(r,P(N(),l?m.current:void 0)),a=t<-.55&&n<=i+1&&e<i-8;return!o||!a&&e>i-u?!1:(o(),!0)},t[4]=u,t[5]=l,t[6]=o,t[7]=v):v=t[7];let y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{h.current=e},t[8]=y):y=t[8];let b;t[9]!==c||t[10]!==g||t[11]!==_||t[12]!==v?(b={surfaceRef:d,initialPoint:c,renderMode:`translate`,minimumHeight:g,getPoints:_,onRelease:v,onCommit:y},t[9]=c,t[10]=g,t[11]=_,t[12]=v,t[13]=b):b=t[13];let x=E(b),S;t[14]!==x||t[15]!==c?(S=()=>{m.current=null,h.current=c,x.reset()},t[14]=x,t[15]=c,t[16]=S):S=t[16];let C=a(S),w;return t[17]!==x||t[18]!==C?(w={...x,surfaceRef:d,reset:C},t[17]=x,t[18]=C,t[19]=w):w=t[19],w},I=e=>{let t=(0,p.c)(13),{controller:n,ariaLabel:r,compact:i}=e,a=i!==void 0&&i,o;t[0]===n.snapPoint?o=t[1]:(o=Math.round(n.snapPoint*100),t[0]=n.snapPoint,t[1]=o);let s=`flex cursor-ns-resize touch-none justify-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)] ${a?`min-h-4 pt-1`:`min-h-8 pt-2.5`}`,c;return t[2]!==r||t[3]!==n.handleClick||t[4]!==n.handleKeyDown||t[5]!==n.handleLostPointerCapture||t[6]!==n.handlePointerCancel||t[7]!==n.handlePointerDown||t[8]!==n.handlePointerMove||t[9]!==n.handlePointerUp||t[10]!==o||t[11]!==s?(c=(0,m.jsx)(y,{"data-mobile-sheet-snap-handle":!0,role:`separator`,tabIndex:0,"aria-label":r,"aria-orientation":`horizontal`,"aria-valuemin":A*100,"aria-valuemax":j*100,"aria-valuenow":o,className:s,onPointerDown:n.handlePointerDown,onPointerMove:n.handlePointerMove,onPointerUp:n.handlePointerUp,onPointerCancel:n.handlePointerCancel,onLostPointerCapture:n.handleLostPointerCapture,onClick:n.handleClick,onKeyDown:n.handleKeyDown}),t[2]=r,t[3]=n.handleClick,t[4]=n.handleKeyDown,t[5]=n.handleLostPointerCapture,t[6]=n.handlePointerCancel,t[7]=n.handlePointerDown,t[8]=n.handlePointerMove,t[9]=n.handlePointerUp,t[10]=o,t[11]=s,t[12]=c):c=t[12],c},L=new WeakMap;function R(e){L.set(e.currentTarget,!0)}function z(e){if(L.delete(e.currentTarget))return!0;if(e.detail!==0)return!1;if(typeof document>`u`)return!0;let t=document.activeElement,n=e.currentTarget;return n instanceof Node&&t instanceof Node&&n.contains(t)}function B(e){e.target===e.currentTarget&&R(e)}function V(e){return e.target===e.currentTarget&&z(e)}var H=(0,f.createContext)(!0),ae=(e,t)=>{let n=`flex min-h-0 flex-col bg-background shadow-none`;if(e===`page`)return`${n} h-full w-full`;let r=`${n} pwa-overlay-panel`;return t===`top`?`${r} mx-auto mb-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-b-xl border-x border-b border-border/50`:t===`left`?`${r} h-full w-[min(86vw,24rem)] rounded-r-xl border-r border-y border-border/50`:t===`right`?`${r} ml-auto h-full w-[min(86vw,24rem)] rounded-l-xl border-l border-y border-border/50`:`${r} mx-auto mt-auto max-h-[calc(100dvh-0.75rem)] w-full max-w-lg rounded-t-2xl border-x border-t border-border/50 pb-[max(0.5rem,var(--yuri-app-bottom-safe,0px),var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px)))]`},U=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),W=(e,t)=>{let n=U(t),r=`${(1-n)*100}%`;return{progress:n,scrimOpacity:n,surfaceOpacity:n,surfaceTransform:e===`left`?`translate3d(-${r}, 0, 0)`:e===`right`?`translate3d(${r}, 0, 0)`:e===`top`?`translate3d(0, -${r}, 0)`:`translate3d(0, ${r}, 0)`}},G=(e,t)=>{let n=U(t);return e===`present`?n:1-n},oe=(e,t)=>e===`present`?+(t===`commit`):t===`commit`?0:1,K=e=>+!!e,se=`mobile-sessions`,ce=new Map,le=e=>ce.get(e)??null,ue=(e,t)=>(ce.set(e,t),()=>{ce.get(e)===t&&ce.delete(e)}),de=`.overlay-scrollbar-container`,q=1,fe=e=>e===`left`||e===`right`?`x`:`y`,J=e=>e===`bottom`||e===`right`?1:-1,pe=(e,t,n)=>{let r=fe(e)===`x`?t:n;return Math.max(0,r*J(e))},me=(e,t,n,r,i)=>{let a=pe(e,t,n),o=Math.abs(fe(e)===`x`?n:t);return Math.hypot(t,n)>r&&a>0&&o<a*i},Y=(e,t)=>Math.min(1,Math.max(0,e/Math.max(1,t))),X=(e,t,n,r)=>Math.min(r,Math.max(n,e*t)),he=(e,t,n,r,i)=>e>=n||e>=i&&t>=r,Z=(e,t,n,r,i)=>t!==0&&n>0?t*i/n:r>80?0:e,Q=(e,t,n=q)=>{if(t===`bottom`)return e.scrollTop<=n;if(t===`top`)return e.scrollTop>=e.scrollHeight-e.clientHeight-n;if(e.matches?.(`:dir(rtl)`)){let r=e.scrollWidth-e.clientWidth;return t===`right`?Math.abs(e.scrollLeft)<=n:Math.abs(e.scrollLeft)>=r-n}return t===`right`?e.scrollLeft<=n:e.scrollLeft>=e.scrollWidth-e.clientWidth-n},ge=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=e.item(n);if(r?.identifier===t)return r}return null},$=(e,t)=>{let n=window.getComputedStyle(e),r=fe(t),i=r===`x`?n.overflowX:n.overflowY,a=r===`x`?e.scrollWidth:e.scrollHeight,o=r===`x`?e.clientWidth:e.clientHeight;return(i===`auto`||i===`scroll`||i===`overlay`)&&a>o},_e=(e,t,n,r)=>{let i=t instanceof Element?t:null,a=i instanceof HTMLElement?i:i?.parentElement??null;for(;a&&e.contains(a);){if($(a,n))return a;if(a===e)break;a=a.parentElement}let o=i?.closest(r)??null;return o&&e.contains(o)&&$(o,n)?o:null},ve=e=>{let t=f.useRef(e),n=f.useRef(null),r=f.useRef(null);return t.current=e,f.useCallback(e=>{if(n.current?.(),n.current=null,!e)return;let i=()=>{let e=r.current;r.current=null,e?.active&&e.controller?.finish(`cancel`)},a=(e,t,n)=>{let r=fe(e.edge)===`x`?t.clientX:t.clientY,i=n-e.lastTime,a=r-e.lastPrimary;e.velocity=Z(e.velocity,a,i,n-e.lastVelocityTime,J(e.edge)),a!==0&&i>0&&(e.lastVelocityTime=n),e.lastPrimary=r,e.lastTime=n,e.distance=pe(e.edge,t.clientX-e.startX,t.clientY-e.startY)},o=n=>{i();let a=t.current;if(a.disabled||n.touches.length!==1)return;let o=n.target instanceof Element?n.target:null,s=a.reservedTargetSelector?o?.closest(a.reservedTargetSelector):null;if(s&&e.contains(s)||o?.closest(`input, textarea, select, [contenteditable=""], [contenteditable="true"], [data-mobile-sheet-no-dismiss]`))return;let c=n.touches[0],l=_e(e,n.target,a.edge,a.scrollContainerSelector??de);if(l&&!Q(l,a.edge))return;let u=e.getBoundingClientRect(),d=fe(a.edge)===`x`?u.width||window.innerWidth:u.height||window.innerHeight;r.current={edge:a.edge,motionId:a.motionId,touchId:c.identifier,startX:c.clientX,startY:c.clientY,lastPrimary:fe(a.edge)===`x`?c.clientX:c.clientY,lastTime:n.timeStamp,lastVelocityTime:n.timeStamp,velocity:0,distance:0,commitDistance:X(d,a.commitDistanceRatio??.1,a.minCommitDistance??40,a.maxCommitDistance??64),motionDistance:d,intentDistance:a.intentDistance??8,maxOffAxisRatio:a.maxOffAxisRatio??1,flingVelocity:a.flingVelocity??.65,flingMinDistance:a.flingMinDistance??12,controller:null,active:!1}},s=e=>{let n=r.current;if(!n)return;if(t.current.disabled||e.touches.length!==1){i();return}let o=ge(e.touches,n.touchId);if(!o){i();return}if(a(n,o,e.timeStamp),!n.active){if(Math.hypot(o.clientX-n.startX,o.clientY-n.startY)<=n.intentDistance)return;if(!me(n.edge,o.clientX-n.startX,o.clientY-n.startY,n.intentDistance,n.maxOffAxisRatio)){r.current=null;return}let e=le(n.motionId);if(!e){r.current=null;return}if(!e.begin(`dismiss`)){r.current=null;return}n.active=!0,n.controller=e}n.controller?.update(Y(n.distance,n.motionDistance)),e.preventDefault()},c=e=>{let t=r.current;if(!t)return;let n=ge(e.changedTouches,t.touchId);if(!n){i();return}if(r.current=null,!t.active)return;a(t,n,e.timeStamp),t.controller?.update(Y(t.distance,t.motionDistance));let o=he(t.distance,t.velocity,t.commitDistance,t.flingVelocity,t.flingMinDistance);t.controller?.finish(o?`commit`:`cancel`),e.preventDefault()},l=()=>i();e.addEventListener(`touchstart`,o,{passive:!0,capture:!0}),e.addEventListener(`touchmove`,s,{passive:!1,capture:!0}),e.addEventListener(`touchend`,c,{passive:!1,capture:!0}),e.addEventListener(`touchcancel`,l,{passive:!0,capture:!0}),n.current=()=>{i(),e.removeEventListener(`touchstart`,o,!0),e.removeEventListener(`touchmove`,s,!0),e.removeEventListener(`touchend`,c,!0),e.removeEventListener(`touchcancel`,l,!0)}},[])},ye=`mobile-overlay-root`,be=200,xe=80,Se=`cubic-bezier(0.32, 0.72, 0, 1)`,Ce=`a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`,we=()=>{if(typeof document>`u`)return null;let e=document.getElementById(ye);return e||(e=document.createElement(`div`),e.id=ye,document.body.appendChild(e)),e},Te=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Ee=({id:e,open:t,onOpenChange:n,keepMounted:r=!1,presentation:i=`sheet`,edge:a=`bottom`,children:o,className:c,scrimClassName:l,surfaceClassName:u,surfaceElementRef:p,dismissGesture:g=!1,onExitComplete:_,onPreviewChange:y,ariaLabel:b})=>{let x=f.useRef(null),S=f.useRef(null),C=f.useRef(null),w=f.useRef(null),T=f.useRef(t),E=f.useRef(n),ee=f.useRef(_),te=f.useRef(y),D=f.useRef(0),ne=f.useRef(0),O=f.useRef(null),re=f.useRef([]),ie=f.useRef(null),k=f.useRef(`standard`),A=f.useRef(`present`),j=f.useRef(0),M=f.useRef(!1),N=f.useRef(t),P=f.useRef(!1),F=f.useRef(t),I=f.useRef(null),[L,R]=f.useState(t),[z,U]=f.useState(t),[se,ce]=f.useState(`standard`),[le,de]=f.useState(!1),q=se===`interactive-present`,fe=f.useSyncExternalStore(d.subscribe,d.getSnapshot,d.getSnapshot),J=z&&!q&&fe===e,pe=ve({motionId:e,edge:a,disabled:!g,...typeof g==`object`?g:{}}),me=f.useCallback(e=>{C.current=e,pe(e),typeof p==`function`?p(e):p&&typeof p==`object`&&(p.current=e)},[pe,p]),Y=f.useCallback(()=>{F.current&&(F.current=!1,U(!1),r||R(!1),ee.current?.())},[r]);T.current=t,E.current=n,ee.current=_,te.current=y,f.useLayoutEffect(()=>{te.current?.(z&&q)},[z,q]),typeof document<`u`&&!x.current&&(x.current=we());let X=f.useCallback(e=>{let t=W(a,e);D.current=t.progress,!(!S.current||!C.current)&&(S.current.style.opacity=String(t.scrimOpacity),C.current.style.transform=t.surfaceTransform,C.current.style.opacity=String(t.surfaceOpacity))},[a]),he=f.useCallback(()=>{O.current!==null&&window.cancelAnimationFrame(O.current),O.current=null},[]),Z=f.useCallback(()=>{S.current&&(S.current.style.willChange=``),C.current&&(C.current.style.willChange=``)},[]),Q=f.useCallback((e=re.current)=>{for(let t of e)t.cancel();re.current=[]},[]),ge=f.useCallback(()=>{he();let e=ie.current;if(e){let t=e.animations[1]?.effect?.getComputedTiming().progress;X(typeof t==`number`&&Number.isFinite(t)?e.from+(e.target-e.from)*t:D.current),Q(e.animations),ie.current=null}else Q();Z(),de(!1)},[X,Q,he,Z]),$=f.useCallback((e,t)=>{if(ie.current?.target===e)return;ge();let n=D.current,r=S.current,i=C.current;if(de(!0),!r||!i||Te()||n===e){X(e),Z(),de(!1),t?.();return}let o=W(a,n),s=W(a,e);r.style.willChange=`opacity`,i.style.willChange=`transform, opacity`;let c=Math.max(xe,be*Math.abs(e-n)),l=[r.animate([{opacity:o.scrimOpacity},{opacity:s.scrimOpacity}],{duration:c,easing:Se,fill:`forwards`}),i.animate([{transform:o.surfaceTransform,opacity:o.surfaceOpacity},{transform:s.surfaceTransform,opacity:s.surfaceOpacity}],{duration:c,easing:Se,fill:`forwards`})];re.current=l;let u={from:n,target:e,animations:l};ie.current=u,Promise.all(l.map(e=>e.finished.catch(()=>void 0))).then(()=>{ie.current===u&&(X(e),Q(l),ie.current=null,Z(),de(!1),t?.())})},[X,Q,Z,a,ge]);if(f.useLayoutEffect(()=>{P.current=L,L&&X(ne.current)},[X,L]),f.useLayoutEffect(()=>{F.current=z},[z]),f.useEffect(()=>{t&&!P.current&&(ne.current=D.current,R(!0)),t&&!F.current&&(F.current=!0,U(!0)),P.current&&k.current===`standard`&&$(K(t),()=>{!T.current&&k.current===`standard`&&Y()})},[Y,t,$]),f.useLayoutEffect(()=>{!L||k.current!==`standard`||$(+!!t,()=>{!T.current&&k.current===`standard`&&Y()})},[Y,L,t,$]),f.useEffect(()=>{if(!(!z||q))return window.dispatchEvent(new Event(`yuri:mobile-overlay-opened`)),()=>{window.dispatchEvent(new Event(`yuri:mobile-overlay-closed`))}},[z,q]),f.useEffect(()=>{if(!(!z||q))return d.add({id:e,onClose:()=>E.current(!1)},document.body)},[z,e,q]),f.useEffect(()=>{if(!z||q||!J)return;let e=C.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null;w.current?.focus({preventScroll:!0});let n=t=>{if(t.key===`Escape`&&d.closeTop(),t.key!==`Tab`||!e)return;let n=Array.from(e.querySelectorAll(Ce)).filter(e=>!e.closest(`[data-mobile-sheet-snap-handle]`)),r=n[0]??w.current,i=n.at(-1)??w.current;!r||!i||(t.shiftKey&&document.activeElement===r&&(t.preventDefault(),i.focus({preventScroll:!0})),!t.shiftKey&&document.activeElement===i&&(t.preventDefault(),r.focus({preventScroll:!0})))};return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n),v()||t?.focus({preventScroll:!0})}},[z,q,J]),I.current={begin:e=>{if(e===`dismiss`&&(!F.current||k.current===`interactive-present`))return!1;ge(),j.current+=1,M.current=!0,A.current=e;let t=e===`present`?`interactive-present`:`interactive-dismiss`;return k.current=t,ce(t),de(!0),e===`present`&&(ne.current=D.current,F.current=!0,U(!0),R(!0)),!0},update:e=>{M.current&&(ne.current=G(A.current,e),O.current===null&&(O.current=window.requestAnimationFrame(()=>{O.current=null,M.current&&X(ne.current)})))},finish:e=>{if(!M.current)return;M.current=!1;let t=j.current,n=A.current,r=oe(n,e);O.current!==null&&(he(),X(ne.current)),$(r,()=>{t===j.current&&(e===`commit`&&E.current(n===`present`),n===`present`&&e===`cancel`&&!T.current&&Y(),k.current=`standard`,ce(`standard`),r===0&&Y())})},interrupt:()=>{j.current+=1,M.current=!1;let e=k.current===`interactive-present`&&!T.current;e||(k.current=`standard`,ce(`standard`)),ge(),$(K(T.current),()=>{T.current||Y(),e&&(k.current=`standard`,ce(`standard`))})}},f.useLayoutEffect(()=>{let e=N.current;N.current=t,e&&!t&&k.current!==`standard`&&I.current?.interrupt()},[t]),f.useEffect(()=>{let t=ue(e,{begin:e=>I.current?.begin(e)??!1,update:e=>I.current?.update(e),finish:e=>I.current?.finish(e),interrupt:()=>I.current?.interrupt()});return()=>{t(),he(),Q(),ie.current=null,Z(),I.current=null}},[Q,he,Z,e]),!L||!x.current)return null;let _e=(0,m.jsx)(`div`,{ref:S,className:s(`yuri-mobile-window-motion yuri-keyboard-inset-surface fixed inset-0 z-[60] flex flex-col bg-[rgb(0_0_0_/_0.45)]`,le&&`yuri-mobile-window-motion-active`,!z&&!q&&`pointer-events-none invisible`,l,c),"data-mobile-overlay-active":String(z),role:q?void 0:`dialog`,"aria-label":q?void 0:b,"aria-modal":z&&J?`true`:void 0,"aria-hidden":q||!z||!J||void 0,inert:q||!z||!J||void 0,onPointerDown:B,onClick:e=>{!z||q||!J||V(e)&&E.current(!1)},children:(0,m.jsxs)(`div`,{ref:me,className:s(`yuri-mobile-floating-shell`,ae(i,a),u),"data-yuri-motion-id":e,style:{contain:`layout paint style`},onClick:e=>e.stopPropagation(),children:[(0,m.jsx)(`span`,{ref:w,tabIndex:-1,className:`sr-only`,role:`group`,"aria-label":b}),(0,m.jsx)(H.Provider,{value:J,children:o})]})});return(0,h.createPortal)(_e,x.current)},De=f.createContext(null),Oe=e=>{let t=(0,p.c)(5),{children:n}=e,r=f.useContext(De);if(!r)return null;let i;t[0]===n?i=t[1]:(i=(0,m.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,h.createPortal)(i,r),t[2]=r,t[3]=i,t[4]=a):a=t[4],a},ke=e=>{let t=(0,p.c)(50),{id:n,open:r,onOpenChange:i,title:a,leading:c,trailing:l,ariaLabel:d,closeAriaLabel:h,showCloseButton:g,compactHeader:_,resizeAriaLabel:v,initiallyExpanded:y,fitContent:b,bodyClassName:x,className:S,children:C}=e,w=g===void 0||g,T=_!==void 0&&_,E=y!==void 0&&y,ee=b!==void 0&&b,te=E?j:void 0,D;t[0]!==i||t[1]!==r?(D=r?()=>i(!1):void 0,t[0]=i,t[1]=r,t[2]=D):D=t[2];let ne;t[3]!==ee||t[4]!==te||t[5]!==D?(ne={initialSnapPoint:te,fitContent:ee,onDismiss:D},t[3]=ee,t[4]=te,t[5]=D,t[6]=ne):ne=t[6];let O=F(ne),[re,ie]=f.useState(null),k=a!=null||c!=null||l!=null,A=O.snapPoint===j,M=A||!ee,N;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(N={reservedTargetSelector:`[data-mobile-sheet-snap-handle]`},t[7]=N):N=t[7];let P=A?`h-[98dvh] max-h-[98dvh]`:ee?`h-auto max-h-[72dvh]`:`h-[72dvh] max-h-[98dvh]`,L=O.surfaceRef,R=O.reset,z=M&&`flex-1`,B;t[8]===z?B=t[9]:(B=s(`flex min-h-0 flex-col`,z),t[8]=z,t[9]=B);let V;t[10]!==T||t[11]!==v||t[12]!==O?(V=(0,m.jsx)(I,{controller:O,ariaLabel:v,compact:T}),t[10]=T,t[11]=v,t[12]=O,t[13]=V):V=t[13];let H;t[14]!==h||t[15]!==T||t[16]!==ee||t[17]!==k||t[18]!==c||t[19]!==i||t[20]!==w||t[21]!==a||t[22]!==l?(H=k?(0,m.jsxs)(`div`,{"data-mobile-sheet-header":!0,className:T?`flex min-h-6 items-center gap-2 px-3 text-xs`:ee?`flex min-h-9 items-center gap-2 px-4 pb-1`:`flex min-h-10 items-center gap-2 px-4 pb-2`,children:[c?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center`,children:c}):null,(0,m.jsx)(`div`,{className:s(`min-w-0 flex-1`,T&&`truncate`),children:a}),l?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:l}):null,(0,m.jsx)(`div`,{ref:ie,className:`contents`}),w?(0,m.jsx)(o,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i(!1),"aria-label":h,className:`shrink-0 text-muted-foreground`,style:{touchAction:`manipulation`},children:(0,m.jsx)(u,{name:`close`,className:`size-5`})}):null]}):null,t[14]=h,t[15]=T,t[16]=ee,t[17]=k,t[18]=c,t[19]=i,t[20]=w,t[21]=a,t[22]=l,t[23]=H):H=t[23];let ae;t[24]!==V||t[25]!==H?(ae=(0,m.jsxs)(`div`,{className:`shrink-0`,children:[V,H]}),t[24]=V,t[25]=H,t[26]=ae):ae=t[26];let U=M&&`flex-1`,W;t[27]!==x||t[28]!==U?(W=s(`flex min-h-0 flex-col overflow-hidden`,U,x),t[27]=x,t[28]=U,t[29]=W):W=t[29];let G;t[30]!==C||t[31]!==W?(G=(0,m.jsx)(`div`,{className:W,"data-page-scroll-lock":`true`,children:C}),t[30]=C,t[31]=W,t[32]=G):G=t[32];let oe;t[33]!==B||t[34]!==ae||t[35]!==G?(oe=(0,m.jsxs)(`div`,{className:B,children:[ae,G]}),t[33]=B,t[34]=ae,t[35]=G,t[36]=oe):oe=t[36];let K;t[37]!==d||t[38]!==S||t[39]!==n||t[40]!==i||t[41]!==r||t[42]!==O.reset||t[43]!==O.surfaceRef||t[44]!==oe||t[45]!==P?(K=(0,m.jsx)(Ee,{id:n,className:S,open:r,onOpenChange:i,presentation:`sheet`,edge:`bottom`,dismissGesture:N,ariaLabel:d,surfaceClassName:P,surfaceElementRef:L,onExitComplete:R,children:oe}),t[37]=d,t[38]=S,t[39]=n,t[40]=i,t[41]=r,t[42]=O.reset,t[43]=O.surfaceRef,t[44]=oe,t[45]=P,t[46]=K):K=t[46];let se;return t[47]!==re||t[48]!==K?(se=(0,m.jsx)(De.Provider,{value:re,children:K}),t[47]=re,t[48]=K,t[49]=se):se=t[49],se};export{_ as C,v as S,I as _,pe as a,E as b,me as c,le as d,H as f,V as g,B as h,X as i,he as l,R as m,Oe as n,Y as o,z as p,Ee as r,Z as s,ke as t,se as u,j as v,y as x,F as y};
|