rivet-design 0.28.0 → 0.28.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.
Files changed (54) hide show
  1. package/README.md +2 -6
  2. package/README.npm.md +2 -6
  3. package/dist/agent-variants/WorktreeOrchestrator.js +6 -4
  4. package/dist/cli/commands/open.js +4 -2
  5. package/dist/cli/commands/serve.js +1 -0
  6. package/dist/jest.globalSetup.d.ts +3 -0
  7. package/dist/jest.globalSetup.js +19 -0
  8. package/dist/proxy-middleware/proxy-config.d.ts +0 -1
  9. package/dist/proxy-middleware/proxy-config.js +6 -34
  10. package/dist/routes/agentVariants.js +20 -173
  11. package/dist/routes/static.js +8 -2
  12. package/dist/server.d.ts +1 -1
  13. package/dist/server.js +13 -25
  14. package/dist/services/AuthService.js +7 -61
  15. package/dist/services/templates/viteReactTs.js +1 -1
  16. package/dist/types/rivet-page-types.d.ts +48 -0
  17. package/dist/types/rivet-page-types.js +6 -0
  18. package/dist/utils/rivetPage.d.ts +8 -0
  19. package/dist/utils/rivetPage.js +24 -0
  20. package/dist/utils/rivetPage.testHelpers.d.ts +6 -0
  21. package/dist/utils/rivetPage.testHelpers.js +18 -0
  22. package/dist/utils/rivetPageDocument.d.ts +7 -0
  23. package/dist/utils/rivetPageDocument.js +41 -0
  24. package/dist/utils/scriptJson.d.ts +2 -0
  25. package/dist/utils/scriptJson.js +9 -0
  26. package/dist/utils/uiDistPath.d.ts +2 -0
  27. package/dist/utils/uiDistPath.js +22 -0
  28. package/package.json +21 -28
  29. package/src/ui/dist/assets/LibraryEntry-B8-RtQpK.js +2 -0
  30. package/src/ui/dist/assets/google-g-CpxN0HWb.png +0 -0
  31. package/src/ui/dist/assets/main-11-ME6E3.css +1 -0
  32. package/src/ui/dist/assets/main-BGCGsyhl.js +204 -0
  33. package/src/ui/dist/index.html +3 -3
  34. package/src/ui/dist/pages/empty-project.html +53 -0
  35. package/src/ui/dist/pages/rivet-page.html +53 -0
  36. package/dist/routes/emptyStatePage.d.ts +0 -2
  37. package/dist/routes/emptyStatePage.js +0 -589
  38. package/src/ui/dist/assets/LibraryEntry-BE8nZneH.js +0 -37
  39. package/src/ui/dist/assets/logo-animation/clasp.png +0 -0
  40. package/src/ui/dist/assets/logo-animation/eraser.png +0 -0
  41. package/src/ui/dist/assets/logo-animation/playdough.png +0 -0
  42. package/src/ui/dist/assets/logo-animation/sea/bubblephone.png +0 -0
  43. package/src/ui/dist/assets/logo-animation/sea/cart.png +0 -0
  44. package/src/ui/dist/assets/logo-animation/sea/chair.png +0 -0
  45. package/src/ui/dist/assets/logo-animation/sea/desk.png +0 -0
  46. package/src/ui/dist/assets/logo-animation/sea/mug.png +0 -0
  47. package/src/ui/dist/assets/logo-animation/sea/pitcher.png +0 -0
  48. package/src/ui/dist/assets/logo-animation/sea/pot.png +0 -0
  49. package/src/ui/dist/assets/logo-animation/sea/startac.png +0 -0
  50. package/src/ui/dist/assets/logo-animation/sea/terracotta-1.png +0 -0
  51. package/src/ui/dist/assets/logo-animation/sea/terracotta-2.png +0 -0
  52. package/src/ui/dist/assets/logo-animation/sea/vhsplant.png +0 -0
  53. package/src/ui/dist/assets/main-1EDrDqgn.js +0 -498
  54. package/src/ui/dist/assets/main-qgqnlUkI.css +0 -1
@@ -36,6 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.AuthService = exports.validateAccessToken = void 0;
37
37
  const zod_1 = require("zod");
38
38
  const logger_1 = require("../utils/logger");
39
+ const rivetPage_1 = require("../utils/rivetPage");
40
+ const rivet_page_types_1 = require("../types/rivet-page-types");
39
41
  const ConfigManager_1 = require("./ConfigManager");
40
42
  const http_1 = require("http");
41
43
  const accessTokenRefresh_1 = require("./accessTokenRefresh");
@@ -46,7 +48,6 @@ const proxy_1 = require("../config/proxy");
46
48
  const log = (0, logger_1.createLogger)('AuthService');
47
49
  const LOOPBACK_HOST = '127.0.0.1';
48
50
  const LOOPBACK_PORT = 0;
49
- const CALLBACK_COMPLETE_PATH = '/complete';
50
51
  const OAUTH_CALLBACK_TIMEOUT_MS = 120_000;
51
52
  const MAX_CALLBACK_BODY_BYTES = 64 * 1024;
52
53
  const PROFILE_FETCH_TIMEOUT_MS = 10_000;
@@ -101,64 +102,6 @@ const readRequestBody = (request) => {
101
102
  request.on('error', reject);
102
103
  });
103
104
  };
