@yuriai/web 0.2.0-beta.7 → 0.2.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/assets/{AgentAvatar-CMpCBSy_.js → AgentAvatar-RbwoyGL7.js} +1 -1
- package/dist/assets/{AssistantView-CfyUDUVG.js → AssistantView-CTu_YqYq.js} +3 -3
- package/dist/assets/{DiagramView-CZg5AAli.js → DiagramView-BIhEoeWx.js} +1 -1
- package/dist/assets/{FadeInOnReveal-ANDXEIE7.js → FadeInOnReveal-Dt1nUq5y.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CqqJymvB.js → GuiPluginSurface-68HtzOv6.js} +1 -1
- package/dist/assets/{GuiPluginWindow-B2G2-nAK.js → GuiPluginWindow-CMUyR2_9.js} +1 -1
- package/dist/assets/{Icon-DgrlwLKs.js → Icon-GJTjieJN.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-DdaN0XMj.js → ImageLoadingPlaceholder-C4VZA5iQ.js} +1 -1
- package/dist/assets/{LoadingImage-BJc5SC-0.js → LoadingImage-BZjPXN_m.js} +1 -1
- package/dist/assets/{MarkdownRenderer-DZwskKzl.js → MarkdownRenderer-DnCTLWjR.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BQhcJNsK.js → MarkdownRendererImpl-C8HsL6On.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-CsURmqQY.js → MarkstreamRendererImpl-B1M5pAJe.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CH4Oyt33.js → MobileDetailNavigation-BdSsbh04.js} +1 -1
- package/dist/assets/MobileResizableSheet-B8kpq7AR.js +1 -0
- package/dist/assets/{MobileShareBridge-DEDl3YCM.js → MobileShareBridge-r5Q2J_Sc.js} +2 -2
- package/dist/assets/{MobileTabPageHeader-C7Bkm6-_.js → MobileTabPageHeader-BRtaISjE.js} +1 -1
- package/dist/assets/{MultiRunWindow-DI0-Ur1w.js → MultiRunWindow-BPORsCa7.js} +1 -1
- package/dist/assets/{OnboardingScreen-BH__JnO0.js → OnboardingScreen-BssiDW_8.js} +1 -1
- package/dist/assets/{OverlayScrollbar-bByT588g.js → OverlayScrollbar-DWZJpEVx.js} +1 -1
- package/dist/assets/SettingsView-BxRekjws.js +26 -0
- package/dist/assets/{SettingsWindow-BJQyV3do.js → SettingsWindow-BsEMguoj.js} +1 -1
- package/dist/assets/{TerminalView-DRwLYPvJ.js → TerminalView-6hKAHFJ7.js} +1 -1
- package/dist/assets/{ToolOutputDialog-O25CmHgA.js → ToolOutputDialog-CkZORaFS.js} +1 -1
- package/dist/assets/{YuriLogo-Qr_mhaKp.js → YuriLogo-jfvSPXYV.js} +1 -1
- package/dist/assets/{appThemeRegistry-B-rbBHC4.js → appThemeRegistry-DdmE_Iv3.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-DNbxU1Fq.js → assistant-attachment-cache-DWMcn4cE.js} +1 -1
- package/dist/assets/{button-BuhP8T0R.js → button-BgnrCA96.js} +1 -1
- package/dist/assets/{capgoAdapter-BgDvFDUs.js → capgoAdapter-Czek7cOG.js} +1 -1
- package/dist/assets/{collapsible-CwLF0o1c.js → collapsible-gafrZ0Tr.js} +1 -1
- package/dist/assets/desktop-dp2Z0toS.js +1 -0
- package/dist/assets/{desktopHosts-CjH4TGh8.js → desktopHosts-ByGjetLz.js} +1 -1
- package/dist/assets/{desktopRelayRestore-BLJo3sm7.js → desktopRelayRestore-DIO6vl1K.js} +1 -1
- package/dist/assets/{device-BVEAUyle.js → device-Dd4YwDwq.js} +1 -1
- package/dist/assets/{diagram-BIYywJNf.js → diagram-BIjHGw1_.js} +1 -1
- package/dist/assets/{dialog-BUEUatKm.js → dialog-D6jRorvP.js} +1 -1
- package/dist/assets/{dropdown-menu.styles-tzNMk1yW.js → dropdown-menu.styles-BKQriop5.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-C6ylhQkG.js → fileMentionTouchSelection-BSSggGfQ.js} +1 -1
- package/dist/assets/{fileReferenceActions-DuYvTiGf.js → fileReferenceActions-D625rOTl.js} +1 -1
- package/dist/assets/{gitApi-4JPWt45Y.js → gitApi-BkhGiTtu.js} +1 -1
- package/dist/assets/gui-BCPFcL_m.js +1 -0
- package/dist/assets/host-C6DQGHTV.js +1 -0
- package/dist/assets/{image-loading-CU4V_A1c.js → image-loading-Ctpxfqla.js} +1 -1
- package/dist/assets/{input-BVgNVYou.js → input-CDVEeuDT.js} +1 -1
- package/dist/assets/{insertionBoundaries-BSPv205d.js → insertionBoundaries-8-NDZp_y.js} +1 -1
- package/dist/assets/{main-CETRwACI.js → main-C6Yw42Pk.js} +12 -12
- package/dist/assets/{main-foDhMZ24.js → main-UQKItVb4.js} +2 -2
- package/dist/assets/{markdownHeightCache-BceTKVDK.js → markdownHeightCache-Dv5LnHPc.js} +1 -1
- package/dist/assets/{mcpQueries-AswEbyXP.js → mcpQueries-CyI_Hol5.js} +1 -1
- package/dist/assets/miniChat-tf1jH68G.js +2 -0
- package/dist/assets/mobile-C7dS2AHt.js +2 -0
- package/dist/assets/{mobileBackNavigation-C03Z5phB.js → mobileBackNavigation-Bcg-mihS.js} +1 -1
- package/dist/assets/{multirun-CWGx21Ol.js → multirun-xh4jfDx_.js} +1 -1
- package/dist/assets/native-BMAEg2E6.js +1 -0
- package/dist/assets/{native-config-DC-Ccre6.js → native-config-CKpFI_5o.js} +1 -1
- package/dist/assets/native-errors-06if6eu-.js +1 -0
- package/dist/assets/{persistence-D-W3L37Z.js → persistence-BfjCXjLZ.js} +1 -1
- package/dist/assets/{platform-CQG2KlHW.js → platform-Dcd-lkPn.js} +3 -3
- package/dist/assets/{projectMeta-6Sbr-Iiw.js → projectMeta-QJd1QrkI.js} +1 -1
- package/dist/assets/readiness-C1vgtBOT.js +1 -0
- package/dist/assets/{renderElectronMiniChatApp-CQHm04xq.js → renderElectronMiniChatApp-B84E6SfM.js} +2 -2
- package/dist/assets/{renderMobileApp-D4lOGRzz.js → renderMobileApp-PhdK6y6v.js} +4 -4
- package/dist/assets/{runtime-file-download-BdNCQkDe.js → runtime-file-download-CwP-HoXN.js} +1 -1
- package/dist/assets/{runtime-file-resource-DdAheq3y.js → runtime-file-resource-h3yIw4HU.js} +1 -1
- package/dist/assets/{runtime-file-store-hFlndg-n.js → runtime-file-store-BVRgEtI-.js} +1 -1
- package/dist/assets/runtimeConfig-CJCKi9-y.js +2 -0
- package/dist/assets/runtimeEndpointReset-Dxl8XtfH.js +149 -0
- package/dist/assets/{scheduledTaskNavigation-Cy2nZl_A.js → scheduledTaskNavigation-B7WhY2Fp.js} +1 -1
- package/dist/assets/{sessionChangeSummary-C70M_uHA.js → sessionChangeSummary-CY9vQ5i1.js} +1 -1
- package/dist/assets/{sessionLookup-CCOa3Jeq.js → sessionLookup-D1uJyExH.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CAkRGa2f.js → sortable-tabs-strip-C4STfRdG.js} +1 -1
- package/dist/assets/{speechSettingsQueries-CIcSgao2.js → speechSettingsQueries-tUWgMwuK.js} +2 -2
- package/dist/assets/src-r07HspQy.css +2 -0
- package/dist/assets/{terminalApi-DY0KJOiK.js → terminalApi-CJx_hK4K.js} +1 -1
- package/dist/assets/{textarea-BLvbQAIG.js → textarea-DI9j9018.js} +1 -1
- package/dist/assets/{tooltip-jf98dFQe.js → tooltip-BHHwyMVd.js} +1 -1
- package/dist/assets/{types-D5ocrnEK.js → types-BmLypFZI.js} +1 -1
- package/dist/assets/{useAppFontEffects-DSR2ev_Q.js → useAppFontEffects-BeFXBNUc.js} +16 -16
- package/dist/assets/{useDesktopWindowControlsLayout-pyawlD_R.js → useDesktopWindowControlsLayout-BkdDy7r3.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-W6wf50T7.js → useEffectiveDirectory-RivT6KwZ.js} +1 -1
- package/dist/assets/{useFontPreferences-CH3iNDUl.js → useFontPreferences-Bwzz0JNf.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BTF3FUmY.js → useMobileNavigationStore-BQHfCZ55.js} +8 -8
- package/dist/assets/{useWorkerHighlightedLines-Dhr3xUQY.js → useWorkerHighlightedLines-BszN5sdj.js} +1 -1
- package/dist/assets/{vendor-effect-DXlObQuU.js → vendor-effect-DV9F8PTZ.js} +1 -1
- package/dist/assets/vendor-opencode-client-fxfj4IA_.js +12 -0
- package/dist/assets/{vendor-opencode-plugin-BglYYlJt.js → vendor-opencode-plugin-CQ5ogY33.js} +1 -1
- package/dist/assets/{vendor-solid-js-B2FO7pdm.js → vendor-solid-js-Dmt4_-Zk.js} +1 -1
- package/dist/index.html +17 -17
- package/dist/mini-chat.html +17 -17
- package/dist/mobile.html +17 -17
- package/package.json +1 -1
- package/server/index.d.ts +2 -0
- package/server/index.js +8 -1
- package/server/lib/content-search/DOCUMENTATION.md +5 -1
- package/server/lib/content-search/runtime.js +24 -0
- package/server/lib/content-search/runtime.test.js +19 -0
- package/server/lib/opencode/DOCUMENTATION.md +5 -0
- package/server/lib/opencode/gui-plugin-source.js +14 -0
- package/server/lib/opencode/gui-plugin-source.test.js +28 -0
- package/server/lib/opencode/plugin-gui-response.d.ts +7 -0
- package/server/lib/opencode/plugin-gui-response.js +62 -0
- package/server/lib/opencode/plugin-gui-response.test.js +89 -0
- package/server/lib/opencode/proxy.js +32 -0
- package/server/lib/relay/DOCUMENTATION.md +1 -0
- package/server/lib/request-cors.js +2 -2
- package/server/lib/request-cors.test.js +3 -0
- package/server/lib/session-index/DOCUMENTATION.md +4 -0
- package/server/lib/session-index/sync-runtime.js +3 -0
- package/server/lib/session-index/sync-runtime.test.js +18 -0
- package/server/plugin-gui-proxy.test.js +134 -0
- package/dist/assets/MobileResizableSheet-xE71zG4E.js +0 -1
- package/dist/assets/SettingsView-BVmOocRh.js +0 -26
- package/dist/assets/desktop-DpAcrF1h.js +0 -1
- package/dist/assets/gui-B56BgPNQ.js +0 -1
- package/dist/assets/host-Bs4ljApp.js +0 -1
- package/dist/assets/miniChat-Dsodcwqi.js +0 -2
- package/dist/assets/mobile-C4F47gek.js +0 -2
- package/dist/assets/readiness-DWh0yJFu.js +0 -1
- package/dist/assets/runtimeConfig-5btjngJ7.js +0 -2
- package/dist/assets/runtimeEndpointReset-NHpx5wGb.js +0 -149
- package/dist/assets/src-BR-siHj2.css +0 -2
- package/dist/assets/vendor-opencode-client-BcpAhe9I.js +0 -12
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { preparePluginGuiRequest, projectPluginGuiResponse } from './plugin-gui-response.js';
|
|
4
|
+
|
|
5
|
+
const revision = 'revision-with-private-path';
|
|
6
|
+
const token = createHash('sha256').update(revision).digest('hex');
|
|
7
|
+
const envelope = { location: { directory: '/workspace' }, data: { code: 'module.exports = {};', revision, options: { key: 'current-value' } } };
|
|
8
|
+
const response = (value, status = 200) => new Response(JSON.stringify(value), {
|
|
9
|
+
status, headers: { 'content-type': 'application/json', 'x-upstream': 'kept', etag: 'upstream-etag' },
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe('GUI code-only revision protocol', () => {
|
|
13
|
+
it('is exact GET with one nonempty id and strips only GUI/conditional request controls', () => {
|
|
14
|
+
for (const [method, path] of [
|
|
15
|
+
['POST', '/api/plugin/gui?id=x'], ['HEAD', '/api/plugin/gui?id=x'],
|
|
16
|
+
['GET', '/api/plugin/gui/child?id=x'], ['GET', '/api/plugin/gui/?id=x'],
|
|
17
|
+
['GET', '/api/plugin'], ['GET', '/api/plugin/gui'], ['GET', '/api/plugin/gui?id='],
|
|
18
|
+
['GET', '/api/plugin/gui?id=x&id=y'],
|
|
19
|
+
]) expect(preparePluginGuiRequest(method, path, {})).toBeNull();
|
|
20
|
+
const headers = { 'X-Yuri-Gui-Revision': token, 'If-None-Match': 'old', 'If-Modified-Since': 'yesterday',
|
|
21
|
+
Range: 'bytes=0-20', Authorization: 'upstream-auth', 'x-opencode-directory': '/workspace', accept: 'application/json' };
|
|
22
|
+
expect(preparePluginGuiRequest('GET', '/api/plugin/gui?id=x&location%5Bdirectory%5D=%2Fworkspace', headers)).toEqual({
|
|
23
|
+
revision: token, headers: { Authorization: 'upstream-auth', 'x-opencode-directory': '/workspace', accept: 'application/json', 'accept-encoding': 'identity' },
|
|
24
|
+
});
|
|
25
|
+
expect(headers['If-None-Match']).toBe('old');
|
|
26
|
+
for (const value of ['*', token.toUpperCase(), '"' + token + '"', 'not-a-token']) {
|
|
27
|
+
expect(preparePluginGuiRequest('GET', '/api/plugin/gui?id=x', { 'x-yuri-gui-revision': value }).revision).toBeNull();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('keeps original bytes without opt-in and returns only a hashed revision', async () => {
|
|
32
|
+
const raw = JSON.stringify(envelope, null, 2) + '\n';
|
|
33
|
+
const result = await projectPluginGuiResponse(new Response(raw, { headers: { 'content-type': 'application/json' } }), null);
|
|
34
|
+
expect(await result.text()).toBe(raw);
|
|
35
|
+
expect(result.headers.get('x-yuri-gui-revision')).toBe(token);
|
|
36
|
+
expect(result.headers.get('x-yuri-gui-code')).toBeNull();
|
|
37
|
+
expect(result.headers.get('cache-control')).toBe('private, no-store');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('omits only code on a matching revision, retaining fresh options and all envelope fields', async () => {
|
|
41
|
+
for (const options of [{ key: 'new-value' }, { changed: [1, null] }]) {
|
|
42
|
+
const input = { ...envelope, extra: 1, data: { ...envelope.data, options, extra: true } };
|
|
43
|
+
const result = await projectPluginGuiResponse(response(input), token);
|
|
44
|
+
expect(result.status).toBe(200);
|
|
45
|
+
expect(result.headers.get('x-yuri-gui-code')).toBe('cached');
|
|
46
|
+
expect(result.headers.get('etag')).toBeNull();
|
|
47
|
+
expect(result.headers.get('x-upstream')).toBe('kept');
|
|
48
|
+
expect(await result.json()).toEqual({ ...input, data: { ...input.data, code: '' } });
|
|
49
|
+
}
|
|
50
|
+
const changed = { ...envelope, data: { ...envelope.data, revision: 'new-revision' } };
|
|
51
|
+
const result = await projectPluginGuiResponse(response(changed), token);
|
|
52
|
+
expect(result.headers.get('x-yuri-gui-code')).toBeNull();
|
|
53
|
+
expect(result.headers.get('x-yuri-gui-revision')).not.toBe(token);
|
|
54
|
+
expect(await result.json()).toEqual(changed);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it.each([401, 403, 404, 429, 500, 503])('never replaces upstream %i with historical success', async (status) => {
|
|
58
|
+
const upstream = response(envelope, status);
|
|
59
|
+
expect(await projectPluginGuiResponse(upstream, token)).toBe(upstream);
|
|
60
|
+
expect(await upstream.json()).toEqual(envelope);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it.each([
|
|
64
|
+
{ ...envelope.data, code: 1 }, { ...envelope.data, revision: '' },
|
|
65
|
+
{ ...envelope.data, revision: null }, { ...envelope.data, options: null },
|
|
66
|
+
{ ...envelope.data, options: [] }, { code: 'x', revision },
|
|
67
|
+
])('does not issue a revision receipt for malformed bundles: %j', async (data) => {
|
|
68
|
+
const input = { ...envelope, data };
|
|
69
|
+
const result = await projectPluginGuiResponse(response(input), token);
|
|
70
|
+
expect(result.headers.get('x-yuri-gui-revision')).toBeNull();
|
|
71
|
+
expect(result.headers.get('x-yuri-gui-code')).toBeNull();
|
|
72
|
+
expect(await result.json()).toEqual(input);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('preserves malformed JSON and non-JSON success bytes without a receipt', async () => {
|
|
76
|
+
for (const [body, contentType] of [['{invalid', 'application/json'], ['<html>not a GUI</html>', 'text/html']]) {
|
|
77
|
+
const result = await projectPluginGuiResponse(new Response(body, { headers: { 'content-type': contentType } }), token);
|
|
78
|
+
expect(await result.text()).toBe(body);
|
|
79
|
+
expect(result.headers.get('x-yuri-gui-code')).toBeNull();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('does not hide a failed body read behind a matching revision', async () => {
|
|
84
|
+
const upstream = new Response(new ReadableStream({
|
|
85
|
+
start(controller) { controller.error(new Error('upstream body failed')); },
|
|
86
|
+
}), { headers: { 'content-type': 'application/json' } });
|
|
87
|
+
await expect(projectPluginGuiResponse(upstream, token)).rejects.toThrow('upstream body failed');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createProxyMiddleware } from 'http-proxy-middleware';
|
|
2
2
|
import { isSensitiveCredentialResponse } from './credential-boundary.js';
|
|
3
|
+
import { preparePluginGuiRequest, projectPluginGuiResponse } from './plugin-gui-response.js';
|
|
3
4
|
import { registerSessionDeliveryRoute } from './session-delivery-runtime.js';
|
|
4
5
|
import { stripSessionMessageNativePayload } from '../session-turn-pages/native-payload.js';
|
|
5
6
|
|
|
@@ -1363,5 +1364,36 @@ export const registerOpenCodeProxy = (app, deps) => {
|
|
|
1363
1364
|
});
|
|
1364
1365
|
|
|
1365
1366
|
app.use('/api', applyProxyResponseDeadline);
|
|
1367
|
+
app.use('/api', async (req, res, next) => {
|
|
1368
|
+
if (req.method !== 'GET' || req.path !== '/plugin/gui') return next();
|
|
1369
|
+
const upstreamPath = toUpstreamOpenCodeApiPath(req.url);
|
|
1370
|
+
const gui = preparePluginGuiRequest(req.method, upstreamPath, normalizeForwardedDirectoryHeaders(
|
|
1371
|
+
collectForwardProxyHeaders(req.headers, getOpenCodeAuthHeaders()),
|
|
1372
|
+
));
|
|
1373
|
+
if (!gui) return next();
|
|
1374
|
+
|
|
1375
|
+
const controller = new AbortController();
|
|
1376
|
+
const abort = () => controller.abort();
|
|
1377
|
+
req.once('aborted', abort);
|
|
1378
|
+
res.once('close', abort);
|
|
1379
|
+
try {
|
|
1380
|
+
const upstream = await fetch(buildOpenCodeUrl(upstreamPath, ''), {
|
|
1381
|
+
method: req.method, headers: gui.headers, signal: controller.signal, redirect: 'manual',
|
|
1382
|
+
});
|
|
1383
|
+
const response = await projectPluginGuiResponse(upstream, gui.revision);
|
|
1384
|
+
const body = Buffer.from(await response.arrayBuffer());
|
|
1385
|
+
if (res.writableEnded || res.destroyed) return;
|
|
1386
|
+
res.status(response.status);
|
|
1387
|
+
applyForwardProxyResponseHeaders(response.headers, res);
|
|
1388
|
+
res.end(body);
|
|
1389
|
+
} catch (error) {
|
|
1390
|
+
if (!controller.signal.aborted && !req[PROXY_TIMEOUT_MARKER]) {
|
|
1391
|
+
sendProxyErrorResponse(res, isProxyTimeoutError(error) ? 504 : 503);
|
|
1392
|
+
}
|
|
1393
|
+
} finally {
|
|
1394
|
+
req.off('aborted', abort);
|
|
1395
|
+
res.off('close', abort);
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1366
1398
|
app.use('/api', apiProxy);
|
|
1367
1399
|
};
|
|
@@ -55,6 +55,7 @@ Private Relay is transparent for allowlisted HTTP paths, so most “works on LAN
|
|
|
55
55
|
|
|
56
56
|
- **Same path, real Host route required.** Clients call the ordinary `/api/...` path through the tunnel. If that route is missing on the Host process currently holding the relay claim (wrong git worktree, stale packaged Desktop build, or a backend that never registered the Yuri route before the OpenCode proxy/SPA fallback), the tunnel still returns HTTP 200 with SPA HTML or proxied OpenCode content. Symptom: chat and status work, Provider/model catalog does not.
|
|
57
57
|
- **HTTP allowlist is prefix-based for `/api/`.** New REST/SSE APIs under `/api/` do not need a tunnel-host allowlist edit. New **WebSocket** paths still need both tunnel-host allowlisting (`isTunnelWsPathAllowed` / exact `ALLOWED_WS_PATHS`, plus the **`/api/preview/proxy/` prefix** for Preview HMR only) and `isUrlAuthWebSocketPath` (see the `relay-transport` skill). Config sync (`/api/yuri/config-sync/*`, ticket 05/06) therefore works over Relay without a tunnel-host allowlist change; identity and credential grants remain endpoint concerns (`relay:<serverId>`, pairing-settings / inbound host grant).
|
|
58
|
+
- GUI code reuse uses the same `GET /api/plugin/gui?id=…` path: the tunnel preserves `X-Yuri-Gui-Revision` requests and `X-Yuri-Gui-Revision` / `X-Yuri-Gui-Code` responses. The authenticated Host still fetches upstream on each call; matching responses are 200 with current options and empty code, never a tunnel-cached bundle or 304. `Cache-Control: private, no-store` crosses unchanged. The Web GUI proxy integration test exercises this actual dispatcher path.
|
|
58
59
|
- **Transport identity ≠ runtime key.** After LAN⇄relay swaps, UI catalog loaders commit only when `useConfigStore.catalogTransportIdentity` matches `getRuntimeTransportIdentity()`. `runtimeEndpointReset.ts` must write that transport fingerprint on both full endpoint reset and in-place transport reconnect. Writing `runtimeKey` instead leaves Providers empty because the stable device/instance id is shared across LAN and relay.
|
|
59
60
|
- **Safe catalog projection stays Host-owned.** Provider credentials never cross the browser; Relay only carries the already-allowlisted `GET /api/config/catalog/providers` JSON. Keep Host projection, client parser bounds, and `partial` rules in sync (empty `release_date` is absent, not partial).
|
|
60
61
|
|
|
@@ -4,12 +4,12 @@ export const applyRuntimeCorsHeaders = ({ origin, setHeader }) => {
|
|
|
4
4
|
setHeader('Access-Control-Allow-Origin', origin);
|
|
5
5
|
setHeader('Access-Control-Allow-Credentials', 'true');
|
|
6
6
|
setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,DELETE,OPTIONS');
|
|
7
|
-
setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization,Accept,X-Requested-With,Cache-Control,X-OpenCode-Directory,X-OpenCode-Directory-Encoding,X-Message-Queue-Upload-Token,X-Message-Queue-Sha256,X-Message-Queue-Content-Length,X-Yuri-Content-Length,X-Yuri-Sha256,X-Yuri-Mime,X-Yuri-Filename');
|
|
7
|
+
setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization,Accept,X-Requested-With,Cache-Control,X-OpenCode-Directory,X-OpenCode-Directory-Encoding,X-Message-Queue-Upload-Token,X-Message-Queue-Sha256,X-Message-Queue-Content-Length,X-Yuri-Content-Length,X-Yuri-Sha256,X-Yuri-Mime,X-Yuri-Filename,X-Yuri-Gui-Revision');
|
|
8
8
|
// Packaged clients (Electron yuri-ui://app, Capacitor, Vite HMR) are
|
|
9
9
|
// cross-origin to the runtime API. Without an expose list, browsers hide
|
|
10
10
|
// custom response headers from JS — including the optional-read existence
|
|
11
11
|
// marker that FilesAPI.readFile({ optional: true }) requires.
|
|
12
|
-
setHeader('Access-Control-Expose-Headers', 'x-next-cursor, x-yuri-file-exists, x-speech-pitch, x-speech-volume');
|
|
12
|
+
setHeader('Access-Control-Expose-Headers', 'x-next-cursor, x-yuri-file-exists, x-speech-pitch, x-speech-volume, x-yuri-gui-revision, x-yuri-gui-code');
|
|
13
13
|
setHeader('Access-Control-Max-Age', PREFLIGHT_CACHE_SECONDS);
|
|
14
14
|
setHeader('Vary', 'Origin');
|
|
15
15
|
};
|
|
@@ -18,6 +18,9 @@ describe('applyRuntimeCorsHeaders', () => {
|
|
|
18
18
|
expect(headers.get('Access-Control-Allow-Headers')).toContain('X-Yuri-Sha256');
|
|
19
19
|
expect(headers.get('Access-Control-Allow-Headers')).toContain('X-Yuri-Content-Length');
|
|
20
20
|
expect(headers.get('Access-Control-Allow-Headers')).toContain('X-Yuri-Filename');
|
|
21
|
+
expect(headers.get('Access-Control-Allow-Headers')).toContain('X-Yuri-Gui-Revision');
|
|
22
|
+
expect(headers.get('Access-Control-Expose-Headers')).toContain('x-yuri-gui-revision');
|
|
23
|
+
expect(headers.get('Access-Control-Expose-Headers')).toContain('x-yuri-gui-code');
|
|
21
24
|
expect(headers.get('Access-Control-Expose-Headers')).toContain('x-next-cursor');
|
|
22
25
|
expect(headers.get('Access-Control-Expose-Headers')).toContain('x-yuri-file-exists');
|
|
23
26
|
});
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Session Index Runtime
|
|
2
2
|
|
|
3
|
+
Directory refresh retains its previous snapshot when the pagination budget is
|
|
4
|
+
exhausted before filling the visible root limit. Filtered global pages with a
|
|
5
|
+
continuation are partial results, not authoritative empty directories.
|
|
6
|
+
|
|
3
7
|
## Missing local directories
|
|
4
8
|
|
|
5
9
|
The Host probes local directory existence asynchronously before background root
|
|
@@ -301,6 +301,9 @@ export const createSessionIndexSyncRuntime = ({
|
|
|
301
301
|
active.push(session);
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
+
if (hitPageBudget && active.length < SESSION_LIMIT) {
|
|
305
|
+
throw new Error('Directory scan incomplete; retaining prior session index');
|
|
306
|
+
}
|
|
304
307
|
const oldest = active[active.length - 1];
|
|
305
308
|
const cursorNumber = lastCursorToken && Number.isFinite(Number(lastCursorToken))
|
|
306
309
|
? Number(lastCursorToken)
|
|
@@ -41,6 +41,24 @@ const isFullyIdle = (runtime) => (
|
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
describe('session index background sync runtime', () => {
|
|
44
|
+
it('preserves prior directory rows when filtered global pages exhaust the scan budget', async () => {
|
|
45
|
+
const service = createService([{ directory: '/repo', sessions: [session('existing', 10)] }]);
|
|
46
|
+
let page = 0;
|
|
47
|
+
const runtime = createSessionIndexSyncRuntime({
|
|
48
|
+
sessionIndexService: service,
|
|
49
|
+
buildOpenCodeUrl: (route) => `http://opencode.test${route}`,
|
|
50
|
+
getOpenCodeAuthHeaders: () => ({}),
|
|
51
|
+
waitForOpenCodeReady: async () => true,
|
|
52
|
+
fetchFn: async () => Response.json({ data: [], cursor: { next: `page-${++page}` } }),
|
|
53
|
+
});
|
|
54
|
+
try {
|
|
55
|
+
runtime.enqueue(['/repo']);
|
|
56
|
+
await waitUntil(() => isFullyIdle(runtime));
|
|
57
|
+
expect(page).toBe(5);
|
|
58
|
+
expect(service.replaceDirectory).not.toHaveBeenCalled();
|
|
59
|
+
expect(service.snapshot().directories[0].sessions[0].id).toBe('existing');
|
|
60
|
+
} finally { runtime.stop(); }
|
|
61
|
+
});
|
|
44
62
|
it('does not probe indexed directories at startup', async () => {
|
|
45
63
|
const service = createService([{ directory: '/repo', sessions: [], hasMore: false }]);
|
|
46
64
|
service.removeEmptyDirectory = vi.fn(() => true);
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import { gzipSync } from 'node:zlib';
|
|
4
|
+
import { registerOpenCodeProxy } from './lib/opencode/proxy.js';
|
|
5
|
+
import { createTunnelHost } from './lib/relay/tunnel-host.js';
|
|
6
|
+
import { TunnelFrameType, decodeTunnelFrame, encodeJsonPayload, encodeTunnelFrame } from './lib/relay/tunnel-codec.js';
|
|
7
|
+
|
|
8
|
+
const servers = [];
|
|
9
|
+
const listen = async (app) => {
|
|
10
|
+
const server = await new Promise((resolve) => { const listening = app.listen(0, '127.0.0.1', () => resolve(listening)); });
|
|
11
|
+
servers.push(server);
|
|
12
|
+
return server.address().port;
|
|
13
|
+
};
|
|
14
|
+
afterEach(async () => {
|
|
15
|
+
await Promise.all(servers.splice(0).map((server) => new Promise((resolve) => { server.closeAllConnections(); server.close(resolve); })));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const setup = async ({ timeoutMs = 1000 } = {}) => {
|
|
19
|
+
const seen = [];
|
|
20
|
+
const state = { status: 200, revision: 'r1', options: { current: 1 }, compressed: false, stalled: false };
|
|
21
|
+
const upstream = express();
|
|
22
|
+
upstream.all('/api/plugin/gui', (req, res) => {
|
|
23
|
+
seen.push({ method: req.method, url: req.originalUrl, headers: req.headers });
|
|
24
|
+
if (state.stalled) {
|
|
25
|
+
res.set('content-type', 'application/json');
|
|
26
|
+
res.write('{"location":');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const body = JSON.stringify({ location: { directory: '/workspace' }, data: { code: 'x'.repeat(128 * 1024), revision: state.revision, options: state.options } });
|
|
30
|
+
res.status(state.status).set('content-type', 'application/json').set('x-upstream', 'kept');
|
|
31
|
+
if (state.compressed) {
|
|
32
|
+
const compressed = gzipSync(body);
|
|
33
|
+
res.set('content-encoding', 'gzip').set('content-length', String(compressed.length)).end(compressed);
|
|
34
|
+
} else res.end(body);
|
|
35
|
+
});
|
|
36
|
+
const upstreamPort = await listen(upstream);
|
|
37
|
+
const app = express();
|
|
38
|
+
app.use((req, res, next) => req.headers.authorization === 'Bearer client-test' ? next() : res.status(401).end('unauthorized'));
|
|
39
|
+
registerOpenCodeProxy(app, {
|
|
40
|
+
fs: {}, os: {}, path: {}, OPEN_CODE_READY_GRACE_MS: 0, LONG_REQUEST_TIMEOUT_MS: timeoutMs,
|
|
41
|
+
getRuntime: () => ({ openCodePort: upstreamPort, isOpenCodeReady: true }),
|
|
42
|
+
getOpenCodeAuthHeaders: () => ({ Authorization: 'Basic upstream-test' }),
|
|
43
|
+
buildOpenCodeUrl: (path) => `http://127.0.0.1:${upstreamPort}${path}`,
|
|
44
|
+
ensureOpenCodeApiPrefix: () => {},
|
|
45
|
+
});
|
|
46
|
+
const port = await listen(app);
|
|
47
|
+
const requestPath = '/api/plugin/gui?id=plugin%2Fone&location%5Bdirectory%5D=%2Fworkspace';
|
|
48
|
+
const read = (headers = {}) => fetch(`http://127.0.0.1:${port}${requestPath}`, { headers: { Authorization: 'Bearer client-test', ...headers } });
|
|
49
|
+
return { seen, state, port, requestPath, read };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
describe('Web/Electron shared backend GUI response', () => {
|
|
53
|
+
it('times out an incomplete upstream body rather than reusing historical code success', async () => {
|
|
54
|
+
const { read, state, seen } = await setup({ timeoutMs: 100 });
|
|
55
|
+
const first = await read();
|
|
56
|
+
const token = first.headers.get('x-yuri-gui-revision');
|
|
57
|
+
await first.arrayBuffer();
|
|
58
|
+
state.stalled = true;
|
|
59
|
+
const failed = await read({ 'X-Yuri-Gui-Revision': token });
|
|
60
|
+
expect(failed.status).toBe(504);
|
|
61
|
+
expect(failed.headers.get('x-yuri-gui-code')).toBeNull();
|
|
62
|
+
expect(await failed.json()).toEqual({ error: 'OpenCode upstream timed out' });
|
|
63
|
+
expect(seen).toHaveLength(2);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('fetches each full upstream response, preserves query/auth, and transfers fresh options with code reuse', async () => {
|
|
67
|
+
const { read, seen, state, requestPath } = await setup();
|
|
68
|
+
const first = await read();
|
|
69
|
+
const token = first.headers.get('x-yuri-gui-revision');
|
|
70
|
+
expect(token).toMatch(/^[a-f0-9]{64}$/);
|
|
71
|
+
const full = await first.json();
|
|
72
|
+
state.options = { current: 2 };
|
|
73
|
+
state.compressed = true;
|
|
74
|
+
const second = await read({ 'X-Yuri-Gui-Revision': token, 'If-None-Match': '*', 'If-Modified-Since': 'yesterday' });
|
|
75
|
+
expect(second.status).toBe(200);
|
|
76
|
+
expect(second.headers.get('cache-control')).toBe('private, no-store');
|
|
77
|
+
expect(second.headers.get('x-yuri-gui-code')).toBe('cached');
|
|
78
|
+
expect(second.headers.get('content-encoding')).toBeNull();
|
|
79
|
+
expect(second.headers.get('x-upstream')).toBe('kept');
|
|
80
|
+
const thinText = await second.text();
|
|
81
|
+
expect(thinText.length).toBeLessThan(256);
|
|
82
|
+
expect(JSON.parse(thinText)).toEqual({ ...full, data: { ...full.data, code: '', options: { current: 2 } } });
|
|
83
|
+
expect(seen).toHaveLength(2);
|
|
84
|
+
expect(seen[1]).toMatchObject({ method: 'GET', url: requestPath, headers: { authorization: 'Basic upstream-test', 'accept-encoding': 'identity' } });
|
|
85
|
+
expect(seen[1].headers['x-yuri-gui-revision']).toBeUndefined();
|
|
86
|
+
expect(seen[1].headers['if-none-match']).toBeUndefined();
|
|
87
|
+
expect(seen[1].headers['if-modified-since']).toBeUndefined();
|
|
88
|
+
state.revision = 'r2';
|
|
89
|
+
const changed = await read({ 'X-Yuri-Gui-Revision': token });
|
|
90
|
+
expect(changed.headers.get('x-yuri-gui-code')).toBeNull();
|
|
91
|
+
expect((await changed.json()).data.code).toBe(full.data.code);
|
|
92
|
+
state.status = 404;
|
|
93
|
+
const failed = await read({ 'X-Yuri-Gui-Revision': token });
|
|
94
|
+
expect(failed.status).toBe(404);
|
|
95
|
+
expect(failed.headers.get('x-yuri-gui-code')).toBeNull();
|
|
96
|
+
expect((await failed.json()).data.code).toBe(full.data.code);
|
|
97
|
+
expect(seen).toHaveLength(4);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('carries revision headers and current options through the actual relay HTTP path and auth gate', async () => {
|
|
101
|
+
const { read, port, state, requestPath, seen } = await setup();
|
|
102
|
+
const first = await read();
|
|
103
|
+
const token = first.headers.get('x-yuri-gui-revision');
|
|
104
|
+
await first.arrayBuffer();
|
|
105
|
+
state.options = { current: 7 };
|
|
106
|
+
const frames = [];
|
|
107
|
+
let finish;
|
|
108
|
+
const ended = new Promise((resolve) => { finish = resolve; });
|
|
109
|
+
const host = createTunnelHost({ connectionId: 'gui-response', getLocalPort: () => port, getBufferedAmount: () => 0,
|
|
110
|
+
sendFrame: (bytes) => { const frame = decodeTunnelFrame(bytes); frames.push(frame); if (frame.frameType === TunnelFrameType.StreamEnd) finish(); },
|
|
111
|
+
});
|
|
112
|
+
try {
|
|
113
|
+
const url = new URL(requestPath, 'http://yuri.invalid');
|
|
114
|
+
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.HttpRequest, 1, encodeJsonPayload({
|
|
115
|
+
method: 'GET', path: url.pathname, query: url.search.slice(1), acceptEncoding: 'gzip',
|
|
116
|
+
headers: { authorization: 'Bearer client-test', 'x-yuri-gui-revision': token },
|
|
117
|
+
})));
|
|
118
|
+
await ended;
|
|
119
|
+
const head = JSON.parse(new TextDecoder().decode(frames.find((frame) => frame.frameType === TunnelFrameType.HttpResponse).payload));
|
|
120
|
+
expect(head.status).toBe(200);
|
|
121
|
+
expect(head.headers['x-yuri-gui-code']).toBe('cached');
|
|
122
|
+
expect(head.headers['x-yuri-gui-revision']).toBe(token);
|
|
123
|
+
expect(head.headers['cache-control']).toBe('private, no-store');
|
|
124
|
+
const body = new Blob(frames.filter((frame) => frame.frameType === TunnelFrameType.HttpBody).map((frame) => frame.payload));
|
|
125
|
+
const text = head.encoding === 'gzip'
|
|
126
|
+
? await new Response(body.stream().pipeThrough(new DecompressionStream('gzip'))).text() : await body.text();
|
|
127
|
+
expect(JSON.parse(text).data).toEqual({ code: '', revision: 'r1', options: { current: 7 } });
|
|
128
|
+
expect(seen).toHaveLength(2);
|
|
129
|
+
const denied = await fetch(`http://127.0.0.1:${port}${requestPath}`, { headers: { 'X-Yuri-Gui-Revision': token } });
|
|
130
|
+
expect(denied.status).toBe(401);
|
|
131
|
+
expect(seen).toHaveLength(2);
|
|
132
|
+
} finally { host.close(); }
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{it as t,nt as n,rt as r}from"./vendor-base-ui-CdzJ6My_.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{n as a}from"./vendor-reactuses-core-BpfIZ1tg.js";import{r as o,t as s}from"./button-BuhP8T0R.js";import{n as c}from"./Icon-DgrlwLKs.js";import{a as l,s as u}from"./vendor-framer-motion-DsGBcZHB.js";import{t as d}from"./MobileWindowStack-DGLdgoGr.js";var f=e(t(),1),p=i(),m=r(),h=e(n(),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=o(`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 s;return t[6]!==r||t[7]!==i?(s=(0,m.jsx)(`div`,{role:`separator`,tabIndex:0,"aria-orientation":`horizontal`,className:i,...r,children:a}),t[6]=r,t[7]=i,t[8]=s):s=t[8],s}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:c,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),ae=(0,f.useRef)(null),M=(0,f.useRef)(!1),N=(0,f.useRef)(null),P;t[0]===n?P=t[1]:(P=()=>{let e=n.current;if(!e)return 0;if(!N.current)return e.getBoundingClientRect().height;let t=parseFloat(getComputedStyle(e).translate.split(` `)[1])||0;return N.current.layoutHeight-t},t[0]=n,t[1]=P);let F=a(P),I;t[2]===n?I=t[3]:(I=e=>{let t=n.current;t&&(N.current?t.style.translate=`0 ${N.current.layoutHeight-e}px`:t.style.height=`${e}px`)},t[2]=n,t[3]=I);let L=a(I),R;t[4]!==m||t[5]!==n||t[6]!==L?(R=(e,t)=>{let r=n.current;if(r){if(m===`translate`&&!N.current){let e=Math.max(...t.map(ie))+144,{maxHeight:n,position:i,bottom:a,left:o,right:s}=r.style;N.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=N.current?`translate`:`height`,L(e)}},t[4]=m,t[5]=n,t[6]=L,t[7]=R):R=t[7];let oe=a(R),z;t[8]===n?z=t[9]:(z=()=>{let e=n.current;e&&(N.current&&(e.style.translate=``,Object.assign(e.style,N.current.styles),e.style.height=``),e.style.willChange=``,e.removeAttribute(`data-height-snap-active`)),N.current=null},t[8]=n,t[9]=z);let B=a(z),V;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{A.current!==null&&cancelAnimationFrame(A.current),A.current=null,j.current=null,ae.current?.cancel(),ae.current=null},t[10]=V):V=t[10];let H=a(V),se;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{let e=E.current;E.current=null,e?.handle.hasPointerCapture?.(e.pointerId)&&e.handle.releasePointerCapture(e.pointerId)},t[11]=se):se=t[11];let U=a(se),ce;t[12]!==H||t[13]!==B||t[14]!==i||t[15]!==c||t[16]!==oe||t[17]!==F||t[18]!==U||t[19]!==n||t[20]!==L?(ce=(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??F();H(),L(f);let p=i(),m=p.find(t=>t.id===e);if(!m)return;if(oe(f,p),U(),v(!1),b(!1),x.current=e,g(e),L(m.height),c?.(e),!o||Math.abs(f-m.height)<1||typeof d.animate!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches){B();return}b(!0);let h=N.current?.layoutHeight,_=m.height-f,y=l([d],h===void 0?{height:[`${f}px`,`${m.height}px`]}:{translate:[`0 ${h-f}px`,`0 ${h-m.height}px`]},{type:u,stiffness:576,damping:48,mass:1,velocity:s*1e3*100/_,restDelta:20/Math.abs(_),restSpeed:500/Math.abs(_)});ae.current=y,y.finished.catch(k).then(()=>{ae.current===y&&(ae.current=null,B(),b(!1))})},t[12]=H,t[13]=B,t[14]=i,t[15]=c,t[16]=oe,t[17]=F,t[18]=U,t[19]=n,t[20]=L,t[21]=ce):ce=t[21];let W=a(ce),le;t[22]!==H||t[23]!==i||t[24]!==o||t[25]!==oe||t[26]!==F||t[27]!==n||t[28]!==L?(le=e=>{if(E.current||!e.isPrimary||e.pointerType===`mouse`&&e.button!==0||!n.current)return;let t=F();H(),L(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(ne)),samples:[{height:t,time:e.timeStamp}]},M.current=!1,oe(t,r),v(!0),e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault())},t[22]=H,t[23]=i,t[24]=o,t[25]=oe,t[26]=F,t[27]=n,t[28]=L,t[29]=le):le=t[29];let ue=a(le),de;t[30]!==m||t[31]!==L?(de=e=>{let t=E.current;if(!t||t.pointerId!==e.pointerId)return;let n=t.startY-e.clientY;Math.abs(n)>3&&(M.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&&L(j.current)})),e.preventDefault()},t[30]=m,t[31]=L,t[32]=de):de=t[32];let G=a(de),fe;t[33]!==H||t[34]!==s||t[35]!==F||t[36]!==U||t[37]!==W||t[38]!==n?(fe=(e,t)=>{let r=E.current;if(!r||r.pointerId!==e.pointerId)return;let i=j.current??F(),a=r.height+r.startY-e.clientY;t||S(r.samples,a,e.timeStamp);let o=t?0:C(r.samples,e.timeStamp);if(U(),!t&&M.current&&s?.(i,o,r.height))H(),v(!1),n.current&&(n.current.style.willChange=``);else{let e=t||!M.current?r.point:w(r.points,r.point,i,o,a-r.height);W(e,i,!0,o)}e.preventDefault()},t[33]=H,t[34]=s,t[35]=F,t[36]=U,t[37]=W,t[38]=n,t[39]=fe):fe=t[39];let K=a(fe),pe;t[40]!==i||t[41]!==W?(pe=e=>{let t=[...i()].sort(O),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(te).find(e=>e.height<n.height-1);r&&W(r.id)},t[40]=i,t[41]=W,t[42]=pe):pe=t[42];let q=a(pe),J;t[43]!==i||t[44]!==W||t[45]!==q?(J=()=>{if(M.current){M.current=!1;return}let e=[...i()].sort(ee);x.current===e.at(-1)?.id?W(e[0].id):q(1)},t[43]=i,t[44]=W,t[45]=q,t[46]=J):J=t[46];let Y=a(J),X;t[47]!==i||t[48]!==Y||t[49]!==W||t[50]!==q?(X=e=>{if(![`ArrowUp`,`ArrowDown`,`Home`,`End`,`Enter`,` `].includes(e.key))return;e.preventDefault();let t=[...i()].sort(D);t.length&&(e.key===`ArrowUp`?q(1):e.key===`ArrowDown`?q(-1):e.key===`Home`?W(t.at(-1).id):e.key===`End`?W(t[0].id):Y())},t[47]=i,t[48]=Y,t[49]=W,t[50]=q,t[51]=X):X=t[51];let Z=a(X),Q;t[52]!==H||t[53]!==B||t[54]!==r||t[55]!==U||t[56]!==n?(Q=()=>{H(),U(),B(),x.current=r,g(r),v(!1),b(!1),M.current=!1,n.current&&(n.current.style.height=``,n.current.style.willChange=``)},t[52]=H,t[53]=B,t[54]=r,t[55]=U,t[56]=n,t[57]=Q):Q=t[57];let me=a(Q),$,he;t[58]!==H||t[59]!==B||t[60]!==U?($=()=>()=>{H(),U(),B()},he=[H,U,B],t[58]=H,t[59]=B,t[60]=U,t[61]=$,t[62]=he):($=t[61],he=t[62]),(0,f.useLayoutEffect)($,he);let ge;t[63]===K?ge=t[64]:(ge=e=>K(e,!1),t[63]=K,t[64]=ge);let _e=a(ge),ve;t[65]===K?ve=t[66]:(ve=e=>K(e,!0),t[65]=K,t[66]=ve);let ye=a(ve),be;t[67]===K?be=t[68]:(be=e=>K(e,!0),t[67]=K,t[68]=be);let xe=a(be),Se;return t[69]!==_||t[70]!==Y||t[71]!==Z||t[72]!==ue||t[73]!==G||t[74]!==me||t[75]!==W||t[76]!==y||t[77]!==h||t[78]!==_e||t[79]!==ye||t[80]!==xe?(Se={snapPoint:h,dragging:_,settling:y,settleAt:W,reset:me,handlePointerDown:ue,handlePointerMove:G,handlePointerUp:_e,handlePointerCancel:ye,handleLostPointerCapture:xe,handleClick:Y,handleKeyDown:Z},t[69]=_,t[70]=Y,t[71]=Z,t[72]=ue,t[73]=G,t[74]=me,t[75]=W,t[76]=y,t[77]=h,t[78]=_e,t[79]=ye,t[80]=xe,t[81]=Se):Se=t[81],Se}function D(e,t){return e.height-t.height}function ee(e,t){return e.height-t.height}function te(e,t){return t.height-e.height}function O(e,t){return e.height-t.height}function ne(e){return e.height}function re(e){return e.height}function k(){}function ie(e){return e.height}var A=.72,j=.98,ae=64,M=()=>Math.max(1,window.innerHeight),N=(e,t)=>{let n=Math.max(1,e)*A;return t==null||!Number.isFinite(t)?n:Math.min(n,Math.max(0,t))},P=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?ae: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=M(),t=d.current?.parentElement?.clientHeight||e;return l&&h.current===.72&&d.current&&!d.current.hasAttribute(`data-height-snap-active`)&&(m.current=N(e,d.current.getBoundingClientRect().height)),[{id:A,height:Math.min(t,N(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||M(),i=Math.min(r,N(M(),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},F=e=>{let t=(0,p.c)(12),{controller:n,ariaLabel:r}=e,i;t[0]===n.snapPoint?i=t[1]:(i=Math.round(n.snapPoint*100),t[0]=n.snapPoint,t[1]=i);let a;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]!==i?(a=(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":i,className:`flex min-h-8 cursor-ns-resize touch-none justify-center pt-2.5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,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]=i,t[11]=a):a=t[11],a},I=new WeakMap;function L(e){I.set(e.currentTarget,!0)}function R(e){if(I.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 oe(e){e.target===e.currentTarget&&L(e)}function z(e){return e.target===e.currentTarget&&R(e)}var B=(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)))]`},V=e=>Math.min(1,Math.max(0,Number.isFinite(e)?e:0)),H=(e,t)=>{let n=V(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)`}},se=(e,t)=>{let n=V(t);return e===`present`?n:1-n},U=(e,t)=>e===`present`?+(t===`commit`):t===`commit`?0:1,ce=e=>+!!e,W=`mobile-sessions`,le=new Map,ue=e=>le.get(e)??null,de=(e,t)=>(le.set(e,t),()=>{le.get(e)===t&&le.delete(e)}),G=`.overlay-scrollbar-container`,fe=1,K=e=>e===`left`||e===`right`?`x`:`y`,pe=e=>e===`bottom`||e===`right`?1:-1,q=(e,t,n)=>{let r=K(e)===`x`?t:n;return Math.max(0,r*pe(e))},J=(e,t,n,r,i)=>{let a=q(e,t,n),o=Math.abs(K(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)),Z=(e,t,n,r,i)=>e>=n||e>=i&&t>=r,Q=(e,t,n,r,i)=>t!==0&&n>0?t*i/n:r>80?0:e,me=(e,t,n=fe)=>{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},$=(e,t)=>{for(let n=0;n<e.length;n+=1){let r=e.item(n);if(r?.identifier===t)return r}return null},he=(e,t)=>{let n=window.getComputedStyle(e),r=K(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},ge=(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(he(a,n))return a;if(a===e)break;a=a.parentElement}let o=i?.closest(r)??null;return o&&e.contains(o)&&he(o,n)?o:null},_e=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=K(e.edge)===`x`?t.clientX:t.clientY,i=n-e.lastTime,a=r-e.lastPrimary;e.velocity=Q(e.velocity,a,i,n-e.lastVelocityTime,pe(e.edge)),a!==0&&i>0&&(e.lastVelocityTime=n),e.lastPrimary=r,e.lastTime=n,e.distance=q(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=ge(e,n.target,a.edge,a.scrollContainerSelector??G);if(l&&!me(l,a.edge))return;let u=e.getBoundingClientRect(),d=K(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:K(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=$(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(!J(n.edge,o.clientX-n.startX,o.clientY-n.startY,n.intentDistance,n.maxOffAxisRatio)){r.current=null;return}let e=ue(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=$(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=Z(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)}},[])},ve=`mobile-overlay-root`,ye=200,be=80,xe=`cubic-bezier(0.32, 0.72, 0, 1)`,Se=`a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`,Ce=()=>{if(typeof document>`u`)return null;let e=document.getElementById(ve);return e||(e=document.createElement(`div`),e.id=ve,document.body.appendChild(e)),e},we=()=>typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,Te=({id:e,open:t,onOpenChange:n,keepMounted:r=!1,presentation:i=`sheet`,edge:a=`bottom`,children:s,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(t),T=f.useRef(n),E=f.useRef(_),D=f.useRef(y),ee=f.useRef(0),te=f.useRef(0),O=f.useRef(null),ne=f.useRef([]),re=f.useRef(null),k=f.useRef(`standard`),ie=f.useRef(`present`),A=f.useRef(0),j=f.useRef(!1),ae=f.useRef(t),M=f.useRef(!1),N=f.useRef(t),P=f.useRef(null),[F,I]=f.useState(t),[L,R]=f.useState(t),[V,W]=f.useState(`standard`),[le,ue]=f.useState(!1),G=V===`interactive-present`,fe=f.useSyncExternalStore(d.subscribe,d.getSnapshot,d.getSnapshot),K=L&&!G&&fe===e,pe=_e({motionId:e,edge:a,disabled:!g,...typeof g==`object`?g:{}}),q=f.useCallback(e=>{C.current=e,pe(e),typeof p==`function`?p(e):p&&typeof p==`object`&&(p.current=e)},[pe,p]),J=f.useCallback(()=>{N.current&&(N.current=!1,R(!1),r||I(!1),E.current?.())},[r]);w.current=t,T.current=n,E.current=_,D.current=y,f.useLayoutEffect(()=>{D.current?.(L&&G)},[L,G]),typeof document<`u`&&!x.current&&(x.current=Ce());let Y=f.useCallback(e=>{let t=H(a,e);ee.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]),X=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=ne.current)=>{for(let t of e)t.cancel();ne.current=[]},[]),me=f.useCallback(()=>{X();let e=re.current;if(e){let t=e.animations[1]?.effect?.getComputedTiming().progress;Y(typeof t==`number`&&Number.isFinite(t)?e.from+(e.target-e.from)*t:ee.current),Q(e.animations),re.current=null}else Q();Z(),ue(!1)},[Y,Q,X,Z]),$=f.useCallback((e,t)=>{if(re.current?.target===e)return;me();let n=ee.current,r=S.current,i=C.current;if(ue(!0),!r||!i||we()||n===e){Y(e),Z(),ue(!1),t?.();return}let o=H(a,n),s=H(a,e);r.style.willChange=`opacity`,i.style.willChange=`transform, opacity`;let c=Math.max(be,ye*Math.abs(e-n)),l=[r.animate([{opacity:o.scrimOpacity},{opacity:s.scrimOpacity}],{duration:c,easing:xe,fill:`forwards`}),i.animate([{transform:o.surfaceTransform,opacity:o.surfaceOpacity},{transform:s.surfaceTransform,opacity:s.surfaceOpacity}],{duration:c,easing:xe,fill:`forwards`})];ne.current=l;let u={from:n,target:e,animations:l};re.current=u,Promise.all(l.map(e=>e.finished.catch(()=>void 0))).then(()=>{re.current===u&&(Y(e),Q(l),re.current=null,Z(),ue(!1),t?.())})},[Y,Q,Z,a,me]);if(f.useLayoutEffect(()=>{M.current=F,F&&Y(te.current)},[Y,F]),f.useLayoutEffect(()=>{N.current=L},[L]),f.useEffect(()=>{t&&!M.current&&(te.current=ee.current,I(!0)),t&&!N.current&&(N.current=!0,R(!0)),M.current&&k.current===`standard`&&$(ce(t),()=>{!w.current&&k.current===`standard`&&J()})},[J,t,$]),f.useLayoutEffect(()=>{!F||k.current!==`standard`||$(+!!t,()=>{!w.current&&k.current===`standard`&&J()})},[J,F,t,$]),f.useEffect(()=>{if(!(!L||G))return window.dispatchEvent(new Event(`yuri:mobile-overlay-opened`)),()=>{window.dispatchEvent(new Event(`yuri:mobile-overlay-closed`))}},[L,G]),f.useEffect(()=>{if(!(!L||G))return d.add({id:e,onClose:()=>T.current(!1)},document.body)},[L,e,G]),f.useEffect(()=>{if(!L||G||!K)return;let e=C.current,t=document.activeElement instanceof HTMLElement?document.activeElement:null;e?.focus({preventScroll:!0});let n=t=>{if(t.key===`Escape`&&d.closeTop(),t.key!==`Tab`||!e)return;let n=Array.from(e.querySelectorAll(Se)).filter(e=>!e.closest(`[data-mobile-sheet-snap-handle]`)),r=n[0]??e,i=n.at(-1)??e;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})}},[L,G,K]),P.current={begin:e=>{if(e===`dismiss`&&(!N.current||k.current===`interactive-present`))return!1;me(),A.current+=1,j.current=!0,ie.current=e;let t=e===`present`?`interactive-present`:`interactive-dismiss`;return k.current=t,W(t),ue(!0),e===`present`&&(te.current=ee.current,N.current=!0,R(!0),I(!0)),!0},update:e=>{j.current&&(te.current=se(ie.current,e),O.current===null&&(O.current=window.requestAnimationFrame(()=>{O.current=null,j.current&&Y(te.current)})))},finish:e=>{if(!j.current)return;j.current=!1;let t=A.current,n=ie.current,r=U(n,e);O.current!==null&&(X(),Y(te.current)),$(r,()=>{t===A.current&&(e===`commit`&&T.current(n===`present`),n===`present`&&e===`cancel`&&!w.current&&J(),k.current=`standard`,W(`standard`),r===0&&J())})},interrupt:()=>{A.current+=1,j.current=!1;let e=k.current===`interactive-present`&&!w.current;e||(k.current=`standard`,W(`standard`)),me(),$(ce(w.current),()=>{w.current||J(),e&&(k.current=`standard`,W(`standard`))})}},f.useLayoutEffect(()=>{let e=ae.current;ae.current=t,e&&!t&&k.current!==`standard`&&P.current?.interrupt()},[t]),f.useEffect(()=>{let t=de(e,{begin:e=>P.current?.begin(e)??!1,update:e=>P.current?.update(e),finish:e=>P.current?.finish(e),interrupt:()=>P.current?.interrupt()});return()=>{t(),X(),Q(),re.current=null,Z(),P.current=null}},[Q,X,Z,e]),!F||!x.current)return null;let he=(0,m.jsx)(`div`,{ref:S,className:o(`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`,!L&&!G&&`pointer-events-none invisible`,l,c),"data-mobile-overlay-active":String(L),role:G?void 0:`dialog`,"aria-label":G?void 0:b,"aria-modal":L&&K?`true`:void 0,"aria-hidden":G||!L||!K||void 0,inert:G||!L||!K||void 0,onPointerDown:oe,onClick:e=>{!L||G||!K||z(e)&&T.current(!1)},children:(0,m.jsx)(`div`,{ref:q,tabIndex:-1,className:o(`yuri-mobile-floating-shell`,B(i,a),u),"data-yuri-motion-id":e,style:{contain:`layout paint style`},onClick:e=>e.stopPropagation(),children:s})});return(0,h.createPortal)(he,x.current)},Ee=f.createContext(null),De=e=>{let t=(0,p.c)(5),{children:n}=e,r=f.useContext(Ee);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},Oe=e=>{let t=(0,p.c)(47),{id:n,open:r,onOpenChange:i,title:a,leading:l,trailing:u,ariaLabel:d,closeAriaLabel:h,resizeAriaLabel:g,initiallyExpanded:_,fitContent:v,bodyClassName:y,className:b,children:x}=e,S=_!==void 0&&_,C=v!==void 0&&v,w=S?j:void 0,T;t[0]!==i||t[1]!==r?(T=r?()=>i(!1):void 0,t[0]=i,t[1]=r,t[2]=T):T=t[2];let E;t[3]!==C||t[4]!==w||t[5]!==T?(E={initialSnapPoint:w,fitContent:C,onDismiss:T},t[3]=C,t[4]=w,t[5]=T,t[6]=E):E=t[6];let D=P(E),[ee,te]=f.useState(null),O=a!=null||l!=null||u!=null,ne=D.snapPoint===j,re=ne||!C,k;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(k={reservedTargetSelector:`[data-mobile-sheet-snap-handle]`},t[7]=k):k=t[7];let ie=ne?`h-[98dvh] max-h-[98dvh]`:C?`h-auto max-h-[72dvh]`:`h-[72dvh] max-h-[98dvh]`,A=D.surfaceRef,ae=D.reset,M=re&&`flex-1`,N;t[8]===M?N=t[9]:(N=o(`flex min-h-0 flex-col`,M),t[8]=M,t[9]=N);let I;t[10]!==g||t[11]!==D?(I=(0,m.jsx)(F,{controller:D,ariaLabel:g}),t[10]=g,t[11]=D,t[12]=I):I=t[12];let L;t[13]!==h||t[14]!==C||t[15]!==O||t[16]!==l||t[17]!==i||t[18]!==a||t[19]!==u?(L=O?(0,m.jsxs)(`div`,{className:C?`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:[l?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center`,children:l}):null,(0,m.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),u?(0,m.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:u}):null,(0,m.jsx)(`div`,{ref:te,className:`contents`}),(0,m.jsx)(s,{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)(c,{name:`close`,className:`size-5`})})]}):null,t[13]=h,t[14]=C,t[15]=O,t[16]=l,t[17]=i,t[18]=a,t[19]=u,t[20]=L):L=t[20];let R;t[21]!==I||t[22]!==L?(R=(0,m.jsxs)(`div`,{className:`shrink-0`,children:[I,L]}),t[21]=I,t[22]=L,t[23]=R):R=t[23];let oe=re&&`flex-1`,z;t[24]!==y||t[25]!==oe?(z=o(`flex min-h-0 flex-col overflow-hidden`,oe,y),t[24]=y,t[25]=oe,t[26]=z):z=t[26];let B;t[27]!==x||t[28]!==z?(B=(0,m.jsx)(`div`,{className:z,"data-page-scroll-lock":`true`,children:x}),t[27]=x,t[28]=z,t[29]=B):B=t[29];let V;t[30]!==N||t[31]!==R||t[32]!==B?(V=(0,m.jsxs)(`div`,{className:N,children:[R,B]}),t[30]=N,t[31]=R,t[32]=B,t[33]=V):V=t[33];let H;t[34]!==d||t[35]!==b||t[36]!==n||t[37]!==i||t[38]!==r||t[39]!==D.reset||t[40]!==D.surfaceRef||t[41]!==V||t[42]!==ie?(H=(0,m.jsx)(Te,{id:n,className:b,open:r,onOpenChange:i,presentation:`sheet`,edge:`bottom`,dismissGesture:k,ariaLabel:d,surfaceClassName:ie,surfaceElementRef:A,onExitComplete:ae,children:V}),t[34]=d,t[35]=b,t[36]=n,t[37]=i,t[38]=r,t[39]=D.reset,t[40]=D.surfaceRef,t[41]=V,t[42]=ie,t[43]=H):H=t[43];let se;return t[44]!==ee||t[45]!==H?(se=(0,m.jsx)(Ee.Provider,{value:ee,children:H}),t[44]=ee,t[45]=H,t[46]=se):se=t[46],se};export{_ as S,j as _,q as a,y as b,J as c,ue as d,R as f,F as g,z as h,X as i,Z as l,oe as m,De as n,Y as o,L as p,Te as r,Q as s,Oe as t,W as u,P as v,v as x,E as y};
|