rivet-design 0.25.0 → 0.26.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 -2
- package/README.npm.md +2 -2
- package/dist/agent-variants/PreviewRuntime.d.ts +1 -20
- package/dist/agent-variants/PreviewRuntime.js +1 -102
- package/dist/agent-variants/SessionStore.d.ts +1 -8
- package/dist/agent-variants/SessionStore.js +2 -32
- package/dist/agent-variants/WorkspaceInventory.d.ts +0 -3
- package/dist/agent-variants/WorkspaceInventory.js +5 -28
- package/dist/agent-variants/WorktreeOrchestrator.d.ts +1 -30
- package/dist/agent-variants/WorktreeOrchestrator.js +4 -643
- package/dist/agent-variants/WorktreeOrchestrator.testHelpers.d.ts +0 -7
- package/dist/agent-variants/WorktreeOrchestrator.testHelpers.js +0 -34
- package/dist/agent-variants/contracts.d.ts +320 -380
- package/dist/agent-variants/contracts.js +1 -8
- package/dist/agent-variants/index.d.ts +1 -1
- package/dist/agent-variants/runPlan.d.ts +0 -2
- package/dist/agent-variants/runPlan.js +0 -3
- package/dist/agent-variants/variant-project-runtime.d.ts +0 -2
- package/dist/agent-variants/variantWorkspaceFiles.d.ts +0 -3
- package/dist/agent-variants/variantWorkspaceFiles.js +1 -59
- package/dist/agent-variants/variantsTelemetry.d.ts +0 -8
- package/dist/agent-variants/workItemInput.d.ts +210 -210
- package/dist/cli/commands/mcpServe.d.ts +2 -2
- package/dist/cli/commands/mcpServe.js +1 -0
- package/dist/cli/commands/variants.js +2 -43
- package/dist/cli/router.js +3 -2
- package/dist/config/flags.d.ts +0 -3
- package/dist/config/flags.js +0 -1
- package/dist/config/pluginMetrics.js +0 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -8
- package/dist/install/mcpRegistration.js +1 -0
- package/dist/mcp/explorationTools.js +0 -17
- package/dist/routes/account.js +4 -2
- package/dist/routes/agentVariants.js +1 -89
- package/dist/routes/library/browserAccess.d.ts +3 -1
- package/dist/routes/library/browserAccess.js +5 -3
- package/dist/routes/library/index.js +1 -0
- package/dist/routes/variantRequestSchema.d.ts +4 -4
- package/dist/services/AuthService.js +2 -2
- package/dist/services/ConfigManager.d.ts +18 -1
- package/dist/services/ConfigManager.js +91 -4
- package/dist/services/GuidanceVerifierRunner.js +13 -2
- package/dist/services/SessionBridgeService.d.ts +0 -2
- package/dist/services/SessionBridgeService.js +0 -26
- package/dist/services/TelemetryService.d.ts +4 -15
- package/dist/services/TelemetryService.js +29 -33
- package/dist/services/VariantRunService.d.ts +0 -5
- package/dist/services/VariantRunService.js +0 -3
- package/dist/services/WorktreeManager.d.ts +0 -3
- package/dist/services/WorktreeManager.js +7 -54
- package/dist/services/createAgentVariantsOrchestrator.js +0 -1
- package/dist/services/profiles/DesignProfiles.js +4 -3
- package/dist/storage/library/ProjectPreviewCache.d.ts +2 -2
- package/dist/types/guidance-verifier.d.ts +458 -59
- package/dist/types/guidance-verifier.js +35 -12
- package/dist/utils/skills/claude-skill.d.ts +1 -1
- package/dist/utils/skills/claude-skill.js +1 -1
- package/dist/utils/skills/cli-guidance.d.ts +1 -1
- package/dist/utils/skills/cli-guidance.js +7 -9
- package/dist/utils/skills/cursor-rules.d.ts +1 -1
- package/dist/utils/skills/cursor-rules.js +1 -1
- package/package.json +3 -3
- package/src/ui/dist/assets/{LibraryEntry-BJl_pPMq.js → LibraryEntry-Cr4GFYXW.js} +9 -9
- package/src/ui/dist/assets/main-tPO1OCpZ.js +439 -0
- package/src/ui/dist/index.html +1 -1
- package/dist/agent-variants/createProjectArtifacts.d.ts +0 -61
- package/dist/agent-variants/createProjectArtifacts.js +0 -113
- package/src/ui/dist/assets/main-D1832qVC.js +0 -439
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CLI_GUIDANCE_DESCRIPTION = exports.CLI_GUIDANCE_BODY = exports.CLI_GUIDANCE_VERSION = void 0;
|
|
4
4
|
const displayLocale_1 = require("../displayLocale");
|
|
5
|
-
exports.CLI_GUIDANCE_VERSION =
|
|
5
|
+
exports.CLI_GUIDANCE_VERSION = 57;
|
|
6
6
|
const DISPLAY_LOCALE = (0, displayLocale_1.resolveDisplayLocale)();
|
|
7
7
|
exports.CLI_GUIDANCE_BODY = `Rivet helps you **explore multiple design directions** for a web app. You drive it by running \`rivet\` CLI commands. Every command prints exactly one JSON envelope on stdout (\`{ schemaVersion, ok, command, data | error }\`), routes progress to stderr, and never prompts for input.
|
|
8
8
|
|
|
@@ -30,7 +30,6 @@ Use these independently exposed tools for their named purposes:
|
|
|
30
30
|
|
|
31
31
|
- \`rivet_explore_designs\` starts directions with \`project\`, \`instruction\`, \`runLabel\`, and one authored \`briefs\` entry per direction. Use \`baseDirectionId: "sessionId:variantId"\` to vary a result.
|
|
32
32
|
- \`rivet_get_exploration\` reads progress and results with \`project\`. Add \`sessionId\`, \`variantId\`, \`includeHistory\`, or the start response's \`workId\` for recorded context receipts.
|
|
33
|
-
- \`rivet_apply_design\` applies the user's chosen \`project\`, \`sessionId\`, and \`variantId\`.
|
|
34
33
|
- \`rivet_cancel_exploration\` cancels the named \`project\` and \`sessionId\` only when the user asks.
|
|
35
34
|
- \`rivet_find_references\` searches retained titles, text, notes, and analysis with \`query\`, optional \`sourceId\`, and optional \`limit\`. Its \`saved_text\` ranking is lexical. It does not start workers, create an index, or perform semantic model search.
|
|
36
35
|
- \`rivet_get_design_context\` reads enabled instructions or selected \`instructionIds\`, plus references selected by \`referenceSelection: {profileId, keys}\`. Ordinary reads include source digests but exclude checking recipes and package files. For requested verification, add \`includeChecks: true\` with selected \`instructionIds\` to read recipe text and package metadata, without executable code or execution.
|
|
@@ -78,16 +77,16 @@ Every generation resolves current saved instructions once and supplies the same
|
|
|
78
77
|
|
|
79
78
|
**Custom verification on demand.** When asked to check a property such as "verify this used my motion principles," locate its existing context document with \`context list\`/\`show\`. Save missing user-provided principles or pointers through \`context add\` when the user wants them in context; do not invent principles or ingest source snapshots. Retrieve only the selected document with \`rivet context verifier <id>\` (MCP: \`rivet_get_design_context\` with \`instructionIds: ["<id>"]\` and \`includeChecks: true\`). Its \`sourceDigest\` binds the saved text and reference metadata; URL and directory contents remain live and are not frozen by this digest. Inspect the actual relevant references without copying them into persistent context. The CLI packet has \`execution: "host_required"\`. The MCP read returns the saved checking recipe and metadata. Neither read has checked the output.
|
|
80
79
|
|
|
81
|
-
Identify the target from the user's app or \`variants get\`. For an earlier generation, read \`context inspect <workId>\` before claiming the source was delivered. Disclose missing receipts, changed principles, and live-source limitations. A current-source assessment does not establish historical compliance. For CLI packets follow \`nextAction\`. For MCP use the returned source digest and saved recipe to determine whether to create or revise a recipe. Execute a recipe only when the user requests verification and authorizes its required privileges. Keep recipes short and specific about applicability, actions, observable assertions, and evidence. Use code inspection for source-level rules and real interaction for behavioral rules; a screenshot alone cannot verify motion timing or reduced-motion behavior. Execute the recipe once and write a uniquely named local report containing target identity, context ID/digest, each check, evidence locations, and pass/fail/unable-to-verify outcomes. Missing evidence is unable to verify, not a pass. Report failures without silently repairing the app.
|
|
80
|
+
Identify the target from the user's app or \`variants get\`. Choose verification tools for the actual browser, simulator, or other target. Do not assume a URL, DOM, CSS, or Playwright. Use the host's available tools for that target; unavailable tools or inaccessible targets mean unable to verify. Keep reusable assertions separate from target-specific bindings and execution steps, and record applicability when a rule requires a particular platform. For an earlier generation, read \`context inspect <workId>\` before claiming the source was delivered. Disclose missing receipts, changed principles, and live-source limitations. A current-source assessment does not establish historical compliance. For CLI packets follow \`nextAction\`. For MCP use the returned source digest and saved recipe to determine whether to create or revise a recipe. Execute a recipe only when the user requests verification and authorizes its required privileges. Keep recipes short and specific about applicability, actions, observable assertions, and evidence. Use code inspection for source-level rules and real interaction for behavioral rules; a screenshot alone cannot verify motion timing or reduced-motion behavior. Execute the recipe once and write a uniquely named local report containing target identity, context ID/digest, each check, evidence locations, and pass/fail/unable-to-verify outcomes. Missing evidence is unable to verify, not a pass. Report failures without silently repairing the app.
|
|
82
81
|
|
|
83
82
|
After showing the actual result, offer to save a reusable recipe unless the user already requested reuse. With that agreement, run \`rivet context update <id> --verifier <Markdown path> --source-digest <packet digest>\` (MCP: \`rivet_save_design_check\` with \`contextId\`, \`recipeFile\`, and \`sourceDigest\`). A source-change conflict requires retrieving the source and revising the recipe before saving. Source edits and verifier saves are separate updates. Remove just the recipe with \`context update <id> --remove-verifier\` (MCP: \`rivet_remove_design_check\` with \`contextId\`). Saved verifiers run only when requested; saving does not schedule checks or enable automatic reruns. The source retains its existing generation defaults, while recipe text stays out of planning and worker context.
|
|
84
83
|
|
|
85
84
|
|
|
86
|
-
For reusable executable checks, author an optional package with a named \`verify(input)\` export in a retained \`.mjs\` entrypoint. Store only authored verifier code and helpers, never a source-repository snapshot. A local JSON manifest is \`{runtime:"node",entrypoint:"verify.mjs",files:[{name:"verify.mjs",path:"./verify.mjs"}]}\`. Paths resolve relative to the manifest. Use Node built-ins
|
|
85
|
+
For reusable executable checks, author an optional package with a named \`verify(input)\` export in a retained \`.mjs\` entrypoint. Store only authored verifier code and helpers, never a source-repository snapshot. A local JSON manifest is \`{runtime:"node",entrypoint:"verify.mjs",files:[{name:"verify.mjs",path:"./verify.mjs"}]}\`. Paths resolve relative to the manifest. Use Node built-ins and retained relative imports to drive the target's available tools. For browser checks only, \`await import(input.modules.playwright)\` provides Rivet's installed Playwright ESM module. Rivet installs no dependencies, browser, or simulator. Inputs are \`source\` (prepared saved context), \`projectPath\`, \`target\` (opaque target JSON), \`evidenceDirectory\`, and \`modules.playwright\` (a browser helper whose use is optional). Target bindings can include simulator/device identifiers, app identifiers, accessibility identifiers, source files, or browser URLs and selectors as applicable. Missing required tools or bindings produce blocked checks. The code executes locally with the invoking process's permissions and environment, not a sandbox. Only run trusted authored code when the user requests verification.
|
|
87
86
|
|
|
88
|
-
Read expected brand values from the independent source. Bind target elements and modes explicitly in package-specific JSON rather than derive expected values from the app being checked. For color, distinguish
|
|
87
|
+
Read expected brand values from the independent source. Bind target elements and modes explicitly in package-specific JSON rather than derive expected values from the app being checked. For color, distinguish token provenance from rendered color, including platform-specific paint layers. For spacing, bind semantic gaps or padding and density rather than check arbitrary multiples. For typography, compare the complete role and establish that the intended font loaded. Use evidence appropriate to the target, such as browser computed styles, native view/accessibility data, source inspection, or measured interactions; screenshots alone cannot prove every property. Missing or ambiguous targets and unavailable prerequisites must be blocked. Prove the package on a compliant target and intentional violations before saving it for reuse.
|
|
89
88
|
|
|
90
|
-
The export returns \`{checks:[{id,
|
|
89
|
+
The export returns \`{checks:[{id,status:"pass"|"fail"|"blocked",priority:"high"|"medium"|"low"|null,currentState,problem,proposedFix,evidence:[{path,mediaType,label,role:"observed"|"reference"}],comparison?:{expected,observed,unit},location?}]}\`. Write plain factual \`currentState\` text, explain the violation or blocker in \`problem\`, and recommend a supported \`proposedFix\` or use null. Pass requires null problem; fail and blocked require a nonempty problem. Priority is author-selected or null, never inferred by Rivet. Evidence is required but can be empty. Each attachment has a safe relative path, media type, nonempty label, and observed or reference role. Referenced evidence must be real regular files inside \`evidenceDirectory\`, without symlinks or hard links. Do not claim an after state without measuring it. Optional \`comparison\` holds bounded finite JSON expected/observed values and a nonempty unit or null. Optional \`location\` is a nonempty platform-specific identifier. Keep comparison and location in technical metadata rather than the default user explanation. IDs must be stable and unique, checks nonempty. Unknown fields and the preceding category/rule/target format are rejected. The runner owns schemaVersion, verifier identity/source digest, projectPath, runDirectory, durationMs, and aggregate status. These migrated packages require a Rivet release containing this contract; published v25 uses the preceding format. Save with \`context update <id> --verifier <Markdown path> --verifier-package <manifest.json> --source-digest <packet digest>\`. Run with \`rivet context verify <id> --project <absolute target> --input <target.json>\`; with MCP use \`rivet_run_design_check\` with \`contextId\`, \`project\`, and \`inputFile\`, then execute its returned arguments through the host. The MCP call itself runs no code. Saving through \`rivet_save_design_check\` adds \`packageFile\`. A recipe-only update preserves the saved package for the same source digest; changed source requires a replacement package or explicit verifier removal before a Markdown-only save. Rivet bounds runtime/output, cleans up the process tree even after normal returns, and derives fail before blocked before pass. A pass exits 0; fail or blocked exits 1 with the completed report in \`error.details\`. Runtime errors have \`execution: "error"\` and a normalized reason. Report runtime failures separately from assertion failures. Missing/stale recipes and recipes without packages do not execute. Retrieval still runs no checks. Generation excludes executable code and checking recipes. Only explicit \`includeChecks: true\` context reads include recipe text and package metadata; ordinary context reads exclude both, and executable code is never returned. Saving adds no automatic gate, dependency install or source maintenance.
|
|
91
90
|
|
|
92
91
|
## Commands
|
|
93
92
|
|
|
@@ -102,7 +101,6 @@ The export returns \`{checks:[{id,category,status:"pass"|"fail"|"blocked",rule,t
|
|
|
102
101
|
- \`rivet status --project <path> [--watch]\` — session, resolved runner, active run, and the variants snapshot. \`--watch\` streams NDJSON.
|
|
103
102
|
- \`rivet variants status --project <path>\` / \`rivet variants list --project <path> [--history]\` — inspect live or past directions.
|
|
104
103
|
- \`rivet variants get <projectId>/<sessionId>:<variantId> [--detail]\` — resolve a copied direction from any working directory through the local project library, even when its editor is closed. The default response is compact metadata and an artifact path; add \`--detail\` for the full diff, file list, and design notes.
|
|
105
|
-
- \`rivet variants commit <variantId> --project <path> [--session <id>]\` — send the chosen direction to the project.
|
|
106
104
|
- \`rivet variants cancel <sessionId> --project <path>\` — cancel a running variants session.
|
|
107
105
|
- \`rivet evidence capture --url <url>\` — rendered design evidence (root variables, element styles, fonts) for a reference URL.
|
|
108
106
|
- \`rivet reference fetch <url>\` — Pinterest / Are.na reference data via the user's connected account. Accepts full pin/board URLs and \`pin.it\` share links. Pinterest images are downloaded into \`.rivet/references/\` and returned as absolute paths (\`data.images\`, plus \`local_path\` per pin) — view them directly and pass them to variants via \`--context-images\` instead of relaying URLs. If Pinterest returns \`status: not_connected\`, present the returned \`authUrl\` to the user and retry after they authorize. On failure the error message says exactly what to tell the user (e.g. save the pin to a board first).
|
|
@@ -117,13 +115,13 @@ The export returns \`{checks:[{id,category,status:"pass"|"fail"|"blocked",rule,t
|
|
|
117
115
|
|
|
118
116
|
Before every agent-initiated variants start, including fresh apps and \`--target\` requests, author a 1–3 word batch label plus one or more direction briefs as \`[{"label":"…","body":"…"}]\`. Write the user-visible \`runLabel\`, brief \`label\`, and brief \`body\` naturally in ${DISPLAY_LOCALE}, the computer's preferred display locale. The batch label summarizes the shared request and is passed through \`runLabel\` (MCP) or \`--run-label\` (CLI). Each brief \`label\` names what that direction concretely changes, not a vibe or numbered placeholder. Each \`body\` is a concise subtitle describing that direction. Add an optional \`notes\` string per brief for richer implementation intent (design tokens, motion specs, constraints) — it is delivered verbatim to that direction's worker and never shown in UI chips. Use one brief for a single visualization when the user wants Rivet's visualization framework without divergent ideas. For multiple directions, make every brief meaningfully different. Pass the array through the \`rivet_explore_designs\` \`briefs\` field or CLI \`--briefs <json>\`, and omit \`--count\` because the array length is authoritative. Human-direct CLI calls may omit the batch label and briefs and use Rivet's deterministic fallback.
|
|
119
117
|
|
|
120
|
-
Existing app, using CLI commands when MCP is unavailable. With MCP use \`rivet_get_design_context\` before briefs, \`rivet_explore_designs\` to start, \`rivet_get_exploration\` for progress, \`rivet_complete_variant_work\` for assigned completion
|
|
118
|
+
Existing app, using CLI commands when MCP is unavailable. With MCP use \`rivet_get_design_context\` before briefs, \`rivet_explore_designs\` to start, \`rivet_get_exploration\` for progress, \`rivet_complete_variant_work\` for assigned completion. Lifecycle open remains CLI.
|
|
121
119
|
|
|
122
120
|
1. \`rivet open --project <path> --caller-agent cursor --caller-model <model> --caller-session <id>\` → note \`editorUrl\`, \`sessionId\`, and \`resolvedRunner\`.
|
|
123
121
|
2. Author a batch label and three distinct title/subtitle briefs, then call \`rivet variants start --project <path> --instruction "try three hero layouts" --run-label "Hero layouts" --briefs '[{"label":"Split hero","body":"Moves supporting proof beside the primary call to action."},{"label":"Layered hero","body":"Stacks product imagery behind a compact centered headline."},{"label":"Product-led hero","body":"Lets the product preview dominate the opening composition."}]' --caller-agent cursor --caller-model <model> --caller-session <id>\` → note \`workId\`.
|
|
124
122
|
3. Agent-initiated runs return \`nextAction.action="complete_host_variant_work"\`. Each item carries a server-authored \`workerPrompt\` pointing at its complete briefing. Follow \`nextAction.parallelism\` exactly. For \`strategy="direct"\`, implement the single item in the current host. For \`strategy="one_worker_per_work_item"\`, spawn one native subagent per item in the same turn, passing each \`workerPrompt\` VERBATIM as its entire prompt. Preserve current permissions and approvals. Inherit the current model unless that item's \`workerSelection\` requires native selection. Do not substitute a fixed-model worker definition. If native delegation or the requested model is unavailable, report failure before editing. Briefs are final; do not re-plan them. Standalone jobs may use server workers; when there is no \`nextAction\`, watch status and do not implement their work. For \`mode="vary"\` the workspace entry already contains the source direction's finished code: read it first, apply the requested delta with targeted \`Edit\` operations in place, and never rewrite or re-emit the full file — unchanged sections must remain untouched. For \`workspace.kind="artifact_directory"\` the deliverable is \`workspace.rootPath/workspace.entryPath\` (write it in full only when it starts empty, i.e. \`mode="create"\`); for \`workspace.kind="git_worktree"\`, edit the app under \`workspace.projectPath\`.
|
|
125
123
|
4. The briefing file ends with the item's exact \`completeCommand\`: the worker runs \`rivet variants complete <workId> --project <path> --session <sessionId>\` itself as its final step, the moment its workspace is done. Completions are never held back or batched by the coordinator — and because workers self-report, the coordinator does NOT poll status while workers run: check \`rivet status\` once after workers return (or on a single ≥60s wakeup), only to confirm terminal states and surface failures. Rivet reads static HTML from \`workspace.entryPath\` and captures git-worktree changes itself. Do not send inline HTML or repeat project context in the completion payload. If the result says \`requeuedForRegeneration\`, poll status for the renewed lease, address its QA summary, and complete that item once more. If a worker cannot complete it, use \`--status failed --error <message>\`.
|
|
126
|
-
5. Show the user the \`editorUrl\` to compare directions
|
|
124
|
+
5. Show the user the \`editorUrl\` to compare directions. Retrieve their chosen prototype with \`rivet variants get <projectId>/<sessionId>:<variantId> --detail\` (MCP: \`rivet_get_exploration\` with the selected session and variant). The host agent owns implementation and verification in the user project; Rivet retains prototype artifacts and context.
|
|
127
125
|
|
|
128
126
|
Fresh 0-to-1: with MCP use \`rivet_explore_designs\` with \`fresh: true\` after reading \`rivet_get_design_context\`. For the CLI flow, create or use an empty directory and run \`rivet open --project <path> ...\`. Resolve the selected saved instructions with \`rivet context resolve\`, then author a batch label and one distinct brief per direction from the user's request, supplied references, and saved instructions. Include concrete section, layout, typography, and interaction choices in each brief's notes. Run \`rivet variants start --project <path> --fresh --instruction "build a SaaS landing page" --run-label "Landing layouts" --briefs '<json>' ...\`, omitting \`--count\` because the briefs set the count. Rivet uses those briefs directly without a hosted planning call. Pass local reference images via \`--context-images '["/abs/path.png"]'\` (\`rivet_explore_designs\` \`contextImages\`) — Rivet copies them into the run context and every worker views them natively. Pass reference page URLs via \`--reference-pages '["https://example.com"]'\` (\`referencePages\`) — Rivet renders each page server-side for design evidence + a screenshot; never capture evidence or screenshot pages yourself. Pass local reference videos via \`--reference-videos '["/abs/clip.mp4"]'\` (\`referenceVideos\`) — Rivet samples keyframes server-side; never run ffmpeg yourself. Never substitute a prose description of media you can pass directly.
|
|
129
127
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CURSOR_RULES_CONTENT = exports.CURSOR_RULES_FILENAME = exports.CURSOR_RULES_VERSION = void 0;
|
|
4
4
|
const cli_guidance_1 = require("./cli-guidance");
|
|
5
|
-
exports.CURSOR_RULES_VERSION =
|
|
5
|
+
exports.CURSOR_RULES_VERSION = 57;
|
|
6
6
|
exports.CURSOR_RULES_FILENAME = 'rivet.mdc';
|
|
7
7
|
const CURSOR_RULES_VERSION_MARKER = `rivet-rules-version: ${exports.CURSOR_RULES_VERSION}`;
|
|
8
8
|
exports.CURSOR_RULES_CONTENT = `---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rivet-design",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"description": "Local visual web development tool with AI-powered code modification",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"workspaces": [
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"nwsapi": "2.2.24"
|
|
211
211
|
},
|
|
212
212
|
"rivetPlugin": {
|
|
213
|
-
"toolContract": "intent-
|
|
213
|
+
"toolContract": "intent-v2"
|
|
214
214
|
},
|
|
215
|
-
"gitHead": "
|
|
215
|
+
"gitHead": "c4c287a9215f2936c79e05ddce775dfbba251bb4"
|
|
216
216
|
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
var Be=s=>{throw TypeError(s)};var Ee=(s,t,r)=>t.has(s)||Be("Cannot "+r);var h=(s,t,r)=>(Ee(s,t,"read from private field"),r?r.call(s):t.get(s)),z=(s,t,r)=>t.has(s)?Be("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,r),L=(s,t,r,i)=>(Ee(s,t,"write to private field"),i?i.call(s,r):t.set(s,r),r),M=(s,t,r)=>(Ee(s,t,"access private method"),r);import{S as lt,s as ct,h as Ve,g as Kt,n as fe,r as Qt,Q as dt,u as _e,a as Bt,b as Vt,c as d,e as Gt,d as Yt,f as Wt,i as ut,j as Ge,k as Jt,l as Xt,m as Zt,o as ce,p as me,q as es,t as e,B as J,v as Pe,P as ts,w as ss,x as rs,y as is,z as as,X as ht,D as mt,A as pt,C as xt,E as ft,F as bt,G as yt,H as gt,I as Ye,J as ns,K as os,L as ls,M as cs,N as ne,O as Se,R as ds,T as vt,U as ee,V as Y,W as x,Y as re,Z as H,_ as wt,$ as us,a0 as hs,a1 as ms,a2 as ps,a3 as xs,a4 as fs,a5 as bs,a6 as ys,a7 as B,a8 as gs,a9 as vs,aa as We,ab as ws,ac as js,ad as Ns,ae as ks,af as Ss,ag as jt,ah as _s,ai as Is,aj as Rs,ak as Cs,al as Es,am as Ps,an as Ts}from"./main-
|
|
2
|
-
* @license lucide-react v1.
|
|
1
|
+
var Be=s=>{throw TypeError(s)};var Ee=(s,t,r)=>t.has(s)||Be("Cannot "+r);var h=(s,t,r)=>(Ee(s,t,"read from private field"),r?r.call(s):t.get(s)),z=(s,t,r)=>t.has(s)?Be("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,r),L=(s,t,r,i)=>(Ee(s,t,"write to private field"),i?i.call(s,r):t.set(s,r),r),M=(s,t,r)=>(Ee(s,t,"access private method"),r);import{S as lt,s as ct,h as Ve,g as Kt,n as fe,r as Qt,Q as dt,u as _e,a as Bt,b as Vt,c as d,e as Gt,d as Yt,f as Wt,i as ut,j as Ge,k as Jt,l as Xt,m as Zt,o as ce,p as me,q as es,t as e,B as J,v as Pe,P as ts,w as ss,x as rs,y as is,z as as,X as ht,D as mt,A as pt,C as xt,E as ft,F as bt,G as yt,H as gt,I as Ye,J as ns,K as os,L as ls,M as cs,N as ne,O as Se,R as ds,T as vt,U as ee,V as Y,W as x,Y as re,Z as H,_ as wt,$ as us,a0 as hs,a1 as ms,a2 as ps,a3 as xs,a4 as fs,a5 as bs,a6 as ys,a7 as B,a8 as gs,a9 as vs,aa as We,ab as ws,ac as js,ad as Ns,ae as ks,af as Ss,ag as jt,ah as _s,ai as Is,aj as Rs,ak as Cs,al as Es,am as Ps,an as Ts}from"./main-tPO1OCpZ.js";var ie,ae,U,ye,se,pe,Te,nt,Ls=(nt=class extends lt{constructor(t,r){super();z(this,se);z(this,ie);z(this,ae);z(this,U);z(this,ye);L(this,ie,t),this.setOptions(r),this.bindMethods(),M(this,se,pe).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var i;const r=this.options;this.options=h(this,ie).defaultMutationOptions(t),ct(this.options,r)||h(this,ie).getMutationCache().notify({type:"observerOptionsUpdated",mutation:h(this,U),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Ve(r.mutationKey)!==Ve(this.options.mutationKey)?this.reset():((i=h(this,U))==null?void 0:i.state.status)==="pending"&&h(this,U).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&h(this,U)&&(h(this,U).addObserver(this),M(this,se,pe).call(this))}onUnsubscribe(){var t;this.hasListeners()||(t=h(this,U))==null||t.removeObserver(this)}onMutationUpdate(t){M(this,se,pe).call(this),M(this,se,Te).call(this,t)}getCurrentResult(){return h(this,ae)}reset(){var t;(t=h(this,U))==null||t.removeObserver(this),L(this,U,void 0),M(this,se,pe).call(this),M(this,se,Te).call(this)}mutate(t,r){var i;return L(this,ye,r),(i=h(this,U))==null||i.removeObserver(this),L(this,U,h(this,ie).getMutationCache().build(h(this,ie),this.options)),h(this,U).addObserver(this),h(this,U).execute(t)}},ie=new WeakMap,ae=new WeakMap,U=new WeakMap,ye=new WeakMap,se=new WeakSet,pe=function(){var r;const t=((r=h(this,U))==null?void 0:r.state)??Kt();L(this,ae,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Te=function(t){fe.batch(()=>{var i,n,o,a;const r=h(this,ye);if(r&&this.hasListeners()){const l=h(this,ae).variables,m=h(this,ae).context,f={client:h(this,ie),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(i=r.onSuccess)==null||i.call(r,t.data,l,m,f)}catch(b){Promise.reject(b)}try{(n=r.onSettled)==null||n.call(r,t.data,null,l,m,f)}catch(b){Promise.reject(b)}}else if((t==null?void 0:t.type)==="error"){try{(o=r.onError)==null||o.call(r,t.error,l,m,f)}catch(b){Promise.reject(b)}try{(a=r.onSettled)==null||a.call(r,void 0,t.error,l,m,f)}catch(b){Promise.reject(b)}}}this.listeners.forEach(l=>{l(h(this,ae))})})},nt);function Je(s,t){const r=new Set(t);return s.filter(i=>!r.has(i))}var ue,Q,he,oe,G,le,ge,ve,we,je,O,Le,Oe,Nt,Ae,Me,De,ot,Os=(ot=class extends lt{constructor(t,r,i){super();z(this,O);z(this,ue);z(this,Q);z(this,he);z(this,oe);z(this,G);z(this,le);z(this,ge);z(this,ve);z(this,we);z(this,je,[]);L(this,ue,t),L(this,oe,i),L(this,he,[]),L(this,G,[]),L(this,Q,[]),this.setQueries(r)}onSubscribe(){this.listeners.size===1&&h(this,G).forEach(t=>{t.subscribe(r=>{M(this,O,Me).call(this,t,r)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,h(this,G).forEach(t=>{t.destroy()})}setQueries(t,r){L(this,he,t),L(this,oe,r),fe.batch(()=>{const i=h(this,G),n=M(this,O,Ae).call(this,h(this,he));n.forEach(p=>p.observer.setOptions(p.defaultedQueryOptions));const o=n.map(p=>p.observer),a=o.map(p=>p.getCurrentResult()),l=i.length!==o.length,m=o.some((p,j)=>p!==i[j]),f=l||m,b=f?!0:a.some((p,j)=>{const N=h(this,Q)[j];return!N||!ct(p,N)});!f&&!b||(f&&(L(this,je,n),L(this,G,o)),L(this,Q,a),this.hasListeners()&&(f&&(Je(i,o).forEach(p=>{p.destroy()}),Je(o,i).forEach(p=>{p.subscribe(j=>{M(this,O,Me).call(this,p,j)})})),M(this,O,De).call(this)))})}getCurrentResult(){return h(this,Q)}getQueries(){return h(this,G).map(t=>t.getCurrentQuery())}getObservers(){return h(this,G)}getOptimisticResult(t,r){const i=M(this,O,Ae).call(this,t),n=i.map(a=>a.observer.getOptimisticResult(a.defaultedQueryOptions)),o=i.map(a=>a.defaultedQueryOptions.queryHash);return[n,a=>M(this,O,Oe).call(this,a??n,r,o),()=>M(this,O,Le).call(this,n,i)]}},ue=new WeakMap,Q=new WeakMap,he=new WeakMap,oe=new WeakMap,G=new WeakMap,le=new WeakMap,ge=new WeakMap,ve=new WeakMap,we=new WeakMap,je=new WeakMap,O=new WeakSet,Le=function(t,r){const i=new Set;return r.map((n,o)=>{const a=t[o];return n.defaultedQueryOptions.notifyOnChangeProps?a:n.observer.trackResult(a,l=>{i.has(l)||(i.add(l),r.forEach(m=>{m.observer.trackProp(l)}))})})},Oe=function(t,r,i){if(r){const n=h(this,we),o=i!==void 0&&n!==void 0&&(n.length!==i.length||i.some((a,l)=>a!==n[l]));return(h(this,Q)!==h(this,ve)||o||r!==h(this,ge))&&(L(this,ge,r),L(this,ve,h(this,Q)),i!==void 0&&L(this,we,i),L(this,le,Qt(h(this,le),r(t)))),h(this,le)}return t},Nt=function(){var t;return!((t=h(this,oe))!=null&&t.combine)||h(this,G).some((r,i)=>{var n;return r.options.suspense&&((n=h(this,Q)[i])==null?void 0:n.data)===void 0})},Ae=function(t){const r=new Map;h(this,G).forEach(n=>{const o=n.options.queryHash;if(!o)return;const a=r.get(o);a?a.push(n):r.set(o,[n])});const i=[];return t.forEach(n=>{var l;const o=h(this,ue).defaultQueryOptions(n),a=((l=r.get(o.queryHash))==null?void 0:l.shift())??new dt(h(this,ue),o);i.push({defaultedQueryOptions:o,observer:a})}),i},Me=function(t,r){const i=h(this,G).indexOf(t);i!==-1&&(L(this,Q,h(this,Q).slice()),h(this,Q)[i]=r,M(this,O,De).call(this))},De=function(){var t;if(this.hasListeners()){const r=M(this,O,Nt).call(this),i=h(this,le),n=r?i:M(this,O,Oe).call(this,M(this,O,Le).call(this,h(this,Q),h(this,je)),(t=h(this,oe))==null?void 0:t.combine);(r||i!==n)&&fe.batch(()=>{this.listeners.forEach(o=>{o(h(this,Q))})})}},ot);function As({queries:s,...t},r){const i=_e(),n=Bt(),o=Vt(),a=t.subscribed!==!1,l=d.useMemo(()=>s.map(S=>{const y=i.defaultQueryOptions(S);return y._optimisticResults=n?"isRestoring":a?"optimistic":void 0,y}),[s,i,n,a]);l.forEach(S=>{Gt(S);const y=i.getQueryCache().get(S.queryHash);Yt(S,o,y)}),Wt(o);const[m]=d.useState(()=>new Os(i,l,t)),[f,b,p]=m.getOptimisticResult(l,t.combine),j=!n&&a;d.useSyncExternalStore(d.useCallback(S=>j?m.subscribe(fe.batchCalls(S)):ut,[m,j]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),d.useEffect(()=>{m.setQueries(l,t)},[l,t,m]);const N=f.some((S,y)=>Ge(l[y],S))?f.flatMap((S,y)=>{const k=l[y];if(k&&Ge(k,S)){const $=new dt(i,k);return Jt(k,$,o)}return[]}):[];if(N.length>0)throw Promise.all(N);const R=f.find((S,y)=>{const k=l[y];return k&&Xt({result:S,errorResetBoundary:o,throwOnError:k.throwOnError,query:i.getQueryCache().get(k.queryHash),suspense:k.suspense})});if(R)throw R.error;return b(p())}function xe(s,t){const r=_e(),[i]=d.useState(()=>new Ls(r,s));d.useEffect(()=>{i.setOptions(s)},[i,s]);const n=d.useSyncExternalStore(d.useCallback(a=>i.subscribe(fe.batchCalls(a)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),o=d.useCallback((...a)=>{i.mutate(a[0],a[1]).catch(ut)},[i]);if(n.error&&Zt(i.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:o,mutateAsync:n.mutate}}/**
|
|
2
|
+
* @license lucide-react v1.64.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/const kt={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};kt.node;const St=ce(kt);/**
|
|
7
|
-
* @license lucide-react v1.
|
|
7
|
+
* @license lucide-react v1.64.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/const _t={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"}]]};_t.node;const Ms=ce(_t);/**
|
|
12
|
-
* @license lucide-react v1.
|
|
12
|
+
* @license lucide-react v1.64.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/const It={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"]};It.node;const Ds=ce(It);/**
|
|
17
|
-
* @license lucide-react v1.
|
|
17
|
+
* @license lucide-react v1.64.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
21
|
*/const Rt={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"}]]};Rt.node;const Xe=ce(Rt);/**
|
|
22
|
-
* @license lucide-react v1.
|
|
22
|
+
* @license lucide-react v1.64.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
26
|
*/const Ct={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"}]]};Ct.node;const qs=ce(Ct);/**
|
|
27
|
-
* @license lucide-react v1.
|
|
27
|
+
* @license lucide-react v1.64.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
31
|
*/const Et={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"}]]};Et.node;const zs=ce(Et);/**
|
|
32
|
-
* @license lucide-react v1.
|
|
32
|
+
* @license lucide-react v1.64.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
36
|
*/const Pt={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};Pt.node;const Tt=ce(Pt),$s=200,Fs=({project:s,onRename:t,onRemove:r,onSetPinned:i})=>{const n=me(),o=d.useRef(null),a=d.useRef(null),l=d.useRef(null),[m,f]=d.useState(!1),[b,p]=d.useState(!1),j=!!s.pinnedAt,[N,R]=d.useState(null),[S,y]=d.useState(s.name),[k,$]=d.useState(!1),[v,_]=d.useState(null),{containerRef:E,onKeyDown:D}=es();let X=N==="rename"?"Save name":"Remove from projects";k&&(X="Saving…"),d.useEffect(()=>{var q;if(b||!l.current)return;const g=l.current==="button"?a:o;l.current=null,(q=g.current)==null||q.focus()},[b]);const A=g=>{f(g),n==null||n.capture(g?"library_project_menu_opened":"library_project_menu_closed")},T=async g=>{if(!b){l.current=g,p(!0),n==null||n.capture("library_project_pin_clicked",{is_pinning:!j,method:g});try{await i(s.id,!j)}catch(q){gt.error(Ye(q,"Could not save pin. Try again."))}finally{p(!1)}}},W=g=>{A(!1),y(s.name),_(null),R(g),n==null||n.capture("library_project_action_opened",{action:g})},V=g=>{n==null||n.capture("library_project_action_closed",{action:N,outcome:g}),R(null)},I=async()=>{if(!(k||!N||N==="rename"&&!S.trim())){$(!0),_(null);try{N==="rename"?await t(s.id,S.trim()):await r(s.id),V("completed")}catch(g){_(Ye(g,"Could not save changes. Try again."))}finally{$(!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 ${m?"pointer-events-auto opacity-100":"pointer-events-none opacity-0"}`,children:[e.jsx(J,{ref:a,type:"button",variant:"ghost",size:"icon-compact",title:j?"Unpin project":"Pin project","aria-label":`${j?"Unpin":"Pin"} ${s.name}`,"aria-pressed":j,disabled:b,onClick:()=>{T("button")},children:e.jsx(Pe,{weight:j?"fill":"bold",size:16,"aria-hidden":!0})}),e.jsxs(ts,{open:m,onOpenChange:A,children:[e.jsx(ss,{asChild:!0,children:e.jsx(J,{ref:o,type:"button",variant:"ghost",size:"icon-compact","aria-label":`Actions for ${s.name}`,children:e.jsx(Ds,{size:16,"aria-hidden":!0})})}),e.jsx(rs,{children:e.jsxs(is,{"data-rivet-private":!0,ref:E,onKeyDown:D,role:"menu","aria-label":"Project actions",align:"start",sideOffset:4,onCloseAutoFocus:g=>{N&&g.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:b,onClick:()=>{A(!1),T("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(Pe,{size:14,weight:j?"fill":"bold","aria-hidden":!0}),j?"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(as,{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(ht,{size:14,"aria-hidden":!0}),"Remove from projects"]})]})})]})]}),e.jsx(mt,{open:N!==null,onOpenChange:g=>{!g&&!k&&V("cancelled")},children:e.jsxs(pt,{children:[e.jsx(xt,{className:"z-modal fixed inset-0 bg-black/60"}),e.jsxs(ft,{"data-rivet-private":!0,onCloseAutoFocus:g=>{var q;g.preventDefault(),(q=o.current)==null||q.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(bt,{className:"text-base font-medium break-words",children:N==="rename"?"Rename project":`Remove “${s.name}” from projects?`}),e.jsx(yt,{className:"mt-2 text-sm leading-6 text-white/60",children:N==="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:g=>{g.preventDefault(),I()},children:[N==="rename"?e.jsxs("label",{className:"mt-5 block text-xs text-white/70",children:["Project name",e.jsx("input",{autoFocus:!0,value:S,onChange:g=>y(g.target.value),maxLength:$s,disabled:k,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,v?e.jsx("p",{role:"alert",className:"mt-4 text-xs text-red-300",children:v}):null,e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"ghost",disabled:k,onClick:()=>V("cancelled"),children:"Cancel"}),e.jsx(J,{type:"submit",variant:"secondary",disabled:k||N==="rename"&&!S.trim(),children:X})]})]})]})]})})]})},Lt=6e4,Ot=60*Lt,Ie=24*Ot,Us=7*Ie,Hs=30*Ie,Ks=365*Ie,Qs=[["year",Ks],["month",Hs],["week",Us],["day",Ie],["hour",Ot],["minute",Lt]],Bs=new Intl.RelativeTimeFormat("en",{numeric:"always"}),Vs=s=>{const t=new Map;for(const r of s??[]){const i=Date.parse(r.createdAt);if(!Number.isFinite(i))continue;const n=t.get(r.projectId);(n===void 0||i>n)&&t.set(r.projectId,i)}return t},Gs=({projects:s,latestEdits:t})=>[...s].sort((r,i)=>{if(r.pinnedAt&&!i.pinnedAt)return-1;if(i.pinnedAt&&!r.pinnedAt)return 1;if(r.pinnedAt&&i.pinnedAt)return r.pinnedAt.localeCompare(i.pinnedAt)||r.id.localeCompare(i.id);const n=t.get(r.id),o=t.get(i.id);return n===void 0&&o!==void 0?1:o===void 0&&n!==void 0?-1:(o??0)-(n??0)||r.name.localeCompare(i.name)||r.id.localeCompare(i.id)}),Ys=({editedAt:s,now:t})=>{const r=Math.max(0,t-s);for(const[i,n]of Qs)if(r>=n)return`Edited ${Bs.format(-Math.floor(r/n),i)}`;return"Edited just now"},At=d.createContext(null),Ws=({navigation:s,onBrowseProjects:t,controls:r,isHeaderVisible:i=!0,children:n})=>{const[o,a]=d.useState(null);return e.jsxs(At.Provider,{value:o,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:t,"aria-label":"Projects",className:"flex items-center",children:e.jsx("img",{src:ns,alt:"","aria-hidden":!0,draggable:!1,className:"h-8 w-8"})}),e.jsx("div",{ref:a,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:r}),e.jsx("div",{className:"col-start-2 row-start-1 justify-self-end sm:col-start-3",children:s})]}):null,n]})},Mt=({children:s})=>{const t=d.useContext(At);return t?os.createPortal(s,t):null},qe=({label:s,value:t,onChange:r,onBlur:i,isDisabled:n=!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(ls,{size:14,className:"shrink-0","aria-hidden":!0}),e.jsx("input",{type:"search","aria-label":s,placeholder:`${s}…`,value:t,onChange:o=>r==null?void 0:r(o.target.value),onBlur:i,disabled:n,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"})]}),Js=({projects:s,variants:t,historyError:r,onRetryHistory:i,projectPreviews:n={},selectedProjectId:o,onSelectProject:a,onBrowseLibrary:l,onOpenProject:m,onRenameProject:f,onRemoveProject:b,onSetProjectPinned:p,isOpeningProject:j=!1,projectOpenError:N,onSearchCompleted:R,accountMenu:S,navigation:y,view:k="library",children:$})=>{const[v,_]=d.useState(""),E=o===null||$===void 0,D=d.useRef(null),X=Vs(t),A=Date.now(),T=s.find(I=>I.id===o),W=new Map;if(t)for(const I of s)I.historyIssue||W.set(I.id,0);for(const{projectId:I}of t??[]){const g=W.get(I);g!==void 0&&W.set(I,g+1)}const V=Gs({projects:s.filter(I=>I.name.toLowerCase().includes(v.toLowerCase())),latestEdits:X});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(Ws,{navigation:y,onBrowseProjects:l,isHeaderVisible:E,controls:k==="library"?e.jsx(qe,{label:"Search projects",value:v,onChange:_,onBlur:()=>R==null?void 0:R(v.length)}):null,children:[N?e.jsx("p",{role:"alert",className:"px-10 pt-5 text-xs text-red-200",children:N}):null,$!==void 0?$: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:D,tabIndex:-1,className:"sr-only",children:"Projects"}),e.jsx("div",{className:"mb-9 flex items-center justify-end",children:e.jsx(J,{onClick:()=>m(),variant:"secondary",disabled:j,leadingIcon:Xe,className:"shrink-0",children:"Open project…"})}),r?e.jsxs("div",{role:"alert",className:"mb-6 flex items-center gap-3 text-xs text-white/60",children:[e.jsx("span",{children:r}),e.jsx("button",{onClick:i,className:"shrink-0 underline underline-offset-4",children:"Retry history"})]}):null,T!=null&&T.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:T.issue}):null,T&&!T.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 ",T.name,"’s working folder to open its workspace."]}),e.jsx("button",{disabled:j,onClick:()=>m(T.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:[V.map(I=>{const g=W.get(I.id);let q="Loading variants…";g!==void 0?q=`${g.toLocaleString()} ${g===1?"variant":"variants"}`:(r||I.historyIssue)&&(q="Variants unavailable");const u=X.get(I.id);let C="No edits yet";r||I.historyIssue?C="Edit history unavailable":t===void 0?C="Loading edits…":g&&(C="Edit date unavailable");const K=n[I.id];return e.jsxs("div",{className:"group/project grid min-w-0",children:[e.jsxs("button",{onClick:()=>{_(""),a(I.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:K?e.jsx("img",{src:K.dataUrl,alt:`${I.name} — ${K.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:[I.pinnedAt?e.jsx(Pe,{size:12,weight:"fill","aria-hidden":!0,className:"text-content-muted shrink-0"}):null,e.jsx("span",{className:"truncate",children:I.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:Ys({editedAt:u,now:A})}):e.jsx("span",{children:C}),e.jsx("span",{className:"shrink-0",children:q})]}),I.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(Fs,{project:I,onRename:f,onSetPinned:p,onRemove:async Z=>{var de;await b(Z),(de=D.current)==null||de.focus()}})})]},I.id)}),V.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(Xe,{size:26,className:"mb-5 text-white/25"}),e.jsx("h2",{className:"text-sm font-medium",children:v?"No matching projects":"Add your projects"}),e.jsx("p",{className:"mt-2 max-w-sm text-xs leading-6 text-white/40",children:v?"Try another project name.":"Open an existing project to add it as a project here"}),v?null:e.jsx(J,{onClick:()=>m(),variant:"secondary",disabled:j,className:"mt-5",children:"Open project"})]}):null]})]}),E&&S?e.jsx("footer",{className:"border-main-border bg-main-light shrink-0 border-t px-2.5 py-2.5",children:S}):null]})})})},Dt=8,Ze=1,Xs=({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:`${Dt}px`},children:s}),Zs=({children:s})=>{const[t,r]=d.useState(Ze),i=d.useRef(null),n=d.useCallback(o=>{var l;if((l=i.current)==null||l.disconnect(),!o)return;const a=()=>r(Math.max(Ze,Math.ceil(o.getBoundingClientRect().height/Dt)));a(),i.current=new ResizeObserver(a),i.current.observe(o)},[]);return e.jsx("li",{className:"min-w-0",style:{gridRowEnd:`span ${t}`},children:e.jsx("div",{ref:n,className:"relative pb-8",children:s})})},er=async({profileId:s,referenceId:t,hash:r,signal:i})=>{const n=await cs(`/api/library/profile/references/${encodeURIComponent(t)}/media/${r}?${new URLSearchParams({profileId:s})}`,{signal:i});if(!n.ok)throw new Error("Image unavailable");return n.blob()},tr="200px",qt=({profileId:s,referenceId:t,hash:r,title:i,isDetail:n=!1})=>{const[o,a]=d.useState(!1),[l,m]=d.useState(!1),f=d.useRef(null),b=d.useCallback(N=>{var R;(R=f.current)==null||R.disconnect(),N&&(f.current=new IntersectionObserver(S=>{var y;S.some(k=>k.isIntersecting)&&(a(!0),(y=f.current)==null||y.disconnect())},{rootMargin:tr}),f.current.observe(N))},[]),p=ne({queryKey:["design-library-image",s,t,r],queryFn:async({signal:N})=>{const R=await er({profileId:s,referenceId:t,hash:r,signal:N});return new Promise((S,y)=>{const k=new FileReader;k.onload=()=>typeof k.result=="string"?S(k.result):y(new Error("Image unavailable")),k.onerror=()=>y(new Error("Image unavailable")),k.readAsDataURL(R)})},enabled:o,staleTime:1/0,gcTime:0,retry:!1}),j=!!p.data&&!l;return e.jsxs("div",{ref:b,className:Se("flex items-center justify-center overflow-hidden bg-white/[0.025]",n?"min-h-32":null,!n&&!j?"aspect-[4/3]":null),children:[p.isError||l?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,p.data&&!l?e.jsx("img",{src:p.data,alt:i,onError:()=>m(!0),className:n?"max-h-[65vh] w-full object-contain":"block h-auto w-full"}):null,!p.data&&!p.isError?e.jsx("span",{className:"text-xs text-white/25",children:"Loading image…"}):null]})},sr={arena:"Are.na",cosmos:"Cosmos",pinterest:"Pinterest",x:"X",image:"Uploaded image",text:"Saved text",variant:"Saved direction",pdf:"PDF"},rr=({provider:s})=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s==="arena"||s==="cosmos"||s==="pinterest"||s==="x"?e.jsx(ds,{provider:s,className:"h-3.5 w-3.5"}):null,sr[s]]}),ir=({label:s,onCopy:t,referenceCount:r=1})=>{const i=me(),[n,o]=d.useState("idle"),a=async()=>{o("copying");try{await t(),o("copied"),i==null||i.capture("library_reference_copy_completed",{reference_count:r,copy_kind:"agent"})}catch{o("failed"),gt.error("Could not copy. Check clipboard access and try again."),i==null||i.capture("library_reference_copy_failed",{reference_count:r,copy_kind:"agent"})}},l=n==="copied"?vt:Ms,m=n==="copied"?"Copied":s;return e.jsxs(e.Fragment,{children:[e.jsx(J,{variant:"secondary",size:"compact",leadingIcon:l,disabled:n==="copying",onClick:()=>void a(),"aria-label":m,"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:m})]})}),n==="failed"?e.jsx("span",{role:"alert",className:"sr-only",children:"Could not copy. Check clipboard access and try again."}):null]})},ar=6,be=100,et=100,nr=35*1024*1024,tt=Math.ceil(nr/3)*4,or=ee(["pinterest","arena","x","cosmos"]),zt=ee(["image",...or.options,"text","pdf","variant"]),Re=ee(["codex","claude","cursor"]),$t=Y({projectId:x().min(1).max(200),sessionId:x().min(1).max(200),variantId:x().min(1).max(200)}).strict();$t.extend({runtime:Re,note:x().trim().max(500).optional(),imageFile:x().min(1).max(2048).optional()});const Ft=$t.extend({treeSha:x().max(100).optional()}),lr=Y({hash:x().regex(/^[a-f0-9]{64}$/),mimeType:ee(["image/png","image/jpeg","image/webp","image/gif"]),bytes:re().int().positive(),representation:ee(["image","video-cover","page","variant"]).default("image"),page:re().int().positive().optional()});Y({provider:zt,remoteId:x().trim().min(1).max(2048),title:x().trim().min(1).max(500),url:x().url().optional()});Y({provider:zt,remoteId:x().trim().min(1).max(2048),title:x().max(1e3),text:x().max(1e5),url:x().url().optional(),media:H(lr).max(100),remoteImages:H(x().url()).max(100).optional(),remoteImageRepresentations:H(ee(["image","video-cover"])).max(100).optional(),unsupportedReason:x().max(1e3).optional(),variant:Ft.optional(),note:x().max(500).optional()});const Ut=Y({inputTokens:re().nonnegative().optional(),outputTokens:re().nonnegative().optional(),cachedInputTokens:re().nonnegative().optional(),allocation:wt("equal-share").optional()});Y({referenceId:x().min(1),revision:re().int().positive(),description:x().trim().min(1).max(8e3),runtime:us([Re,wt("user")]),evidence:ee(["observation","preference"]),usage:Ut.optional()});const cr=Y({requestId:x().min(1).max(200),instruction:x().min(1).max(3e4),runtime:Re,mode:ee(["auto","off","uploads"]).default("off"),excludedSourceIds:H(x()).max(100).default([]),excludedReferenceIds:H(x()).max(100).default([]),excludedMediaHashes:H(x()).max(100).default([]),suppliedInputHashes:H(x().regex(/^[a-f0-9]{64}$/)).max(be).optional()});cr.extend({mode:ee(["auto","off","uploads"]).default("uploads"),uploads:H(x().max(tt+et)).max(be).optional()}).refine(s=>(s.uploads??[]).reduce((t,r)=>t+r.length,0)<=tt+be*et,"Supplied images exceed the profile upload budget");const dr=hs().transform((s,t)=>{const r=ms.safeParse(s);return r.success?r.data:(t.addIssue({code:ps.custom,message:"Invalid supplied image reference"}),xs)}),st=Y({suppliedReferences:H(dr).max(be).optional(),failedUploadCount:re().int().min(0).max(be).optional(),usage:Ut.optional(),requestId:x(),status:ee(["selected","empty","off","unavailable","timeout"]),queries:H(x()),candidateIds:H(x()),selected:H(Y({id:x(),revision:re(),title:x().optional(),url:x().url().optional(),mediaHashes:H(x().regex(/^[a-f0-9]{64}$/)).optional(),reason:x(),sourceTitles:H(x()),variant:Ft.optional()})),contextText:x().max(6e3),images:H(Y({path:x(),hash:x().regex(/^[a-f0-9]{64}$/),mimeType:ee(["image/png","image/jpeg","image/webp","image/gif"])})).max(ar),durationMs:re()});st.pick({requestId:!0,suppliedReferences:!0,failedUploadCount:!0,status:!0,selected:!0,images:!0,durationMs:!0}).extend({requestId:x().min(1).max(200),selected:st.shape.selected.max(3)});Y({query:x().trim().min(2).max(1e3),sourceId:x().min(1).max(200).optional(),limit:re().int().min(1).max(100).default(24),runtime:Re.default("codex")});const Ht=50,rt=12,ur=x().regex(/^[a-f0-9]{12,64}@[1-9][0-9]*$/).refine(s=>Number.isSafeInteger(Number(s.split("@")[1])),"Invalid reference revision"),hr=Y({profileId:x().uuid(),keys:H(ur).min(1).max(Ht),isDetailed:fs().default(!1)}),mr=s=>{const t=new Map;for(const r of s){const i=r.id.slice(0,rt);t.set(i,(t.get(i)??0)+1)}return new Map(s.map(r=>{const i=r.id.slice(0,rt),n=t.get(i)===1?i:r.id;return[r.id,`${n}@${r.revision}`]}))},pr=({profileId:s,referenceKeys:t})=>{const r=hr.parse({profileId:s,keys:t});return["rivet","profile","reference",r.profileId,...r.keys].join(" ")},ze=s=>{const t=s.referenceKeys.length===1?"Copy to agent":`Copy ${s.referenceKeys.length} to agent`;return e.jsx(ir,{label:t,referenceCount:s.referenceKeys.length,onCopy:()=>navigator.clipboard.writeText(pr(s))})},xr=({profileId:s,reference:t,sources:r,referenceKey:i,children:n})=>{var m,f;const o=me(),a=t.title||"Untitled reference",l=t.url&&/^https?:\/\//i.test(t.url)?t.url:void 0;return e.jsxs(mt,{onOpenChange:b=>o==null?void 0:o.capture(b?"library_reference_opened":"library_reference_closed",{provider:t.provider,media_count:t.media.length}),children:[e.jsx(bs,{asChild:!0,children:n}),e.jsxs(pt,{children:[e.jsx(xt,{className:"fixed inset-0 z-50 bg-black/55"}),e.jsxs(ft,{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(yt,{className:"mb-2 text-xs text-white/40",children:e.jsx(rr,{provider:t.provider})}),e.jsx(bt,{className:"text-lg leading-snug font-medium tracking-tight break-words",children:a})]}),e.jsx(ys,{asChild:!0,children:e.jsx(J,{variant:"ghost",size:"icon-compact","aria-label":"Close reference",children:e.jsx(ht,{size:18})})})]}),e.jsx("div",{className:"border-b border-white/[0.07] px-7 py-4",children:e.jsx(ze,{profileId:s,referenceKeys:[i]},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(b=>e.jsx(qt,{profileId:s,referenceId:t.id,hash:b.hash,title:a,isDetail:!0},b.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:((m=t.observation)==null?void 0:m.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:r.filter(b=>t.sourceIds.includes(b.id)).map(b=>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:b.title}),b.isIncluded?null:e.jsx("span",{className:"text-white/35",children:"Excluded from generation"})]},b.id))})]}),l?e.jsxs("a",{href:l,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(St,{size:14,"aria-hidden":!0})]}):null]})]})]})]})},it="opacity-0 group-hover/card:opacity-100 group-focus-within/card:opacity-100 [@media(hover:none)]:opacity-100",fr="pointer-events-none group-hover/card:pointer-events-auto group-focus-within/card:pointer-events-auto [@media(hover:none)]:pointer-events-auto",br=({profileId:s,reference:t,sources:r,referenceKey:i,isSelected:n,isSelectionDisabled:o,onSelect:a})=>{var f;const l=t.title||"Untitled reference",m=t.media[0];return e.jsxs("div",{className:"group/card relative",children:[e.jsx(xr,{profileId:s,reference:t,sources:r,referenceKey:i,children:e.jsx("button",{"aria-label":`Inspect ${l}`,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:m?e.jsx(qt,{profileId:s,referenceId:t.id,hash:m.hash,title:l},m.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:l}),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:Se("pointer-events-none absolute inset-0 bg-black/40",it)}),e.jsxs("div",{className:Se("absolute inset-x-0 bottom-0 z-10 flex items-center justify-between gap-2 p-2",n?null:it,n?null:fr),children:[e.jsxs("label",{className:"relative shrink-0 cursor-pointer",title:n?"Deselect":"Select",children:[e.jsx("input",{type:"checkbox","aria-label":`Select ${l}`,checked:n,disabled:o,onChange:a,className:"peer absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-default"}),e.jsx("span",{className:Se("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",n?"border-orange-400 bg-orange-500 text-white":"border-white/35 bg-black/60 text-white/70"),children:e.jsx(vt,{size:14,"aria-hidden":!0})})]}),e.jsx(ze,{profileId:s,referenceKeys:[i]},t.revision)]})]})},Ne=24,yr="200px",gr=350,vr=100,wr=({snapshot:s})=>{var q;const t=me(),[r,i]=d.useState(""),[n,o]=d.useState(""),a=d.useRef(null),[l,m]=d.useState(""),[f,b]=d.useState(Ne),[p,j]=d.useState([]),N=d.useRef(null),R=mr(s.references),S=s.references.filter(u=>u.media.length>0),y=ne({queryKey:["design-reference-search",s.profileId,s.revision,s.references.map(({id:u,revision:C,sourceIds:K})=>[u,C,K]),n,l],queryFn:({signal:u})=>B("/profile/search",{method:"POST",body:{query:n,sourceId:l||void 0,limit:vr},signal:u}),enabled:n.length>=2&&s.references.length>0,retry:!1}),k=s.references.filter(u=>p.includes(u.id)),$=k.flatMap(u=>{const C=R.get(u.id);return C?[C]:[]}),v=r.trim(),_=v.length>=2,E=_&&s.references.length>0&&(n!==v||y.isLoading),D=_&&!E&&y.isError,X=new Map(s.references.map(u=>[u.id,u])),A=_?(((q=y.data)==null?void 0:q.results)??[]).flatMap(({id:u})=>{const C=X.get(u);return C?[C]:[]}):S.filter(u=>!l||u.sourceIds.includes(l)),T=S.length>0,W=A.length,V=s.references.length>0?"No images yet":"Your library starts here",I=d.useCallback(u=>{var C;(C=N.current)==null||C.disconnect(),u&&(N.current=new IntersectionObserver(K=>{var Z;K.some(de=>de.isIntersecting)&&((Z=N.current)==null||Z.disconnect(),b(Math.min(f+Ne,W)))},{root:u.parentElement,rootMargin:yr}),N.current.observe(u))},[f,W]),g=u=>{const C=k.map(Z=>Z.id),K=C.includes(u)?C.filter(Z=>Z!==u):[...C,u];j(K),t==null||t.capture("library_reference_selection_changed",{selected_count:K.length})};return e.jsxs("div",{className:"ph-no-capture flex min-h-0 flex-1 flex-col","data-rivet-private":!0,children:[e.jsx(Mt,{children:e.jsx(qe,{label:"Search references",value:r,onChange:u=>{i(u),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>o(u.trim()),gr),b(Ne)},onBlur:()=>{var u;return t==null?void 0:t.capture("library_reference_search_completed",{query_length:r.length,result_count:_?((u=y.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&&T?e.jsx("p",{className:"mb-5 text-xs text-white/40",children:"Automatic use is paused. Your saved references are still here."}):null,T?e.jsx("div",{className:"mb-7 flex flex-wrap items-center gap-3",children:e.jsxs("select",{"aria-label":"Source",value:l,onChange:u=>{m(u.target.value),b(Ne),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,$.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:[$.length," selected"]}),e.jsx(ze,{profileId:s.profileId,referenceKeys:$},$.join(" ")),e.jsx(J,{variant:"ghost",size:"compact",onClick:()=>{j([]),t==null||t.capture("library_reference_selection_changed",{selected_count:0})},children:"Clear selection"})]}):null,_&&y.data&&y.data.coverage.analyzed<y.data.coverage.saved?e.jsxs("p",{role:"status",className:"mb-5 text-xs text-white/45",children:[y.data.coverage.analyzed," of"," ",y.data.coverage.saved," references analyzed; results may be incomplete."]}):null,E?e.jsx("p",{role:"status",className:"py-10 text-center text-xs text-white/45",children:"Searching references…"}):null,D?e.jsxs("div",{role:"alert",className:"py-10 text-center text-xs text-white/50",children:[e.jsxs("p",{children:["Search is unavailable: ",y.error.message]}),e.jsx(J,{variant:"ghost",onClick:()=>{t==null||t.capture("library_reference_search_retry"),y.refetch()},children:"Try again"})]}):null,!E&&!D&&A.length?e.jsx(Xs,{children:A.slice(0,f).map(u=>{const C=R.get(u.id);return C?e.jsx(Zs,{children:e.jsx(br,{profileId:s.profileId,reference:u,sources:s.sources,referenceKey:C,isSelected:p.includes(u.id),isSelectionDisabled:!p.includes(u.id)&&$.length>=Ht,onSelect:()=>g(u.id)})},u.id):null})}):null,!E&&!D&&!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(zs,{size:28,strokeWidth:1,className:"mb-5 text-white/25","aria-hidden":!0}),e.jsx("h2",{className:"text-sm text-white/75",children:T||_?"No references found":V}),e.jsx("p",{className:"mt-2 max-w-sm text-xs leading-6 text-white/35",children:T||_?"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,!E&&!D&&A.length>f?e.jsx("div",{ref:I,role:"status",className:"py-8 text-center text-xs text-white/35",children:"Loading more references…"}):null]})]})},jr=1e4,Nr=({onBrowseProjects:s})=>{var a,l;const t=gs(),r=me(),i=ne({queryKey:["design-library",(a=t.data)==null?void 0:a.userId,(l=t.data)==null?void 0:l.isAuthenticated],queryFn:({signal:m})=>B("/profile/library",{signal:m}),enabled:!t.isPending,refetchInterval:jr,gcTime:0,retry:!1}),n=()=>{r==null||r.capture("library_reference_retry"),i.refetch()},o=e.jsx(Mt,{children:e.jsx(qe,{label:"Search references",value:"",isDisabled:!0})});return i.isError&&!i.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:i.error.message}),e.jsx("div",{className:"mt-5 flex justify-center gap-3",children:e.jsx(J,{variant:"ghost",onClick:s,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(J,{variant:"ghost",onClick:n,children:"Try again"})]}):null,e.jsx(wr,{snapshot:i.data},i.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…"})]})},kr=({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(r=>e.jsx("a",{href:r==="library"?"/rivet/library":"/rivet/library/references","aria-current":s===r?"page":void 0,onClick:i=>{i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),t(r))},className:vs("rounded-md px-3 py-2 text-xs focus-visible:outline-2 focus-visible:outline-offset-2",s===r?"bg-white/[0.08] text-white":"text-white/45 hover:text-white/80"),children:r==="library"?"Projects":"References"},r))}),Sr=()=>{const s=_e(),t=async o=>{await s.cancelQueries({queryKey:["project-library"]}),s.setQueryData(["project-library","projects"],a=>a&&{projects:o(a.projects)}),s.setQueriesData({queryKey:["project-library","history"]},a=>{if(!a)return a;const l=o(a.projects),m=new Set(l.map(({id:f})=>f));return{projects:l,variants:a.variants.filter(({projectId:f})=>m.has(f))}}),s.invalidateQueries({queryKey:["project-library"]})},r=xe({mutationFn:({projectId:o,name:a})=>B(`/projects/${encodeURIComponent(o)}`,{method:"PATCH",body:{name:a}}),onSuccess:({project:o})=>t(a=>a.map(l=>l.id===o.id?{...l,name:o.name}:l))}),i=xe({mutationFn:({projectId:o,isPinned:a})=>B(`/projects/${encodeURIComponent(o)}/pin`,{method:a?"PUT":"DELETE"}),onSuccess:({project:o})=>t(a=>a.map(l=>l.id===o.id?{...l,pinnedAt:o.pinnedAt}:l))}),n=xe({mutationFn:o=>B(`/projects/${encodeURIComponent(o)}`,{method:"DELETE"}),onSuccess:async(o,a)=>{await t(l=>l.filter(({id:m})=>m!==a)),await s.cancelQueries({queryKey:["library-project-preview",a]}),s.removeQueries({queryKey:["library-project-preview",a]})}});return{setProjectPinned:async(o,a)=>{await i.mutateAsync({projectId:o,isPinned:a})},renameProject:async(o,a)=>{await r.mutateAsync({projectId:o,name:a})},removeProject:async o=>{await n.mutateAsync(o)}}},at=2500,_r=500,Ir=6e4,Rr=[],Cr=[],ke=({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"})]}),Er=()=>{var $e,Fe,Ue,He,Ke,Qe;const s=me(),t=_e(),{renameProject:r,removeProject:i,setProjectPinned:n}=Sr(),o=d.useRef(),[a,l]=d.useState(()=>We(new URL(window.location.href))),[m]=d.useState(()=>crypto.randomUUID()),f=d.useRef(0),b=d.useRef(null),p=ne({queryKey:["project-library","projects"],queryFn:({signal:c})=>B("/projects",{signal:c}),refetchInterval:at,retry:!1}),j=(($e=p.data)==null?void 0:$e.projects)??Rr,N=j.map(({id:c,projectPath:w})=>({id:c,projectPath:w})).sort((c,w)=>c.id.localeCompare(w.id)),R=ne({queryKey:["project-library","history",N],queryFn:({signal:c})=>B("",{signal:c}),placeholderData:c=>{if(!c)return;const w=new Map(c.projects.map(({id:F,projectPath:te})=>[F,te]));if(!j.every(({id:F,projectPath:te})=>w.get(F)===te))return;const P=new Set(j.map(({id:F})=>F));return{projects:c.projects.filter(({id:F})=>P.has(F)),variants:c.variants.filter(({projectId:F})=>P.has(F))}},enabled:j.length>0,refetchInterval:at,retry:!1}),S=new Map((Fe=R.data)==null?void 0:Fe.projects.map(c=>[c.id,c])),y=j.map(c=>{const w=S.get(c.id);return{...c,issue:w?w.issue:c.issue,historyIssue:w?w.historyIssue:c.historyIssue}}),k=((Ue=R.data)==null?void 0:Ue.variants)??Cr,$=As({queries:y.map(c=>({queryKey:["library-project-preview",c.id,c.projectPath],queryFn:({signal:w})=>B(`/projects/${c.id}/thumbnail`,{signal:w}),enabled:a.kind==="library",refetchInterval:Ir,retry:!1}))}),v=y.find(c=>c.id===a.projectId),_=k.find(c=>c.projectId===a.projectId&&c.sessionId===a.sessionId&&c.variantId===a.variantId),E=d.useCallback(c=>{window.history.pushState(null,"",ws(c)),l(c)},[]);d.useEffect(()=>{v?o.current=v.id:p.isSuccess&&!p.isFetching&&a.projectId===o.current&&a.projectId&&(o.current=void 0,E({kind:"library"}))},[v,a.projectId,p.isSuccess,p.isFetching,E]),d.useEffect(()=>{const c=()=>l(We(new URL(window.location.href)));return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]),d.useEffect(()=>{const c=new AbortController;let w;const P=async()=>{try{const F=await B(`/views/${m}`,{method:"PUT",body:{isFocused:document.visibilityState==="visible"&&document.hasFocus()},signal:c.signal});for(const te of F.navigations){if(c.signal.aborted)return;if(te.sequence>f.current){let Ce="library";te.projectId&&(Ce="workspace"),te.variantId&&(Ce="preview"),E({...te,kind:Ce}),f.current=te.sequence}await B(`/views/${m}/acknowledgements`,{method:"POST",body:{sequence:te.sequence},signal:c.signal})}}catch{}c.signal.aborted||(w=setTimeout(()=>{P()},_r))};return P(),()=>{c.abort(),clearTimeout(w)}},[m,E]);const D=ne({queryKey:["library-workspace",a.projectId],queryFn:()=>B(`/projects/${a.projectId}/runtime`,{method:"POST"}),enabled:a.kind==="workspace"&&!!a.projectId&&(v==null?void 0:v.isAvailable)===!0,retry:!1,refetchOnWindowFocus:!1}),X=D.data?new URL(D.data.editorUrl).origin:null;d.useEffect(()=>{if(a.kind!=="workspace"||!X)return;const c=w=>{!b.current||w.source!==b.current.contentWindow||w.origin!==X||w.data!==Ss||(s==null||s.capture("library_view_changed",{view:"projects"}),E({kind:"library"}))};return window.addEventListener("message",c),()=>window.removeEventListener("message",c)},[a.kind,X,E,s]);const A=ne({queryKey:["library-preview",a.projectId,a.sessionId,a.variantId],queryFn:()=>B(`/projects/${a.projectId}/variants/${a.sessionId}/${a.variantId}/preview`,{method:"POST"}),enabled:a.kind==="preview"&&!!(_!=null&&_.hasStaticPreview),retry:!1,refetchOnWindowFocus:!1}),T=xe({mutationFn:c=>B(`/projects/${a.projectId}/variants/${a.sessionId}/${a.variantId}`,{method:"PATCH",body:{label:c}}),onSuccess:()=>t.invalidateQueries({queryKey:["project-library"]})}),W=c=>{const w=y.find(P=>P.id===c);s==null||s.capture("library_project_selected",{project_id:c,workspace_available:(w==null?void 0:w.isAvailable)??!1}),E({kind:"workspace",projectId:c})},V=xe({mutationFn:async c=>{const{projectPath:w}=await B("/folder-selections",{method:"POST"});return w===null?null:B(c?`/projects/${c}/workspace`:"/projects",{method:c?"PATCH":"POST",body:{projectPath:w}})},onSuccess:c=>{c&&(t.invalidateQueries({queryKey:["project-library"]}),s==null||s.capture("library_project_selected",{project_id:c.project.id,workspace_available:c.project.isAvailable}),E({kind:"workspace",projectId:c.project.id}))},onSettled:(c,w,P)=>{s==null||s.capture("library_open_project_closed",{is_relink:!!P})}}),I=c=>{V.isPending||(s==null||s.capture("library_open_project_opened",{is_relink:!!c}),V.mutate(c))},g=()=>{s==null||s.capture("library_view_changed",{view:"projects"}),E({kind:"library"})},q=()=>{s==null||s.capture("library_view_changed",{view:"workspace"}),E({...a,kind:"workspace"})},u=()=>{s==null||s.capture("library_history_retry"),R.refetch()};let C;if(a.kind==="workspace"&&(v==null?void 0:v.isAvailable)!==!1||a.kind==="preview"){let c=!1,w=e.jsxs("div",{className:"m-auto flex items-center gap-2 text-xs text-white/40",children:[e.jsx(Tt,{size:14,className:"animate-spin"}),"Opening ",(v==null?void 0:v.name)??"project","…"]});if(p.data&&!v||R.data&&a.variantId&&!_)w=e.jsx("div",{className:"m-auto text-sm text-white/60",children:"This project or direction is no longer in your library."});else if(a.kind==="preview"&&R.error&&!R.data)w=e.jsx(ke,{error:R.error,retry:u});else if(a.kind==="workspace"&&D.error)w=e.jsx(ke,{error:D.error,retry:()=>{D.refetch()}});else if(a.kind==="workspace"&&D.data){c=!0;const P=new URL(D.data.editorUrl);P.searchParams.set("library","1"),P.searchParams.set("libraryOrigin",window.location.origin),a.sessionId&&a.variantId&&(P.searchParams.set("historySession",a.sessionId),P.searchParams.set("historyVariant",a.variantId)),w=e.jsx("iframe",{ref:b,title:`${(v==null?void 0:v.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 a.kind==="preview"&&A.error?w=e.jsx(ke,{error:A.error,retry:()=>{A.refetch()}}):a.kind==="preview"&&A.data?w=e.jsx("iframe",{title:`${(_==null?void 0:_.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"}):a.kind==="preview"&&_&&!_.hasStaticPreview&&(w=e.jsxs("div",{className:"m-auto max-w-sm text-center",children:[e.jsx("p",{className:"text-sm",children:_.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:_.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:q,disabled:(v==null?void 0:v.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"})]}));C=e.jsxs(e.Fragment,{children:[a.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:g,className:"rounded p-1.5 text-white/45 hover:bg-white/5",children:e.jsx(js,{size:15})}),e.jsx("span",{className:"text-xs text-white/40",children:v==null?void 0:v.name}),_?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white/20",children:"/"}),e.jsxs("form",{onSubmit:P=>{P.preventDefault();const F=new FormData(P.currentTarget);T.mutate(String(F.get("label")))},className:"flex min-w-0 flex-1 gap-2",children:[e.jsx("input",{name:"label","aria-label":"Direction name",defaultValue:_.label,className:"max-w-xs min-w-0 flex-1 bg-transparent text-xs text-white/80 outline-none"}),e.jsx("button",{disabled:T.isPending,className:"text-[10px] text-white/30 hover:text-white",children:"Rename"})]},`${_.projectId}:${_.variantId}`)]}):e.jsx("span",{className:"flex-1"}),a.kind==="preview"?e.jsxs("button",{onClick:q,disabled:(v==null?void 0:v.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(St,{size:12})]}):null]}):null,a.kind==="workspace"&&!c?e.jsx("button",{onClick:g,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,T.error?e.jsx("p",{role:"alert",className:"px-5 py-2 text-xs text-red-200",children:T.error.message}):null,w]})}let K=C;p.error&&!p.data?K=e.jsx(ke,{error:p.error,retry:()=>{p.refetch()}}):p.isPending&&(K=e.jsx("div",{role:"status",className:"m-auto text-xs text-white/40",children:"Loading projects…"}));const Z=a.kind==="references"?"references":"library",de=e.jsx(kr,{view:Z,onNavigate:c=>{s==null||s.capture("library_view_changed",{view:c==="references"?"references":"projects"}),E({kind:c})}});return a.kind==="references"&&(K=e.jsx(Nr,{onBrowseProjects:g})),e.jsxs(e.Fragment,{children:[e.jsx(Js,{projects:y,variants:(He=R.data)==null?void 0:He.variants,historyError:(Ke=R.error)==null?void 0:Ke.message,onRetryHistory:u,projectPreviews:Object.fromEntries(y.map((c,w)=>{var P,F;return[c.id,(F=(P=$[w])==null?void 0:P.data)==null?void 0:F.preview]})),selectedProjectId:a.projectId??null,onSelectProject:W,onBrowseLibrary:g,navigation:de,view:Z,onOpenProject:I,onRenameProject:r,onRemoveProject:i,onSetProjectPinned:n,accountMenu:e.jsx(Ns,{side:"top",align:"start"}),isOpeningProject:V.isPending,projectOpenError:(Qe=V.error)==null?void 0:Qe.message,onSearchCompleted:c=>s==null?void 0:s.capture("library_search_completed",{query_length:c}),children:K}),e.jsx(ks,{position:"bottom-right",theme:"dark"})]})},Pr=async s=>{const t=Ts(),r=await Cs("/api/library/browser-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!r.ok){const i=Y({error:x()}).safeParse(await r.json().catch(()=>null));throw new Error(i.success?i.data.error:"Could not start a library session.")}Es(Ps(await r.json()),t)},Tr=()=>{const s=d.useSyncExternalStore(jt,Is),{startLogin:t,isStartingLogin:r,loginError:i}=Rs("library",Pr);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:r,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:[r?e.jsx(Tt,{size:16,className:"animate-spin"}):null,r?"Connecting…":"Continue with Google"]}),i||s?e.jsx("p",{role:"alert",className:"mt-4 text-sm text-red-300",children:i??s}):null]})})},Ar=()=>d.useSyncExternalStore(jt,_s)?e.jsx(Er,{}):e.jsx(Tr,{});export{Ar as default};
|
|
37
|
-
//# sourceMappingURL=LibraryEntry-
|
|
37
|
+
//# sourceMappingURL=LibraryEntry-Cr4GFYXW.js.map
|