rivet-design 0.27.1 → 0.28.1
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 +2 -6
- package/README.npm.md +2 -6
- package/dist/agent-variants/PreviewRuntime.d.ts +4 -0
- package/dist/agent-variants/PreviewRuntime.js +5 -3
- package/dist/agent-variants/WorktreeOrchestrator.js +6 -4
- package/dist/agent-variants/contracts.d.ts +4 -0
- package/dist/config/posthog.d.ts +2 -0
- package/dist/config/posthog.js +5 -0
- package/dist/services/DependencyPreparationService.js +44 -6
- package/dist/services/FeatureFlagService.js +2 -2
- package/dist/services/TelemetryService.js +2 -2
- package/dist/utils/failureReason.d.ts +1 -1
- package/dist/utils/failureReason.js +3 -0
- package/package.json +16 -26
- package/src/ui/dist/assets/LibraryEntry-DS6Ce0sW.js +112 -0
- package/src/ui/dist/assets/logo.png +0 -0
- package/src/ui/dist/assets/main-CQSk-6km.css +1 -0
- package/src/ui/dist/assets/main-DkKRuatC.js +218 -0
- package/src/ui/dist/assets/rivet-wordmark-orange-CYKVQDmG.svg +7 -0
- package/src/ui/dist/index.html +2 -2
- package/src/ui/dist/assets/LibraryEntry-BZ5EdFgA.js +0 -37
- package/src/ui/dist/assets/main-MepMmTwb.css +0 -1
- package/src/ui/dist/assets/main-RriU35pI.js +0 -497
- package/src/ui/dist/assets/rivet.svg +0 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rivet
|
|
2
2
|
|
|
3
|
-
Rivet
|
|
3
|
+
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. It opens a local visual editor, generates parallel variants, and lets you refine with comments.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -81,8 +81,6 @@ rivet variants start --project /path/to/app --instruction "try three hero layout
|
|
|
81
81
|
rivet wait <workId> --project /path/to/app --timeout 120
|
|
82
82
|
rivet variants list --project /path/to/app
|
|
83
83
|
rivet variants get <projectId>/<sessionId>:<variantId> --detail
|
|
84
|
-
rivet changes request --project /path/to/app --instruction "make the header coral" --element "#header"
|
|
85
|
-
rivet changes pull --project /path/to/app
|
|
86
84
|
rivet update
|
|
87
85
|
rivet stop --project /path/to/app
|
|
88
86
|
```
|
|
@@ -103,12 +101,10 @@ rivet open --project /path/to/app --caller-agent cursor --caller-model <model> -
|
|
|
103
101
|
## How It Works
|
|
104
102
|
|
|
105
103
|
1. `rivet open` starts or attaches to the local Rivet editor server for a project. It can attach to an existing dev server or start the app's standard `dev`, `start`, or `serve` script when possible.
|
|
106
|
-
2. The editor shows your app and variant previews in the browser. Agents use `rivet variants ...`
|
|
104
|
+
2. The editor shows your app and variant previews in the browser. Agents use `rivet variants ...` to enqueue work.
|
|
107
105
|
3. Use `rivet wait`, `rivet status`, or `rivet status --watch` to observe progress.
|
|
108
106
|
4. Copy the chosen direction’s context and ask your coding agent to implement it in your project. Rivet preserves the prototype; your agent owns integration and verification.
|
|
109
107
|
|
|
110
|
-
If Rivet reports pull mode, staged work can be drained with `rivet changes pull --project <path>`, applied by the agent, then acknowledged with `rivet changes pull --project <path> --ack <leaseId>`.
|
|
111
|
-
|
|
112
108
|
## Supported Frameworks
|
|
113
109
|
|
|
114
110
|
- Next.js
|
package/README.npm.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rivet
|
|
2
2
|
|
|
3
|
-
Rivet
|
|
3
|
+
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. It opens a local visual editor, generates parallel variants, and lets you refine with comments.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -81,8 +81,6 @@ rivet variants start --project /path/to/app --instruction "try three hero layout
|
|
|
81
81
|
rivet wait <workId> --project /path/to/app --timeout 120
|
|
82
82
|
rivet variants list --project /path/to/app
|
|
83
83
|
rivet variants get <projectId>/<sessionId>:<variantId> --detail
|
|
84
|
-
rivet changes request --project /path/to/app --instruction "make the header coral" --element "#header"
|
|
85
|
-
rivet changes pull --project /path/to/app
|
|
86
84
|
rivet update
|
|
87
85
|
rivet stop --project /path/to/app
|
|
88
86
|
```
|
|
@@ -103,12 +101,10 @@ rivet open --project /path/to/app --caller-agent cursor --caller-model <model> -
|
|
|
103
101
|
## How It Works
|
|
104
102
|
|
|
105
103
|
1. `rivet open` starts or attaches to the local Rivet editor server for a project. It can attach to an existing dev server or start the app's standard `dev`, `start`, or `serve` script when possible.
|
|
106
|
-
2. The editor shows your app and variant previews in the browser. Agents use `rivet variants ...`
|
|
104
|
+
2. The editor shows your app and variant previews in the browser. Agents use `rivet variants ...` to enqueue work.
|
|
107
105
|
3. Use `rivet wait`, `rivet status`, or `rivet status --watch` to observe progress.
|
|
108
106
|
4. Copy the chosen direction’s context and ask your coding agent to implement it in your project. Rivet preserves the prototype; your agent owns integration and verification.
|
|
109
107
|
|
|
110
|
-
If Rivet reports pull mode, staged work can be drained with `rivet changes pull --project <path>`, applied by the agent, then acknowledged with `rivet changes pull --project <path> --ack <leaseId>`.
|
|
111
|
-
|
|
112
108
|
## Supported Frameworks
|
|
113
109
|
|
|
114
110
|
- Next.js
|
|
@@ -3,6 +3,7 @@ import { type DevServerFailureReason } from '../utils/devServerError';
|
|
|
3
3
|
import type { ProjectContext } from './contracts';
|
|
4
4
|
import type { ProjectEnvironment, WorktreeManagerLike } from './variant-project-runtime';
|
|
5
5
|
import { type VariantsTelemetry } from './variantsTelemetry';
|
|
6
|
+
import { type FailureReasonCode } from '../utils/failureReason';
|
|
6
7
|
export type ResolvedDevServer = {
|
|
7
8
|
cwd: string;
|
|
8
9
|
cmd: string;
|
|
@@ -14,6 +15,9 @@ export type PreviewFailure = {
|
|
|
14
15
|
reason: DevServerFailureReason | 'missing_static_entry' | 'idle_timeout' | 'unknown';
|
|
15
16
|
portInUse: boolean;
|
|
16
17
|
detail?: string;
|
|
18
|
+
reasonCode?: FailureReasonCode;
|
|
19
|
+
reasonDetail?: string;
|
|
20
|
+
nodeVersion?: string;
|
|
17
21
|
};
|
|
18
22
|
type PreviewRuntimeDeps = {
|
|
19
23
|
worktreeManager: WorktreeManagerLike;
|
|
@@ -364,9 +364,14 @@ class PreviewRuntime {
|
|
|
364
364
|
const detail = devError?.detail ||
|
|
365
365
|
failure.detail ||
|
|
366
366
|
(error === undefined ? '' : (0, errorMessage_1.errorMessage)(error));
|
|
367
|
+
const reportedError = REPORTED_FAILURE_REASONS.has(failure.reason)
|
|
368
|
+
? error
|
|
369
|
+
: undefined;
|
|
367
370
|
this.requireSession(args.sessionId).failures.set(args.workItemId, {
|
|
368
371
|
...failure,
|
|
369
372
|
...(detail ? { detail } : {}),
|
|
373
|
+
...(reportedError === undefined ? {} : (0, failureReason_1.failureReason)(reportedError)),
|
|
374
|
+
nodeVersion: process.version,
|
|
370
375
|
});
|
|
371
376
|
let errorCode = 'DEV_SERVER_START_FAILED';
|
|
372
377
|
if (failure.reason === 'dependency_install_failed') {
|
|
@@ -374,9 +379,6 @@ class PreviewRuntime {
|
|
|
374
379
|
}
|
|
375
380
|
if (failure.reason === 'missing_dev_script')
|
|
376
381
|
errorCode = 'DEV_SCRIPT_MISSING';
|
|
377
|
-
const reportedError = REPORTED_FAILURE_REASONS.has(failure.reason)
|
|
378
|
-
? error
|
|
379
|
-
: undefined;
|
|
380
382
|
(0, variantsTelemetry_1.trackFreshDevServerFailed)(this.deps.telemetry, {
|
|
381
383
|
sessionId: args.sessionId,
|
|
382
384
|
variantId: args.workItemId,
|
|
@@ -2743,10 +2743,12 @@ class AgentVariantsOrchestrator {
|
|
|
2743
2743
|
await Promise.all(this.workspaceInventory
|
|
2744
2744
|
.getWorktrees(sessionId)
|
|
2745
2745
|
.map((record) => DependencyPreparationService_1.previewDependencies.settle(record.worktreePath)));
|
|
2746
|
-
await Promise
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2746
|
+
await new Promise((resolve) => {
|
|
2747
|
+
const timer = setTimeout(resolve, SETTLE_PERSISTS_TEARDOWN_TIMEOUT_MS);
|
|
2748
|
+
void this.settleHistoryPersists()
|
|
2749
|
+
.finally(() => clearTimeout(timer))
|
|
2750
|
+
.then(resolve);
|
|
2751
|
+
});
|
|
2750
2752
|
await this.previewRuntime.closeSession(sessionId);
|
|
2751
2753
|
await this.workspaceInventory.disposeAssignments({ sessionId });
|
|
2752
2754
|
this.resources.delete(sessionId);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GuidanceDocument } from '../types/guidance';
|
|
2
2
|
import type { WorkerSelection } from '../types/change-request-types';
|
|
3
3
|
import type { DirectionRef } from '../types/direction-ref';
|
|
4
|
+
import type { FailureReasonCode } from '../utils/failureReason';
|
|
4
5
|
import { type VariantReference } from '../types/variant-reference';
|
|
5
6
|
import { z } from 'zod/v3';
|
|
6
7
|
import { ERROR_CODES, type ErrorCode } from './errors';
|
|
@@ -6387,6 +6388,9 @@ export interface ActiveVariantSnapshot {
|
|
|
6387
6388
|
reason: 'spawn_error' | 'exited' | 'timeout' | 'compile_error' | 'dependency_install_failed' | 'missing_dev_script' | 'missing_static_entry' | 'idle_timeout' | 'unknown';
|
|
6388
6389
|
portInUse?: boolean;
|
|
6389
6390
|
detail?: string;
|
|
6391
|
+
reasonCode?: FailureReasonCode;
|
|
6392
|
+
reasonDetail?: string;
|
|
6393
|
+
nodeVersion?: string;
|
|
6390
6394
|
};
|
|
6391
6395
|
actions?: ActiveVariantActions;
|
|
6392
6396
|
refinement?: {
|
|
@@ -38,17 +38,40 @@ const INSTALL_ENVIRONMENT_PREFIXES = [
|
|
|
38
38
|
'corepack_',
|
|
39
39
|
];
|
|
40
40
|
const INSTALL_ENVIRONMENT_KEYS = new Set(['node_options', 'path']);
|
|
41
|
+
const INSTALL_FAILURE_CAUSES = [
|
|
42
|
+
{
|
|
43
|
+
reasonCode: 'lockfile_outdated',
|
|
44
|
+
pattern: /^error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`/m,
|
|
45
|
+
guidance: 'The lockfile does not match package.json. Update the lockfile in the project, commit it, then retry the preview.',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
reasonCode: 'engine_incompatible',
|
|
49
|
+
pattern: /^error .+: The engine "node" is incompatible with this module/m,
|
|
50
|
+
guidance: 'The project or one of its dependencies does not support the active Node.js version. Switch to a Node.js version the project supports, then retry the preview.',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
reasonCode: 'install_script_failed',
|
|
54
|
+
pattern: /^error .+: Command failed\.$/m,
|
|
55
|
+
guidance: 'A dependency install script failed. If it builds a native addon, switch to a Node.js version the project supports, then retry the preview.',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
const UNRECOGNIZED_INSTALL_FAILURE = {
|
|
59
|
+
reasonCode: 'install_failed',
|
|
60
|
+
guidance: 'Fix the installation error, then retry the preview.',
|
|
61
|
+
};
|
|
62
|
+
const installFailureCause = (output) => INSTALL_FAILURE_CAUSES.find(({ pattern }) => pattern.test(output));
|
|
41
63
|
const isInstallEnvironmentKey = (key) => {
|
|
42
64
|
const lower = key.toLowerCase();
|
|
43
65
|
return (INSTALL_ENVIRONMENT_PREFIXES.some((prefix) => lower.startsWith(prefix)) ||
|
|
44
66
|
INSTALL_ENVIRONMENT_KEYS.has(lower));
|
|
45
67
|
};
|
|
46
68
|
const yarnAgentForVersion = (version) => Number.parseInt(version, 10) > 1 ? 'yarn@berry' : 'yarn';
|
|
47
|
-
const preparationError = ({ reasonCode, message, detail = '', }) => new devServerError_1.DevServerStartError({
|
|
69
|
+
const preparationError = ({ reasonCode, message, detail = '', exitCode, }) => new devServerError_1.DevServerStartError({
|
|
48
70
|
message: detail ? `${message}\n${detail}` : message,
|
|
49
71
|
reason: 'dependency_install_failed',
|
|
50
72
|
portInUse: false,
|
|
51
73
|
detail,
|
|
74
|
+
exitCode,
|
|
52
75
|
reasonCode,
|
|
53
76
|
summary: message,
|
|
54
77
|
});
|
|
@@ -309,10 +332,13 @@ class DependencyPreparationService {
|
|
|
309
332
|
stdio: 'pipe',
|
|
310
333
|
});
|
|
311
334
|
let output = '';
|
|
335
|
+
let failureCause;
|
|
312
336
|
let interruption;
|
|
313
337
|
let settleTimer;
|
|
314
338
|
const drain = (chunk) => {
|
|
315
|
-
|
|
339
|
+
const received = output + chunk.toString();
|
|
340
|
+
failureCause ??= installFailureCause(received);
|
|
341
|
+
output = received.slice(-OUTPUT_TAIL_LIMIT);
|
|
316
342
|
};
|
|
317
343
|
proc.stdout?.on('data', drain);
|
|
318
344
|
proc.stderr?.on('data', drain);
|
|
@@ -351,14 +377,26 @@ class DependencyPreparationService {
|
|
|
351
377
|
});
|
|
352
378
|
proc.once('close', (code) => {
|
|
353
379
|
cleanup();
|
|
354
|
-
if (code === 0 && !interruption)
|
|
380
|
+
if (code === 0 && !interruption) {
|
|
355
381
|
resolve(output);
|
|
356
|
-
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const command = `${project.name} ${args.join(' ')}`;
|
|
385
|
+
if (interruption) {
|
|
357
386
|
reject(preparationError({
|
|
358
|
-
reasonCode: interruption
|
|
359
|
-
message: `Dependency preparation failed: ${
|
|
387
|
+
reasonCode: interruption,
|
|
388
|
+
message: `Dependency preparation failed: ${command} (cancelled or timed out). ${UNRECOGNIZED_INSTALL_FAILURE.guidance}`,
|
|
360
389
|
detail: output.trim(),
|
|
361
390
|
}));
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const { reasonCode, guidance } = failureCause ?? UNRECOGNIZED_INSTALL_FAILURE;
|
|
394
|
+
reject(preparationError({
|
|
395
|
+
reasonCode,
|
|
396
|
+
message: `Dependency preparation failed: ${command} (exit ${code}). ${guidance}`,
|
|
397
|
+
detail: output.trim(),
|
|
398
|
+
exitCode: code,
|
|
399
|
+
}));
|
|
362
400
|
});
|
|
363
401
|
});
|
|
364
402
|
}
|
|
@@ -5,9 +5,9 @@ const telemetryPolicy_1 = require("../config/telemetryPolicy");
|
|
|
5
5
|
const posthog_node_1 = require("posthog-node");
|
|
6
6
|
const logger_1 = require("../utils/logger");
|
|
7
7
|
const ConfigManager_1 = require("./ConfigManager");
|
|
8
|
+
const posthog_1 = require("../config/posthog");
|
|
8
9
|
const proxy_1 = require("../config/proxy");
|
|
9
10
|
const log = (0, logger_1.createLogger)('FeatureFlagService');
|
|
10
|
-
const POSTHOG_PUBLIC_API_KEY = 'phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH';
|
|
11
11
|
const remoteFlagsDisabled = () => {
|
|
12
12
|
const v = process.env.RIVET_DISABLE_REMOTE_FLAGS;
|
|
13
13
|
return v !== undefined && v !== 'false' && v !== '0';
|
|
@@ -20,7 +20,7 @@ class FeatureFlagService {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
try {
|
|
23
|
-
this.posthog = new posthog_node_1.PostHog(POSTHOG_PUBLIC_API_KEY, {
|
|
23
|
+
this.posthog = new posthog_node_1.PostHog(posthog_1.POSTHOG_PUBLIC_API_KEY, {
|
|
24
24
|
host: proxy_1.POSTHOG_HOST,
|
|
25
25
|
flushAt: 1,
|
|
26
26
|
flushInterval: 0,
|
|
@@ -11,6 +11,7 @@ const telemetryPolicy_1 = require("../config/telemetryPolicy");
|
|
|
11
11
|
const pluginMetrics_1 = require("../config/pluginMetrics");
|
|
12
12
|
const telemetryContract_1 = require("../config/telemetryContract");
|
|
13
13
|
const failureReason_1 = require("../utils/failureReason");
|
|
14
|
+
const posthog_1 = require("../config/posthog");
|
|
14
15
|
const proxy_1 = require("../config/proxy");
|
|
15
16
|
const MCPVariantsTelemetry_1 = require("./MCPVariantsTelemetry");
|
|
16
17
|
const errorMessage_1 = require("../utils/errorMessage");
|
|
@@ -41,7 +42,6 @@ const mcpEditorEventValue = (editor) => {
|
|
|
41
42
|
}
|
|
42
43
|
return 'other';
|
|
43
44
|
};
|
|
44
|
-
const POSTHOG_PUBLIC_API_KEY = 'phc_Ntj9tXHbS64XgYxlTfhglRmFivFsfm0AERph4ZlnNH';
|
|
45
45
|
const HASH_PREFIX_LENGTH = 12;
|
|
46
46
|
class TelemetryService {
|
|
47
47
|
trackGuidanceOperation(data) {
|
|
@@ -98,7 +98,7 @@ class TelemetryService {
|
|
|
98
98
|
this.editor = opts.editor;
|
|
99
99
|
if (this.isEnabled) {
|
|
100
100
|
try {
|
|
101
|
-
this.posthog = new posthog_node_1.PostHog(POSTHOG_PUBLIC_API_KEY, {
|
|
101
|
+
this.posthog = new posthog_node_1.PostHog(posthog_1.POSTHOG_PUBLIC_API_KEY, {
|
|
102
102
|
host: proxy_1.POSTHOG_HOST,
|
|
103
103
|
flushAt: 1,
|
|
104
104
|
flushInterval: 0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const FAILURE_REASON_CODES: readonly ["multiple_lockfiles", "unsupported_package_manager", "invalid_package_manager_field", "invalid_manifest", "invalid_workspace", "path_outside_workspace", "dangling_symlink", "version_unreadable", "version_mismatch", "no_install_command", "install_failed", "installer_unstoppable", "inputs_changed", "ENOENT", "EACCES", "EPERM", "EEXIST", "ENOTDIR", "EISDIR", "ELOOP", "ENOSPC", "EMFILE", "EADDRINUSE", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EBUSY", "ENOTSUP", "EINVAL", "ENOTEMPTY", "EROFS", "EAI_AGAIN", "timeout", "aborted", "unknown"];
|
|
1
|
+
export declare const FAILURE_REASON_CODES: readonly ["multiple_lockfiles", "unsupported_package_manager", "invalid_package_manager_field", "invalid_manifest", "invalid_workspace", "path_outside_workspace", "dangling_symlink", "version_unreadable", "version_mismatch", "no_install_command", "install_failed", "lockfile_outdated", "engine_incompatible", "install_script_failed", "installer_unstoppable", "inputs_changed", "ENOENT", "EACCES", "EPERM", "EEXIST", "ENOTDIR", "EISDIR", "ELOOP", "ENOSPC", "EMFILE", "EADDRINUSE", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EBUSY", "ENOTSUP", "EINVAL", "ENOTEMPTY", "EROFS", "EAI_AGAIN", "timeout", "aborted", "unknown"];
|
|
2
2
|
export type FailureReasonCode = (typeof FAILURE_REASON_CODES)[number];
|
|
3
3
|
export interface FailureReason {
|
|
4
4
|
reasonCode: FailureReasonCode;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rivet-design",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.28.1",
|
|
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",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"markdown-it": "^14.1.0",
|
|
88
88
|
"open": "^8.4.0",
|
|
89
89
|
"package-manager-detector": "^1.8.0",
|
|
90
|
-
"parse5": "^
|
|
90
|
+
"parse5": "^8.1.0",
|
|
91
91
|
"playwright-core": "^1.58.2",
|
|
92
92
|
"posthog-node": "^5.52.4",
|
|
93
93
|
"simple-git": "^4.0.2",
|
|
@@ -154,32 +154,22 @@
|
|
|
154
154
|
"README.npm.md"
|
|
155
155
|
],
|
|
156
156
|
"keywords": [
|
|
157
|
-
"
|
|
158
|
-
"
|
|
159
|
-
"
|
|
157
|
+
"design-agent",
|
|
158
|
+
"coding-agent",
|
|
159
|
+
"design-variants",
|
|
160
|
+
"design-exploration",
|
|
161
|
+
"mcp",
|
|
162
|
+
"claude-code",
|
|
163
|
+
"claude",
|
|
164
|
+
"cursor",
|
|
165
|
+
"codex",
|
|
160
166
|
"design-tools",
|
|
161
|
-
"
|
|
162
|
-
"
|
|
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"
|
|
167
|
+
"frontend-development",
|
|
168
|
+
"web-design"
|
|
172
169
|
],
|
|
173
170
|
"author": "Rivet Design",
|
|
174
171
|
"license": "GPL-3.0-or-later",
|
|
175
|
-
"
|
|
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",
|
|
172
|
+
"homepage": "https://rivet.design",
|
|
183
173
|
"publishConfig": {
|
|
184
174
|
"access": "public"
|
|
185
175
|
},
|
|
@@ -212,5 +202,5 @@
|
|
|
212
202
|
"rivetPlugin": {
|
|
213
203
|
"toolContract": "intent-v2"
|
|
214
204
|
},
|
|
215
|
-
"gitHead": "
|
|
205
|
+
"gitHead": "b2fbc13c45997a1b003d0e124016e384f648e0e7"
|
|
216
206
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var He=s=>{throw TypeError(s)};var je=(s,t,n)=>t.has(s)||He("Cannot "+n);var _=(s,t,n)=>(je(s,t,"read from private field"),n?n.call(s):t.get(s)),V=(s,t,n)=>t.has(s)?He("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,n),D=(s,t,n,r)=>(je(s,t,"write to private field"),r?r.call(s,n):t.set(s,n),n),G=(s,t,n)=>(je(s,t,"access private method"),n);import{S as Mt,n as Ne,s as zt,r as Tt,Q as Ze,u as Ae,a as Dt,b as $t,c as d,e as qt,d as Ft,f as Ht,g as Ut,h as Ue,i as Bt,j as Kt,k as de,l as Qt,m as e,B as Y,o as Se,P as Wt,p as Vt,q as Gt,t as Yt,D as et,v as tt,w as st,x as rt,y as nt,z as it,A as Jt,C as at,E as Be,F as Xt,G as Zt,H as es,I as te,J as ye,K as $,R as ts,L as ne,M as ss,N as rs,O as le,T as ns,U as ae,V as U,W as ot,X as ge,Y as is,Z as as,_ as H,$ as ct,a0 as os,a1 as ue,a2 as cs,a3 as _e,a4 as ls,a5 as Ke,a6 as ds,a7 as us,a8 as hs,a9 as ms,aa as xs,ab as ps,ac as fs,ad as bs,ae as ys,af as gs,ag as vs,ah as ws,ai as js,aj as lt,ak as ks,al as Ns,am as Ss,an as _s,ao as Cs,ap as Rs,aq as Is,ar as Ps}from"./main-DkKRuatC.js";function Qe(s,t){const n=new Set(t);return s.filter(r=>!n.has(r))}var oe,F,ce,se,Q,re,he,me,xe,pe,M,Ce,Re,dt,Ie,Pe,Ee,Xe,Es=(Xe=class extends Mt{constructor(t,n,r){super();V(this,M);V(this,oe);V(this,F);V(this,ce);V(this,se);V(this,Q);V(this,re);V(this,he);V(this,me);V(this,xe);V(this,pe,[]);D(this,oe,t),D(this,se,r),D(this,ce,[]),D(this,Q,[]),D(this,F,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&_(this,Q).forEach(t=>{t.subscribe(n=>{G(this,M,Pe).call(this,t,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,_(this,Q).forEach(t=>{t.destroy()})}setQueries(t,n){D(this,ce,t),D(this,se,n),Ne.batch(()=>{const r=_(this,Q),a=G(this,M,Ie).call(this,_(this,ce));a.forEach(m=>m.observer.setOptions(m.defaultedQueryOptions));const o=a.map(m=>m.observer),i=o.map(m=>m.getCurrentResult()),c=r.length!==o.length,h=o.some((m,w)=>m!==r[w]),f=c||h,k=f?!0:i.some((m,w)=>{const g=_(this,F)[w];return!g||!zt(m,g)});!f&&!k||(f&&(D(this,pe,a),D(this,Q,o)),D(this,F,i),this.hasListeners()&&(f&&(Qe(r,o).forEach(m=>{m.destroy()}),Qe(o,r).forEach(m=>{m.subscribe(w=>{G(this,M,Pe).call(this,m,w)})})),G(this,M,Ee).call(this)))})}getCurrentResult(){return _(this,F)}getQueries(){return _(this,Q).map(t=>t.getCurrentQuery())}getObservers(){return _(this,Q)}getOptimisticResult(t,n){const r=G(this,M,Ie).call(this,t),a=r.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions)),o=r.map(i=>i.defaultedQueryOptions.queryHash);return[a,i=>G(this,M,Re).call(this,i??a,n,o),()=>G(this,M,Ce).call(this,a,r)]}},oe=new WeakMap,F=new WeakMap,ce=new WeakMap,se=new WeakMap,Q=new WeakMap,re=new WeakMap,he=new WeakMap,me=new WeakMap,xe=new WeakMap,pe=new WeakMap,M=new WeakSet,Ce=function(t,n){const r=new Set;return n.map((a,o)=>{const i=t[o];return a.defaultedQueryOptions.notifyOnChangeProps?i:a.observer.trackResult(i,c=>{r.has(c)||(r.add(c),n.forEach(h=>{h.observer.trackProp(c)}))})})},Re=function(t,n,r){if(n){const a=_(this,xe),o=r!==void 0&&a!==void 0&&(a.length!==r.length||r.some((i,c)=>i!==a[c]));return(_(this,F)!==_(this,me)||o||n!==_(this,he))&&(D(this,he,n),D(this,me,_(this,F)),r!==void 0&&D(this,xe,r),D(this,re,Tt(_(this,re),n(t)))),_(this,re)}return t},dt=function(){var t;return!((t=_(this,se))!=null&&t.combine)||_(this,Q).some((n,r)=>{var a;return n.options.suspense&&((a=_(this,F)[r])==null?void 0:a.data)===void 0})},Ie=function(t){const n=new Map;_(this,Q).forEach(a=>{const o=a.options.queryHash;if(!o)return;const i=n.get(o);i?i.push(a):n.set(o,[a])});const r=[];return t.forEach(a=>{var c;const o=_(this,oe).defaultQueryOptions(a),i=((c=n.get(o.queryHash))==null?void 0:c.shift())??new Ze(_(this,oe),o);r.push({defaultedQueryOptions:o,observer:i})}),r},Pe=function(t,n){const r=_(this,Q).indexOf(t);r!==-1&&(D(this,F,_(this,F).slice()),_(this,F)[r]=n,G(this,M,Ee).call(this))},Ee=function(){var t;if(this.hasListeners()){const n=G(this,M,dt).call(this),r=_(this,re),a=n?r:G(this,M,Re).call(this,G(this,M,Ce).call(this,_(this,F),_(this,pe)),(t=_(this,se))==null?void 0:t.combine);(n||r!==a)&&Ne.batch(()=>{this.listeners.forEach(o=>{o(_(this,F))})})}},Xe);function Ls({queries:s,...t},n){const r=Ae(),a=Dt(),o=$t(),i=t.subscribed!==!1,c=d.useMemo(()=>s.map(j=>{const x=r.defaultQueryOptions(j);return x._optimisticResults=a?"isRestoring":i?"optimistic":void 0,x}),[s,r,a,i]);c.forEach(j=>{qt(j);const x=r.getQueryCache().get(j.queryHash);Ft(j,o,x)}),Ht(o);const[h]=d.useState(()=>new Es(r,c,t)),[f,k,m]=h.getOptimisticResult(c,t.combine);d.useEffect(()=>{h.setQueries(c,t)},[c,t,h]);const w=!a&&i;d.useSyncExternalStore(d.useCallback(j=>w?h.subscribe(Ne.batchCalls(j)):Ut,[h,w]),()=>h.getCurrentResult(),()=>h.getCurrentResult());const g=f.some((j,x)=>Ue(c[x],j))?f.flatMap((j,x)=>{const N=c[x];if(N&&Ue(N,j)){const E=new Ze(r,N);return Bt(N,E,o)}return[]}):[];if(g.length>0)throw Promise.all(g);const p=f.find((j,x)=>{const N=c[x];return N&&Kt({result:j,errorResetBoundary:o,throwOnError:N.throwOnError,query:r.getQueryCache().get(N.queryHash),suspense:N.suspense})});if(p)throw p.error;return k(m())}/**
|
|
2
|
+
* @license lucide-react v1.70.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const As=s=>s==null?void 0:s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
7
|
+
* @license lucide-react v1.70.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/function Os(s,t,n=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:As(s),size:24,node:t,...n.length>0?{aliases:n}:{}}}/**
|
|
12
|
+
* @license lucide-react v1.70.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Ms=s=>{let t="",n=!1;for(const r of s){if(r==="-"||r==="_"||r<=" "){n=t.length>0;continue}t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1}return t};/**
|
|
17
|
+
* @license lucide-react v1.70.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const zs=s=>{const t=Ms(s);return t.charAt(0).toUpperCase()+t.slice(1)};/**
|
|
22
|
+
* @license lucide-react v1.70.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Le=(...s)=>s.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
|
|
27
|
+
* @license lucide-react v1.70.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const ee={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/**
|
|
32
|
+
* @license lucide-react v1.70.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/function ke(s){return s!=null}function Ts(s,t={}){var w,g;const n=t.attributeNames??{},r=p=>n[p]??p,a=s.size??s.width??ee.width,o=s.size??s.height??ee.height,i=((w=s.aliases)==null?void 0:w.filter(p=>typeof p=="string"&&p.trim()!=="").map(p=>`lucide-${p}`))??[],c=[...s.name?[`lucide-${s.name}`]:[],...i],h=((g=t.className)==null?void 0:g.split(" ").filter(Boolean))??[],f=t.includeDefaultClasses===!1?Le(...h):Le("lucide",...c,...h),k=t.absoluteStrokeWidth?Number(t.strokeWidth??ee["stroke-width"])*Number(s.size??s.width??ee.width)/Number(t.size??t.width??ee.width):t.strokeWidth??ee["stroke-width"];return["svg",{...Object.entries(ee).reduce((p,[j,x])=>(p[r(j)]=x,p),{}),..."color"in t&&t.color&&{[r("stroke")]:t.color},..."size"in t&&ke(t.size)&&{[r("width")]:t.size,[r("height")]:t.size},..."width"in t&&ke(t.width)&&{[r("width")]:t.width},..."height"in t&&ke(t.height)&&{[r("height")]:t.height},[r("stroke-width")]:k,...f&&{[r("class")]:f},[r("viewBox")]:`0 0 ${a} ${o}`,...t.hasA11yProp===!1?{[r("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},s.node.map(p=>{const[j,x,N]=p,E=t.nonScalingStroke?{[r("vector-effect")]:"non-scaling-stroke",...x}:x;return N?[j,E,N]:[j,E]})]}/**
|
|
37
|
+
* @license lucide-react v1.70.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/function Ds(s,t={}){return Ts(s,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}/**
|
|
42
|
+
* @license lucide-react v1.70.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const $s=s=>{for(const t in s)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},qs=d.createContext({}),Fs=()=>d.useContext(qs),Hs=d.forwardRef(({color:s,size:t,width:n,height:r,strokeWidth:a,absoluteStrokeWidth:o,nonScalingStroke:i,className:c="",children:h,iconNode:f=[],icon:k={node:f,aliases:[],size:24},...m},w)=>{const{size:g=24,strokeWidth:p=2,absoluteStrokeWidth:j=!1,nonScalingStroke:x=!1,color:N="currentColor",className:E=""}=Fs()??{},b=!!h||$s(m),[S,I,O=[]]=Ds(k,{color:s??N,width:n??t??g,height:r??t??g,strokeWidth:a??p,absoluteStrokeWidth:o??j,nonScalingStroke:i??x,className:Le(E,c),hasA11yProp:b,attributes:m});return d.createElement(S,{ref:w,...I},[...O.map(([B,A])=>d.createElement(B,A)),...Array.isArray(h)?h:[h]])});/**
|
|
47
|
+
* @license lucide-react v1.70.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/function J(s,t=[],n=[]){const r=typeof s=="string"?Os(s,t,n):s,a=d.forwardRef(({className:o,...i},c)=>d.createElement(Hs,{ref:c,icon:r,className:o,...i}));return r.name&&(a.displayName=zs(r.name)),a}/**
|
|
52
|
+
* @license lucide-react v1.70.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const ut={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};ut.node;const Us=J(ut);/**
|
|
57
|
+
* @license lucide-react v1.70.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const ht={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};ht.node;const mt=J(ht);/**
|
|
62
|
+
* @license lucide-react v1.70.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const xt={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};xt.node;const pt=J(xt);/**
|
|
67
|
+
* @license lucide-react v1.70.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const ft={name:"clipboard-copy",size:24,node:[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]};ft.node;const Bs=J(ft);/**
|
|
72
|
+
* @license lucide-react v1.70.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const bt={name:"ellipsis",size:24,node:[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],aliases:["more-horizontal"]};bt.node;const Ks=J(bt);/**
|
|
77
|
+
* @license lucide-react v1.70.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const yt={name:"folder-open",size:24,node:[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]};yt.node;const We=J(yt);/**
|
|
82
|
+
* @license lucide-react v1.70.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const gt={name:"image-off",size:24,node:[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]};gt.node;const Qs=J(gt);/**
|
|
87
|
+
* @license lucide-react v1.70.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/const vt={name:"images",size:24,node:[["path",{d:"m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16",key:"9kzy35"}],["path",{d:"M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2",key:"1t0f0t"}],["circle",{cx:"13",cy:"7",r:"1",fill:"currentColor",key:"1obus6"}],["rect",{x:"8",y:"2",width:"14",height:"14",rx:"2",key:"1gvhby"}]]};vt.node;const Ws=J(vt);/**
|
|
92
|
+
* @license lucide-react v1.70.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const wt={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};wt.node;const jt=J(wt);/**
|
|
97
|
+
* @license lucide-react v1.70.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const kt={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};kt.node;const Vs=J(kt);/**
|
|
102
|
+
* @license lucide-react v1.70.0 - ISC
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the ISC license.
|
|
105
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
+
*/const Nt={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Nt.node;const Gs=J(Nt);/**
|
|
107
|
+
* @license lucide-react v1.70.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/const St={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};St.node;const _t=J(St),Ys=({project:s,onRename:t,onRemove:n,onSetPinned:r})=>{const a=de(),o=d.useRef(null),i=d.useRef(null),c=d.useRef(null),[h,f]=d.useState(!1),[k,m]=d.useState(!1),w=!!s.pinnedAt,[g,p]=d.useState(null),[j,x]=d.useState(s.name),[N,E]=d.useState(!1),[b,S]=d.useState(null),{containerRef:I,onKeyDown:O}=Qt();let B=g==="rename"?"Save name":"Remove from projects";N&&(B="Saving…"),d.useEffect(()=>{var z;if(k||!c.current)return;const y=c.current==="button"?i:o;c.current=null,(z=y.current)==null||z.focus()},[k]);const A=y=>{f(y),a==null||a.capture(y?"library_project_menu_opened":"library_project_menu_closed")},L=async y=>{if(!k){c.current=y,m(!0),a==null||a.capture("library_project_pin_clicked",{is_pinning:!w,method:y});try{await r(s.id,!w)}catch(z){at.error(Be(z,"Could not save pin. Try again."))}finally{m(!1)}}},W=y=>{A(!1),x(s.name),S(null),p(y),a==null||a.capture("library_project_action_opened",{action:y})},K=y=>{a==null||a.capture("library_project_action_closed",{action:g,outcome:y}),p(null)},C=async()=>{if(!(N||!g||g==="rename"&&!j.trim())){E(!0),S(null);try{g==="rename"?await t(s.id,j.trim()):await n(s.id),K("completed")}catch(y){S(Be(y,"Could not save changes. Try again."))}finally{E(!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 ${h?"pointer-events-auto opacity-100":"pointer-events-none opacity-0"}`,children:[e.jsx(Y,{ref:i,type:"button",variant:"ghost",size:"icon-compact",title:w?"Unpin project":"Pin project","aria-label":`${w?"Unpin":"Pin"} ${s.name}`,"aria-pressed":w,disabled:k,onClick:()=>{L("button")},children:e.jsx(Se,{weight:w?"fill":"bold",size:16,"aria-hidden":!0})}),e.jsxs(Wt,{open:h,onOpenChange:A,children:[e.jsx(Vt,{asChild:!0,children:e.jsx(Y,{ref:o,type:"button",variant:"ghost",size:"icon-compact","aria-label":`Actions for ${s.name}`,children:e.jsx(Ks,{size:16,"aria-hidden":!0})})}),e.jsx(Gt,{children:e.jsxs(Yt,{"data-rivet-private":!0,ref:I,onKeyDown:O,role:"menu","aria-label":"Project actions",align:"start",sideOffset:4,onCloseAutoFocus:y=>{g&&y.preventDefault()},className:"ph-no-capture bg-surface-2 text-content z-ui-primary min-w-44 rounded-lg p-1 shadow-lg",children:[e.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,disabled:k,onClick:()=>{A(!1),L("menu")},className:"hover:bg-hover focus:bg-hover flex w-full items-center gap-2 rounded-md px-3 py-2 text-xs focus:outline-none disabled:opacity-50",children:[e.jsx(Se,{size:14,weight:w?"fill":"bold","aria-hidden":!0}),w?"Unpin":"Pin"]}),e.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>W("rename"),className:"hover:bg-hover focus:bg-hover flex w-full items-center gap-2 rounded-md px-3 py-2 text-xs focus:outline-none",children:[e.jsx(Vs,{size:14,"aria-hidden":!0}),"Rename"]}),e.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,onClick:()=>W("remove"),className:"hover:bg-hover focus:bg-hover flex w-full items-center gap-2 rounded-md px-3 py-2 text-xs focus:outline-none",children:[e.jsx(_t,{size:14,"aria-hidden":!0}),"Remove from projects"]})]})})]})]}),e.jsx(et,{open:g!==null,onOpenChange:y=>{!y&&!N&&K("cancelled")},children:e.jsxs(tt,{children:[e.jsx(st,{className:"z-modal fixed inset-0 bg-black/60"}),e.jsxs(rt,{"data-rivet-private":!0,onCloseAutoFocus:y=>{var z;y.preventDefault(),(z=o.current)==null||z.focus()},className:"ph-no-capture bg-surface-2 text-content z-ui-secondary fixed top-1/2 left-1/2 w-[calc(100%-2rem)] max-w-sm -translate-x-1/2 -translate-y-1/2 rounded-xl p-6 shadow-lg",children:[e.jsx(nt,{className:"text-base font-medium break-words",children:g==="rename"?"Rename project":`Remove “${s.name}” from projects?`}),e.jsx(it,{className:"mt-2 text-sm leading-6 text-white/60",children:g==="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:y=>{y.preventDefault(),C()},children:[g==="rename"?e.jsxs("label",{className:"mt-5 block text-xs text-white/70",children:["Project name",e.jsx("input",{autoFocus:!0,value:j,onChange:y=>x(y.target.value),maxLength:Jt,disabled:N,className:"mt-2 w-full rounded-lg border border-white/15 bg-white/5 px-3 py-2 text-sm text-white outline-none focus:border-white/50"})]}):null,b?e.jsx("p",{role:"alert",className:"mt-4 text-xs text-red-300",children:b}):null,e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(Y,{type:"button",variant:"ghost",disabled:N,onClick:()=>K("cancelled"),children:"Cancel"}),e.jsx(Y,{type:"submit",variant:"secondary",disabled:N||g==="rename"&&!j.trim(),children:B})]})]})]})]})})]})},Ct=6e4,Rt=60*Ct,ve=24*Rt,Js=7*ve,Xs=30*ve,Zs=365*ve,er=[["year",Zs],["month",Xs],["week",Js],["day",ve],["hour",Rt],["minute",Ct]],tr=new Intl.RelativeTimeFormat("en",{numeric:"always"}),sr=s=>{const t=new Map;for(const n of s??[]){const r=Date.parse(n.createdAt);if(!Number.isFinite(r))continue;const a=t.get(n.projectId);(a===void 0||r>a)&&t.set(n.projectId,r)}return t},rr=({projects:s,latestEdits:t})=>[...s].sort((n,r)=>{if(n.pinnedAt&&!r.pinnedAt)return-1;if(r.pinnedAt&&!n.pinnedAt)return 1;if(n.pinnedAt&&r.pinnedAt)return n.pinnedAt.localeCompare(r.pinnedAt)||n.id.localeCompare(r.id);const a=t.get(n.id),o=t.get(r.id);return a===void 0&&o!==void 0?1:o===void 0&&a!==void 0?-1:(o??0)-(a??0)||n.name.localeCompare(r.name)||n.id.localeCompare(r.id)}),nr=({editedAt:s,now:t})=>{const n=Math.max(0,t-s);for(const[r,a]of er)if(n>=a)return`Edited ${tr.format(-Math.floor(n/a),r)}`;return"Edited just now"},It=d.createContext(null),ir=({navigation:s,onBrowseProjects:t,controls:n,isHeaderVisible:r=!0,children:a})=>{const[o,i]=d.useState(null);return e.jsxs(It.Provider,{value:o,children:[r?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:t,"aria-label":"Projects",className:"flex items-center",children:e.jsx("img",{src:Xt,alt:"","aria-hidden":!0,draggable:!1,className:"h-8 w-8"})}),e.jsx("div",{ref:i,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:n}),e.jsx("div",{className:"col-start-2 row-start-1 justify-self-end sm:col-start-3",children:s})]}):null,a]})},Pt=({children:s})=>{const t=d.useContext(It);return t?Zt.createPortal(s,t):null},Oe=({label:s,value:t,onChange:n,onBlur:r,isDisabled:a=!1})=>e.jsxs("label",{className:"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 max-sm:flex-1",children:[e.jsx(Gs,{size:14,className:"shrink-0","aria-hidden":!0}),e.jsx("input",{type:"search","aria-label":s,placeholder:`${s}…`,value:t,onChange:o=>n==null?void 0:n(o.target.value),onBlur:r,disabled:a,className:"min-w-0 flex-1 bg-transparent text-xs text-white outline-none placeholder:text-white/30 disabled:opacity-40 [&::-webkit-search-cancel-button]:hidden"})]}),ar=({projects:s,variants:t,historyError:n,onRetryHistory:r,projectPreviews:a={},selectedProjectId:o,onSelectProject:i,onBrowseLibrary:c,onOpenProject:h,onRenameProject:f,onRemoveProject:k,onSetProjectPinned:m,isOpeningProject:w=!1,projectOpenError:g,onSearchCompleted:p,accountMenu:j,navigation:x,view:N="library",children:E})=>{const[b,S]=d.useState(""),I=o===null||E===void 0,O=d.useRef(null),B=sr(t),[A]=d.useState(Date.now),L=s.find(C=>C.id===o),W=new Map;if(t)for(const C of s)C.historyIssue||W.set(C.id,0);for(const{projectId:C}of t??[]){const y=W.get(C);y!==void 0&&W.set(C,y+1)}const K=rr({projects:s.filter(C=>C.name.toLowerCase().includes(b.toLowerCase())),latestEdits:B});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(ir,{navigation:x,onBrowseProjects:c,isHeaderVisible:I,controls:N==="library"?e.jsx(Oe,{label:"Search projects",value:b,onChange:S,onBlur:()=>p==null?void 0:p(b.length)}):null,children:[g?e.jsx("p",{role:"alert",className:"px-10 pt-5 text-xs text-red-200",children:g}):null,E!==void 0?E: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:O,tabIndex:-1,className:"sr-only",children:"Projects"}),e.jsx("div",{className:"mb-9 flex items-center justify-end",children:e.jsx(Y,{onClick:()=>h(),variant:"secondary",disabled:w,leadingIcon:We,className:"shrink-0",children:"Open project…"})}),n?e.jsxs("div",{role:"alert",className:"mb-6 flex items-center gap-3 text-xs text-white/60",children:[e.jsx("span",{children:n}),e.jsx("button",{onClick:r,className:"shrink-0 underline underline-offset-4",children:"Retry history"})]}):null,L!=null&&L.issue?e.jsx("p",{role:"alert",className:"mb-6 rounded-lg border border-amber-200/10 bg-amber-200/[0.03] p-4 text-xs leading-6 text-white/70",children:L.issue}):null,L&&!L.isAvailable?e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4 rounded-lg border border-amber-200/10 bg-amber-200/[0.03] p-4 text-xs text-white/60",children:[e.jsxs("span",{children:["Locate ",L.name,"’s working folder to open its workspace."]}),e.jsx("button",{disabled:w,onClick:()=>h(L.id),className:"shrink-0 text-white underline decoration-white/30 underline-offset-4",children:"Locate folder"})]}):null,e.jsxs("div",{className:"grid items-start gap-x-6 gap-y-8 sm:grid-cols-2",children:[K.map(C=>{const y=W.get(C.id);let z="Loading variants…";y!==void 0?z=`${y.toLocaleString()} ${y===1?"variant":"variants"}`:(n||C.historyIssue)&&(z="Variants unavailable");const u=B.get(C.id);let R="No edits yet";n||C.historyIssue?R="Edit history unavailable":t===void 0?R="Loading edits…":y&&(R="Edit date unavailable");const q=a[C.id];return e.jsxs("div",{className:"group/project grid min-w-0",children:[e.jsxs("button",{onClick:()=>{S(""),i(C.id)},className:"group 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 hover:bg-white/[0.06] focus-visible:bg-white/[0.06] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-white/60",children:[e.jsx("span",{className:"group-hover:border-border relative block aspect-video overflow-hidden rounded-xl border border-white/[0.08] bg-white/[0.02]",children:q?e.jsx("img",{src:q.dataUrl,alt:`${C.name} — ${q.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:[C.pinnedAt?e.jsx(Se,{size:12,weight:"fill","aria-hidden":!0,className:"text-content-muted shrink-0"}):null,e.jsx("span",{className:"truncate",children:C.name})]}),e.jsxs("span",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-white/40 group-hover:text-white/65 group-focus-visible:text-white/65",children:[u!==void 0?e.jsx("time",{dateTime:new Date(u).toISOString(),title:new Date(u).toLocaleString(),children:nr({editedAt:u,now:A})}):e.jsx("span",{children:R}),e.jsx("span",{className:"shrink-0",children:z})]}),C.isAvailable?null:e.jsx("span",{className:"mt-2 block text-xs text-amber-200/65",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(Ys,{project:C,onRename:f,onSetPinned:m,onRemove:async X=>{var ie;await k(X),(ie=O.current)==null||ie.focus()}})})]},C.id)}),K.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(We,{size:26,className:"mb-5 text-white/25"}),e.jsx("h2",{className:"text-sm font-medium",children:b?"No matching projects":"Add your projects"}),e.jsx("p",{className:"mt-2 max-w-sm text-xs leading-6 text-white/40",children:b?"Try another project name.":"Open an existing project to add it as a project here"}),b?null:e.jsx(Y,{onClick:()=>h(),variant:"secondary",disabled:w,className:"mt-5",children:"Open project"})]}):null]})]}),I&&j?e.jsx("footer",{className:"border-main-border bg-main-light shrink-0 border-t px-2.5 py-2.5",children:j}):null]})})})},Et=8,Ve=1,or=({children:s})=>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:`${Et}px`},children:s}),cr=({children:s})=>{const[t,n]=d.useState(Ve),r=d.useRef(null),a=d.useCallback(o=>{var c;if((c=r.current)==null||c.disconnect(),!o)return;const i=()=>n(Math.max(Ve,Math.ceil(o.getBoundingClientRect().height/Et)));i(),r.current=new ResizeObserver(i),r.current.observe(o)},[]);return e.jsx("li",{className:"min-w-0",style:{gridRowEnd:`span ${t}`},children:e.jsx("div",{ref:a,className:"relative pb-8",children:s})})},lr=async({profileId:s,referenceId:t,hash:n,signal:r})=>{const a=await es(`/api/library/profile/references/${encodeURIComponent(t)}/media/${n}?${new URLSearchParams({profileId:s})}`,{signal:r});if(!a.ok)throw new Error("Image unavailable");return a.blob()},dr="200px",Lt=({profileId:s,referenceId:t,hash:n,title:r,isDetail:a=!1})=>{const[o,i]=d.useState(!1),[c,h]=d.useState(!1),f=d.useRef(null),k=d.useCallback(g=>{var p;(p=f.current)==null||p.disconnect(),g&&(f.current=new IntersectionObserver(j=>{var x;j.some(N=>N.isIntersecting)&&(i(!0),(x=f.current)==null||x.disconnect())},{rootMargin:dr}),f.current.observe(g))},[]),m=te({queryKey:$.designLibraryImage({profileId:s,referenceId:t,hash:n}),queryFn:async({signal:g})=>{const p=await lr({profileId:s,referenceId:t,hash:n,signal:g});return new Promise((j,x)=>{const N=new FileReader;N.onload=()=>typeof N.result=="string"?j(N.result):x(new Error("Image unavailable")),N.onerror=()=>x(new Error("Image unavailable")),N.readAsDataURL(p)})},enabled:o,staleTime:1/0,gcTime:0,retry:!1}),w=!!m.data&&!c;return e.jsxs("div",{ref:k,className:ye("flex items-center justify-center overflow-hidden bg-white/[0.025]",a?"min-h-32":null,!a&&!w?"aspect-[4/3]":null),children:[m.isError||c?e.jsxs("span",{className:"flex items-center gap-2 p-5 text-xs text-white/35",children:[e.jsx(Qs,{size:16,"aria-hidden":!0}),"Image unavailable"]}):null,m.data&&!c?e.jsx("img",{src:m.data,alt:r,onError:()=>h(!0),className:a?"max-h-[65vh] w-full object-contain":"block h-auto w-full"}):null,!m.data&&!m.isError?e.jsx("span",{className:"text-xs text-white/25",children:"Loading image…"}):null]})},ur={arena:"Are.na",cosmos:"Cosmos",pinterest:"Pinterest",x:"X",image:"Uploaded image",text:"Saved text",variant:"Saved direction",pdf:"PDF"},hr=({provider:s})=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s==="arena"||s==="cosmos"||s==="pinterest"||s==="x"?e.jsx(ts,{provider:s,className:"h-3.5 w-3.5"}):null,ur[s]]}),mr=({label:s,onCopy:t,referenceCount:n=1})=>{const r=de(),[a,o]=d.useState("idle"),i=async()=>{o("copying");try{await t(),o("copied"),r==null||r.capture("library_reference_copy_completed",{reference_count:n,copy_kind:"agent"})}catch{o("failed"),at.error("Could not copy. Check clipboard access and try again."),r==null||r.capture("library_reference_copy_failed",{reference_count:n,copy_kind:"agent"})}},c=a==="copied"?pt:Bs,h=a==="copied"?"Copied":s;return e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"secondary",size:"compact",leadingIcon:c,disabled:a==="copying",onClick:()=>void i(),"aria-label":h,"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:s}),e.jsx("span",{className:"col-start-1 row-start-1",children:h})]})}),a==="failed"?e.jsx("span",{role:"alert",className:"sr-only",children:"Could not copy. Check clipboard access and try again."}):null]})},At=ne({id:U(),title:U(),provider:ot,isIncluded:ge()}),xr=ss.extend({sourceIds:le(U()),observation:rs.nullable()}),pr=ne({profileId:U(),revision:ae(),isEnabled:ge(),sources:le(At),references:le(xr)});ne({query:U().trim().min(2).max(1e3),sourceId:U().min(1).max(200).optional(),limit:ae().int().min(1).max(100).default(24),runtime:ns.default("codex")});const fr=ne({profileId:U(),query:U(),coverage:ne({saved:ae(),analyzed:ae(),indexed:ae()}),results:le(ne({id:U(),key:U(),title:U(),provider:ot,url:U().optional(),description:U().nullable(),imageCount:ae(),sources:le(At),isIncluded:ge()}))}),Ot=50,Ge=12,br=U().regex(/^[a-f0-9]{12,64}@[1-9][0-9]*$/).refine(s=>Number.isSafeInteger(Number(s.split("@")[1])),"Invalid reference revision"),yr=ne({profileId:U().uuid(),keys:le(br).min(1).max(Ot),isDetailed:ge().default(!1)}),gr=s=>{const t=new Map;for(const n of s){const r=n.id.slice(0,Ge);t.set(r,(t.get(r)??0)+1)}return new Map(s.map(n=>{const r=n.id.slice(0,Ge),a=t.get(r)===1?r:n.id;return[n.id,`${a}@${n.revision}`]}))},vr=({profileId:s,referenceKeys:t})=>{const n=yr.parse({profileId:s,keys:t});return["rivet","profile","reference",n.profileId,...n.keys].join(" ")},Me=s=>{const t=s.referenceKeys.length===1?"Copy to agent":`Copy ${s.referenceKeys.length} to agent`;return e.jsx(mr,{label:t,referenceCount:s.referenceKeys.length,onCopy:()=>navigator.clipboard.writeText(vr(s))})},wr=({profileId:s,reference:t,sources:n,referenceKey:r,children:a})=>{var h,f;const o=de(),i=t.title||"Untitled reference",c=t.url&&/^https?:\/\//i.test(t.url)?t.url:void 0;return e.jsxs(et,{onOpenChange:k=>o==null?void 0:o.capture(k?"library_reference_opened":"library_reference_closed",{provider:t.provider,media_count:t.media.length}),children:[e.jsx(is,{asChild:!0,children:a}),e.jsxs(tt,{children:[e.jsx(st,{className:"fixed inset-0 z-50 bg-black/55"}),e.jsxs(rt,{className:"ph-no-capture bg-background text-foreground fixed inset-y-0 right-0 z-50 flex w-full max-w-2xl flex-col border-l border-white/10 shadow-2xl outline-none","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(it,{className:"mb-2 text-xs text-white/40",children:e.jsx(hr,{provider:t.provider})}),e.jsx(nt,{className:"text-lg leading-snug font-medium tracking-tight break-words",children:i})]}),e.jsx(as,{asChild:!0,children:e.jsx(Y,{variant:"ghost",size:"icon-compact","aria-label":"Close reference",children:e.jsx(_t,{size:18})})})]}),e.jsx("div",{className:"border-b border-white/[0.07] px-7 py-4",children:e.jsx(Me,{profileId:s,referenceKeys:[r]},t.revision)}),e.jsxs("div",{className:"min-h-0 flex-1 space-y-7 overflow-y-auto px-7 py-6",children:[t.media.map(k=>e.jsx(Lt,{profileId:s,referenceId:t.id,hash:k.hash,title:i,isDetail:!0},k.hash)),t.text?e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/70",children:t.text}):null,t.note?e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-xs font-medium text-white/45",children:"Your note"}),e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/75",children:t.note})]}):null,e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-xs font-medium text-white/45",children:((h=t.observation)==null?void 0:h.evidence)==="preference"?"Your preference":"Rivet’s analysis"}),e.jsx("p",{className:"text-sm leading-7 break-words whitespace-pre-wrap text-white/75",children:((f=t.observation)==null?void 0:f.description)??t.unsupportedReason??"No analysis saved yet."})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"mb-3 text-xs font-medium text-white/45",children:"Saved in"}),e.jsx("ul",{className:"space-y-2",children:n.filter(k=>t.sourceIds.includes(k.id)).map(k=>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:k.title}),k.isIncluded?null:e.jsx("span",{className:"text-white/35",children:"Excluded from generation"})]},k.id))})]}),c?e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>o==null?void 0:o.capture("library_reference_original_opened",{provider:t.provider}),className:"inline-flex items-center gap-1 text-xs text-white/70 underline-offset-4 hover:underline",children:["Open original",e.jsx(mt,{size:14,"aria-hidden":!0})]}):null]})]})]})]})},Ye="opacity-0 group-hover/card:opacity-100 group-focus-within/card:opacity-100 [@media(hover:none)]:opacity-100",jr="pointer-events-none group-hover/card:pointer-events-auto group-focus-within/card:pointer-events-auto [@media(hover:none)]:pointer-events-auto",kr=({profileId:s,reference:t,sources:n,referenceKey:r,isSelected:a,isSelectionDisabled:o,onSelect:i})=>{var f;const c=t.title||"Untitled reference",h=t.media[0];return e.jsxs("div",{className:"group/card relative",children:[e.jsx(wr,{profileId:s,reference:t,sources:n,referenceKey:r,children:e.jsx("button",{"aria-label":`Inspect ${c}`,className:"block w-full overflow-hidden text-left outline-none focus-visible:ring-2 focus-visible:ring-white/50 focus-visible:ring-offset-4 focus-visible:ring-offset-background",children:h?e.jsx(Lt,{profileId:s,referenceId:t.id,hash:h.hash,title:c},h.hash):e.jsxs("div",{className:"min-h-44 border border-white/10 bg-white/[0.03] p-5 pb-14",children:[e.jsx("p",{className:"text-sm font-medium text-white/80",children:c}),e.jsx("p",{className:"mt-3 line-clamp-3 text-xs leading-5 text-white/45",children:((f=t.observation)==null?void 0:f.description)??t.text})]})})}),e.jsx("div",{"aria-hidden":!0,className:ye("pointer-events-none absolute inset-0 bg-black/40",Ye)}),e.jsxs("div",{className:ye("absolute inset-x-0 bottom-0 z-10 flex items-center justify-between gap-2 p-2",a?null:Ye,a?null:jr),children:[e.jsxs("label",{className:"relative shrink-0 cursor-pointer",title:a?"Deselect":"Select",children:[e.jsx("input",{type:"checkbox","aria-label":`Select ${c}`,checked:a,disabled:o,onChange:i,className:"peer absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-default"}),e.jsx("span",{className:ye("flex h-7 w-7 items-center justify-center rounded-full border shadow-sm peer-focus-visible:ring-2 peer-focus-visible:ring-white peer-focus-visible:ring-offset-2 peer-disabled:opacity-40",a?"border-orange-400 bg-orange-500 text-white":"border-white/35 bg-black/60 text-white/70"),children:e.jsx(pt,{size:14,"aria-hidden":!0})})]}),e.jsx(Me,{profileId:s,referenceKeys:[r]},t.revision)]})]})},fe=24,Nr="200px",Sr=350,_r=100,Cr=({snapshot:s})=>{var z;const t=de(),[n,r]=d.useState(""),[a,o]=d.useState(""),i=d.useRef(null),[c,h]=d.useState(""),[f,k]=d.useState(fe),[m,w]=d.useState([]),g=d.useRef(null),p=gr(s.references),j=s.references.filter(u=>u.media.length>0),x=te({queryKey:$.designReferenceSearch({profileId:s.profileId,revision:s.revision,references:s.references.map(({id:u,revision:R,sourceIds:q})=>[u,R,q]),search:a,sourceId:c}),queryFn:({signal:u})=>H("/profile/search",{schema:fr,method:"POST",body:{query:a,sourceId:c||void 0,limit:_r},signal:u}),enabled:a.length>=2&&s.references.length>0,retry:!1}),N=s.references.filter(u=>m.includes(u.id)),E=N.flatMap(u=>{const R=p.get(u.id);return R?[R]:[]}),b=n.trim(),S=b.length>=2,I=S&&s.references.length>0&&(a!==b||x.isLoading),O=S&&!I&&x.isError,B=new Map(s.references.map(u=>[u.id,u])),A=S?(((z=x.data)==null?void 0:z.results)??[]).flatMap(({id:u})=>{const R=B.get(u);return R?[R]:[]}):j.filter(u=>!c||u.sourceIds.includes(c)),L=j.length>0,W=A.length,K=s.references.length>0?"No images yet":"Your library starts here",C=d.useCallback(u=>{var R;(R=g.current)==null||R.disconnect(),u&&(g.current=new IntersectionObserver(q=>{var X;q.some(ie=>ie.isIntersecting)&&((X=g.current)==null||X.disconnect(),k(Math.min(f+fe,W)))},{root:u.parentElement,rootMargin:Nr}),g.current.observe(u))},[f,W]),y=u=>{const R=N.map(X=>X.id),q=R.includes(u)?R.filter(X=>X!==u):[...R,u];w(q),t==null||t.capture("library_reference_selection_changed",{selected_count:q.length})};return e.jsxs("div",{className:"ph-no-capture flex min-h-0 flex-1 flex-col","data-rivet-private":!0,children:[e.jsx(Pt,{children:e.jsx(Oe,{label:"Search references",value:n,onChange:u=>{r(u),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>o(u.trim()),Sr),k(fe)},onBlur:()=>{var u;return t==null?void 0:t.capture("library_reference_search_completed",{query_length:n.length,result_count:S?((u=x.data)==null?void 0:u.results.length)??0:A.length})}})}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-10 pb-10 max-sm:px-5",children:[!s.isEnabled&&L?e.jsx("p",{className:"mb-5 text-xs text-white/40",children:"Automatic use is paused. Your saved references are still here."}):null,L?e.jsx("div",{className:"mb-7 flex flex-wrap items-center gap-3",children:e.jsxs("select",{"aria-label":"Source",value:c,onChange:u=>{h(u.target.value),k(fe),t==null||t.capture("library_reference_source_filtered",{is_filtered:!!u.target.value})},className:"bg-background max-w-64 rounded-lg border border-white/[0.08] px-3 py-2.5 text-xs text-white/60 focus-visible:outline-2",children:[e.jsx("option",{value:"",children:"All sources"}),s.sources.map(u=>e.jsx("option",{value:u.id,children:u.title},u.id))]})}):null,E.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:[E.length," selected"]}),e.jsx(Me,{profileId:s.profileId,referenceKeys:E},E.join(" ")),e.jsx(Y,{variant:"ghost",size:"compact",onClick:()=>{w([]),t==null||t.capture("library_reference_selection_changed",{selected_count:0})},children:"Clear selection"})]}):null,S&&x.data&&x.data.coverage.analyzed<x.data.coverage.saved?e.jsxs("p",{role:"status",className:"mb-5 text-xs text-white/45",children:[x.data.coverage.analyzed," of"," ",x.data.coverage.saved," references analyzed; results may be incomplete."]}):null,I?e.jsx("p",{role:"status",className:"py-10 text-center text-xs text-white/45",children:"Searching references…"}):null,O?e.jsxs("div",{role:"alert",className:"py-10 text-center text-xs text-white/50",children:[e.jsxs("p",{children:["Search is unavailable: ",x.error.message]}),e.jsx(Y,{variant:"ghost",onClick:()=>{t==null||t.capture("library_reference_search_retry"),x.refetch()},children:"Try again"})]}):null,!I&&!O&&A.length?e.jsx(or,{children:A.slice(0,f).map(u=>{const R=p.get(u.id);return R?e.jsx(cr,{children:e.jsx(kr,{profileId:s.profileId,reference:u,sources:s.sources,referenceKey:R,isSelected:m.includes(u.id),isSelectionDisabled:!m.includes(u.id)&&E.length>=Ot,onSelect:()=>y(u.id)})},u.id):null})}):null,!I&&!O&&!A.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(Ws,{size:28,strokeWidth:1,className:"mb-5 text-white/25","aria-hidden":!0}),e.jsx("h2",{className:"text-sm text-white/75",children:L||S?"No references found":K}),e.jsx("p",{className:"mt-2 max-w-sm text-xs leading-6 text-white/35",children:L||S?"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,!I&&!O&&A.length>f?e.jsx("div",{ref:C,role:"status",className:"py-8 text-center text-xs text-white/35",children:"Loading more references…"}):null]})]})},Rr=1e4,Ir=({onBrowseProjects:s})=>{var i,c;const t=ct(),n=de(),r=te({queryKey:$.designLibrary((i=t.data)==null?void 0:i.userId,(c=t.data)==null?void 0:c.isAuthenticated),queryFn:({signal:h})=>H("/profile/library",{schema:pr,signal:h}),enabled:!t.isPending,refetchInterval:Rr,gcTime:0,retry:!1}),a=()=>{n==null||n.capture("library_reference_retry"),r.refetch()},o=e.jsx(Pt,{children:e.jsx(Oe,{label:"Search references",value:"",isDisabled:!0})});return r.isError&&!r.data?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o,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:r.error.message}),e.jsx("div",{className:"mt-5 flex justify-center gap-3",children:e.jsx(Y,{variant:"ghost",onClick:s,children:"Projects"})})]})]}):r.data?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[r.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(Y,{variant:"ghost",onClick:a,children:"Try again"})]}):null,e.jsx(Cr,{snapshot:r.data},r.data.profileId)]}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o,e.jsx("p",{role:"status",className:"m-auto text-xs text-white/40",children:"Loading references…"})]})},Pr=({view:s,onNavigate:t})=>e.jsx("nav",{"aria-label":"Library",className:"flex items-center gap-1 rounded-lg bg-white/[0.03] p-1",children:["library","references"].map(n=>e.jsx("a",{href:n==="library"?"/rivet/library":"/rivet/library/references","aria-current":s===n?"page":void 0,onClick:r=>{r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||(r.preventDefault(),t(n))},className:os("rounded-md px-3 py-2 text-xs focus-visible:outline-2 focus-visible:outline-offset-2",s===n?"bg-white/[0.08] text-white":"text-white/45 hover:text-white/80"),children:n==="library"?"Projects":"References"},n))}),Er=()=>{const s=Ae(),t=async o=>{await s.cancelQueries({queryKey:$.projectLibrary.all}),s.setQueryData($.projectLibrary.projects,i=>i&&{projects:o(i.projects)}),s.setQueriesData({queryKey:$.projectLibrary.histories},i=>{if(!i)return i;const c=o(i.projects),h=new Set(c.map(({id:f})=>f));return{projects:c,variants:i.variants.filter(({projectId:f})=>h.has(f))}}),s.invalidateQueries({queryKey:$.projectLibrary.all})},n=ue({mutationFn:({projectId:o,name:i})=>H(`/projects/${encodeURIComponent(o)}`,{schema:_e,method:"PATCH",body:{name:i}}),onSuccess:({project:o})=>t(i=>i.map(c=>c.id===o.id?{...c,name:o.name}:c))}),r=ue({mutationFn:({projectId:o,isPinned:i})=>H(`/projects/${encodeURIComponent(o)}/pin`,{schema:_e,method:i?"PUT":"DELETE"}),onSuccess:({project:o})=>t(i=>i.map(c=>c.id===o.id?{...c,pinnedAt:o.pinnedAt}:c))}),a=ue({mutationFn:o=>H(`/projects/${encodeURIComponent(o)}`,{schema:cs,method:"DELETE"}),onSuccess:async(o,i)=>{await t(c=>c.filter(({id:h})=>h!==i)),await s.cancelQueries({queryKey:$.libraryProjectPreview.project(i)}),s.removeQueries({queryKey:$.libraryProjectPreview.project(i)})}});return{setProjectPinned:async(o,i)=>{await r.mutateAsync({projectId:o,isPinned:i})},renameProject:async(o,i)=>{await n.mutateAsync({projectId:o,name:i})},removeProject:async o=>{await a.mutateAsync(o)}}},Je=2500,Lr=500,Ar=6e4,Or=[],Mr=[],be=({error:s,retry:t})=>e.jsxs("div",{className:"m-auto max-w-md px-8 text-center",children:[e.jsx("p",{className:"text-sm text-white/70",children:s.message}),e.jsx("button",{onClick:t,className:"mt-5 rounded-lg border border-white/15 px-4 py-2 text-xs text-white/70",children:"Try again"})]}),zr=()=>{var ze,Te,De,$e,qe,Fe;const s=de();ls(ct().data);const t=Ae(),{renameProject:n,removeProject:r,setProjectPinned:a}=Er(),o=d.useRef(),[i,c]=d.useState(()=>Ke(new URL(window.location.href))),[h]=d.useState(()=>crypto.randomUUID()),f=d.useRef(0),k=d.useRef(null),m=te({queryKey:$.projectLibrary.projects,queryFn:({signal:l})=>H("/projects",{schema:gs,signal:l}),refetchInterval:Je,retry:!1}),w=((ze=m.data)==null?void 0:ze.projects)??Or,g=w.map(({id:l,projectPath:v})=>({id:l,projectPath:v})).sort((l,v)=>l.id.localeCompare(v.id)),p=te({queryKey:$.projectLibrary.history(g),queryFn:({signal:l})=>H("",{schema:vs,signal:l}),placeholderData:l=>{if(!l)return;const v=new Map(l.projects.map(({id:T,projectPath:Z})=>[T,Z]));if(!w.every(({id:T,projectPath:Z})=>v.get(T)===Z))return;const P=new Set(w.map(({id:T})=>T));return{projects:l.projects.filter(({id:T})=>P.has(T)),variants:l.variants.filter(({projectId:T})=>P.has(T))}},enabled:w.length>0,refetchInterval:Je,retry:!1}),j=new Map((Te=p.data)==null?void 0:Te.projects.map(l=>[l.id,l])),x=w.map(l=>{const v=j.get(l.id);return{...l,issue:v?v.issue:l.issue,historyIssue:v?v.historyIssue:l.historyIssue}}),N=((De=p.data)==null?void 0:De.variants)??Mr,E=Ls({queries:x.map(l=>({queryKey:$.libraryProjectPreview.thumbnail(l.id,l.projectPath),queryFn:({signal:v})=>H(`/projects/${l.id}/thumbnail`,{schema:ys,signal:v}),enabled:i.kind==="library",refetchInterval:Ar,retry:!1}))}),b=x.find(l=>l.id===i.projectId),S=N.find(l=>l.projectId===i.projectId&&l.sessionId===i.sessionId&&l.variantId===i.variantId),I=d.useCallback(l=>{window.history.pushState(null,"",ds(l)),c(l)},[]);d.useEffect(()=>{b?o.current=b.id:m.isSuccess&&!m.isFetching&&i.projectId===o.current&&i.projectId&&(o.current=void 0,I({kind:"library"}))},[b,i.projectId,m.isSuccess,m.isFetching,I]),d.useEffect(()=>{const l=()=>c(Ke(new URL(window.location.href)));return window.addEventListener("popstate",l),()=>window.removeEventListener("popstate",l)},[]),d.useEffect(()=>{const l=new AbortController;let v;const P=async()=>{try{const T=await H(`/views/${h}`,{schema:ms,method:"PUT",body:{isFocused:document.visibilityState==="visible"&&document.hasFocus()},signal:l.signal});for(const Z of T.navigations){if(l.signal.aborted)return;if(Z.sequence>f.current){let we="library";Z.projectId&&(we="workspace"),Z.variantId&&(we="preview"),I({...Z,kind:we}),f.current=Z.sequence}await H(`/views/${h}/acknowledgements`,{schema:xs,method:"POST",body:{sequence:Z.sequence},signal:l.signal})}}catch{}l.signal.aborted||(v=setTimeout(()=>{P()},Lr))};return P(),()=>{l.abort(),clearTimeout(v)}},[h,I]);const O=te({queryKey:$.libraryWorkspace(i.projectId),queryFn:()=>H(`/projects/${i.projectId}/runtime`,{schema:ws,method:"POST"}),enabled:i.kind==="workspace"&&!!i.projectId&&(b==null?void 0:b.isAvailable)===!0,retry:!1,refetchOnWindowFocus:!1}),B=O.data?new URL(O.data.editorUrl).origin:null;d.useEffect(()=>{if(i.kind!=="workspace"||!B)return;const l=v=>{!k.current||v.source!==k.current.contentWindow||v.origin!==B||v.data!==ps||(s==null||s.capture("library_view_changed",{view:"projects"}),I({kind:"library"}))};return window.addEventListener("message",l),()=>window.removeEventListener("message",l)},[i.kind,B,I,s]);const A=te({queryKey:$.libraryPreview({projectId:i.projectId,sessionId:i.sessionId,variantId:i.variantId}),queryFn:()=>H(`/projects/${i.projectId}/variants/${i.sessionId}/${i.variantId}/preview`,{schema:js,method:"POST"}),enabled:i.kind==="preview"&&!!(S!=null&&S.hasStaticPreview),retry:!1,refetchOnWindowFocus:!1}),L=ue({mutationFn:l=>H(`/projects/${i.projectId}/variants/${i.sessionId}/${i.variantId}`,{schema:fs,method:"PATCH",body:{label:l}}),onSuccess:()=>t.invalidateQueries({queryKey:$.projectLibrary.all})}),W=l=>{const v=x.find(P=>P.id===l);s==null||s.capture("library_project_selected",{project_id:l,workspace_available:(v==null?void 0:v.isAvailable)??!1}),I({kind:"workspace",projectId:l})},K=ue({mutationFn:async l=>{const{projectPath:v}=await H("/folder-selections",{schema:bs,method:"POST"});return v===null?null:H(l?`/projects/${l}/workspace`:"/projects",{schema:_e,method:l?"PATCH":"POST",body:{projectPath:v}})},onSuccess:l=>{l&&(t.invalidateQueries({queryKey:$.projectLibrary.all}),s==null||s.capture("library_project_selected",{project_id:l.project.id,workspace_available:l.project.isAvailable}),I({kind:"workspace",projectId:l.project.id}))},onSettled:(l,v,P)=>{s==null||s.capture("library_open_project_closed",{is_relink:!!P})}}),C=l=>{K.isPending||(s==null||s.capture("library_open_project_opened",{is_relink:!!l}),K.mutate(l))},y=()=>{s==null||s.capture("library_view_changed",{view:"projects"}),I({kind:"library"})},z=()=>{s==null||s.capture("library_view_changed",{view:"workspace"}),I({...i,kind:"workspace"})},u=()=>{s==null||s.capture("library_history_retry"),p.refetch()};let R;if(i.kind==="workspace"&&(b==null?void 0:b.isAvailable)!==!1||i.kind==="preview"){let l=!1,v=e.jsxs("div",{className:"m-auto flex items-center gap-2 text-xs text-white/40",children:[e.jsx(jt,{size:14,className:"animate-spin"}),"Opening ",(b==null?void 0:b.name)??"project","…"]});if(m.data&&!b||p.data&&i.variantId&&!S)v=e.jsx("div",{className:"m-auto text-sm text-white/60",children:"This project or direction is no longer in your library."});else if(i.kind==="preview"&&p.error&&!p.data)v=e.jsx(be,{error:p.error,retry:u});else if(i.kind==="workspace"&&O.error)v=e.jsx(be,{error:O.error,retry:()=>{O.refetch()}});else if(i.kind==="workspace"&&O.data){l=!0;const P=new URL(O.data.editorUrl);P.searchParams.set("library","1"),P.searchParams.set("libraryOrigin",window.location.origin),i.sessionId&&i.variantId&&(P.searchParams.set("historySession",i.sessionId),P.searchParams.set("historyVariant",i.variantId)),v=e.jsx("iframe",{ref:k,title:`${(b==null?void 0:b.name)??"Project"} workspace`,src:P.toString(),allow:"clipboard-write","data-rivet-private":!0,className:"ph-no-capture min-h-0 w-full flex-1 border-0"},P.toString())}else i.kind==="preview"&&A.error?v=e.jsx(be,{error:A.error,retry:()=>{A.refetch()}}):i.kind==="preview"&&A.data?v=e.jsx("iframe",{title:`${(S==null?void 0:S.label)??"Saved direction"} preview`,src:A.data.url,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",className:"min-h-0 w-full flex-1 border-0 bg-white"}):i.kind==="preview"&&S&&!S.hasStaticPreview&&(v=e.jsxs("div",{className:"m-auto max-w-sm text-center",children:[e.jsx("p",{className:"text-sm",children:S.hasInteractivePreview?"Open this direction in its workspace":"This direction contains saved code changes"}),e.jsx("p",{className:"mt-2 text-xs leading-6 text-white/40",children:S.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("button",{onClick:z,disabled:(b==null?void 0:b.isAvailable)===!1,className:"mt-5 rounded-lg bg-white px-4 py-2.5 text-xs font-medium text-black disabled:opacity-30",children:"Open workspace"})]}));R=e.jsxs(e.Fragment,{children:[i.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("button",{"aria-label":"Back to projects",onClick:y,className:"rounded p-1.5 text-white/45 hover:bg-white/5",children:e.jsx(Us,{size:15})}),e.jsx("span",{className:"text-xs text-white/40",children:b==null?void 0:b.name}),S?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/20",children:"/"}),e.jsxs("form",{onSubmit:P=>{P.preventDefault();const T=new FormData(P.currentTarget);L.mutate(String(T.get("label")))},className:"flex min-w-0 flex-1 gap-2",children:[e.jsx("input",{name:"label","aria-label":"Direction name",defaultValue:S.label,className:"max-w-xs min-w-0 flex-1 bg-transparent text-xs text-white/80 outline-none"}),e.jsx("button",{disabled:L.isPending,className:"text-[10px] text-white/30 hover:text-white",children:"Rename"})]},`${S.projectId}:${S.variantId}`)]}):e.jsx("span",{className:"flex-1"}),i.kind==="preview"?e.jsxs("button",{onClick:z,disabled:(b==null?void 0:b.isAvailable)===!1,className:"flex items-center gap-1.5 rounded-md border border-white/10 px-3 py-1.5 text-[11px] text-white/70 disabled:opacity-30",children:["Edit in project",e.jsx(mt,{size:12})]}):null]}):null,i.kind==="workspace"&&!l?e.jsx("button",{onClick:y,className:"absolute top-5 left-5 rounded px-2 py-1 text-xs text-white/50 hover:bg-white/5 hover:text-white",children:"Projects"}):null,L.error?e.jsx("p",{role:"alert",className:"px-5 py-2 text-xs text-red-200",children:L.error.message}):null,v]})}let q=R;m.error&&!m.data?q=e.jsx(be,{error:m.error,retry:()=>{m.refetch()}}):m.isPending&&(q=e.jsx("div",{role:"status",className:"flex min-h-0 flex-1 items-center justify-center text-xs text-white/40",children:"Loading projects…"}));const X=i.kind==="references"?"references":"library",ie=e.jsx(Pr,{view:X,onNavigate:l=>{s==null||s.capture("library_view_changed",{view:l==="references"?"references":"projects"}),I({kind:l})}});return i.kind==="references"&&(q=e.jsx(Ir,{onBrowseProjects:y})),e.jsxs(e.Fragment,{children:[e.jsx(ar,{projects:x,variants:($e=p.data)==null?void 0:$e.variants,historyError:(qe=p.error)==null?void 0:qe.message,onRetryHistory:u,projectPreviews:Object.fromEntries(x.map((l,v)=>{var P,T;return[l.id,(T=(P=E[v])==null?void 0:P.data)==null?void 0:T.preview]})),selectedProjectId:i.projectId??null,onSelectProject:W,onBrowseLibrary:y,navigation:ie,view:X,onOpenProject:C,onRenameProject:n,onRemoveProject:r,onSetProjectPinned:a,accountMenu:e.jsx(us,{side:"top",align:"start"}),isOpeningProject:K.isPending,projectOpenError:(Fe=K.error)==null?void 0:Fe.message,onSearchCompleted:l=>s==null?void 0:s.capture("library_search_completed",{query_length:l}),children:q}),e.jsx(hs,{position:"bottom-right",theme:"dark"})]})},Tr=async s=>{const t=Ps(),n=await _s("/api/library/browser-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!n.ok){const r=Cs.safeParse(await n.json().catch(()=>null));throw new Error(r.success?r.data.error:"Could not start a library session.")}Rs(Is(await n.json()),t)},Dr=()=>{const s=d.useSyncExternalStore(lt,Ns),{startLogin:t,isStartingLogin:n,loginError:r}=Ss("library",Tr);return e.jsx("main",{className:"flex min-h-screen items-center justify-center bg-[#111215] px-6 text-white",children:e.jsxs("div",{className:"w-full max-w-sm rounded-2xl border border-white/10 bg-white/[0.04] p-8 text-center shadow-2xl",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Rivet"}),e.jsx("p",{className:"mt-3 text-sm leading-6 text-white/60",children:"Sign in to open your project library on this computer."}),e.jsxs("button",{type:"button",onClick:()=>void t(),disabled:n,className:"mt-7 inline-flex h-10 w-full items-center justify-center gap-2 rounded-lg bg-white px-4 text-sm font-medium text-black disabled:opacity-60",children:[n?e.jsx(jt,{size:16,className:"animate-spin"}):null,n?"Connecting…":"Continue with Google"]}),r||s?e.jsx("p",{role:"alert",className:"mt-4 text-sm text-red-300",children:r??s}):null]})})},Fr=()=>d.useSyncExternalStore(lt,ks)?e.jsx(zr,{}):e.jsx(Dr,{});export{Fr as default};
|
|
112
|
+
//# sourceMappingURL=LibraryEntry-DS6Ce0sW.js.map
|