104
- const getLoopbackCallbackHtml = () => {
105
- return `<!doctype html>
106
- <html>
107
- <head>
108
- <meta charset="utf-8" />
109
- <meta name="viewport" content="width=device-width, initial-scale=1" />
110
- <title>Rivet authentication</title>
111
- <style>
112
- body {
113
- margin: 0;
114
- min-height: 100vh;
115
- display: grid;
116
- place-items: center;
117
- font-family: system-ui, sans-serif;
118
- background: #0b0b0f;
119
- color: #fff;
120
- }
121
- main {
122
- max-width: 420px;
123
- padding: 32px;
124
- text-align: center;
125
- }
126
- </style>
127
- </head>
128
- <body>
129
- <main>
130
- <h1>Finishing Rivet sign in...</h1>
131
- <p>You can return to your editor after this page completes.</p>
132
- </main>
133
- <script>
134
- const params = new URLSearchParams(window.location.search);
135
- const hash = new URLSearchParams(window.location.hash.slice(1));
136
- if (window.location.hash) {
137
- window.history.replaceState(
138
- null,
139
- document.title,
140
- window.location.pathname + window.location.search
141
- );
142
- }
143
- fetch('/complete', {
144
- method: 'POST',
145
- headers: { 'Content-Type': 'application/json' },
146
- body: JSON.stringify({
147
- sessionId: params.get('session'),
148
- accessToken: hash.get('access_token'),
149
- refreshToken: hash.get('refresh_token')
150
- })
151
- }).then((response) => {
152
- document.querySelector('h1').textContent = response.ok
153
- ? 'Rivet sign in complete'
154
- : 'Rivet sign in failed';
155
- }).catch(() => {
156
- document.querySelector('h1').textContent = 'Rivet sign in failed';
157
- });
158
- </script>
159
- </body>
160
- </html>`;
161
- };
162
105
  const validateAccessToken = async (proxyUrl, accessToken) => {
163
106
  const response = await fetch(`${proxyUrl.replace(/\/$/, '')}/api/user/profile`, {
164
107
  method: 'GET',
@@ -204,11 +147,14 @@ const createLoopbackOAuthCallback = async () => {
204
147
  const server = (0, http_1.createServer)((request, response) => {
205
148
  const url = new URL(request.url ?? '/', `http://${LOOPBACK_HOST}`);
206
149
  if (request.method === 'GET') {
207
- sendTextResponse(response, 200, getLoopbackCallbackHtml());
150
+ sendTextResponse(response, 200, (0, rivetPage_1.renderRivetPage)({
151
+ page: { kind: 'sign-in-callback' },
152
+ head: { title: 'Rivet authentication' },
153
+ }));
208
154
  return;
209
155
  }
210
156
  if (request.method !== 'POST' ||
211
- url.pathname !== CALLBACK_COMPLETE_PATH) {
157
+ url.pathname !== rivet_page_types_1.SIGN_IN_CALLBACK_COMPLETE_PATH) {
212
158
  sendTextResponse(response, 404, 'Not found');
213
159
  return;
214
160
  }
@@ -200,7 +200,7 @@ textarea {
200
200
 
201
201
  .eyebrow {
202
202
  margin: 0 0 16px;
203
- color: #ff3300;
203
+ color: #e54b2c;
204
204
  font-size: 13px;
205
205
  font-weight: 700;
206
206
  letter-spacing: 0;
@@ -0,0 +1,48 @@
1
+ export declare const RIVET_PAGE_DATA_ELEMENT_ID = "rivet-page";
2
+ export declare const SIGN_IN_CALLBACK_COMPLETE_PATH = "/complete";
3
+ export type CanvasShareDirection = {
4
+ label: string;
5
+ brief: string;
6
+ shareUrl: string;
7
+ };
8
+ export type SharedShellRivetPage = {
9
+ kind: 'preview-waiting';
10
+ } | {
11
+ kind: 'sign-in-callback';
12
+ } | {
13
+ kind: 'canvas-share';
14
+ prompt: string;
15
+ directions: CanvasShareDirection[];
16
+ };
17
+ export type RivetPage = {
18
+ kind: 'empty-project';
19
+ } | SharedShellRivetPage;
20
+ export type ConnectResultMessage = {
21
+ type: 'rivet:connect-result';
22
+ provider: string;
23
+ status: 'connected' | 'error';
24
+ message?: string;
25
+ };
26
+ export type ConnectResultClosePolicy = 'always' | 'after-notifying-opener';
27
+ export type HostedRivetPage = {
28
+ kind: 'google-sign-in';
29
+ initiator: string;
30
+ providerAuthUrl: string;
31
+ } | {
32
+ kind: 'sign-in-link-expired';
33
+ } | {
34
+ kind: 'connect-result';
35
+ result: ConnectResultMessage;
36
+ notice: string;
37
+ closePolicy: ConnectResultClosePolicy;
38
+ };
39
+ export type RivetPageShareCard = {
40
+ description: string;
41
+ imageUrl: string;
42
+ };
43
+ export type RivetPageHead = {
44
+ title: string;
45
+ shareCard?: RivetPageShareCard;
46
+ robots?: 'noindex';
47
+ };
48
+ //# sourceMappingURL=rivet-page-types.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SIGN_IN_CALLBACK_COMPLETE_PATH = exports.RIVET_PAGE_DATA_ELEMENT_ID = void 0;
4
+ exports.RIVET_PAGE_DATA_ELEMENT_ID = 'rivet-page';
5
+ exports.SIGN_IN_CALLBACK_COMPLETE_PATH = '/complete';
6
+ //# sourceMappingURL=rivet-page-types.js.map
@@ -0,0 +1,8 @@
1
+ import type { RivetPage, RivetPageHead } from '../types/rivet-page-types';
2
+ export declare const RIVET_PAGE_SHELL_DIRECTORY: string;
3
+ export declare const RIVET_PAGE_SHELL_FILES: string[];
4
+ export declare const renderRivetPage: (args: {
5
+ page: RivetPage;
6
+ head: RivetPageHead;
7
+ }) => string;
8
+ //# sourceMappingURL=rivetPage.d.ts.map
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.renderRivetPage = exports.RIVET_PAGE_SHELL_FILES = exports.RIVET_PAGE_SHELL_DIRECTORY = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const rivetPageDocument_1 = require("./rivetPageDocument");
10
+ const uiDistPath_1 = require("./uiDistPath");
11
+ exports.RIVET_PAGE_SHELL_DIRECTORY = path_1.default.join(uiDistPath_1.DIST_UI_PATH, 'pages');
12
+ const SHARED_SHELL_FILE = 'rivet-page.html';
13
+ const EMPTY_PROJECT_SHELL_FILE = 'empty-project.html';
14
+ exports.RIVET_PAGE_SHELL_FILES = [
15
+ SHARED_SHELL_FILE,
16
+ EMPTY_PROJECT_SHELL_FILE,
17
+ ];
18
+ const shellFileFor = (page) => page.kind === 'empty-project' ? EMPTY_PROJECT_SHELL_FILE : SHARED_SHELL_FILE;
19
+ const renderRivetPage = (args) => (0, rivetPageDocument_1.composeRivetPage)({
20
+ shell: fs_1.default.readFileSync(path_1.default.join(exports.RIVET_PAGE_SHELL_DIRECTORY, shellFileFor(args.page)), 'utf8'),
21
+ ...args,
22
+ });
23
+ exports.renderRivetPage = renderRivetPage;
24
+ //# sourceMappingURL=rivetPage.js.map
@@ -0,0 +1,6 @@
1
+ export declare const readRivetPageData: (html: string) => unknown;
2
+ export declare const readRivetPageHead: (html: string) => {
3
+ title: string | null;
4
+ robots: string | null;
5
+ };
6
+ //# sourceMappingURL=rivetPage.testHelpers.d.ts.map
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readRivetPageHead = exports.readRivetPageData = void 0;
4
+ const rivet_page_types_1 = require("../types/rivet-page-types");
5
+ const PAGE_DATA_PATTERN = new RegExp(`<script id="${rivet_page_types_1.RIVET_PAGE_DATA_ELEMENT_ID}" type="application/json">([\\s\\S]*?)</script>`);
6
+ const readRivetPageData = (html) => {
7
+ const data = html.match(PAGE_DATA_PATTERN)?.[1];
8
+ if (data === undefined)
9
+ throw new Error('Rivet page data is missing');
10
+ return JSON.parse(data);
11
+ };
12
+ exports.readRivetPageData = readRivetPageData;
13
+ const readRivetPageHead = (html) => ({
14
+ title: html.match(/<title>([\s\S]*?)<\/title>/)?.[1] ?? null,
15
+ robots: html.match(/<meta name="robots" content="([^"]*)" \/>/)?.[1] ?? null,
16
+ });
17
+ exports.readRivetPageHead = readRivetPageHead;
18
+ //# sourceMappingURL=rivetPage.testHelpers.js.map
@@ -0,0 +1,7 @@
1
+ import { type HostedRivetPage, type RivetPage, type RivetPageHead } from '../types/rivet-page-types';
2
+ export declare const composeRivetPage: ({ shell, page, head, }: {
3
+ shell: string;
4
+ page: RivetPage | HostedRivetPage;
5
+ head: RivetPageHead;
6
+ }) => string;
7
+ //# sourceMappingURL=rivetPageDocument.d.ts.map
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.composeRivetPage = void 0;
4
+ const rivet_page_types_1 = require("../types/rivet-page-types");
5
+ const scriptJson_1 = require("./scriptJson");
6
+ const PAGE_HEAD_MARKER = '<meta name="rivet-page-head" />';
7
+ const renderPageDataElement = (json) => `<script id="${rivet_page_types_1.RIVET_PAGE_DATA_ELEMENT_ID}" type="application/json">${json}</script>`;
8
+ const PAGE_DATA_PLACEHOLDER = renderPageDataElement('null');
9
+ const escapeHtml = (value) => value
10
+ .replace(/&/g, '&amp;')
11
+ .replace(/</g, '&lt;')
12
+ .replace(/>/g, '&gt;')
13
+ .replace(/"/g, '&quot;')
14
+ .replace(/'/g, '&#39;');
15
+ const renderShareCardTags = (title, { description, imageUrl }) => [
16
+ ['name', 'description', description],
17
+ ['property', 'og:type', 'website'],
18
+ ['property', 'og:title', title],
19
+ ['property', 'og:description', description],
20
+ ['property', 'og:image', imageUrl],
21
+ ['name', 'twitter:card', 'summary_large_image'],
22
+ ['name', 'twitter:title', title],
23
+ ['name', 'twitter:description', description],
24
+ ['name', 'twitter:image', imageUrl],
25
+ ].map(([attribute, key, content]) => `<meta ${attribute}="${key}" content="${escapeHtml(content)}" />`);
26
+ const renderHead = ({ title, shareCard, robots }) => [
27
+ ...(robots ? [`<meta name="robots" content="${robots}" />`] : []),
28
+ `<title>${escapeHtml(title)}</title>`,
29
+ ...(shareCard ? renderShareCardTags(title, shareCard) : []),
30
+ ].join('\n ');
31
+ const composeRivetPage = ({ shell, page, head, }) => {
32
+ if (!shell.includes(PAGE_HEAD_MARKER) ||
33
+ !shell.includes(PAGE_DATA_PLACEHOLDER)) {
34
+ throw new Error('Rivet page shell is missing its head or data placeholder');
35
+ }
36
+ return shell
37
+ .replace(PAGE_HEAD_MARKER, () => renderHead(head))
38
+ .replace(PAGE_DATA_PLACEHOLDER, () => renderPageDataElement((0, scriptJson_1.escapeScriptJson)(page)));
39
+ };
40
+ exports.composeRivetPage = composeRivetPage;
41
+ //# sourceMappingURL=rivetPageDocument.js.map
@@ -0,0 +1,2 @@
1
+ export declare const escapeScriptJson: (value: unknown) => string;
2
+ //# sourceMappingURL=scriptJson.d.ts.map
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.escapeScriptJson = void 0;
4
+ const escapeScriptJson = (value) => JSON.stringify(value)
5
+ .replace(/</g, '\\u003c')
6
+ .replace(/\u2028/g, '\\u2028')
7
+ .replace(/\u2029/g, '\\u2029');
8
+ exports.escapeScriptJson = escapeScriptJson;
9
+ //# sourceMappingURL=scriptJson.js.map
@@ -0,0 +1,2 @@
1
+ export declare const DIST_UI_PATH: string;
2
+ //# sourceMappingURL=uiDistPath.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DIST_UI_PATH = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const logger_1 = require("./logger");
10
+ const log = (0, logger_1.createLogger)('UiDistPath');
11
+ const resolveUiPath = () => {
12
+ const bundledPath = path_1.default.join(__dirname, '..', 'ui/dist');
13
+ const devPath = path_1.default.join(__dirname, '../../src/ui/dist');
14
+ if (fs_1.default.existsSync(bundledPath)) {
15
+ log.debug(`Using bundled UI path: ${bundledPath}`);
16
+ return bundledPath;
17
+ }
18
+ log.debug(`Using development UI path: ${devPath}`);
19
+ return devPath;
20
+ };
21
+ exports.DIST_UI_PATH = resolveUiPath();
22
+ //# sourceMappingURL=uiDistPath.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rivet-design",
3
- "version": "0.28.0",
4
- "description": "Local visual web development tool with AI-powered code modification",
3
+ "version": "0.28.2",
4
+ "description": "Rivet is a design agent for your coding agent. It explores dozens of design directions in parallel so you can pick the one that fits.",
5
5
  "main": "dist/index.js",
6
6
  "workspaces": [
7
7
  "src/ui",
@@ -14,7 +14,7 @@
14
14
  "preinstall": "node scripts/verify-node-version.cjs",
15
15
  "build": "npm run clean && tsc && npm run build:assets && npm run build:ui && npm run build:bin",
16
16
  "build:assets": "mkdir -p dist/services/templates/designmd && cp src/services/templates/designmd/*.md dist/services/templates/designmd/",
17
- "build:ui": "cd src/ui && vite build",
17
+ "build:ui": "cd src/ui && vite build && vite build --config vite.pages.config.ts && vite build --config vite.pages.config.ts --mode empty-project",
18
18
  "storybook:ui": "yarn workspace @rivet/ui storybook",
19
19
  "build-storybook:ui": "yarn workspace @rivet/ui build-storybook",
20
20
  "build:bin": "mkdir -p bin && cp src/bin-template.js bin/rivet.js && chmod +x bin/rivet.js",
@@ -43,9 +43,9 @@
43
43
  "prepare": "husky",
44
44
  "docs:sync": "node scripts/sync-external-docs.js",
45
45
  "deploy:supabase:functions": "bash scripts/deploy-supabase-functions.sh",
46
- "ratchet": "tsx scripts/ratchet.ts",
46
+ "ratchet": "node scripts/ratchet.mts",
47
47
  "check:comments": "node scripts/code-comments.mjs --changed",
48
- "test:ratchet": "node --import tsx --test scripts/ratchet/*.test.ts scripts/code-comments.test.mjs && python3 scripts/python-comments.test.py",
48
+ "test:ratchet": "node --import tsx --test --test-concurrency=4 scripts/ratchet/*.test.ts scripts/semantic-colors.test.ts scripts/code-comments.test.mjs && python3 scripts/python-comments.test.py",
49
49
  "bench": "node --import tsx benchmarks/bench.ts",
50
50
  "bench:run": "node --import tsx benchmarks/runner.ts",
51
51
  "bench:compare": "node --import tsx benchmarks/compare.ts",
@@ -99,6 +99,7 @@
99
99
  "@csstools/css-tokenizer": "^3.0.4",
100
100
  "@eslint/js": "^9.36.0",
101
101
  "@playwright/test": "^1.58.2",
102
+ "@tailwindcss/node": "4.3.3",
102
103
  "@types/cors": "^2.8.19",
103
104
  "@types/express": "^5.0.3",
104
105
  "@types/express-serve-static-core": "^5.0.0",
@@ -114,6 +115,7 @@
114
115
  "@types/ws": "^8.18.1",
115
116
  "@typescript-eslint/eslint-plugin": "^8.44.0",
116
117
  "@typescript-eslint/parser": "^8.44.0",
118
+ "@typescript-eslint/typescript-estree": "^8.44.0",
117
119
  "@vitejs/plugin-react": "^4.2.1",
118
120
  "autoprefixer": "^10.4.16",
119
121
  "dockerfile-ast": "^0.7.1",
@@ -137,6 +139,7 @@
137
139
  "react-dom": "^18.2.0",
138
140
  "supabase": "^2.47.2",
139
141
  "supertest": "^7.1.4",
142
+ "tailwind-merge": "^3.6.0",
140
143
  "tailwindcss": "^3.4.0",
141
144
  "ts-jest": "^29.4.4",
142
145
  "ts-node": "^10.9.2",
@@ -154,32 +157,22 @@
154
157
  "README.npm.md"
155
158
  ],
156
159
  "keywords": [
157
- "visual-editor",
158
- "frontend-development",
159
- "css-editor",
160
+ "design-agent",
161
+ "coding-agent",
162
+ "design-variants",
163
+ "design-exploration",
164
+ "mcp",
165
+ "claude-code",
166
+ "claude",
167
+ "cursor",
168
+ "codex",
160
169
  "design-tools",
161
- "ui-development",
162
- "react-editor",
163
- "web-design",
164
- "css-visual-editor",
165
- "no-code",
166
- "low-code",
167
- "ai-powered",
168
- "product-design",
169
- "tailwind-css",
170
- "component-editor",
171
- "web-builder"
170
+ "frontend-development",
171
+ "web-design"
172
172
  ],
173
173
  "author": "Rivet Design",
174
174
  "license": "GPL-3.0-or-later",
175
- "repository": {
176
- "type": "git",
177
- "url": "https://github.com/rivet-design/rivet"
178
- },
179
- "bugs": {
180
- "url": "https://github.com/rivet-design/rivet/issues"
181
- },
182
- "homepage": "https://github.com/rivet-design/rivet#readme",
175
+ "homepage": "https://rivet.design",
183
176
  "publishConfig": {
184
177
  "access": "public"
185
178
  },
@@ -212,5 +205,5 @@
212
205
  "rivetPlugin": {
213
206
  "toolContract": "intent-v2"
214
207
  },
215
- "gitHead": "24cfc02a15b83a2b7c9e324780ee1997b1120722"
208
+ "gitHead": "8a2d16d2418525b49e4aa448f5b82f869f7d7065"
216
209
  }
@@ -0,0 +1,2 @@
1
+ var Fe=t=>{throw TypeError(t)};var je=(t,r,a)=>r.has(t)||Fe("Cannot "+a);var E=(t,r,a)=>(je(t,r,"read from private field"),a?a.call(t):r.get(t)),B=(t,r,a)=>r.has(t)?Fe("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(t):r.set(t,a),Z=(t,r,a,i)=>(je(t,r,"write to private field"),i?i.call(t,a):r.set(t,a),a),W=(t,r,a)=>(je(t,r,"access private method"),a);import{S as St,n as Se,s as Nt,r as Et,Q as Ye,u as He,a as Lt,b as At,c as s,e as Rt,d as It,f as kt,g as Ht,h as De,i as _t,j as Mt,p as be,k as le,l as e,B as _,m as Ne,M as Ct,o as Pt,q as Vt,t as Zt,v as we,w as Tt,x as Je,D as Xe,y as et,z as tt,A as rt,P as Ot,C as st,E as $e,F as Ft,G as Dt,H as $t,I as qe,J as qt,K as ee,L as xe,N as T,R as zt,O as at,T as Ut,U as se,V as Kt,W as Qt,X as oe,Y as Bt,Z as ae,_ as q,$ as nt,a0 as ge,a1 as Wt,a2 as Gt,a3 as $,a4 as it,a5 as Yt,a6 as ce,a7 as Jt,a8 as Ee,a9 as Xt,aa as ze,ab as er,ac as tr,ad as rr,ae as sr,af as ar,ag as nr,ah as ir,ai as or,aj as lr,ak as cr,al as dr,am as ur,an as mr,ao as hr,ap as pr,aq as fr,ar as ot,as as xr,at as br,au as gr,av as vr,aw as yr,ax as jr,ay as wr,az as Sr,aA as Nr}from"./main-BGCGsyhl.js";function Ue(t,r){const a=new Set(r);return t.filter(i=>!a.has(i))}var ne,D,ie,te,Q,re,de,ue,me,he,M,Le,Ae,lt,Re,Ie,ke,Ge,Er=(Ge=class extends St{constructor(r,a,i){super();B(this,M);B(this,ne);B(this,D);B(this,ie);B(this,te);B(this,Q);B(this,re);B(this,de);B(this,ue);B(this,me);B(this,he,[]);Z(this,ne,r),Z(this,te,i),Z(this,ie,[]),Z(this,Q,[]),Z(this,D,[]),this.setQueries(a)}onSubscribe(){this.listeners.size===1&&E(this,Q).forEach(r=>{r.subscribe(a=>{W(this,M,Ie).call(this,r,a)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,E(this,Q).forEach(r=>{r.destroy()})}setQueries(r,a){Z(this,ie,r),Z(this,te,a),Se.batch(()=>{const i=E(this,Q),o=W(this,M,Re).call(this,E(this,ie));o.forEach(m=>m.observer.setOptions(m.defaultedQueryOptions));const l=o.map(m=>m.observer),n=l.map(m=>m.getCurrentResult()),d=i.length!==l.length,p=l.some((m,y)=>m!==i[y]),g=d||p,v=g?!0:n.some((m,y)=>{const j=E(this,D)[y];return!j||!Nt(m,j)});!g&&!v||(g&&(Z(this,he,o),Z(this,Q,l)),Z(this,D,n),this.hasListeners()&&(g&&(Ue(i,l).forEach(m=>{m.destroy()}),Ue(l,i).forEach(m=>{m.subscribe(y=>{W(this,M,Ie).call(this,m,y)})})),W(this,M,ke).call(this)))})}getCurrentResult(){return E(this,D)}getQueries(){return E(this,Q).map(r=>r.getCurrentQuery())}getObservers(){return E(this,Q)}getOptimisticResult(r,a){const i=W(this,M,Re).call(this,r),o=i.map(n=>n.observer.getOptimisticResult(n.defaultedQueryOptions)),l=i.map(n=>n.defaultedQueryOptions.queryHash);return[o,n=>W(this,M,Ae).call(this,n??o,a,l),()=>W(this,M,Le).call(this,o,i)]}},ne=new WeakMap,D=new WeakMap,ie=new WeakMap,te=new WeakMap,Q=new WeakMap,re=new WeakMap,de=new WeakMap,ue=new WeakMap,me=new WeakMap,he=new WeakMap,M=new WeakSet,Le=function(r,a){const i=new Set;return a.map((o,l)=>{const n=r[l];return o.defaultedQueryOptions.notifyOnChangeProps?n:o.observer.trackResult(n,d=>{i.has(d)||(i.add(d),a.forEach(p=>{p.observer.trackProp(d)}))})})},Ae=function(r,a,i){if(a){const o=E(this,me),l=i!==void 0&&o!==void 0&&(o.length!==i.length||i.some((n,d)=>n!==o[d]));return(E(this,D)!==E(this,ue)||l||a!==E(this,de))&&(Z(this,de,a),Z(this,ue,E(this,D)),i!==void 0&&Z(this,me,i),Z(this,re,Et(E(this,re),a(r)))),E(this,re)}return r},lt=function(){var r;return!((r=E(this,te))!=null&&r.combine)||E(this,Q).some((a,i)=>{var o;return a.options.suspense&&((o=E(this,D)[i])==null?void 0:o.data)===void 0})},Re=function(r){const a=new Map;E(this,Q).forEach(o=>{const l=o.options.queryHash;if(!l)return;const n=a.get(l);n?n.push(o):a.set(l,[o])});const i=[];return r.forEach(o=>{var d;const l=E(this,ne).defaultQueryOptions(o),n=((d=a.get(l.queryHash))==null?void 0:d.shift())??new Ye(E(this,ne),l);i.push({defaultedQueryOptions:l,observer:n})}),i},Ie=function(r,a){const i=E(this,Q).indexOf(r);i!==-1&&(Z(this,D,E(this,D).slice()),E(this,D)[i]=a,W(this,M,ke).call(this))},ke=function(){var r;if(this.hasListeners()){const a=W(this,M,lt).call(this),i=E(this,re),o=a?i:W(this,M,Ae).call(this,W(this,M,Le).call(this,E(this,D),E(this,he)),(r=E(this,te))==null?void 0:r.combine);(a||i!==o)&&Se.batch(()=>{this.listeners.forEach(l=>{l(E(this,D))})})}},Ge);function Lr({queries:t,...r},a){const i=He(),o=Lt(),l=At(),n=r.subscribed!==!1,d=s.useMemo(()=>t.map(N=>{const f=i.defaultQueryOptions(N);return f._optimisticResults=o?"isRestoring":n?"optimistic":void 0,f}),[t,i,o,n]);d.forEach(N=>{Rt(N);const f=i.getQueryCache().get(N.queryHash);It(N,l,f)}),kt(l);const[p]=s.useState(()=>new Er(i,d,r)),[g,v,m]=p.getOptimisticResult(d,r.combine);s.useEffect(()=>{p.setQueries(d,r)},[d,r,p]);const y=!o&&n;s.useSyncExternalStore(s.useCallback(N=>y?p.subscribe(Se.batchCalls(N)):Ht,[p,y]),()=>p.getCurrentResult(),()=>p.getCurrentResult());const j=g.some((N,f)=>De(d[f],N))?g.flatMap((N,f)=>{const w=d[f];if(w&&De(w,N)){const P=new Ye(i,w);return _t(w,P,l)}return[]}):[];if(j.length>0)throw Promise.all(j);const L=g.find((N,f)=>{const w=d[f];return w&&Mt({result:N,errorResetBoundary:l,throwOnError:w.throwOnError,query:i.getQueryCache().get(w.queryHash),suspense:w.suspense})});if(L)throw L.error;return v(m())}const Ar=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H69l51.52,51.51a12,12,0,0,1-17,17l-72-72a12,12,0,0,1,0-17l72-72a12,12,0,0,1,17,17L69,116H216A12,12,0,0,1,228,128Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M112,56V200L40,128Z",opacity:"0.2"}),s.createElement("path",{d:"M216,120H120V56a8,8,0,0,0-13.66-5.66l-72,72a8,8,0,0,0,0,11.32l72,72A8,8,0,0,0,120,200V136h96a8,8,0,0,0,0-16ZM104,180.69,51.31,128,104,75.31Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H120v64a8,8,0,0,1-13.66,5.66l-72-72a8,8,0,0,1,0-11.32l72-72A8,8,0,0,1,120,56v64h96A8,8,0,0,1,224,128Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H54.49l61.75,61.76a6,6,0,1,1-8.48,8.48l-72-72a6,6,0,0,1,0-8.48l72-72a6,6,0,0,1,8.48,8.48L54.49,122H216A6,6,0,0,1,222,128Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H49.66l65.17,65.17a4,4,0,0,1-5.66,5.66l-72-72a4,4,0,0,1,0-5.66l72-72a4,4,0,0,1,5.66,5.66L49.66,124H216A4,4,0,0,1,220,128Z"}))]]),Rr=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M204,64V168a12,12,0,0,1-24,0V93L72.49,200.49a12,12,0,0,1-17-17L163,76H88a12,12,0,0,1,0-24H192A12,12,0,0,1,204,64Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M192,64V168L88,64Z",opacity:"0.2"}),s.createElement("path",{d:"M192,56H88a8,8,0,0,0-5.66,13.66L128.69,116,58.34,186.34a8,8,0,0,0,11.32,11.32L140,127.31l46.34,46.35A8,8,0,0,0,200,168V64A8,8,0,0,0,192,56Zm-8,92.69-38.34-38.34h0L107.31,72H184Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M200,64V168a8,8,0,0,1-13.66,5.66L140,127.31,69.66,197.66a8,8,0,0,1-11.32-11.32L128.69,116,82.34,69.66A8,8,0,0,1,88,56H192A8,8,0,0,1,200,64Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M198,64V168a6,6,0,0,1-12,0V78.48L68.24,196.24a6,6,0,0,1-8.48-8.48L177.52,70H88a6,6,0,0,1,0-12H192A6,6,0,0,1,198,64Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M200,64V168a8,8,0,0,1-16,0V83.31L69.66,197.66a8,8,0,0,1-11.32-11.32L172.69,72H88a8,8,0,0,1,0-16H192A8,8,0,0,1,200,64Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M196,64V168a4,4,0,0,1-8,0V73.66L66.83,194.83a4,4,0,0,1-5.66-5.66L182.34,68H88a4,4,0,0,1,0-8H192A4,4,0,0,1,196,64Z"}))]]),Ir=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M231,112a12,12,0,0,0-10.81-1.65l-23.81,7.93a12,12,0,0,0-7.34,6.93l-13.67,34.18-34.18,13.67a12,12,0,0,0-6.93,7.34l-7.93,23.81A12,12,0,0,0,137.73,220H216a20,20,0,0,0,20-20V121.73A12,12,0,0,0,231,112Zm-19,84H154.38l.91-2.73,33.79-13.51a12,12,0,0,0,6.68-6.68l13.51-33.79,2.73-.91Zm4-160H40A20,20,0,0,0,20,56V200a20,20,0,0,0,20,20H95.57A12,12,0,0,0,107,211.79L123.21,163l35.09-14A12,12,0,0,0,165,142.3l14-35.09L227.79,91A12,12,0,0,0,236,79.57V56A20,20,0,0,0,216,36ZM102.2,150.16,86.92,196H44V173.66l48-48,17.14,17.14h0A12,12,0,0,0,102.2,150.16ZM212,70.92,166.16,86.2a12,12,0,0,0-7.35,6.93l-14.2,35.48-11.22,4.49-27.25-27.24a20,20,0,0,0-28.28,0L44,139.72V60H212Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,56V88l-48,16-16,40-23.35,9.34-39-39a8,8,0,0,0-11.32,0L32,168.69V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z",opacity:"0.2"}),s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16h64a8,8,0,0,0,7.59-5.47l14.83-44.48L163,151.43a8.07,8.07,0,0,0,4.46-4.46l14.62-36.55,44.48-14.83A8,8,0,0,0,232,88V56A16,16,0,0,0,216,40ZM112.41,157.47,98.23,200H40V172l52-52,30.42,30.42L117,152.57A8,8,0,0,0,112.41,157.47ZM216,82.23,173.47,96.41a8,8,0,0,0-4.9,4.62l-14.72,36.82L138.58,144l-35.27-35.27a16,16,0,0,0-22.62,0L40,149.37V56H216Zm12.68,33a8,8,0,0,0-7.21-1.1l-23.8,7.94a8,8,0,0,0-4.9,4.61l-14.31,35.77-35.77,14.31a8,8,0,0,0-4.61,4.9l-7.94,23.8A8,8,0,0,0,137.73,216H216a16,16,0,0,0,16-16V121.73A8,8,0,0,0,228.68,115.24ZM216,200H148.83l3.25-9.75,35.51-14.2a8.07,8.07,0,0,0,4.46-4.46l14.2-35.51,9.75-3.25Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16h64a8,8,0,0,0,7.59-5.47l14.83-44.48L163,151.43a8.07,8.07,0,0,0,4.46-4.46l14.62-36.55,44.48-14.83A8,8,0,0,0,232,88V56A16,16,0,0,0,216,40ZM117,152.57a8,8,0,0,0-4.62,4.9L98.23,200H40V160.69l46.34-46.35a8,8,0,0,1,11.32,0l32.84,32.84Zm115-30.84V200a16,16,0,0,1-16,16H137.73a8,8,0,0,1-7.59-10.53l7.94-23.8a8,8,0,0,1,4.61-4.9l35.77-14.31,14.31-35.77a8,8,0,0,1,4.9-4.61l23.8-7.94A8,8,0,0,1,232,121.73Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14h64a6,6,0,0,0,5.69-4.1l15.12-45.36,37.42-15a6,6,0,0,0,3.34-3.34l15-37.42L225.9,93.69A6,6,0,0,0,230,88V56A14,14,0,0,0,216,42ZM117.77,154.43a6,6,0,0,0-3.46,3.67L99.68,202H40a2,2,0,0,1-2-2V171.17l52.58-52.58a2,2,0,0,1,2.83,0L126,151.15ZM218,83.68,174.1,98.31a6,6,0,0,0-3.67,3.46l-15.05,37.61L138.1,146.3l-36.2-36.2a14,14,0,0,0-19.8,0L38,154.2V56a2,2,0,0,1,2-2H216a2,2,0,0,1,2,2Zm9.51,33.18a6,6,0,0,0-5.41-.82L198.3,124a6,6,0,0,0-3.67,3.47L180,164l-36.56,14.63A6,6,0,0,0,140,182.3L132,206.1a6,6,0,0,0,5.69,7.9H216a14,14,0,0,0,14-14V121.73A6,6,0,0,0,227.51,116.86ZM218,200a2,2,0,0,1-2,2H146.06l4.42-13.26,36.37-14.55a6,6,0,0,0,3.34-3.34l14.55-36.37L218,130.06Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16h64a8,8,0,0,0,7.59-5.47l14.83-44.48L163,151.43a8.07,8.07,0,0,0,4.46-4.46l14.62-36.55,44.48-14.83A8,8,0,0,0,232,88V56A16,16,0,0,0,216,40ZM112.41,157.47,98.23,200H40V172l52-52,30.42,30.42L117,152.57A8,8,0,0,0,112.41,157.47ZM216,82.23,173.47,96.41a8,8,0,0,0-4.9,4.62l-14.72,36.82L138.58,144l-35.27-35.27a16,16,0,0,0-22.62,0L40,149.37V56H216Zm12.68,33a8,8,0,0,0-7.21-1.1l-23.8,7.94a8,8,0,0,0-4.9,4.61l-14.31,35.77-35.77,14.31a8,8,0,0,0-4.61,4.9l-7.94,23.8A8,8,0,0,0,137.73,216H216a16,16,0,0,0,16-16V121.73A8,8,0,0,0,228.68,115.24ZM216,200H148.83l3.25-9.75,35.51-14.2a8.07,8.07,0,0,0,4.46-4.46l14.2-35.51,9.75-3.25Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12h64a4,4,0,0,0,3.79-2.74L123.21,163l38.28-15.31a4,4,0,0,0,2.22-2.22L179,107.21l46.24-15.42A4,4,0,0,0,228,88V56A12,12,0,0,0,216,44ZM118.51,156.29a4,4,0,0,0-2.3,2.45L101.12,204H40a4,4,0,0,1-4-4V170.34l53.17-53.17a4,4,0,0,1,5.66,0l34.71,34.71ZM220,85.12l-45.26,15.09a4,4,0,0,0-2.45,2.3l-15.37,38.41-19.3,7.73-37.13-37.14a12,12,0,0,0-17,0L36,159V56a4,4,0,0,1,4-4H216a4,4,0,0,1,4,4Zm6.34,33.37a4,4,0,0,0-3.6-.55l-23.81,7.93a4,4,0,0,0-2.44,2.31l-15,37.36-37.36,15a4,4,0,0,0-2.31,2.44l-7.93,23.81a4,4,0,0,0,.55,3.6,4,4,0,0,0,3.24,1.66H216a12,12,0,0,0,12-12V121.73A4,4,0,0,0,226.34,118.49ZM220,200a4,4,0,0,1-4,4H143.28l5.59-16.78,37.23-14.89a4,4,0,0,0,2.23-2.23l14.89-37.23L220,127.28Z"}))]]),kr=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M160,88a16,16,0,1,1,16,16A16,16,0,0,1,160,88Zm76-32V160a20,20,0,0,1-20,20H204v20a20,20,0,0,1-20,20H40a20,20,0,0,1-20-20V88A20,20,0,0,1,40,68H60V56A20,20,0,0,1,80,36H216A20,20,0,0,1,236,56ZM180,180H80a20,20,0,0,1-20-20V92H44V196H180Zm-21.66-24L124,121.66,89.66,156ZM212,60H84v67.72l25.86-25.86a20,20,0,0,1,28.28,0L192.28,156H212Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,56v82.06l-23.72-23.72a8,8,0,0,0-11.31,0L163.31,140,113.66,90.34a8,8,0,0,0-11.32,0L64,128.69V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z",opacity:"0.2"}),s.createElement("path",{d:"M216,40H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V184h16a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM72,56H216v62.75l-10.07-10.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L72,109.37ZM184,200H40V88H56v80a16,16,0,0,0,16,16H184Zm32-32H72V132l36-36,49.66,49.66a8,8,0,0,0,11.31,0L194.63,120,216,141.38V168ZM160,84a12,12,0,1,1,12,12A12,12,0,0,1,160,84Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V184h16a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM172,72a12,12,0,1,1-12,12A12,12,0,0,1,172,72Zm12,128H40V88H56v80a16,16,0,0,0,16,16H184Zm32-32H72V120.69l30.34-30.35a8,8,0,0,1,11.32,0L163.31,140,189,114.34a8,8,0,0,1,11.31,0L216,130.07V168Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,42H72A14,14,0,0,0,58,56V74H40A14,14,0,0,0,26,88V200a14,14,0,0,0,14,14H184a14,14,0,0,0,14-14V182h18a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42ZM70,56a2,2,0,0,1,2-2H216a2,2,0,0,1,2,2v67.57L204.53,110.1a14,14,0,0,0-19.8,0l-21.42,21.41L117.9,86.1a14,14,0,0,0-19.8,0L70,114.2ZM186,200a2,2,0,0,1-2,2H40a2,2,0,0,1-2-2V88a2,2,0,0,1,2-2H58v82a14,14,0,0,0,14,14H186Zm30-30H72a2,2,0,0,1-2-2V131.17l36.58-36.58a2,2,0,0,1,2.83,0l49.66,49.66a6,6,0,0,0,8.49,0l25.65-25.66a2,2,0,0,1,2.83,0l22,22V168A2,2,0,0,1,216,170ZM162,84a10,10,0,1,1,10,10A10,10,0,0,1,162,84Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,40H72A16,16,0,0,0,56,56V72H40A16,16,0,0,0,24,88V200a16,16,0,0,0,16,16H184a16,16,0,0,0,16-16V184h16a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM72,56H216v62.75l-10.07-10.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L72,109.37ZM184,200H40V88H56v80a16,16,0,0,0,16,16H184Zm32-32H72V132l36-36,49.66,49.66a8,8,0,0,0,11.31,0L194.63,120,216,141.38V168ZM160,84a12,12,0,1,1,12,12A12,12,0,0,1,160,84Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M216,44H72A12,12,0,0,0,60,56V76H40A12,12,0,0,0,28,88V200a12,12,0,0,0,12,12H184a12,12,0,0,0,12-12V180h20a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44ZM68,56a4,4,0,0,1,4-4H216a4,4,0,0,1,4,4v72.4l-16.89-16.89a12,12,0,0,0-17,0l-22.83,22.83L116.49,87.51a12,12,0,0,0-17,0L68,119ZM188,200a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V88a4,4,0,0,1,4-4H60v84a12,12,0,0,0,12,12H188Zm28-28H72a4,4,0,0,1-4-4V130.34l37.17-37.17a4,4,0,0,1,5.66,0l49.66,49.66a4,4,0,0,0,5.65,0l25.66-25.66a4,4,0,0,1,5.66,0L220,139.71V168A4,4,0,0,1,216,172ZM164,84a8,8,0,1,1,8,8A8,8,0,0,1,164,84Z"}))]]),ct=s.forwardRef((t,r)=>s.createElement(be,{ref:r,...t,weights:Ar}));ct.displayName="ArrowLeftIcon";const Hr=ct,dt=s.forwardRef((t,r)=>s.createElement(be,{ref:r,...t,weights:Rr}));dt.displayName="ArrowUpRightIcon";const ut=dt,mt=s.forwardRef((t,r)=>s.createElement(be,{ref:r,...t,weights:Ir}));mt.displayName="ImageBrokenIcon";const _r=mt,ht=s.forwardRef((t,r)=>s.createElement(be,{ref:r,...t,weights:kr}));ht.displayName="ImagesIcon";const Mr=ht,Cr=({project:t,onRename:r,onRemove:a,onSetPinned:i})=>{const o=le(),l=s.useRef(null),n=s.useRef(null),d=s.useRef(null),[p,g]=s.useState(!1),[v,m]=s.useState(!1),y=!!t.pinnedAt,[j,L]=s.useState(null),[N,f]=s.useState(t.name),[w,P]=s.useState(!1),[h,C]=s.useState(null);let A=j==="rename"?"Save name":"Remove from projects";w&&(A="Saving…"),s.useEffect(()=>{var b;if(v||!d.current)return;const S=d.current==="button"?n:l;d.current=null,(b=S.current)==null||b.focus()},[v]);const H=S=>{g(S),o==null||o.capture(S?"library_project_menu_opened":"library_project_menu_closed")},O=async S=>{if(!v){d.current=S,m(!0),o==null||o.capture("library_project_pin_clicked",{is_pinning:!y,method:S});try{await i(t.id,!y)}catch(b){st.error($e(b,"Could not save pin. Try again."))}finally{m(!1)}}},F=S=>{f(t.name),C(null),L(S),o==null||o.capture("library_project_action_opened",{action:S})},I=S=>{o==null||o.capture("library_project_action_closed",{action:j,outcome:S}),L(null)},z=async()=>{if(!(w||!j||j==="rename"&&!N.trim())){P(!0),C(null);try{j==="rename"?await r(t.id,N.trim()):await a(t.id),I("completed")}catch(S){C($e(S,"Could not save changes. Try again."))}finally{P(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-center gap-0.5 group-hover/project:pointer-events-auto group-hover/project:opacity-100 has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100 ${p?"pointer-events-auto opacity-100":"pointer-events-none opacity-0"}`,children:[e.jsx(_,{ref:n,type:"button",variant:"ghost",size:"icon-compact",title:y?"Unpin project":"Pin project","aria-label":`${y?"Unpin":"Pin"} ${t.name}`,"aria-pressed":y,disabled:v,onClick:()=>{O("button")},children:e.jsx(Ne,{weight:y?"fill":"bold",size:16,"aria-hidden":!0})}),e.jsxs(Ct,{isOpen:p,onOpenChange:H,children:[e.jsx(Pt,{asChild:!0,children:e.jsx(_,{ref:l,type:"button",variant:"ghost",size:"icon-compact","aria-label":`Actions for ${t.name}`,children:e.jsx(Vt,{size:16,weight:"bold","aria-hidden":!0})})}),e.jsxs(Zt,{"data-rivet-private":!0,"aria-label":"Project actions",align:"start",onCloseAutoFocus:S=>{j&&S.preventDefault()},className:"ph-no-capture min-w-44",children:[e.jsxs(we,{disabled:v,onSelect:()=>void O("menu"),children:[e.jsx(Ne,{size:14,weight:y?"fill":"bold","aria-hidden":!0}),y?"Unpin":"Pin"]}),e.jsxs(we,{onSelect:()=>F("rename"),children:[e.jsx(Tt,{size:14,weight:"bold","aria-hidden":!0}),"Rename"]}),e.jsxs(we,{onSelect:()=>F("remove"),children:[e.jsx(Je,{size:14,weight:"bold","aria-hidden":!0}),"Remove from projects"]})]})]})]}),e.jsx(Xe,{open:j!==null,onOpenChange:S=>{!S&&!w&&I("cancelled")},children:e.jsxs(et,{surface:"library","data-rivet-private":!0,onCloseAutoFocus:S=>{var b;S.preventDefault(),(b=l.current)==null||b.focus()},className:"ph-no-capture w-[calc(100%-2rem)] max-w-sm",children:[e.jsx(tt,{className:"text-base font-medium break-words",children:j==="rename"?"Rename project":`Remove “${t.name}” from projects?`}),e.jsx(rt,{className:"mt-2 text-sm leading-6 text-white/60",children:j==="rename"?"Choose a display name for this project. Its folder name will stay the same.":"Your folders and saved variants will remain on this computer. Open the project again to restore it."}),e.jsxs("form",{onSubmit:S=>{S.preventDefault(),z()},children:[j==="rename"?e.jsxs("label",{className:"mt-5 block text-xs text-white/70",children:["Project name",e.jsx("input",{autoFocus:!0,value:N,onChange:S=>f(S.target.value),maxLength:Ot,disabled:w,className:"focus:border-soft-foreground mt-2 w-full rounded-lg border border-white/15 bg-white/5 px-3 py-2 text-sm text-white outline-hidden transition-colors"})]}):null,h?e.jsx("p",{role:"alert",className:"text-accent-error mt-4 text-xs",children:h}):null,e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(_,{type:"button",variant:"ghost",disabled:w,onClick:()=>I("cancelled"),children:"Cancel"}),e.jsx(_,{type:"submit",variant:"secondary",disabled:w||j==="rename"&&!N.trim(),children:A})]})]})]})})]})},pt=6e4,ft=60*pt,ve=24*ft,Pr=7*ve,Vr=30*ve,Zr=365*ve,Tr=[["year",Zr],["month",Vr],["week",Pr],["day",ve],["hour",ft],["minute",pt]],Or=new Intl.RelativeTimeFormat("en",{numeric:"always"}),Fr=t=>{const r=new Map;for(const a of t??[]){const i=Date.parse(a.createdAt);if(!Number.isFinite(i))continue;const o=r.get(a.projectId);(o===void 0||i>o)&&r.set(a.projectId,i)}return r},Dr=({projects:t,latestEdits:r})=>[...t].sort((a,i)=>{if(a.pinnedAt&&!i.pinnedAt)return-1;if(i.pinnedAt&&!a.pinnedAt)return 1;if(a.pinnedAt&&i.pinnedAt)return a.pinnedAt.localeCompare(i.pinnedAt)||a.id.localeCompare(i.id);const o=r.get(a.id),l=r.get(i.id);return o===void 0&&l!==void 0?1:l===void 0&&o!==void 0?-1:(l??0)-(o??0)||a.name.localeCompare(i.name)||a.id.localeCompare(i.id)}),$r=({editedAt:t,now:r})=>{const a=Math.max(0,r-t);for(const[i,o]of Tr)if(a>=o)return`Edited ${Or.format(-Math.floor(a/o),i)}`;return"Edited just now"},xt=s.createContext(null),qr=({navigation:t,onBrowseProjects:r,controls:a,isHeaderVisible:i=!0,children:o})=>{const[l,n]=s.useState(null);return e.jsxs(xt.Provider,{value:l,children:[i?e.jsxs("div",{className:"grid shrink-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-4 px-10 py-5 max-sm:px-5 sm:grid-cols-[auto_minmax(0,1fr)_auto]",children:[e.jsx("button",{onClick:r,"aria-label":"Projects",className:"hover:bg-hover focus-visible:border-muted-foreground focus-visible:bg-active -m-1 flex items-center rounded-lg border border-transparent p-[3px] transition-colors outline-hidden",children:e.jsx("img",{src:Ft,alt:"","aria-hidden":!0,draggable:!1,className:"h-8 w-8"})}),e.jsx("div",{ref:n,className:"col-span-2 row-start-2 flex min-w-0 items-center gap-3 sm:col-span-1 sm:col-start-2 sm:row-start-1",children:a}),e.jsx("div",{className:"col-start-2 row-start-1 justify-self-end sm:col-start-3",children:t})]}):null,o]})},bt=({children:t})=>{const r=s.useContext(xt);return r?Dt.createPortal(t,r):null},_e=({label:t,value:r,onChange:a,onBlur:i,isDisabled:o=!1})=>e.jsxs("label",{className:"not-focus-within:has-[:enabled]:hover:border-border focus-within:border-muted-foreground focus-within:bg-hover focus-within:text-soft-foreground flex w-64 min-w-0 items-center gap-2 rounded-lg border border-white/[0.08] bg-white/[0.02] px-3 py-2.5 text-white/35 transition-colors max-sm:flex-1",children:[e.jsx($t,{size:14,weight:"bold",className:"shrink-0","aria-hidden":!0}),e.jsx("input",{type:"search","aria-label":t,placeholder:`${t}…`,value:r,onChange:l=>a==null?void 0:a(l.target.value),onBlur:i,disabled:o,className:"min-w-0 flex-1 bg-transparent text-xs text-white outline-hidden placeholder:text-white/30 disabled:opacity-40 [&::-webkit-search-cancel-button]:hidden"})]}),zr=({projects:t,variants:r,historyError:a,onRetryHistory:i,projectPreviews:o={},selectedProjectId:l,onSelectProject:n,onBrowseLibrary:d,onOpenProject:p,onRenameProject:g,onRemoveProject:v,onSetProjectPinned:m,isOpeningProject:y=!1,projectOpenError:j,onSearchCompleted:L,accountMenu:N,navigation:f,view:w="library",children:P})=>{const[h,C]=s.useState(""),A=l===null||P===void 0,H=s.useRef(null),O=Fr(r),[F]=s.useState(Date.now),I=t.find(b=>b.id===l),z=new Map;if(r)for(const b of t)b.historyIssue||z.set(b.id,0);for(const{projectId:b}of r??[]){const G=z.get(b);G!==void 0&&z.set(b,G+1)}const S=Dr({projects:t.filter(b=>b.name.toLowerCase().includes(h.toLowerCase())),latestEdits:O});return e.jsx("div",{className:"ph-no-capture bg-background text-foreground flex h-screen min-h-0","data-rivet-private":!0,children:e.jsx("main",{className:"relative flex min-w-0 flex-1 flex-col overflow-hidden",children:e.jsxs(qr,{navigation:f,onBrowseProjects:d,isHeaderVisible:A,controls:w==="library"?e.jsx(_e,{label:"Search projects",value:h,onChange:C,onBlur:()=>L==null?void 0:L(h.length)}):null,children:[j?e.jsx("p",{role:"alert",className:"text-accent-error px-10 pt-5 text-xs",children:j}):null,P!==void 0?P:e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-10 pb-10 max-sm:px-5",children:[e.jsx("h1",{ref:H,tabIndex:-1,className:"sr-only",children:"Projects"}),e.jsx("div",{className:"mb-9 flex items-center justify-end",children:e.jsx(_,{onClick:()=>p(),variant:"secondary",disabled:y,leadingIcon:qe,className:"shrink-0",children:"Open project…"})}),a?e.jsxs("div",{role:"alert",className:"mb-6 flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"text-accent-error",children:a}),e.jsx(_,{onClick:i,variant:"ghost",size:"compact",className:"shrink-0",children:"Retry history"})]}):null,I!=null&&I.issue?e.jsx("p",{role:"alert",className:"border-accent-warning/10 bg-accent-warning/[0.03] mb-6 rounded-lg border p-4 text-xs leading-6 text-white/70",children:I.issue}):null,I&&!I.isAvailable?e.jsxs("div",{className:"border-accent-warning/10 bg-accent-warning/[0.03] mb-6 flex items-center justify-between gap-4 rounded-lg border p-4 text-xs text-white/60",children:[e.jsxs("span",{children:["Locate ",I.name,"’s working folder to open its workspace."]}),e.jsx(_,{disabled:y,onClick:()=>p(I.id),variant:"secondary",size:"compact",className:"shrink-0",children:"Locate folder"})]}):null,e.jsxs("div",{className:"grid items-start gap-x-6 gap-y-8 sm:grid-cols-2",children:[S.map(b=>{const G=z.get(b.id);let Y="Loading variants…";G!==void 0?Y=`${G.toLocaleString()} ${G===1?"variant":"variants"}`:(a||b.historyIssue)&&(Y="Variants unavailable");const u=O.get(b.id);let R="No edits yet";a||b.historyIssue?R="Edit history unavailable":r===void 0?R="Loading edits…":G&&(R="Edit date unavailable");const U=o[b.id];return e.jsxs("div",{className:"group/project grid min-w-0",children:[e.jsxs("button",{onClick:()=>{C(""),n(b.id)},className:"group hover:bg-hover focus-visible:bg-active col-start-1 row-span-2 row-start-1 -m-2 grid w-[calc(100%+1rem)] min-w-0 grid-rows-subgrid rounded-2xl p-2 text-left transition-colors outline-hidden",children:[e.jsx("span",{className:"group-hover:border-border group-focus-visible:border-muted-foreground relative block aspect-video overflow-hidden rounded-xl border border-white/[0.08] bg-white/[0.02]",children:U?e.jsx("img",{src:U.dataUrl,alt:`${b.name} — ${U.label}`,draggable:!1,className:"h-full w-full object-cover object-top"}):null}),e.jsxs("span",{className:"mt-3 block pr-16",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-sm font-medium",children:[b.pinnedAt?e.jsx(Ne,{size:12,weight:"fill","aria-hidden":!0,className:"text-soft-foreground shrink-0"}):null,e.jsx("span",{className:"truncate",children:b.name})]}),e.jsxs("span",{className:"text-muted-foreground group-hover:text-soft-foreground group-focus-visible:text-soft-foreground mt-2 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs",children:[u!==void 0?e.jsx("time",{dateTime:new Date(u).toISOString(),title:new Date(u).toLocaleString(),children:$r({editedAt:u,now:F})}):e.jsx("span",{children:R}),e.jsx("span",{className:"shrink-0",children:Y})]}),b.isAvailable?null:e.jsx("span",{className:"text-accent-warning mt-2 block text-xs",children:"Folder unavailable"})]})]}),e.jsx("div",{className:"z-content col-start-1 row-start-2 mt-3 self-center justify-self-end",children:e.jsx(Cr,{project:b,onRename:g,onSetPinned:m,onRemove:async K=>{var X;await v(K),(X=H.current)==null||X.focus()}})})]},b.id)}),S.length===0?e.jsxs("div",{className:"col-span-full flex min-h-80 flex-col items-center justify-center rounded-xl border border-dashed border-white/10 px-8 text-center",children:[e.jsx(qe,{size:26,weight:"bold",className:"mb-5 text-white/25","aria-hidden":!0}),e.jsx("h2",{className:"text-sm font-medium",children:h?"No matching projects":"Add your projects"}),e.jsx("p",{className:"text-muted-foreground mt-2 max-w-sm text-xs leading-6",children:h?"Try another project name.":"Open an existing project to add it as a project here"}),h?null:e.jsx(_,{onClick:()=>p(),variant:"secondary",disabled:y,className:"mt-5",children:"Open project"})]}):null]})]}),A&&N?e.jsx("footer",{className:"border-surface-2 bg-card shrink-0 border-t px-2.5 py-2.5",children:N}):null]})})})},gt=8,Ke=1,Ur=({children:t})=>e.jsx("ul",{className:"grid grid-cols-1 items-start gap-x-5 min-[400px]:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",style:{gridAutoRows:`${gt}px`},children:t}),Kr=({children:t})=>{const[r,a]=s.useState(Ke),i=s.useRef(null),o=s.useCallback(l=>{var d;if((d=i.current)==null||d.disconnect(),!l)return;const n=()=>a(Math.max(Ke,Math.ceil(l.getBoundingClientRect().height/gt)));n(),i.current=new ResizeObserver(n),i.current.observe(l)},[]);return e.jsx("li",{className:"min-w-0",style:{gridRowEnd:`span ${r}`},children:e.jsx("div",{ref:o,className:"relative pb-8",children:t})})},Qr=async({profileId:t,referenceId:r,hash:a,signal:i})=>{const o=await qt(`/api/library/profile/references/${encodeURIComponent(r)}/media/${a}?${new URLSearchParams({profileId:t})}`,{signal:i});if(!o.ok)throw new Error("Image unavailable");return o.blob()},Br="200px",vt=({profileId:t,referenceId:r,hash:a,title:i,isDetail:o=!1})=>{const[l,n]=s.useState(!1),[d,p]=s.useState(!1),g=s.useRef(null),v=s.useCallback(j=>{var L;(L=g.current)==null||L.disconnect(),j&&(g.current=new IntersectionObserver(N=>{var f;N.some(w=>w.isIntersecting)&&(n(!0),(f=g.current)==null||f.disconnect())},{rootMargin:Br}),g.current.observe(j))},[]),m=ee({queryKey:T.designLibraryImage({profileId:t,referenceId:r,hash:a}),queryFn:async({signal:j})=>{const L=await Qr({profileId:t,referenceId:r,hash:a,signal:j});return new Promise((N,f)=>{const w=new FileReader;w.onload=()=>typeof w.result=="string"?N(w.result):f(new Error("Image unavailable")),w.onerror=()=>f(new Error("Image unavailable")),w.readAsDataURL(L)})},enabled:l,staleTime:1/0,gcTime:0,retry:!1}),y=!!m.data&&!d;return e.jsxs("div",{ref:v,className:xe("flex items-center justify-center overflow-hidden bg-white/[0.025]",o?"min-h-32":null,!o&&!y?"aspect-[4/3]":null),children:[m.isError||d?e.jsxs("span",{className:"text-muted-foreground flex items-center gap-2 p-5 text-xs",children:[e.jsx(_r,{size:16,weight:"bold","aria-hidden":!0}),"Image unavailable"]}):null,m.data&&!d?e.jsx("img",{src:m.data,alt:i,onError:()=>p(!0),className:o?"max-h-[65vh] w-full object-contain":"block h-auto w-full"}):null,!m.data&&!m.isError?e.jsx("span",{className:"text-muted-foreground text-xs",children:"Loading image…"}):null]})},Wr={arena:"Are.na",cosmos:"Cosmos",pinterest:"Pinterest",x:"X",image:"Uploaded image",text:"Saved text",variant:"Saved direction",pdf:"PDF"},Gr=({provider:t})=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t==="arena"||t==="cosmos"||t==="pinterest"||t==="x"?e.jsx(zt,{provider:t,className:"h-3.5 w-3.5"}):null,Wr[t]]}),Yr=({label:t,onCopy:r,referenceCount:a=1})=>{const i=le(),[o,l]=s.useState("idle"),n=async()=>{l("copying");try{await r(),l("copied"),i==null||i.capture("library_reference_copy_completed",{reference_count:a,copy_kind:"agent"})}catch{l("failed"),st.error("Could not copy. Check clipboard access and try again."),i==null||i.capture("library_reference_copy_failed",{reference_count:a,copy_kind:"agent"})}},d=o==="copied"?at:Ut,p=o==="copied"?"Copied":t;return e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"secondary",size:"compact",leadingIcon:d,disabled:o==="copying",onClick:()=>void n(),"aria-label":p,"aria-live":"polite",children:e.jsxs("span",{className:"grid whitespace-nowrap",children:[e.jsx("span",{"aria-hidden":!0,className:"invisible col-start-1 row-start-1",children:t}),e.jsx("span",{className:"col-start-1 row-start-1",children:p})]})}),o==="failed"?e.jsx("span",{role:"alert",className:"sr-only",children:"Could not copy. Check clipboard access and try again."}):null]})},yt=se({id:q(),title:q(),provider:nt,isIncluded:ge()}),Jr=Kt.extend({sourceIds:oe(q()),observation:Qt.nullable()}),Xr=se({profileId:q(),revision:ae(),isEnabled:ge(),sources:oe(yt),references:oe(Jr)});se({query:q().trim().min(2).max(1e3),sourceId:q().min(1).max(200).optional(),limit:ae().int().min(1).max(100).default(24),runtime:Bt.default("codex")});const es=se({profileId:q(),query:q(),coverage:se({saved:ae(),analyzed:ae(),indexed:ae()}),results:oe(se({id:q(),key:q(),title:q(),provider:nt,url:q().optional(),description:q().nullable(),imageCount:ae(),sources:oe(yt),isIncluded:ge()}))}),jt=50,Qe=12,ts=q().regex(/^[a-f0-9]{12,64}@[1-9][0-9]*$/).refine(t=>Number.isSafeInteger(Number(t.split("@")[1])),"Invalid reference revision"),rs=se({profileId:q().uuid(),keys:oe(ts).min(1).max(jt),isDetailed:ge().default(!1)}),ss=t=>{const r=new Map;for(const a of t){const i=a.id.slice(0,Qe);r.set(i,(r.get(i)??0)+1)}return new Map(t.map(a=>{const i=a.id.slice(0,Qe),o=r.get(i)===1?i:a.id;return[a.id,`${o}@${a.revision}`]}))},as=({profileId:t,referenceKeys:r})=>{const a=rs.parse({profileId:t,keys:r});return["rivet","profile","reference",a.profileId,...a.keys].join(" ")},Me=t=>{const r=t.referenceKeys.length===1?"Copy to agent":`Copy ${t.referenceKeys.length} to agent`;return e.jsx(Yr,{label:r,referenceCount:t.referenceKeys.length,onCopy:()=>navigator.clipboard.writeText(as(t))})},ns=({profileId:t,reference:r,sources:a,referenceKey:i,children:o})=>{var p,g;const l=le(),n=r.title||"Untitled reference",d=r.url&&/^https?:\/\//i.test(r.url)?r.url:void 0;return e.jsxs(Xe,{onOpenChange:v=>l==null?void 0:l.capture(v?"library_reference_opened":"library_reference_closed",{provider:r.provider,media_count:r.media.length}),children:[e.jsx(Wt,{asChild:!0,children:o}),e.jsxs(et,{surface:"librarySheet",className:"ph-no-capture w-full max-w-2xl","data-rivet-private":!0,children:[e.jsxs("header",{className:"flex items-start justify-between gap-6 border-b border-white/[0.07] px-7 py-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(rt,{className:"text-muted-foreground mb-2 text-xs",children:e.jsx(Gr,{provider:r.provider})}),e.jsx(tt,{className:"text-lg leading-snug font-medium tracking-tight break-words",children:n})]}),e.jsx(Gt,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"icon-compact","aria-label":"Close reference",children:e.jsx(Je,{size:18,weight:"bold","aria-hidden":!0})})})]}),e.jsx("div",{className:"border-b border-white/[0.07] px-7 py-4",children:e.jsx(Me,{profileId:t,referenceKeys:[i]},r.revision)}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-7 overflow-y-auto px-7 py-6",children:[r.media.map(v=>e.jsx(vt,{profileId:t,referenceId:r.id,hash:v.hash,title:n,isDetail:!0},v.hash)),r.text?e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/70",children:r.text}):null,r.note?e.jsxs("section",{children:[e.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-medium",children:"Your note"}),e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/75",children:r.note})]}):null,e.jsxs("section",{children:[e.jsx("h3",{className:"text-muted-foreground mb-2 text-xs font-medium",children:((p=r.observation)==null?void 0:p.evidence)==="preference"?"Your preference":"Rivet’s analysis"}),e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/75",children:((g=r.observation)==null?void 0:g.description)??r.unsupportedReason??"No analysis saved yet."})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-muted-foreground mb-3 text-xs font-medium",children:"Saved in"}),e.jsx("ul",{className:"space-y-2",children:a.filter(v=>r.sourceIds.includes(v.id)).map(v=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-white/[0.035] px-3 py-2.5 text-xs",children:[e.jsx("span",{children:v.title}),v.isIncluded?null:e.jsx("span",{className:"text-muted-foreground",children:"Excluded from generation"})]},v.id))})]}),d?e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",onClick:()=>l==null?void 0:l.capture("library_reference_original_opened",{provider:r.provider}),className:"hover:text-foreground focus-visible:text-foreground focus-visible:bg-active -mx-1.5 -my-1 inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-white/70 underline-offset-4 transition-colors outline-hidden hover:underline focus-visible:underline",children:["Open original",e.jsx(ut,{size:14,weight:"bold","aria-hidden":!0})]}):null]})]})]})},Be="opacity-0 group-hover/card:opacity-100 group-focus-within/card:opacity-100 [@media(hover:none)]:opacity-100",is="pointer-events-none group-hover/card:pointer-events-auto group-focus-within/card:pointer-events-auto [@media(hover:none)]:pointer-events-auto",os=({profileId:t,reference:r,sources:a,referenceKey:i,isSelected:o,isSelectionDisabled:l,onSelect:n})=>{var g;const d=r.title||"Untitled reference",p=r.media[0];return e.jsxs("div",{className:"group/card relative",children:[e.jsx(ns,{profileId:t,reference:r,sources:a,referenceKey:i,children:e.jsx("button",{"aria-label":`Inspect ${d}`,className:"focus-visible:border-muted-foreground block w-full overflow-hidden border border-transparent text-left outline-hidden transition-colors",children:p?e.jsx(vt,{profileId:t,referenceId:r.id,hash:p.hash,title:d},p.hash):e.jsxs("div",{className:"border-border bg-surface-2 min-h-44 border p-5 pb-14",children:[e.jsx("p",{className:"text-soft-foreground text-sm font-medium",children:d}),e.jsx("p",{className:"text-muted-foreground mt-3 line-clamp-3 text-xs leading-5",children:((g=r.observation)==null?void 0:g.description)??r.text})]})})}),e.jsx("div",{"aria-hidden":!0,className:xe("pointer-events-none absolute inset-0 bg-black/40",Be)}),e.jsxs("div",{className:xe("absolute inset-x-0 bottom-0 z-10 flex items-center justify-between gap-2 p-2",o?null:Be,o?null:is),children:[e.jsxs("label",{className:"relative shrink-0 cursor-pointer",title:o?"Deselect":"Select",children:[e.jsx("input",{type:"checkbox","aria-label":`Select ${d}`,checked:o,disabled:l,onChange:n,className:"peer absolute inset-0 h-full w-full cursor-pointer opacity-0 outline-hidden disabled:cursor-default"}),e.jsx("span",{className:xe("peer-focus-visible:border-foreground peer-focus-visible:text-foreground flex h-7 w-7 items-center justify-center rounded-full border shadow-sm transition-colors peer-disabled:opacity-40 forced-colors:peer-focus-visible:outline-2 forced-colors:peer-focus-visible:outline-offset-2 forced-colors:peer-focus-visible:outline-solid",o?"border-primary bg-primary text-primary-foreground":"peer-enabled:peer-hover:text-foreground border-white/35 bg-black/60 text-white/70 peer-focus-visible:bg-black/80"),children:e.jsx(at,{size:14,weight:"bold","aria-hidden":!0})})]}),e.jsx(Me,{profileId:t,referenceKeys:[i]},r.revision)]})]})},pe=24,ls="200px",cs=350,ds=100,us=({snapshot:t})=>{var Y;const r=le(),[a,i]=s.useState(""),[o,l]=s.useState(""),n=s.useRef(null),[d,p]=s.useState(""),[g,v]=s.useState(pe),[m,y]=s.useState([]),j=s.useRef(null),L=ss(t.references),N=t.references.filter(u=>u.media.length>0),f=ee({queryKey:T.designReferenceSearch({profileId:t.profileId,revision:t.revision,references:t.references.map(({id:u,revision:R,sourceIds:U})=>[u,R,U]),search:o,sourceId:d}),queryFn:({signal:u})=>$("/profile/search",{schema:es,method:"POST",body:{query:o,sourceId:d||void 0,limit:ds},signal:u}),enabled:o.length>=2&&t.references.length>0,retry:!1}),w=t.references.filter(u=>m.includes(u.id)),P=w.flatMap(u=>{const R=L.get(u.id);return R?[R]:[]}),h=a.trim(),C=h.length>=2,A=C&&t.references.length>0&&(o!==h||f.isLoading),H=C&&!A&&f.isError,O=new Map(t.references.map(u=>[u.id,u])),F=C?(((Y=f.data)==null?void 0:Y.results)??[]).flatMap(({id:u})=>{const R=O.get(u);return R?[R]:[]}):N.filter(u=>!d||u.sourceIds.includes(d)),I=N.length>0,z=F.length,S=t.references.length>0?"No images yet":"Your library starts here",b=s.useCallback(u=>{var R;(R=j.current)==null||R.disconnect(),u&&(j.current=new IntersectionObserver(U=>{var K;U.some(X=>X.isIntersecting)&&((K=j.current)==null||K.disconnect(),v(Math.min(g+pe,z)))},{root:u.parentElement,rootMargin:ls}),j.current.observe(u))},[g,z]),G=u=>{const R=w.map(K=>K.id),U=R.includes(u)?R.filter(K=>K!==u):[...R,u];y(U),r==null||r.capture("library_reference_selection_changed",{selected_count:U.length})};return e.jsxs("div",{className:"ph-no-capture flex min-h-0 flex-1 flex-col","data-rivet-private":!0,children:[e.jsx(bt,{children:e.jsx(_e,{label:"Search references",value:a,onChange:u=>{i(u),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>l(u.trim()),cs),v(pe)},onBlur:()=>{var u;return r==null?void 0:r.capture("library_reference_search_completed",{query_length:a.length,result_count:C?((u=f.data)==null?void 0:u.results.length)??0:F.length})}})}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-10 pb-10 max-sm:px-5",children:[!t.isEnabled&&I?e.jsx("p",{className:"text-muted-foreground mb-5 text-xs",children:"Automatic use is paused. Your saved references are still here."}):null,I?e.jsx("div",{className:"mb-7 flex flex-wrap items-center gap-3",children:e.jsxs("select",{"aria-label":"Source",value:d,onChange:u=>{p(u.target.value),v(pe),r==null||r.capture("library_reference_source_filtered",{is_filtered:!!u.target.value})},className:"bg-background hover:border-border focus-visible:border-muted-foreground focus-visible:text-foreground max-w-64 rounded-lg border border-white/[0.08] px-3 py-2.5 text-xs text-white/60 transition-colors outline-hidden",children:[e.jsx("option",{value:"",children:"All sources"}),t.sources.map(u=>e.jsx("option",{value:u.id,children:u.title},u.id))]})}):null,P.length?e.jsxs("div",{className:"bg-background sticky top-0 z-20 mb-6 flex flex-wrap items-center gap-3 rounded-lg border border-white/10 p-3 shadow-lg",children:[e.jsxs("span",{className:"text-xs text-white/50",children:[P.length," selected"]}),e.jsx(Me,{profileId:t.profileId,referenceKeys:P},P.join(" ")),e.jsx(_,{variant:"ghost",size:"compact",onClick:()=>{y([]),r==null||r.capture("library_reference_selection_changed",{selected_count:0})},children:"Clear selection"})]}):null,C&&f.data&&f.data.coverage.analyzed<f.data.coverage.saved?e.jsxs("p",{role:"status",className:"text-muted-foreground mb-5 text-xs",children:[f.data.coverage.analyzed," of"," ",f.data.coverage.saved," references analyzed; results may be incomplete."]}):null,A?e.jsx("p",{role:"status",className:"text-muted-foreground py-10 text-center text-xs",children:"Searching references…"}):null,H?e.jsxs("div",{role:"alert",className:"text-accent-error py-10 text-center text-xs",children:[e.jsxs("p",{children:["Search is unavailable: ",f.error.message]}),e.jsx(_,{variant:"ghost",onClick:()=>{r==null||r.capture("library_reference_search_retry"),f.refetch()},children:"Try again"})]}):null,!A&&!H&&F.length?e.jsx(Ur,{children:F.slice(0,g).map(u=>{const R=L.get(u.id);return R?e.jsx(Kr,{children:e.jsx(os,{profileId:t.profileId,reference:u,sources:t.sources,referenceKey:R,isSelected:m.includes(u.id),isSelectionDisabled:!m.includes(u.id)&&P.length>=jt,onSelect:()=>G(u.id)})},u.id):null})}):null,!A&&!H&&!F.length?e.jsxs("div",{className:"flex min-h-72 flex-col items-center justify-center rounded-xl border border-dashed border-white/[0.08] px-6 text-center",children:[e.jsx(Mr,{size:28,weight:"light",className:"mb-5 text-white/25","aria-hidden":!0}),e.jsx("h2",{className:"text-sm text-white/75",children:I||C?"No references found":S}),e.jsx("p",{className:"text-muted-foreground mt-2 max-w-sm text-xs leading-6",children:I||C?"Try another search or choose a different source.":"Ask your agent to save a design reference with an image to your library. It will appear here, ready to browse."})]}):null,!A&&!H&&F.length>g?e.jsx("div",{ref:b,role:"status",className:"text-muted-foreground py-8 text-center text-xs",children:"Loading more references…"}):null]})]})},ms=1e4,hs=({onBrowseProjects:t})=>{var n,d;const r=it(),a=le(),i=ee({queryKey:T.designLibrary((n=r.data)==null?void 0:n.userId,(d=r.data)==null?void 0:d.isAuthenticated),queryFn:({signal:p})=>$("/profile/library",{schema:Xr,signal:p}),enabled:!r.isPending,refetchInterval:ms,gcTime:0,retry:!1}),o=()=>{a==null||a.capture("library_reference_retry"),i.refetch()},l=e.jsx(bt,{children:e.jsx(_e,{label:"Search references",value:"",isDisabled:!0})});return i.isError&&!i.data?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[l,e.jsxs("div",{className:"m-auto max-w-md px-8 text-center",children:[e.jsx("h1",{className:"mb-3 text-lg font-medium",children:"References"}),e.jsx("p",{role:"alert",className:"text-sm text-white/50",children:i.error.message}),e.jsx("div",{className:"mt-5 flex justify-center gap-3",children:e.jsx(_,{variant:"ghost",onClick:t,children:"Projects"})})]})]}):i.data?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[i.isError?e.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-4 border-b border-white/10 px-8 py-3 text-xs text-white/50",children:[e.jsx("span",{children:"Could not refresh. Showing the last saved results."}),e.jsx(_,{variant:"ghost",onClick:o,children:"Try again"})]}):null,e.jsx(us,{snapshot:i.data},i.data.profileId)]}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[l,e.jsx("p",{role:"status",className:"m-auto text-xs text-white/40",children:"Loading references…"})]})},ps=({view:t,onNavigate:r})=>e.jsx("nav",{"aria-label":"Library",className:"bg-surface-2 flex items-center gap-1 rounded-lg p-1",children:["library","references"].map(a=>e.jsx("a",{href:a==="library"?"/rivet/library":"/rivet/library/references","aria-current":t===a?"page":void 0,onClick:i=>{i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),r(a))},className:Yt("rounded-md px-3 py-2 text-xs outline-none forced-colors:focus-visible:outline-2 forced-colors:focus-visible:outline-offset-2 forced-colors:focus-visible:outline-solid",t===a?"bg-active text-foreground focus-visible:bg-selected forced-colors:bg-[Highlight] forced-colors:text-[HighlightText] forced-colors:forced-color-adjust-none forced-colors:focus-visible:bg-[Highlight]":"text-muted-foreground hover:text-soft-foreground focus-visible:bg-hover focus-visible:text-foreground"),children:a==="library"?"Projects":"References"},a))}),fs=()=>{const t=He(),r=async l=>{await t.cancelQueries({queryKey:T.projectLibrary.all}),t.setQueryData(T.projectLibrary.projects,n=>n&&{projects:l(n.projects)}),t.setQueriesData({queryKey:T.projectLibrary.histories},n=>{if(!n)return n;const d=l(n.projects),p=new Set(d.map(({id:g})=>g));return{projects:d,variants:n.variants.filter(({projectId:g})=>p.has(g))}}),t.invalidateQueries({queryKey:T.projectLibrary.all})},a=ce({mutationFn:({projectId:l,name:n})=>$(`/projects/${encodeURIComponent(l)}`,{schema:Ee,method:"PATCH",body:{name:n}}),onSuccess:({project:l})=>r(n=>n.map(d=>d.id===l.id?{...d,name:l.name}:d))}),i=ce({mutationFn:({projectId:l,isPinned:n})=>$(`/projects/${encodeURIComponent(l)}/pin`,{schema:Ee,method:n?"PUT":"DELETE"}),onSuccess:({project:l})=>r(n=>n.map(d=>d.id===l.id?{...d,pinnedAt:l.pinnedAt}:d))}),o=ce({mutationFn:l=>$(`/projects/${encodeURIComponent(l)}`,{schema:Jt,method:"DELETE"}),onSuccess:async(l,n)=>{await r(d=>d.filter(({id:p})=>p!==n)),await t.cancelQueries({queryKey:T.libraryProjectPreview.project(n)}),t.removeQueries({queryKey:T.libraryProjectPreview.project(n)})}});return{setProjectPinned:async(l,n)=>{await i.mutateAsync({projectId:l,isPinned:n})},renameProject:async(l,n)=>{await a.mutateAsync({projectId:l,name:n})},removeProject:async l=>{await o.mutateAsync(l)}}},We=2500,xs=500,bs=6e4,gs=[],vs=[],fe=({error:t,retry:r})=>e.jsxs("div",{className:"m-auto max-w-md px-8 text-center",children:[e.jsx("p",{className:"text-accent-error text-sm",children:t.message}),e.jsx(_,{onClick:r,variant:"tertiary",size:"compact",className:"mt-5",children:"Try again"})]}),ys=()=>{var Ce,Pe,Ve,Ze,Te,Oe;const t=le();Xt(it().data);const r=He(),{renameProject:a,removeProject:i,setProjectPinned:o}=fs(),l=s.useRef(),[n,d]=s.useState(()=>ze(new URL(window.location.href))),[p]=s.useState(()=>crypto.randomUUID()),g=s.useRef(0),v=s.useRef(null),m=ee({queryKey:T.projectLibrary.projects,queryFn:({signal:c})=>$("/projects",{schema:mr,signal:c}),refetchInterval:We,retry:!1}),y=((Ce=m.data)==null?void 0:Ce.projects)??gs,j=y.map(({id:c,projectPath:x})=>({id:c,projectPath:x})).sort((c,x)=>c.id.localeCompare(x.id)),L=ee({queryKey:T.projectLibrary.history(j),queryFn:({signal:c})=>$("",{schema:hr,signal:c}),placeholderData:c=>{if(!c)return;const x=new Map(c.projects.map(({id:V,projectPath:J})=>[V,J]));if(!y.every(({id:V,projectPath:J})=>x.get(V)===J))return;const k=new Set(y.map(({id:V})=>V));return{projects:c.projects.filter(({id:V})=>k.has(V)),variants:c.variants.filter(({projectId:V})=>k.has(V))}},enabled:y.length>0,refetchInterval:We,retry:!1}),N=new Map((Pe=L.data)==null?void 0:Pe.projects.map(c=>[c.id,c])),f=y.map(c=>{const x=N.get(c.id);return{...c,issue:x?x.issue:c.issue,historyIssue:x?x.historyIssue:c.historyIssue}}),w=((Ve=L.data)==null?void 0:Ve.variants)??vs,P=Lr({queries:f.map(c=>({queryKey:T.libraryProjectPreview.thumbnail(c.id,c.projectPath),queryFn:({signal:x})=>$(`/projects/${c.id}/thumbnail`,{schema:ur,signal:x}),enabled:n.kind==="library",refetchInterval:bs,retry:!1}))}),h=f.find(c=>c.id===n.projectId),C=er({name:h==null?void 0:h.name,projectPath:h==null?void 0:h.projectPath}),A=w.find(c=>c.projectId===n.projectId&&c.sessionId===n.sessionId&&c.variantId===n.variantId),H=s.useCallback(c=>{window.history.pushState(null,"",tr(c)),d(c)},[]);s.useEffect(()=>{const c=rr(C);return h?l.current=h.id:m.isSuccess&&!m.isFetching&&n.projectId===l.current&&n.projectId&&(l.current=void 0,H({kind:"library"})),c},[h,C,n.projectId,m.isSuccess,m.isFetching,H]),s.useEffect(()=>{const c=()=>d(ze(new URL(window.location.href)));return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]),s.useEffect(()=>{const c=new AbortController;let x;const k=async()=>{try{const V=await $(`/views/${p}`,{schema:ir,method:"PUT",body:{isFocused:document.visibilityState==="visible"&&document.hasFocus()},signal:c.signal});for(const J of V.navigations){if(c.signal.aborted)return;if(J.sequence>g.current){let ye="library";J.projectId&&(ye="workspace"),J.variantId&&(ye="preview"),H({...J,kind:ye}),g.current=J.sequence}await $(`/views/${p}/acknowledgements`,{schema:or,method:"POST",body:{sequence:J.sequence},signal:c.signal})}}catch{}c.signal.aborted||(x=setTimeout(()=>{k()},xs))};return k(),()=>{c.abort(),clearTimeout(x)}},[p,H]);const O=ee({queryKey:T.libraryWorkspace(n.projectId),queryFn:()=>$(`/projects/${n.projectId}/runtime`,{schema:pr,method:"POST"}),enabled:n.kind==="workspace"&&!!n.projectId&&(h==null?void 0:h.isAvailable)===!0,retry:!1,refetchOnWindowFocus:!1}),F=O.data?new URL(O.data.editorUrl).origin:null;s.useEffect(()=>{if(n.kind!=="workspace"||!F)return;const c=x=>{!v.current||x.source!==v.current.contentWindow||x.origin!==F||x.data!==lr||(t==null||t.capture("library_view_changed",{view:"projects"}),H({kind:"library"}))};return window.addEventListener("message",c),()=>window.removeEventListener("message",c)},[n.kind,F,H,t]);const I=ee({queryKey:T.libraryPreview({projectId:n.projectId,sessionId:n.sessionId,variantId:n.variantId}),queryFn:()=>$(`/projects/${n.projectId}/variants/${n.sessionId}/${n.variantId}/preview`,{schema:fr,method:"POST"}),enabled:n.kind==="preview"&&!!(A!=null&&A.hasStaticPreview),retry:!1,refetchOnWindowFocus:!1}),z=ce({mutationFn:c=>$(`/projects/${n.projectId}/variants/${n.sessionId}/${n.variantId}`,{schema:cr,method:"PATCH",body:{label:c}}),onSuccess:()=>r.invalidateQueries({queryKey:T.projectLibrary.all})}),S=c=>{const x=f.find(k=>k.id===c);t==null||t.capture("library_project_selected",{project_id:c,workspace_available:(x==null?void 0:x.isAvailable)??!1}),H({kind:"workspace",projectId:c})},b=ce({mutationFn:async c=>{const{projectPath:x}=await $("/folder-selections",{schema:dr,method:"POST"});return x===null?null:$(c?`/projects/${c}/workspace`:"/projects",{schema:Ee,method:c?"PATCH":"POST",body:{projectPath:x}})},onSuccess:c=>{c&&(r.invalidateQueries({queryKey:T.projectLibrary.all}),t==null||t.capture("library_project_selected",{project_id:c.project.id,workspace_available:c.project.isAvailable}),H({kind:"workspace",projectId:c.project.id}))},onSettled:(c,x,k)=>{t==null||t.capture("library_open_project_closed",{is_relink:!!k})}}),G=c=>{b.isPending||(t==null||t.capture("library_open_project_opened",{is_relink:!!c}),b.mutate(c))},Y=()=>{t==null||t.capture("library_view_changed",{view:"projects"}),H({kind:"library"})},u=()=>{t==null||t.capture("library_view_changed",{view:"workspace"}),H({...n,kind:"workspace"})},R=()=>{t==null||t.capture("library_history_retry"),L.refetch()};let U;if(n.kind==="workspace"&&(h==null?void 0:h.isAvailable)!==!1||n.kind==="preview"){let c=!1,x=e.jsxs("div",{className:"text-muted-foreground m-auto flex items-center gap-2 text-xs",children:[e.jsx(sr,{size:14,weight:"bold",className:"animate-spin","aria-hidden":!0}),"Opening ",(h==null?void 0:h.name)??"project","…"]});if(m.data&&!h||L.data&&n.variantId&&!A)x=e.jsx("div",{className:"m-auto text-sm text-white/60",children:"This project or direction is no longer in your library."});else if(n.kind==="preview"&&L.error&&!L.data)x=e.jsx(fe,{error:L.error,retry:R});else if(n.kind==="workspace"&&O.error)x=e.jsx(fe,{error:O.error,retry:()=>{O.refetch()}});else if(n.kind==="workspace"&&O.data){c=!0;const k=new URL(O.data.editorUrl);k.searchParams.set("library","1"),k.searchParams.set("libraryOrigin",window.location.origin),n.sessionId&&n.variantId&&(k.searchParams.set("historySession",n.sessionId),k.searchParams.set("historyVariant",n.variantId)),x=e.jsx("iframe",{ref:v,title:`${(h==null?void 0:h.name)??"Project"} workspace`,src:k.toString(),allow:"clipboard-write","data-rivet-private":!0,className:"ph-no-capture min-h-0 w-full flex-1 border-0"},k.toString())}else n.kind==="preview"&&I.error?x=e.jsx(fe,{error:I.error,retry:()=>{I.refetch()}}):n.kind==="preview"&&I.data?x=e.jsx("iframe",{title:`${(A==null?void 0:A.label)??"Saved direction"} preview`,src:I.data.url,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",className:"min-h-0 w-full flex-1 border-0 bg-white"}):n.kind==="preview"&&A&&!A.hasStaticPreview&&(x=e.jsxs("div",{className:"m-auto max-w-sm text-center",children:[e.jsx("p",{className:"text-sm",children:A.hasInteractivePreview?"Open this direction in its workspace":"This direction contains saved code changes"}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs leading-6",children:A.hasInteractivePreview?"Rivet will start the preview with this project’s dependencies and configuration.":"Open the project to continue working with its saved history."}),e.jsx(_,{onClick:u,disabled:(h==null?void 0:h.isAvailable)===!1,variant:"primary",className:"mt-5",children:"Open workspace"})]}));U=e.jsxs(e.Fragment,{children:[n.kind==="preview"?e.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-3 border-b border-white/[0.07] px-5",children:[e.jsx(_,{"aria-label":"Back to projects",onClick:Y,variant:"ghost",size:"icon-compact",children:e.jsx(Hr,{size:15,weight:"bold","aria-hidden":!0})}),e.jsx("span",{className:"text-muted-foreground text-xs",children:h==null?void 0:h.name}),A?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,className:"text-white/20",children:"/"}),e.jsxs("form",{onSubmit:k=>{k.preventDefault();const V=new FormData(k.currentTarget);z.mutate(String(V.get("label")))},className:"flex min-w-0 flex-1 gap-2",children:[e.jsx("input",{name:"label","aria-label":"Direction name",defaultValue:A.label,className:"hover:border-border focus-visible:border-muted-foreground focus-visible:bg-hover focus-visible:text-foreground -ml-2 max-w-xs min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-2 py-1 text-xs text-white/80 transition-colors outline-hidden"}),e.jsx(_,{type:"submit",disabled:z.isPending,variant:"ghost",size:"compact",children:"Rename"})]},`${A.projectId}:${A.variantId}`)]}):e.jsx("span",{className:"flex-1"}),n.kind==="preview"?e.jsx(_,{onClick:u,disabled:(h==null?void 0:h.isAvailable)===!1,variant:"tertiary",size:"compact",trailingIcon:ut,children:"Edit in project"}):null]}):null,n.kind==="workspace"&&!c?e.jsx(_,{onClick:Y,variant:"ghost",size:"compact",className:"absolute top-5 left-5",children:"Projects"}):null,z.error?e.jsx("p",{role:"alert",className:"text-accent-error px-5 py-2 text-xs",children:z.error.message}):null,x]})}let K=U;m.error&&!m.data?K=e.jsx(fe,{error:m.error,retry:()=>{m.refetch()}}):m.isPending&&(K=e.jsx("div",{role:"status",className:"text-muted-foreground flex min-h-0 flex-1 items-center justify-center text-xs",children:"Loading projects…"}));const X=n.kind==="references"?"references":"library",wt=e.jsx(ps,{view:X,onNavigate:c=>{t==null||t.capture("library_view_changed",{view:c==="references"?"references":"projects"}),H({kind:c})}});return n.kind==="references"&&(K=e.jsx(hs,{onBrowseProjects:Y})),e.jsxs(e.Fragment,{children:[e.jsx(zr,{projects:f,variants:(Ze=L.data)==null?void 0:Ze.variants,historyError:(Te=L.error)==null?void 0:Te.message,onRetryHistory:R,projectPreviews:Object.fromEntries(f.map((c,x)=>{var k,V;return[c.id,(V=(k=P[x])==null?void 0:k.data)==null?void 0:V.preview]})),selectedProjectId:n.projectId??null,onSelectProject:S,onBrowseLibrary:Y,navigation:wt,view:X,onOpenProject:G,onRenameProject:a,onRemoveProject:i,onSetProjectPinned:o,accountMenu:e.jsx(ar,{side:"top",align:"start"}),isOpeningProject:b.isPending,projectOpenError:(Oe=b.error)==null?void 0:Oe.message,onSearchCompleted:c=>t==null?void 0:t.capture("library_search_completed",{query_length:c}),children:K}),e.jsx(nr,{position:"bottom-right",theme:"dark"})]})},js=async t=>{const r=Nr(),a=await yr("/api/library/browser-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){const i=jr.safeParse(await a.json().catch(()=>null));throw new Error(i.success?i.data.error:"Could not start a library session.")}wr(Sr(await a.json()),r)},ws=()=>{const t=s.useSyncExternalStore(ot,br),{startLogin:r,isStartingLogin:a,loginError:i}=gr("library",js);return e.jsx(vr,{isSigningIn:a,onStartSignIn:()=>void r(),errorMessage:i??t})},Es=()=>s.useSyncExternalStore(ot,xr)?e.jsx(ys,{}):e.jsx(ws,{});export{Es as default};
2
+ //# sourceMappingURL=LibraryEntry-B8-RtQpK.js.map