@mean-weasel/lineage 0.1.17 → 0.1.18

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.18
4
+
5
+ - Keep managed stable/preview service control compatible with launchers generated by the immediately preceding public channel bootstrap by resolving the exact launcher through its receipt-bound channel pointer.
6
+ - Preserve explicit and current-shim launcher selection while surfacing the underlying spawn failure instead of masking it with an undefined stderr formatting error.
7
+ - Extend isolated first-user onboarding proof to simulate the legacy bootstrap contract across custom runtime and shim roots.
8
+
3
9
  ## 0.1.17
4
10
 
5
11
  - Add atomic `profile init` for fresh installs, including exact runtime pinning, owner-only manifests, bound SQLite identity, no-clobber rollback, and actionable guidance when an unbound runtime attempts a write.
@@ -88,9 +88,26 @@ function serviceRoot() {
88
88
  }
89
89
  function defaultLauncher(channel) {
90
90
  if (channel === "dev") return [process.execPath, "--import", "tsx", join(root, "src", "cli", "lineage-dev.ts")];
91
- const runtimeRoot = process.env.LINEAGE_RUNTIME_ROOT || (platform() === "darwin" ? join(homedir(), "Library", "Application Support", "Lineage", "runtimes") : join(homedir(), ".local", "share", "lineage", "runtimes"));
92
91
  const envName = channel === "stable" ? "LINEAGE_STABLE_BIN" : "LINEAGE_PREVIEW_BIN";
93
- return [process.env[envName] || process.env.LINEAGE_CHANNEL_LAUNCHER || join(runtimeRoot, "bin", channel === "stable" ? "lineage-stable" : "lineage-preview")];
92
+ const explicit = process.env[envName] || process.env.LINEAGE_CHANNEL_LAUNCHER;
93
+ if (explicit) return [explicit];
94
+ const receiptPath = process.env.LINEAGE_RUNTIME_RECEIPT;
95
+ if (receiptPath) {
96
+ if (!existsSync(receiptPath)) throw new Error(`${channel} service manager runtime receipt does not exist: ${receiptPath}`);
97
+ const resolvedReceipt = realpathSync(receiptPath);
98
+ const runtimeRoot2 = dirname(dirname(dirname(dirname(resolvedReceipt))));
99
+ const pointerPath = join(runtimeRoot2, "channels", `${channel}.json`);
100
+ if (!existsSync(pointerPath)) throw new Error(`${channel} service manager could not find its receipt-bound channel pointer: ${pointerPath}`);
101
+ const pointer = JSON.parse(readFileSync(pointerPath, "utf8"));
102
+ if (pointer.channel !== channel) throw new Error(`${channel} service manager channel pointer reports ${pointer.channel || "(missing)"}`);
103
+ if (!pointer.receipt_path || !existsSync(pointer.receipt_path) || realpathSync(pointer.receipt_path) !== resolvedReceipt) {
104
+ throw new Error(`${channel} service manager channel pointer is not bound to its runtime receipt`);
105
+ }
106
+ if (!pointer.shim || !existsSync(pointer.shim)) throw new Error(`${channel} service manager channel pointer launcher is missing: ${pointer.shim || "(missing)"}`);
107
+ return [realpathSync(pointer.shim)];
108
+ }
109
+ const runtimeRoot = process.env.LINEAGE_RUNTIME_ROOT || (platform() === "darwin" ? join(homedir(), "Library", "Application Support", "Lineage", "runtimes") : join(homedir(), ".local", "share", "lineage", "runtimes"));
110
+ return [join(runtimeRoot, "bin", channel === "stable" ? "lineage-stable" : "lineage-preview")];
94
111
  }
95
112
  function launcherFor(channel, args) {
96
113
  const explicit = readOption(args, "--launcher");
@@ -103,6 +120,12 @@ function invoke(launcher, args, options = {}) {
103
120
  ...options
104
121
  });
105
122
  }
123
+ function invocationFailure(result) {
124
+ const stderr = typeof result.stderr === "string" ? result.stderr.trim() : "";
125
+ const stdout = typeof result.stdout === "string" ? result.stdout.trim() : "";
126
+ const spawnError = result.error instanceof Error ? result.error.message : result.error ? String(result.error) : "";
127
+ return stderr || stdout || spawnError || `process exited with status ${result.status ?? "unknown"}`;
128
+ }
106
129
  function shellDisplay(parts) {
107
130
  return parts.map((part) => /^[A-Za-z0-9_./:@=-]+$/.test(part) ? part : JSON.stringify(part)).join(" ");
108
131
  }
@@ -112,10 +135,10 @@ function profileDoctor(launcher, selector) {
112
135
  try {
113
136
  doctor = JSON.parse(result.stdout || "{}");
114
137
  } catch {
115
- throw new Error(`Profile doctor did not return JSON: ${(result.stderr || result.stdout).trim()}`);
138
+ throw new Error(`Profile doctor did not return JSON: ${invocationFailure(result)}`);
116
139
  }
117
140
  if (!doctor.profile) {
118
- const detail = doctor.error || (doctor.checks || []).filter((check) => check.status === "fail").map((check) => check.message).join("; ") || result.stderr.trim() || "profile manifest was not found or could not be read";
141
+ const detail = doctor.error || (doctor.checks || []).filter((check) => check.status === "fail").map((check) => check.message).join("; ") || invocationFailure(result) || "profile manifest was not found or could not be read";
119
142
  const doctorCommand = shellDisplay([...launcher, "profile", "doctor", "--profile", selector, "--json"]);
120
143
  const initCommand = shellDisplay([...launcher, "profile", "init", "--profile", selector, "--confirm-write", "--json"]);
121
144
  throw new Error(`Profile ${selector} could not be resolved: ${detail}. Next: run \`${doctorCommand}\`. If this is a new profile, run \`${initCommand}\` instead.`);
@@ -128,9 +151,9 @@ function runtimeDoctor(launcher) {
128
151
  try {
129
152
  runtime = JSON.parse(result.stdout || "{}");
130
153
  } catch {
131
- throw new Error(`Runtime doctor did not return JSON: ${(result.stderr || result.stdout).trim()}`);
154
+ throw new Error(`Runtime doctor did not return JSON: ${invocationFailure(result)}`);
132
155
  }
133
- if (result.status !== 0 || !runtime.verified) throw new Error(`Runtime doctor failed: ${(result.stderr || JSON.stringify(runtime)).trim()}`);
156
+ if (result.status !== 0 || !runtime.verified) throw new Error(`Runtime doctor failed: ${invocationFailure(result) || JSON.stringify(runtime)}`);
134
157
  return runtime;
135
158
  }
136
159
  function statePaths(channel, profile) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../scripts/managed-service.mjs"],
4
- "sourcesContent": ["#!/usr/bin/env node\n\nimport { randomUUID, createHash } from 'node:crypto';\nimport { spawn, spawnSync } from 'node:child_process';\nimport {\n closeSync,\n existsSync,\n mkdirSync,\n openSync,\n readFileSync,\n readdirSync,\n readlinkSync,\n realpathSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from 'node:fs';\nimport { homedir, platform } from 'node:os';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst scriptDirectory = dirname(fileURLToPath(import.meta.url));\nconst root = [resolve(scriptDirectory, '../..'), resolve(scriptDirectory, '..')].find(candidate => {\n try {\n const packageInfo = JSON.parse(readFileSync(join(candidate, 'package.json'), 'utf8'));\n return packageInfo.name === '@mean-weasel/lineage';\n } catch {\n return false;\n }\n});\nif (!root) throw new Error('Unable to locate the Lineage package root for managed service control');\nconst receiptSchema = 'lineage.managed_service.v1';\n\nfunction packageTreeSha256(packageRoot) {\n const hash = createHash('sha256');\n const visit = (directory, relativeDirectory = '') => {\n for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {\n const relativePath = relativeDirectory ? join(relativeDirectory, entry.name) : entry.name;\n const path = join(directory, entry.name);\n hash.update(relativePath.replaceAll('\\\\', '/'));\n hash.update('\\0');\n if (entry.isDirectory()) {\n hash.update('directory\\0');\n visit(path, relativePath);\n } else if (entry.isSymbolicLink()) {\n hash.update('symlink\\0');\n hash.update(readlinkSync(path));\n } else if (entry.isFile()) {\n hash.update('file\\0');\n hash.update(readFileSync(path));\n } else {\n hash.update('other\\0');\n }\n hash.update('\\0');\n }\n };\n visit(packageRoot);\n return hash.digest('hex');\n}\n\nfunction assertServiceManagerOrigin(channel) {\n const checkoutController = resolve(scriptDirectory) === resolve(root, 'scripts');\n if (channel === 'dev') {\n if (!checkoutController) throw new Error('Dev service control is checkout-only; run node scripts/managed-service.mjs from the intended worktree');\n return;\n }\n if (checkoutController) throw new Error(`${channel} service control requires the matching attested packaged manager`);\n const receiptPath = process.env.LINEAGE_RUNTIME_RECEIPT;\n if (!receiptPath || !existsSync(receiptPath)) throw new Error(`${channel} service manager is missing its runtime install receipt`);\n const receipt = JSON.parse(readFileSync(receiptPath, 'utf8'));\n if (receipt.channel !== channel || process.env.LINEAGE_RELEASE_CHANNEL !== channel) {\n throw new Error(`${channel} service manager receipt channel does not match the requested channel`);\n }\n if (!receipt.package_root || realpathSync(receipt.package_root) !== realpathSync(root)) {\n throw new Error(`${channel} service manager receipt package root ${receipt.package_root || '(missing)'} does not match controller root ${root}`);\n }\n if (packageTreeSha256(root) !== receipt.package_tree_sha256) throw new Error(`${channel} service manager package tree does not match its install receipt`);\n}\n\nfunction readOption(args, name) {\n const inline = args.find(arg => arg.startsWith(`${name}=`));\n if (inline) return inline.slice(name.length + 1);\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n\nfunction serviceRoot() {\n if (process.env.LINEAGE_SERVICE_ROOT) return resolve(process.env.LINEAGE_SERVICE_ROOT);\n if (platform() === 'darwin') return join(homedir(), 'Library', 'Application Support', 'Lineage', 'services');\n if (platform() === 'win32') return join(process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'), 'Lineage', 'services');\n return join(process.env.XDG_STATE_HOME || join(homedir(), '.local', 'state'), 'lineage', 'services');\n}\n\nfunction defaultLauncher(channel) {\n if (channel === 'dev') return [process.execPath, '--import', 'tsx', join(root, 'src', 'cli', 'lineage-dev.ts')];\n const runtimeRoot = process.env.LINEAGE_RUNTIME_ROOT\n || (platform() === 'darwin'\n ? join(homedir(), 'Library', 'Application Support', 'Lineage', 'runtimes')\n : join(homedir(), '.local', 'share', 'lineage', 'runtimes'));\n const envName = channel === 'stable' ? 'LINEAGE_STABLE_BIN' : 'LINEAGE_PREVIEW_BIN';\n return [process.env[envName]\n || process.env.LINEAGE_CHANNEL_LAUNCHER\n || join(runtimeRoot, 'bin', channel === 'stable' ? 'lineage-stable' : 'lineage-preview')];\n}\n\nfunction launcherFor(channel, args) {\n const explicit = readOption(args, '--launcher');\n return explicit ? [resolve(explicit)] : defaultLauncher(channel);\n}\n\nfunction invoke(launcher, args, options = {}) {\n return spawnSync(launcher[0], [...launcher.slice(1), ...args], {\n cwd: root,\n encoding: 'utf8',\n ...options,\n });\n}\n\nfunction shellDisplay(parts) {\n return parts.map(part => /^[A-Za-z0-9_./:@=-]+$/.test(part) ? part : JSON.stringify(part)).join(' ');\n}\n\nfunction profileDoctor(launcher, selector) {\n const result = invoke(launcher, ['profile', 'doctor', '--profile', selector, '--json']);\n let doctor;\n try {\n doctor = JSON.parse(result.stdout || '{}');\n } catch {\n throw new Error(`Profile doctor did not return JSON: ${(result.stderr || result.stdout).trim()}`);\n }\n if (!doctor.profile) {\n const detail = doctor.error\n || (doctor.checks || []).filter(check => check.status === 'fail').map(check => check.message).join('; ')\n || result.stderr.trim()\n || 'profile manifest was not found or could not be read';\n const doctorCommand = shellDisplay([...launcher, 'profile', 'doctor', '--profile', selector, '--json']);\n const initCommand = shellDisplay([...launcher, 'profile', 'init', '--profile', selector, '--confirm-write', '--json']);\n throw new Error(`Profile ${selector} could not be resolved: ${detail}. Next: run \\`${doctorCommand}\\`. If this is a new profile, run \\`${initCommand}\\` instead.`);\n }\n return { doctor, status: result.status ?? 1 };\n}\n\nfunction runtimeDoctor(launcher) {\n const result = invoke(launcher, ['runtime', 'doctor', '--json']);\n let runtime;\n try {\n runtime = JSON.parse(result.stdout || '{}');\n } catch {\n throw new Error(`Runtime doctor did not return JSON: ${(result.stderr || result.stdout).trim()}`);\n }\n if (result.status !== 0 || !runtime.verified) throw new Error(`Runtime doctor failed: ${(result.stderr || JSON.stringify(runtime)).trim()}`);\n return runtime;\n}\n\nfunction statePaths(channel, profile) {\n const digest = createHash('sha256').update(profile.manifest_path).digest('hex').slice(0, 12);\n const key = `${channel}--${profile.profile_id}--${digest}`;\n const directory = join(serviceRoot(), key);\n return {\n directory,\n lock: `${directory}.manager.lock`,\n log: join(directory, 'service.log'),\n receipt: join(directory, 'service.json'),\n };\n}\n\nfunction processAlive(pid) {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return error?.code !== 'ESRCH';\n }\n}\n\nfunction processStartToken(pid) {\n if (platform() === 'win32') return undefined;\n const result = spawnSync('ps', ['-p', String(pid), '-o', 'lstart='], { encoding: 'utf8' });\n return result.status === 0 ? result.stdout.trim() || undefined : undefined;\n}\n\nfunction processCommand(pid) {\n if (platform() === 'win32') return undefined;\n const result = spawnSync('ps', ['-p', String(pid), '-o', 'command='], { encoding: 'utf8' });\n return result.status === 0 ? result.stdout.trim() || undefined : undefined;\n}\n\nfunction acquireManagerLock(path) {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n for (let attempt = 0; attempt < 3; attempt += 1) {\n try {\n mkdirSync(path, { mode: 0o700 });\n writeFileSync(join(path, 'owner.json'), `${JSON.stringify({ acquired_at: new Date().toISOString(), pid: process.pid })}\\n`, { mode: 0o600 });\n return () => rmSync(path, { force: true, recursive: true });\n } catch (error) {\n if (error?.code !== 'EEXIST') throw error;\n try {\n const owner = JSON.parse(readFileSync(join(path, 'owner.json'), 'utf8'));\n if (Number.isSafeInteger(owner.pid) && processAlive(owner.pid)) {\n throw new Error(`Another service manager operation is active (pid ${owner.pid})`, { cause: error });\n }\n } catch (ownerError) {\n if (ownerError instanceof Error && ownerError.message.startsWith('Another service manager')) throw ownerError;\n }\n rmSync(path, { force: true, recursive: true });\n }\n }\n throw new Error(`Could not acquire service manager lock ${path}`);\n}\n\nfunction readReceipt(path) {\n if (!existsSync(path)) return undefined;\n const receipt = JSON.parse(readFileSync(path, 'utf8'));\n if (\n receipt.schema_version !== receiptSchema\n || !Number.isSafeInteger(receipt.pid)\n || typeof receipt.instance_id !== 'string'\n || typeof receipt.profile_fingerprint !== 'string'\n || !Array.isArray(receipt.launcher)\n ) throw new Error(`Managed service receipt is invalid: ${path}`);\n return receipt;\n}\n\nfunction writeReceipt(path, receipt) {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n const temporary = `${path}.tmp-${process.pid}-${randomUUID()}`;\n writeFileSync(temporary, `${JSON.stringify(receipt, null, 2)}\\n`, { encoding: 'utf8', flag: 'wx', mode: 0o600 });\n renameSync(temporary, path);\n}\n\nexport function managedServiceIdentityErrors(runtime, receipt) {\n const errors = [];\n if (runtime.channel !== receipt.channel) errors.push(`channel ${runtime.channel} != ${receipt.channel}`);\n if (!runtime.code?.verified) errors.push('code identity is not verified');\n if (runtime.code?.fingerprint !== receipt.code_fingerprint) errors.push(`code fingerprint ${runtime.code?.fingerprint || 'missing'} != ${receipt.code_fingerprint}`);\n if (runtime.profile?.id !== receipt.profile_id) errors.push(`profile ${runtime.profile?.id || 'missing'} != ${receipt.profile_id}`);\n if (runtime.profile?.environment !== receipt.environment) errors.push(`environment ${runtime.profile?.environment || 'missing'} != ${receipt.environment}`);\n if (runtime.profile?.fingerprint !== receipt.profile_fingerprint) errors.push(`profile fingerprint ${runtime.profile?.fingerprint || 'missing'} != ${receipt.profile_fingerprint}`);\n if (runtime.schema?.profile_id !== receipt.profile_id) errors.push(`database profile ${runtime.schema?.profile_id || 'missing'} != ${receipt.profile_id}`);\n if (runtime.schema?.profile_fingerprint !== receipt.profile_fingerprint) errors.push(`database fingerprint ${runtime.schema?.profile_fingerprint || 'missing'} != ${receipt.profile_fingerprint}`);\n if (resolve(runtime.database?.path || '') !== resolve(receipt.database_path)) errors.push(`database ${runtime.database?.path || 'missing'} != ${receipt.database_path}`);\n if (runtime.service?.instance_id !== receipt.instance_id) errors.push(`instance ${runtime.service?.instance_id || 'missing'} != ${receipt.instance_id}`);\n if (runtime.service?.launcher_pid !== receipt.pid) errors.push(`launcher pid ${runtime.service?.launcher_pid || 'missing'} != ${receipt.pid}`);\n if (runtime.service?.mode !== 'managed') errors.push(`service mode ${runtime.service?.mode || 'missing'} != managed`);\n return errors;\n}\n\nfunction desiredReceiptErrors(channel, doctor, receipt) {\n const errors = [];\n if (receipt.channel !== channel) errors.push(`receipt channel ${receipt.channel} != ${channel}`);\n if (receipt.code_fingerprint !== doctor.runtime?.code_fingerprint) errors.push(`receipt code fingerprint ${receipt.code_fingerprint} != current ${doctor.runtime?.code_fingerprint || 'missing'}`);\n if (receipt.code_origin !== doctor.runtime?.code_origin) errors.push(`receipt code origin ${receipt.code_origin} != current ${doctor.runtime?.code_origin || 'missing'}`);\n if (receipt.profile_id !== doctor.profile.profile_id) errors.push(`receipt profile ${receipt.profile_id} != ${doctor.profile.profile_id}`);\n if (receipt.environment !== doctor.profile.environment) errors.push(`receipt environment ${receipt.environment} != ${doctor.profile.environment}`);\n if (receipt.profile_fingerprint !== doctor.profile.profile_fingerprint) errors.push(`receipt profile fingerprint ${receipt.profile_fingerprint} != current ${doctor.profile.profile_fingerprint}`);\n if (resolve(receipt.database_path) !== resolve(doctor.profile.database_path)) errors.push('receipt database path does not match current profile');\n if (receipt.service_origin !== doctor.profile.service_origin) errors.push('receipt service origin does not match current profile');\n if (receipt.manifest_path !== doctor.profile.manifest_path) errors.push('receipt manifest path does not match current profile');\n return errors;\n}\n\nasync function fetchRuntime(origin) {\n const response = await fetch(`${origin}/api/runtime`, { signal: AbortSignal.timeout(1_000) });\n if (!response.ok) throw new Error(`HTTP ${response.status}`);\n const body = await response.json();\n if (!body?.runtime) throw new Error('Runtime response is missing runtime identity');\n return body.runtime;\n}\n\nasync function inspectHealth(receipt) {\n const errors = [];\n if (!processAlive(receipt.pid)) errors.push(`launcher pid ${receipt.pid} is not alive`);\n if (receipt.process_start && processStartToken(receipt.pid) !== receipt.process_start) errors.push(`launcher pid ${receipt.pid} was reused`);\n let runtime;\n try {\n runtime = await fetchRuntime(receipt.service_origin);\n errors.push(...managedServiceIdentityErrors(runtime, receipt));\n } catch (error) {\n errors.push(`runtime health failed: ${error instanceof Error ? error.message : String(error)}`);\n }\n return { errors, healthy: errors.length === 0, runtime };\n}\n\nasync function waitForHealthy(receipt, timeoutMs = 20_000) {\n const deadline = Date.now() + timeoutMs;\n let health = { errors: ['service did not respond'], healthy: false };\n while (Date.now() < deadline && processAlive(receipt.pid)) {\n health = await inspectHealth(receipt);\n if (health.healthy) return health;\n await new Promise(resolveDelay => setTimeout(resolveDelay, 250));\n }\n throw new Error(`Service failed readiness: ${health.errors.join('; ')}`);\n}\n\nfunction openBrowser(origin) {\n const command = platform() === 'darwin' ? 'open' : platform() === 'win32' ? 'cmd' : 'xdg-open';\n const args = platform() === 'win32' ? ['/c', 'start', '', origin] : [origin];\n const child = spawn(command, args, { detached: true, stdio: 'ignore' });\n child.unref();\n}\n\nfunction terminate(receipt, force = false) {\n if (!processAlive(receipt.pid)) return;\n const currentStart = processStartToken(receipt.pid);\n const command = processCommand(receipt.pid);\n const processMatches = receipt.process_start\n ? currentStart === receipt.process_start\n : Boolean(command?.includes('start') && command.includes(receipt.manifest_path));\n if (!processMatches && !force) {\n throw new Error(`Refusing to signal pid ${receipt.pid}: process identity no longer matches the service receipt; inspect manually or pass --force`);\n }\n const signalTarget = platform() === 'win32' ? receipt.pid : -receipt.pid;\n try { process.kill(signalTarget, 'SIGTERM'); } catch (error) { if (error?.code !== 'ESRCH') throw error; }\n}\n\nasync function startManaged(channel, selector, launcher, args) {\n const { doctor, status } = profileDoctor(launcher, selector);\n const runtimeIdentity = runtimeDoctor(launcher);\n if (status !== 0 || !doctor.ok || !doctor.runtime?.code_verified) {\n const failures = (doctor.checks || []).filter(check => check.status === 'fail').map(check => `${check.id}: ${check.message}`);\n throw new Error(`Profile doctor must pass before service start: ${failures.join('; ') || 'unverified runtime'}`);\n }\n if (runtimeIdentity.fingerprint !== doctor.runtime.code_fingerprint || runtimeIdentity.channel !== channel) {\n throw new Error('Runtime doctor identity changed while resolving the service profile');\n }\n const paths = statePaths(channel, doctor.profile);\n const release = acquireManagerLock(paths.lock);\n try {\n const existing = readReceipt(paths.receipt);\n if (existing) {\n const health = await inspectHealth(existing);\n const desiredErrors = desiredReceiptErrors(channel, doctor, existing);\n if (health.healthy && desiredErrors.length === 0) {\n if (args.includes('--open')) openBrowser(existing.service_origin);\n return { already_running: true, healthy: true, receipt: existing, runtime: health.runtime, state_path: paths.receipt };\n }\n if (processAlive(existing.pid)) throw new Error(`Managed service pid ${existing.pid} exists but is stale or unhealthy: ${[...desiredErrors, ...health.errors].join('; ')}`);\n rmSync(paths.receipt, { force: true });\n }\n mkdirSync(paths.directory, { recursive: true, mode: 0o700 });\n const logFd = openSync(paths.log, 'a', 0o600);\n const instanceId = randomUUID();\n const startArgs = ['start', '--profile', doctor.profile.manifest_path, '--json'];\n const child = spawn(launcher[0], [...launcher.slice(1), ...startArgs], {\n cwd: root,\n detached: true,\n env: { ...process.env, LINEAGE_SERVICE_INSTANCE_ID: instanceId, LINEAGE_SERVICE_MODE: 'managed' },\n stdio: ['ignore', logFd, logFd],\n });\n closeSync(logFd);\n child.unref();\n const receipt = {\n channel,\n code_fingerprint: doctor.runtime.code_fingerprint,\n code_origin: doctor.runtime.code_origin,\n code_root: runtimeIdentity.root,\n database_path: doctor.profile.database_path,\n environment: doctor.profile.environment,\n instance_id: instanceId,\n launcher,\n log_path: paths.log,\n manifest_path: doctor.profile.manifest_path,\n pid: child.pid,\n process_start: processStartToken(child.pid),\n profile_fingerprint: doctor.profile.profile_fingerprint,\n profile_id: doctor.profile.profile_id,\n schema_version: receiptSchema,\n service_origin: doctor.profile.service_origin,\n started_at: new Date().toISOString(),\n };\n writeReceipt(paths.receipt, receipt);\n try {\n const health = await waitForHealthy(receipt, Number(readOption(args, '--timeout-ms') || 20_000));\n if (args.includes('--open')) openBrowser(receipt.service_origin);\n return { healthy: true, receipt, runtime: health.runtime, state_path: paths.receipt };\n } catch (error) {\n terminate(receipt, true);\n throw error;\n }\n } finally {\n release();\n }\n}\n\nasync function statusManaged(channel, selector, launcher) {\n const { doctor, status } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const receipt = readReceipt(paths.receipt);\n if (!receipt) throw new Error(`No managed service receipt exists for ${channel}/${doctor.profile.profile_id}`);\n const health = await inspectHealth(receipt);\n const doctorFailures = status === 0 && doctor.ok\n ? []\n : (doctor.checks || []).filter(check => check.status === 'fail').map(check => `current doctor ${check.id}: ${check.message}`);\n const errors = [...doctorFailures, ...desiredReceiptErrors(channel, doctor, receipt), ...health.errors];\n if (errors.length > 0) throw new Error(`Managed service is not healthy: ${errors.join('; ')}`);\n return { healthy: true, receipt, runtime: health.runtime, state_path: paths.receipt };\n}\n\nasync function stopManaged(channel, selector, launcher, force) {\n const { doctor } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const release = acquireManagerLock(paths.lock);\n try {\n const receipt = readReceipt(paths.receipt);\n if (!receipt) return { already_stopped: true, profile_id: doctor.profile.profile_id };\n if (receipt.manifest_path !== doctor.profile.manifest_path || receipt.profile_id !== doctor.profile.profile_id) {\n throw new Error('Service receipt identity does not match the requested profile');\n }\n terminate(receipt, force);\n const deadline = Date.now() + 5_000;\n while (processAlive(receipt.pid) && Date.now() < deadline) await new Promise(resolveDelay => setTimeout(resolveDelay, 100));\n if (processAlive(receipt.pid) && force) {\n const signalTarget = platform() === 'win32' ? receipt.pid : -receipt.pid;\n try { process.kill(signalTarget, 'SIGKILL'); } catch { /* already exited */ }\n }\n if (processAlive(receipt.pid)) throw new Error(`Service pid ${receipt.pid} did not stop`);\n rmSync(paths.receipt, { force: true });\n return { profile_id: receipt.profile_id, stopped: true };\n } finally {\n release();\n }\n}\n\nfunction logsManaged(channel, selector, launcher, lines) {\n const { doctor } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const receipt = readReceipt(paths.receipt);\n const logPath = receipt?.log_path || paths.log;\n if (!existsSync(logPath)) throw new Error(`No managed service log exists: ${logPath}`);\n return readFileSync(logPath, 'utf8').split('\\n').slice(-lines).join('\\n');\n}\n\nfunction usage() {\n return `Usage:\n lineage-service start --channel stable|preview|dev --profile <id-or-manifest> [--open] [--json]\n lineage-service status --channel stable|preview|dev --profile <id-or-manifest> [--json]\n lineage-service stop --channel stable|preview|dev --profile <id-or-manifest> [--force] [--json]\n lineage-service logs --channel stable|preview|dev --profile <id-or-manifest> [--lines 100]\n\nStart writes a profile-scoped receipt, waits for /api/runtime to match the exact\ncode/profile/database/service instance, and only then opens a browser. Status is\nnonzero for a stale PID, failed health request, or any identity mismatch.`;\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n if (args.length === 0 || args.includes('--help') || args.includes('-h')) {\n console.log(usage());\n return;\n }\n const command = args[0];\n const channel = readOption(args, '--channel');\n const selector = readOption(args, '--profile');\n if (!['stable', 'preview', 'dev'].includes(channel)) throw new Error('--channel must be stable, preview, or dev');\n if (!selector) throw new Error('--profile is required; managed services never use legacy-unbound data');\n assertServiceManagerOrigin(channel);\n const launcher = launcherFor(channel, args);\n let result;\n if (command === 'start') result = await startManaged(channel, selector, launcher, args);\n else if (command === 'status') result = await statusManaged(channel, selector, launcher);\n else if (command === 'stop') result = await stopManaged(channel, selector, launcher, args.includes('--force'));\n else if (command === 'logs') {\n const output = logsManaged(channel, selector, launcher, Number(readOption(args, '--lines') || 100));\n console.log(output);\n return;\n } else throw new Error(`Unknown managed-service command: ${command}`);\n if (args.includes('--json')) console.log(JSON.stringify(result, null, 2));\n else if (command === 'status' || command === 'start') console.log(`Lineage ${channel}/${result.receipt.profile_id} healthy at ${result.receipt.service_origin}`);\n else console.log(`Lineage ${channel}/${result.profile_id} stopped`);\n}\n\nconst invokedAs = process.argv[1] ? basename(process.argv[1]) : '';\nif (process.argv[1] && (\n resolve(process.argv[1]) === fileURLToPath(import.meta.url)\n || ['lineage-service', 'lineage-stable-service', 'lineage-preview-service', 'managed-service.js', 'managed-service.mjs'].includes(invokedAs)\n)) {\n main().catch(error => {\n const message = error instanceof Error ? error.message : String(error);\n if (process.argv.includes('--json')) console.error(JSON.stringify({ error: message, ok: false }, null, 2));\n else console.error(`managed-service: ${message}`);\n process.exitCode = 1;\n });\n}\n"],
5
- "mappings": ";;;AAEA,SAAS,YAAY,kBAAkB;AACvC,SAAS,OAAO,iBAAiB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS,gBAAgB;AAClC,SAAS,UAAU,SAAS,MAAM,eAAe;AACjD,SAAS,qBAAqB;AAE9B,IAAM,kB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 'node:child_process';\nimport {\n closeSync,\n existsSync,\n mkdirSync,\n openSync,\n readFileSync,\n readdirSync,\n readlinkSync,\n realpathSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from 'node:fs';\nimport { homedir, platform } from 'node:os';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst scriptDirectory = dirname(fileURLToPath(import.meta.url));\nconst root = [resolve(scriptDirectory, '../..'), resolve(scriptDirectory, '..')].find(candidate => {\n try {\n const packageInfo = JSON.parse(readFileSync(join(candidate, 'package.json'), 'utf8'));\n return packageInfo.name === '@mean-weasel/lineage';\n } catch {\n return false;\n }\n});\nif (!root) throw new Error('Unable to locate the Lineage package root for managed service control');\nconst receiptSchema = 'lineage.managed_service.v1';\n\nfunction packageTreeSha256(packageRoot) {\n const hash = createHash('sha256');\n const visit = (directory, relativeDirectory = '') => {\n for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {\n const relativePath = relativeDirectory ? join(relativeDirectory, entry.name) : entry.name;\n const path = join(directory, entry.name);\n hash.update(relativePath.replaceAll('\\\\', '/'));\n hash.update('\\0');\n if (entry.isDirectory()) {\n hash.update('directory\\0');\n visit(path, relativePath);\n } else if (entry.isSymbolicLink()) {\n hash.update('symlink\\0');\n hash.update(readlinkSync(path));\n } else if (entry.isFile()) {\n hash.update('file\\0');\n hash.update(readFileSync(path));\n } else {\n hash.update('other\\0');\n }\n hash.update('\\0');\n }\n };\n visit(packageRoot);\n return hash.digest('hex');\n}\n\nfunction assertServiceManagerOrigin(channel) {\n const checkoutController = resolve(scriptDirectory) === resolve(root, 'scripts');\n if (channel === 'dev') {\n if (!checkoutController) throw new Error('Dev service control is checkout-only; run node scripts/managed-service.mjs from the intended worktree');\n return;\n }\n if (checkoutController) throw new Error(`${channel} service control requires the matching attested packaged manager`);\n const receiptPath = process.env.LINEAGE_RUNTIME_RECEIPT;\n if (!receiptPath || !existsSync(receiptPath)) throw new Error(`${channel} service manager is missing its runtime install receipt`);\n const receipt = JSON.parse(readFileSync(receiptPath, 'utf8'));\n if (receipt.channel !== channel || process.env.LINEAGE_RELEASE_CHANNEL !== channel) {\n throw new Error(`${channel} service manager receipt channel does not match the requested channel`);\n }\n if (!receipt.package_root || realpathSync(receipt.package_root) !== realpathSync(root)) {\n throw new Error(`${channel} service manager receipt package root ${receipt.package_root || '(missing)'} does not match controller root ${root}`);\n }\n if (packageTreeSha256(root) !== receipt.package_tree_sha256) throw new Error(`${channel} service manager package tree does not match its install receipt`);\n}\n\nfunction readOption(args, name) {\n const inline = args.find(arg => arg.startsWith(`${name}=`));\n if (inline) return inline.slice(name.length + 1);\n const index = args.indexOf(name);\n return index >= 0 ? args[index + 1] : undefined;\n}\n\nfunction serviceRoot() {\n if (process.env.LINEAGE_SERVICE_ROOT) return resolve(process.env.LINEAGE_SERVICE_ROOT);\n if (platform() === 'darwin') return join(homedir(), 'Library', 'Application Support', 'Lineage', 'services');\n if (platform() === 'win32') return join(process.env.LOCALAPPDATA || join(homedir(), 'AppData', 'Local'), 'Lineage', 'services');\n return join(process.env.XDG_STATE_HOME || join(homedir(), '.local', 'state'), 'lineage', 'services');\n}\n\nfunction defaultLauncher(channel) {\n if (channel === 'dev') return [process.execPath, '--import', 'tsx', join(root, 'src', 'cli', 'lineage-dev.ts')];\n const envName = channel === 'stable' ? 'LINEAGE_STABLE_BIN' : 'LINEAGE_PREVIEW_BIN';\n const explicit = process.env[envName] || process.env.LINEAGE_CHANNEL_LAUNCHER;\n if (explicit) return [explicit];\n const receiptPath = process.env.LINEAGE_RUNTIME_RECEIPT;\n if (receiptPath) {\n if (!existsSync(receiptPath)) throw new Error(`${channel} service manager runtime receipt does not exist: ${receiptPath}`);\n const resolvedReceipt = realpathSync(receiptPath);\n const runtimeRoot = dirname(dirname(dirname(dirname(resolvedReceipt))));\n const pointerPath = join(runtimeRoot, 'channels', `${channel}.json`);\n if (!existsSync(pointerPath)) throw new Error(`${channel} service manager could not find its receipt-bound channel pointer: ${pointerPath}`);\n const pointer = JSON.parse(readFileSync(pointerPath, 'utf8'));\n if (pointer.channel !== channel) throw new Error(`${channel} service manager channel pointer reports ${pointer.channel || '(missing)'}`);\n if (!pointer.receipt_path || !existsSync(pointer.receipt_path) || realpathSync(pointer.receipt_path) !== resolvedReceipt) {\n throw new Error(`${channel} service manager channel pointer is not bound to its runtime receipt`);\n }\n if (!pointer.shim || !existsSync(pointer.shim)) throw new Error(`${channel} service manager channel pointer launcher is missing: ${pointer.shim || '(missing)'}`);\n return [realpathSync(pointer.shim)];\n }\n const runtimeRoot = process.env.LINEAGE_RUNTIME_ROOT\n || (platform() === 'darwin'\n ? join(homedir(), 'Library', 'Application Support', 'Lineage', 'runtimes')\n : join(homedir(), '.local', 'share', 'lineage', 'runtimes'));\n return [join(runtimeRoot, 'bin', channel === 'stable' ? 'lineage-stable' : 'lineage-preview')];\n}\n\nfunction launcherFor(channel, args) {\n const explicit = readOption(args, '--launcher');\n return explicit ? [resolve(explicit)] : defaultLauncher(channel);\n}\n\nfunction invoke(launcher, args, options = {}) {\n return spawnSync(launcher[0], [...launcher.slice(1), ...args], {\n cwd: root,\n encoding: 'utf8',\n ...options,\n });\n}\n\nfunction invocationFailure(result) {\n const stderr = typeof result.stderr === 'string' ? result.stderr.trim() : '';\n const stdout = typeof result.stdout === 'string' ? result.stdout.trim() : '';\n const spawnError = result.error instanceof Error ? result.error.message : result.error ? String(result.error) : '';\n return stderr || stdout || spawnError || `process exited with status ${result.status ?? 'unknown'}`;\n}\n\nfunction shellDisplay(parts) {\n return parts.map(part => /^[A-Za-z0-9_./:@=-]+$/.test(part) ? part : JSON.stringify(part)).join(' ');\n}\n\nfunction profileDoctor(launcher, selector) {\n const result = invoke(launcher, ['profile', 'doctor', '--profile', selector, '--json']);\n let doctor;\n try {\n doctor = JSON.parse(result.stdout || '{}');\n } catch {\n throw new Error(`Profile doctor did not return JSON: ${invocationFailure(result)}`);\n }\n if (!doctor.profile) {\n const detail = doctor.error\n || (doctor.checks || []).filter(check => check.status === 'fail').map(check => check.message).join('; ')\n || invocationFailure(result)\n || 'profile manifest was not found or could not be read';\n const doctorCommand = shellDisplay([...launcher, 'profile', 'doctor', '--profile', selector, '--json']);\n const initCommand = shellDisplay([...launcher, 'profile', 'init', '--profile', selector, '--confirm-write', '--json']);\n throw new Error(`Profile ${selector} could not be resolved: ${detail}. Next: run \\`${doctorCommand}\\`. If this is a new profile, run \\`${initCommand}\\` instead.`);\n }\n return { doctor, status: result.status ?? 1 };\n}\n\nfunction runtimeDoctor(launcher) {\n const result = invoke(launcher, ['runtime', 'doctor', '--json']);\n let runtime;\n try {\n runtime = JSON.parse(result.stdout || '{}');\n } catch {\n throw new Error(`Runtime doctor did not return JSON: ${invocationFailure(result)}`);\n }\n if (result.status !== 0 || !runtime.verified) throw new Error(`Runtime doctor failed: ${invocationFailure(result) || JSON.stringify(runtime)}`);\n return runtime;\n}\n\nfunction statePaths(channel, profile) {\n const digest = createHash('sha256').update(profile.manifest_path).digest('hex').slice(0, 12);\n const key = `${channel}--${profile.profile_id}--${digest}`;\n const directory = join(serviceRoot(), key);\n return {\n directory,\n lock: `${directory}.manager.lock`,\n log: join(directory, 'service.log'),\n receipt: join(directory, 'service.json'),\n };\n}\n\nfunction processAlive(pid) {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return error?.code !== 'ESRCH';\n }\n}\n\nfunction processStartToken(pid) {\n if (platform() === 'win32') return undefined;\n const result = spawnSync('ps', ['-p', String(pid), '-o', 'lstart='], { encoding: 'utf8' });\n return result.status === 0 ? result.stdout.trim() || undefined : undefined;\n}\n\nfunction processCommand(pid) {\n if (platform() === 'win32') return undefined;\n const result = spawnSync('ps', ['-p', String(pid), '-o', 'command='], { encoding: 'utf8' });\n return result.status === 0 ? result.stdout.trim() || undefined : undefined;\n}\n\nfunction acquireManagerLock(path) {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n for (let attempt = 0; attempt < 3; attempt += 1) {\n try {\n mkdirSync(path, { mode: 0o700 });\n writeFileSync(join(path, 'owner.json'), `${JSON.stringify({ acquired_at: new Date().toISOString(), pid: process.pid })}\\n`, { mode: 0o600 });\n return () => rmSync(path, { force: true, recursive: true });\n } catch (error) {\n if (error?.code !== 'EEXIST') throw error;\n try {\n const owner = JSON.parse(readFileSync(join(path, 'owner.json'), 'utf8'));\n if (Number.isSafeInteger(owner.pid) && processAlive(owner.pid)) {\n throw new Error(`Another service manager operation is active (pid ${owner.pid})`, { cause: error });\n }\n } catch (ownerError) {\n if (ownerError instanceof Error && ownerError.message.startsWith('Another service manager')) throw ownerError;\n }\n rmSync(path, { force: true, recursive: true });\n }\n }\n throw new Error(`Could not acquire service manager lock ${path}`);\n}\n\nfunction readReceipt(path) {\n if (!existsSync(path)) return undefined;\n const receipt = JSON.parse(readFileSync(path, 'utf8'));\n if (\n receipt.schema_version !== receiptSchema\n || !Number.isSafeInteger(receipt.pid)\n || typeof receipt.instance_id !== 'string'\n || typeof receipt.profile_fingerprint !== 'string'\n || !Array.isArray(receipt.launcher)\n ) throw new Error(`Managed service receipt is invalid: ${path}`);\n return receipt;\n}\n\nfunction writeReceipt(path, receipt) {\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n const temporary = `${path}.tmp-${process.pid}-${randomUUID()}`;\n writeFileSync(temporary, `${JSON.stringify(receipt, null, 2)}\\n`, { encoding: 'utf8', flag: 'wx', mode: 0o600 });\n renameSync(temporary, path);\n}\n\nexport function managedServiceIdentityErrors(runtime, receipt) {\n const errors = [];\n if (runtime.channel !== receipt.channel) errors.push(`channel ${runtime.channel} != ${receipt.channel}`);\n if (!runtime.code?.verified) errors.push('code identity is not verified');\n if (runtime.code?.fingerprint !== receipt.code_fingerprint) errors.push(`code fingerprint ${runtime.code?.fingerprint || 'missing'} != ${receipt.code_fingerprint}`);\n if (runtime.profile?.id !== receipt.profile_id) errors.push(`profile ${runtime.profile?.id || 'missing'} != ${receipt.profile_id}`);\n if (runtime.profile?.environment !== receipt.environment) errors.push(`environment ${runtime.profile?.environment || 'missing'} != ${receipt.environment}`);\n if (runtime.profile?.fingerprint !== receipt.profile_fingerprint) errors.push(`profile fingerprint ${runtime.profile?.fingerprint || 'missing'} != ${receipt.profile_fingerprint}`);\n if (runtime.schema?.profile_id !== receipt.profile_id) errors.push(`database profile ${runtime.schema?.profile_id || 'missing'} != ${receipt.profile_id}`);\n if (runtime.schema?.profile_fingerprint !== receipt.profile_fingerprint) errors.push(`database fingerprint ${runtime.schema?.profile_fingerprint || 'missing'} != ${receipt.profile_fingerprint}`);\n if (resolve(runtime.database?.path || '') !== resolve(receipt.database_path)) errors.push(`database ${runtime.database?.path || 'missing'} != ${receipt.database_path}`);\n if (runtime.service?.instance_id !== receipt.instance_id) errors.push(`instance ${runtime.service?.instance_id || 'missing'} != ${receipt.instance_id}`);\n if (runtime.service?.launcher_pid !== receipt.pid) errors.push(`launcher pid ${runtime.service?.launcher_pid || 'missing'} != ${receipt.pid}`);\n if (runtime.service?.mode !== 'managed') errors.push(`service mode ${runtime.service?.mode || 'missing'} != managed`);\n return errors;\n}\n\nfunction desiredReceiptErrors(channel, doctor, receipt) {\n const errors = [];\n if (receipt.channel !== channel) errors.push(`receipt channel ${receipt.channel} != ${channel}`);\n if (receipt.code_fingerprint !== doctor.runtime?.code_fingerprint) errors.push(`receipt code fingerprint ${receipt.code_fingerprint} != current ${doctor.runtime?.code_fingerprint || 'missing'}`);\n if (receipt.code_origin !== doctor.runtime?.code_origin) errors.push(`receipt code origin ${receipt.code_origin} != current ${doctor.runtime?.code_origin || 'missing'}`);\n if (receipt.profile_id !== doctor.profile.profile_id) errors.push(`receipt profile ${receipt.profile_id} != ${doctor.profile.profile_id}`);\n if (receipt.environment !== doctor.profile.environment) errors.push(`receipt environment ${receipt.environment} != ${doctor.profile.environment}`);\n if (receipt.profile_fingerprint !== doctor.profile.profile_fingerprint) errors.push(`receipt profile fingerprint ${receipt.profile_fingerprint} != current ${doctor.profile.profile_fingerprint}`);\n if (resolve(receipt.database_path) !== resolve(doctor.profile.database_path)) errors.push('receipt database path does not match current profile');\n if (receipt.service_origin !== doctor.profile.service_origin) errors.push('receipt service origin does not match current profile');\n if (receipt.manifest_path !== doctor.profile.manifest_path) errors.push('receipt manifest path does not match current profile');\n return errors;\n}\n\nasync function fetchRuntime(origin) {\n const response = await fetch(`${origin}/api/runtime`, { signal: AbortSignal.timeout(1_000) });\n if (!response.ok) throw new Error(`HTTP ${response.status}`);\n const body = await response.json();\n if (!body?.runtime) throw new Error('Runtime response is missing runtime identity');\n return body.runtime;\n}\n\nasync function inspectHealth(receipt) {\n const errors = [];\n if (!processAlive(receipt.pid)) errors.push(`launcher pid ${receipt.pid} is not alive`);\n if (receipt.process_start && processStartToken(receipt.pid) !== receipt.process_start) errors.push(`launcher pid ${receipt.pid} was reused`);\n let runtime;\n try {\n runtime = await fetchRuntime(receipt.service_origin);\n errors.push(...managedServiceIdentityErrors(runtime, receipt));\n } catch (error) {\n errors.push(`runtime health failed: ${error instanceof Error ? error.message : String(error)}`);\n }\n return { errors, healthy: errors.length === 0, runtime };\n}\n\nasync function waitForHealthy(receipt, timeoutMs = 20_000) {\n const deadline = Date.now() + timeoutMs;\n let health = { errors: ['service did not respond'], healthy: false };\n while (Date.now() < deadline && processAlive(receipt.pid)) {\n health = await inspectHealth(receipt);\n if (health.healthy) return health;\n await new Promise(resolveDelay => setTimeout(resolveDelay, 250));\n }\n throw new Error(`Service failed readiness: ${health.errors.join('; ')}`);\n}\n\nfunction openBrowser(origin) {\n const command = platform() === 'darwin' ? 'open' : platform() === 'win32' ? 'cmd' : 'xdg-open';\n const args = platform() === 'win32' ? ['/c', 'start', '', origin] : [origin];\n const child = spawn(command, args, { detached: true, stdio: 'ignore' });\n child.unref();\n}\n\nfunction terminate(receipt, force = false) {\n if (!processAlive(receipt.pid)) return;\n const currentStart = processStartToken(receipt.pid);\n const command = processCommand(receipt.pid);\n const processMatches = receipt.process_start\n ? currentStart === receipt.process_start\n : Boolean(command?.includes('start') && command.includes(receipt.manifest_path));\n if (!processMatches && !force) {\n throw new Error(`Refusing to signal pid ${receipt.pid}: process identity no longer matches the service receipt; inspect manually or pass --force`);\n }\n const signalTarget = platform() === 'win32' ? receipt.pid : -receipt.pid;\n try { process.kill(signalTarget, 'SIGTERM'); } catch (error) { if (error?.code !== 'ESRCH') throw error; }\n}\n\nasync function startManaged(channel, selector, launcher, args) {\n const { doctor, status } = profileDoctor(launcher, selector);\n const runtimeIdentity = runtimeDoctor(launcher);\n if (status !== 0 || !doctor.ok || !doctor.runtime?.code_verified) {\n const failures = (doctor.checks || []).filter(check => check.status === 'fail').map(check => `${check.id}: ${check.message}`);\n throw new Error(`Profile doctor must pass before service start: ${failures.join('; ') || 'unverified runtime'}`);\n }\n if (runtimeIdentity.fingerprint !== doctor.runtime.code_fingerprint || runtimeIdentity.channel !== channel) {\n throw new Error('Runtime doctor identity changed while resolving the service profile');\n }\n const paths = statePaths(channel, doctor.profile);\n const release = acquireManagerLock(paths.lock);\n try {\n const existing = readReceipt(paths.receipt);\n if (existing) {\n const health = await inspectHealth(existing);\n const desiredErrors = desiredReceiptErrors(channel, doctor, existing);\n if (health.healthy && desiredErrors.length === 0) {\n if (args.includes('--open')) openBrowser(existing.service_origin);\n return { already_running: true, healthy: true, receipt: existing, runtime: health.runtime, state_path: paths.receipt };\n }\n if (processAlive(existing.pid)) throw new Error(`Managed service pid ${existing.pid} exists but is stale or unhealthy: ${[...desiredErrors, ...health.errors].join('; ')}`);\n rmSync(paths.receipt, { force: true });\n }\n mkdirSync(paths.directory, { recursive: true, mode: 0o700 });\n const logFd = openSync(paths.log, 'a', 0o600);\n const instanceId = randomUUID();\n const startArgs = ['start', '--profile', doctor.profile.manifest_path, '--json'];\n const child = spawn(launcher[0], [...launcher.slice(1), ...startArgs], {\n cwd: root,\n detached: true,\n env: { ...process.env, LINEAGE_SERVICE_INSTANCE_ID: instanceId, LINEAGE_SERVICE_MODE: 'managed' },\n stdio: ['ignore', logFd, logFd],\n });\n closeSync(logFd);\n child.unref();\n const receipt = {\n channel,\n code_fingerprint: doctor.runtime.code_fingerprint,\n code_origin: doctor.runtime.code_origin,\n code_root: runtimeIdentity.root,\n database_path: doctor.profile.database_path,\n environment: doctor.profile.environment,\n instance_id: instanceId,\n launcher,\n log_path: paths.log,\n manifest_path: doctor.profile.manifest_path,\n pid: child.pid,\n process_start: processStartToken(child.pid),\n profile_fingerprint: doctor.profile.profile_fingerprint,\n profile_id: doctor.profile.profile_id,\n schema_version: receiptSchema,\n service_origin: doctor.profile.service_origin,\n started_at: new Date().toISOString(),\n };\n writeReceipt(paths.receipt, receipt);\n try {\n const health = await waitForHealthy(receipt, Number(readOption(args, '--timeout-ms') || 20_000));\n if (args.includes('--open')) openBrowser(receipt.service_origin);\n return { healthy: true, receipt, runtime: health.runtime, state_path: paths.receipt };\n } catch (error) {\n terminate(receipt, true);\n throw error;\n }\n } finally {\n release();\n }\n}\n\nasync function statusManaged(channel, selector, launcher) {\n const { doctor, status } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const receipt = readReceipt(paths.receipt);\n if (!receipt) throw new Error(`No managed service receipt exists for ${channel}/${doctor.profile.profile_id}`);\n const health = await inspectHealth(receipt);\n const doctorFailures = status === 0 && doctor.ok\n ? []\n : (doctor.checks || []).filter(check => check.status === 'fail').map(check => `current doctor ${check.id}: ${check.message}`);\n const errors = [...doctorFailures, ...desiredReceiptErrors(channel, doctor, receipt), ...health.errors];\n if (errors.length > 0) throw new Error(`Managed service is not healthy: ${errors.join('; ')}`);\n return { healthy: true, receipt, runtime: health.runtime, state_path: paths.receipt };\n}\n\nasync function stopManaged(channel, selector, launcher, force) {\n const { doctor } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const release = acquireManagerLock(paths.lock);\n try {\n const receipt = readReceipt(paths.receipt);\n if (!receipt) return { already_stopped: true, profile_id: doctor.profile.profile_id };\n if (receipt.manifest_path !== doctor.profile.manifest_path || receipt.profile_id !== doctor.profile.profile_id) {\n throw new Error('Service receipt identity does not match the requested profile');\n }\n terminate(receipt, force);\n const deadline = Date.now() + 5_000;\n while (processAlive(receipt.pid) && Date.now() < deadline) await new Promise(resolveDelay => setTimeout(resolveDelay, 100));\n if (processAlive(receipt.pid) && force) {\n const signalTarget = platform() === 'win32' ? receipt.pid : -receipt.pid;\n try { process.kill(signalTarget, 'SIGKILL'); } catch { /* already exited */ }\n }\n if (processAlive(receipt.pid)) throw new Error(`Service pid ${receipt.pid} did not stop`);\n rmSync(paths.receipt, { force: true });\n return { profile_id: receipt.profile_id, stopped: true };\n } finally {\n release();\n }\n}\n\nfunction logsManaged(channel, selector, launcher, lines) {\n const { doctor } = profileDoctor(launcher, selector);\n const paths = statePaths(channel, doctor.profile);\n const receipt = readReceipt(paths.receipt);\n const logPath = receipt?.log_path || paths.log;\n if (!existsSync(logPath)) throw new Error(`No managed service log exists: ${logPath}`);\n return readFileSync(logPath, 'utf8').split('\\n').slice(-lines).join('\\n');\n}\n\nfunction usage() {\n return `Usage:\n lineage-service start --channel stable|preview|dev --profile <id-or-manifest> [--open] [--json]\n lineage-service status --channel stable|preview|dev --profile <id-or-manifest> [--json]\n lineage-service stop --channel stable|preview|dev --profile <id-or-manifest> [--force] [--json]\n lineage-service logs --channel stable|preview|dev --profile <id-or-manifest> [--lines 100]\n\nStart writes a profile-scoped receipt, waits for /api/runtime to match the exact\ncode/profile/database/service instance, and only then opens a browser. Status is\nnonzero for a stale PID, failed health request, or any identity mismatch.`;\n}\n\nasync function main() {\n const args = process.argv.slice(2);\n if (args.length === 0 || args.includes('--help') || args.includes('-h')) {\n console.log(usage());\n return;\n }\n const command = args[0];\n const channel = readOption(args, '--channel');\n const selector = readOption(args, '--profile');\n if (!['stable', 'preview', 'dev'].includes(channel)) throw new Error('--channel must be stable, preview, or dev');\n if (!selector) throw new Error('--profile is required; managed services never use legacy-unbound data');\n assertServiceManagerOrigin(channel);\n const launcher = launcherFor(channel, args);\n let result;\n if (command === 'start') result = await startManaged(channel, selector, launcher, args);\n else if (command === 'status') result = await statusManaged(channel, selector, launcher);\n else if (command === 'stop') result = await stopManaged(channel, selector, launcher, args.includes('--force'));\n else if (command === 'logs') {\n const output = logsManaged(channel, selector, launcher, Number(readOption(args, '--lines') || 100));\n console.log(output);\n return;\n } else throw new Error(`Unknown managed-service command: ${command}`);\n if (args.includes('--json')) console.log(JSON.stringify(result, null, 2));\n else if (command === 'status' || command === 'start') console.log(`Lineage ${channel}/${result.receipt.profile_id} healthy at ${result.receipt.service_origin}`);\n else console.log(`Lineage ${channel}/${result.profile_id} stopped`);\n}\n\nconst invokedAs = process.argv[1] ? basename(process.argv[1]) : '';\nif (process.argv[1] && (\n resolve(process.argv[1]) === fileURLToPath(import.meta.url)\n || ['lineage-service', 'lineage-stable-service', 'lineage-preview-service', 'managed-service.js', 'managed-service.mjs'].includes(invokedAs)\n)) {\n main().catch(error => {\n const message = error instanceof Error ? error.message : String(error);\n if (process.argv.includes('--json')) console.error(JSON.stringify({ error: message, ok: false }, null, 2));\n else console.error(`managed-service: ${message}`);\n process.exitCode = 1;\n });\n}\n"],
5
+ "mappings": ";;;AAEA,SAAS,YAAY,kBAAkB;AACvC,SAAS,OAAO,iBAAiB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS,gBAAgB;AAClC,SAAS,UAAU,SAAS,MAAM,eAAe;AACjD,SAAS,qBAAqB;AAE9B,IAAM,kBAAkB,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC9D,IAAM,OAAO,CAAC,QAAQ,iBAAiB,OAAO,GAAG,QAAQ,iBAAiB,IAAI,CAAC,EAAE,KAAK,eAAa;AACjG,MAAI;AACF,UAAM,cAAc,KAAK,MAAM,aAAa,KAAK,WAAW,cAAc,GAAG,MAAM,CAAC;AACpF,WAAO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ACF,MAAO,OAAM,IAAI,MAAM,oCAAoC,OAAO,EAAE;AACpE,MAAI,KAAK,SAAS,QAAQ,EAAG,SAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,WAC/D,YAAY,YAAY,YAAY,QAAS,SAAQ,IAAI,WAAW,OAAO,IAAI,OAAO,QAAQ,UAAU,eAAe,OAAO,QAAQ,cAAc,EAAE;AAAA,MAC1J,SAAQ,IAAI,WAAW,OAAO,IAAI,OAAO,UAAU,UAAU;AACpE;AAEA,IAAM,YAAY,QAAQ,KAAK,CAAC,IAAI,SAAS,QAAQ,KAAK,CAAC,CAAC,IAAI;AAChE,IAAI,QAAQ,KAAK,CAAC,MAChB,QAAQ,QAAQ,KAAK,CAAC,CAAC,MAAM,cAAc,YAAY,GAAG,KACvD,CAAC,mBAAmB,0BAA0B,2BAA2B,sBAAsB,qBAAqB,EAAE,SAAS,SAAS,IAC1I;AACD,OAAK,EAAE,MAAM,WAAS;AACpB,UAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,QAAI,QAAQ,KAAK,SAAS,QAAQ,EAAG,SAAQ,MAAM,KAAK,UAAU,EAAE,OAAO,SAAS,IAAI,MAAM,GAAG,MAAM,CAAC,CAAC;AAAA,QACpG,SAAQ,MAAM,oBAAoB,OAAO,EAAE;AAChD,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;",
6
+ "names": ["runtimeRoot"]
7
7
  }
@@ -1,9 +1,9 @@
1
1
  {
2
- "build_fingerprint": "87a10b563bd810b777c088e8ae7fd2b3ef4a0f4b655c85be7ca5bd8fed743743",
2
+ "build_fingerprint": "06b247a5facc91f5229fcc17b7ae8bb22a2d3e663f4fd1520bb50152254669fe",
3
3
  "package_name": "@mean-weasel/lineage",
4
- "package_version": "0.1.17",
4
+ "package_version": "0.1.18",
5
5
  "schema_version": "lineage.runtime_build.v1",
6
6
  "source_dirty": false,
7
- "source_fingerprint": "c678535d3cc4bf66e48e0609f32aecd75d0ec648494aa1ef84f8ec94f999c0bf",
8
- "source_git_sha": "399a50473ece3f18150e811d8e5ffdd06484fd5a"
7
+ "source_fingerprint": "f57dfbc56b806bf349bab7a5a4431c014e76cdb04321e610178a8b85707679b0",
8
+ "source_git_sha": "7b7a0ba3166359522a78bf918bf3e88e471bf933"
9
9
  }
@@ -13,4 +13,4 @@ import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t
13
13
  `),p=e=>e===`variation source`?`Copy source`:e===`agent brief`?`Copy prompt`:e===`link-child command`?`Copy link command`:`Copy command`,m=ch(i,o);async function h(e,t){try{await Im(e),r(`ok`,`Copied ${t}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}}async function _(){try{let n=await g(`/api/agent-claims`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentName:`Copied Lineage handoff`,channel:t?.channel,project:i,scopeType:`lineage_workspace`,targetId:m,targetTitle:t?`${t.title} lineage`:`Lineage workspace ${o}`,ttl:`20m`})});await Im(ph(n.claim_token,s,e,f)),r(`ok`,`Copied claim-aware handoff for ${n.claim.id}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}}return(0,Y.jsxs)(`section`,{className:`lineage-handoff-panel`,"data-testid":`lineage-handoff-panel`,children:[(0,Y.jsx)(`h3`,{children:`Agent handoff`}),(0,Y.jsxs)(`div`,{className:`lineage-handoff-base ${t&&!t.is_latest?`branch`:``}`,children:[(0,Y.jsx)(`span`,{children:t?`Agent will evolve`:`Choose a variation source`}),(0,Y.jsx)(`strong`,{children:l}),t&&(0,Y.jsx)(`small`,{children:[t.channel,t.status,t.review_state].filter(Boolean).join(` / `)}),t&&!t.is_latest&&(0,Y.jsx)(`p`,{children:`Branch from here: this asset is not a latest leaf.`})]}),u.map(e=>(0,Y.jsxs)(`div`,{className:`lineage-copy-row`,children:[(0,Y.jsx)(`code`,{children:e.text}),(0,Y.jsx)(`button`,{"aria-label":`Copy ${e.label}`,onClick:()=>void h(e.text,e.label),children:p(e.label)})]},e.label)),a.length>0&&(0,Y.jsxs)(`div`,{className:`lineage-brief-group`,children:[(0,Y.jsxs)(`div`,{className:`lineage-brief-head`,children:[(0,Y.jsx)(`h4`,{children:`Re-roll queue`}),(0,Y.jsx)(`button`,{"aria-label":`Copy re-roll queue handoff`,onClick:()=>void h(sh(c,a),`re-roll queue`),children:`Copy queue`})]}),(0,Y.jsx)(`p`,{children:`Use this for repair work. Import outputs with reroll import; do not link them as lineage children.`}),(0,Y.jsxs)(`div`,{className:`lineage-copy-row`,children:[(0,Y.jsx)(`code`,{children:c}),(0,Y.jsx)(`button`,{"aria-label":`Copy reroll list command`,onClick:()=>void h(c,`reroll list command`),children:`Copy command`})]}),a.map(e=>(0,Y.jsxs)(`div`,{className:`lineage-copy-row`,children:[(0,Y.jsxs)(`code`,{children:[e.asset_id,e.reroll_request?.notes?`: ${e.reroll_request.notes}`:``]}),(0,Y.jsx)(`button`,{"aria-label":`Copy re-roll target ${e.asset_id}`,onClick:()=>void h(e.asset_id,`re-roll target`),children:`Copy target`})]},e.asset_id))]}),d.length>0&&(0,Y.jsxs)(`div`,{className:`lineage-brief-group`,children:[(0,Y.jsxs)(`div`,{className:`lineage-brief-head`,children:[(0,Y.jsx)(`h4`,{children:`Generated brief`}),(0,Y.jsx)(`button`,{"aria-label":`Copy full generated brief`,onClick:()=>void h(f,`full brief`),children:`Copy all`})]}),(0,Y.jsx)(`p`,{children:`Use this bundle when asking an agent to continue from the chosen asset.`}),(0,Y.jsx)(`button`,{"aria-label":`Copy claim-aware handoff`,className:`lineage-claim-handoff-button`,onClick:()=>_(),children:`Copy claim handoff`}),(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{children:`Commands and prompt`}),d.map(e=>(0,Y.jsxs)(`div`,{className:`lineage-copy-row`,children:[(0,Y.jsx)(`code`,{children:e.text}),(0,Y.jsx)(`button`,{"aria-label":`Copy ${e.label}`,onClick:()=>void h(e.text,e.label),children:p(e.label)})]},e.label))]})]}),(0,Y.jsx)(`button`,{"aria-label":d.length>0?`Regenerate agent brief`:`Generate agent brief`,onClick:n,children:d.length>0?`Regenerate brief`:`Generate brief`})]})}function sh(e,t){return[e,`For each pending target, ask for or use a target-specific repair prompt.`,`Run reroll plan for one target at a time, generate one file under .asset-scratch, then run reroll import.`,`Do not use link-child for re-roll outputs.`,...t.map(e=>`Target ${e.asset_id}: ${e.title}${e.reroll_request?.notes?` (${e.reroll_request.notes})`:``}`)].join(`
14
14
  `)}function ch(e,t){return`${e}:lineage-workspace:${t}`}function lh(e){return`'${e.replace(/'/g,`'\\''`)}'`}function uh(e){let t=/\s--(db|profile)\s+('[^']*(?:'\\''[^']*)*'|"[^"]*"|\S+)/.exec(e);return t?` --${t[1]} ${t[2]}`:``}function dh(e){let t=/\s(?:next|inspect|link-child)\s/.exec(e);return t?e.slice(0,t.index):`npx @mean-weasel/lineage`}function fh(e){return e.includes(`--claim-token`)?e:/\s--json$/.test(e)?e.replace(/\s--json$/,` --claim-token "$LINEAGE_CLAIM_TOKEN" --json`):`${e} --claim-token "$LINEAGE_CLAIM_TOKEN"`}function ph(e,t,n,r){let i=n?.handoff?.link_child_command||n?.handoff?.next_command||t,a=uh(i),o=`${dh(i)} agent heartbeat --claim-token "$LINEAGE_CLAIM_TOKEN"${a} --json`;return[`export LINEAGE_CLAIM_TOKEN=${lh(e)}`,o,t,n?.handoff?.inspect_command,n?.handoff?.link_child_command?fh(n.handoff.link_child_command):void 0,r?`Agent brief:\n${r}`:void 0].filter(e=>!!e).join(`
15
15
 
16
- `)}function mh(e){let{activeNode:t,brief:n,childAssetId:r,clearNextVariation:i,closePanel:a,latestNodes:o,linkChild:s,markReview:c,noteDirty:l,onSelectedAsset:u,nextVariationLimit:d,onToast:f,project:p,refreshBrief:m,saveRationale:h,selectNextBase:g,selectedNode:_,selectedNodes:v,selectionFull:y,refreshLineage:b,replaceNextVariation:x,selectionNote:S,setActiveNodeId:C,setChildAssetId:w,setDetailNodeId:T,setSelected:E,setSelectionNote:D,sideOpen:O,snapshot:k}=e,A=t?ye({hasLocal:!!t.local_path,hasS3:!!t.s3_key}):null,j=v.filter(e=>!e.is_latest),M=k.nodes.filter(e=>e.reroll_request?.status===`pending`);return(0,Y.jsxs)(`aside`,{"aria-hidden":!O,className:`lineage-side ${O?``:`collapsed`}`,id:`lineage-selection-panel`,children:[(0,Y.jsxs)(`div`,{className:`lineage-side-head`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{children:`Next variation`}),(0,Y.jsx)(`p`,{className:`muted-copy`,children:`Choose what the agent will evolve next; double-click nodes for full details.`})]}),(0,Y.jsx)(`button`,{"aria-label":`Close lineage selection panel`,className:`icon-button`,onClick:a,type:`button`,children:`×`})]}),(0,Y.jsxs)(`section`,{className:`lineage-next-panel`,children:[(0,Y.jsxs)(`div`,{className:`lineage-panel-title-row`,children:[(0,Y.jsx)(`h3`,{children:`Using for next variation`}),(0,Y.jsxs)(`span`,{className:`lineage-count-pill ${y?`full`:``}`,children:[v.length,`/`,d]})]}),v.length>0&&(0,Y.jsx)(`div`,{className:`lineage-panel-action-row`,children:(0,Y.jsx)(`button`,{onClick:()=>void i(),type:`button`,children:`Clear all`})}),j.length>0&&(0,Y.jsxs)(`div`,{className:`lineage-selection-warning`,role:`status`,children:[j.length,` selected asset`,j.length===1?` is`:`s are`,` not latest. This is valid for branching, but clear or replace it if you meant to continue from the newest leaves.`]}),v.length>0?v.map(e=>(0,Y.jsxs)(`div`,{className:`lineage-candidate selected`,children:[(0,Y.jsxs)(`button`,{"aria-label":`Inspect asset used for next variation ${e.title}`,className:`lineage-candidate-main`,onClick:()=>{C(e.asset_id),u(e.asset_id)},children:[(0,Y.jsx)(`span`,{children:e.title}),(0,Y.jsx)(`code`,{children:e.asset_id}),(0,Y.jsx)(ah,{node:e})]}),!e.is_latest&&(0,Y.jsx)(`span`,{className:`lineage-candidate-warning`,children:`Not latest`}),(0,Y.jsxs)(`div`,{className:`lineage-candidate-actions`,children:[v.length>1&&(0,Y.jsx)(`button`,{className:`lineage-candidate-action secondary`,onClick:()=>x(e),children:`Use only this`}),(0,Y.jsx)(`button`,{className:`lineage-candidate-action remove`,onClick:()=>void i(e.asset_id),children:`Remove`})]})]},e.asset_id)):(0,Y.jsxs)(`p`,{className:`muted-copy`,children:[`Choose up to `,d,` assets to guide the next generation.`]}),v.length>1&&(0,Y.jsx)(`p`,{className:`muted-copy`,children:`The agent will use these as separate next-variation bases; imported outputs should link back to the matching selected parent.`})]}),(0,Y.jsx)(hh,{activeNode:t,onSelectedAsset:u,onToast:f,project:p,refreshLineage:b,setActiveNodeId:C,snapshot:k}),(0,Y.jsxs)(`section`,{className:`lineage-next-panel`,children:[(0,Y.jsxs)(`div`,{className:`lineage-panel-title-row`,children:[(0,Y.jsx)(`h3`,{children:`Re-roll queue`}),(0,Y.jsx)(`span`,{className:`lineage-count-pill`,children:M.length})]}),M.length>0?M.map(e=>(0,Y.jsx)(`div`,{className:`lineage-candidate ${e.asset_id===t?.asset_id?`active`:``}`,children:(0,Y.jsxs)(`button`,{"aria-label":`Inspect re-roll target ${e.title}`,className:`lineage-candidate-main`,onClick:()=>{C(e.asset_id),u(e.asset_id)},children:[(0,Y.jsx)(`span`,{children:e.title}),(0,Y.jsx)(`code`,{children:e.asset_id}),e.reroll_request?.notes&&(0,Y.jsx)(`small`,{children:e.reroll_request.notes})]})},e.asset_id)):(0,Y.jsx)(`p`,{className:`muted-copy`,children:`No pending re-roll targets.`})]}),(0,Y.jsxs)(`section`,{className:`lineage-next-panel`,children:[(0,Y.jsx)(`h3`,{children:`Latest candidates`}),o.length>0?o.map(e=>{let n=!e.user_selected&&y;return(0,Y.jsxs)(`div`,{className:`lineage-candidate ${e.asset_id===t?.asset_id?`active`:``} ${e.user_selected?`selected`:``}`,children:[(0,Y.jsxs)(`button`,{"aria-label":`Inspect ${e.title}`,className:`lineage-candidate-main`,onClick:()=>{C(e.asset_id),u(e.asset_id)},children:[(0,Y.jsx)(`span`,{children:e.title}),(0,Y.jsx)(`code`,{children:e.asset_id}),(0,Y.jsx)(ah,{node:e})]}),(0,Y.jsxs)(`div`,{className:`lineage-candidate-actions`,children:[(0,Y.jsx)(`button`,{"aria-label":e.user_selected?`Remove ${e.title} from next variation`:`Use ${e.title} for next variation`,className:`lineage-candidate-action ${e.user_selected?`remove`:``}`,disabled:n,onClick:()=>e.user_selected?void i(e.asset_id):g(e),children:e.user_selected?`Remove`:n?`Selection full`:`Use for next variation`}),!e.user_selected&&v.length>0&&(0,Y.jsx)(`button`,{className:`lineage-candidate-action secondary`,onClick:()=>x(e),children:`Replace selection`})]})]},e.asset_id)}):(0,Y.jsx)(`p`,{className:`muted-copy`,children:`No latest leaves yet.`})]}),(0,Y.jsx)(oh,{brief:n,nextBase:_,onRefreshBrief:()=>void m(),onToast:f,project:p,rerollTargets:M,rootAssetId:k.root_asset_id}),(0,Y.jsx)(`h3`,{children:`Inspecting`}),t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`strong`,{children:t.title}),(0,Y.jsx)(`code`,{children:t.asset_id}),(0,Y.jsxs)(`dl`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Storage`}),(0,Y.jsx)(`dd`,{children:A&&(0,Y.jsx)(`span`,{className:`storage-chip ${A.kind}`,children:A.label})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Source`}),(0,Y.jsx)(`dd`,{children:t.source})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Review`}),(0,Y.jsx)(`dd`,{children:t.review_state})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Latest`}),(0,Y.jsx)(`dd`,{children:t.is_latest?`yes`:`no`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Next variation`}),(0,Y.jsx)(`dd`,{children:t.user_selected?`yes`:`no`})]})]}),t.user_selected&&!t.is_latest&&(0,Y.jsx)(`div`,{className:`lineage-selection-warning`,role:`status`,children:`This selected asset is not a latest leaf. Keep it selected to branch from an earlier idea, or replace it with the current inspected asset.`}),(0,Y.jsxs)(`label`,{className:`lineage-note-field`,children:[`Variation rationale`,(0,Y.jsx)(`textarea`,{value:S,onChange:e=>D(e.target.value),placeholder:`Why should the next generation branch from this asset?`}),(0,Y.jsx)(`span`,{className:`lineage-note-status ${l?`dirty`:``}`,children:t.user_selected?l?`Unsaved rationale`:`Rationale saved for next variation`:`Rationale saves when this is used for next variation`})]}),(0,Y.jsxs)(`div`,{className:`lineage-side-actions`,children:[(0,Y.jsx)(`button`,{"aria-label":t.user_selected?`Remove ${t.title} from next variation`:`Use ${t.title} for next variation`,className:`primary-lite`,disabled:!t.user_selected&&y,onClick:()=>t.user_selected?void i(t.asset_id):E(),children:t.user_selected?`Remove from next variation`:y?`Selection full`:`Use for next variation`}),t.user_selected&&v.length>1&&(0,Y.jsx)(`button`,{onClick:()=>x(t,S),children:`Use only this`}),!t.user_selected&&v.length>0&&(0,Y.jsx)(`button`,{onClick:()=>x(t,S),children:`Replace selection`}),(0,Y.jsx)(`button`,{disabled:!t.user_selected||!l,onClick:h,children:`Save rationale`}),(0,Y.jsx)(`button`,{"aria-label":`Open detail for ${t.title}`,onClick:()=>T(t.asset_id),children:`Open detail`}),(0,Y.jsx)(`button`,{"aria-label":`Approve ${t.title}`,onClick:()=>void c(`approved`),children:`Approve`}),(0,Y.jsx)(`button`,{"aria-label":`Reject ${t.title}`,onClick:()=>void c(`rejected`),children:`Reject`}),(0,Y.jsx)(`button`,{"aria-label":`Ignore ${t.title}`,onClick:()=>void c(`ignored`),children:`Ignore`})]}),(0,Y.jsxs)(`form`,{className:`lineage-link-form`,onSubmit:e=>{e.preventDefault(),s()},children:[(0,Y.jsxs)(`label`,{children:[`Child asset ID`,(0,Y.jsx)(`input`,{value:r,onChange:e=>w(e.target.value),placeholder:`local-... or catalog id`})]}),(0,Y.jsx)(`button`,{disabled:!r.trim(),type:`submit`,children:`Link child`})]})]}):(0,Y.jsx)(`p`,{className:`muted-copy`,children:`No lineage node selected.`})]})}function hh({activeNode:e,onSelectedAsset:t,onToast:n,project:r,refreshLineage:i,setActiveNodeId:a,snapshot:o}){let s=(0,p.useMemo)(()=>vh(o.tasks||[]),[o.tasks]),c=s.filter(e=>yh(e)).length,l=(0,p.useMemo)(()=>new Map(o.nodes.map(e=>[e.asset_id,e])),[o.nodes]);return(0,Y.jsxs)(`section`,{className:`lineage-next-panel lineage-task-queue-panel`,children:[(0,Y.jsxs)(`div`,{className:`lineage-panel-title-row`,children:[(0,Y.jsx)(`h3`,{children:`Task queue`}),(0,Y.jsx)(`span`,{className:`lineage-count-pill`,children:c})]}),s.length>0?s.map(o=>(0,Y.jsx)(gh,{active:o.target_asset_id===e?.asset_id,node:l.get(o.target_asset_id),onInspect:()=>{a(o.target_asset_id),t(o.target_asset_id)},onToast:n,project:r,refreshLineage:i,task:o},`${o.id}:${o.updated_at}`)):(0,Y.jsx)(`p`,{className:`muted-copy`,children:`No open lineage tasks.`})]})}function gh({active:e,node:t,onInspect:n,onToast:r,project:i,refreshLineage:a,task:o}){let s=o.status===`claimed`||o.status===`in_progress`,c=o.status===`pending`,[l,u]=(0,p.useState)(o.instructions||``),[d,f]=(0,p.useState)(``),[m,h]=(0,p.useState)(!1);(0,p.useEffect)(()=>u(o.instructions||``),[o.id,o.instructions]);async function _(e,t,n){h(!0);try{return await g(e,{body:JSON.stringify({project:i,...t}),headers:{"Content-Type":`application/json`},method:`POST`}),r(`ok`,n),await a(),!0}catch(e){return r(`error`,e instanceof Error?e.message:String(e)),!1}finally{h(!1)}}async function v(e){e.preventDefault(),await _(`/api/lineage/tasks/${encodeURIComponent(o.id)}/instructions`,{instructions:l},`Updated ${xh(o)} instructions`)}async function y(e){e.preventDefault();let t=d.trim();t&&await _(`/api/lineage/tasks/${encodeURIComponent(o.id)}/comment`,{actor:`human`,message:t},`Commented on ${xh(o)}`)&&f(``)}async function b(){window.confirm(`Unlock ${xh(o)} for human edits?`)&&await _(`/api/lineage/tasks/${encodeURIComponent(o.id)}/override`,{actor:`human`,reason:`Human unlocked task from lineage UI.`},`Unlocked ${xh(o)}`)}async function x(){window.confirm(s?`Cancel ${xh(o)} while an agent is working?`:`Cancel ${xh(o)}?`)&&await _(`/api/lineage/tasks/${encodeURIComponent(o.id)}/cancel`,{actor:`human`,confirmWrite:!0,override:s},`Cancelled ${xh(o)}`)}return(0,Y.jsxs)(`article`,{className:`lineage-task-card ${e?`active`:``} ${s?`locked`:o.status}`,children:[(0,Y.jsxs)(`button`,{"aria-label":`Inspect task target ${t?.title||o.target_asset_id}`,className:`lineage-task-target`,onClick:n,type:`button`,children:[(0,Y.jsx)(`span`,{children:t?.title||o.target_asset_id}),(0,Y.jsx)(`code`,{children:o.target_asset_id})]}),(0,Y.jsxs)(`div`,{className:`lineage-task-meta`,children:[(0,Y.jsx)(`span`,{className:`lineage-task-status ${o.status}`,children:bh(o.status)}),(0,Y.jsx)(`span`,{children:o.task_type})]}),c?(0,Y.jsxs)(`form`,{className:`lineage-task-form`,onSubmit:v,children:[(0,Y.jsxs)(`label`,{children:[`Instructions`,(0,Y.jsx)(`textarea`,{"aria-label":`Instructions for ${o.id}`,value:l,onChange:e=>u(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`lineage-task-actions`,children:[(0,Y.jsx)(`button`,{disabled:m||l===(o.instructions||``),type:`submit`,children:`Save instructions`}),(0,Y.jsx)(`button`,{disabled:m,onClick:x,type:`button`,children:`Cancel`})]})]}):(0,Y.jsxs)(`div`,{className:`lineage-task-locked-body`,children:[(0,Y.jsxs)(`label`,{children:[`Instructions`,(0,Y.jsx)(`textarea`,{"aria-label":`Locked instructions for ${o.id}`,disabled:!0,readOnly:!0,value:l||`No instructions.`})]}),s&&(0,Y.jsx)(_h,{claim:o.active_claim}),s&&(0,Y.jsxs)(`form`,{className:`lineage-task-form`,onSubmit:y,children:[(0,Y.jsxs)(`label`,{children:[`Comment`,(0,Y.jsx)(`textarea`,{"aria-label":`Comment for ${o.id}`,value:d,onChange:e=>f(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`lineage-task-actions`,children:[(0,Y.jsx)(`button`,{disabled:m||!d.trim(),type:`submit`,children:`Add comment`}),(0,Y.jsx)(`button`,{disabled:m,onClick:b,type:`button`,children:`Unlock`}),(0,Y.jsx)(`button`,{disabled:m,onClick:x,type:`button`,children:`Cancel`})]})]})]})]})}function _h({claim:e}){return e?(0,Y.jsxs)(`p`,{className:`lineage-task-claim ${e.derived_state===`active`?`active`:e.derived_state}`,children:[(0,Y.jsxs)(`span`,{children:[bh(e.derived_state),` claim`]}),(0,Y.jsx)(`strong`,{children:e.agent_name})]}):(0,Y.jsx)(`p`,{className:`lineage-task-claim`,children:`Claimed by agent`})}function vh(e){return[...e].sort((e,t)=>{let n=+!yh(e),r=+!yh(t);return n===r?e.created_at.localeCompare(t.created_at):n-r})}function yh(e){return e.status===`pending`||e.status===`claimed`||e.status===`in_progress`}function bh(e){return e.replace(/_/g,` `)}function xh(e){return`${e.task_type} task`}function Sh(e,t){return e?.root_asset_id||t||``}function Ch(e){return`${e.title} (${e.root_asset_id})`}function wh(e,t){let n=`${t.project}:lineage-workspace:${t.root_asset_id}`;return e.filter(e=>e.project!==t.project||e.status!==`active`||e.derived_state===`expired`?!1:e.scope_type===`lineage_workspace`?e.target_id===t.id||e.target_id===n:e.scope_type===`project_channel`)}function Th(e){return e.some(e=>e.derived_state===`stale`)?`stale`:e.some(e=>e.derived_state===`idle`)?`idle`:`active`}function Eh(e){let t=Th(e);return e.length===1?`${t===`active`?`Claimed`:t===`idle`?`Idle claim`:`Stale claim`} by ${e[0].agent_name}`:`${e.length} active claims`}function Dh({activeWorkspace:e,closeSignal:t,loading:n,onNewLineage:r,onRefresh:i,onSelect:a,workspaces:o}){let[s,c]=(0,p.useState)(!1),[l,u]=(0,p.useState)([]),d=(0,p.useRef)(null),f=e?.project||o[0]?.project||``;(0,p.useEffect)(()=>{function e(e){d.current?.contains(e.target)||c(!1)}function t(e){e.key===`Escape`&&c(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0)}},[]),(0,p.useEffect)(()=>{c(!1)},[t]),(0,p.useEffect)(()=>{if(!f){u([]);return}let e=!1;return g(`/api/agent-claims?${new URLSearchParams({project:f})}`).then(t=>{e||u(t.claims)}).catch(()=>{e||u([])}),()=>{e=!0}},[f,t,o.length]);function m(e){c(!1),a(e)}let h=e?wh(l,e):[];return(0,Y.jsxs)(`section`,{"aria-label":`Lineage workspace picker`,className:`lineage-workspace-picker`,ref:d,children:[(0,Y.jsxs)(`button`,{"aria-expanded":s,"aria-haspopup":`listbox`,className:`lineage-workspace-trigger`,disabled:n,onClick:()=>c(e=>!e),onKeyDown:e=>{e.key===`Escape`&&c(!1)},type:`button`,children:[(0,Y.jsx)(`span`,{children:`Workspace`}),(0,Y.jsx)(`strong`,{children:e?.title||`No workspace selected`}),(0,Y.jsx)(`code`,{children:e?.root_asset_id||`Start with New lineage`}),(0,Y.jsx)(kh,{claims:h})]}),s&&(0,Y.jsxs)(`div`,{className:`lineage-workspace-menu`,children:[(0,Y.jsxs)(`div`,{className:`lineage-workspace-options`,role:`listbox`,children:[o.length===0&&(0,Y.jsx)(`p`,{children:`No workspaces yet.`}),o.map(t=>(0,Y.jsx)(Oh,{active:e?.id===t.id,claims:wh(l,t),onSelect:()=>m(t.id),workspace:t},t.id))]}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`button`,{className:`secondary-button`,disabled:n,onClick:i,type:`button`,children:`Refresh`}),(0,Y.jsx)(`button`,{className:`primary-button`,onClick:()=>{c(!1),r()},type:`button`,children:`New lineage`})]})]})]})}function Oh({active:e,claims:t,onSelect:n,workspace:r}){return(0,Y.jsxs)(`button`,{"aria-selected":e,className:e?`active`:``,onClick:n,role:`option`,type:`button`,children:[(0,Y.jsx)(`strong`,{children:r.title}),(0,Y.jsx)(`code`,{children:r.root_asset_id}),(0,Y.jsx)(`span`,{children:Ch(r)}),(0,Y.jsx)(kh,{claims:t})]})}function kh({claims:e}){return e.length===0?null:(0,Y.jsxs)(`small`,{className:`lineage-workspace-claim ${Th(e)}`,children:[(0,Y.jsx)(oe,{size:13}),(0,Y.jsx)(`span`,{children:Eh(e)})]})}function Ah({activeWorkspace:e,actionsOpen:t,closeSignal:n,demoSeedStatus:r,edgeSummariesVisible:i,graphDirection:a,loading:o,onArchiveWorkspace:s,onActionsOpenChange:c,onDownloadSwissifierMedia:l,onEdgeSummariesVisible:u,onFitGraph:d,onGraphDirection:f,onIndexLocal:m,onNewLineage:h,onRefreshLineage:g,onRefreshWorkspaces:_,onReplayGrowth:v,onRestoreDemoMedia:y,onRestoreSwissifierMedia:b,onSeedDemo:x,onSeedSwissifierDemo:S,onSelectWorkspace:C,onTidyGraph:w,onToggleNextPanel:T,sideOpen:E,replayActive:D,snapshot:O,swissifierDemoStatus:k,workspaceLoading:A,workspaceProgress:j,workspaceRootAssetId:M,workspaces:N}){let P=r?`${r.present}/${r.total} SVG placeholders`:`Checking media`,F=k?`${k.present}/${k.total} PNG images`:`Checking media`,I=!!(k&&k.present===k.total),L=!!(k?.download_available&&!I),R=j===`downloading`?`Downloading rich demo media`:j===`downloaded`?`Rich demo media ready to seed`:j===`seeding`?`Creating rich demo workspace`:j===`indexing`?`Indexing 14 rich demo images`:j===`ready`?`Rich demo ready`:j===`error`?`Rich demo setup failed`:null,z=A||[`downloading`,`seeding`,`indexing`].includes(j||``),B=R||(O?`${O.nodes.length} nodes · ${O.edges.length} links`:M||`Choose a lineage workspace`);(0,p.useEffect)(()=>{c(!1)},[n,c]),(0,p.useEffect)(()=>{function e(e){e.key===`Escape`&&c(!1)}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[c]);function V(e){c(!1),e()}function H(e){e.key===`Escape`&&(e.preventDefault(),c(!1))}return(0,Y.jsxs)(`header`,{className:`lineage-header`,children:[(0,Y.jsxs)(`div`,{className:`lineage-primary-controls`,children:[(0,Y.jsx)(Dh,{activeWorkspace:e,closeSignal:n,loading:z,onNewLineage:h,onRefresh:_,onSelect:C,workspaces:N}),(0,Y.jsx)(`p`,{className:`lineage-toolbar-context`,children:B}),(0,Y.jsx)(`button`,{"aria-pressed":D,className:`secondary-button lineage-replay-launch`,disabled:D||!O||O.nodes.length<2||O.edges.length===0,onClick:v,type:`button`,children:`Replay growth`}),(0,Y.jsx)(`button`,{className:`primary-button`,onClick:h,type:`button`,children:`New lineage`})]}),(0,Y.jsxs)(`details`,{className:`lineage-overflow`,onToggle:e=>c(e.currentTarget.open),open:t,children:[(0,Y.jsx)(`summary`,{onKeyDown:H,tabIndex:0,children:`Actions`}),(0,Y.jsxs)(`div`,{children:[!e&&(0,Y.jsx)(`button`,{disabled:z,onClick:()=>V(x),type:`button`,children:`Load demo lineage`}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`QA seed media`}),(0,Y.jsx)(`span`,{children:F})]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Basic SVG demo`}),(0,Y.jsx)(`span`,{children:P})]}),(0,Y.jsx)(`button`,{disabled:z||r?.present===r?.total,onClick:y,type:`button`,children:`Restore basic media`}),(0,Y.jsx)(`button`,{disabled:z,onClick:()=>V(x),type:`button`,children:`Load SVG placeholder demo`}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Swissifier rich demo`}),(0,Y.jsx)(`span`,{children:F})]}),(0,Y.jsx)(`button`,{disabled:z||!L,onClick:l,type:`button`,children:`Download rich images`}),(0,Y.jsx)(`button`,{disabled:z||I,onClick:b,type:`button`,children:`Restore rich media`}),(0,Y.jsx)(`button`,{disabled:z,onClick:()=>V(S),type:`button`,children:`Load rich image demo`}),(0,Y.jsxs)(`label`,{className:`lineage-action-select`,children:[(0,Y.jsx)(`span`,{children:`Direction`}),(0,Y.jsxs)(`select`,{"aria-label":`Lineage graph direction`,disabled:!O||o,onChange:e=>f(e.target.value),value:a,children:[(0,Y.jsx)(`option`,{value:`LR`,children:`Left to right`}),(0,Y.jsx)(`option`,{value:`TB`,children:`Top to bottom`}),(0,Y.jsx)(`option`,{value:`RL`,children:`Right to left`}),(0,Y.jsx)(`option`,{value:`BT`,children:`Bottom to top`})]})]}),(0,Y.jsx)(`button`,{"aria-pressed":i,disabled:!O,onClick:()=>V(u),type:`button`,children:i?`Hide edge labels`:`Show edge labels`}),(0,Y.jsx)(`button`,{disabled:!O,onClick:()=>V(d),type:`button`,children:`Fit graph`}),(0,Y.jsx)(`button`,{disabled:!O,onClick:()=>V(w),type:`button`,children:`Tidy tree`}),(0,Y.jsx)(`button`,{"aria-controls":`lineage-selection-panel`,"aria-expanded":E,disabled:!O,onClick:()=>V(T),type:`button`,children:`Manage selection`}),(0,Y.jsx)(`button`,{disabled:z||!e,onClick:()=>V(s),type:`button`,children:`Archive current lineage`}),(0,Y.jsx)(`button`,{disabled:o||z,onClick:()=>V(m),type:`button`,children:`Index local`}),(0,Y.jsx)(`button`,{disabled:o||!O,onClick:()=>V(g),type:`button`,children:`Refresh graph`}),(0,Y.jsx)(`button`,{disabled:z,onClick:()=>V(_),type:`button`,children:`Refresh workspaces`})]})]})]})}async function jh(e,t,n){await g(`/api/lineage/layout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({confirmWrite:!0,positions:n,project:e,rootAssetId:t})})}function Mh(e,t,n){return dd(e.filter(e=>e.type!==`remove`),t)}function Nh(e,t){return!e?.user_selected||t!==`rejected`&&t!==`ignored`?null:{confirmation:`${e.title} is being used for next variation. Marking it ${t} will remove it from next variation.`,clearsSelection:!0}}var Ph=Object.defineProperty,Fh=(e,t,n)=>t in e?Ph(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ih=(e,t)=>{for(var n in t)Ph(e,n,{get:t[n],enumerable:!0})},Lh=(e,t,n)=>Fh(e,typeof t==`symbol`?t:t+``,n),Rh={};Ih(Rh,{Graph:()=>Vh,alg:()=>$h,json:()=>Jh,version:()=>qh});var zh=Object.defineProperty,Bh=(e,t)=>{for(var n in t)zh(e,n,{get:t[n],enumerable:!0})},Vh=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e?e.multigraph:!1,this._isCompound=`compound`in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e==`function`?this._defaultNodeLabelFn=e:this._defaultNodeLabelFn=()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let t of this.successors(e))n.add(t);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return typeof e==`function`?this._defaultEdgeLabelFn=e:this._defaultEdgeLabelFn=()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=Wh(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=Gh(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Hh(this._preds[a],i),Hh(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Kh(this._isDirected,e):Wh(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r==`object`?r:{label:r}}hasEdge(e,t,n){return(arguments.length===1?Kh(this._isDirected,e):Wh(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Kh(this._isDirected,e):Wh(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Uh(this._preds[t],e),Uh(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Hh(e,t){e[t]?e[t]++:e[t]=1}function Uh(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Wh(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function Gh(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function Kh(e,t){return Wh(e,t.v,t.w,t.name)}var qh=`4.0.1`,Jh={};Bh(Jh,{read:()=>Qh,write:()=>Yh});function Yh(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Xh(e),edges:Zh(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Xh(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function Zh(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Qh(e){let t=new Vh(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var $h={};Bh($h,{CycleException:()=>mg,bellmanFord:()=>tg,components:()=>rg,dijkstra:()=>og,dijkstraAll:()=>cg,findCycles:()=>ug,floydWarshall:()=>fg,isAcyclic:()=>gg,postorder:()=>bg,preorder:()=>xg,prim:()=>Sg,shortestPaths:()=>Cg,tarjan:()=>lg,topsort:()=>hg});var eg=()=>1;function tg(e,t,n,r){return ng(e,String(t),n||eg,r||function(t){return e.outEdges(t)})}function ng(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=n(e);i[e.v].distance+t<i[e.w].distance&&(i[e.w]={distance:i[e.v].distance+t,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function rg(e){let t={},n=[],r;function i(n){n in t||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var ig=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},ag=()=>1;function og(e,t,n,r){return sg(e,String(t),n||ag,r||function(t){return e.outEdges(t)})}function sg(e,t,n,r){let i={},a=new ig,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t],c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0&&(o=a.removeMin(),s=i[o],s.distance!==1/0);)r(o).forEach(c);return i}function cg(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=og(e,i,t,n),r},{})}function lg(e){let t=0,n=[],r={},i=[];function a(o){let s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){e in r?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){let e=[],t;do t=n.pop(),r[t].onStack=!1,e.push(t);while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function ug(e){return lg(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var dg=()=>1;function fg(e,t,n){return pg(e,t||dg,n||function(t){return e.outEdges(t)})}function pg(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){let t=r[e];i.forEach(function(n){let a=r[n];i.forEach(function(n){let r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}var mg=class extends Error{constructor(...e){super(...e)}};function hg(e){let t={},n={},r=[];function i(a){if(a in n)throw new mg;a in t||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new mg;return r}function gg(e){try{hg(e)}catch(e){if(e instanceof mg)return!1;throw e}return!0}function _g(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=vg(e,t,n===`post`,o,a,r,i)}),i}function vg(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=vg(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function yg(e,t,n){return _g(e,t,n,function(e,t){return e.push(t),e},[])}function bg(e,t){return yg(e,t,`post`)}function xg(e,t){return yg(e,t,`pre`)}function Sg(e,t){let n=new Vh,r={},i=new ig,a;function o(e){let n=e.v===a?e.w:e.v,o=i.priority(n);if(o!==void 0){let s=t(e);s<o&&(r[n]=a,i.decrease(n,s))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(e){i.add(e,1/0),n.setNode(e)}),i.decrease(e.nodes()[0],0);let s=!1;for(;i.size()>0;){if(a=i.removeMin(),a in r)n.setEdge(a,r[a]);else{if(s)throw Error(`Input graph is not connected: `+e);s=!0}e.nodeEdges(a).forEach(o)}return n}function Cg(e,t,n,r){return wg(e,t,n,r??(t=>e.outEdges(t)??[]))}function wg(e,t,n,r){if(n===void 0)return og(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=r(a[o]);for(let e=0;e<s.length;e++){let t=s[e],r=t.v===a[o]?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return tg(e,t,n,r)}return og(e,t,n,r)}function Tg(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Vg(r);return n.dummy=t,e.setNode(i,n),i}function Eg(e){let t=new Vh().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function Dg(e){let t=new Vh({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Og(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function kg(e){let t=Hg(Ig(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function Ag(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Fg(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function jg(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Fg(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function Mg(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Tg(e,`border`,i,t)}function Ng(e,t=Pg){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Pg=65535;function Fg(e,t){return t.length>Pg?e(...Ng(t).map(t=>e(...t))):e(...t)}function Ig(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Fg(Math.max,t)}function Lg(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Rg(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function zg(e,t){return t()}var Bg=0;function Vg(e){return e+(``+ ++Bg)}function Hg(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function Ug(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Wg(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function Gg(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Kg=`\0`,qg=class{constructor(){Lh(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Jg(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Jg(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,Yg)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Jg(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Yg(e,t){if(e!==`_next`&&e!==`_prev`)return t}var Xg=qg,Zg=()=>1;function Qg(e,t){if(e.nodeCount()<=1)return[];let n=t_(e,t||Zg);return $g(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function $g(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)e_(e,t,n,o);for(;o=i.dequeue();)e_(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(e_(e,t,n,o,!0)||[]);break}}}return r}function e_(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,n_(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,n_(t,n,o)}),e.removeNode(r.v),o}function t_(e,t){let n=new Vh,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=r_(i+r+3).map(()=>new Xg),o=r+1;return n.nodes().forEach(e=>{n_(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function n_(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function r_(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function i_(e){(e.graph().acyclicer===`greedy`?Qg(e,t(e)):a_(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,Vg(`rev`))});function t(e){return t=>e.edge(t).weight}}function a_(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function o_(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function s_(e){e.graph().dummyChains=[],e.edges().forEach(t=>c_(e,t))}function c_(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d;for(d=0,++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=Tg(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function l_(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function u_(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=Fg(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function d_(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var f_=p_;function p_(e){let t=new Vh({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;m_(t,e)<i&&(a=h_(t,e),a);)o=t.hasNode(a.v)?d_(e,a):-d_(e,a),g_(t,e,o);return t}function m_(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!d_(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function h_(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=d_(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function g_(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:__,postorder:v_}=$h,y_=b_;b_.initLowLimValues=w_,b_.initCutValues=x_,b_.calcCutValue=C_,b_.leaveEdge=E_,b_.enterEdge=D_,b_.exchangeEdges=O_;function b_(e){e=Eg(e),u_(e);let t=f_(e);w_(t),x_(t,e);let n,r;for(;n=E_(t);)r=D_(t,e,n),O_(t,e,n,r)}function x_(e,t){let n=v_(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>S_(e,t,n))}function S_(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=C_(e,t,n)}function C_(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,A_(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function w_(e,t){arguments.length<2&&(t=e.nodes()[0]),T_(e,{},1,t)}function T_(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=T_(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function E_(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function D_(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===j_(e,e.node(t.v),s)&&c!==j_(e,e.node(t.w),s)).reduce((e,n)=>d_(t,n)<d_(t,e)?n:e)}function O_(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),w_(e),x_(e,t),k_(e,t)}function k_(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=__(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function A_(e,t,n){return e.hasEdge(t,n)}function j_(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var M_=N_;function N_(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:I_(e);break;case`tight-tree`:F_(e);break;case`longest-path`:P_(e);break;case`none`:break;default:I_(e)}}var P_=u_;function F_(e){u_(e),f_(e)}function I_(e){y_(e)}var L_=R_;function R_(e){let t=B_(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=z_(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function z_(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function B_(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(Kg).forEach(r),t}function V_(e){let t=Tg(e,`root`,{},`_root`),n=U_(e),r=Object.values(n),i=Fg(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=W_(e)+1;e.children(Kg).forEach(r=>H_(e,t,a,o,i,n,r)),e.graph().nodeRankFactor=a}function H_(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=Mg(e,`_bt`),l=Mg(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{H_(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function U_(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(Kg).forEach(e=>n(e,1)),t}function W_(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function G_(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var K_=q_;function q_(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)J_(e,`borderLeft`,`_bl`,n,i,t),J_(e,`borderRight`,`_br`,n,i,t)}}e.children(Kg).forEach(t)}function J_(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Tg(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Y_(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&Z_(e)}function X_(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&$_(e),(t===`lr`||t===`rl`)&&(tv(e),Z_(e))}function Z_(e){e.nodes().forEach(t=>Q_(e.node(t))),e.edges().forEach(t=>Q_(e.edge(t)))}function Q_(e){let t=e.width;e.width=e.height,e.height=t}function $_(e){e.nodes().forEach(t=>ev(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ev),Object.hasOwn(r,`y`)&&ev(r)})}function ev(e){e.y=-e.y}function tv(e){e.nodes().forEach(t=>nv(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(nv),Object.hasOwn(r,`x`)&&nv(r)})}function nv(e){let t=e.x;e.x=e.y,e.y=t}function rv(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),r=n.map(t=>e.node(t).rank),i=Hg(Fg(Math.max,r)+1).map(()=>[]);function a(n){if(t[n])return;t[n]=!0;let r=e.node(n);i[r.rank].push(n);let o=e.successors(n);o&&o.forEach(a)}return n.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(a),i}function iv(e,t){let n=0;for(let r=1;r<t.length;++r)n+=av(e,t[r-1],t[r]);return n}function av(e,t,n){let r=Gg(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function ov(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function sv(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),cv(Object.values(n).filter(e=>!e.indegree))}function cv(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&lv(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>Ug(e,[`vs`,`i`,`barycenter`,`weight`]))}function lv(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function uv(e,t){let n=Lg(e,e=>Object.hasOwn(e,`barycenter`)),r=n.lhs,i=n.rhs.sort((e,t)=>t.i-e.i),a=[],o=0,s=0,c=0;r.sort(fv(!!t)),c=dv(a,i,c),r.forEach(e=>{c+=e.vs.length,a.push(e.vs),o+=e.barycenter*e.weight,s+=e.weight,c=dv(a,i,c)});let l={vs:a.flat(1)};return s&&(l.barycenter=o/s,l.weight=s),l}function dv(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function fv(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function pv(e,t,n,r){let i=e.children(t),a=e.node(t),o=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,c={};o&&(i=i.filter(e=>e!==o&&e!==s));let l=ov(e,i);l.forEach(t=>{if(e.children(t.v).length){let i=pv(e,t.v,n,r);c[t.v]=i,Object.hasOwn(i,`barycenter`)&&hv(t,i)}});let u=sv(l,n);mv(u,c);let d=uv(u,r);if(o&&s){d.vs=[o,d.vs,s].flat(1);let t=e.predecessors(o);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(s),i=e.node(r[0]);Object.hasOwn(d,`barycenter`)||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+n.order+i.order)/(d.weight+2),d.weight+=2}}return d}function mv(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function hv(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function gv(e,t,n,r){r||=e.nodes();let i=_v(e),a=new Vh({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function _v(e){let t;for(;e.hasNode(t=Vg(`_root`)););return t}function vv(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function yv(e,t={}){if(typeof t.customOrder==`function`){t.customOrder(e,yv);return}let n=Ig(e),r=bv(e,Hg(1,n+1),`inEdges`),i=bv(e,Hg(n-1,-1,-1),`outEdges`),a=rv(e);if(Sv(e,a),t.disableOptimalOrderHeuristic)return;let o=1/0,s,c=t.constraints||[];for(let t=0,n=0;n<4;++t,++n){xv(t%2?r:i,t%4>=2,c),a=kg(e);let l=iv(e,a);l<o?(n=0,s=Object.assign({},a),o=l):l===o&&(s=structuredClone(a))}Sv(e,s)}function bv(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return gv(e,t,n,r.get(t)||[])})}function xv(e,t,n){let r=new Vh;e.forEach(function(e){n.forEach(e=>r.setEdge(e.left,e.right));let i=e.graph().root,a=pv(e,i,r,t);a.vs.forEach((t,n)=>e.node(t).order=n),vv(e,r,a.vs)})}function Sv(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Cv(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=Tv(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&Ev(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function wv(e,t){let n={};function r(t,r,i,a,o){Hg(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&Ev(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function Tv(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function Ev(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Dv(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function Ov(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s&&s.length){let r=s.sort((e,t)=>{let n=o[e],r=o[t];return(n===void 0?0:n)-(r===void 0?0:r)}),c=(r.length-1)/2;for(let s=Math.floor(c),l=Math.ceil(c);s<=l;++s){let c=r[s];if(c===void 0)continue;let l=o[c];if(l!==void 0&&a[e]===e&&t<l&&!Dv(n,e,c)){let n=i[c];n!==void 0&&(a[c]=e,a[e]=i[e]=n,t=l)}}}})}),{root:i,align:a}}function kv(e,t,n,r,i=!1){let a={},o=Av(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function Av(e,t,n,r){let i=new Vh,a=e.graph(),o=Fv(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function jv(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Iv(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function Mv(e,t){let n=Object.values(t),r=Fg(Math.min,n),i=Fg(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-Fg(Math.min,c);a!==`l`&&(l=i-Fg(Math.max,c)),l&&(e[o]=Wg(s,e=>e+l))})})}function Nv(e,t=void 0){let n=e.ul;return n?Wg(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function Pv(e){let t=kg(e),n=Object.assign(Cv(e,t),wv(e,t)),r={},i;return[`u`,`d`].forEach(a=>{i=a===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(i=i.map(e=>Object.values(e).reverse()));let o=Ov(e,i,n,t=>(a===`u`?e.predecessors(t):e.successors(t))||[]),s=kv(e,i,o.root,o.align,t===`r`);t===`r`&&(s=Wg(s,e=>-e)),r[a+t]=s})}),Mv(r,jv(e,r)),Nv(r,e.graph().align)}function Fv(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2;break}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2;break}return l&&(c+=n?l:-l),c}}function Iv(e,t){return e.node(t).width}function Lv(e){e=Dg(e),Rv(e),Object.entries(Pv(e)).forEach(([t,n])=>e.node(t).x=n)}function Rv(e){let t=kg(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);i===`top`?r.y=a+r.height/2:i===`bottom`?r.y=a+n-r.height/2:r.y=a+n/2}),a+=n+r})}function zv(e,t={}){let n=t.debugTiming?Rg:zg;return n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>Xv(e));return n(` runLayout`,()=>Bv(r,n,t)),n(` updateInputGraph`,()=>Vv(e,r)),r})}function Bv(e,t,n){t(` makeSpaceForEdgeLabels`,()=>Zv(e)),t(` removeSelfEdges`,()=>oy(e)),t(` acyclic`,()=>i_(e)),t(` nestingGraph.run`,()=>V_(e)),t(` rank`,()=>M_(Dg(e))),t(` injectEdgeLabelProxies`,()=>Qv(e)),t(` removeEmptyRanks`,()=>jg(e)),t(` nestingGraph.cleanup`,()=>G_(e)),t(` normalizeRanks`,()=>Ag(e)),t(` assignRankMinMax`,()=>$v(e)),t(` removeEdgeLabelProxies`,()=>ey(e)),t(` normalize.run`,()=>s_(e)),t(` parentDummyChains`,()=>L_(e)),t(` addBorderSegments`,()=>K_(e)),t(` order`,()=>yv(e,n)),t(` insertSelfEdges`,()=>sy(e)),t(` adjustCoordinateSystem`,()=>Y_(e)),t(` position`,()=>Lv(e)),t(` positionSelfEdges`,()=>cy(e)),t(` removeBorderNodes`,()=>ay(e)),t(` normalize.undo`,()=>l_(e)),t(` fixupEdgeLabelCoords`,()=>ry(e)),t(` undoCoordinateSystem`,()=>X_(e)),t(` translateGraph`,()=>ty(e)),t(` assignNodeIntersects`,()=>ny(e)),t(` reversePoints`,()=>iy(e)),t(` acyclic.undo`,()=>o_(e))}function Vv(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Hv=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],Uv={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},Wv=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],Gv=[`width`,`height`,`rank`],Kv={width:0,height:0},qv=[`minlen`,`weight`,`width`,`height`,`labeloffset`],Jv={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},Yv=[`labelpos`];function Xv(e){let t=new Vh({multigraph:!0,compound:!0}),n=uy(e.graph());return t.setGraph(Object.assign({},Uv,ly(n,Hv),Ug(n,Wv))),e.nodes().forEach(n=>{let r=ly(uy(e.node(n)),Gv);Object.keys(Kv).forEach(e=>{r[e]===void 0&&(r[e]=Kv[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=uy(e.edge(n));t.setEdge(n,Object.assign({},Jv,ly(r,qv),Ug(r,Yv)))}),t}function Zv(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Qv(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Tg(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function $v(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function ey(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function ty(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function ny(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(Og(r,a)),n.points.push(Og(i,o))})}function ry(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset;break}})}function iy(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function ay(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function oy(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function sy(e){kg(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{Tg(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function cy(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`selfedge`){let r=n,i=e.node(r.e.v),a=i.x+i.width/2,o=i.y,s=n.x-a,c=i.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:a+2*s/3,y:o-c},{x:a+5*s/6,y:o-c},{x:a+s,y:o},{x:a+5*s/6,y:o+c},{x:a+2*s/3,y:o+c}],r.label.x=n.x,r.label.y=n.y}})}function ly(e,t){return Wg(Ug(e,t),Number)}function uy(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var dy=212,fy=164;function py(e,t,n=`LR`,r=!0){if(!e)return{nodes:[],edges:[]};let i=_y(e,n),a=my(n),o=gy(e,t),s=e.nodes.map(n=>({id:n.asset_id,initialHeight:fy,initialWidth:dy,measured:{height:fy,width:dy},type:`assetNode`,height:fy,position:n.position||i.get(n.asset_id)||{x:0,y:0},sourcePosition:a.source,targetPosition:a.target,width:dy,data:{...n,active:n.asset_id===t,focusRole:o.roles.get(n.asset_id)||`none`,root:n.asset_id===e.root_asset_id,sourcePosition:a.source,targetPosition:a.target}})),c=new Map(e.nodes.map(e=>[e.asset_id,e.title]));return{nodes:s,edges:e.edges.map(t=>{let n=t.summary?`lineage-edge-summary`:``,i=[o.edgeClasses.get(t.id),n].filter(Boolean).join(` `)||void 0,a=`${c.get(t.parent_asset_id)||t.parent_asset_id} to ${c.get(t.child_asset_id)||t.child_asset_id}`;return{ariaLabel:t.summary?`${a}: ${t.summary}`:a,ariaRole:`button`,className:i,domAttributes:{"aria-keyshortcuts":`Enter Space`},focusable:!0,id:t.id,markerEnd:{type:Rs.ArrowClosed},source:t.parent_asset_id,target:t.child_asset_id,type:`smoothstep`,animated:e.selected.includes(t.child_asset_id),...t.summary&&r?{label:t.summary,labelBgBorderRadius:4,labelBgPadding:[5,3],labelShowBg:!0}:{}}})}}function my(e){return{BT:{source:X.Top,target:X.Bottom},LR:{source:X.Right,target:X.Left},RL:{source:X.Left,target:X.Right},TB:{source:X.Bottom,target:X.Top}}[e]}function hy(e,t=`LR`){if(!e)return`lineage-empty`;let n=e.nodes.map(e=>e.asset_id).sort().join(`,`),r=e.edges.map(e=>e.id).sort().join(`,`);return`${e.root_asset_id}:${t}:${n}:${r}`}function gy(e,t){let n=new Map,r=new Map;if(!t||!e.nodes.some(e=>e.asset_id===t))return{edgeClasses:r,roles:n};n.set(t,`active`);for(let i of e.edges)i.child_asset_id===t&&(n.has(i.parent_asset_id)||n.set(i.parent_asset_id,`parent`),r.set(i.id,`lineage-edge-focus lineage-edge-focus-parent`)),i.parent_asset_id===t&&(n.has(i.child_asset_id)||n.set(i.child_asset_id,`child`),r.set(i.id,`lineage-edge-focus lineage-edge-focus-child`));return{edgeClasses:r,roles:n}}function _y(e,t=`LR`){let n=new Rh.Graph;n.setGraph({marginx:40,marginy:40,nodesep:80,rankdir:t,ranksep:110}),n.setDefaultEdgeLabel(()=>({}));for(let t of e.nodes)n.setNode(t.asset_id,{height:fy,width:dy});for(let t of e.edges)n.setEdge(t.parent_asset_id,t.child_asset_id);return zv(n),new Map(e.nodes.map(e=>{let t=n.node(e.asset_id);return[e.asset_id,{x:Math.round((t?.x||dy/2)-dy/2),y:Math.round((t?.y||fy/2)-fy/2)}]}))}function vy(e){return!!(e&&e.nodes.length>1&&e.edges.length>0)}function yy(e){let t=new Set(e.nodes.map(e=>e.asset_id));if(t.size===0)return{stages:[]};let n=[...t].sort(Cy),r=t.has(e.root_asset_id)?e.root_asset_id:n[0],i=new Set([r]),a=new Set,o=e.edges.filter(e=>t.has(e.parent_asset_id)&&t.has(e.child_asset_id)).sort(Sy),s=[xy(0,i,a,[r],[])];for(;i.size<t.size||o.length>0;){let e=o.findIndex(e=>i.has(e.parent_asset_id));if(e>=0){let[t]=o.splice(e,1);a.add(t.id);let n=i.has(t.child_asset_id)?[]:[t.child_asset_id];i.add(t.child_asset_id),s.push(xy(s.length,i,a,n,[t.id]));continue}let t=n.find(e=>!i.has(e));if(t){i.add(t),s.push(xy(s.length,i,a,[t],[]));continue}break}return{stages:s}}function by(e,t,n,r,i){let a=n.stages,o=a.length-1,s=Math.max(-1,Math.min(r,o)),c=s>=0?a[s]:void 0,l=s<o?a[s+1]:void 0,u=new Set(c?.nodeIds||[]),d=new Set(c?.edgeIds||[]),f=new Set,p=new Set;if(l&&(i===`edge`||i===`node`))for(let e of l.enteringEdgeIds)i===`edge`?p.add(e):d.add(e);if(l&&i===`node`)for(let e of l.enteringNodeIds)f.add(e);let m=s===o&&i===`settled`,h=new Map(e.map(e=>[e.id,f.has(e.id)?`entering`:u.has(e.id)?`visible`:`future`])),g=new Map(t.map(e=>[e.id,p.has(e.id)?`entering`:d.has(e.id)?`visible`:`future`]));return{nodes:e.map(e=>({...e,data:{...e.data,replayInteractive:m,replayState:h.get(e.id)||`future`}})),edges:t.map(e=>{let t=g.get(e.id)||`future`;return{...e,className:[e.className,`lineage-edge-replay-${t}`].filter(Boolean).join(` `),domAttributes:{...e.domAttributes,"aria-hidden":t===`future`?!0:void 0},focusable:m?e.focusable:!1}}),projection:{edgeStates:g,interactive:m,nodeStates:h}}}function xy(e,t,n,r,i){return{edgeIds:[...n],enteringEdgeIds:i,enteringNodeIds:r,index:e,nodeIds:[...t]}}function Sy(e,t){return Cy(e.created_at||``,t.created_at||``)||Cy(e.id,t.id)}function Cy(e,t){return e.localeCompare(t)}function wy(e,t){(0,p.useEffect)(()=>{function n(n){n.key===`Escape`&&e&&t()}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t])}function Ty({asset:e,onResetLineage:t,onSelectedAsset:n,onToast:r,project:i}){let a=(0,p.useRef)(i),[o,s]=(0,p.useState)(null),[c,l]=(0,p.useState)(null),[u,d]=(0,p.useState)(null),[f,m]=(0,p.useState)(!1),h=o?.project===i,_=h?o:null,v=(_?.workspaces||[]).filter(e=>e.status!==`archived`),y=_?.active_workspace||v[0]||null,b=Sh(y,h&&_?.workspaces.length===0?e?.asset_id:void 0);(0,p.useEffect)(()=>{a.current=i,s(null),l(null),d(null)},[i]);let x=(0,p.useCallback)(async()=>{m(!0);try{let e=await g(`/api/lineage-workspaces?${new URLSearchParams({project:i}).toString()}`);e.project===a.current&&s(e)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}},[r,i]),S=(0,p.useCallback)(async()=>{try{let e=new URLSearchParams({project:i}),[t,n]=await Promise.all([g(`/api/lineage-workspaces/demo/media?${e.toString()}`),g(`/api/lineage-workspaces/demo/swissifier/media?${e.toString()}`)]);if(a.current!==i)return;l(t.status),d(n.status)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}},[r,i]);async function C(e){if(e){m(!0);try{let a=await g(`/api/lineage-workspaces/${encodeURIComponent(e)}/activate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});t(),await x(),n(a.workspace.root_asset_id),r(`ok`,`Using ${a.workspace.title}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}}}async function w(e={}){m(!0);try{let a=await g(`/api/lineage-workspaces/demo/seed`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});return t(),await x(),await S(),n(a.workspace?.root_asset_id||a.root_asset_id),e.quiet||r(`ok`,`Seeded demo lineage workspace`),a}catch(e){return r(`error`,e instanceof Error?e.message:String(e)),null}finally{m(!1)}}async function T(e={}){m(!0);try{let a=await g(`/api/lineage-workspaces/demo/swissifier/seed`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});return t(),await x(),await S(),n(a.workspace?.root_asset_id||a.root_asset_id),e.quiet||r(`ok`,`Seeded Swissifier demo lineage`),a}catch(e){return r(`error`,e instanceof Error?e.message:String(e)),null}finally{m(!1)}}async function E(){m(!0);try{let e=await g(`/api/lineage-workspaces/demo/media/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});await S(),r(`ok`,`Restored ${e.result.restored||0} demo media file${e.result.restored===1?``:`s`}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}}async function D(){m(!0);try{let e=await g(`/api/lineage-workspaces/demo/swissifier/media/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});await S(),e.result.source_required?r(`error`,`Set ${e.result.source_env||`LINEAGE_SWISSIFIER_MEDIA_DIR`} to restore Swissifier media`):r(`ok`,`Restored ${e.result.restored||0} Swissifier media file${e.result.restored===1?``:`s`}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}}async function O(){m(!0);try{let e=await g(`/api/lineage-workspaces/demo/swissifier/media/download`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});return await S(),e.result.download_available?(r(`ok`,`Downloaded ${e.result.restored||0} Swissifier media file${e.result.restored===1?``:`s`}`),!0):(r(`error`,`Swissifier media download is not configured`),!1)}catch(e){return r(`error`,e instanceof Error?e.message:String(e)),!1}finally{m(!1)}}async function k(){if(y&&window.confirm(`Archive ${y.title}? This hides it from the picker and clears its next-variation selection.`)){m(!0);try{await g(`/api/lineage-workspaces/${encodeURIComponent(y.id)}/archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})}),t(),await x(),await S(),r(`ok`,`Archived ${y.title}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}}}function A(e){s(t=>({project:i,active_workspace:e,workspaces:[e,...(t?.workspaces||[]).filter(t=>t.id!==e.id)],fetchedAt:new Date().toISOString()})),t(),n(e.root_asset_id),r(`ok`,`Using ${e.title}`)}return{activateWorkspace:C,activeWorkspace:y,archiveWorkspace:k,demoSeedStatus:c,downloadSwissifierDemoMedia:O,handleWorkspaceCreated:A,refreshDemoSeedStatus:S,refreshWorkspaces:x,restoreDemoSeedMedia:E,restoreSwissifierDemoMedia:D,seedDemoWorkspace:w,seedSwissifierDemoWorkspace:T,swissifierDemoStatus:u,visibleWorkspaces:v,workspaceLoading:f,workspaceRootAssetId:b}}function Ey(e,t,n){let r=(0,p.useRef)(!1),i=(0,p.useRef)(``),a=(0,p.useRef)(!1),o=(0,p.useRef)(``),s=(0,p.useCallback)((t=0)=>{window.setTimeout(()=>{e&&(r.current=!0,e.fitView({maxZoom:.9,padding:.32}),window.setTimeout(()=>{r.current=!1},450))},t)},[e]),c=(0,p.useCallback)(()=>{r.current||(a.current=!0)},[]);return(0,p.useEffect)(()=>{if(!t||!e)return;o.current!==t&&(o.current=t,a.current=!1,i.current=``);let r=`${t}:${n?`side-open`:`side-closed`}`;i.current!==r&&(i.current=r,a.current||s(280))},[s,e,t,n]),{fitGraph:s,markViewportInteraction:c}}function Dy({actionsOpen:e,asset:t,onActionsOpenChange:n,onAssetsChanged:r,project:i,onSelectedAsset:a,onToast:o}){let[s,c]=(0,p.useState)(null),[l,u]=(0,p.useState)(null),[d,f]=(0,p.useState)(``),[m,_]=(0,p.useState)(null),[v,y]=(0,p.useState)(null),[b,x]=(0,p.useState)([]),[S]=(0,p.useState)(ym),[C,w]=(0,p.useState)(null),[T,E]=(0,p.useState)([]),[D,O]=(0,p.useState)(!0),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(`LR`),[N,P]=(0,p.useState)(``),[F,I]=(0,p.useState)(null),[L,R]=(0,p.useState)(!1),[z,B]=(0,p.useState)(!1),[V,H]=(0,p.useState)(!1),[U,W,ee]=Ip([]),[G,te]=Lp([]),[ne,re]=(0,p.useState)(null),[ie,ae]=(0,p.useState)(!1),[oe,se]=(0,p.useState)(null),[ce,le]=(0,p.useState)(0),[ue,de]=(0,p.useState)(null),[K,fe]=(0,p.useState)(-1),[pe,me]=(0,p.useState)(`settled`),[he,q]=(0,p.useState)(!1),[ge,J]=(0,p.useState)(1),[_e,ve]=(0,p.useState)(!1),ye=(0,p.useMemo)(()=>ue?yy(ue):{stages:[]},[ue]),be=ye.stages.length-1,xe=!!(ue&&K===be&&pe===`settled`),Se=ue&&!xe?ue:s,Ce=s?.nodes.find(e=>e.asset_id===l)||s?.nodes[0],we=s?.edges.find(e=>e.id===k?.edgeId),Te=s?.nodes.filter(e=>s.latest.includes(e.asset_id))||[],Ee=s?.selected.map(e=>s.nodes.find(t=>t.asset_id===e)).filter(e=>!!e)||[],De=Ee[0],Oe=Ee.length>=3,ke=s?.nodes.find(e=>e.asset_id===m)||null,Ae=s?.nodes.find(e=>e.asset_id===v)||null,je=s?.nodes.find(e=>e.asset_id===F?.assetId),Me=S&&!ke&&!Ae&&!we&&(!ue||xe),Ne=!!(Ce&&N!==(Ce.selection_note||``)),Pe=(0,p.useRef)(null),Fe=(0,p.useRef)([]),Ie=(0,p.useRef)(``),Le=(0,p.useRef)(``),{fitGraph:Re,markViewportInteraction:ze}=Ey(ne,s?.root_asset_id,z),Be=(0,p.useCallback)(()=>{le(e=>e+1),I(null)},[]),Ve=(0,p.useRef)(i);(0,p.useEffect)(()=>{Ve.current=i},[i]);let He=(0,p.useCallback)(()=>{u(null),Be()},[Be]),Ue=(0,p.useCallback)(()=>{c(null),u(null),w(null),de(null),q(!1),me(`settled`),fe(-1)},[]),{activateWorkspace:We,activeWorkspace:Ge,archiveWorkspace:Ke,demoSeedStatus:qe,downloadSwissifierDemoMedia:Je,handleWorkspaceCreated:Ye,refreshDemoSeedStatus:Xe,refreshWorkspaces:Ze,restoreDemoSeedMedia:Qe,restoreSwissifierDemoMedia:$e,seedDemoWorkspace:et,seedSwissifierDemoWorkspace:tt,swissifierDemoStatus:nt,visibleWorkspaces:rt,workspaceLoading:it,workspaceRootAssetId:at}=Ty({asset:t,onResetLineage:Ue,onSelectedAsset:a,onToast:o,project:i});Le.current=at,(0,p.useEffect)(()=>{Xe()},[Xe]);let ot=(0,p.useCallback)(async(e={})=>{let t=e.rootAssetId||at;if(!t)return!1;e.quiet||ae(!0);try{let n=new URLSearchParams({project:i}),[r,a]=await Promise.all([g(`/api/lineage/${t}?${n.toString()}`),g(`/api/agent-claims?${n.toString()}`)]);return!e.rootAssetId&&Le.current!==t?!1:(c(r),E(a.claims),e.quiet||w(null),u(t=>Pm(t,r.nodes,r.active_asset_id,!!e.quiet)),!0)}catch(n){return!e.rootAssetId&&Le.current!==t||!e.quiet&&Ve.current===i&&(c(null),o(`error`,n instanceof Error?n.message:String(n))),!1}finally{!e.quiet&&Ve.current===i&&ae(!1)}},[o,i,at]),st=(0,p.useCallback)(()=>{!s||!vy(s)||(Pe.current&&window.clearTimeout(Pe.current),Be(),u(null),_(null),y(null),x([]),A(null),B(!1),H(!1),de(s),fe(-1),me(`node`),q(!0))},[Be,s]),ct=(0,p.useCallback)(()=>{de(null),fe(-1),me(`settled`),q(!1),ot({quiet:!0})},[ot]),lt=(0,p.useCallback)(()=>{xe&&s&&de(s),fe(-1),me(`node`),q(!0)},[xe,s]),ut=(0,p.useCallback)(()=>{if(xe){lt();return}q(e=>!e)},[xe,lt]),dt=(0,p.useCallback)(e=>{q(!1),me(`settled`),fe(Math.max(0,Math.min(e,be)))},[be]);async function ft(){se(null),ae(!0);try{o(`ok`,`Indexed ${(await g(`/api/index/local`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i})})).summary.total} assets`),await Ze(),await ot()}catch(e){o(`error`,e instanceof Error?e.message:String(e))}finally{ae(!1)}}async function pt(){Be(),se(null);let e=await et();if(e)try{await r?.(),await ot({rootAssetId:e.workspace?.root_asset_id||e.root_asset_id})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function mt(){Be(),se(`seeding`);let e=await tt();if(!e){se(`error`);return}try{se(`indexing`),await r?.(),await ot({rootAssetId:e.workspace?.root_asset_id||e.root_asset_id})||se(`error`)}catch(e){se(`error`),o(`error`,e instanceof Error?e.message:String(e))}}async function ht(){se(`downloading`);let e=await Je();se(e?`downloaded`:`error`)}async function gt(e,t,n){try{await g(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,...t})}),o(`ok`,n),await ot()}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}function _t(){Ce&&yt(Ce,N)}function vt(){Ce?.user_selected&&yt(Ce,N)}async function yt(e,t=e.selection_note||``){if(!e.user_selected&&Oe){o(`error`,`Choose at most 3 assets for next variation`);return}await gt(`/api/selection`,{assetId:e.asset_id,rootAssetId:s?.root_asset_id,mode:e.user_selected?`remove`:`add`,notes:t,confirmWrite:!0},e.user_selected?`Removed ${e.asset_id} from next variation`:`Using ${e.asset_id} for next variation`)}async function bt(e,t=e.selection_note||``){await gt(`/api/selection`,{assetId:e.asset_id,rootAssetId:s?.root_asset_id,mode:`replace`,notes:t,confirmWrite:!0},`Using only ${e.asset_id} for next variation`)}async function xt(e){if(s){if(e){await gt(`/api/selection`,{assetId:e,rootAssetId:s.root_asset_id,mode:`remove`,confirmWrite:!0},`Removed ${e} from next variation`);return}Ee.length>0&&await gt(`/api/selection`,{rootAssetId:s.root_asset_id,clear:!0,confirmWrite:!0},`Removed all assets from next variation`)}}function St(){if(Pe.current&&window.clearTimeout(Pe.current),z){B(!1),Pe.current=window.setTimeout(()=>H(!1),260);return}H(!0),window.requestAnimationFrame(()=>B(!0))}async function Ct(e,t=Ce?.asset_id){if(!t)return;let n=s?.nodes.find(e=>e.asset_id===t),r=Nh(n,e);r&&!window.confirm(r.confirmation)||(r&&await xt(t),gt(`/api/reviews/${t}`,{reviewState:e,confirmWrite:!0},`Marked ${t} ${e}`))}async function wt(e){s&&await gt(`/api/lineage/${s.root_asset_id}/rerolls/${e.asset_id}`,{confirmWrite:!0,requestedBy:`human`},`Marked ${e.asset_id} for re-roll`)}async function Tt(e){s&&await gt(`/api/lineage/${s.root_asset_id}/rerolls/${e.asset_id}/cancel`,{confirmWrite:!0},`Cleared re-roll request for ${e.asset_id}`)}async function Et(e){if(s)try{let t=new URLSearchParams({project:i}),n=await g(`/api/lineage/${s.root_asset_id}/attempts/${e}?${t.toString()}`);x(n.attempts),y(e)}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}function Dt(){y(null),x([])}function Ot(e){Dt(),_(e)}async function kt(e){if(!(!s||!v))try{let t=await g(`/api/lineage/${s.root_asset_id}/attempts/${v}/promote`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,attemptId:e.id,confirmWrite:!0})});x(t.attempts),o(`ok`,`Set v${e.attempt_index} as current`),await ot({quiet:!0})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function At(){!Ce||!d.trim()||(await gt(`/api/lineage/link`,{childAssetId:d.trim(),confirmWrite:!0,parentAssetId:Ce.asset_id},`Linked ${d.trim()} from ${Ce.asset_id}`),f(``))}async function jt(e,t){if(we)try{let n=await g(`/api/lineage/edges/${encodeURIComponent(we.id)}/summary`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e,confirmWrite:!0,expectedSummaryUpdatedAt:we.summary_updated_at||null,project:i,...e===`set`?{summary:t}:{}})});await ot({quiet:!0}),o(`ok`,n.message),A(null)}catch(e){throw e instanceof h&&e.status===409&&e.message.includes(`Edge summary changed since it was opened`)?(await ot({quiet:!0}),Error(`This edge changed elsewhere. The current label has been reloaded; review it and retry.`,{cause:e})):e}}async function Mt(e){if(!s)return;if(e.asset_id===s.root_asset_id){o(`error`,`Root lineage node cannot be removed. Archive this workspace or start a new lineage instead.`);return}let t=s.edges.filter(t=>t.parent_asset_id===e.asset_id).length,n=s.edges.filter(t=>t.child_asset_id===e.asset_id).length,r=t>0&&n>0?` Its ${t} child${t===1?``:`ren`} will be reconnected to its parent${n===1?``:`s`}.`:``;window.confirm(`Remove "${e.title}" from this lineage? This keeps the asset file and S3 object intact.${r}`)&&(await gt(`/api/lineage/remove-node`,{assetId:e.asset_id,rootAssetId:s.root_asset_id,confirmWrite:!0},`Removed ${e.asset_id} from lineage`),I(null),_(t=>t===e.asset_id?null:t),u(t=>t===e.asset_id?s.root_asset_id:t))}async function Nt(e){if(s)try{await jh(i,s.root_asset_id,[{assetId:e.id,x:e.position.x,y:e.position.y}])}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function Pt(){if(!s)return;let e=[..._y(s,j)].map(([e,t])=>({assetId:e,...t}));It(e),W(t=>t.map(t=>({...t,position:e.find(e=>e.assetId===t.id)||t.position})));try{await jh(i,s.root_asset_id,e),o(`ok`,`Tidied ${e.length} lineage nodes`),Re(80),await ot({quiet:!0})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function Ft(e){if(!s)return;let t=[..._y(s,e)].map(([e,t])=>({assetId:e,...t}));It(t),M(e),W(e=>e.map(e=>({...e,position:t.find(t=>t.assetId===e.id)||e.position})));try{await jh(i,s.root_asset_id,t),o(`ok`,`Rotated lineage graph ${ky(e).toLowerCase()}`),Re(80),await ot({quiet:!0})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}function It(e){let t=new Map(e.map(e=>[e.assetId,{x:e.x,y:e.y}]));c(e=>e&&{...e,nodes:e.nodes.map(e=>({...e,position:t.get(e.asset_id)||e.position}))})}async function Lt(){if(s)try{let e=new URLSearchParams({project:i});w(await g(`/api/lineage/${s.root_asset_id}/brief?${e.toString()}`))}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function Rt(e,t,n){try{await g(`/api/agent-claims/${t.id}/${e}`,{body:JSON.stringify({project:i,...n}),headers:{"Content-Type":`application/json`},method:`POST`}),o(`ok`,`Updated claim ${t.id}`),await ot({quiet:!0})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}(0,p.useEffect)(()=>{Ze()},[Ze]),(0,p.useEffect)(()=>{ot()},[ot]),(0,p.useEffect)(()=>{at||Ue()},[Ue,at]),(0,p.useEffect)(()=>{if(!s)return;let e=window.setInterval(()=>void ot({quiet:!0}),8e3);return()=>window.clearInterval(e)},[ot,s?.root_asset_id]),(0,p.useEffect)(()=>{let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);if(!e)return;let t=()=>ve(e.matches);return t(),e.addEventListener?.(`change`,t),()=>e.removeEventListener?.(`change`,t)},[]),(0,p.useEffect)(()=>{if(!ue||!he||be<0)return;let e=Math.min(K+1,be);if(pe===`settled`&&K>=be){q(!1);return}let t=ye.stages[e],n=_e?40:void 0,r=n??120/ge,i=()=>{let e=t.enteringEdgeIds.length>0?`edge`:`node`;me(e)};pe===`edge`?(r=n??320/ge,i=()=>{t.enteringNodeIds.length>0?me(`node`):(fe(e),me(`settled`))}):pe===`node`&&(r=n??200/ge,i=()=>{fe(e),me(`settled`)});let a=window.setTimeout(i,r);return()=>window.clearTimeout(a)},[_e,be,pe,he,ue,ge,K,ye.stages]);let zt=(0,p.useMemo)(()=>py(Se,l,j,D),[l,D,j,Se]),Bt=(0,p.useMemo)(()=>ue&&!xe?by(zt.nodes,zt.edges,ye,K,pe):zt,[zt,xe,pe,ue,K,ye]),Vt=(0,p.useMemo)(()=>hy(Se,j),[j,Se]);Fe.current=Bt.edges;let Ht=(0,p.useCallback)(e=>{te(t=>Mh(e,t,Fe.current))},[te]),Ut=(0,p.useCallback)(e=>{e.key===`Escape`&&Be()},[Be]);return(0,p.useEffect)(()=>{P(Ce?.selection_note||``)},[Ce?.asset_id,Ce?.selection_note]),(0,p.useEffect)(()=>{let e=Ie.current!==Vt;Ie.current=Vt,W(t=>Bt.nodes.map(n=>({...n,position:e?n.position:t.find(e=>e.id===n.id)?.position||n.position}))),te(Bt.edges)},[Bt.edges,Bt.nodes,Vt,te,W]),(0,p.useEffect)(()=>{oe!==`indexing`||!s?.nodes.length||Ie.current!==Vt||U.length!==s.nodes.length||se(`ready`)},[U.length,Vt,s,oe]),wy(!!l,He),(0,p.useEffect)(()=>()=>{Pe.current&&window.clearTimeout(Pe.current)},[]),(0,p.useEffect)(()=>{Ue(),se(null)},[i,Ue]),(0,Y.jsxs)(`section`,{className:`lineage-view`,onKeyDownCapture:Ut,children:[(0,Y.jsx)(Ah,{actionsOpen:e,activeWorkspace:Ge,closeSignal:ce,edgeSummariesVisible:D,loading:ie,graphDirection:j,demoSeedStatus:qe,onArchiveWorkspace:()=>{se(null),Ke()},onActionsOpenChange:n,onFitGraph:()=>Re(),onIndexLocal:()=>void ft(),onGraphDirection:e=>void Ft(e),onNewLineage:()=>{se(null),R(!0)},onRefreshLineage:()=>void ot(),onRefreshWorkspaces:()=>void Ze(),onReplayGrowth:st,onRestoreDemoMedia:()=>void Qe(),onRestoreSwissifierMedia:()=>void $e(),onDownloadSwissifierMedia:()=>void ht(),onEdgeSummariesVisible:()=>O(e=>!e),onSeedDemo:()=>void pt(),onSeedSwissifierDemo:()=>void mt(),onSelectWorkspace:e=>{se(null),We(e)},onTidyGraph:()=>void Pt(),onToggleNextPanel:St,replayActive:!!ue,sideOpen:z,snapshot:s,swissifierDemoStatus:nt,workspaceLoading:it,workspaceProgress:oe,workspaceRootAssetId:at,workspaces:rt}),(0,Y.jsxs)(`div`,{className:`lineage-workbench`,"data-testid":`lineage-workbench`,children:[(0,Y.jsxs)(`div`,{className:`lineage-canvas ${l?`focus-active`:``} ${ue?`lineage-replay-active`:``} ${xe?`lineage-replay-interactive`:``} ${ue&&!he?`lineage-replay-paused`:``}`,style:ue?{"--lineage-replay-edge-duration":`${_e?1:320/ge}ms`,"--lineage-replay-node-duration":`${_e?1:200/ge}ms`}:void 0,children:[ue&&ye.stages.length>0&&(0,Y.jsx)(ih,{atEnd:xe,onClose:ct,onPlayPause:ut,onRestart:lt,onScrub:dt,onSpeed:J,playing:he,speed:ge,stageIndex:K,totalStages:ye.stages.length}),(0,Y.jsx)(km,{flowEdges:Se?G:[],flowNodes:Se?U:[],graphKey:Vt,hoverPreviewsEnabled:Me,loading:ie,onEdgesChange:Ht,onEdgeEdit:(e,t)=>A({edgeId:e,returnFocus:t}),onClearFocus:He,onIndexNow:()=>void ft(),onNewLineage:()=>{se(null),R(!0)},onSeedDemo:()=>void pt(),onNodeActionMenu:(e,t,n)=>I(e?{assetId:e,x:t,y:n}:null),onNodeInspect:e=>{Be(),u(e)},onNodeOpenDetail:_,onNodeOpenHistory:e=>void Et(e),onNodePosition:e=>void Nt(e),onNodesChange:ee,onReady:re,onSelectedAsset:a,onToggleBranch:e=>e.user_selected?xt(e.asset_id):yt(e),onToggleReroll:e=>e.reroll_request?.status===`pending`?Tt(e):wt(e),onViewportInteraction:ze,replayInteractive:!ue||xe,selectionFull:Oe,workspaceProgress:oe,workspaceRootAssetId:at})]}),V&&s&&(0,Y.jsx)(mh,{activeNode:Ce,brief:C,childAssetId:d,clearNextVariation:xt,closePanel:St,latestNodes:Te,linkChild:At,markReview:Ct,nextVariationLimit:3,noteDirty:Ne,onSelectedAsset:a,onToast:o,project:i,refreshBrief:Lt,refreshLineage:async()=>{await ot({quiet:!0})},saveRationale:vt,replaceNextVariation:bt,selectNextBase:yt,selectedNode:De,selectedNodes:Ee,selectionFull:Oe,selectionNote:N,setActiveNodeId:u,setChildAssetId:f,setDetailNodeId:_,setSelected:_t,setSelectionNote:P,sideOpen:z,snapshot:s}),F&&je&&s&&(0,Y.jsx)(Am,{canRemoveFromLineage:je.asset_id!==s.root_asset_id,claims:Oy(T,i,s.root_asset_id),node:je,onClaimControl:(e,t,n)=>{Rt(e,t,n)},onClearAllNext:()=>void xt(),onClearNext:()=>void xt(je.asset_id),onClearReroll:()=>void Tt(je),onClose:()=>I(null),onMarkReroll:()=>void wt(je),onOpenDetail:()=>_(je.asset_id),onRemoveFromLineage:()=>void Mt(je),onReplaceNext:()=>bt(je),onReview:e=>void Ct(e,je.asset_id),onSelectNext:()=>yt(je),position:F,selectedCount:Ee.length,selectionFull:Oe})]}),Ae&&s&&(0,Y.jsx)(Bm,{actions:{canRemoveFromLineage:Ae.asset_id!==s.root_asset_id,onClearAllNext:()=>void xt(),onClearNext:()=>void xt(Ae.asset_id),onOpenNode:Ot,onRemoveFromLineage:e=>void Mt(e),onReplaceNext:bt,onReview:Ct,onSelectNext:yt,onToast:o,selectedCount:Ee.length,selectionFull:Oe,snapshot:s},attempts:b,node:Ae,onClose:Dt,onPromoteAttempt:kt,project:i}),ke&&s&&(0,Y.jsx)(Km,{canRemoveFromLineage:ke.asset_id!==s.root_asset_id,node:ke,onClearAllNext:()=>void xt(),onClearNext:()=>void xt(ke.asset_id),onClose:()=>_(null),onOpenNode:_,onRemoveFromLineage:e=>void Mt(e),onReplaceNext:bt,onReview:Ct,onSelectNext:yt,onToast:o,selectedCount:Ee.length,selectionFull:Oe,snapshot:s}),we&&k&&s&&(0,Y.jsx)(Ym,{childTitle:s.nodes.find(e=>e.asset_id===we.child_asset_id)?.title||we.child_asset_id,edge:we,onClose:()=>A(null),onSubmit:jt,parentTitle:s.nodes.find(e=>e.asset_id===we.parent_asset_id)?.title||we.parent_asset_id,returnFocus:k.returnFocus}),(0,Y.jsx)(rh,{onClose:()=>R(!1),onCreated:Ye,onToast:o,open:L,project:i})]})}function Oy(e,t,n){let r=`${t}:lineage-workspace:${n}`;return e.filter(e=>e.project!==t||e.status!==`active`||e.derived_state===`expired`?!1:e.scope_type===`lineage_workspace`?e.target_id===r:e.scope_type===`project_channel`)}function ky(e){return{BT:`bottom to top`,LR:`left to right`,RL:`right to left`,TB:`top to bottom`}[e]}function Ay({assets:e,onClose:t,onDone:n,onError:r,project:i}){let a=e[0],[o,s]=(0,p.useState)(!1),[c,l]=(0,p.useState)(!1),[u,d]=(0,p.useState)([]),[f,m]=(0,p.useState)({audience:a?.audience||`local-review`,campaign:a?.campaign||`local-review`,channel:a?.channel===`local`?`meta`:a?.channel||`meta`,cta:a?.cta||`Review before upload`,status:`working`}),h=e.filter(e=>!My(e)),_=h.length>0||e.length===0;function v(e,t){m(n=>({...n,[e]:t}))}function y(e,t){let n=me(e.title)||e.asset_id;return{...f,assetId:n,confirmWrite:o,dryRun:t,hook:e.hook,notes:e.notes,path:e.local?.relative_path,project:i,title:e.title,type:e.content_type,utmContent:e.utm_content||n.replaceAll(`-`,`_`)}}async function b(t){if(_){r(`Local backup is locked until every selected local asset is approved.`);return}l(!0);try{let r=[];for(let n of e){if(!n.local?.relative_path)throw Error(`${n.asset_id} has no local path`);let e=await g(`/api/assets/local-backup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(y(n,t))});r.push(e.message)}t?d(r):await n(`Backed up ${e.length} local asset${e.length===1?``:`s`}`)}catch(e){r(e instanceof Error?e.message:String(e))}finally{l(!1)}}return(0,Y.jsx)(`div`,{className:`drawer-backdrop`,children:(0,Y.jsxs)(`section`,{className:`local-backup-drawer`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:`Back up local assets`}),(0,Y.jsx)(`p`,{children:i})]}),(0,Y.jsx)(`button`,{onClick:t,children:`Close`})]}),(0,Y.jsx)(`div`,{className:`local-backup-list`,children:e.map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:me(e.title)||e.asset_id}),(0,Y.jsx)(`span`,{children:e.local?.relative_path}),(0,Y.jsxs)(`span`,{children:[`Review: `,Ny(jy(e))]})]},e.asset_id))}),_&&(0,Y.jsxs)(`div`,{className:`local-backup-warning`,role:`alert`,children:[(0,Y.jsx)(`strong`,{children:`Backup is locked until local review is approved.`}),e.length===0?(0,Y.jsx)(`span`,{children:`No local assets are selected.`}):null,h.map(e=>(0,Y.jsxs)(`span`,{children:[me(e.title)||e.asset_id,`: `,Ny(jy(e))]},e.asset_id))]}),(0,Y.jsxs)(`div`,{className:`form-grid`,children:[(0,Y.jsxs)(`label`,{children:[`Campaign`,(0,Y.jsx)(`input`,{value:f.campaign,onChange:e=>v(`campaign`,e.target.value)})]}),(0,Y.jsxs)(`label`,{children:[`Channel`,(0,Y.jsx)(`input`,{value:f.channel,onChange:e=>v(`channel`,e.target.value)})]}),(0,Y.jsxs)(`label`,{children:[`Audience`,(0,Y.jsx)(`input`,{value:f.audience,onChange:e=>v(`audience`,e.target.value)})]}),(0,Y.jsxs)(`label`,{children:[`Status`,(0,Y.jsxs)(`select`,{value:f.status,onChange:e=>v(`status`,e.target.value),children:[(0,Y.jsx)(`option`,{children:`working`}),(0,Y.jsx)(`option`,{children:`published`})]})]}),(0,Y.jsxs)(`label`,{className:`wide`,children:[`CTA`,(0,Y.jsx)(`input`,{value:f.cta,onChange:e=>v(`cta`,e.target.value)})]})]}),u.length>0&&(0,Y.jsx)(`div`,{className:`local-backup-preview`,children:u.map(e=>(0,Y.jsx)(`span`,{children:e},e))}),(0,Y.jsxs)(`label`,{className:`confirm-line`,children:[(0,Y.jsx)(`input`,{checked:o,type:`checkbox`,onChange:e=>s(e.target.checked)}),(0,Y.jsx)(`span`,{children:`Confirm write to the production asset bucket`})]}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`button`,{disabled:c||_,onClick:()=>void b(!0),children:`Dry run`}),(0,Y.jsxs)(`button`,{className:`primary-button`,disabled:c||_||!o,onClick:()=>void b(!1),children:[c?(0,Y.jsx)(ee,{className:`spin`,size:16}):(0,Y.jsx)(E,{size:16}),`Back up`]})]})]})})}function jy(e){return e.review?.review_state||`unreviewed`}function My(e){return!!e.local?.relative_path&&jy(e)===`approved`}function Ny(e){return e===`needs_revision`?`needs revision`:e}var Py=[[`unreviewed`,`Needs review`],[`approved`,`Approved keepers`],[`needs_revision`,`Needs revision`],[`rejected`,`Rejected or ignored`]];function Fy(e){let t=e.assets.filter(e=>e.local?.relative_path&&!e.s3?.key),n=t.filter(e=>Ry(e)===`approved`),r=e.selectedBackupIds.length,i=`npx lineage local queue --project ${e.project} --json`;function a(){for(let t of n)e.onQueueBackup(t)}return(0,Y.jsxs)(`section`,{className:`local-backup-queue`,children:[(0,Y.jsxs)(`header`,{className:`backup-queue-head`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:`Local Backup Queue`}),(0,Y.jsx)(`p`,{children:`Review local-only candidates, select approved keepers, then back them up intentionally.`}),(0,Y.jsxs)(`p`,{children:[e.snapshot?.catalog.default_bucket||`No bucket loaded`,` · refreshed `,pe(e.snapshot?.fetchedAt)]})]}),(0,Y.jsxs)(`div`,{className:`backup-queue-actions`,children:[(0,Y.jsxs)(`button`,{disabled:n.length===0,onClick:a,type:`button`,children:[(0,Y.jsx)(w,{size:15}),` Select approved`]}),(0,Y.jsxs)(`button`,{disabled:r===0,onClick:e.onOpenBackup,type:`button`,children:[(0,Y.jsx)(E,{size:15}),` Back up selected`]})]})]}),(0,Y.jsxs)(`div`,{className:`backup-queue-stats`,"aria-label":`Local backup queue summary`,children:[(0,Y.jsx)(Ly,{label:`Local only`,value:t.length}),(0,Y.jsx)(Ly,{label:`Needs review`,value:t.filter(e=>Ry(e)===`unreviewed`).length}),(0,Y.jsx)(Ly,{label:`Approved`,value:n.length}),(0,Y.jsx)(Ly,{label:`Selected`,value:r})]}),(0,Y.jsxs)(`div`,{className:`handoff-strip`,children:[(0,Y.jsx)(`code`,{children:i}),(0,Y.jsxs)(`button`,{onClick:()=>void e.onCopy(i,`local backup queue command`),type:`button`,children:[(0,Y.jsx)(T,{size:14}),` Copy`]})]}),t.length===0?(0,Y.jsx)(`div`,{className:`backup-empty`,children:`No local-only assets are waiting for review or backup.`}):(0,Y.jsx)(`div`,{className:`backup-queue-grid`,children:Py.map(([n,r])=>(0,Y.jsxs)(`section`,{className:`backup-queue-lane`,children:[(0,Y.jsx)(`h3`,{children:r}),t.filter(e=>zy(e)===n).map(t=>(0,Y.jsx)(Iy,{asset:t,onLocalReview:e.onLocalReview,onQueueBackup:e.onQueueBackup,onSelectAsset:e.onSelectAsset,selected:e.selected?.asset_id===t.asset_id,selectedForBackup:e.selectedBackupIds.includes(t.asset_id)},t.asset_id))]},n))}),(0,Y.jsxs)(`footer`,{className:`pagination-bar`,children:[(0,Y.jsx)(`button`,{disabled:!e.snapshot||e.snapshot.pagination.page<=1,onClick:()=>e.setPage(e=>Math.max(e-1,1)),type:`button`,children:`Previous`}),(0,Y.jsxs)(`span`,{children:[e.snapshot?.pagination.page||e.page,` of `,e.snapshot?.pagination.totalPages||1]}),(0,Y.jsx)(`button`,{disabled:!e.snapshot||e.snapshot.pagination.page>=e.snapshot.pagination.totalPages,onClick:()=>e.setPage(e=>e+1),type:`button`,children:`Next`}),(0,Y.jsxs)(`label`,{children:[`Per page`,(0,Y.jsx)(`select`,{onChange:t=>e.setPageSize(Number(t.target.value)),value:e.pageSize,children:[10,25,50,100].map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]})]})]})}function Iy(e){let t=Ry(e.asset),n=be(e.asset),r=t===`approved`;return(0,Y.jsxs)(`article`,{className:`backup-queue-card ${e.selected?`selected`:``}`,children:[(0,Y.jsx)(`strong`,{children:e.asset.title}),(0,Y.jsx)(`code`,{children:e.asset.asset_id}),(0,Y.jsx)(`small`,{children:e.asset.local?.relative_path}),(0,Y.jsxs)(`div`,{className:`backup-card-meta`,children:[(0,Y.jsx)(`span`,{children:n.label}),(0,Y.jsx)(`span`,{children:By(t)}),(0,Y.jsx)(`span`,{children:fe(e.asset.local?.size_bytes)})]}),(0,Y.jsxs)(`div`,{className:`backup-card-actions`,children:[(0,Y.jsx)(`button`,{onClick:()=>e.onSelectAsset(e.asset),type:`button`,children:`Open`}),(0,Y.jsx)(`button`,{"aria-pressed":t===`approved`,onClick:()=>void e.onLocalReview(e.asset,`approved`),type:`button`,children:`Approve`}),(0,Y.jsx)(`button`,{"aria-pressed":t===`needs_revision`,onClick:()=>void e.onLocalReview(e.asset,`needs_revision`),type:`button`,children:`Revise`}),(0,Y.jsx)(`button`,{"aria-pressed":t===`rejected`,onClick:()=>void e.onLocalReview(e.asset,`rejected`),type:`button`,children:`Reject`}),(0,Y.jsx)(`button`,{disabled:!r,onClick:()=>e.onQueueBackup(e.asset),type:`button`,children:e.selectedForBackup?`Selected`:r?`Select backup`:`Approve first`})]})]})}function Ly({label:e,value:t}){return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:t}),(0,Y.jsx)(`span`,{children:e})]})}function Ry(e){return e.review?.review_state||`unreviewed`}function zy(e){let t=Ry(e);return t===`ignored`?`rejected`:t}function By(e){return e===`needs_revision`?`needs revision`:e}function Vy({assets:e,onClear:t,onOpen:n}){return e.length===0?null:(0,Y.jsxs)(`div`,{className:`local-selection-toolbar`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`strong`,{children:[e.length,` local keeper`,e.length===1?``:`s`,` selected`]}),(0,Y.jsx)(`span`,{children:`Ready for S3 backup preflight`})]}),(0,Y.jsxs)(`button`,{onClick:n,children:[(0,Y.jsx)(E,{size:16}),`Back up selected`]}),(0,Y.jsx)(`button`,{"aria-label":`Clear local backup selection`,className:`icon-lite`,onClick:t,children:(0,Y.jsx)(K,{size:16})})]})}function Hy(e){return e.find(e=>Uy(e)>0)?.channel||e[0]?.channel}function Uy(e){return e.totals.needsQa+e.totals.approvedLocal+e.totals.needsRevision+e.totals.rejectedLocal}var Wy=[[`needsQa`,`Needs QA`],[`approvedLocal`,`Approved`],[`needsRevision`,`Revise`],[`rejectedLocal`,`Rejected`],[`readyToPost`,`S3 ready`],[`scheduled`,`Scheduled`],[`posted`,`Posted`]];function Gy(e){let[t,n]=(0,p.useState)(null),[r,i]=(0,p.useState)(null),[a,o]=(0,p.useState)(null),[s,c]=(0,p.useState)([]),[l,u]=(0,p.useState)(``);async function d(){try{let t=new URLSearchParams({project:e.project,limit:`4`});e.channel!==`all`&&t.set(`channel`,e.channel),n(await g(`/api/review/queue?${t.toString()}`)),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}}if((0,p.useEffect)(()=>{d()},[e.project,e.channel]),r)return(0,Y.jsx)(`section`,{className:`review-queue`,children:(0,Y.jsx)(`div`,{className:`toast error`,children:r})});if(!t)return(0,Y.jsx)(`section`,{className:`review-queue`,children:(0,Y.jsx)(`div`,{className:`asset-board`,children:(0,Y.jsx)(`div`,{className:`board-head`,children:(0,Y.jsx)(`h2`,{children:`Loading review queue`})})})});let f=t.totals.needsQa+t.totals.approvedLocal+t.totals.needsRevision+t.totals.rejectedLocal,m=new Set(t.lanes.flatMap(e=>[...e.needsQa,...e.approvedLocal,...e.needsRevision,...e.rejectedLocal]).map(e=>e.asset_id)),h=s.filter(e=>m.has(e)),_=Hy(t.lanes);function v(e){c(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}async function y(t){if(h.length!==0){o(`batch`);try{await g(`/api/local-review/batch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({assetIds:h,confirmWrite:!0,notes:l,project:e.project,reviewState:t})}),c(e=>e.filter(e=>!m.has(e))),u(``),await d()}finally{o(null)}}}return(0,Y.jsxs)(`section`,{className:`review-queue`,children:[(0,Y.jsxs)(`div`,{className:`review-summary`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h2`,{children:[t.project,` review queue`]}),(0,Y.jsx)(`p`,{children:`Local-first queue for demo assets, channel posting state, and agent handoff.`}),(0,Y.jsxs)(`p`,{children:[t.totals.channels,` channels · refreshed `,pe(t.fetchedAt)]})]}),(0,Y.jsx)(Ky,{label:`Local review`,value:f}),(0,Y.jsx)(Ky,{label:`S3 ready`,value:t.totals.readyToPost}),(0,Y.jsx)(Ky,{label:`Scheduled`,value:t.totals.scheduled}),(0,Y.jsx)(Ky,{label:`Posted`,value:t.totals.posted})]}),h.length>0?(0,Y.jsxs)(`div`,{className:`batch-review-strip`,"aria-label":`Batch local review actions`,children:[(0,Y.jsxs)(`strong`,{children:[h.length,` selected`]}),(0,Y.jsx)(`textarea`,{"aria-label":`Shared batch review notes`,onChange:e=>u(e.target.value),placeholder:`Shared review notes`,rows:2,value:l}),(0,Y.jsx)(`button`,{disabled:h.length===0||a===`batch`,onClick:()=>void y(`approved`),type:`button`,children:`Approve`}),(0,Y.jsx)(`button`,{disabled:h.length===0||a===`batch`,onClick:()=>void y(`needs_revision`),type:`button`,children:`Needs revision`}),(0,Y.jsx)(`button`,{disabled:h.length===0||a===`batch`,onClick:()=>void y(`rejected`),type:`button`,children:`Reject`})]}):null,(0,Y.jsx)(`div`,{className:`queue-lanes`,children:t.lanes.map(t=>(0,Y.jsxs)(`details`,{className:`queue-lane`,open:e.channel!==`all`||t.channel===_,children:[(0,Y.jsxs)(`summary`,{children:[(0,Y.jsx)(`h3`,{children:t.channel}),(0,Y.jsxs)(`div`,{className:`lane-counts`,children:[(0,Y.jsxs)(`span`,{children:[t.totals.needsQa,` qa`]}),(0,Y.jsxs)(`span`,{children:[t.totals.approvedLocal,` approved`]}),(0,Y.jsxs)(`span`,{children:[t.totals.needsRevision,` revise`]}),(0,Y.jsxs)(`span`,{children:[t.totals.readyToPost,` ready`]}),(0,Y.jsxs)(`span`,{children:[t.totals.scheduled,` scheduled`]}),(0,Y.jsxs)(`span`,{children:[t.totals.posted,` posted`]})]})]}),(0,Y.jsxs)(`div`,{className:`queue-columns`,children:[Wy.filter(([e])=>t[e].length>0).map(([n,r])=>(0,Y.jsx)(qy,{assets:t[n],label:r,onCopy:e.onCopy,onLocalReview:async(t,n)=>{o(t.asset_id);try{await e.onLocalReview(t,n),await d()}finally{o(null)}},onOpenBackup:e.onOpenBackup,onSelectAsset:e.onSelectAsset,pendingReview:a,selected:e.selected,selectedReviewIds:h,onToggleReviewSelection:v},n)),Wy.every(([e])=>t[e].length===0)&&(0,Y.jsx)(`p`,{className:`review-empty`,children:`No items in this channel.`})]})]},t.channel))})]})}function Ky({label:e,value:t}){return(0,Y.jsxs)(`div`,{className:`queue-stat`,children:[(0,Y.jsx)(`strong`,{children:t}),(0,Y.jsx)(`span`,{children:e})]})}function qy(e){return(0,Y.jsxs)(`div`,{className:`queue-column`,children:[(0,Y.jsx)(`h4`,{children:e.label}),e.assets.map(t=>(0,Y.jsx)(Jy,{asset:t,onCopy:e.onCopy,onLocalReview:e.onLocalReview,onOpenBackup:e.onOpenBackup,onSelectAsset:e.onSelectAsset,onToggleReviewSelection:e.onToggleReviewSelection,pendingReview:e.pendingReview===t.asset_id,selected:e.selected?.asset_id===t.asset_id,selectedForReview:e.selectedReviewIds.includes(t.asset_id)},t.asset_id))]})}function Jy(e){let t=be(e.asset),n=e.asset.local?Yy(e.asset):null,r=n===`approved`,i=e.asset.source===`local`?`npx lineage local inspect --asset-id ${e.asset.asset_id} --json`:`npx lineage inspect --asset-id ${e.asset.asset_id} --json`;return(0,Y.jsxs)(`article`,{className:`queue-card ${e.selected?`selected`:``}`,onClick:()=>e.onSelectAsset(e.asset),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&e.onSelectAsset(e.asset)},role:`button`,tabIndex:0,children:[n?(0,Y.jsxs)(`label`,{className:`confirm-line`,onClick:e=>e.stopPropagation(),onKeyDown:eb,children:[(0,Y.jsx)(`input`,{checked:e.selectedForReview,onChange:()=>e.onToggleReviewSelection(e.asset.asset_id),type:`checkbox`}),(0,Y.jsx)(`span`,{children:`Select for batch review`})]}):null,(0,Y.jsx)(`strong`,{children:e.asset.title}),(0,Y.jsx)(`small`,{children:e.asset.asset_id}),(0,Y.jsxs)(`div`,{className:`lane-counts`,children:[(0,Y.jsx)(`span`,{className:`storage-chip ${t.kind}`,children:t.label}),(0,Y.jsx)(`span`,{className:`queue-tag`,children:Ee(e.asset)}),n?(0,Y.jsx)(`span`,{className:`review-chip ${n}`,children:Xy(n)}):null]}),n?(0,Y.jsxs)(`div`,{className:`review-actions`,"aria-label":`Local review actions for ${e.asset.title}`,onKeyDown:eb,children:[(0,Y.jsx)(`button`,{"aria-pressed":n===`approved`,disabled:e.pendingReview,type:`button`,onClick:t=>Qy(t,e.onLocalReview,e.asset,`approved`),children:`Approve`}),(0,Y.jsx)(`button`,{"aria-pressed":n===`needs_revision`,disabled:e.pendingReview,type:`button`,onClick:t=>Qy(t,e.onLocalReview,e.asset,`needs_revision`),children:`Needs revision`}),(0,Y.jsx)(`button`,{"aria-pressed":n===`rejected`,disabled:e.pendingReview,type:`button`,onClick:t=>Qy(t,e.onLocalReview,e.asset,`rejected`),children:`Reject`})]}):null,(0,Y.jsxs)(`div`,{className:`queue-actions`,onKeyDown:eb,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:t=>Zy(t,e.onCopy,i),children:`Copy inspect`}),e.asset.local?r?(0,Y.jsx)(`button`,{type:`button`,onClick:t=>$y(t,e.onOpenBackup,e.asset),children:`Back up`}):(0,Y.jsx)(`span`,{className:`backup-locked`,title:`Approve this local asset before backup`,children:`Backup locked until approved.`}):null]})]})}function Yy(e){return e.review?.review_state||`unreviewed`}function Xy(e){return e===`needs_revision`?`needs revision`:e}function Zy(e,t,n){e.stopPropagation(),t(n,`inspect command`)}function Qy(e,t,n,r){e.stopPropagation(),t(n,r)}function $y(e,t,n){e.stopPropagation(),t(n)}function eb(e){(e.key===`Enter`||e.key===` `)&&e.stopPropagation()}var tb={channel:`dev`,version:`0.1.17`},nb={cloud:D,image_generator:V,scheduler:ae},rb={cloud:`Cloud storage`,image_generator:`Image generation`,scheduler:`Social scheduling`},ib=[{adapterType:`cloud`,ariaLabel:`Cloud storage settings`},{adapterType:`scheduler`,ariaLabel:`Social scheduling settings`},{adapterType:`image_generator`,ariaLabel:`Image generation settings`}];function ab(e){return typeof e==`boolean`?e?`on`:`off`:typeof e==`number`?String(e):typeof e==`string`?e||`not set`:JSON.stringify(e)}function ob(e){return Object.entries(e.safe_config).filter(([e])=>![`secret`,`token`,`password`,`credential`,`apiKey`].includes(e))}function sb(e){return e.health_status===`configured`?`ok`:e.health_status===`missing_config`?`warn`:`muted`}function cb(e){return(0,Y.jsx)(`button`,{"aria-checked":e.checked,"aria-label":e.label,className:`settings-switch ${e.checked?`on`:``}`,disabled:e.disabled,onClick:e.onClick,role:`switch`,type:`button`,children:(0,Y.jsx)(`span`,{})})}function lb(e){let[t,n]=(0,p.useState)(null),[r,i]=(0,p.useState)(null),[a,s]=(0,p.useState)(!0),[c,l]=(0,p.useState)(``),[u,d]=(0,p.useState)(ym);function f(){let t=!u;if(!bm(t)){e.onToast(`error`,`Browser storage is unavailable, so the hover preview preference could not be saved`);return}d(t),e.onToast(`ok`,`Lineage hover previews ${t?`enabled`:`disabled`}`)}async function m(){s(!0);try{let[t,r]=await Promise.all([g(`/api/adapters/settings?project=${encodeURIComponent(e.project)}`),g(`/api/runtime`)]);n(t),i(r.runtime)}catch(t){e.onToast(`error`,t instanceof Error?t.message:String(t))}finally{s(!1)}}async function h(t){let r=`${t.adapter_type}:${t.provider}`;l(r);try{let r=await g(`/api/adapters/settings/${t.adapter_type}/${t.provider}`,{body:JSON.stringify({confirmWrite:!0,enabled:!t.enabled,project:e.project,safeConfig:t.safe_config}),headers:{"Content-Type":`application/json`},method:`POST`});n(e=>e&&{...e,settings:e.settings.map(e=>e.adapter_type===r.setting.adapter_type&&e.provider===r.setting.provider?r.setting:e)}),e.onToast(`ok`,`${rb[t.adapter_type]} ${r.setting.enabled?`enabled`:`disabled`}`)}catch(t){e.onToast(`error`,t instanceof Error?t.message:String(t))}finally{l(``)}}return(0,p.useEffect)(()=>{m()},[e.project]),(0,Y.jsxs)(`section`,{className:`settings-view`,children:[(0,Y.jsxs)(`header`,{className:`settings-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:`Settings`}),(0,Y.jsxs)(`p`,{children:[`Adapter switches, safe local preferences, and credential-source status for `,e.project,`.`]})]}),(0,Y.jsxs)(`button`,{className:`secondary-button`,disabled:a,onClick:()=>void m(),type:`button`,children:[a?(0,Y.jsx)(ee,{className:`spin`,size:17}):(0,Y.jsx)(o,{size:17}),`Refresh`]})]}),(0,Y.jsxs)(`div`,{className:`settings-sections`,children:[(0,Y.jsxs)(`section`,{"aria-label":`Release information`,className:`settings-section`,children:[(0,Y.jsx)(`h3`,{children:`Release`}),(0,Y.jsxs)(`dl`,{className:`settings-release`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Version`}),(0,Y.jsx)(`dd`,{children:r?.version||tb.version})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Channel`}),(0,Y.jsx)(`dd`,{children:r?.channel||tb.channel})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Profile`}),(0,Y.jsx)(`dd`,{children:r?.profile.id||`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Environment`}),(0,Y.jsx)(`dd`,{children:r?.profile.environment||`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Binding`}),(0,Y.jsx)(`dd`,{children:r?r.profile.bound?`bound`:`legacy unbound`:`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Git`}),(0,Y.jsx)(`dd`,{children:r?.git_sha||`not available`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Assets`}),(0,Y.jsx)(`dd`,{className:`settings-path`,children:r?.asset_root||`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`SQLite`}),(0,Y.jsx)(`dd`,{className:`settings-path`,children:r?.database.path||`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Database`}),(0,Y.jsx)(`dd`,{children:r?.database.exists?`${r.database.projects??0} projects / ${r.database.workspaces??0} workspaces`:`not created yet`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Schema`}),(0,Y.jsx)(`dd`,{children:r?`${r.schema.migration_keys.length} migration marker(s)`:`loading`})]})]})]}),(0,Y.jsxs)(`section`,{"aria-label":`Lineage experience settings`,className:`settings-section`,children:[(0,Y.jsx)(`h3`,{children:`Lineage experience`}),(0,Y.jsx)(`div`,{className:`settings-grid`,children:(0,Y.jsx)(`article`,{className:`settings-card`,children:(0,Y.jsxs)(`div`,{className:`settings-card-head`,children:[(0,Y.jsx)(`span`,{className:`settings-icon`,children:(0,Y.jsx)(N,{size:19})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{children:`Hover previews`}),(0,Y.jsx)(`p`,{children:`Show the full asset and quick Branch/Re-roll/Details actions when hovering over or focusing a lineage node. Double-click details remain available when this is off.`})]}),(0,Y.jsx)(cb,{checked:u,label:`Enable lineage hover previews`,onClick:f})]})})})]}),ib.map(e=>(0,Y.jsxs)(`section`,{"aria-label":e.ariaLabel,className:`settings-section`,children:[(0,Y.jsx)(`h3`,{children:rb[e.adapterType]}),(0,Y.jsx)(`div`,{className:`settings-grid`,children:(t?.settings||[]).filter(t=>t.adapter_type===e.adapterType).map(e=>{let t=nb[e.adapter_type],n=`Enable ${e.label===`Buffer`?`Buffer scheduling`:e.label}`,r=c===`${e.adapter_type}:${e.provider}`;return(0,Y.jsxs)(`article`,{className:`settings-card`,children:[(0,Y.jsxs)(`div`,{className:`settings-card-head`,children:[(0,Y.jsx)(`span`,{className:`settings-icon`,children:(0,Y.jsx)(t,{size:19})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{children:e.label}),(0,Y.jsx)(`p`,{children:e.description})]}),(0,Y.jsx)(cb,{checked:e.enabled,disabled:r,label:n,onClick:()=>void h(e)})]}),(0,Y.jsxs)(`dl`,{className:`settings-meta`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Status`}),(0,Y.jsxs)(`dd`,{className:sb(e),children:[e.health_status===`configured`?(0,Y.jsx)(w,{size:14}):(0,Y.jsx)(C,{size:14}),e.health_status.replace(/_/g,` `)]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Credential source`}),(0,Y.jsx)(`dd`,{children:e.credential.label})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Secret ref`}),(0,Y.jsx)(`dd`,{children:e.credential.secret_ref||`none`})]})]}),ob(e).length>0&&(0,Y.jsx)(`div`,{className:`settings-config`,children:ob(e).map(([e,t])=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:e}),ab(t)]},e))})]},`${e.adapter_type}:${e.provider}`)})})]},e.adapterType)),a&&!t&&(0,Y.jsx)(`div`,{className:`settings-loading`,children:`Loading settings...`})]})]})}var ub=`Lineage`,db=`Local-first creative lineage workspace`;function fb(e){let{channel:t,channels:n,placementStatus:r,project:i,projects:a,setChannel:o,setPlacementStatus:s,setProject:c,setSource:l,setStatus:u,source:d,status:f}=e,[m,h]=(0,p.useState)(!1),[g,_]=(0,p.useState)(!0),v=a.length?a.map(e=>e.project):[i];return(0,Y.jsxs)(`aside`,{className:`sidebar ${g?``:`collapsed`}`,children:[(0,Y.jsx)(`button`,{"aria-label":g?`Collapse sidebar`:`Expand sidebar`,className:`sidebar-collapse-toggle`,onClick:()=>_(e=>!e),type:`button`,children:g?(0,Y.jsx)(te,{size:16}):(0,Y.jsx)(ne,{size:16})}),(0,Y.jsxs)(`div`,{className:`brand`,children:[(0,Y.jsx)(`div`,{className:`brand-mark`,"aria-label":db,children:`L`}),(0,Y.jsxs)(`div`,{className:`brand-copy`,children:[(0,Y.jsx)(`h1`,{children:ub}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`span`,{children:i}),(0,Y.jsxs)(`span`,{"aria-label":`Lineage version ${tb.version}`,className:`brand-version`,title:`Lineage version ${tb.version}, ${tb.channel} channel`,children:[`v`,tb.version]})]})]})]}),(0,Y.jsxs)(`button`,{"aria-controls":`mobile-sidebar-controls`,"aria-expanded":m,className:`mobile-filter-toggle`,onClick:()=>h(e=>!e),type:`button`,children:[(0,Y.jsx)(se,{size:16}),`Filters`,(0,Y.jsx)(S,{className:m?`open`:``,size:16})]}),(0,Y.jsxs)(`div`,{className:`sidebar-mobile-collapse`,"data-open":m,id:`mobile-sidebar-controls`,children:[(0,Y.jsxs)(`div`,{className:`side-section`,children:[(0,Y.jsx)(`h2`,{children:`Project`}),(0,Y.jsx)(pb,{id:`asset-project-filter`,label:`Project`,value:i,values:v,onChange:c})]}),(0,Y.jsxs)(`section`,{className:`side-section`,children:[(0,Y.jsx)(`h2`,{children:`Filters`}),(0,Y.jsx)(pb,{id:`asset-source-filter`,label:`Source`,value:d,values:J,onChange:e=>l(e)}),(0,Y.jsx)(pb,{id:`asset-status-filter`,label:`Status`,value:f,values:q,onChange:e=>u(e)}),(0,Y.jsx)(pb,{id:`asset-channel-filter`,label:`Channel`,value:t,values:n,onChange:o}),(0,Y.jsx)(pb,{id:`asset-placement-filter`,label:`Placement`,value:r,values:ge,onChange:e=>s(e)})]})]})]})}function pb({id:e,label:t,value:n,values:r,onChange:i}){return(0,Y.jsxs)(`label`,{htmlFor:e,children:[t,(0,Y.jsx)(`select`,{"aria-label":t,id:e,value:n,onChange:e=>i(e.target.value),children:r.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]})}var mb=[{label:`Lineage`,view:`lineage`},{label:`Review`,view:`review`},{label:`Assets`,view:`assets`},{label:`Agents`,view:`agents`},{label:`Settings`,view:`settings`}],hb=[{label:`Ledger`,view:`ledger`},{label:`Content batches`,view:`content`},{label:`Backup queue`,view:`backup`}];function gb(e){let t=hb.some(t=>t.view===e.view);function n(t){e.setView(t),e.onMoreOpenChange(!1)}function r(t){e.setView(t),e.onMoreOpenChange(!1)}return(0,Y.jsxs)(`header`,{className:`topbar`,children:[(0,Y.jsxs)(`div`,{className:`view-tabs`,role:`tablist`,"aria-label":`${ub} views`,children:[mb.map(t=>(0,Y.jsx)(`button`,{"aria-pressed":e.view===t.view,className:e.view===t.view?`active`:``,onClick:()=>n(t.view),type:`button`,children:t.label},t.view)),(0,Y.jsxs)(`div`,{className:`more-menu`,children:[(0,Y.jsxs)(`button`,{"aria-expanded":e.moreOpen,"aria-haspopup":`menu`,"aria-pressed":t,className:t?`active`:``,onClick:()=>e.onMoreOpenChange(!e.moreOpen),type:`button`,children:[(0,Y.jsx)(j,{size:16}),` More `,(0,Y.jsx)(S,{className:e.moreOpen?`open`:``,size:15})]}),e.moreOpen&&(0,Y.jsx)(`div`,{className:`more-menu-popover`,role:`menu`,children:hb.map(t=>(0,Y.jsx)(`button`,{"aria-pressed":e.view===t.view,onClick:()=>r(t.view),role:`menuitem`,type:`button`,children:t.label},t.view))})]})]}),(0,Y.jsx)(_b,{runtime:e.runtime,unavailable:e.runtimeIdentityUnavailable}),(0,Y.jsxs)(`div`,{className:`searchbox`,children:[(0,Y.jsx)(ie,{size:17}),(0,Y.jsx)(`input`,{onChange:t=>e.setQuery(t.target.value),placeholder:`Search assets, campaigns, hooks`,value:e.query})]}),e.view!==`lineage`&&(0,Y.jsxs)(`button`,{"aria-expanded":e.assetDetailsOpen,className:`secondary-button`,disabled:!e.canInspectAsset,onClick:()=>{e.onMoreOpenChange(!1),e.setAssetDetailsOpen(!e.assetDetailsOpen)},type:`button`,children:[(0,Y.jsx)(I,{size:17}),`Details`]}),(0,Y.jsx)(`button`,{className:`icon-button`,disabled:e.loading,onClick:()=>void e.refresh(),title:`Refresh current page`,children:e.loading?(0,Y.jsx)(ee,{className:`spin`,size:18}):(0,Y.jsx)(o,{size:18})}),(0,Y.jsxs)(`button`,{className:`primary-button`,onClick:()=>e.setUploadOpen(!0),children:[(0,Y.jsx)(de,{size:17}),`Upload`]})]})}function _b(e){if(e.unavailable)return(0,Y.jsx)(`div`,{"aria-label":`Lineage runtime identity unavailable`,className:`runtime-identity-badge unavailable`,children:`IDENTITY UNAVAILABLE`});if(!e.runtime)return(0,Y.jsx)(`div`,{"aria-label":`Loading Lineage runtime identity`,className:`runtime-identity-badge loading`,children:`IDENTITY LOADING`});let{profile:t}=e.runtime,n=t.bound?``:` · UNBOUND`,r=[`${t.environment.toUpperCase()} profile ${t.id}${t.bound?``:` (unbound)`}`,`Channel ${e.runtime.channel}`,`Version ${e.runtime.version}`,t.warning].filter(Boolean).join(` · `);return(0,Y.jsxs)(`div`,{"aria-label":`Lineage ${t.environment} profile ${t.id}${t.bound?``:` unbound`}`,className:`runtime-identity-badge ${t.environment} ${t.bound?`bound`:`unbound`}`,"data-profile-id":t.id,title:r,children:[(0,Y.jsx)(`strong`,{children:t.environment.toUpperCase()}),(0,Y.jsxs)(`span`,{children:[t.id,n]})]})}function vb({toast:e,onDismiss:t}){return(0,Y.jsxs)(`div`,{className:`toast ${e.type}`,role:`status`,children:[e.type===`ok`?(0,Y.jsx)(w,{size:16}):(0,Y.jsx)(oe,{size:16}),(0,Y.jsx)(`span`,{children:e.message}),(0,Y.jsx)(`button`,{onClick:t,children:`Dismiss`})]})}var yb=200*1024*1024;function bb({channels:e,project:t,onClose:n,onUploaded:r,onError:i}){let[a,o]=(0,p.useState)({assetId:``,audience:`short-form-creators`,campaign:`2026-06-organic-traffic-test`,channel:e[0]||`meta`,cta:``,hook:``,status:`working`,title:``,type:`image`,utmContent:``}),[s,c]=(0,p.useState)(null),[l,u]=(0,p.useState)(!1),[d,f]=(0,p.useState)(!1);function m(e,t){o(n=>({...n,[e]:t}))}function h(e){o(t=>({...t,assetId:t.assetId||me(`demo-${t.channel}-${e}`),title:e,utmContent:t.utmContent||me(e).replaceAll(`-`,`_`)}))}function _(e){if(!e){c(null);return}if(e.size>yb){i(`File is larger than ${fe(yb)}`);return}c(e)}async function v(e){if(e.preventDefault(),!s)return i(`Choose a file before uploading`);f(!0);try{let e=new FormData;Object.entries({project:t,...a,confirmWrite:String(l)}).forEach(([t,n])=>e.append(t,n)),e.append(`file`,s),await r((await g(`/api/assets/upload`,{method:`POST`,body:e})).message)}catch(e){i(e instanceof Error?e.message:String(e))}finally{f(!1)}}return(0,Y.jsx)(`div`,{className:`drawer-backdrop`,children:(0,Y.jsxs)(`form`,{className:`upload-drawer`,onSubmit:v,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:`Upload asset`}),(0,Y.jsx)(`p`,{children:t})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:`Close`})]}),(0,Y.jsxs)(`label`,{className:`file-drop`,children:[(0,Y.jsx)(de,{size:20}),(0,Y.jsx)(`span`,{children:s?s.name:`Choose creative export up to ${fe(yb)}`}),(0,Y.jsx)(`input`,{type:`file`,onChange:e=>_(e.target.files?.[0])})]}),(0,Y.jsxs)(`div`,{className:`form-grid`,children:[(0,Y.jsxs)(`label`,{children:[`Title`,(0,Y.jsx)(`input`,{value:a.title,onChange:e=>h(e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{children:[`Asset ID`,(0,Y.jsx)(`input`,{value:a.assetId,onChange:e=>m(`assetId`,e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{children:[`Campaign`,(0,Y.jsx)(`input`,{value:a.campaign,onChange:e=>m(`campaign`,e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{children:[`Channel`,(0,Y.jsx)(`select`,{value:a.channel,onChange:e=>m(`channel`,e.target.value),children:e.map(e=>(0,Y.jsx)(`option`,{children:e},e))})]}),(0,Y.jsxs)(`label`,{children:[`Audience`,(0,Y.jsx)(`input`,{value:a.audience,onChange:e=>m(`audience`,e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{children:[`Status`,(0,Y.jsxs)(`select`,{value:a.status,onChange:e=>m(`status`,e.target.value),children:[(0,Y.jsx)(`option`,{children:`working`}),(0,Y.jsx)(`option`,{children:`published`})]})]}),(0,Y.jsxs)(`label`,{children:[`Type`,(0,Y.jsx)(`select`,{value:a.type,onChange:e=>m(`type`,e.target.value),children:_e.map(e=>(0,Y.jsx)(`option`,{children:e},e))})]}),(0,Y.jsxs)(`label`,{children:[`UTM content`,(0,Y.jsx)(`input`,{value:a.utmContent,onChange:e=>m(`utmContent`,e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{className:`wide`,children:[`Hook`,(0,Y.jsx)(`input`,{value:a.hook,onChange:e=>m(`hook`,e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`wide`,children:[`CTA`,(0,Y.jsx)(`input`,{value:a.cta,onChange:e=>m(`cta`,e.target.value),required:!0})]})]}),(0,Y.jsxs)(`label`,{className:`confirm-line`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,Y.jsx)(`span`,{children:`Confirm write to the production asset bucket`})]}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,Y.jsxs)(`button`,{className:`primary-button`,disabled:d||!l,children:[d?(0,Y.jsx)(ee,{className:`spin`,size:16}):(0,Y.jsx)(de,{size:16}),`Upload`]})]})]})})}function xb(e,t){let n=`${e} ${t}`.toLowerCase();return n.includes(`agent`)||n.includes(`command`)||n.includes(`selection`)||n.includes(`next context`)}function Sb(){return typeof window>`u`?he:new URLSearchParams(window.location.search).get(`project`)||`demo-project`}function Cb(){let[e,t]=(0,p.useState)(null),[n,r]=(0,p.useState)(null),[i,a]=(0,p.useState)(Sb),[o,s]=(0,p.useState)([]),[c,l]=(0,p.useState)(`all`),[u,d]=(0,p.useState)(`all`),[f,m]=(0,p.useState)(`local`),[h,y]=(0,p.useState)(`all`),[b,x]=(0,p.useState)(``),[S,C]=(0,p.useState)(1),[w,T]=(0,p.useState)(10),[E,D]=(0,p.useState)(!1),[O,k]=(0,p.useState)(!0),[A,j]=(0,p.useState)(null),[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)({}),[I,L]=(0,p.useState)({}),[R,z]=(0,p.useState)([]),[B,V]=(0,p.useState)([]),[H,U]=(0,p.useState)(!1),[W,ee]=(0,p.useState)(!1),[G,te]=(0,p.useState)(`lineage`),[ne,re]=(0,p.useState)(!1),[ie,ae]=(0,p.useState)(null),[oe,se]=(0,p.useState)(0),[ce,le]=(0,p.useState)(null),[ue,de]=(0,p.useState)(!1),[K,fe]=(0,p.useState)(null),pe=(0,p.useCallback)(e=>{fe(t=>e?`lineage-actions`:t===`lineage-actions`?null:t)},[]),me=(0,p.useCallback)(e=>{fe(t=>e?`topbar-more`:t===`topbar-more`?null:t)},[]),he=(0,p.useCallback)((e,t)=>{j({type:e,message:t})},[]),q=e?.catalog.project===i?e:null,ge=q?.assets||[],J=Se(ge,n)||(ie?.project===i&&ie.asset_id===n?ie:void 0),_e=J?.asset_id||``,ve=[...B.filter(e=>R.includes(e.asset_id)),...ge.filter(e=>R.includes(e.asset_id)&&e.local?.relative_path)].filter((e,t,n)=>n.findIndex(t=>t.asset_id===e.asset_id)===t),ye=J&&P[J.asset_id]||null,be=(0,p.useMemo)(()=>[`all`,...q?.facets.channels||[]],[q]),xe=(0,p.useMemo)(()=>({assets:q?.catalog.asset_count||0,live:q?.liveObjects.length||0,orphan:q?.orphanObjects.length||0,size:q?.facets.totalSizeBytes||0}),[q]);async function we(){try{let e=await g(`/api/projects`);s(e.projects),a(t=>e.projects.some(e=>e.project===t)?t:e.projects[0]?.project||`demo-project`)}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}}async function Te(){try{let e=await g(`/api/runtime`);le(e.runtime),de(!1)}catch{le(null),de(!0)}}async function Ee(){k(!0);try{let e=await g(`/api/assets?${De()}`);t(e),r(t=>Se(e.assets,t)?.asset_id||(t&&ie?.asset_id===t?t:null)),F({}),L({})}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}finally{k(!1)}}function De(){let e=new URLSearchParams({project:i,page:String(S),pageSize:String(w),live:String(E),source:f});return c!==`all`&&e.set(`status`,c),u!==`all`&&e.set(`placementStatus`,u),h!==`all`&&e.set(`channel`,h),b.trim()&&e.set(`q`,b.trim()),e.toString()}async function Oe(e){try{let t=await e();j({type:`ok`,message:t.message}),F({}),await Ee()}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}}async function ke(e,t={}){if(!Ce(e))return null;let n=P[e.asset_id];if(n)return t.open&&window.open(n,`_blank`,`noopener,noreferrer`),n;if(e.local?.relative_path){let n=`/api/assets/local-preview?${new URLSearchParams({project:i,path:e.local.relative_path}).toString()}`;return F(t=>({...t,[e.asset_id]:n})),L(t=>({...t,[e.asset_id]:``})),t.open&&window.open(n,`_blank`,`noopener,noreferrer`),n}try{let n=await g(`/api/assets/presign`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,assetId:e.asset_id,expiresIn:900})});return F(t=>({...t,[e.asset_id]:n.url})),L(t=>({...t,[e.asset_id]:``})),t.open&&window.open(n.url,`_blank`,`noopener,noreferrer`),n.url}catch(n){let r=n instanceof Error?n.message:String(n);return L(t=>({...t,[e.asset_id]:r})),t.quiet||j({type:`error`,message:`Preview unavailable. Check S3 credentials or pull the asset locally.`}),null}}async function Ae(e,t){try{let n=await Im(e);j({type:`ok`,message:n.method===`fallback`?`Copied ${t} using browser fallback`:`Copied ${t}`}),N(xb(t,e)?{label:t,text:e}:null)}catch(n){N(xb(t,e)?{label:t,text:e}:null),j({type:`error`,message:n instanceof Error?n.message:String(n)})}}async function Me(e){let t=await ke(e,{quiet:!0});t&&await Ae(t,`preview link`)}function Ne(e){e.local?.relative_path&&(z(t=>t.includes(e.asset_id)?t:[...t,e.asset_id]),V(t=>t.some(t=>t.asset_id===e.asset_id)?t:[...t,e]))}function Pe(e){ae(e),r(e.asset_id),re(!0)}async function Fe(e){r(e),re(!0);let t=ge.find(t=>t.asset_id===e);if(t){ae(t);return}try{let t=await g(`/api/assets/lookup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,assetIds:[e]})});t.assets[0]&&ae(t.assets[0])}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}}function Re(){m(`local`),l(`all`),d(`all`),x(``),te(`backup`)}async function ze(e){try{e.assetId&&r(e.assetId),e.view===`lineage`&&e.workspaceId&&await g(`/api/lineage-workspaces/${encodeURIComponent(e.workspaceId)}/activate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})}),re(!1),te(e.view),j({type:`ok`,message:`Opened ${e.claim.target_title||e.claim.target_id}`})}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}}function Be(e){e.local?.relative_path&&(z(t=>t.includes(e.asset_id)?t.filter(t=>t!==e.asset_id):[...t,e.asset_id]),V(t=>t.filter(t=>t.asset_id!==e.asset_id)))}return(0,p.useEffect)(()=>{we(),Te()},[]),(0,p.useEffect)(()=>{let e=new URLSearchParams(window.location.search);e.get(`project`)!==i&&(e.set(`project`,i),window.history.replaceState(null,``,`${window.location.pathname}?${e.toString()}${window.location.hash}`))},[i]),(0,p.useEffect)(()=>{j(null),N(null),ae(null),re(!1)},[i]),(0,p.useEffect)(()=>{Ee()},[S,w,i,c,u,f,h,b,E]),(0,p.useEffect)(()=>{C(1)},[i,c,u,f,h,b,w]),(0,p.useEffect)(()=>{!Ce(J)||P[J.asset_id]||ke(J,{quiet:!0})},[J?.asset_id,J?.s3?.version_id,P]),(0,p.useEffect)(()=>{if(A?.type!==`ok`)return;let e=window.setTimeout(()=>j(null),2600);return()=>window.clearTimeout(e)},[A?.message,A?.type]),(0,p.useEffect)(()=>{G===`backup`&&(m(`local`),l(`all`),d(`all`))},[G]),(0,p.useEffect)(()=>{fe(null)},[G]),(0,p.useEffect)(()=>{_e||re(!1)},[_e]),(0,Y.jsxs)(`div`,{className:`app-shell ${G===`lineage`?`lineage-mode`:``}`,children:[(0,Y.jsx)(fb,{channel:h,channels:be,liveSync:E,placementStatus:u,project:i,projects:o,setChannel:y,setPlacementStatus:d,setProject:a,setSource:m,setStatus:l,setView:te,showBackupQueue:Re,source:f,snapshot:q,status:c,totals:xe}),(0,Y.jsxs)(`main`,{className:`workspace`,children:[(0,Y.jsx)(gb,{assetDetailsOpen:ne,canInspectAsset:!!J,loading:O,moreOpen:K===`topbar-more`,onMoreOpenChange:me,query:b,refresh:Ee,runtime:ce,runtimeIdentityUnavailable:ue,setAssetDetailsOpen:re,setQuery:x,setUploadOpen:ee,setView:e=>e===`backup`?Re():te(e),view:G}),A&&(0,Y.jsx)(vb,{toast:A,onDismiss:()=>j(null)}),M&&(0,Y.jsx)(xt,{copiedText:M,onDismiss:()=>N(null)}),(0,Y.jsx)(Et,{onCopy:Ae,project:i,refreshKey:oe,selectedAsset:J,view:G}),G===`review`?(0,Y.jsx)(Gy,{channel:h,onCopy:Ae,onLocalReview:async(e,t)=>{await Oe(()=>_(`/api/local-review/${e.asset_id}`,i,{reviewState:t,confirmWrite:!0}))},onOpenBackup:e=>{Ne(e),U(!0)},onSelectAsset:e=>{Pe(e)},project:i,selected:J}):G===`ledger`?(0,Y.jsx)(zt,{project:i,query:b,onOpenAsset:Fe}):G===`content`?(0,Y.jsx)(ht,{onCopy:Ae,onOpenAsset:Fe,onToast:he,onWorkTargetsChanged:()=>se(e=>e+1),project:i,selectedAsset:J}):G===`agents`?(0,Y.jsx)(Le,{onCopy:Ae,onOpenWork:ze,project:i}):G===`backup`?(0,Y.jsx)(Fy,{assets:ge,onCopy:Ae,onLocalReview:async(e,t)=>{await Oe(()=>_(`/api/local-review/${e.asset_id}`,i,{reviewState:t,confirmWrite:!0}))},onOpenBackup:()=>U(!0),onQueueBackup:Ne,onSelectAsset:e=>{Pe(e)},page:S,pageSize:w,project:i,selected:J,selectedBackupIds:R,setPage:C,setPageSize:T,snapshot:q}):G===`assets`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Vy,{assets:ve,onClear:()=>{z([]),V([])},onOpen:()=>U(!0)}),(0,Y.jsx)(Ie,{assets:ge,liveSync:E,onCopy:Ae,onSelectionChanged:()=>se(e=>e+1),page:S,pageSize:w,previewUrls:P,project:i,selected:J,setLiveSync:D,setPage:C,setPageSize:T,setSelectedId:r,snapshot:q,source:f,totals:xe})]}):G===`settings`?(0,Y.jsx)(lb,{onToast:he,project:i}):(0,Y.jsx)(Dy,{asset:J,actionsOpen:K===`lineage-actions`,onAssetsChanged:Ee,onActionsOpenChange:pe,onSelectedAsset:r,onToast:he,project:i})]}),G!==`lineage`&&ne&&(0,Y.jsx)(je,{asset:J,onArchive:e=>void Oe(()=>_(`/api/assets/archive`,i,{assetId:e.asset_id,confirmArchive:!0})),onClose:()=>re(!1),onCopy:(e,t)=>void Ae(e,t),onCopyPreview:e=>void Me(e),onDelete:(e,t)=>void Oe(()=>_(`/api/assets/delete-object`,i,{assetId:e.asset_id,confirmation:t})),onPlacement:(e,t,n)=>void Oe(()=>_(`/api/assets/placement`,i,{assetId:e.asset_id,channel:e.channel,...v(n),status:t,confirmWrite:!0})),onPresign:e=>void ke(e,{open:!0}),onPromote:e=>void Oe(()=>_(`/api/assets/promote`,i,{assetId:e.asset_id,confirmWrite:!0})),onPull:e=>void Oe(()=>_(`/api/assets/pull`,i,{assetId:e.asset_id,out:`.asset-scratch`})),onToggleBackup:Be,previewError:J&&I[J.asset_id]||null,previewUrl:ye,selectedForBackup:J?R.includes(J.asset_id):!1}),W&&(0,Y.jsx)(bb,{channels:be.filter(e=>e!==`all`),project:i,onClose:()=>ee(!1),onError:e=>j({type:`error`,message:e}),onUploaded:async e=>{j({type:`ok`,message:e}),ee(!1),await Ee()}}),H&&(0,Y.jsx)(Ay,{assets:ve,project:i,onClose:()=>U(!1),onError:e=>j({type:`error`,message:e}),onDone:async e=>{j({type:`ok`,message:e}),z([]),V([]),U(!1),await Ee()}})]})}(0,m.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(p.StrictMode,{children:(0,Y.jsx)(Cb,{})}));
16
+ `)}function mh(e){let{activeNode:t,brief:n,childAssetId:r,clearNextVariation:i,closePanel:a,latestNodes:o,linkChild:s,markReview:c,noteDirty:l,onSelectedAsset:u,nextVariationLimit:d,onToast:f,project:p,refreshBrief:m,saveRationale:h,selectNextBase:g,selectedNode:_,selectedNodes:v,selectionFull:y,refreshLineage:b,replaceNextVariation:x,selectionNote:S,setActiveNodeId:C,setChildAssetId:w,setDetailNodeId:T,setSelected:E,setSelectionNote:D,sideOpen:O,snapshot:k}=e,A=t?ye({hasLocal:!!t.local_path,hasS3:!!t.s3_key}):null,j=v.filter(e=>!e.is_latest),M=k.nodes.filter(e=>e.reroll_request?.status===`pending`);return(0,Y.jsxs)(`aside`,{"aria-hidden":!O,className:`lineage-side ${O?``:`collapsed`}`,id:`lineage-selection-panel`,children:[(0,Y.jsxs)(`div`,{className:`lineage-side-head`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{children:`Next variation`}),(0,Y.jsx)(`p`,{className:`muted-copy`,children:`Choose what the agent will evolve next; double-click nodes for full details.`})]}),(0,Y.jsx)(`button`,{"aria-label":`Close lineage selection panel`,className:`icon-button`,onClick:a,type:`button`,children:`×`})]}),(0,Y.jsxs)(`section`,{className:`lineage-next-panel`,children:[(0,Y.jsxs)(`div`,{className:`lineage-panel-title-row`,children:[(0,Y.jsx)(`h3`,{children:`Using for next variation`}),(0,Y.jsxs)(`span`,{className:`lineage-count-pill ${y?`full`:``}`,children:[v.length,`/`,d]})]}),v.length>0&&(0,Y.jsx)(`div`,{className:`lineage-panel-action-row`,children:(0,Y.jsx)(`button`,{onClick:()=>void i(),type:`button`,children:`Clear all`})}),j.length>0&&(0,Y.jsxs)(`div`,{className:`lineage-selection-warning`,role:`status`,children:[j.length,` selected asset`,j.length===1?` is`:`s are`,` not latest. This is valid for branching, but clear or replace it if you meant to continue from the newest leaves.`]}),v.length>0?v.map(e=>(0,Y.jsxs)(`div`,{className:`lineage-candidate selected`,children:[(0,Y.jsxs)(`button`,{"aria-label":`Inspect asset used for next variation ${e.title}`,className:`lineage-candidate-main`,onClick:()=>{C(e.asset_id),u(e.asset_id)},children:[(0,Y.jsx)(`span`,{children:e.title}),(0,Y.jsx)(`code`,{children:e.asset_id}),(0,Y.jsx)(ah,{node:e})]}),!e.is_latest&&(0,Y.jsx)(`span`,{className:`lineage-candidate-warning`,children:`Not latest`}),(0,Y.jsxs)(`div`,{className:`lineage-candidate-actions`,children:[v.length>1&&(0,Y.jsx)(`button`,{className:`lineage-candidate-action secondary`,onClick:()=>x(e),children:`Use only this`}),(0,Y.jsx)(`button`,{className:`lineage-candidate-action remove`,onClick:()=>void i(e.asset_id),children:`Remove`})]})]},e.asset_id)):(0,Y.jsxs)(`p`,{className:`muted-copy`,children:[`Choose up to `,d,` assets to guide the next generation.`]}),v.length>1&&(0,Y.jsx)(`p`,{className:`muted-copy`,children:`The agent will use these as separate next-variation bases; imported outputs should link back to the matching selected parent.`})]}),(0,Y.jsx)(hh,{activeNode:t,onSelectedAsset:u,onToast:f,project:p,refreshLineage:b,setActiveNodeId:C,snapshot:k}),(0,Y.jsxs)(`section`,{className:`lineage-next-panel`,children:[(0,Y.jsxs)(`div`,{className:`lineage-panel-title-row`,children:[(0,Y.jsx)(`h3`,{children:`Re-roll queue`}),(0,Y.jsx)(`span`,{className:`lineage-count-pill`,children:M.length})]}),M.length>0?M.map(e=>(0,Y.jsx)(`div`,{className:`lineage-candidate ${e.asset_id===t?.asset_id?`active`:``}`,children:(0,Y.jsxs)(`button`,{"aria-label":`Inspect re-roll target ${e.title}`,className:`lineage-candidate-main`,onClick:()=>{C(e.asset_id),u(e.asset_id)},children:[(0,Y.jsx)(`span`,{children:e.title}),(0,Y.jsx)(`code`,{children:e.asset_id}),e.reroll_request?.notes&&(0,Y.jsx)(`small`,{children:e.reroll_request.notes})]})},e.asset_id)):(0,Y.jsx)(`p`,{className:`muted-copy`,children:`No pending re-roll targets.`})]}),(0,Y.jsxs)(`section`,{className:`lineage-next-panel`,children:[(0,Y.jsx)(`h3`,{children:`Latest candidates`}),o.length>0?o.map(e=>{let n=!e.user_selected&&y;return(0,Y.jsxs)(`div`,{className:`lineage-candidate ${e.asset_id===t?.asset_id?`active`:``} ${e.user_selected?`selected`:``}`,children:[(0,Y.jsxs)(`button`,{"aria-label":`Inspect ${e.title}`,className:`lineage-candidate-main`,onClick:()=>{C(e.asset_id),u(e.asset_id)},children:[(0,Y.jsx)(`span`,{children:e.title}),(0,Y.jsx)(`code`,{children:e.asset_id}),(0,Y.jsx)(ah,{node:e})]}),(0,Y.jsxs)(`div`,{className:`lineage-candidate-actions`,children:[(0,Y.jsx)(`button`,{"aria-label":e.user_selected?`Remove ${e.title} from next variation`:`Use ${e.title} for next variation`,className:`lineage-candidate-action ${e.user_selected?`remove`:``}`,disabled:n,onClick:()=>e.user_selected?void i(e.asset_id):g(e),children:e.user_selected?`Remove`:n?`Selection full`:`Use for next variation`}),!e.user_selected&&v.length>0&&(0,Y.jsx)(`button`,{className:`lineage-candidate-action secondary`,onClick:()=>x(e),children:`Replace selection`})]})]},e.asset_id)}):(0,Y.jsx)(`p`,{className:`muted-copy`,children:`No latest leaves yet.`})]}),(0,Y.jsx)(oh,{brief:n,nextBase:_,onRefreshBrief:()=>void m(),onToast:f,project:p,rerollTargets:M,rootAssetId:k.root_asset_id}),(0,Y.jsx)(`h3`,{children:`Inspecting`}),t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`strong`,{children:t.title}),(0,Y.jsx)(`code`,{children:t.asset_id}),(0,Y.jsxs)(`dl`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Storage`}),(0,Y.jsx)(`dd`,{children:A&&(0,Y.jsx)(`span`,{className:`storage-chip ${A.kind}`,children:A.label})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Source`}),(0,Y.jsx)(`dd`,{children:t.source})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Review`}),(0,Y.jsx)(`dd`,{children:t.review_state})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Latest`}),(0,Y.jsx)(`dd`,{children:t.is_latest?`yes`:`no`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Next variation`}),(0,Y.jsx)(`dd`,{children:t.user_selected?`yes`:`no`})]})]}),t.user_selected&&!t.is_latest&&(0,Y.jsx)(`div`,{className:`lineage-selection-warning`,role:`status`,children:`This selected asset is not a latest leaf. Keep it selected to branch from an earlier idea, or replace it with the current inspected asset.`}),(0,Y.jsxs)(`label`,{className:`lineage-note-field`,children:[`Variation rationale`,(0,Y.jsx)(`textarea`,{value:S,onChange:e=>D(e.target.value),placeholder:`Why should the next generation branch from this asset?`}),(0,Y.jsx)(`span`,{className:`lineage-note-status ${l?`dirty`:``}`,children:t.user_selected?l?`Unsaved rationale`:`Rationale saved for next variation`:`Rationale saves when this is used for next variation`})]}),(0,Y.jsxs)(`div`,{className:`lineage-side-actions`,children:[(0,Y.jsx)(`button`,{"aria-label":t.user_selected?`Remove ${t.title} from next variation`:`Use ${t.title} for next variation`,className:`primary-lite`,disabled:!t.user_selected&&y,onClick:()=>t.user_selected?void i(t.asset_id):E(),children:t.user_selected?`Remove from next variation`:y?`Selection full`:`Use for next variation`}),t.user_selected&&v.length>1&&(0,Y.jsx)(`button`,{onClick:()=>x(t,S),children:`Use only this`}),!t.user_selected&&v.length>0&&(0,Y.jsx)(`button`,{onClick:()=>x(t,S),children:`Replace selection`}),(0,Y.jsx)(`button`,{disabled:!t.user_selected||!l,onClick:h,children:`Save rationale`}),(0,Y.jsx)(`button`,{"aria-label":`Open detail for ${t.title}`,onClick:()=>T(t.asset_id),children:`Open detail`}),(0,Y.jsx)(`button`,{"aria-label":`Approve ${t.title}`,onClick:()=>void c(`approved`),children:`Approve`}),(0,Y.jsx)(`button`,{"aria-label":`Reject ${t.title}`,onClick:()=>void c(`rejected`),children:`Reject`}),(0,Y.jsx)(`button`,{"aria-label":`Ignore ${t.title}`,onClick:()=>void c(`ignored`),children:`Ignore`})]}),(0,Y.jsxs)(`form`,{className:`lineage-link-form`,onSubmit:e=>{e.preventDefault(),s()},children:[(0,Y.jsxs)(`label`,{children:[`Child asset ID`,(0,Y.jsx)(`input`,{value:r,onChange:e=>w(e.target.value),placeholder:`local-... or catalog id`})]}),(0,Y.jsx)(`button`,{disabled:!r.trim(),type:`submit`,children:`Link child`})]})]}):(0,Y.jsx)(`p`,{className:`muted-copy`,children:`No lineage node selected.`})]})}function hh({activeNode:e,onSelectedAsset:t,onToast:n,project:r,refreshLineage:i,setActiveNodeId:a,snapshot:o}){let s=(0,p.useMemo)(()=>vh(o.tasks||[]),[o.tasks]),c=s.filter(e=>yh(e)).length,l=(0,p.useMemo)(()=>new Map(o.nodes.map(e=>[e.asset_id,e])),[o.nodes]);return(0,Y.jsxs)(`section`,{className:`lineage-next-panel lineage-task-queue-panel`,children:[(0,Y.jsxs)(`div`,{className:`lineage-panel-title-row`,children:[(0,Y.jsx)(`h3`,{children:`Task queue`}),(0,Y.jsx)(`span`,{className:`lineage-count-pill`,children:c})]}),s.length>0?s.map(o=>(0,Y.jsx)(gh,{active:o.target_asset_id===e?.asset_id,node:l.get(o.target_asset_id),onInspect:()=>{a(o.target_asset_id),t(o.target_asset_id)},onToast:n,project:r,refreshLineage:i,task:o},`${o.id}:${o.updated_at}`)):(0,Y.jsx)(`p`,{className:`muted-copy`,children:`No open lineage tasks.`})]})}function gh({active:e,node:t,onInspect:n,onToast:r,project:i,refreshLineage:a,task:o}){let s=o.status===`claimed`||o.status===`in_progress`,c=o.status===`pending`,[l,u]=(0,p.useState)(o.instructions||``),[d,f]=(0,p.useState)(``),[m,h]=(0,p.useState)(!1);(0,p.useEffect)(()=>u(o.instructions||``),[o.id,o.instructions]);async function _(e,t,n){h(!0);try{return await g(e,{body:JSON.stringify({project:i,...t}),headers:{"Content-Type":`application/json`},method:`POST`}),r(`ok`,n),await a(),!0}catch(e){return r(`error`,e instanceof Error?e.message:String(e)),!1}finally{h(!1)}}async function v(e){e.preventDefault(),await _(`/api/lineage/tasks/${encodeURIComponent(o.id)}/instructions`,{instructions:l},`Updated ${xh(o)} instructions`)}async function y(e){e.preventDefault();let t=d.trim();t&&await _(`/api/lineage/tasks/${encodeURIComponent(o.id)}/comment`,{actor:`human`,message:t},`Commented on ${xh(o)}`)&&f(``)}async function b(){window.confirm(`Unlock ${xh(o)} for human edits?`)&&await _(`/api/lineage/tasks/${encodeURIComponent(o.id)}/override`,{actor:`human`,reason:`Human unlocked task from lineage UI.`},`Unlocked ${xh(o)}`)}async function x(){window.confirm(s?`Cancel ${xh(o)} while an agent is working?`:`Cancel ${xh(o)}?`)&&await _(`/api/lineage/tasks/${encodeURIComponent(o.id)}/cancel`,{actor:`human`,confirmWrite:!0,override:s},`Cancelled ${xh(o)}`)}return(0,Y.jsxs)(`article`,{className:`lineage-task-card ${e?`active`:``} ${s?`locked`:o.status}`,children:[(0,Y.jsxs)(`button`,{"aria-label":`Inspect task target ${t?.title||o.target_asset_id}`,className:`lineage-task-target`,onClick:n,type:`button`,children:[(0,Y.jsx)(`span`,{children:t?.title||o.target_asset_id}),(0,Y.jsx)(`code`,{children:o.target_asset_id})]}),(0,Y.jsxs)(`div`,{className:`lineage-task-meta`,children:[(0,Y.jsx)(`span`,{className:`lineage-task-status ${o.status}`,children:bh(o.status)}),(0,Y.jsx)(`span`,{children:o.task_type})]}),c?(0,Y.jsxs)(`form`,{className:`lineage-task-form`,onSubmit:v,children:[(0,Y.jsxs)(`label`,{children:[`Instructions`,(0,Y.jsx)(`textarea`,{"aria-label":`Instructions for ${o.id}`,value:l,onChange:e=>u(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`lineage-task-actions`,children:[(0,Y.jsx)(`button`,{disabled:m||l===(o.instructions||``),type:`submit`,children:`Save instructions`}),(0,Y.jsx)(`button`,{disabled:m,onClick:x,type:`button`,children:`Cancel`})]})]}):(0,Y.jsxs)(`div`,{className:`lineage-task-locked-body`,children:[(0,Y.jsxs)(`label`,{children:[`Instructions`,(0,Y.jsx)(`textarea`,{"aria-label":`Locked instructions for ${o.id}`,disabled:!0,readOnly:!0,value:l||`No instructions.`})]}),s&&(0,Y.jsx)(_h,{claim:o.active_claim}),s&&(0,Y.jsxs)(`form`,{className:`lineage-task-form`,onSubmit:y,children:[(0,Y.jsxs)(`label`,{children:[`Comment`,(0,Y.jsx)(`textarea`,{"aria-label":`Comment for ${o.id}`,value:d,onChange:e=>f(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`lineage-task-actions`,children:[(0,Y.jsx)(`button`,{disabled:m||!d.trim(),type:`submit`,children:`Add comment`}),(0,Y.jsx)(`button`,{disabled:m,onClick:b,type:`button`,children:`Unlock`}),(0,Y.jsx)(`button`,{disabled:m,onClick:x,type:`button`,children:`Cancel`})]})]})]})]})}function _h({claim:e}){return e?(0,Y.jsxs)(`p`,{className:`lineage-task-claim ${e.derived_state===`active`?`active`:e.derived_state}`,children:[(0,Y.jsxs)(`span`,{children:[bh(e.derived_state),` claim`]}),(0,Y.jsx)(`strong`,{children:e.agent_name})]}):(0,Y.jsx)(`p`,{className:`lineage-task-claim`,children:`Claimed by agent`})}function vh(e){return[...e].sort((e,t)=>{let n=+!yh(e),r=+!yh(t);return n===r?e.created_at.localeCompare(t.created_at):n-r})}function yh(e){return e.status===`pending`||e.status===`claimed`||e.status===`in_progress`}function bh(e){return e.replace(/_/g,` `)}function xh(e){return`${e.task_type} task`}function Sh(e,t){return e?.root_asset_id||t||``}function Ch(e){return`${e.title} (${e.root_asset_id})`}function wh(e,t){let n=`${t.project}:lineage-workspace:${t.root_asset_id}`;return e.filter(e=>e.project!==t.project||e.status!==`active`||e.derived_state===`expired`?!1:e.scope_type===`lineage_workspace`?e.target_id===t.id||e.target_id===n:e.scope_type===`project_channel`)}function Th(e){return e.some(e=>e.derived_state===`stale`)?`stale`:e.some(e=>e.derived_state===`idle`)?`idle`:`active`}function Eh(e){let t=Th(e);return e.length===1?`${t===`active`?`Claimed`:t===`idle`?`Idle claim`:`Stale claim`} by ${e[0].agent_name}`:`${e.length} active claims`}function Dh({activeWorkspace:e,closeSignal:t,loading:n,onNewLineage:r,onRefresh:i,onSelect:a,workspaces:o}){let[s,c]=(0,p.useState)(!1),[l,u]=(0,p.useState)([]),d=(0,p.useRef)(null),f=e?.project||o[0]?.project||``;(0,p.useEffect)(()=>{function e(e){d.current?.contains(e.target)||c(!1)}function t(e){e.key===`Escape`&&c(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0)}},[]),(0,p.useEffect)(()=>{c(!1)},[t]),(0,p.useEffect)(()=>{if(!f){u([]);return}let e=!1;return g(`/api/agent-claims?${new URLSearchParams({project:f})}`).then(t=>{e||u(t.claims)}).catch(()=>{e||u([])}),()=>{e=!0}},[f,t,o.length]);function m(e){c(!1),a(e)}let h=e?wh(l,e):[];return(0,Y.jsxs)(`section`,{"aria-label":`Lineage workspace picker`,className:`lineage-workspace-picker`,ref:d,children:[(0,Y.jsxs)(`button`,{"aria-expanded":s,"aria-haspopup":`listbox`,className:`lineage-workspace-trigger`,disabled:n,onClick:()=>c(e=>!e),onKeyDown:e=>{e.key===`Escape`&&c(!1)},type:`button`,children:[(0,Y.jsx)(`span`,{children:`Workspace`}),(0,Y.jsx)(`strong`,{children:e?.title||`No workspace selected`}),(0,Y.jsx)(`code`,{children:e?.root_asset_id||`Start with New lineage`}),(0,Y.jsx)(kh,{claims:h})]}),s&&(0,Y.jsxs)(`div`,{className:`lineage-workspace-menu`,children:[(0,Y.jsxs)(`div`,{className:`lineage-workspace-options`,role:`listbox`,children:[o.length===0&&(0,Y.jsx)(`p`,{children:`No workspaces yet.`}),o.map(t=>(0,Y.jsx)(Oh,{active:e?.id===t.id,claims:wh(l,t),onSelect:()=>m(t.id),workspace:t},t.id))]}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`button`,{className:`secondary-button`,disabled:n,onClick:i,type:`button`,children:`Refresh`}),(0,Y.jsx)(`button`,{className:`primary-button`,onClick:()=>{c(!1),r()},type:`button`,children:`New lineage`})]})]})]})}function Oh({active:e,claims:t,onSelect:n,workspace:r}){return(0,Y.jsxs)(`button`,{"aria-selected":e,className:e?`active`:``,onClick:n,role:`option`,type:`button`,children:[(0,Y.jsx)(`strong`,{children:r.title}),(0,Y.jsx)(`code`,{children:r.root_asset_id}),(0,Y.jsx)(`span`,{children:Ch(r)}),(0,Y.jsx)(kh,{claims:t})]})}function kh({claims:e}){return e.length===0?null:(0,Y.jsxs)(`small`,{className:`lineage-workspace-claim ${Th(e)}`,children:[(0,Y.jsx)(oe,{size:13}),(0,Y.jsx)(`span`,{children:Eh(e)})]})}function Ah({activeWorkspace:e,actionsOpen:t,closeSignal:n,demoSeedStatus:r,edgeSummariesVisible:i,graphDirection:a,loading:o,onArchiveWorkspace:s,onActionsOpenChange:c,onDownloadSwissifierMedia:l,onEdgeSummariesVisible:u,onFitGraph:d,onGraphDirection:f,onIndexLocal:m,onNewLineage:h,onRefreshLineage:g,onRefreshWorkspaces:_,onReplayGrowth:v,onRestoreDemoMedia:y,onRestoreSwissifierMedia:b,onSeedDemo:x,onSeedSwissifierDemo:S,onSelectWorkspace:C,onTidyGraph:w,onToggleNextPanel:T,sideOpen:E,replayActive:D,snapshot:O,swissifierDemoStatus:k,workspaceLoading:A,workspaceProgress:j,workspaceRootAssetId:M,workspaces:N}){let P=r?`${r.present}/${r.total} SVG placeholders`:`Checking media`,F=k?`${k.present}/${k.total} PNG images`:`Checking media`,I=!!(k&&k.present===k.total),L=!!(k?.download_available&&!I),R=j===`downloading`?`Downloading rich demo media`:j===`downloaded`?`Rich demo media ready to seed`:j===`seeding`?`Creating rich demo workspace`:j===`indexing`?`Indexing 14 rich demo images`:j===`ready`?`Rich demo ready`:j===`error`?`Rich demo setup failed`:null,z=A||[`downloading`,`seeding`,`indexing`].includes(j||``),B=R||(O?`${O.nodes.length} nodes · ${O.edges.length} links`:M||`Choose a lineage workspace`);(0,p.useEffect)(()=>{c(!1)},[n,c]),(0,p.useEffect)(()=>{function e(e){e.key===`Escape`&&c(!1)}return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[c]);function V(e){c(!1),e()}function H(e){e.key===`Escape`&&(e.preventDefault(),c(!1))}return(0,Y.jsxs)(`header`,{className:`lineage-header`,children:[(0,Y.jsxs)(`div`,{className:`lineage-primary-controls`,children:[(0,Y.jsx)(Dh,{activeWorkspace:e,closeSignal:n,loading:z,onNewLineage:h,onRefresh:_,onSelect:C,workspaces:N}),(0,Y.jsx)(`p`,{className:`lineage-toolbar-context`,children:B}),(0,Y.jsx)(`button`,{"aria-pressed":D,className:`secondary-button lineage-replay-launch`,disabled:D||!O||O.nodes.length<2||O.edges.length===0,onClick:v,type:`button`,children:`Replay growth`}),(0,Y.jsx)(`button`,{className:`primary-button`,onClick:h,type:`button`,children:`New lineage`})]}),(0,Y.jsxs)(`details`,{className:`lineage-overflow`,onToggle:e=>c(e.currentTarget.open),open:t,children:[(0,Y.jsx)(`summary`,{onKeyDown:H,tabIndex:0,children:`Actions`}),(0,Y.jsxs)(`div`,{children:[!e&&(0,Y.jsx)(`button`,{disabled:z,onClick:()=>V(x),type:`button`,children:`Load demo lineage`}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`QA seed media`}),(0,Y.jsx)(`span`,{children:F})]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Basic SVG demo`}),(0,Y.jsx)(`span`,{children:P})]}),(0,Y.jsx)(`button`,{disabled:z||r?.present===r?.total,onClick:y,type:`button`,children:`Restore basic media`}),(0,Y.jsx)(`button`,{disabled:z,onClick:()=>V(x),type:`button`,children:`Load SVG placeholder demo`}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Swissifier rich demo`}),(0,Y.jsx)(`span`,{children:F})]}),(0,Y.jsx)(`button`,{disabled:z||!L,onClick:l,type:`button`,children:`Download rich images`}),(0,Y.jsx)(`button`,{disabled:z||I,onClick:b,type:`button`,children:`Restore rich media`}),(0,Y.jsx)(`button`,{disabled:z,onClick:()=>V(S),type:`button`,children:`Load rich image demo`}),(0,Y.jsxs)(`label`,{className:`lineage-action-select`,children:[(0,Y.jsx)(`span`,{children:`Direction`}),(0,Y.jsxs)(`select`,{"aria-label":`Lineage graph direction`,disabled:!O||o,onChange:e=>f(e.target.value),value:a,children:[(0,Y.jsx)(`option`,{value:`LR`,children:`Left to right`}),(0,Y.jsx)(`option`,{value:`TB`,children:`Top to bottom`}),(0,Y.jsx)(`option`,{value:`RL`,children:`Right to left`}),(0,Y.jsx)(`option`,{value:`BT`,children:`Bottom to top`})]})]}),(0,Y.jsx)(`button`,{"aria-pressed":i,disabled:!O,onClick:()=>V(u),type:`button`,children:i?`Hide edge labels`:`Show edge labels`}),(0,Y.jsx)(`button`,{disabled:!O,onClick:()=>V(d),type:`button`,children:`Fit graph`}),(0,Y.jsx)(`button`,{disabled:!O,onClick:()=>V(w),type:`button`,children:`Tidy tree`}),(0,Y.jsx)(`button`,{"aria-controls":`lineage-selection-panel`,"aria-expanded":E,disabled:!O,onClick:()=>V(T),type:`button`,children:`Manage selection`}),(0,Y.jsx)(`button`,{disabled:z||!e,onClick:()=>V(s),type:`button`,children:`Archive current lineage`}),(0,Y.jsx)(`button`,{disabled:o||z,onClick:()=>V(m),type:`button`,children:`Index local`}),(0,Y.jsx)(`button`,{disabled:o||!O,onClick:()=>V(g),type:`button`,children:`Refresh graph`}),(0,Y.jsx)(`button`,{disabled:z,onClick:()=>V(_),type:`button`,children:`Refresh workspaces`})]})]})]})}async function jh(e,t,n){await g(`/api/lineage/layout`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({confirmWrite:!0,positions:n,project:e,rootAssetId:t})})}function Mh(e,t,n){return dd(e.filter(e=>e.type!==`remove`),t)}function Nh(e,t){return!e?.user_selected||t!==`rejected`&&t!==`ignored`?null:{confirmation:`${e.title} is being used for next variation. Marking it ${t} will remove it from next variation.`,clearsSelection:!0}}var Ph=Object.defineProperty,Fh=(e,t,n)=>t in e?Ph(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ih=(e,t)=>{for(var n in t)Ph(e,n,{get:t[n],enumerable:!0})},Lh=(e,t,n)=>Fh(e,typeof t==`symbol`?t:t+``,n),Rh={};Ih(Rh,{Graph:()=>Vh,alg:()=>$h,json:()=>Jh,version:()=>qh});var zh=Object.defineProperty,Bh=(e,t)=>{for(var n in t)zh(e,n,{get:t[n],enumerable:!0})},Vh=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e?e.multigraph:!1,this._isCompound=`compound`in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e==`function`?this._defaultNodeLabelFn=e:this._defaultNodeLabelFn=()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let t of this.successors(e))n.add(t);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return typeof e==`function`?this._defaultEdgeLabelFn=e:this._defaultEdgeLabelFn=()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=Wh(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=Gh(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Hh(this._preds[a],i),Hh(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Kh(this._isDirected,e):Wh(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r==`object`?r:{label:r}}hasEdge(e,t,n){return(arguments.length===1?Kh(this._isDirected,e):Wh(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Kh(this._isDirected,e):Wh(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],Uh(this._preds[t],e),Uh(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Hh(e,t){e[t]?e[t]++:e[t]=1}function Uh(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Wh(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function Gh(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function Kh(e,t){return Wh(e,t.v,t.w,t.name)}var qh=`4.0.1`,Jh={};Bh(Jh,{read:()=>Qh,write:()=>Yh});function Yh(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Xh(e),edges:Zh(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Xh(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function Zh(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Qh(e){let t=new Vh(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var $h={};Bh($h,{CycleException:()=>mg,bellmanFord:()=>tg,components:()=>rg,dijkstra:()=>og,dijkstraAll:()=>cg,findCycles:()=>ug,floydWarshall:()=>fg,isAcyclic:()=>gg,postorder:()=>bg,preorder:()=>xg,prim:()=>Sg,shortestPaths:()=>Cg,tarjan:()=>lg,topsort:()=>hg});var eg=()=>1;function tg(e,t,n,r){return ng(e,String(t),n||eg,r||function(t){return e.outEdges(t)})}function ng(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=n(e);i[e.v].distance+t<i[e.w].distance&&(i[e.w]={distance:i[e.v].distance+t,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function rg(e){let t={},n=[],r;function i(n){n in t||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var ig=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},ag=()=>1;function og(e,t,n,r){return sg(e,String(t),n||ag,r||function(t){return e.outEdges(t)})}function sg(e,t,n,r){let i={},a=new ig,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t],c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0&&(o=a.removeMin(),s=i[o],s.distance!==1/0);)r(o).forEach(c);return i}function cg(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=og(e,i,t,n),r},{})}function lg(e){let t=0,n=[],r={},i=[];function a(o){let s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){e in r?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){let e=[],t;do t=n.pop(),r[t].onStack=!1,e.push(t);while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function ug(e){return lg(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var dg=()=>1;function fg(e,t,n){return pg(e,t||dg,n||function(t){return e.outEdges(t)})}function pg(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){let t=r[e];i.forEach(function(n){let a=r[n];i.forEach(function(n){let r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}var mg=class extends Error{constructor(...e){super(...e)}};function hg(e){let t={},n={},r=[];function i(a){if(a in n)throw new mg;a in t||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new mg;return r}function gg(e){try{hg(e)}catch(e){if(e instanceof mg)return!1;throw e}return!0}function _g(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=vg(e,t,n===`post`,o,a,r,i)}),i}function vg(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=vg(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function yg(e,t,n){return _g(e,t,n,function(e,t){return e.push(t),e},[])}function bg(e,t){return yg(e,t,`post`)}function xg(e,t){return yg(e,t,`pre`)}function Sg(e,t){let n=new Vh,r={},i=new ig,a;function o(e){let n=e.v===a?e.w:e.v,o=i.priority(n);if(o!==void 0){let s=t(e);s<o&&(r[n]=a,i.decrease(n,s))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(e){i.add(e,1/0),n.setNode(e)}),i.decrease(e.nodes()[0],0);let s=!1;for(;i.size()>0;){if(a=i.removeMin(),a in r)n.setEdge(a,r[a]);else{if(s)throw Error(`Input graph is not connected: `+e);s=!0}e.nodeEdges(a).forEach(o)}return n}function Cg(e,t,n,r){return wg(e,t,n,r??(t=>e.outEdges(t)??[]))}function wg(e,t,n,r){if(n===void 0)return og(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=r(a[o]);for(let e=0;e<s.length;e++){let t=s[e],r=t.v===a[o]?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return tg(e,t,n,r)}return og(e,t,n,r)}function Tg(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Vg(r);return n.dummy=t,e.setNode(i,n),i}function Eg(e){let t=new Vh().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function Dg(e){let t=new Vh({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Og(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function kg(e){let t=Hg(Ig(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function Ag(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Fg(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function jg(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Fg(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function Mg(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Tg(e,`border`,i,t)}function Ng(e,t=Pg){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Pg=65535;function Fg(e,t){return t.length>Pg?e(...Ng(t).map(t=>e(...t))):e(...t)}function Ig(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Fg(Math.max,t)}function Lg(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Rg(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function zg(e,t){return t()}var Bg=0;function Vg(e){return e+(``+ ++Bg)}function Hg(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function Ug(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Wg(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function Gg(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Kg=`\0`,qg=class{constructor(){Lh(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Jg(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Jg(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,Yg)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Jg(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Yg(e,t){if(e!==`_next`&&e!==`_prev`)return t}var Xg=qg,Zg=()=>1;function Qg(e,t){if(e.nodeCount()<=1)return[];let n=t_(e,t||Zg);return $g(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function $g(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)e_(e,t,n,o);for(;o=i.dequeue();)e_(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(e_(e,t,n,o,!0)||[]);break}}}return r}function e_(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,n_(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,n_(t,n,o)}),e.removeNode(r.v),o}function t_(e,t){let n=new Vh,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=r_(i+r+3).map(()=>new Xg),o=r+1;return n.nodes().forEach(e=>{n_(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function n_(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function r_(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function i_(e){(e.graph().acyclicer===`greedy`?Qg(e,t(e)):a_(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,Vg(`rev`))});function t(e){return t=>e.edge(t).weight}}function a_(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function o_(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function s_(e){e.graph().dummyChains=[],e.edges().forEach(t=>c_(e,t))}function c_(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d;for(d=0,++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=Tg(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function l_(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function u_(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=Fg(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function d_(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var f_=p_;function p_(e){let t=new Vh({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;m_(t,e)<i&&(a=h_(t,e),a);)o=t.hasNode(a.v)?d_(e,a):-d_(e,a),g_(t,e,o);return t}function m_(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!d_(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function h_(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=d_(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function g_(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:__,postorder:v_}=$h,y_=b_;b_.initLowLimValues=w_,b_.initCutValues=x_,b_.calcCutValue=C_,b_.leaveEdge=E_,b_.enterEdge=D_,b_.exchangeEdges=O_;function b_(e){e=Eg(e),u_(e);let t=f_(e);w_(t),x_(t,e);let n,r;for(;n=E_(t);)r=D_(t,e,n),O_(t,e,n,r)}function x_(e,t){let n=v_(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>S_(e,t,n))}function S_(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=C_(e,t,n)}function C_(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,A_(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function w_(e,t){arguments.length<2&&(t=e.nodes()[0]),T_(e,{},1,t)}function T_(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=T_(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function E_(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function D_(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===j_(e,e.node(t.v),s)&&c!==j_(e,e.node(t.w),s)).reduce((e,n)=>d_(t,n)<d_(t,e)?n:e)}function O_(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),w_(e),x_(e,t),k_(e,t)}function k_(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=__(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function A_(e,t,n){return e.hasEdge(t,n)}function j_(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var M_=N_;function N_(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:I_(e);break;case`tight-tree`:F_(e);break;case`longest-path`:P_(e);break;case`none`:break;default:I_(e)}}var P_=u_;function F_(e){u_(e),f_(e)}function I_(e){y_(e)}var L_=R_;function R_(e){let t=B_(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=z_(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function z_(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function B_(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(Kg).forEach(r),t}function V_(e){let t=Tg(e,`root`,{},`_root`),n=U_(e),r=Object.values(n),i=Fg(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=W_(e)+1;e.children(Kg).forEach(r=>H_(e,t,a,o,i,n,r)),e.graph().nodeRankFactor=a}function H_(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=Mg(e,`_bt`),l=Mg(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{H_(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function U_(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(Kg).forEach(e=>n(e,1)),t}function W_(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function G_(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var K_=q_;function q_(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)J_(e,`borderLeft`,`_bl`,n,i,t),J_(e,`borderRight`,`_br`,n,i,t)}}e.children(Kg).forEach(t)}function J_(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Tg(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Y_(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&Z_(e)}function X_(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&$_(e),(t===`lr`||t===`rl`)&&(tv(e),Z_(e))}function Z_(e){e.nodes().forEach(t=>Q_(e.node(t))),e.edges().forEach(t=>Q_(e.edge(t)))}function Q_(e){let t=e.width;e.width=e.height,e.height=t}function $_(e){e.nodes().forEach(t=>ev(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ev),Object.hasOwn(r,`y`)&&ev(r)})}function ev(e){e.y=-e.y}function tv(e){e.nodes().forEach(t=>nv(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(nv),Object.hasOwn(r,`x`)&&nv(r)})}function nv(e){let t=e.x;e.x=e.y,e.y=t}function rv(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),r=n.map(t=>e.node(t).rank),i=Hg(Fg(Math.max,r)+1).map(()=>[]);function a(n){if(t[n])return;t[n]=!0;let r=e.node(n);i[r.rank].push(n);let o=e.successors(n);o&&o.forEach(a)}return n.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(a),i}function iv(e,t){let n=0;for(let r=1;r<t.length;++r)n+=av(e,t[r-1],t[r]);return n}function av(e,t,n){let r=Gg(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function ov(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function sv(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),cv(Object.values(n).filter(e=>!e.indegree))}function cv(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&lv(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>Ug(e,[`vs`,`i`,`barycenter`,`weight`]))}function lv(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function uv(e,t){let n=Lg(e,e=>Object.hasOwn(e,`barycenter`)),r=n.lhs,i=n.rhs.sort((e,t)=>t.i-e.i),a=[],o=0,s=0,c=0;r.sort(fv(!!t)),c=dv(a,i,c),r.forEach(e=>{c+=e.vs.length,a.push(e.vs),o+=e.barycenter*e.weight,s+=e.weight,c=dv(a,i,c)});let l={vs:a.flat(1)};return s&&(l.barycenter=o/s,l.weight=s),l}function dv(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function fv(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function pv(e,t,n,r){let i=e.children(t),a=e.node(t),o=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,c={};o&&(i=i.filter(e=>e!==o&&e!==s));let l=ov(e,i);l.forEach(t=>{if(e.children(t.v).length){let i=pv(e,t.v,n,r);c[t.v]=i,Object.hasOwn(i,`barycenter`)&&hv(t,i)}});let u=sv(l,n);mv(u,c);let d=uv(u,r);if(o&&s){d.vs=[o,d.vs,s].flat(1);let t=e.predecessors(o);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(s),i=e.node(r[0]);Object.hasOwn(d,`barycenter`)||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+n.order+i.order)/(d.weight+2),d.weight+=2}}return d}function mv(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function hv(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function gv(e,t,n,r){r||=e.nodes();let i=_v(e),a=new Vh({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function _v(e){let t;for(;e.hasNode(t=Vg(`_root`)););return t}function vv(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function yv(e,t={}){if(typeof t.customOrder==`function`){t.customOrder(e,yv);return}let n=Ig(e),r=bv(e,Hg(1,n+1),`inEdges`),i=bv(e,Hg(n-1,-1,-1),`outEdges`),a=rv(e);if(Sv(e,a),t.disableOptimalOrderHeuristic)return;let o=1/0,s,c=t.constraints||[];for(let t=0,n=0;n<4;++t,++n){xv(t%2?r:i,t%4>=2,c),a=kg(e);let l=iv(e,a);l<o?(n=0,s=Object.assign({},a),o=l):l===o&&(s=structuredClone(a))}Sv(e,s)}function bv(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return gv(e,t,n,r.get(t)||[])})}function xv(e,t,n){let r=new Vh;e.forEach(function(e){n.forEach(e=>r.setEdge(e.left,e.right));let i=e.graph().root,a=pv(e,i,r,t);a.vs.forEach((t,n)=>e.node(t).order=n),vv(e,r,a.vs)})}function Sv(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Cv(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=Tv(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&Ev(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function wv(e,t){let n={};function r(t,r,i,a,o){Hg(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&Ev(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function Tv(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function Ev(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function Dv(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function Ov(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s&&s.length){let r=s.sort((e,t)=>{let n=o[e],r=o[t];return(n===void 0?0:n)-(r===void 0?0:r)}),c=(r.length-1)/2;for(let s=Math.floor(c),l=Math.ceil(c);s<=l;++s){let c=r[s];if(c===void 0)continue;let l=o[c];if(l!==void 0&&a[e]===e&&t<l&&!Dv(n,e,c)){let n=i[c];n!==void 0&&(a[c]=e,a[e]=i[e]=n,t=l)}}}})}),{root:i,align:a}}function kv(e,t,n,r,i=!1){let a={},o=Av(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function Av(e,t,n,r){let i=new Vh,a=e.graph(),o=Fv(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function jv(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Iv(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function Mv(e,t){let n=Object.values(t),r=Fg(Math.min,n),i=Fg(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-Fg(Math.min,c);a!==`l`&&(l=i-Fg(Math.max,c)),l&&(e[o]=Wg(s,e=>e+l))})})}function Nv(e,t=void 0){let n=e.ul;return n?Wg(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function Pv(e){let t=kg(e),n=Object.assign(Cv(e,t),wv(e,t)),r={},i;return[`u`,`d`].forEach(a=>{i=a===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(i=i.map(e=>Object.values(e).reverse()));let o=Ov(e,i,n,t=>(a===`u`?e.predecessors(t):e.successors(t))||[]),s=kv(e,i,o.root,o.align,t===`r`);t===`r`&&(s=Wg(s,e=>-e)),r[a+t]=s})}),Mv(r,jv(e,r)),Nv(r,e.graph().align)}function Fv(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2;break}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2;break}return l&&(c+=n?l:-l),c}}function Iv(e,t){return e.node(t).width}function Lv(e){e=Dg(e),Rv(e),Object.entries(Pv(e)).forEach(([t,n])=>e.node(t).x=n)}function Rv(e){let t=kg(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);i===`top`?r.y=a+r.height/2:i===`bottom`?r.y=a+n-r.height/2:r.y=a+n/2}),a+=n+r})}function zv(e,t={}){let n=t.debugTiming?Rg:zg;return n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>Xv(e));return n(` runLayout`,()=>Bv(r,n,t)),n(` updateInputGraph`,()=>Vv(e,r)),r})}function Bv(e,t,n){t(` makeSpaceForEdgeLabels`,()=>Zv(e)),t(` removeSelfEdges`,()=>oy(e)),t(` acyclic`,()=>i_(e)),t(` nestingGraph.run`,()=>V_(e)),t(` rank`,()=>M_(Dg(e))),t(` injectEdgeLabelProxies`,()=>Qv(e)),t(` removeEmptyRanks`,()=>jg(e)),t(` nestingGraph.cleanup`,()=>G_(e)),t(` normalizeRanks`,()=>Ag(e)),t(` assignRankMinMax`,()=>$v(e)),t(` removeEdgeLabelProxies`,()=>ey(e)),t(` normalize.run`,()=>s_(e)),t(` parentDummyChains`,()=>L_(e)),t(` addBorderSegments`,()=>K_(e)),t(` order`,()=>yv(e,n)),t(` insertSelfEdges`,()=>sy(e)),t(` adjustCoordinateSystem`,()=>Y_(e)),t(` position`,()=>Lv(e)),t(` positionSelfEdges`,()=>cy(e)),t(` removeBorderNodes`,()=>ay(e)),t(` normalize.undo`,()=>l_(e)),t(` fixupEdgeLabelCoords`,()=>ry(e)),t(` undoCoordinateSystem`,()=>X_(e)),t(` translateGraph`,()=>ty(e)),t(` assignNodeIntersects`,()=>ny(e)),t(` reversePoints`,()=>iy(e)),t(` acyclic.undo`,()=>o_(e))}function Vv(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Hv=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],Uv={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},Wv=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],Gv=[`width`,`height`,`rank`],Kv={width:0,height:0},qv=[`minlen`,`weight`,`width`,`height`,`labeloffset`],Jv={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},Yv=[`labelpos`];function Xv(e){let t=new Vh({multigraph:!0,compound:!0}),n=uy(e.graph());return t.setGraph(Object.assign({},Uv,ly(n,Hv),Ug(n,Wv))),e.nodes().forEach(n=>{let r=ly(uy(e.node(n)),Gv);Object.keys(Kv).forEach(e=>{r[e]===void 0&&(r[e]=Kv[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=uy(e.edge(n));t.setEdge(n,Object.assign({},Jv,ly(r,qv),Ug(r,Yv)))}),t}function Zv(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Qv(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Tg(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function $v(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function ey(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function ty(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function ny(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(Og(r,a)),n.points.push(Og(i,o))})}function ry(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset;break}})}function iy(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function ay(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function oy(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function sy(e){kg(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{Tg(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function cy(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`selfedge`){let r=n,i=e.node(r.e.v),a=i.x+i.width/2,o=i.y,s=n.x-a,c=i.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:a+2*s/3,y:o-c},{x:a+5*s/6,y:o-c},{x:a+s,y:o},{x:a+5*s/6,y:o+c},{x:a+2*s/3,y:o+c}],r.label.x=n.x,r.label.y=n.y}})}function ly(e,t){return Wg(Ug(e,t),Number)}function uy(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var dy=212,fy=164;function py(e,t,n=`LR`,r=!0){if(!e)return{nodes:[],edges:[]};let i=_y(e,n),a=my(n),o=gy(e,t),s=e.nodes.map(n=>({id:n.asset_id,initialHeight:fy,initialWidth:dy,measured:{height:fy,width:dy},type:`assetNode`,height:fy,position:n.position||i.get(n.asset_id)||{x:0,y:0},sourcePosition:a.source,targetPosition:a.target,width:dy,data:{...n,active:n.asset_id===t,focusRole:o.roles.get(n.asset_id)||`none`,root:n.asset_id===e.root_asset_id,sourcePosition:a.source,targetPosition:a.target}})),c=new Map(e.nodes.map(e=>[e.asset_id,e.title]));return{nodes:s,edges:e.edges.map(t=>{let n=t.summary?`lineage-edge-summary`:``,i=[o.edgeClasses.get(t.id),n].filter(Boolean).join(` `)||void 0,a=`${c.get(t.parent_asset_id)||t.parent_asset_id} to ${c.get(t.child_asset_id)||t.child_asset_id}`;return{ariaLabel:t.summary?`${a}: ${t.summary}`:a,ariaRole:`button`,className:i,domAttributes:{"aria-keyshortcuts":`Enter Space`},focusable:!0,id:t.id,markerEnd:{type:Rs.ArrowClosed},source:t.parent_asset_id,target:t.child_asset_id,type:`smoothstep`,animated:e.selected.includes(t.child_asset_id),...t.summary&&r?{label:t.summary,labelBgBorderRadius:4,labelBgPadding:[5,3],labelShowBg:!0}:{}}})}}function my(e){return{BT:{source:X.Top,target:X.Bottom},LR:{source:X.Right,target:X.Left},RL:{source:X.Left,target:X.Right},TB:{source:X.Bottom,target:X.Top}}[e]}function hy(e,t=`LR`){if(!e)return`lineage-empty`;let n=e.nodes.map(e=>e.asset_id).sort().join(`,`),r=e.edges.map(e=>e.id).sort().join(`,`);return`${e.root_asset_id}:${t}:${n}:${r}`}function gy(e,t){let n=new Map,r=new Map;if(!t||!e.nodes.some(e=>e.asset_id===t))return{edgeClasses:r,roles:n};n.set(t,`active`);for(let i of e.edges)i.child_asset_id===t&&(n.has(i.parent_asset_id)||n.set(i.parent_asset_id,`parent`),r.set(i.id,`lineage-edge-focus lineage-edge-focus-parent`)),i.parent_asset_id===t&&(n.has(i.child_asset_id)||n.set(i.child_asset_id,`child`),r.set(i.id,`lineage-edge-focus lineage-edge-focus-child`));return{edgeClasses:r,roles:n}}function _y(e,t=`LR`){let n=new Rh.Graph;n.setGraph({marginx:40,marginy:40,nodesep:80,rankdir:t,ranksep:110}),n.setDefaultEdgeLabel(()=>({}));for(let t of e.nodes)n.setNode(t.asset_id,{height:fy,width:dy});for(let t of e.edges)n.setEdge(t.parent_asset_id,t.child_asset_id);return zv(n),new Map(e.nodes.map(e=>{let t=n.node(e.asset_id);return[e.asset_id,{x:Math.round((t?.x||dy/2)-dy/2),y:Math.round((t?.y||fy/2)-fy/2)}]}))}function vy(e){return!!(e&&e.nodes.length>1&&e.edges.length>0)}function yy(e){let t=new Set(e.nodes.map(e=>e.asset_id));if(t.size===0)return{stages:[]};let n=[...t].sort(Cy),r=t.has(e.root_asset_id)?e.root_asset_id:n[0],i=new Set([r]),a=new Set,o=e.edges.filter(e=>t.has(e.parent_asset_id)&&t.has(e.child_asset_id)).sort(Sy),s=[xy(0,i,a,[r],[])];for(;i.size<t.size||o.length>0;){let e=o.findIndex(e=>i.has(e.parent_asset_id));if(e>=0){let[t]=o.splice(e,1);a.add(t.id);let n=i.has(t.child_asset_id)?[]:[t.child_asset_id];i.add(t.child_asset_id),s.push(xy(s.length,i,a,n,[t.id]));continue}let t=n.find(e=>!i.has(e));if(t){i.add(t),s.push(xy(s.length,i,a,[t],[]));continue}break}return{stages:s}}function by(e,t,n,r,i){let a=n.stages,o=a.length-1,s=Math.max(-1,Math.min(r,o)),c=s>=0?a[s]:void 0,l=s<o?a[s+1]:void 0,u=new Set(c?.nodeIds||[]),d=new Set(c?.edgeIds||[]),f=new Set,p=new Set;if(l&&(i===`edge`||i===`node`))for(let e of l.enteringEdgeIds)i===`edge`?p.add(e):d.add(e);if(l&&i===`node`)for(let e of l.enteringNodeIds)f.add(e);let m=s===o&&i===`settled`,h=new Map(e.map(e=>[e.id,f.has(e.id)?`entering`:u.has(e.id)?`visible`:`future`])),g=new Map(t.map(e=>[e.id,p.has(e.id)?`entering`:d.has(e.id)?`visible`:`future`]));return{nodes:e.map(e=>({...e,data:{...e.data,replayInteractive:m,replayState:h.get(e.id)||`future`}})),edges:t.map(e=>{let t=g.get(e.id)||`future`;return{...e,className:[e.className,`lineage-edge-replay-${t}`].filter(Boolean).join(` `),domAttributes:{...e.domAttributes,"aria-hidden":t===`future`?!0:void 0},focusable:m?e.focusable:!1}}),projection:{edgeStates:g,interactive:m,nodeStates:h}}}function xy(e,t,n,r,i){return{edgeIds:[...n],enteringEdgeIds:i,enteringNodeIds:r,index:e,nodeIds:[...t]}}function Sy(e,t){return Cy(e.created_at||``,t.created_at||``)||Cy(e.id,t.id)}function Cy(e,t){return e.localeCompare(t)}function wy(e,t){(0,p.useEffect)(()=>{function n(n){n.key===`Escape`&&e&&t()}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t])}function Ty({asset:e,onResetLineage:t,onSelectedAsset:n,onToast:r,project:i}){let a=(0,p.useRef)(i),[o,s]=(0,p.useState)(null),[c,l]=(0,p.useState)(null),[u,d]=(0,p.useState)(null),[f,m]=(0,p.useState)(!1),h=o?.project===i,_=h?o:null,v=(_?.workspaces||[]).filter(e=>e.status!==`archived`),y=_?.active_workspace||v[0]||null,b=Sh(y,h&&_?.workspaces.length===0?e?.asset_id:void 0);(0,p.useEffect)(()=>{a.current=i,s(null),l(null),d(null)},[i]);let x=(0,p.useCallback)(async()=>{m(!0);try{let e=await g(`/api/lineage-workspaces?${new URLSearchParams({project:i}).toString()}`);e.project===a.current&&s(e)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}},[r,i]),S=(0,p.useCallback)(async()=>{try{let e=new URLSearchParams({project:i}),[t,n]=await Promise.all([g(`/api/lineage-workspaces/demo/media?${e.toString()}`),g(`/api/lineage-workspaces/demo/swissifier/media?${e.toString()}`)]);if(a.current!==i)return;l(t.status),d(n.status)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}},[r,i]);async function C(e){if(e){m(!0);try{let a=await g(`/api/lineage-workspaces/${encodeURIComponent(e)}/activate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});t(),await x(),n(a.workspace.root_asset_id),r(`ok`,`Using ${a.workspace.title}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}}}async function w(e={}){m(!0);try{let a=await g(`/api/lineage-workspaces/demo/seed`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});return t(),await x(),await S(),n(a.workspace?.root_asset_id||a.root_asset_id),e.quiet||r(`ok`,`Seeded demo lineage workspace`),a}catch(e){return r(`error`,e instanceof Error?e.message:String(e)),null}finally{m(!1)}}async function T(e={}){m(!0);try{let a=await g(`/api/lineage-workspaces/demo/swissifier/seed`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});return t(),await x(),await S(),n(a.workspace?.root_asset_id||a.root_asset_id),e.quiet||r(`ok`,`Seeded Swissifier demo lineage`),a}catch(e){return r(`error`,e instanceof Error?e.message:String(e)),null}finally{m(!1)}}async function E(){m(!0);try{let e=await g(`/api/lineage-workspaces/demo/media/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});await S(),r(`ok`,`Restored ${e.result.restored||0} demo media file${e.result.restored===1?``:`s`}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}}async function D(){m(!0);try{let e=await g(`/api/lineage-workspaces/demo/swissifier/media/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});await S(),e.result.source_required?r(`error`,`Set ${e.result.source_env||`LINEAGE_SWISSIFIER_MEDIA_DIR`} to restore Swissifier media`):r(`ok`,`Restored ${e.result.restored||0} Swissifier media file${e.result.restored===1?``:`s`}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}}async function O(){m(!0);try{let e=await g(`/api/lineage-workspaces/demo/swissifier/media/download`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})});return await S(),e.result.download_available?(r(`ok`,`Downloaded ${e.result.restored||0} Swissifier media file${e.result.restored===1?``:`s`}`),!0):(r(`error`,`Swissifier media download is not configured`),!1)}catch(e){return r(`error`,e instanceof Error?e.message:String(e)),!1}finally{m(!1)}}async function k(){if(y&&window.confirm(`Archive ${y.title}? This hides it from the picker and clears its next-variation selection.`)){m(!0);try{await g(`/api/lineage-workspaces/${encodeURIComponent(y.id)}/archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})}),t(),await x(),await S(),r(`ok`,`Archived ${y.title}`)}catch(e){r(`error`,e instanceof Error?e.message:String(e))}finally{m(!1)}}}function A(e){s(t=>({project:i,active_workspace:e,workspaces:[e,...(t?.workspaces||[]).filter(t=>t.id!==e.id)],fetchedAt:new Date().toISOString()})),t(),n(e.root_asset_id),r(`ok`,`Using ${e.title}`)}return{activateWorkspace:C,activeWorkspace:y,archiveWorkspace:k,demoSeedStatus:c,downloadSwissifierDemoMedia:O,handleWorkspaceCreated:A,refreshDemoSeedStatus:S,refreshWorkspaces:x,restoreDemoSeedMedia:E,restoreSwissifierDemoMedia:D,seedDemoWorkspace:w,seedSwissifierDemoWorkspace:T,swissifierDemoStatus:u,visibleWorkspaces:v,workspaceLoading:f,workspaceRootAssetId:b}}function Ey(e,t,n){let r=(0,p.useRef)(!1),i=(0,p.useRef)(``),a=(0,p.useRef)(!1),o=(0,p.useRef)(``),s=(0,p.useCallback)((t=0)=>{window.setTimeout(()=>{e&&(r.current=!0,e.fitView({maxZoom:.9,padding:.32}),window.setTimeout(()=>{r.current=!1},450))},t)},[e]),c=(0,p.useCallback)(()=>{r.current||(a.current=!0)},[]);return(0,p.useEffect)(()=>{if(!t||!e)return;o.current!==t&&(o.current=t,a.current=!1,i.current=``);let r=`${t}:${n?`side-open`:`side-closed`}`;i.current!==r&&(i.current=r,a.current||s(280))},[s,e,t,n]),{fitGraph:s,markViewportInteraction:c}}function Dy({actionsOpen:e,asset:t,onActionsOpenChange:n,onAssetsChanged:r,project:i,onSelectedAsset:a,onToast:o}){let[s,c]=(0,p.useState)(null),[l,u]=(0,p.useState)(null),[d,f]=(0,p.useState)(``),[m,_]=(0,p.useState)(null),[v,y]=(0,p.useState)(null),[b,x]=(0,p.useState)([]),[S]=(0,p.useState)(ym),[C,w]=(0,p.useState)(null),[T,E]=(0,p.useState)([]),[D,O]=(0,p.useState)(!0),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(`LR`),[N,P]=(0,p.useState)(``),[F,I]=(0,p.useState)(null),[L,R]=(0,p.useState)(!1),[z,B]=(0,p.useState)(!1),[V,H]=(0,p.useState)(!1),[U,W,ee]=Ip([]),[G,te]=Lp([]),[ne,re]=(0,p.useState)(null),[ie,ae]=(0,p.useState)(!1),[oe,se]=(0,p.useState)(null),[ce,le]=(0,p.useState)(0),[ue,de]=(0,p.useState)(null),[K,fe]=(0,p.useState)(-1),[pe,me]=(0,p.useState)(`settled`),[he,q]=(0,p.useState)(!1),[ge,J]=(0,p.useState)(1),[_e,ve]=(0,p.useState)(!1),ye=(0,p.useMemo)(()=>ue?yy(ue):{stages:[]},[ue]),be=ye.stages.length-1,xe=!!(ue&&K===be&&pe===`settled`),Se=ue&&!xe?ue:s,Ce=s?.nodes.find(e=>e.asset_id===l)||s?.nodes[0],we=s?.edges.find(e=>e.id===k?.edgeId),Te=s?.nodes.filter(e=>s.latest.includes(e.asset_id))||[],Ee=s?.selected.map(e=>s.nodes.find(t=>t.asset_id===e)).filter(e=>!!e)||[],De=Ee[0],Oe=Ee.length>=3,ke=s?.nodes.find(e=>e.asset_id===m)||null,Ae=s?.nodes.find(e=>e.asset_id===v)||null,je=s?.nodes.find(e=>e.asset_id===F?.assetId),Me=S&&!ke&&!Ae&&!we&&(!ue||xe),Ne=!!(Ce&&N!==(Ce.selection_note||``)),Pe=(0,p.useRef)(null),Fe=(0,p.useRef)([]),Ie=(0,p.useRef)(``),Le=(0,p.useRef)(``),{fitGraph:Re,markViewportInteraction:ze}=Ey(ne,s?.root_asset_id,z),Be=(0,p.useCallback)(()=>{le(e=>e+1),I(null)},[]),Ve=(0,p.useRef)(i);(0,p.useEffect)(()=>{Ve.current=i},[i]);let He=(0,p.useCallback)(()=>{u(null),Be()},[Be]),Ue=(0,p.useCallback)(()=>{c(null),u(null),w(null),de(null),q(!1),me(`settled`),fe(-1)},[]),{activateWorkspace:We,activeWorkspace:Ge,archiveWorkspace:Ke,demoSeedStatus:qe,downloadSwissifierDemoMedia:Je,handleWorkspaceCreated:Ye,refreshDemoSeedStatus:Xe,refreshWorkspaces:Ze,restoreDemoSeedMedia:Qe,restoreSwissifierDemoMedia:$e,seedDemoWorkspace:et,seedSwissifierDemoWorkspace:tt,swissifierDemoStatus:nt,visibleWorkspaces:rt,workspaceLoading:it,workspaceRootAssetId:at}=Ty({asset:t,onResetLineage:Ue,onSelectedAsset:a,onToast:o,project:i});Le.current=at,(0,p.useEffect)(()=>{Xe()},[Xe]);let ot=(0,p.useCallback)(async(e={})=>{let t=e.rootAssetId||at;if(!t)return!1;e.quiet||ae(!0);try{let n=new URLSearchParams({project:i}),[r,a]=await Promise.all([g(`/api/lineage/${t}?${n.toString()}`),g(`/api/agent-claims?${n.toString()}`)]);return!e.rootAssetId&&Le.current!==t?!1:(c(r),E(a.claims),e.quiet||w(null),u(t=>Pm(t,r.nodes,r.active_asset_id,!!e.quiet)),!0)}catch(n){return!e.rootAssetId&&Le.current!==t||!e.quiet&&Ve.current===i&&(c(null),o(`error`,n instanceof Error?n.message:String(n))),!1}finally{!e.quiet&&Ve.current===i&&ae(!1)}},[o,i,at]),st=(0,p.useCallback)(()=>{!s||!vy(s)||(Pe.current&&window.clearTimeout(Pe.current),Be(),u(null),_(null),y(null),x([]),A(null),B(!1),H(!1),de(s),fe(-1),me(`node`),q(!0))},[Be,s]),ct=(0,p.useCallback)(()=>{de(null),fe(-1),me(`settled`),q(!1),ot({quiet:!0})},[ot]),lt=(0,p.useCallback)(()=>{xe&&s&&de(s),fe(-1),me(`node`),q(!0)},[xe,s]),ut=(0,p.useCallback)(()=>{if(xe){lt();return}q(e=>!e)},[xe,lt]),dt=(0,p.useCallback)(e=>{q(!1),me(`settled`),fe(Math.max(0,Math.min(e,be)))},[be]);async function ft(){se(null),ae(!0);try{o(`ok`,`Indexed ${(await g(`/api/index/local`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i})})).summary.total} assets`),await Ze(),await ot()}catch(e){o(`error`,e instanceof Error?e.message:String(e))}finally{ae(!1)}}async function pt(){Be(),se(null);let e=await et();if(e)try{await r?.(),await ot({rootAssetId:e.workspace?.root_asset_id||e.root_asset_id})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function mt(){Be(),se(`seeding`);let e=await tt();if(!e){se(`error`);return}try{se(`indexing`),await r?.(),await ot({rootAssetId:e.workspace?.root_asset_id||e.root_asset_id})||se(`error`)}catch(e){se(`error`),o(`error`,e instanceof Error?e.message:String(e))}}async function ht(){se(`downloading`);let e=await Je();se(e?`downloaded`:`error`)}async function gt(e,t,n){try{await g(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,...t})}),o(`ok`,n),await ot()}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}function _t(){Ce&&yt(Ce,N)}function vt(){Ce?.user_selected&&yt(Ce,N)}async function yt(e,t=e.selection_note||``){if(!e.user_selected&&Oe){o(`error`,`Choose at most 3 assets for next variation`);return}await gt(`/api/selection`,{assetId:e.asset_id,rootAssetId:s?.root_asset_id,mode:e.user_selected?`remove`:`add`,notes:t,confirmWrite:!0},e.user_selected?`Removed ${e.asset_id} from next variation`:`Using ${e.asset_id} for next variation`)}async function bt(e,t=e.selection_note||``){await gt(`/api/selection`,{assetId:e.asset_id,rootAssetId:s?.root_asset_id,mode:`replace`,notes:t,confirmWrite:!0},`Using only ${e.asset_id} for next variation`)}async function xt(e){if(s){if(e){await gt(`/api/selection`,{assetId:e,rootAssetId:s.root_asset_id,mode:`remove`,confirmWrite:!0},`Removed ${e} from next variation`);return}Ee.length>0&&await gt(`/api/selection`,{rootAssetId:s.root_asset_id,clear:!0,confirmWrite:!0},`Removed all assets from next variation`)}}function St(){if(Pe.current&&window.clearTimeout(Pe.current),z){B(!1),Pe.current=window.setTimeout(()=>H(!1),260);return}H(!0),window.requestAnimationFrame(()=>B(!0))}async function Ct(e,t=Ce?.asset_id){if(!t)return;let n=s?.nodes.find(e=>e.asset_id===t),r=Nh(n,e);r&&!window.confirm(r.confirmation)||(r&&await xt(t),gt(`/api/reviews/${t}`,{reviewState:e,confirmWrite:!0},`Marked ${t} ${e}`))}async function wt(e){s&&await gt(`/api/lineage/${s.root_asset_id}/rerolls/${e.asset_id}`,{confirmWrite:!0,requestedBy:`human`},`Marked ${e.asset_id} for re-roll`)}async function Tt(e){s&&await gt(`/api/lineage/${s.root_asset_id}/rerolls/${e.asset_id}/cancel`,{confirmWrite:!0},`Cleared re-roll request for ${e.asset_id}`)}async function Et(e){if(s)try{let t=new URLSearchParams({project:i}),n=await g(`/api/lineage/${s.root_asset_id}/attempts/${e}?${t.toString()}`);x(n.attempts),y(e)}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}function Dt(){y(null),x([])}function Ot(e){Dt(),_(e)}async function kt(e){if(!(!s||!v))try{let t=await g(`/api/lineage/${s.root_asset_id}/attempts/${v}/promote`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,attemptId:e.id,confirmWrite:!0})});x(t.attempts),o(`ok`,`Set v${e.attempt_index} as current`),await ot({quiet:!0})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function At(){!Ce||!d.trim()||(await gt(`/api/lineage/link`,{childAssetId:d.trim(),confirmWrite:!0,parentAssetId:Ce.asset_id},`Linked ${d.trim()} from ${Ce.asset_id}`),f(``))}async function jt(e,t){if(we)try{let n=await g(`/api/lineage/edges/${encodeURIComponent(we.id)}/summary`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e,confirmWrite:!0,expectedSummaryUpdatedAt:we.summary_updated_at||null,project:i,...e===`set`?{summary:t}:{}})});await ot({quiet:!0}),o(`ok`,n.message),A(null)}catch(e){throw e instanceof h&&e.status===409&&e.message.includes(`Edge summary changed since it was opened`)?(await ot({quiet:!0}),Error(`This edge changed elsewhere. The current label has been reloaded; review it and retry.`,{cause:e})):e}}async function Mt(e){if(!s)return;if(e.asset_id===s.root_asset_id){o(`error`,`Root lineage node cannot be removed. Archive this workspace or start a new lineage instead.`);return}let t=s.edges.filter(t=>t.parent_asset_id===e.asset_id).length,n=s.edges.filter(t=>t.child_asset_id===e.asset_id).length,r=t>0&&n>0?` Its ${t} child${t===1?``:`ren`} will be reconnected to its parent${n===1?``:`s`}.`:``;window.confirm(`Remove "${e.title}" from this lineage? This keeps the asset file and S3 object intact.${r}`)&&(await gt(`/api/lineage/remove-node`,{assetId:e.asset_id,rootAssetId:s.root_asset_id,confirmWrite:!0},`Removed ${e.asset_id} from lineage`),I(null),_(t=>t===e.asset_id?null:t),u(t=>t===e.asset_id?s.root_asset_id:t))}async function Nt(e){if(s)try{await jh(i,s.root_asset_id,[{assetId:e.id,x:e.position.x,y:e.position.y}])}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function Pt(){if(!s)return;let e=[..._y(s,j)].map(([e,t])=>({assetId:e,...t}));It(e),W(t=>t.map(t=>({...t,position:e.find(e=>e.assetId===t.id)||t.position})));try{await jh(i,s.root_asset_id,e),o(`ok`,`Tidied ${e.length} lineage nodes`),Re(80),await ot({quiet:!0})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function Ft(e){if(!s)return;let t=[..._y(s,e)].map(([e,t])=>({assetId:e,...t}));It(t),M(e),W(e=>e.map(e=>({...e,position:t.find(t=>t.assetId===e.id)||e.position})));try{await jh(i,s.root_asset_id,t),o(`ok`,`Rotated lineage graph ${ky(e).toLowerCase()}`),Re(80),await ot({quiet:!0})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}function It(e){let t=new Map(e.map(e=>[e.assetId,{x:e.x,y:e.y}]));c(e=>e&&{...e,nodes:e.nodes.map(e=>({...e,position:t.get(e.asset_id)||e.position}))})}async function Lt(){if(s)try{let e=new URLSearchParams({project:i});w(await g(`/api/lineage/${s.root_asset_id}/brief?${e.toString()}`))}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}async function Rt(e,t,n){try{await g(`/api/agent-claims/${t.id}/${e}`,{body:JSON.stringify({project:i,...n}),headers:{"Content-Type":`application/json`},method:`POST`}),o(`ok`,`Updated claim ${t.id}`),await ot({quiet:!0})}catch(e){o(`error`,e instanceof Error?e.message:String(e))}}(0,p.useEffect)(()=>{Ze()},[Ze]),(0,p.useEffect)(()=>{ot()},[ot]),(0,p.useEffect)(()=>{at||Ue()},[Ue,at]),(0,p.useEffect)(()=>{if(!s)return;let e=window.setInterval(()=>void ot({quiet:!0}),8e3);return()=>window.clearInterval(e)},[ot,s?.root_asset_id]),(0,p.useEffect)(()=>{let e=window.matchMedia?.(`(prefers-reduced-motion: reduce)`);if(!e)return;let t=()=>ve(e.matches);return t(),e.addEventListener?.(`change`,t),()=>e.removeEventListener?.(`change`,t)},[]),(0,p.useEffect)(()=>{if(!ue||!he||be<0)return;let e=Math.min(K+1,be);if(pe===`settled`&&K>=be){q(!1);return}let t=ye.stages[e],n=_e?40:void 0,r=n??120/ge,i=()=>{let e=t.enteringEdgeIds.length>0?`edge`:`node`;me(e)};pe===`edge`?(r=n??320/ge,i=()=>{t.enteringNodeIds.length>0?me(`node`):(fe(e),me(`settled`))}):pe===`node`&&(r=n??200/ge,i=()=>{fe(e),me(`settled`)});let a=window.setTimeout(i,r);return()=>window.clearTimeout(a)},[_e,be,pe,he,ue,ge,K,ye.stages]);let zt=(0,p.useMemo)(()=>py(Se,l,j,D),[l,D,j,Se]),Bt=(0,p.useMemo)(()=>ue&&!xe?by(zt.nodes,zt.edges,ye,K,pe):zt,[zt,xe,pe,ue,K,ye]),Vt=(0,p.useMemo)(()=>hy(Se,j),[j,Se]);Fe.current=Bt.edges;let Ht=(0,p.useCallback)(e=>{te(t=>Mh(e,t,Fe.current))},[te]),Ut=(0,p.useCallback)(e=>{e.key===`Escape`&&Be()},[Be]);return(0,p.useEffect)(()=>{P(Ce?.selection_note||``)},[Ce?.asset_id,Ce?.selection_note]),(0,p.useEffect)(()=>{let e=Ie.current!==Vt;Ie.current=Vt,W(t=>Bt.nodes.map(n=>({...n,position:e?n.position:t.find(e=>e.id===n.id)?.position||n.position}))),te(Bt.edges)},[Bt.edges,Bt.nodes,Vt,te,W]),(0,p.useEffect)(()=>{oe!==`indexing`||!s?.nodes.length||Ie.current!==Vt||U.length!==s.nodes.length||se(`ready`)},[U.length,Vt,s,oe]),wy(!!l,He),(0,p.useEffect)(()=>()=>{Pe.current&&window.clearTimeout(Pe.current)},[]),(0,p.useEffect)(()=>{Ue(),se(null)},[i,Ue]),(0,Y.jsxs)(`section`,{className:`lineage-view`,onKeyDownCapture:Ut,children:[(0,Y.jsx)(Ah,{actionsOpen:e,activeWorkspace:Ge,closeSignal:ce,edgeSummariesVisible:D,loading:ie,graphDirection:j,demoSeedStatus:qe,onArchiveWorkspace:()=>{se(null),Ke()},onActionsOpenChange:n,onFitGraph:()=>Re(),onIndexLocal:()=>void ft(),onGraphDirection:e=>void Ft(e),onNewLineage:()=>{se(null),R(!0)},onRefreshLineage:()=>void ot(),onRefreshWorkspaces:()=>void Ze(),onReplayGrowth:st,onRestoreDemoMedia:()=>void Qe(),onRestoreSwissifierMedia:()=>void $e(),onDownloadSwissifierMedia:()=>void ht(),onEdgeSummariesVisible:()=>O(e=>!e),onSeedDemo:()=>void pt(),onSeedSwissifierDemo:()=>void mt(),onSelectWorkspace:e=>{se(null),We(e)},onTidyGraph:()=>void Pt(),onToggleNextPanel:St,replayActive:!!ue,sideOpen:z,snapshot:s,swissifierDemoStatus:nt,workspaceLoading:it,workspaceProgress:oe,workspaceRootAssetId:at,workspaces:rt}),(0,Y.jsxs)(`div`,{className:`lineage-workbench`,"data-testid":`lineage-workbench`,children:[(0,Y.jsxs)(`div`,{className:`lineage-canvas ${l?`focus-active`:``} ${ue?`lineage-replay-active`:``} ${xe?`lineage-replay-interactive`:``} ${ue&&!he?`lineage-replay-paused`:``}`,style:ue?{"--lineage-replay-edge-duration":`${_e?1:320/ge}ms`,"--lineage-replay-node-duration":`${_e?1:200/ge}ms`}:void 0,children:[ue&&ye.stages.length>0&&(0,Y.jsx)(ih,{atEnd:xe,onClose:ct,onPlayPause:ut,onRestart:lt,onScrub:dt,onSpeed:J,playing:he,speed:ge,stageIndex:K,totalStages:ye.stages.length}),(0,Y.jsx)(km,{flowEdges:Se?G:[],flowNodes:Se?U:[],graphKey:Vt,hoverPreviewsEnabled:Me,loading:ie,onEdgesChange:Ht,onEdgeEdit:(e,t)=>A({edgeId:e,returnFocus:t}),onClearFocus:He,onIndexNow:()=>void ft(),onNewLineage:()=>{se(null),R(!0)},onSeedDemo:()=>void pt(),onNodeActionMenu:(e,t,n)=>I(e?{assetId:e,x:t,y:n}:null),onNodeInspect:e=>{Be(),u(e)},onNodeOpenDetail:_,onNodeOpenHistory:e=>void Et(e),onNodePosition:e=>void Nt(e),onNodesChange:ee,onReady:re,onSelectedAsset:a,onToggleBranch:e=>e.user_selected?xt(e.asset_id):yt(e),onToggleReroll:e=>e.reroll_request?.status===`pending`?Tt(e):wt(e),onViewportInteraction:ze,replayInteractive:!ue||xe,selectionFull:Oe,workspaceProgress:oe,workspaceRootAssetId:at})]}),V&&s&&(0,Y.jsx)(mh,{activeNode:Ce,brief:C,childAssetId:d,clearNextVariation:xt,closePanel:St,latestNodes:Te,linkChild:At,markReview:Ct,nextVariationLimit:3,noteDirty:Ne,onSelectedAsset:a,onToast:o,project:i,refreshBrief:Lt,refreshLineage:async()=>{await ot({quiet:!0})},saveRationale:vt,replaceNextVariation:bt,selectNextBase:yt,selectedNode:De,selectedNodes:Ee,selectionFull:Oe,selectionNote:N,setActiveNodeId:u,setChildAssetId:f,setDetailNodeId:_,setSelected:_t,setSelectionNote:P,sideOpen:z,snapshot:s}),F&&je&&s&&(0,Y.jsx)(Am,{canRemoveFromLineage:je.asset_id!==s.root_asset_id,claims:Oy(T,i,s.root_asset_id),node:je,onClaimControl:(e,t,n)=>{Rt(e,t,n)},onClearAllNext:()=>void xt(),onClearNext:()=>void xt(je.asset_id),onClearReroll:()=>void Tt(je),onClose:()=>I(null),onMarkReroll:()=>void wt(je),onOpenDetail:()=>_(je.asset_id),onRemoveFromLineage:()=>void Mt(je),onReplaceNext:()=>bt(je),onReview:e=>void Ct(e,je.asset_id),onSelectNext:()=>yt(je),position:F,selectedCount:Ee.length,selectionFull:Oe})]}),Ae&&s&&(0,Y.jsx)(Bm,{actions:{canRemoveFromLineage:Ae.asset_id!==s.root_asset_id,onClearAllNext:()=>void xt(),onClearNext:()=>void xt(Ae.asset_id),onOpenNode:Ot,onRemoveFromLineage:e=>void Mt(e),onReplaceNext:bt,onReview:Ct,onSelectNext:yt,onToast:o,selectedCount:Ee.length,selectionFull:Oe,snapshot:s},attempts:b,node:Ae,onClose:Dt,onPromoteAttempt:kt,project:i}),ke&&s&&(0,Y.jsx)(Km,{canRemoveFromLineage:ke.asset_id!==s.root_asset_id,node:ke,onClearAllNext:()=>void xt(),onClearNext:()=>void xt(ke.asset_id),onClose:()=>_(null),onOpenNode:_,onRemoveFromLineage:e=>void Mt(e),onReplaceNext:bt,onReview:Ct,onSelectNext:yt,onToast:o,selectedCount:Ee.length,selectionFull:Oe,snapshot:s}),we&&k&&s&&(0,Y.jsx)(Ym,{childTitle:s.nodes.find(e=>e.asset_id===we.child_asset_id)?.title||we.child_asset_id,edge:we,onClose:()=>A(null),onSubmit:jt,parentTitle:s.nodes.find(e=>e.asset_id===we.parent_asset_id)?.title||we.parent_asset_id,returnFocus:k.returnFocus}),(0,Y.jsx)(rh,{onClose:()=>R(!1),onCreated:Ye,onToast:o,open:L,project:i})]})}function Oy(e,t,n){let r=`${t}:lineage-workspace:${n}`;return e.filter(e=>e.project!==t||e.status!==`active`||e.derived_state===`expired`?!1:e.scope_type===`lineage_workspace`?e.target_id===r:e.scope_type===`project_channel`)}function ky(e){return{BT:`bottom to top`,LR:`left to right`,RL:`right to left`,TB:`top to bottom`}[e]}function Ay({assets:e,onClose:t,onDone:n,onError:r,project:i}){let a=e[0],[o,s]=(0,p.useState)(!1),[c,l]=(0,p.useState)(!1),[u,d]=(0,p.useState)([]),[f,m]=(0,p.useState)({audience:a?.audience||`local-review`,campaign:a?.campaign||`local-review`,channel:a?.channel===`local`?`meta`:a?.channel||`meta`,cta:a?.cta||`Review before upload`,status:`working`}),h=e.filter(e=>!My(e)),_=h.length>0||e.length===0;function v(e,t){m(n=>({...n,[e]:t}))}function y(e,t){let n=me(e.title)||e.asset_id;return{...f,assetId:n,confirmWrite:o,dryRun:t,hook:e.hook,notes:e.notes,path:e.local?.relative_path,project:i,title:e.title,type:e.content_type,utmContent:e.utm_content||n.replaceAll(`-`,`_`)}}async function b(t){if(_){r(`Local backup is locked until every selected local asset is approved.`);return}l(!0);try{let r=[];for(let n of e){if(!n.local?.relative_path)throw Error(`${n.asset_id} has no local path`);let e=await g(`/api/assets/local-backup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(y(n,t))});r.push(e.message)}t?d(r):await n(`Backed up ${e.length} local asset${e.length===1?``:`s`}`)}catch(e){r(e instanceof Error?e.message:String(e))}finally{l(!1)}}return(0,Y.jsx)(`div`,{className:`drawer-backdrop`,children:(0,Y.jsxs)(`section`,{className:`local-backup-drawer`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:`Back up local assets`}),(0,Y.jsx)(`p`,{children:i})]}),(0,Y.jsx)(`button`,{onClick:t,children:`Close`})]}),(0,Y.jsx)(`div`,{className:`local-backup-list`,children:e.map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:me(e.title)||e.asset_id}),(0,Y.jsx)(`span`,{children:e.local?.relative_path}),(0,Y.jsxs)(`span`,{children:[`Review: `,Ny(jy(e))]})]},e.asset_id))}),_&&(0,Y.jsxs)(`div`,{className:`local-backup-warning`,role:`alert`,children:[(0,Y.jsx)(`strong`,{children:`Backup is locked until local review is approved.`}),e.length===0?(0,Y.jsx)(`span`,{children:`No local assets are selected.`}):null,h.map(e=>(0,Y.jsxs)(`span`,{children:[me(e.title)||e.asset_id,`: `,Ny(jy(e))]},e.asset_id))]}),(0,Y.jsxs)(`div`,{className:`form-grid`,children:[(0,Y.jsxs)(`label`,{children:[`Campaign`,(0,Y.jsx)(`input`,{value:f.campaign,onChange:e=>v(`campaign`,e.target.value)})]}),(0,Y.jsxs)(`label`,{children:[`Channel`,(0,Y.jsx)(`input`,{value:f.channel,onChange:e=>v(`channel`,e.target.value)})]}),(0,Y.jsxs)(`label`,{children:[`Audience`,(0,Y.jsx)(`input`,{value:f.audience,onChange:e=>v(`audience`,e.target.value)})]}),(0,Y.jsxs)(`label`,{children:[`Status`,(0,Y.jsxs)(`select`,{value:f.status,onChange:e=>v(`status`,e.target.value),children:[(0,Y.jsx)(`option`,{children:`working`}),(0,Y.jsx)(`option`,{children:`published`})]})]}),(0,Y.jsxs)(`label`,{className:`wide`,children:[`CTA`,(0,Y.jsx)(`input`,{value:f.cta,onChange:e=>v(`cta`,e.target.value)})]})]}),u.length>0&&(0,Y.jsx)(`div`,{className:`local-backup-preview`,children:u.map(e=>(0,Y.jsx)(`span`,{children:e},e))}),(0,Y.jsxs)(`label`,{className:`confirm-line`,children:[(0,Y.jsx)(`input`,{checked:o,type:`checkbox`,onChange:e=>s(e.target.checked)}),(0,Y.jsx)(`span`,{children:`Confirm write to the production asset bucket`})]}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`button`,{disabled:c||_,onClick:()=>void b(!0),children:`Dry run`}),(0,Y.jsxs)(`button`,{className:`primary-button`,disabled:c||_||!o,onClick:()=>void b(!1),children:[c?(0,Y.jsx)(ee,{className:`spin`,size:16}):(0,Y.jsx)(E,{size:16}),`Back up`]})]})]})})}function jy(e){return e.review?.review_state||`unreviewed`}function My(e){return!!e.local?.relative_path&&jy(e)===`approved`}function Ny(e){return e===`needs_revision`?`needs revision`:e}var Py=[[`unreviewed`,`Needs review`],[`approved`,`Approved keepers`],[`needs_revision`,`Needs revision`],[`rejected`,`Rejected or ignored`]];function Fy(e){let t=e.assets.filter(e=>e.local?.relative_path&&!e.s3?.key),n=t.filter(e=>Ry(e)===`approved`),r=e.selectedBackupIds.length,i=`npx lineage local queue --project ${e.project} --json`;function a(){for(let t of n)e.onQueueBackup(t)}return(0,Y.jsxs)(`section`,{className:`local-backup-queue`,children:[(0,Y.jsxs)(`header`,{className:`backup-queue-head`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:`Local Backup Queue`}),(0,Y.jsx)(`p`,{children:`Review local-only candidates, select approved keepers, then back them up intentionally.`}),(0,Y.jsxs)(`p`,{children:[e.snapshot?.catalog.default_bucket||`No bucket loaded`,` · refreshed `,pe(e.snapshot?.fetchedAt)]})]}),(0,Y.jsxs)(`div`,{className:`backup-queue-actions`,children:[(0,Y.jsxs)(`button`,{disabled:n.length===0,onClick:a,type:`button`,children:[(0,Y.jsx)(w,{size:15}),` Select approved`]}),(0,Y.jsxs)(`button`,{disabled:r===0,onClick:e.onOpenBackup,type:`button`,children:[(0,Y.jsx)(E,{size:15}),` Back up selected`]})]})]}),(0,Y.jsxs)(`div`,{className:`backup-queue-stats`,"aria-label":`Local backup queue summary`,children:[(0,Y.jsx)(Ly,{label:`Local only`,value:t.length}),(0,Y.jsx)(Ly,{label:`Needs review`,value:t.filter(e=>Ry(e)===`unreviewed`).length}),(0,Y.jsx)(Ly,{label:`Approved`,value:n.length}),(0,Y.jsx)(Ly,{label:`Selected`,value:r})]}),(0,Y.jsxs)(`div`,{className:`handoff-strip`,children:[(0,Y.jsx)(`code`,{children:i}),(0,Y.jsxs)(`button`,{onClick:()=>void e.onCopy(i,`local backup queue command`),type:`button`,children:[(0,Y.jsx)(T,{size:14}),` Copy`]})]}),t.length===0?(0,Y.jsx)(`div`,{className:`backup-empty`,children:`No local-only assets are waiting for review or backup.`}):(0,Y.jsx)(`div`,{className:`backup-queue-grid`,children:Py.map(([n,r])=>(0,Y.jsxs)(`section`,{className:`backup-queue-lane`,children:[(0,Y.jsx)(`h3`,{children:r}),t.filter(e=>zy(e)===n).map(t=>(0,Y.jsx)(Iy,{asset:t,onLocalReview:e.onLocalReview,onQueueBackup:e.onQueueBackup,onSelectAsset:e.onSelectAsset,selected:e.selected?.asset_id===t.asset_id,selectedForBackup:e.selectedBackupIds.includes(t.asset_id)},t.asset_id))]},n))}),(0,Y.jsxs)(`footer`,{className:`pagination-bar`,children:[(0,Y.jsx)(`button`,{disabled:!e.snapshot||e.snapshot.pagination.page<=1,onClick:()=>e.setPage(e=>Math.max(e-1,1)),type:`button`,children:`Previous`}),(0,Y.jsxs)(`span`,{children:[e.snapshot?.pagination.page||e.page,` of `,e.snapshot?.pagination.totalPages||1]}),(0,Y.jsx)(`button`,{disabled:!e.snapshot||e.snapshot.pagination.page>=e.snapshot.pagination.totalPages,onClick:()=>e.setPage(e=>e+1),type:`button`,children:`Next`}),(0,Y.jsxs)(`label`,{children:[`Per page`,(0,Y.jsx)(`select`,{onChange:t=>e.setPageSize(Number(t.target.value)),value:e.pageSize,children:[10,25,50,100].map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]})]})]})}function Iy(e){let t=Ry(e.asset),n=be(e.asset),r=t===`approved`;return(0,Y.jsxs)(`article`,{className:`backup-queue-card ${e.selected?`selected`:``}`,children:[(0,Y.jsx)(`strong`,{children:e.asset.title}),(0,Y.jsx)(`code`,{children:e.asset.asset_id}),(0,Y.jsx)(`small`,{children:e.asset.local?.relative_path}),(0,Y.jsxs)(`div`,{className:`backup-card-meta`,children:[(0,Y.jsx)(`span`,{children:n.label}),(0,Y.jsx)(`span`,{children:By(t)}),(0,Y.jsx)(`span`,{children:fe(e.asset.local?.size_bytes)})]}),(0,Y.jsxs)(`div`,{className:`backup-card-actions`,children:[(0,Y.jsx)(`button`,{onClick:()=>e.onSelectAsset(e.asset),type:`button`,children:`Open`}),(0,Y.jsx)(`button`,{"aria-pressed":t===`approved`,onClick:()=>void e.onLocalReview(e.asset,`approved`),type:`button`,children:`Approve`}),(0,Y.jsx)(`button`,{"aria-pressed":t===`needs_revision`,onClick:()=>void e.onLocalReview(e.asset,`needs_revision`),type:`button`,children:`Revise`}),(0,Y.jsx)(`button`,{"aria-pressed":t===`rejected`,onClick:()=>void e.onLocalReview(e.asset,`rejected`),type:`button`,children:`Reject`}),(0,Y.jsx)(`button`,{disabled:!r,onClick:()=>e.onQueueBackup(e.asset),type:`button`,children:e.selectedForBackup?`Selected`:r?`Select backup`:`Approve first`})]})]})}function Ly({label:e,value:t}){return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`strong`,{children:t}),(0,Y.jsx)(`span`,{children:e})]})}function Ry(e){return e.review?.review_state||`unreviewed`}function zy(e){let t=Ry(e);return t===`ignored`?`rejected`:t}function By(e){return e===`needs_revision`?`needs revision`:e}function Vy({assets:e,onClear:t,onOpen:n}){return e.length===0?null:(0,Y.jsxs)(`div`,{className:`local-selection-toolbar`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`strong`,{children:[e.length,` local keeper`,e.length===1?``:`s`,` selected`]}),(0,Y.jsx)(`span`,{children:`Ready for S3 backup preflight`})]}),(0,Y.jsxs)(`button`,{onClick:n,children:[(0,Y.jsx)(E,{size:16}),`Back up selected`]}),(0,Y.jsx)(`button`,{"aria-label":`Clear local backup selection`,className:`icon-lite`,onClick:t,children:(0,Y.jsx)(K,{size:16})})]})}function Hy(e){return e.find(e=>Uy(e)>0)?.channel||e[0]?.channel}function Uy(e){return e.totals.needsQa+e.totals.approvedLocal+e.totals.needsRevision+e.totals.rejectedLocal}var Wy=[[`needsQa`,`Needs QA`],[`approvedLocal`,`Approved`],[`needsRevision`,`Revise`],[`rejectedLocal`,`Rejected`],[`readyToPost`,`S3 ready`],[`scheduled`,`Scheduled`],[`posted`,`Posted`]];function Gy(e){let[t,n]=(0,p.useState)(null),[r,i]=(0,p.useState)(null),[a,o]=(0,p.useState)(null),[s,c]=(0,p.useState)([]),[l,u]=(0,p.useState)(``);async function d(){try{let t=new URLSearchParams({project:e.project,limit:`4`});e.channel!==`all`&&t.set(`channel`,e.channel),n(await g(`/api/review/queue?${t.toString()}`)),i(null)}catch(e){i(e instanceof Error?e.message:String(e))}}if((0,p.useEffect)(()=>{d()},[e.project,e.channel]),r)return(0,Y.jsx)(`section`,{className:`review-queue`,children:(0,Y.jsx)(`div`,{className:`toast error`,children:r})});if(!t)return(0,Y.jsx)(`section`,{className:`review-queue`,children:(0,Y.jsx)(`div`,{className:`asset-board`,children:(0,Y.jsx)(`div`,{className:`board-head`,children:(0,Y.jsx)(`h2`,{children:`Loading review queue`})})})});let f=t.totals.needsQa+t.totals.approvedLocal+t.totals.needsRevision+t.totals.rejectedLocal,m=new Set(t.lanes.flatMap(e=>[...e.needsQa,...e.approvedLocal,...e.needsRevision,...e.rejectedLocal]).map(e=>e.asset_id)),h=s.filter(e=>m.has(e)),_=Hy(t.lanes);function v(e){c(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}async function y(t){if(h.length!==0){o(`batch`);try{await g(`/api/local-review/batch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({assetIds:h,confirmWrite:!0,notes:l,project:e.project,reviewState:t})}),c(e=>e.filter(e=>!m.has(e))),u(``),await d()}finally{o(null)}}}return(0,Y.jsxs)(`section`,{className:`review-queue`,children:[(0,Y.jsxs)(`div`,{className:`review-summary`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h2`,{children:[t.project,` review queue`]}),(0,Y.jsx)(`p`,{children:`Local-first queue for demo assets, channel posting state, and agent handoff.`}),(0,Y.jsxs)(`p`,{children:[t.totals.channels,` channels · refreshed `,pe(t.fetchedAt)]})]}),(0,Y.jsx)(Ky,{label:`Local review`,value:f}),(0,Y.jsx)(Ky,{label:`S3 ready`,value:t.totals.readyToPost}),(0,Y.jsx)(Ky,{label:`Scheduled`,value:t.totals.scheduled}),(0,Y.jsx)(Ky,{label:`Posted`,value:t.totals.posted})]}),h.length>0?(0,Y.jsxs)(`div`,{className:`batch-review-strip`,"aria-label":`Batch local review actions`,children:[(0,Y.jsxs)(`strong`,{children:[h.length,` selected`]}),(0,Y.jsx)(`textarea`,{"aria-label":`Shared batch review notes`,onChange:e=>u(e.target.value),placeholder:`Shared review notes`,rows:2,value:l}),(0,Y.jsx)(`button`,{disabled:h.length===0||a===`batch`,onClick:()=>void y(`approved`),type:`button`,children:`Approve`}),(0,Y.jsx)(`button`,{disabled:h.length===0||a===`batch`,onClick:()=>void y(`needs_revision`),type:`button`,children:`Needs revision`}),(0,Y.jsx)(`button`,{disabled:h.length===0||a===`batch`,onClick:()=>void y(`rejected`),type:`button`,children:`Reject`})]}):null,(0,Y.jsx)(`div`,{className:`queue-lanes`,children:t.lanes.map(t=>(0,Y.jsxs)(`details`,{className:`queue-lane`,open:e.channel!==`all`||t.channel===_,children:[(0,Y.jsxs)(`summary`,{children:[(0,Y.jsx)(`h3`,{children:t.channel}),(0,Y.jsxs)(`div`,{className:`lane-counts`,children:[(0,Y.jsxs)(`span`,{children:[t.totals.needsQa,` qa`]}),(0,Y.jsxs)(`span`,{children:[t.totals.approvedLocal,` approved`]}),(0,Y.jsxs)(`span`,{children:[t.totals.needsRevision,` revise`]}),(0,Y.jsxs)(`span`,{children:[t.totals.readyToPost,` ready`]}),(0,Y.jsxs)(`span`,{children:[t.totals.scheduled,` scheduled`]}),(0,Y.jsxs)(`span`,{children:[t.totals.posted,` posted`]})]})]}),(0,Y.jsxs)(`div`,{className:`queue-columns`,children:[Wy.filter(([e])=>t[e].length>0).map(([n,r])=>(0,Y.jsx)(qy,{assets:t[n],label:r,onCopy:e.onCopy,onLocalReview:async(t,n)=>{o(t.asset_id);try{await e.onLocalReview(t,n),await d()}finally{o(null)}},onOpenBackup:e.onOpenBackup,onSelectAsset:e.onSelectAsset,pendingReview:a,selected:e.selected,selectedReviewIds:h,onToggleReviewSelection:v},n)),Wy.every(([e])=>t[e].length===0)&&(0,Y.jsx)(`p`,{className:`review-empty`,children:`No items in this channel.`})]})]},t.channel))})]})}function Ky({label:e,value:t}){return(0,Y.jsxs)(`div`,{className:`queue-stat`,children:[(0,Y.jsx)(`strong`,{children:t}),(0,Y.jsx)(`span`,{children:e})]})}function qy(e){return(0,Y.jsxs)(`div`,{className:`queue-column`,children:[(0,Y.jsx)(`h4`,{children:e.label}),e.assets.map(t=>(0,Y.jsx)(Jy,{asset:t,onCopy:e.onCopy,onLocalReview:e.onLocalReview,onOpenBackup:e.onOpenBackup,onSelectAsset:e.onSelectAsset,onToggleReviewSelection:e.onToggleReviewSelection,pendingReview:e.pendingReview===t.asset_id,selected:e.selected?.asset_id===t.asset_id,selectedForReview:e.selectedReviewIds.includes(t.asset_id)},t.asset_id))]})}function Jy(e){let t=be(e.asset),n=e.asset.local?Yy(e.asset):null,r=n===`approved`,i=e.asset.source===`local`?`npx lineage local inspect --asset-id ${e.asset.asset_id} --json`:`npx lineage inspect --asset-id ${e.asset.asset_id} --json`;return(0,Y.jsxs)(`article`,{className:`queue-card ${e.selected?`selected`:``}`,onClick:()=>e.onSelectAsset(e.asset),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&e.onSelectAsset(e.asset)},role:`button`,tabIndex:0,children:[n?(0,Y.jsxs)(`label`,{className:`confirm-line`,onClick:e=>e.stopPropagation(),onKeyDown:eb,children:[(0,Y.jsx)(`input`,{checked:e.selectedForReview,onChange:()=>e.onToggleReviewSelection(e.asset.asset_id),type:`checkbox`}),(0,Y.jsx)(`span`,{children:`Select for batch review`})]}):null,(0,Y.jsx)(`strong`,{children:e.asset.title}),(0,Y.jsx)(`small`,{children:e.asset.asset_id}),(0,Y.jsxs)(`div`,{className:`lane-counts`,children:[(0,Y.jsx)(`span`,{className:`storage-chip ${t.kind}`,children:t.label}),(0,Y.jsx)(`span`,{className:`queue-tag`,children:Ee(e.asset)}),n?(0,Y.jsx)(`span`,{className:`review-chip ${n}`,children:Xy(n)}):null]}),n?(0,Y.jsxs)(`div`,{className:`review-actions`,"aria-label":`Local review actions for ${e.asset.title}`,onKeyDown:eb,children:[(0,Y.jsx)(`button`,{"aria-pressed":n===`approved`,disabled:e.pendingReview,type:`button`,onClick:t=>Qy(t,e.onLocalReview,e.asset,`approved`),children:`Approve`}),(0,Y.jsx)(`button`,{"aria-pressed":n===`needs_revision`,disabled:e.pendingReview,type:`button`,onClick:t=>Qy(t,e.onLocalReview,e.asset,`needs_revision`),children:`Needs revision`}),(0,Y.jsx)(`button`,{"aria-pressed":n===`rejected`,disabled:e.pendingReview,type:`button`,onClick:t=>Qy(t,e.onLocalReview,e.asset,`rejected`),children:`Reject`})]}):null,(0,Y.jsxs)(`div`,{className:`queue-actions`,onKeyDown:eb,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:t=>Zy(t,e.onCopy,i),children:`Copy inspect`}),e.asset.local?r?(0,Y.jsx)(`button`,{type:`button`,onClick:t=>$y(t,e.onOpenBackup,e.asset),children:`Back up`}):(0,Y.jsx)(`span`,{className:`backup-locked`,title:`Approve this local asset before backup`,children:`Backup locked until approved.`}):null]})]})}function Yy(e){return e.review?.review_state||`unreviewed`}function Xy(e){return e===`needs_revision`?`needs revision`:e}function Zy(e,t,n){e.stopPropagation(),t(n,`inspect command`)}function Qy(e,t,n,r){e.stopPropagation(),t(n,r)}function $y(e,t,n){e.stopPropagation(),t(n)}function eb(e){(e.key===`Enter`||e.key===` `)&&e.stopPropagation()}var tb={channel:`dev`,version:`0.1.18`},nb={cloud:D,image_generator:V,scheduler:ae},rb={cloud:`Cloud storage`,image_generator:`Image generation`,scheduler:`Social scheduling`},ib=[{adapterType:`cloud`,ariaLabel:`Cloud storage settings`},{adapterType:`scheduler`,ariaLabel:`Social scheduling settings`},{adapterType:`image_generator`,ariaLabel:`Image generation settings`}];function ab(e){return typeof e==`boolean`?e?`on`:`off`:typeof e==`number`?String(e):typeof e==`string`?e||`not set`:JSON.stringify(e)}function ob(e){return Object.entries(e.safe_config).filter(([e])=>![`secret`,`token`,`password`,`credential`,`apiKey`].includes(e))}function sb(e){return e.health_status===`configured`?`ok`:e.health_status===`missing_config`?`warn`:`muted`}function cb(e){return(0,Y.jsx)(`button`,{"aria-checked":e.checked,"aria-label":e.label,className:`settings-switch ${e.checked?`on`:``}`,disabled:e.disabled,onClick:e.onClick,role:`switch`,type:`button`,children:(0,Y.jsx)(`span`,{})})}function lb(e){let[t,n]=(0,p.useState)(null),[r,i]=(0,p.useState)(null),[a,s]=(0,p.useState)(!0),[c,l]=(0,p.useState)(``),[u,d]=(0,p.useState)(ym);function f(){let t=!u;if(!bm(t)){e.onToast(`error`,`Browser storage is unavailable, so the hover preview preference could not be saved`);return}d(t),e.onToast(`ok`,`Lineage hover previews ${t?`enabled`:`disabled`}`)}async function m(){s(!0);try{let[t,r]=await Promise.all([g(`/api/adapters/settings?project=${encodeURIComponent(e.project)}`),g(`/api/runtime`)]);n(t),i(r.runtime)}catch(t){e.onToast(`error`,t instanceof Error?t.message:String(t))}finally{s(!1)}}async function h(t){let r=`${t.adapter_type}:${t.provider}`;l(r);try{let r=await g(`/api/adapters/settings/${t.adapter_type}/${t.provider}`,{body:JSON.stringify({confirmWrite:!0,enabled:!t.enabled,project:e.project,safeConfig:t.safe_config}),headers:{"Content-Type":`application/json`},method:`POST`});n(e=>e&&{...e,settings:e.settings.map(e=>e.adapter_type===r.setting.adapter_type&&e.provider===r.setting.provider?r.setting:e)}),e.onToast(`ok`,`${rb[t.adapter_type]} ${r.setting.enabled?`enabled`:`disabled`}`)}catch(t){e.onToast(`error`,t instanceof Error?t.message:String(t))}finally{l(``)}}return(0,p.useEffect)(()=>{m()},[e.project]),(0,Y.jsxs)(`section`,{className:`settings-view`,children:[(0,Y.jsxs)(`header`,{className:`settings-header`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:`Settings`}),(0,Y.jsxs)(`p`,{children:[`Adapter switches, safe local preferences, and credential-source status for `,e.project,`.`]})]}),(0,Y.jsxs)(`button`,{className:`secondary-button`,disabled:a,onClick:()=>void m(),type:`button`,children:[a?(0,Y.jsx)(ee,{className:`spin`,size:17}):(0,Y.jsx)(o,{size:17}),`Refresh`]})]}),(0,Y.jsxs)(`div`,{className:`settings-sections`,children:[(0,Y.jsxs)(`section`,{"aria-label":`Release information`,className:`settings-section`,children:[(0,Y.jsx)(`h3`,{children:`Release`}),(0,Y.jsxs)(`dl`,{className:`settings-release`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Version`}),(0,Y.jsx)(`dd`,{children:r?.version||tb.version})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Channel`}),(0,Y.jsx)(`dd`,{children:r?.channel||tb.channel})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Profile`}),(0,Y.jsx)(`dd`,{children:r?.profile.id||`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Environment`}),(0,Y.jsx)(`dd`,{children:r?.profile.environment||`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Binding`}),(0,Y.jsx)(`dd`,{children:r?r.profile.bound?`bound`:`legacy unbound`:`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Git`}),(0,Y.jsx)(`dd`,{children:r?.git_sha||`not available`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Assets`}),(0,Y.jsx)(`dd`,{className:`settings-path`,children:r?.asset_root||`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`SQLite`}),(0,Y.jsx)(`dd`,{className:`settings-path`,children:r?.database.path||`loading`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Database`}),(0,Y.jsx)(`dd`,{children:r?.database.exists?`${r.database.projects??0} projects / ${r.database.workspaces??0} workspaces`:`not created yet`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Schema`}),(0,Y.jsx)(`dd`,{children:r?`${r.schema.migration_keys.length} migration marker(s)`:`loading`})]})]})]}),(0,Y.jsxs)(`section`,{"aria-label":`Lineage experience settings`,className:`settings-section`,children:[(0,Y.jsx)(`h3`,{children:`Lineage experience`}),(0,Y.jsx)(`div`,{className:`settings-grid`,children:(0,Y.jsx)(`article`,{className:`settings-card`,children:(0,Y.jsxs)(`div`,{className:`settings-card-head`,children:[(0,Y.jsx)(`span`,{className:`settings-icon`,children:(0,Y.jsx)(N,{size:19})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{children:`Hover previews`}),(0,Y.jsx)(`p`,{children:`Show the full asset and quick Branch/Re-roll/Details actions when hovering over or focusing a lineage node. Double-click details remain available when this is off.`})]}),(0,Y.jsx)(cb,{checked:u,label:`Enable lineage hover previews`,onClick:f})]})})})]}),ib.map(e=>(0,Y.jsxs)(`section`,{"aria-label":e.ariaLabel,className:`settings-section`,children:[(0,Y.jsx)(`h3`,{children:rb[e.adapterType]}),(0,Y.jsx)(`div`,{className:`settings-grid`,children:(t?.settings||[]).filter(t=>t.adapter_type===e.adapterType).map(e=>{let t=nb[e.adapter_type],n=`Enable ${e.label===`Buffer`?`Buffer scheduling`:e.label}`,r=c===`${e.adapter_type}:${e.provider}`;return(0,Y.jsxs)(`article`,{className:`settings-card`,children:[(0,Y.jsxs)(`div`,{className:`settings-card-head`,children:[(0,Y.jsx)(`span`,{className:`settings-icon`,children:(0,Y.jsx)(t,{size:19})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{children:e.label}),(0,Y.jsx)(`p`,{children:e.description})]}),(0,Y.jsx)(cb,{checked:e.enabled,disabled:r,label:n,onClick:()=>void h(e)})]}),(0,Y.jsxs)(`dl`,{className:`settings-meta`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Status`}),(0,Y.jsxs)(`dd`,{className:sb(e),children:[e.health_status===`configured`?(0,Y.jsx)(w,{size:14}):(0,Y.jsx)(C,{size:14}),e.health_status.replace(/_/g,` `)]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Credential source`}),(0,Y.jsx)(`dd`,{children:e.credential.label})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:`Secret ref`}),(0,Y.jsx)(`dd`,{children:e.credential.secret_ref||`none`})]})]}),ob(e).length>0&&(0,Y.jsx)(`div`,{className:`settings-config`,children:ob(e).map(([e,t])=>(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`strong`,{children:e}),ab(t)]},e))})]},`${e.adapter_type}:${e.provider}`)})})]},e.adapterType)),a&&!t&&(0,Y.jsx)(`div`,{className:`settings-loading`,children:`Loading settings...`})]})]})}var ub=`Lineage`,db=`Local-first creative lineage workspace`;function fb(e){let{channel:t,channels:n,placementStatus:r,project:i,projects:a,setChannel:o,setPlacementStatus:s,setProject:c,setSource:l,setStatus:u,source:d,status:f}=e,[m,h]=(0,p.useState)(!1),[g,_]=(0,p.useState)(!0),v=a.length?a.map(e=>e.project):[i];return(0,Y.jsxs)(`aside`,{className:`sidebar ${g?``:`collapsed`}`,children:[(0,Y.jsx)(`button`,{"aria-label":g?`Collapse sidebar`:`Expand sidebar`,className:`sidebar-collapse-toggle`,onClick:()=>_(e=>!e),type:`button`,children:g?(0,Y.jsx)(te,{size:16}):(0,Y.jsx)(ne,{size:16})}),(0,Y.jsxs)(`div`,{className:`brand`,children:[(0,Y.jsx)(`div`,{className:`brand-mark`,"aria-label":db,children:`L`}),(0,Y.jsxs)(`div`,{className:`brand-copy`,children:[(0,Y.jsx)(`h1`,{children:ub}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`span`,{children:i}),(0,Y.jsxs)(`span`,{"aria-label":`Lineage version ${tb.version}`,className:`brand-version`,title:`Lineage version ${tb.version}, ${tb.channel} channel`,children:[`v`,tb.version]})]})]})]}),(0,Y.jsxs)(`button`,{"aria-controls":`mobile-sidebar-controls`,"aria-expanded":m,className:`mobile-filter-toggle`,onClick:()=>h(e=>!e),type:`button`,children:[(0,Y.jsx)(se,{size:16}),`Filters`,(0,Y.jsx)(S,{className:m?`open`:``,size:16})]}),(0,Y.jsxs)(`div`,{className:`sidebar-mobile-collapse`,"data-open":m,id:`mobile-sidebar-controls`,children:[(0,Y.jsxs)(`div`,{className:`side-section`,children:[(0,Y.jsx)(`h2`,{children:`Project`}),(0,Y.jsx)(pb,{id:`asset-project-filter`,label:`Project`,value:i,values:v,onChange:c})]}),(0,Y.jsxs)(`section`,{className:`side-section`,children:[(0,Y.jsx)(`h2`,{children:`Filters`}),(0,Y.jsx)(pb,{id:`asset-source-filter`,label:`Source`,value:d,values:J,onChange:e=>l(e)}),(0,Y.jsx)(pb,{id:`asset-status-filter`,label:`Status`,value:f,values:q,onChange:e=>u(e)}),(0,Y.jsx)(pb,{id:`asset-channel-filter`,label:`Channel`,value:t,values:n,onChange:o}),(0,Y.jsx)(pb,{id:`asset-placement-filter`,label:`Placement`,value:r,values:ge,onChange:e=>s(e)})]})]})]})}function pb({id:e,label:t,value:n,values:r,onChange:i}){return(0,Y.jsxs)(`label`,{htmlFor:e,children:[t,(0,Y.jsx)(`select`,{"aria-label":t,id:e,value:n,onChange:e=>i(e.target.value),children:r.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]})}var mb=[{label:`Lineage`,view:`lineage`},{label:`Review`,view:`review`},{label:`Assets`,view:`assets`},{label:`Agents`,view:`agents`},{label:`Settings`,view:`settings`}],hb=[{label:`Ledger`,view:`ledger`},{label:`Content batches`,view:`content`},{label:`Backup queue`,view:`backup`}];function gb(e){let t=hb.some(t=>t.view===e.view);function n(t){e.setView(t),e.onMoreOpenChange(!1)}function r(t){e.setView(t),e.onMoreOpenChange(!1)}return(0,Y.jsxs)(`header`,{className:`topbar`,children:[(0,Y.jsxs)(`div`,{className:`view-tabs`,role:`tablist`,"aria-label":`${ub} views`,children:[mb.map(t=>(0,Y.jsx)(`button`,{"aria-pressed":e.view===t.view,className:e.view===t.view?`active`:``,onClick:()=>n(t.view),type:`button`,children:t.label},t.view)),(0,Y.jsxs)(`div`,{className:`more-menu`,children:[(0,Y.jsxs)(`button`,{"aria-expanded":e.moreOpen,"aria-haspopup":`menu`,"aria-pressed":t,className:t?`active`:``,onClick:()=>e.onMoreOpenChange(!e.moreOpen),type:`button`,children:[(0,Y.jsx)(j,{size:16}),` More `,(0,Y.jsx)(S,{className:e.moreOpen?`open`:``,size:15})]}),e.moreOpen&&(0,Y.jsx)(`div`,{className:`more-menu-popover`,role:`menu`,children:hb.map(t=>(0,Y.jsx)(`button`,{"aria-pressed":e.view===t.view,onClick:()=>r(t.view),role:`menuitem`,type:`button`,children:t.label},t.view))})]})]}),(0,Y.jsx)(_b,{runtime:e.runtime,unavailable:e.runtimeIdentityUnavailable}),(0,Y.jsxs)(`div`,{className:`searchbox`,children:[(0,Y.jsx)(ie,{size:17}),(0,Y.jsx)(`input`,{onChange:t=>e.setQuery(t.target.value),placeholder:`Search assets, campaigns, hooks`,value:e.query})]}),e.view!==`lineage`&&(0,Y.jsxs)(`button`,{"aria-expanded":e.assetDetailsOpen,className:`secondary-button`,disabled:!e.canInspectAsset,onClick:()=>{e.onMoreOpenChange(!1),e.setAssetDetailsOpen(!e.assetDetailsOpen)},type:`button`,children:[(0,Y.jsx)(I,{size:17}),`Details`]}),(0,Y.jsx)(`button`,{className:`icon-button`,disabled:e.loading,onClick:()=>void e.refresh(),title:`Refresh current page`,children:e.loading?(0,Y.jsx)(ee,{className:`spin`,size:18}):(0,Y.jsx)(o,{size:18})}),(0,Y.jsxs)(`button`,{className:`primary-button`,onClick:()=>e.setUploadOpen(!0),children:[(0,Y.jsx)(de,{size:17}),`Upload`]})]})}function _b(e){if(e.unavailable)return(0,Y.jsx)(`div`,{"aria-label":`Lineage runtime identity unavailable`,className:`runtime-identity-badge unavailable`,children:`IDENTITY UNAVAILABLE`});if(!e.runtime)return(0,Y.jsx)(`div`,{"aria-label":`Loading Lineage runtime identity`,className:`runtime-identity-badge loading`,children:`IDENTITY LOADING`});let{profile:t}=e.runtime,n=t.bound?``:` · UNBOUND`,r=[`${t.environment.toUpperCase()} profile ${t.id}${t.bound?``:` (unbound)`}`,`Channel ${e.runtime.channel}`,`Version ${e.runtime.version}`,t.warning].filter(Boolean).join(` · `);return(0,Y.jsxs)(`div`,{"aria-label":`Lineage ${t.environment} profile ${t.id}${t.bound?``:` unbound`}`,className:`runtime-identity-badge ${t.environment} ${t.bound?`bound`:`unbound`}`,"data-profile-id":t.id,title:r,children:[(0,Y.jsx)(`strong`,{children:t.environment.toUpperCase()}),(0,Y.jsxs)(`span`,{children:[t.id,n]})]})}function vb({toast:e,onDismiss:t}){return(0,Y.jsxs)(`div`,{className:`toast ${e.type}`,role:`status`,children:[e.type===`ok`?(0,Y.jsx)(w,{size:16}):(0,Y.jsx)(oe,{size:16}),(0,Y.jsx)(`span`,{children:e.message}),(0,Y.jsx)(`button`,{onClick:t,children:`Dismiss`})]})}var yb=200*1024*1024;function bb({channels:e,project:t,onClose:n,onUploaded:r,onError:i}){let[a,o]=(0,p.useState)({assetId:``,audience:`short-form-creators`,campaign:`2026-06-organic-traffic-test`,channel:e[0]||`meta`,cta:``,hook:``,status:`working`,title:``,type:`image`,utmContent:``}),[s,c]=(0,p.useState)(null),[l,u]=(0,p.useState)(!1),[d,f]=(0,p.useState)(!1);function m(e,t){o(n=>({...n,[e]:t}))}function h(e){o(t=>({...t,assetId:t.assetId||me(`demo-${t.channel}-${e}`),title:e,utmContent:t.utmContent||me(e).replaceAll(`-`,`_`)}))}function _(e){if(!e){c(null);return}if(e.size>yb){i(`File is larger than ${fe(yb)}`);return}c(e)}async function v(e){if(e.preventDefault(),!s)return i(`Choose a file before uploading`);f(!0);try{let e=new FormData;Object.entries({project:t,...a,confirmWrite:String(l)}).forEach(([t,n])=>e.append(t,n)),e.append(`file`,s),await r((await g(`/api/assets/upload`,{method:`POST`,body:e})).message)}catch(e){i(e instanceof Error?e.message:String(e))}finally{f(!1)}}return(0,Y.jsx)(`div`,{className:`drawer-backdrop`,children:(0,Y.jsxs)(`form`,{className:`upload-drawer`,onSubmit:v,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{children:`Upload asset`}),(0,Y.jsx)(`p`,{children:t})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:`Close`})]}),(0,Y.jsxs)(`label`,{className:`file-drop`,children:[(0,Y.jsx)(de,{size:20}),(0,Y.jsx)(`span`,{children:s?s.name:`Choose creative export up to ${fe(yb)}`}),(0,Y.jsx)(`input`,{type:`file`,onChange:e=>_(e.target.files?.[0])})]}),(0,Y.jsxs)(`div`,{className:`form-grid`,children:[(0,Y.jsxs)(`label`,{children:[`Title`,(0,Y.jsx)(`input`,{value:a.title,onChange:e=>h(e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{children:[`Asset ID`,(0,Y.jsx)(`input`,{value:a.assetId,onChange:e=>m(`assetId`,e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{children:[`Campaign`,(0,Y.jsx)(`input`,{value:a.campaign,onChange:e=>m(`campaign`,e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{children:[`Channel`,(0,Y.jsx)(`select`,{value:a.channel,onChange:e=>m(`channel`,e.target.value),children:e.map(e=>(0,Y.jsx)(`option`,{children:e},e))})]}),(0,Y.jsxs)(`label`,{children:[`Audience`,(0,Y.jsx)(`input`,{value:a.audience,onChange:e=>m(`audience`,e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{children:[`Status`,(0,Y.jsxs)(`select`,{value:a.status,onChange:e=>m(`status`,e.target.value),children:[(0,Y.jsx)(`option`,{children:`working`}),(0,Y.jsx)(`option`,{children:`published`})]})]}),(0,Y.jsxs)(`label`,{children:[`Type`,(0,Y.jsx)(`select`,{value:a.type,onChange:e=>m(`type`,e.target.value),children:_e.map(e=>(0,Y.jsx)(`option`,{children:e},e))})]}),(0,Y.jsxs)(`label`,{children:[`UTM content`,(0,Y.jsx)(`input`,{value:a.utmContent,onChange:e=>m(`utmContent`,e.target.value),required:!0})]}),(0,Y.jsxs)(`label`,{className:`wide`,children:[`Hook`,(0,Y.jsx)(`input`,{value:a.hook,onChange:e=>m(`hook`,e.target.value)})]}),(0,Y.jsxs)(`label`,{className:`wide`,children:[`CTA`,(0,Y.jsx)(`input`,{value:a.cta,onChange:e=>m(`cta`,e.target.value),required:!0})]})]}),(0,Y.jsxs)(`label`,{className:`confirm-line`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,Y.jsx)(`span`,{children:`Confirm write to the production asset bucket`})]}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:`Cancel`}),(0,Y.jsxs)(`button`,{className:`primary-button`,disabled:d||!l,children:[d?(0,Y.jsx)(ee,{className:`spin`,size:16}):(0,Y.jsx)(de,{size:16}),`Upload`]})]})]})})}function xb(e,t){let n=`${e} ${t}`.toLowerCase();return n.includes(`agent`)||n.includes(`command`)||n.includes(`selection`)||n.includes(`next context`)}function Sb(){return typeof window>`u`?he:new URLSearchParams(window.location.search).get(`project`)||`demo-project`}function Cb(){let[e,t]=(0,p.useState)(null),[n,r]=(0,p.useState)(null),[i,a]=(0,p.useState)(Sb),[o,s]=(0,p.useState)([]),[c,l]=(0,p.useState)(`all`),[u,d]=(0,p.useState)(`all`),[f,m]=(0,p.useState)(`local`),[h,y]=(0,p.useState)(`all`),[b,x]=(0,p.useState)(``),[S,C]=(0,p.useState)(1),[w,T]=(0,p.useState)(10),[E,D]=(0,p.useState)(!1),[O,k]=(0,p.useState)(!0),[A,j]=(0,p.useState)(null),[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)({}),[I,L]=(0,p.useState)({}),[R,z]=(0,p.useState)([]),[B,V]=(0,p.useState)([]),[H,U]=(0,p.useState)(!1),[W,ee]=(0,p.useState)(!1),[G,te]=(0,p.useState)(`lineage`),[ne,re]=(0,p.useState)(!1),[ie,ae]=(0,p.useState)(null),[oe,se]=(0,p.useState)(0),[ce,le]=(0,p.useState)(null),[ue,de]=(0,p.useState)(!1),[K,fe]=(0,p.useState)(null),pe=(0,p.useCallback)(e=>{fe(t=>e?`lineage-actions`:t===`lineage-actions`?null:t)},[]),me=(0,p.useCallback)(e=>{fe(t=>e?`topbar-more`:t===`topbar-more`?null:t)},[]),he=(0,p.useCallback)((e,t)=>{j({type:e,message:t})},[]),q=e?.catalog.project===i?e:null,ge=q?.assets||[],J=Se(ge,n)||(ie?.project===i&&ie.asset_id===n?ie:void 0),_e=J?.asset_id||``,ve=[...B.filter(e=>R.includes(e.asset_id)),...ge.filter(e=>R.includes(e.asset_id)&&e.local?.relative_path)].filter((e,t,n)=>n.findIndex(t=>t.asset_id===e.asset_id)===t),ye=J&&P[J.asset_id]||null,be=(0,p.useMemo)(()=>[`all`,...q?.facets.channels||[]],[q]),xe=(0,p.useMemo)(()=>({assets:q?.catalog.asset_count||0,live:q?.liveObjects.length||0,orphan:q?.orphanObjects.length||0,size:q?.facets.totalSizeBytes||0}),[q]);async function we(){try{let e=await g(`/api/projects`);s(e.projects),a(t=>e.projects.some(e=>e.project===t)?t:e.projects[0]?.project||`demo-project`)}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}}async function Te(){try{let e=await g(`/api/runtime`);le(e.runtime),de(!1)}catch{le(null),de(!0)}}async function Ee(){k(!0);try{let e=await g(`/api/assets?${De()}`);t(e),r(t=>Se(e.assets,t)?.asset_id||(t&&ie?.asset_id===t?t:null)),F({}),L({})}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}finally{k(!1)}}function De(){let e=new URLSearchParams({project:i,page:String(S),pageSize:String(w),live:String(E),source:f});return c!==`all`&&e.set(`status`,c),u!==`all`&&e.set(`placementStatus`,u),h!==`all`&&e.set(`channel`,h),b.trim()&&e.set(`q`,b.trim()),e.toString()}async function Oe(e){try{let t=await e();j({type:`ok`,message:t.message}),F({}),await Ee()}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}}async function ke(e,t={}){if(!Ce(e))return null;let n=P[e.asset_id];if(n)return t.open&&window.open(n,`_blank`,`noopener,noreferrer`),n;if(e.local?.relative_path){let n=`/api/assets/local-preview?${new URLSearchParams({project:i,path:e.local.relative_path}).toString()}`;return F(t=>({...t,[e.asset_id]:n})),L(t=>({...t,[e.asset_id]:``})),t.open&&window.open(n,`_blank`,`noopener,noreferrer`),n}try{let n=await g(`/api/assets/presign`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,assetId:e.asset_id,expiresIn:900})});return F(t=>({...t,[e.asset_id]:n.url})),L(t=>({...t,[e.asset_id]:``})),t.open&&window.open(n.url,`_blank`,`noopener,noreferrer`),n.url}catch(n){let r=n instanceof Error?n.message:String(n);return L(t=>({...t,[e.asset_id]:r})),t.quiet||j({type:`error`,message:`Preview unavailable. Check S3 credentials or pull the asset locally.`}),null}}async function Ae(e,t){try{let n=await Im(e);j({type:`ok`,message:n.method===`fallback`?`Copied ${t} using browser fallback`:`Copied ${t}`}),N(xb(t,e)?{label:t,text:e}:null)}catch(n){N(xb(t,e)?{label:t,text:e}:null),j({type:`error`,message:n instanceof Error?n.message:String(n)})}}async function Me(e){let t=await ke(e,{quiet:!0});t&&await Ae(t,`preview link`)}function Ne(e){e.local?.relative_path&&(z(t=>t.includes(e.asset_id)?t:[...t,e.asset_id]),V(t=>t.some(t=>t.asset_id===e.asset_id)?t:[...t,e]))}function Pe(e){ae(e),r(e.asset_id),re(!0)}async function Fe(e){r(e),re(!0);let t=ge.find(t=>t.asset_id===e);if(t){ae(t);return}try{let t=await g(`/api/assets/lookup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,assetIds:[e]})});t.assets[0]&&ae(t.assets[0])}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}}function Re(){m(`local`),l(`all`),d(`all`),x(``),te(`backup`)}async function ze(e){try{e.assetId&&r(e.assetId),e.view===`lineage`&&e.workspaceId&&await g(`/api/lineage-workspaces/${encodeURIComponent(e.workspaceId)}/activate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({project:i,confirmWrite:!0})}),re(!1),te(e.view),j({type:`ok`,message:`Opened ${e.claim.target_title||e.claim.target_id}`})}catch(e){j({type:`error`,message:e instanceof Error?e.message:String(e)})}}function Be(e){e.local?.relative_path&&(z(t=>t.includes(e.asset_id)?t.filter(t=>t!==e.asset_id):[...t,e.asset_id]),V(t=>t.filter(t=>t.asset_id!==e.asset_id)))}return(0,p.useEffect)(()=>{we(),Te()},[]),(0,p.useEffect)(()=>{let e=new URLSearchParams(window.location.search);e.get(`project`)!==i&&(e.set(`project`,i),window.history.replaceState(null,``,`${window.location.pathname}?${e.toString()}${window.location.hash}`))},[i]),(0,p.useEffect)(()=>{j(null),N(null),ae(null),re(!1)},[i]),(0,p.useEffect)(()=>{Ee()},[S,w,i,c,u,f,h,b,E]),(0,p.useEffect)(()=>{C(1)},[i,c,u,f,h,b,w]),(0,p.useEffect)(()=>{!Ce(J)||P[J.asset_id]||ke(J,{quiet:!0})},[J?.asset_id,J?.s3?.version_id,P]),(0,p.useEffect)(()=>{if(A?.type!==`ok`)return;let e=window.setTimeout(()=>j(null),2600);return()=>window.clearTimeout(e)},[A?.message,A?.type]),(0,p.useEffect)(()=>{G===`backup`&&(m(`local`),l(`all`),d(`all`))},[G]),(0,p.useEffect)(()=>{fe(null)},[G]),(0,p.useEffect)(()=>{_e||re(!1)},[_e]),(0,Y.jsxs)(`div`,{className:`app-shell ${G===`lineage`?`lineage-mode`:``}`,children:[(0,Y.jsx)(fb,{channel:h,channels:be,liveSync:E,placementStatus:u,project:i,projects:o,setChannel:y,setPlacementStatus:d,setProject:a,setSource:m,setStatus:l,setView:te,showBackupQueue:Re,source:f,snapshot:q,status:c,totals:xe}),(0,Y.jsxs)(`main`,{className:`workspace`,children:[(0,Y.jsx)(gb,{assetDetailsOpen:ne,canInspectAsset:!!J,loading:O,moreOpen:K===`topbar-more`,onMoreOpenChange:me,query:b,refresh:Ee,runtime:ce,runtimeIdentityUnavailable:ue,setAssetDetailsOpen:re,setQuery:x,setUploadOpen:ee,setView:e=>e===`backup`?Re():te(e),view:G}),A&&(0,Y.jsx)(vb,{toast:A,onDismiss:()=>j(null)}),M&&(0,Y.jsx)(xt,{copiedText:M,onDismiss:()=>N(null)}),(0,Y.jsx)(Et,{onCopy:Ae,project:i,refreshKey:oe,selectedAsset:J,view:G}),G===`review`?(0,Y.jsx)(Gy,{channel:h,onCopy:Ae,onLocalReview:async(e,t)=>{await Oe(()=>_(`/api/local-review/${e.asset_id}`,i,{reviewState:t,confirmWrite:!0}))},onOpenBackup:e=>{Ne(e),U(!0)},onSelectAsset:e=>{Pe(e)},project:i,selected:J}):G===`ledger`?(0,Y.jsx)(zt,{project:i,query:b,onOpenAsset:Fe}):G===`content`?(0,Y.jsx)(ht,{onCopy:Ae,onOpenAsset:Fe,onToast:he,onWorkTargetsChanged:()=>se(e=>e+1),project:i,selectedAsset:J}):G===`agents`?(0,Y.jsx)(Le,{onCopy:Ae,onOpenWork:ze,project:i}):G===`backup`?(0,Y.jsx)(Fy,{assets:ge,onCopy:Ae,onLocalReview:async(e,t)=>{await Oe(()=>_(`/api/local-review/${e.asset_id}`,i,{reviewState:t,confirmWrite:!0}))},onOpenBackup:()=>U(!0),onQueueBackup:Ne,onSelectAsset:e=>{Pe(e)},page:S,pageSize:w,project:i,selected:J,selectedBackupIds:R,setPage:C,setPageSize:T,snapshot:q}):G===`assets`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Vy,{assets:ve,onClear:()=>{z([]),V([])},onOpen:()=>U(!0)}),(0,Y.jsx)(Ie,{assets:ge,liveSync:E,onCopy:Ae,onSelectionChanged:()=>se(e=>e+1),page:S,pageSize:w,previewUrls:P,project:i,selected:J,setLiveSync:D,setPage:C,setPageSize:T,setSelectedId:r,snapshot:q,source:f,totals:xe})]}):G===`settings`?(0,Y.jsx)(lb,{onToast:he,project:i}):(0,Y.jsx)(Dy,{asset:J,actionsOpen:K===`lineage-actions`,onAssetsChanged:Ee,onActionsOpenChange:pe,onSelectedAsset:r,onToast:he,project:i})]}),G!==`lineage`&&ne&&(0,Y.jsx)(je,{asset:J,onArchive:e=>void Oe(()=>_(`/api/assets/archive`,i,{assetId:e.asset_id,confirmArchive:!0})),onClose:()=>re(!1),onCopy:(e,t)=>void Ae(e,t),onCopyPreview:e=>void Me(e),onDelete:(e,t)=>void Oe(()=>_(`/api/assets/delete-object`,i,{assetId:e.asset_id,confirmation:t})),onPlacement:(e,t,n)=>void Oe(()=>_(`/api/assets/placement`,i,{assetId:e.asset_id,channel:e.channel,...v(n),status:t,confirmWrite:!0})),onPresign:e=>void ke(e,{open:!0}),onPromote:e=>void Oe(()=>_(`/api/assets/promote`,i,{assetId:e.asset_id,confirmWrite:!0})),onPull:e=>void Oe(()=>_(`/api/assets/pull`,i,{assetId:e.asset_id,out:`.asset-scratch`})),onToggleBackup:Be,previewError:J&&I[J.asset_id]||null,previewUrl:ye,selectedForBackup:J?R.includes(J.asset_id):!1}),W&&(0,Y.jsx)(bb,{channels:be.filter(e=>e!==`all`),project:i,onClose:()=>ee(!1),onError:e=>j({type:`error`,message:e}),onUploaded:async e=>{j({type:`ok`,message:e}),ee(!1),await Ee()}}),H&&(0,Y.jsx)(Ay,{assets:ve,project:i,onClose:()=>U(!1),onError:e=>j({type:`error`,message:e}),onDone:async e=>{j({type:`ok`,message:e}),z([]),V([]),U(!1),await Ee()}})]})}(0,m.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(p.StrictMode,{children:(0,Y.jsx)(Cb,{})}));
@@ -1 +1 @@
1
- import{a as e,c as t,d as n,i as r,l as i,n as a,o,p as s,r as c,s as l,t as u}from"./jsx-runtime-DAFSxiwi.js";var d=t(`ArrowDownRight`,[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]),f=t(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),p=t(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),m=t(`MousePointer2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),h=t(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),g=s(n(),1),_=i(),v=`/assets/agent-shared-state-DOfpTLiw.webp`,y=`/assets/agent-to-canvas-DtIu_cPq.mp4`,b=`/assets/attempt-history-D6wdic6n.webp`,x=`/assets/branching-tree-B8I5_S6D.png`,S=`/assets/canvas-cli-DHBacq7r.png`,C=`/assets/hero-agent-sync-CSyh0tHy.mp4`,w=`/assets/hero-board-DG3ED4AW.webp`,T=`/assets/hero-lineage-growth-Bsl9tiq-.mp4`,E=`/assets/hero-trace-connections-Bb52ABBc.mp4`,D=`/assets/human-selection-BdDBDE-I.webp`,O=`/assets/human-to-agent-D1z92ZO9.mp4`,k=`/assets/reroll-history-DQcEH42R.mp4`,A=[{id:`hero-lineage-growth`,eyebrow:`From agent to canvas`,title:`Turn agent output into visual creative history.`,description:`Every new asset joins the lineage instead of disappearing into a chat.`,kind:`video`,src:T,poster:w,fit:`contain`},{id:`hero-trace-connections`,eyebrow:`Context stays connected`,title:`Keep the reasoning behind the visual work.`,description:`Prompts, branches, and decisions remain attached to every result.`,kind:`video`,src:E,poster:x,fit:`contain`},{id:`hero-agent-sync`,eyebrow:`One shared creative state`,title:`Humans and agents continue from the same place.`,description:`New agent work returns to the canvas, ready for the next decision.`,kind:`video`,src:C,poster:v,fit:`contain`}],j={"human-to-agent":{id:`human-to-agent`,eyebrow:`Human → agent`,title:`Send the exact creative context to Codex.`,description:`A canvas selection becomes actionable agent context.`,kind:`video`,src:O,poster:S,fit:`contain`},"agent-to-canvas":{id:`agent-to-canvas`,eyebrow:`Agent → canvas`,title:`Bring agent results back into the shared state.`,description:`New agent output returns to the same visual workspace.`,kind:`video`,src:y,poster:v,fit:`contain`},"trace-tree":{id:`trace-tree`,eyebrow:`Lineage graph`,title:`Every branch remains visible.`,description:`The graph preserves the path from source to variation.`,kind:`image`,src:x,fit:`cover`},"selection-still":{id:`selection-still`,eyebrow:`Selection + direction`,title:`Choose exactly where the work continues.`,description:`Inspect, select, and turn the decision into precise context.`,kind:`image`,src:D,fit:`cover`,position:`left`},"reroll-history":{id:`reroll-history`,eyebrow:`Attempt history`,title:`Ask for another pass without losing the first.`,description:`The new attempt returns without replacing earlier work.`,kind:`video`,src:k,poster:b,fit:`cover`}},M=u(),N=`npm install -g @mean-weasel/lineage@latest`;function P(){let[e,t]=(0,g.useState)(!1);async function n(){try{await navigator.clipboard.writeText(N),t(!0),window.setTimeout(()=>t(!1),1800)}catch{t(!1)}}return(0,M.jsxs)(`div`,{className:`landing-shell`,children:[(0,M.jsxs)(`header`,{className:`landing-nav`,children:[(0,M.jsxs)(`a`,{"aria-label":`Lineage home`,className:`landing-brand`,href:`#top`,children:[(0,M.jsxs)(`span`,{"aria-hidden":`true`,className:`landing-brand-mark`,children:[(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{})]}),(0,M.jsx)(`span`,{children:`LINEAGE`})]}),(0,M.jsxs)(`nav`,{"aria-label":`Landing page`,children:[(0,M.jsx)(`a`,{href:`#loop`,children:`How it works`}),(0,M.jsx)(`a`,{href:`#features`,children:`What it enables`}),(0,M.jsx)(`a`,{href:`#install`,children:`Install`})]}),(0,M.jsxs)(`a`,{className:`nav-cta`,href:`https://github.com/mean-weasel/lineage`,rel:`noreferrer`,target:`_blank`,children:[`View on GitHub `,(0,M.jsx)(d,{"aria-hidden":`true`,size:16})]})]}),(0,M.jsxs)(`main`,{id:`top`,children:[(0,M.jsxs)(`section`,{className:`hero-section`,children:[(0,M.jsxs)(`div`,{className:`hero-grid`,"aria-hidden":`true`,children:[(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{})]}),(0,M.jsxs)(`div`,{className:`hero-copy`,children:[(0,M.jsxs)(`p`,{className:`section-index`,children:[(0,M.jsx)(`span`,{children:`01`}),` Human × agent creative work`]}),(0,M.jsx)(`h1`,{children:`The UX where humans and agents shape visual work together.`}),(0,M.jsx)(`p`,{className:`hero-summary`,children:`Lineage is the shared visual workspace where humans and agents create, review, and evolve creative assets together.`}),(0,M.jsxs)(`div`,{className:`hero-actions`,children:[(0,M.jsxs)(`a`,{className:`primary-cta`,href:`#loop`,children:[`See the collaboration loop `,(0,M.jsx)(l,{"aria-hidden":`true`,size:18})]}),(0,M.jsx)(`a`,{className:`text-cta`,href:`#install`,children:`Install Lineage`})]})]}),(0,M.jsx)(`div`,{className:`hero-media-wrap`,children:(0,M.jsx)(F,{})})]}),(0,M.jsxs)(`section`,{className:`loop-section`,id:`loop`,children:[(0,M.jsxs)(`div`,{className:`loop-heading`,children:[(0,M.jsxs)(`p`,{className:`section-index`,children:[(0,M.jsx)(`span`,{children:`02`}),` Context travels both ways`]}),(0,M.jsx)(`h2`,{children:`One creative state for humans and agents.`}),(0,M.jsxs)(`div`,{className:`loop-copy`,children:[(0,M.jsx)(`p`,{className:`loop-problem`,children:`Chat is the right UX for directing agent-driven creative work. But it isn’t built to hold the state of that work.`}),(0,M.jsx)(`p`,{children:`Lineage preserves every asset, path, prompt, relationship, and decision in a shared record—precise enough for agents to retrieve through the CLI and organized visually for humans to review and direct.`})]})]}),(0,M.jsxs)(`div`,{className:`interface-grid`,children:[(0,M.jsxs)(`article`,{className:`interface-card agent-card`,children:[(0,M.jsx)(`div`,{className:`interface-number`,children:`A`}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`card-eyebrow`,children:`For agents`}),(0,M.jsx)(`h3`,{children:`Never lose the state behind the work.`}),(0,M.jsx)(`p`,{children:`Every asset, path, prompt, iteration, and relationship stays available so the work can continue accurately.`})]}),(0,M.jsx)(I,{definition:j[`agent-to-canvas`],showCaption:!0})]}),(0,M.jsxs)(`div`,{className:`loop-bridge`,"aria-label":`Assets, context, selections, and annotations move through one creative state`,children:[(0,M.jsx)(`span`,{children:`Assets + context`}),(0,M.jsx)(`div`,{className:`bridge-line`,children:(0,M.jsx)(l,{"aria-hidden":`true`,size:18})}),(0,M.jsxs)(`strong`,{children:[`ONE CREATIVE`,(0,M.jsx)(`br`,{}),`STATE`]}),(0,M.jsx)(`div`,{className:`bridge-line reverse`,children:(0,M.jsx)(l,{"aria-hidden":`true`,size:18})}),(0,M.jsx)(`span`,{children:`Selections + annotations`})]}),(0,M.jsxs)(`article`,{className:`interface-card human-card`,children:[(0,M.jsx)(`div`,{className:`interface-number`,children:`H`}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`card-eyebrow`,children:`For humans`}),(0,M.jsx)(`h3`,{children:`Keep your creative history organized.`}),(0,M.jsx)(`p`,{children:`Review and compare the history, then use selections and annotations to direct the next iteration.`})]}),(0,M.jsx)(I,{definition:j[`human-to-agent`],showCaption:!0})]})]})]}),(0,M.jsxs)(`section`,{className:`features-section`,id:`features`,children:[(0,M.jsxs)(`div`,{className:`features-heading`,children:[(0,M.jsxs)(`p`,{className:`section-index`,children:[(0,M.jsx)(`span`,{children:`03`}),` What it enables`]}),(0,M.jsx)(`h2`,{children:`A shared creative history you and your agents can build on.`}),(0,M.jsx)(`p`,{children:`Keep the useful context behind every asset available, understandable, and ready for the next human or agent action.`})]}),(0,M.jsxs)(`div`,{className:`feature-grid`,children:[(0,M.jsx)(R,{icon:(0,M.jsx)(p,{}),media:j[`trace-tree`],number:`01`,title:`Trace every iteration`,children:`Follow an asset from its origin through branches, selections, and final campaign formats.`}),(0,M.jsx)(R,{icon:(0,M.jsx)(m,{}),media:j[`selection-still`],number:`02`,title:`Continue from the exact asset`,children:`Select any useful point in the lineage and bring that context into the next agent session.`}),(0,M.jsx)(R,{icon:(0,M.jsx)(a,{}),media:j[`reroll-history`],number:`03`,title:`Keep every agent attempt tied to your decisions`,children:`Review another pass without losing earlier results, prompts, relationships, or human direction.`})]}),(0,M.jsxs)(`div`,{className:`final-cta`,id:`install`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`p`,{className:`section-index`,children:[(0,M.jsx)(`span`,{children:`→`}),` Local-first and agent-ready`]}),(0,M.jsx)(`h3`,{children:`One durable home for visual work made with your agents.`})]}),(0,M.jsxs)(`div`,{className:`install-panel`,children:[(0,M.jsxs)(`div`,{className:`install-command`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`$`}),(0,M.jsx)(`code`,{children:N}),(0,M.jsxs)(`button`,{"aria-label":`Copy install command`,onClick:()=>void n(),type:`button`,children:[e?(0,M.jsx)(f,{"aria-hidden":`true`,size:18}):(0,M.jsx)(r,{"aria-hidden":`true`,size:18}),e?`Copied`:`Copy`]})]}),(0,M.jsxs)(`div`,{className:`install-meta`,children:[(0,M.jsx)(`span`,{children:`Local-first`}),(0,M.jsx)(`span`,{children:`MIT licensed`}),(0,M.jsx)(`span`,{children:`Codex plugin`}),(0,M.jsx)(`span`,{children:`CLI access`})]}),(0,M.jsxs)(`a`,{className:`primary-cta dark`,href:`https://github.com/mean-weasel/lineage`,rel:`noreferrer`,target:`_blank`,children:[`Explore Lineage on GitHub `,(0,M.jsx)(d,{"aria-hidden":`true`,size:18})]})]})]})]})]}),(0,M.jsxs)(`footer`,{children:[(0,M.jsxs)(`a`,{className:`landing-brand`,href:`#top`,children:[(0,M.jsxs)(`span`,{"aria-hidden":`true`,className:`landing-brand-mark`,children:[(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{})]}),(0,M.jsx)(`span`,{children:`LINEAGE`})]}),(0,M.jsx)(`p`,{children:`The shared visual workspace for humans and agents.`}),(0,M.jsxs)(`a`,{href:`https://github.com/mean-weasel/lineage`,rel:`noreferrer`,target:`_blank`,children:[`GitHub `,(0,M.jsx)(d,{"aria-hidden":`true`,size:14})]})]})]})}function F(){let[t,n]=(0,g.useState)(0),r=A[t];function i(e){n(t=>(t+e+A.length)%A.length)}return(0,M.jsxs)(`div`,{"aria-label":`Lineage product tour`,"aria-roledescription":`carousel`,className:`hero-carousel`,onKeyDown:e=>{e.key===`ArrowLeft`&&i(-1),e.key===`ArrowRight`&&i(1)},role:`region`,tabIndex:0,children:[(0,M.jsx)(I,{definition:r,hero:!0}),(0,M.jsxs)(`div`,{"aria-live":`polite`,className:`hero-carousel-caption`,children:[(0,M.jsx)(`span`,{className:`media-eyebrow`,children:r.eyebrow}),(0,M.jsx)(`strong`,{children:r.title}),(0,M.jsx)(`small`,{children:r.description})]}),(0,M.jsxs)(`div`,{className:`hero-carousel-controls`,children:[(0,M.jsx)(`button`,{"aria-label":`Previous carousel slide`,onClick:()=>i(-1),type:`button`,children:(0,M.jsx)(o,{"aria-hidden":`true`,size:19})}),(0,M.jsx)(`div`,{"aria-label":`Slide ${t+1} of ${A.length}`,className:`carousel-progress`,children:A.map((e,r)=>(0,M.jsx)(`button`,{"aria-current":r===t?`true`:void 0,"aria-label":`Show slide ${r+1}: ${e.title}`,className:r===t?`active`:``,onClick:()=>n(r),type:`button`},e.id))}),(0,M.jsx)(`button`,{"aria-label":`Next carousel slide`,onClick:()=>i(1),type:`button`,children:(0,M.jsx)(e,{"aria-hidden":`true`,size:19})})]})]})}function I({definition:e,hero:t=!1,showCaption:n=!1}){return(0,M.jsxs)(`figure`,{className:`media-slot media-slot-ready ${`media-fit-${e.fit??`cover`}`} ${e.position===`left`?`media-position-left`:``} ${t?`media-slot-hero`:``}`,"data-media-slot":e.id,children:[e.kind===`video`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(L,{definition:e}),e.poster&&(0,M.jsx)(`img`,{alt:``,"aria-hidden":`true`,className:`reduced-motion-poster`,src:e.poster})]}):(0,M.jsx)(`img`,{alt:e.description,loading:`lazy`,src:e.src}),n&&(0,M.jsxs)(`figcaption`,{"aria-live":t?`polite`:void 0,children:[(0,M.jsx)(`span`,{className:`media-eyebrow`,children:e.eyebrow}),(0,M.jsx)(`strong`,{children:e.title}),(0,M.jsx)(`small`,{children:e.description})]})]})}function L({definition:e}){let t=(0,g.useRef)(null),[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=t.current;if(!e||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;if(i){e.pause();return}if(!(`IntersectionObserver`in window)){e.play().catch(()=>void 0);return}let n=new IntersectionObserver(([t])=>{t?.isIntersecting?e.play().catch(()=>void 0):e.pause()},{threshold:.45});return n.observe(e),()=>{n.disconnect(),e.pause()}},[e.src,i]);function o(){let e=t.current;e&&(e.paused?(a(!1),e.play().catch(()=>void 0)):(a(!0),e.pause()))}return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`video`,{"aria-label":e.description,loop:!0,muted:!0,onPause:()=>r(!1),onPlay:()=>r(!0),playsInline:!0,poster:e.poster,preload:`metadata`,ref:t,src:e.src}),(0,M.jsx)(`button`,{"aria-label":`${n?`Pause`:`Play`} ${e.title}`,className:`video-toggle`,onClick:o,type:`button`,children:n?(0,M.jsx)(h,{"aria-hidden":`true`,size:16}):(0,M.jsx)(c,{"aria-hidden":`true`,fill:`currentColor`,size:16})})]})}function R({children:e,icon:t,media:n,number:r,title:i}){return(0,M.jsxs)(`article`,{className:`feature-card`,children:[(0,M.jsxs)(`div`,{className:`feature-top`,children:[(0,M.jsx)(`span`,{children:r}),t]}),(0,M.jsx)(`h3`,{children:i}),(0,M.jsx)(`p`,{children:e}),(0,M.jsx)(`div`,{className:`feature-media`,children:(0,M.jsx)(I,{definition:n})})]})}(0,_.createRoot)(document.getElementById(`landing-root`)).render((0,M.jsx)(g.StrictMode,{children:(0,M.jsx)(P,{})}));
1
+ import{a as e,c as t,d as n,i as r,l as i,n as a,o,p as s,r as c,s as l,t as u}from"./jsx-runtime-DAFSxiwi.js";var d=t(`ArrowDownRight`,[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]),f=t(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),p=t(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),m=t(`MousePointer2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),h=t(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),g=s(n(),1),_=i(),v=`/assets/agent-shared-state-DOfpTLiw.webp`,y=`/assets/agent-to-canvas-DtIu_cPq.mp4`,b=`/assets/attempt-history-D6wdic6n.webp`,x=`/assets/branching-tree-B8I5_S6D.png`,S=`/assets/canvas-cli-DHBacq7r.png`,C=`/assets/hero-agent-sync-CSyh0tHy.mp4`,w=`/assets/hero-board-DG3ED4AW.webp`,T=`/assets/hero-lineage-growth-Bsl9tiq-.mp4`,E=`/assets/hero-trace-connections-Bb52ABBc.mp4`,D=`/assets/human-selection-BdDBDE-I.webp`,O=`/assets/human-to-agent-D1z92ZO9.mp4`,k=`/assets/reroll-history-DQcEH42R.mp4`,A=[{id:`hero-lineage-growth`,eyebrow:`From agent to canvas`,title:`Turn agent output into visual creative history.`,description:`Every new asset joins the lineage instead of disappearing into a chat.`,kind:`video`,src:T,poster:w,fit:`contain`},{id:`hero-trace-connections`,eyebrow:`Context stays connected`,title:`Keep the reasoning behind the visual work.`,description:`Prompts, branches, and decisions remain attached to every result.`,kind:`video`,src:E,poster:x,fit:`contain`},{id:`hero-agent-sync`,eyebrow:`One shared creative state`,title:`Humans and agents continue from the same place.`,description:`New agent work returns to the canvas, ready for the next decision.`,kind:`video`,src:C,poster:v,fit:`contain`}],j={"human-to-agent":{id:`human-to-agent`,eyebrow:`Human → agent`,title:`Send the exact creative context to Codex.`,description:`A canvas selection becomes actionable agent context.`,kind:`video`,src:O,poster:S,fit:`contain`},"agent-to-canvas":{id:`agent-to-canvas`,eyebrow:`Agent → canvas`,title:`Bring agent results back into the shared state.`,description:`New agent output returns to the same visual workspace.`,kind:`video`,src:y,poster:v,fit:`contain`},"trace-tree":{id:`trace-tree`,eyebrow:`Lineage graph`,title:`Every branch remains visible.`,description:`The graph preserves the path from source to variation.`,kind:`image`,src:x,fit:`cover`},"selection-still":{id:`selection-still`,eyebrow:`Selection + direction`,title:`Choose exactly where the work continues.`,description:`Inspect, select, and turn the decision into precise context.`,kind:`image`,src:D,fit:`cover`,position:`left`},"reroll-history":{id:`reroll-history`,eyebrow:`Attempt history`,title:`Ask for another pass without losing the first.`,description:`The new attempt returns without replacing earlier work.`,kind:`video`,src:k,poster:b,fit:`cover`}},M=u(),N=`npm install -g @mean-weasel/lineage@latest`;function P(){let[e,t]=(0,g.useState)(!1);async function n(){try{await navigator.clipboard.writeText(N),t(!0),window.setTimeout(()=>t(!1),1800)}catch{t(!1)}}return(0,M.jsxs)(`div`,{className:`landing-shell`,children:[(0,M.jsxs)(`header`,{className:`landing-nav`,children:[(0,M.jsxs)(`a`,{"aria-label":`Lineage home`,className:`landing-brand`,href:`#top`,children:[(0,M.jsxs)(`span`,{"aria-hidden":`true`,className:`landing-brand-mark`,children:[(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{})]}),(0,M.jsx)(`span`,{children:`LINEAGE`})]}),(0,M.jsxs)(`nav`,{"aria-label":`Landing page`,children:[(0,M.jsx)(`a`,{href:`#loop`,children:`How it works`}),(0,M.jsx)(`a`,{href:`#features`,children:`What it enables`}),(0,M.jsx)(`a`,{href:`#install`,children:`Install`})]}),(0,M.jsxs)(`a`,{className:`nav-cta`,href:`https://github.com/mean-weasel/lineage`,rel:`noreferrer`,target:`_blank`,children:[`View on GitHub `,(0,M.jsx)(d,{"aria-hidden":`true`,size:16})]})]}),(0,M.jsxs)(`main`,{id:`top`,children:[(0,M.jsxs)(`section`,{className:`hero-section`,children:[(0,M.jsxs)(`div`,{className:`hero-grid`,"aria-hidden":`true`,children:[(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{})]}),(0,M.jsxs)(`div`,{className:`hero-copy`,children:[(0,M.jsxs)(`p`,{className:`section-index`,children:[(0,M.jsx)(`span`,{children:`01`}),` Human × agent creative work`]}),(0,M.jsx)(`h1`,{children:`The UX where humans and agents shape visual work together.`}),(0,M.jsx)(`p`,{className:`hero-summary`,children:`Lineage is the shared visual workspace where humans and agents create, review, and evolve creative assets together.`}),(0,M.jsxs)(`div`,{className:`hero-actions`,children:[(0,M.jsxs)(`a`,{className:`primary-cta`,href:`#loop`,children:[`See the collaboration loop `,(0,M.jsx)(l,{"aria-hidden":`true`,size:18})]}),(0,M.jsx)(`a`,{className:`text-cta`,href:`#install`,children:`Install Lineage`})]})]}),(0,M.jsx)(`div`,{className:`hero-media-wrap`,children:(0,M.jsx)(F,{})})]}),(0,M.jsxs)(`section`,{className:`loop-section`,id:`loop`,children:[(0,M.jsxs)(`div`,{className:`loop-heading`,children:[(0,M.jsxs)(`p`,{className:`section-index`,children:[(0,M.jsx)(`span`,{children:`02`}),` Context travels both ways`]}),(0,M.jsx)(`h2`,{children:`One creative state for humans and agents.`}),(0,M.jsxs)(`div`,{className:`loop-copy`,children:[(0,M.jsx)(`p`,{className:`loop-problem`,children:`Chat is the right UX for directing agent-driven creative work. But it isn’t built to hold the state of that work.`}),(0,M.jsx)(`p`,{children:`Lineage preserves every asset, path, prompt, relationship, and decision in a shared record—precise enough for agents to retrieve through the CLI and organized visually for humans to review and direct.`})]})]}),(0,M.jsxs)(`div`,{className:`interface-grid`,children:[(0,M.jsxs)(`article`,{className:`interface-card agent-card`,children:[(0,M.jsx)(`div`,{className:`interface-number`,children:`A`}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`card-eyebrow`,children:`For agents`}),(0,M.jsx)(`h3`,{children:`Never lose the state behind the work.`}),(0,M.jsx)(`p`,{children:`Every asset, path, prompt, iteration, and relationship stays available so the work can continue accurately.`})]}),(0,M.jsx)(I,{definition:j[`agent-to-canvas`],showCaption:!0})]}),(0,M.jsxs)(`div`,{className:`loop-bridge`,"aria-label":`Assets, context, selections, and annotations move through one creative state`,children:[(0,M.jsx)(`span`,{children:`Assets + context`}),(0,M.jsx)(`div`,{className:`bridge-line`,children:(0,M.jsx)(l,{"aria-hidden":`true`,size:18})}),(0,M.jsxs)(`strong`,{children:[`ONE CREATIVE`,(0,M.jsx)(`br`,{}),`STATE`]}),(0,M.jsx)(`div`,{className:`bridge-line reverse`,children:(0,M.jsx)(l,{"aria-hidden":`true`,size:18})}),(0,M.jsx)(`span`,{children:`Selections + annotations`})]}),(0,M.jsxs)(`article`,{className:`interface-card human-card`,children:[(0,M.jsx)(`div`,{className:`interface-number`,children:`H`}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`card-eyebrow`,children:`For humans`}),(0,M.jsx)(`h3`,{children:`Keep your creative history organized.`}),(0,M.jsx)(`p`,{children:`Review and compare the history, then use selections and annotations to direct the next iteration.`})]}),(0,M.jsx)(I,{definition:j[`human-to-agent`],showCaption:!0})]})]})]}),(0,M.jsxs)(`section`,{className:`features-section`,id:`features`,children:[(0,M.jsxs)(`div`,{className:`features-heading`,children:[(0,M.jsxs)(`p`,{className:`section-index`,children:[(0,M.jsx)(`span`,{children:`03`}),` What it enables`]}),(0,M.jsx)(`h2`,{children:`A shared creative history you and your agents can build on.`}),(0,M.jsx)(`p`,{children:`Keep the useful context behind every asset available, understandable, and ready for the next human or agent action.`})]}),(0,M.jsxs)(`div`,{className:`feature-grid`,children:[(0,M.jsx)(R,{icon:(0,M.jsx)(p,{}),media:j[`trace-tree`],number:`01`,title:`Trace every iteration`,children:`Follow an asset from its origin through branches, selections, and final campaign formats.`}),(0,M.jsx)(R,{icon:(0,M.jsx)(m,{}),media:j[`selection-still`],number:`02`,title:`Continue from the exact asset`,children:`Select any useful point in the lineage and bring that context into the next agent session.`}),(0,M.jsx)(R,{icon:(0,M.jsx)(a,{}),media:j[`reroll-history`],number:`03`,title:`Keep every agent attempt tied to your decisions`,children:`Review another pass without losing earlier results, prompts, relationships, or human direction.`})]}),(0,M.jsxs)(`div`,{className:`final-cta`,id:`install`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`p`,{className:`section-index`,children:[(0,M.jsx)(`span`,{children:`→`}),` Local-first and agent-ready`]}),(0,M.jsx)(`h3`,{children:`One durable home for visual work made with your agents.`})]}),(0,M.jsxs)(`div`,{className:`install-panel`,children:[(0,M.jsxs)(`div`,{className:`install-command`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`$`}),(0,M.jsx)(`code`,{children:N}),(0,M.jsxs)(`button`,{"aria-label":`Copy install command`,onClick:()=>void n(),type:`button`,children:[e?(0,M.jsx)(f,{"aria-hidden":`true`,size:18}):(0,M.jsx)(r,{"aria-hidden":`true`,size:18}),e?`Copied`:`Copy`]})]}),(0,M.jsxs)(`div`,{className:`install-meta`,children:[(0,M.jsx)(`span`,{children:`Local-first`}),(0,M.jsx)(`span`,{children:`MIT licensed`}),(0,M.jsx)(`span`,{children:`Codex plugin`}),(0,M.jsx)(`span`,{children:`CLI access`})]}),(0,M.jsxs)(`a`,{className:`primary-cta dark`,href:`https://github.com/mean-weasel/lineage`,rel:`noreferrer`,target:`_blank`,children:[`Explore Lineage on GitHub `,(0,M.jsx)(d,{"aria-hidden":`true`,size:18})]})]})]})]})]}),(0,M.jsxs)(`footer`,{children:[(0,M.jsxs)(`a`,{className:`landing-brand`,href:`#top`,children:[(0,M.jsxs)(`span`,{"aria-hidden":`true`,className:`landing-brand-mark`,children:[(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{}),(0,M.jsx)(`span`,{})]}),(0,M.jsx)(`span`,{children:`LINEAGE`})]}),(0,M.jsx)(`p`,{children:`The shared visual workspace for humans and agents.`}),(0,M.jsxs)(`a`,{href:`https://github.com/mean-weasel/lineage`,rel:`noreferrer`,target:`_blank`,children:[`GitHub `,(0,M.jsx)(d,{"aria-hidden":`true`,size:14})]})]})]})}function F(){let[t,n]=(0,g.useState)(0),[r,i]=(0,g.useState)(null),a=A[t],s=r?A[r.fromIndex]:null,c=r?.direction===1?`next`:`previous`;(0,g.useEffect)(()=>{if(!r)return;let e=window.setTimeout(()=>i(null),700);return()=>window.clearTimeout(e)},[r]);function l(e){u((t+e+A.length)%A.length,e)}function u(e,a){if(!(r||e===t)){if(window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches){n(e);return}i({direction:a,fromIndex:t}),n(e)}}return(0,M.jsxs)(`div`,{"aria-label":`Lineage product tour`,"aria-roledescription":`carousel`,className:`hero-carousel`,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`ArrowLeft`&&l(-1),e.key===`ArrowRight`&&l(1))},role:`region`,tabIndex:0,children:[(0,M.jsx)(`div`,{className:`hero-carousel-media-viewport`,children:(0,M.jsxs)(`div`,{className:`hero-carousel-media-track ${r?`carousel-track-${c}`:``}`,onAnimationEnd:e=>{e.currentTarget===e.target&&i(null)},children:[r?.direction===-1&&(0,M.jsx)(`div`,{className:`hero-carousel-media-slide`,children:(0,M.jsx)(I,{definition:a,hero:!0})},a.id),(0,M.jsx)(`div`,{"aria-hidden":s?`true`:void 0,className:`hero-carousel-media-slide`,children:(0,M.jsx)(I,{definition:s??a,hero:!0,showPlaybackControl:!s})},(s??a).id),r?.direction===1&&(0,M.jsx)(`div`,{className:`hero-carousel-media-slide`,children:(0,M.jsx)(I,{definition:a,hero:!0})},a.id)]})}),(0,M.jsxs)(`div`,{"aria-live":`polite`,className:`hero-carousel-caption-viewport`,children:[s&&(0,M.jsxs)(`div`,{"aria-hidden":`true`,className:`hero-carousel-caption carousel-caption-exit carousel-${c}`,children:[(0,M.jsx)(`span`,{className:`media-eyebrow`,children:s.eyebrow}),(0,M.jsx)(`strong`,{children:s.title}),(0,M.jsx)(`small`,{children:s.description})]},s.id),(0,M.jsxs)(`div`,{className:`hero-carousel-caption ${r?`carousel-caption-enter carousel-${c}`:``}`,children:[(0,M.jsx)(`span`,{className:`media-eyebrow`,children:a.eyebrow}),(0,M.jsx)(`strong`,{children:a.title}),(0,M.jsx)(`small`,{children:a.description})]},a.id)]}),(0,M.jsxs)(`div`,{className:`hero-carousel-controls`,children:[(0,M.jsx)(`button`,{"aria-label":`Previous carousel slide`,onClick:()=>l(-1),type:`button`,children:(0,M.jsx)(o,{"aria-hidden":`true`,size:19})}),(0,M.jsx)(`div`,{"aria-label":`Slide ${t+1} of ${A.length}`,className:`carousel-progress`,children:A.map((e,n)=>(0,M.jsx)(`button`,{"aria-current":n===t?`true`:void 0,"aria-label":`Show slide ${n+1}: ${e.title}`,className:n===t?`active`:``,onClick:()=>u(n,n>t?1:-1),type:`button`},e.id))}),(0,M.jsx)(`button`,{"aria-label":`Next carousel slide`,onClick:()=>l(1),type:`button`,children:(0,M.jsx)(e,{"aria-hidden":`true`,size:19})})]})]})}function I({definition:e,hero:t=!1,showCaption:n=!1,showPlaybackControl:r=!0}){return(0,M.jsxs)(`figure`,{className:`media-slot media-slot-ready ${`media-fit-${e.fit??`cover`}`} ${e.position===`left`?`media-position-left`:``} ${t?`media-slot-hero`:``}`,"data-media-slot":e.id,children:[e.kind===`video`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(L,{definition:e,showPlaybackControl:r}),e.poster&&(0,M.jsx)(`img`,{alt:``,"aria-hidden":`true`,className:`reduced-motion-poster`,src:e.poster})]}):(0,M.jsx)(`img`,{alt:e.description,loading:`lazy`,src:e.src}),n&&(0,M.jsxs)(`figcaption`,{"aria-live":t?`polite`:void 0,children:[(0,M.jsx)(`span`,{className:`media-eyebrow`,children:e.eyebrow}),(0,M.jsx)(`strong`,{children:e.title}),(0,M.jsx)(`small`,{children:e.description})]})]})}function L({definition:e,showPlaybackControl:t}){let n=(0,g.useRef)(null),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=n.current;if(!e||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;if(a){e.pause();return}if(!(`IntersectionObserver`in window)){e.play().catch(()=>void 0);return}let t=new IntersectionObserver(([t])=>{t?.isIntersecting?e.play().catch(()=>void 0):e.pause()},{threshold:.45});return t.observe(e),()=>{t.disconnect(),e.pause()}},[e.src,a]);function s(){let e=n.current;e&&(e.paused?(o(!1),e.play().catch(()=>void 0)):(o(!0),e.pause()))}return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`video`,{"aria-label":e.description,loop:!0,muted:!0,onPause:()=>i(!1),onPlay:()=>i(!0),playsInline:!0,poster:e.poster,preload:`metadata`,ref:n,src:e.src}),t&&(0,M.jsx)(`button`,{"aria-label":`${r?`Pause`:`Play`} ${e.title}`,className:`video-toggle`,onClick:s,type:`button`,children:r?(0,M.jsx)(h,{"aria-hidden":`true`,size:16}):(0,M.jsx)(c,{"aria-hidden":`true`,fill:`currentColor`,size:16})})]})}function R({children:e,icon:t,media:n,number:r,title:i}){return(0,M.jsxs)(`article`,{className:`feature-card`,children:[(0,M.jsxs)(`div`,{className:`feature-top`,children:[(0,M.jsx)(`span`,{children:r}),t]}),(0,M.jsx)(`h3`,{children:i}),(0,M.jsx)(`p`,{children:e}),(0,M.jsx)(`div`,{className:`feature-media`,children:(0,M.jsx)(I,{definition:n})})]})}(0,_.createRoot)(document.getElementById(`landing-root`)).render((0,M.jsx)(g.StrictMode,{children:(0,M.jsx)(P,{})}));
@@ -0,0 +1 @@
1
+ :root{--landing-ink:#121212;--landing-paper:#f3f0e8;--landing-cream:#fffdf6;--landing-red:#f04432;--landing-yellow:#f6c643;--landing-mint:#b9ddd2;--landing-blue:#2646d8;--landing-line:#1212122e;color:var(--landing-ink);background:var(--landing-paper);font-synthesis:none;font-family:Helvetica Neue,Arial Nova,Arial,sans-serif}*{box-sizing:border-box}html{scroll-behavior:smooth}body{background:linear-gradient(90deg, transparent calc(50% - .5px), #1212120b 50%, transparent calc(50% + .5px)), var(--landing-paper);min-width:320px;margin:0}button,a{font:inherit}a{color:inherit}button{cursor:pointer}.landing-shell{overflow:hidden}.landing-nav{z-index:10;border-bottom:1px solid var(--landing-ink);background:#f3f0e8f0;grid-template-columns:minmax(160px,1fr) auto minmax(160px,1fr);align-items:center;min-height:74px;padding:0 3.2vw;display:grid;position:relative}.landing-brand{width:fit-content;color:var(--landing-ink);letter-spacing:.08em;justify-self:start;align-items:center;gap:11px;font-size:14px;font-weight:900;text-decoration:none;display:inline-flex}.landing-brand-mark{border:1px solid var(--landing-ink);grid-template-columns:repeat(3,1fr);gap:3px;width:30px;height:30px;padding:4px;display:grid;position:relative}.landing-brand-mark span{background:var(--landing-ink)}.landing-brand-mark span:nth-child(2){background:var(--landing-red)}.landing-brand-mark span:nth-child(3){background:var(--landing-yellow)}.landing-nav nav{gap:clamp(18px,3vw,46px);display:flex}.landing-nav nav a,.nav-cta{font-size:12px;font-weight:750;text-decoration:none}.landing-nav nav a:hover{text-underline-offset:5px;text-decoration:underline}.nav-cta{border-bottom:1px solid var(--landing-ink);justify-self:end;align-items:center;gap:7px;padding:6px 0;display:inline-flex}.hero-section{border-bottom:1px solid var(--landing-ink);grid-template-columns:minmax(0,.92fr) minmax(460px,1.08fr);min-height:calc(100vh - 74px);display:grid;position:relative}.hero-grid{pointer-events:none;grid-template-columns:repeat(4,1fr);display:grid;position:absolute;inset:0}.hero-grid span{border-right:1px solid #12121214}.hero-copy{z-index:1;flex-direction:column;justify-content:center;padding:clamp(52px,5vw,76px) clamp(32px,5vw,84px);display:flex;position:relative}.section-index{letter-spacing:.12em;text-transform:uppercase;align-items:center;gap:11px;margin:0 0 28px;font-size:11px;font-weight:800;display:flex}.section-index span{border:1px solid;border-radius:50%;place-items:center;width:27px;height:27px;font-size:9px;display:grid}.hero-copy h1{letter-spacing:-.075em;max-width:760px;margin:0;font-size:clamp(58px,5.35vw,86px);font-weight:900;line-height:.86}.hero-summary{letter-spacing:-.025em;max-width:650px;margin:30px 0 0;font-size:clamp(18px,1.45vw,24px);font-weight:580;line-height:1.22}.hero-actions{align-items:center;gap:24px;margin-top:30px;display:flex}.primary-cta{border:1px solid var(--landing-ink);background:var(--landing-red);min-height:52px;color:var(--landing-ink);box-shadow:5px 5px 0 var(--landing-ink);justify-content:center;align-items:center;gap:14px;padding:0 19px;font-size:13px;font-weight:850;text-decoration:none;transition:transform .15s,box-shadow .15s;display:inline-flex}.primary-cta:hover{box-shadow:3px 3px 0 var(--landing-ink);transform:translate(2px,2px)}.primary-cta.dark{background:var(--landing-ink);color:var(--landing-cream);box-shadow:5px 5px 0 var(--landing-red)}.text-cta{text-underline-offset:5px;font-size:13px;font-weight:850}.hero-media-wrap{border-left:1px solid var(--landing-ink);background:var(--landing-yellow);align-items:center;padding:clamp(52px,6vw,96px) clamp(28px,4.8vw,80px);display:flex;position:relative}.hero-carousel{outline:none;gap:14px;width:100%;display:grid}.hero-carousel:focus-visible .media-slot{outline:3px solid var(--landing-blue);outline-offset:5px}.hero-carousel-media-viewport{margin:-5px -13px -13px -5px;padding:5px 13px 13px 5px;position:relative;overflow:hidden}.hero-carousel-media-track{width:100%;display:flex}.hero-carousel-media-slide{flex:0 0 100%;min-width:0}.hero-carousel-media-track[class*=carousel-track-]{will-change:transform;width:200%}.hero-carousel-media-track[class*=carousel-track-] .hero-carousel-media-slide{flex-basis:50%}.hero-carousel-media-track[class*=carousel-track-] .hero-carousel-media-slide[aria-hidden=true]{pointer-events:none}.carousel-track-next{animation:.58s cubic-bezier(.65,0,.35,1) both carousel-track-next}.carousel-track-previous{animation:.58s cubic-bezier(.65,0,.35,1) both carousel-track-previous}.hero-carousel-caption-viewport{margin:-4px -8px -8px -4px;padding:4px 8px 8px 4px;position:relative;overflow:hidden}.hero-carousel-caption{border:1px solid var(--landing-ink);background:var(--landing-cream);box-shadow:4px 4px 0 var(--landing-ink);will-change:opacity;grid-template-columns:minmax(130px,.62fr) minmax(0,1fr);gap:4px 18px;padding:13px 15px;display:grid}.hero-carousel-caption.carousel-caption-exit{z-index:1;pointer-events:none;position:absolute;inset:4px 8px 8px 4px}.hero-carousel-caption.carousel-caption-enter{z-index:2;position:relative}.carousel-caption-enter{animation:.46s 60ms both carousel-caption-enter}.carousel-caption-exit{animation:.4s both carousel-caption-exit}@keyframes carousel-track-next{0%{transform:translate(0)}to{transform:translate(-50%)}}@keyframes carousel-track-previous{0%{transform:translate(-50%)}to{transform:translate(0)}}@keyframes carousel-caption-enter{0%{opacity:0}to{opacity:1}}@keyframes carousel-caption-exit{0%{opacity:1}to{opacity:0}}.hero-carousel-caption .media-eyebrow{grid-row:1/span 2;align-self:center}.hero-carousel-caption strong{letter-spacing:-.02em;font-size:15px}.hero-carousel-caption small{font-size:11px;line-height:1.35}.hero-carousel-controls{grid-template-columns:42px 1fr 42px;align-items:center;gap:12px;display:grid}.hero-carousel-controls>button{border:1px solid var(--landing-ink);background:var(--landing-cream);width:42px;height:42px;color:var(--landing-ink);box-shadow:3px 3px 0 var(--landing-ink);place-items:center;transition:transform .15s,box-shadow .15s;display:grid}.hero-carousel-controls>button:hover{box-shadow:2px 2px 0 var(--landing-ink);transform:translate(1px,1px)}.carousel-progress{justify-self:center;align-items:center;gap:7px;display:flex}.carousel-progress button{border:1px solid var(--landing-ink);background:var(--landing-cream);border-radius:999px;width:28px;height:8px;padding:0}.carousel-progress button.active{background:var(--landing-red)}.media-slot{border:1px solid var(--landing-ink);background:var(--landing-cream);aspect-ratio:16/10;width:100%;min-width:0;box-shadow:8px 8px 0 var(--landing-ink);margin:0;position:relative;overflow:hidden}.media-slot-hero{aspect-ratio:16/11}.media-slot-ready img,.media-slot-ready video{object-fit:cover;width:100%;max-width:100%;height:100%;display:block}.media-slot-ready.media-fit-contain img,.media-slot-ready.media-fit-contain video{object-fit:contain;background:#f5f8f5}.media-slot-ready.media-position-left img,.media-slot-ready.media-position-left video{object-position:left center}.media-slot-ready .reduced-motion-poster{display:none}.video-toggle{z-index:5;border:1px solid var(--landing-ink);width:38px;height:38px;color:var(--landing-ink);box-shadow:3px 3px 0 var(--landing-ink);background:#fffdf6f0;border-radius:50%;place-items:center;display:grid;position:absolute;top:12px;right:12px}.video-toggle:hover{background:var(--landing-mint)}.video-toggle:focus-visible{outline:3px solid var(--landing-blue);outline-offset:3px}.placeholder-canvas{background:linear-gradient(#1212120f 1px,#0000 1px) 0 0/32px 32px,linear-gradient(90deg,#1212120f 1px,#0000 1px) 0 0/32px 32px,linear-gradient(145deg,#fefcf5,#ddd8cd);position:absolute;inset:0}.placeholder-node{z-index:2;aspect-ratio:4/3;border:1px solid var(--landing-ink);background:var(--landing-cream);width:21%;padding:7px;display:block;position:absolute}.placeholder-node i{background:var(--landing-yellow);width:100%;height:100%;display:block}.placeholder-node.node-root{top:40%;left:8%}.placeholder-node.node-a{top:14%;left:39%}.placeholder-node.node-b{top:60%;left:39%}.placeholder-node.node-c{top:34%;right:8%}.placeholder-node.node-a i{background:var(--landing-red)}.placeholder-node.node-b i{background:var(--landing-mint)}.placeholder-node.node-c i{background:var(--landing-blue)}.placeholder-edge{z-index:1;background:var(--landing-ink);transform-origin:0;height:1px;display:block;position:absolute}.edge-a{width:20%;top:46%;left:27%;transform:rotate(-27deg)}.edge-b{width:19%;top:53%;left:27%;transform:rotate(29deg)}.edge-c{width:22%;top:40%;left:58%;transform:rotate(8deg)}.media-slot figcaption{z-index:3;border:1px solid var(--landing-ink);background:#fffdf6f2;grid-template-columns:1fr auto;gap:2px 12px;padding:11px 13px;display:grid;position:absolute;bottom:14px;left:14px;right:14px}.media-slot figcaption strong{letter-spacing:-.02em;font-size:14px}.media-slot figcaption small{grid-column:1/-1;max-width:90%;font-size:10px;line-height:1.3}.media-eyebrow{letter-spacing:.1em;text-transform:uppercase;font-size:9px;font-weight:850}.play-badge{z-index:4;border:1px solid var(--landing-ink);background:var(--landing-red);border-radius:50%;place-items:center;width:34px;height:34px;display:grid;position:absolute;top:14px;right:14px}.features-heading h2{letter-spacing:-.065em;margin:0;font-size:clamp(48px,6vw,92px);font-weight:900;line-height:.92}.loop-section{background:var(--landing-ink);color:var(--landing-cream);padding:clamp(76px,9vw,148px) clamp(26px,6vw,98px)}.loop-heading{grid-template-columns:.58fr 1fr .72fr;align-items:end;gap:5vw;display:grid}.loop-heading .section-index{align-self:start}.loop-heading h2{letter-spacing:-.065em;margin:0;font-size:clamp(48px,5.5vw,88px);line-height:.92}.loop-copy{gap:22px;display:grid}.loop-copy p{margin:0;font-size:16px;line-height:1.45}.loop-copy .loop-problem{letter-spacing:-.02em;font-size:clamp(18px,1.5vw,23px);font-weight:750;line-height:1.25}.interface-grid{grid-template-columns:minmax(0,1fr) 110px minmax(0,1fr);align-items:stretch;margin-top:78px;display:grid}.interface-card{border:1px solid var(--landing-cream);min-width:0;color:var(--landing-ink);grid-template-rows:auto auto 1fr;gap:28px;padding:clamp(24px,3vw,46px);display:grid;position:relative}.human-card{background:var(--landing-yellow)}.agent-card{background:var(--landing-mint)}.interface-card h3{letter-spacing:-.05em;max-width:570px;margin:8px 0 14px;font-size:clamp(31px,3vw,51px);line-height:.95}.interface-card p{max-width:520px;margin:0;font-size:15px;line-height:1.45}.card-eyebrow{letter-spacing:.12em;text-transform:uppercase;font-weight:900;font-size:10px!important}.interface-number{border:1px solid var(--landing-ink);border-radius:50%;place-items:center;width:42px;height:42px;font-size:12px;font-weight:900;display:grid}.interface-card .media-slot{box-shadow:6px 6px 0 var(--landing-ink);align-self:end;margin-top:22px}.loop-bridge{border-top:1px solid var(--landing-cream);border-bottom:1px solid var(--landing-cream);text-align:center;flex-direction:column;justify-content:center;align-items:center;gap:18px;display:flex}.loop-bridge strong{letter-spacing:.12em;font-size:12px;line-height:1.15}.loop-bridge span{letter-spacing:.12em;text-transform:uppercase;font-size:9px}.bridge-line{place-items:center;width:100%;display:grid}.bridge-line:before{content:"";background:var(--landing-cream);width:72px;height:1px;position:absolute}.bridge-line svg{background:var(--landing-ink);margin-left:60px;position:relative}.bridge-line.reverse{transform:rotate(180deg)}.features-section{padding:clamp(76px,9vw,148px) clamp(26px,6vw,98px)}.features-heading{grid-template-columns:.5fr 1fr .75fr;align-items:end;gap:5vw;display:grid}.features-heading .section-index{align-self:start}.features-heading>p:last-child{margin:0;font-size:17px;line-height:1.5}.feature-grid{border-top:1px solid var(--landing-ink);border-left:1px solid var(--landing-ink);grid-template-columns:repeat(3,1fr);margin-top:76px;display:grid}.feature-card{border-right:1px solid var(--landing-ink);border-bottom:1px solid var(--landing-ink);flex-direction:column;min-height:580px;padding:24px;display:flex}.feature-card:nth-child(2){background:var(--landing-yellow)}.feature-card:nth-child(3){background:var(--landing-mint)}.feature-top{justify-content:space-between;align-items:center;display:flex}.feature-top span{font-size:10px;font-weight:850}.feature-card h3{letter-spacing:-.05em;margin:66px 0 14px;font-size:clamp(25px,2.3vw,38px);line-height:1}.feature-card p{margin:0;font-size:14px;line-height:1.45}.feature-media{margin-top:auto;padding-top:28px}.feature-media .media-slot{aspect-ratio:4/3;box-shadow:4px 4px 0 var(--landing-ink)}.final-cta{border:1px solid var(--landing-ink);background:var(--landing-yellow);grid-template-columns:1fr .92fr;gap:7vw;margin-top:82px;padding:clamp(34px,5vw,72px);display:grid}.final-cta h3{letter-spacing:-.065em;max-width:760px;margin:0;font-size:clamp(42px,5vw,76px);font-weight:900;line-height:.92}.install-panel{flex-direction:column;justify-content:center;gap:28px;display:flex}.install-command{border:1px solid var(--landing-ink);background:var(--landing-cream);min-height:70px;box-shadow:7px 7px 0 var(--landing-ink);grid-template-columns:auto 1fr auto;align-items:center;gap:12px;padding:10px 12px 10px 20px;display:grid}.install-command code{text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:700;overflow:hidden}.install-command button{border:1px solid var(--landing-ink);background:var(--landing-mint);align-items:center;gap:7px;height:44px;padding:0 12px;font-size:11px;font-weight:850;display:inline-flex}.install-meta{flex-wrap:wrap;gap:9px;display:flex}.install-meta span{border:1px solid var(--landing-ink);text-transform:uppercase;border-radius:999px;padding:7px 11px;font-size:10px;font-weight:850}footer{background:var(--landing-ink);min-height:150px;color:var(--landing-cream);grid-template-columns:1fr auto 1fr;align-items:center;padding:28px 3.2vw;display:grid}footer .landing-brand{color:var(--landing-cream)}footer .landing-brand-mark{border-color:var(--landing-cream)}footer p{margin:0;font-size:12px}footer>a:last-child{justify-self:end;align-items:center;gap:5px;font-size:12px;display:inline-flex}@media (width<=1080px){.hero-section{grid-template-columns:1fr}.hero-media-wrap{border-top:1px solid var(--landing-ink);border-left:0;min-height:650px}.loop-heading,.features-heading{grid-template-columns:1fr 1.4fr}.loop-copy,.features-heading>p:last-child{grid-column:2}.interface-grid{grid-template-columns:minmax(0,1fr);gap:0}.loop-bridge{border-right:1px solid var(--landing-cream);border-left:1px solid var(--landing-cream);flex-direction:row;min-height:90px}.bridge-line{width:80px}.bridge-line:before{width:60px}.feature-card{min-height:280px}.final-cta{grid-template-columns:1fr;gap:48px}}@media (width<=760px){.landing-nav{grid-template-columns:1fr auto;padding:0 18px}.landing-nav nav{display:none}.nav-cta{font-size:11px}.hero-copy{padding:76px 22px 66px}.hero-copy h1{font-size:clamp(55px,17vw,82px)}.hero-summary{font-size:19px}.hero-actions{flex-direction:column;align-items:flex-start}.hero-media-wrap{min-height:470px;padding:52px 22px}.hero-carousel-caption{grid-template-columns:1fr}.hero-carousel-caption .media-eyebrow{grid-row:auto}.loop-heading,.features-heading{grid-template-columns:1fr}.loop-copy,.features-heading>p:last-child{grid-column:1}.interface-grid{margin-top:48px}.interface-card{padding:26px 20px}.feature-grid{grid-template-columns:1fr}.feature-card{min-height:580px}.feature-card h3{margin-top:58px}.final-cta{padding:32px 20px}.install-command{grid-template-columns:auto 1fr}.install-command button{grid-column:1/-1;justify-content:center}footer{grid-template-columns:1fr auto;gap:28px}footer p{display:none}}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}.primary-cta,.hero-carousel-controls>button{transition:none}.hero-carousel-media-track,.carousel-caption-enter,.carousel-caption-exit{animation:none}.media-slot-ready video{display:none}.media-slot-ready .reduced-motion-poster{display:block}.video-toggle{display:none}}
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Lineage</title>
7
- <script type="module" crossorigin src="/assets/app-DMogkUoS.js"></script>
7
+ <script type="module" crossorigin src="/assets/app-XjkwA_uj.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DAFSxiwi.js">
9
9
  <link rel="stylesheet" crossorigin href="/assets/app-B-fAyNsU.css">
10
10
  </head>
@@ -9,9 +9,9 @@
9
9
  content="Lineage is the shared visual workspace where humans and agents create, review, and evolve creative assets together."
10
10
  />
11
11
  <title>Lineage — Visual work for humans and agents</title>
12
- <script type="module" crossorigin src="/assets/landing-CoyGmxBo.js"></script>
12
+ <script type="module" crossorigin src="/assets/landing-BogL3MNz.js"></script>
13
13
  <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DAFSxiwi.js">
14
- <link rel="stylesheet" crossorigin href="/assets/landing-Bn4qKbIO.css">
14
+ <link rel="stylesheet" crossorigin href="/assets/landing-D79qigX-.css">
15
15
  </head>
16
16
  <body>
17
17
  <div id="landing-root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mean-weasel/lineage",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Local-first creative lineage workspace",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- :root{--landing-ink:#121212;--landing-paper:#f3f0e8;--landing-cream:#fffdf6;--landing-red:#f04432;--landing-yellow:#f6c643;--landing-mint:#b9ddd2;--landing-blue:#2646d8;--landing-line:#1212122e;color:var(--landing-ink);background:var(--landing-paper);font-synthesis:none;font-family:Helvetica Neue,Arial Nova,Arial,sans-serif}*{box-sizing:border-box}html{scroll-behavior:smooth}body{background:linear-gradient(90deg, transparent calc(50% - .5px), #1212120b 50%, transparent calc(50% + .5px)), var(--landing-paper);min-width:320px;margin:0}button,a{font:inherit}a{color:inherit}button{cursor:pointer}.landing-shell{overflow:hidden}.landing-nav{z-index:10;border-bottom:1px solid var(--landing-ink);background:#f3f0e8f0;grid-template-columns:minmax(160px,1fr) auto minmax(160px,1fr);align-items:center;min-height:74px;padding:0 3.2vw;display:grid;position:relative}.landing-brand{width:fit-content;color:var(--landing-ink);letter-spacing:.08em;justify-self:start;align-items:center;gap:11px;font-size:14px;font-weight:900;text-decoration:none;display:inline-flex}.landing-brand-mark{border:1px solid var(--landing-ink);grid-template-columns:repeat(3,1fr);gap:3px;width:30px;height:30px;padding:4px;display:grid;position:relative}.landing-brand-mark span{background:var(--landing-ink)}.landing-brand-mark span:nth-child(2){background:var(--landing-red)}.landing-brand-mark span:nth-child(3){background:var(--landing-yellow)}.landing-nav nav{gap:clamp(18px,3vw,46px);display:flex}.landing-nav nav a,.nav-cta{font-size:12px;font-weight:750;text-decoration:none}.landing-nav nav a:hover{text-underline-offset:5px;text-decoration:underline}.nav-cta{border-bottom:1px solid var(--landing-ink);justify-self:end;align-items:center;gap:7px;padding:6px 0;display:inline-flex}.hero-section{border-bottom:1px solid var(--landing-ink);grid-template-columns:minmax(0,.92fr) minmax(460px,1.08fr);min-height:calc(100vh - 74px);display:grid;position:relative}.hero-grid{pointer-events:none;grid-template-columns:repeat(4,1fr);display:grid;position:absolute;inset:0}.hero-grid span{border-right:1px solid #12121214}.hero-copy{z-index:1;flex-direction:column;justify-content:center;padding:clamp(52px,5vw,76px) clamp(32px,5vw,84px);display:flex;position:relative}.section-index{letter-spacing:.12em;text-transform:uppercase;align-items:center;gap:11px;margin:0 0 28px;font-size:11px;font-weight:800;display:flex}.section-index span{border:1px solid;border-radius:50%;place-items:center;width:27px;height:27px;font-size:9px;display:grid}.hero-copy h1{letter-spacing:-.075em;max-width:760px;margin:0;font-size:clamp(58px,5.35vw,86px);font-weight:900;line-height:.86}.hero-summary{letter-spacing:-.025em;max-width:650px;margin:30px 0 0;font-size:clamp(18px,1.45vw,24px);font-weight:580;line-height:1.22}.hero-actions{align-items:center;gap:24px;margin-top:30px;display:flex}.primary-cta{border:1px solid var(--landing-ink);background:var(--landing-red);min-height:52px;color:var(--landing-ink);box-shadow:5px 5px 0 var(--landing-ink);justify-content:center;align-items:center;gap:14px;padding:0 19px;font-size:13px;font-weight:850;text-decoration:none;transition:transform .15s,box-shadow .15s;display:inline-flex}.primary-cta:hover{box-shadow:3px 3px 0 var(--landing-ink);transform:translate(2px,2px)}.primary-cta.dark{background:var(--landing-ink);color:var(--landing-cream);box-shadow:5px 5px 0 var(--landing-red)}.text-cta{text-underline-offset:5px;font-size:13px;font-weight:850}.hero-media-wrap{border-left:1px solid var(--landing-ink);background:var(--landing-yellow);align-items:center;padding:clamp(52px,6vw,96px) clamp(28px,4.8vw,80px);display:flex;position:relative}.hero-carousel{outline:none;gap:14px;width:100%;display:grid}.hero-carousel:focus-visible .media-slot{outline:3px solid var(--landing-blue);outline-offset:5px}.hero-carousel-caption{border:1px solid var(--landing-ink);background:var(--landing-cream);box-shadow:4px 4px 0 var(--landing-ink);grid-template-columns:minmax(130px,.62fr) minmax(0,1fr);gap:4px 18px;padding:13px 15px;display:grid}.hero-carousel-caption .media-eyebrow{grid-row:1/span 2;align-self:center}.hero-carousel-caption strong{letter-spacing:-.02em;font-size:15px}.hero-carousel-caption small{font-size:11px;line-height:1.35}.hero-carousel-controls{grid-template-columns:42px 1fr 42px;align-items:center;gap:12px;display:grid}.hero-carousel-controls>button{border:1px solid var(--landing-ink);background:var(--landing-cream);width:42px;height:42px;color:var(--landing-ink);box-shadow:3px 3px 0 var(--landing-ink);place-items:center;transition:transform .15s,box-shadow .15s;display:grid}.hero-carousel-controls>button:hover{box-shadow:2px 2px 0 var(--landing-ink);transform:translate(1px,1px)}.carousel-progress{justify-self:center;align-items:center;gap:7px;display:flex}.carousel-progress button{border:1px solid var(--landing-ink);background:var(--landing-cream);border-radius:999px;width:28px;height:8px;padding:0}.carousel-progress button.active{background:var(--landing-red)}.media-slot{border:1px solid var(--landing-ink);background:var(--landing-cream);aspect-ratio:16/10;width:100%;min-width:0;box-shadow:8px 8px 0 var(--landing-ink);margin:0;position:relative;overflow:hidden}.media-slot-hero{aspect-ratio:16/11}.media-slot-ready img,.media-slot-ready video{object-fit:cover;width:100%;max-width:100%;height:100%;display:block}.media-slot-ready.media-fit-contain img,.media-slot-ready.media-fit-contain video{object-fit:contain;background:#f5f8f5}.media-slot-ready.media-position-left img,.media-slot-ready.media-position-left video{object-position:left center}.media-slot-ready .reduced-motion-poster{display:none}.video-toggle{z-index:5;border:1px solid var(--landing-ink);width:38px;height:38px;color:var(--landing-ink);box-shadow:3px 3px 0 var(--landing-ink);background:#fffdf6f0;border-radius:50%;place-items:center;display:grid;position:absolute;top:12px;right:12px}.video-toggle:hover{background:var(--landing-mint)}.video-toggle:focus-visible{outline:3px solid var(--landing-blue);outline-offset:3px}.placeholder-canvas{background:linear-gradient(#1212120f 1px,#0000 1px) 0 0/32px 32px,linear-gradient(90deg,#1212120f 1px,#0000 1px) 0 0/32px 32px,linear-gradient(145deg,#fefcf5,#ddd8cd);position:absolute;inset:0}.placeholder-node{z-index:2;aspect-ratio:4/3;border:1px solid var(--landing-ink);background:var(--landing-cream);width:21%;padding:7px;display:block;position:absolute}.placeholder-node i{background:var(--landing-yellow);width:100%;height:100%;display:block}.placeholder-node.node-root{top:40%;left:8%}.placeholder-node.node-a{top:14%;left:39%}.placeholder-node.node-b{top:60%;left:39%}.placeholder-node.node-c{top:34%;right:8%}.placeholder-node.node-a i{background:var(--landing-red)}.placeholder-node.node-b i{background:var(--landing-mint)}.placeholder-node.node-c i{background:var(--landing-blue)}.placeholder-edge{z-index:1;background:var(--landing-ink);transform-origin:0;height:1px;display:block;position:absolute}.edge-a{width:20%;top:46%;left:27%;transform:rotate(-27deg)}.edge-b{width:19%;top:53%;left:27%;transform:rotate(29deg)}.edge-c{width:22%;top:40%;left:58%;transform:rotate(8deg)}.media-slot figcaption{z-index:3;border:1px solid var(--landing-ink);background:#fffdf6f2;grid-template-columns:1fr auto;gap:2px 12px;padding:11px 13px;display:grid;position:absolute;bottom:14px;left:14px;right:14px}.media-slot figcaption strong{letter-spacing:-.02em;font-size:14px}.media-slot figcaption small{grid-column:1/-1;max-width:90%;font-size:10px;line-height:1.3}.media-eyebrow{letter-spacing:.1em;text-transform:uppercase;font-size:9px;font-weight:850}.play-badge{z-index:4;border:1px solid var(--landing-ink);background:var(--landing-red);border-radius:50%;place-items:center;width:34px;height:34px;display:grid;position:absolute;top:14px;right:14px}.features-heading h2{letter-spacing:-.065em;margin:0;font-size:clamp(48px,6vw,92px);font-weight:900;line-height:.92}.loop-section{background:var(--landing-ink);color:var(--landing-cream);padding:clamp(76px,9vw,148px) clamp(26px,6vw,98px)}.loop-heading{grid-template-columns:.58fr 1fr .72fr;align-items:end;gap:5vw;display:grid}.loop-heading .section-index{align-self:start}.loop-heading h2{letter-spacing:-.065em;margin:0;font-size:clamp(48px,5.5vw,88px);line-height:.92}.loop-copy{gap:22px;display:grid}.loop-copy p{margin:0;font-size:16px;line-height:1.45}.loop-copy .loop-problem{letter-spacing:-.02em;font-size:clamp(18px,1.5vw,23px);font-weight:750;line-height:1.25}.interface-grid{grid-template-columns:minmax(0,1fr) 110px minmax(0,1fr);align-items:stretch;margin-top:78px;display:grid}.interface-card{border:1px solid var(--landing-cream);min-width:0;color:var(--landing-ink);grid-template-rows:auto auto 1fr;gap:28px;padding:clamp(24px,3vw,46px);display:grid;position:relative}.human-card{background:var(--landing-yellow)}.agent-card{background:var(--landing-mint)}.interface-card h3{letter-spacing:-.05em;max-width:570px;margin:8px 0 14px;font-size:clamp(31px,3vw,51px);line-height:.95}.interface-card p{max-width:520px;margin:0;font-size:15px;line-height:1.45}.card-eyebrow{letter-spacing:.12em;text-transform:uppercase;font-weight:900;font-size:10px!important}.interface-number{border:1px solid var(--landing-ink);border-radius:50%;place-items:center;width:42px;height:42px;font-size:12px;font-weight:900;display:grid}.interface-card .media-slot{box-shadow:6px 6px 0 var(--landing-ink);align-self:end;margin-top:22px}.loop-bridge{border-top:1px solid var(--landing-cream);border-bottom:1px solid var(--landing-cream);text-align:center;flex-direction:column;justify-content:center;align-items:center;gap:18px;display:flex}.loop-bridge strong{letter-spacing:.12em;font-size:12px;line-height:1.15}.loop-bridge span{letter-spacing:.12em;text-transform:uppercase;font-size:9px}.bridge-line{place-items:center;width:100%;display:grid}.bridge-line:before{content:"";background:var(--landing-cream);width:72px;height:1px;position:absolute}.bridge-line svg{background:var(--landing-ink);margin-left:60px;position:relative}.bridge-line.reverse{transform:rotate(180deg)}.features-section{padding:clamp(76px,9vw,148px) clamp(26px,6vw,98px)}.features-heading{grid-template-columns:.5fr 1fr .75fr;align-items:end;gap:5vw;display:grid}.features-heading .section-index{align-self:start}.features-heading>p:last-child{margin:0;font-size:17px;line-height:1.5}.feature-grid{border-top:1px solid var(--landing-ink);border-left:1px solid var(--landing-ink);grid-template-columns:repeat(3,1fr);margin-top:76px;display:grid}.feature-card{border-right:1px solid var(--landing-ink);border-bottom:1px solid var(--landing-ink);flex-direction:column;min-height:580px;padding:24px;display:flex}.feature-card:nth-child(2){background:var(--landing-yellow)}.feature-card:nth-child(3){background:var(--landing-mint)}.feature-top{justify-content:space-between;align-items:center;display:flex}.feature-top span{font-size:10px;font-weight:850}.feature-card h3{letter-spacing:-.05em;margin:66px 0 14px;font-size:clamp(25px,2.3vw,38px);line-height:1}.feature-card p{margin:0;font-size:14px;line-height:1.45}.feature-media{margin-top:auto;padding-top:28px}.feature-media .media-slot{aspect-ratio:4/3;box-shadow:4px 4px 0 var(--landing-ink)}.final-cta{border:1px solid var(--landing-ink);background:var(--landing-yellow);grid-template-columns:1fr .92fr;gap:7vw;margin-top:82px;padding:clamp(34px,5vw,72px);display:grid}.final-cta h3{letter-spacing:-.065em;max-width:760px;margin:0;font-size:clamp(42px,5vw,76px);font-weight:900;line-height:.92}.install-panel{flex-direction:column;justify-content:center;gap:28px;display:flex}.install-command{border:1px solid var(--landing-ink);background:var(--landing-cream);min-height:70px;box-shadow:7px 7px 0 var(--landing-ink);grid-template-columns:auto 1fr auto;align-items:center;gap:12px;padding:10px 12px 10px 20px;display:grid}.install-command code{text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:700;overflow:hidden}.install-command button{border:1px solid var(--landing-ink);background:var(--landing-mint);align-items:center;gap:7px;height:44px;padding:0 12px;font-size:11px;font-weight:850;display:inline-flex}.install-meta{flex-wrap:wrap;gap:9px;display:flex}.install-meta span{border:1px solid var(--landing-ink);text-transform:uppercase;border-radius:999px;padding:7px 11px;font-size:10px;font-weight:850}footer{background:var(--landing-ink);min-height:150px;color:var(--landing-cream);grid-template-columns:1fr auto 1fr;align-items:center;padding:28px 3.2vw;display:grid}footer .landing-brand{color:var(--landing-cream)}footer .landing-brand-mark{border-color:var(--landing-cream)}footer p{margin:0;font-size:12px}footer>a:last-child{justify-self:end;align-items:center;gap:5px;font-size:12px;display:inline-flex}@media (width<=1080px){.hero-section{grid-template-columns:1fr}.hero-media-wrap{border-top:1px solid var(--landing-ink);border-left:0;min-height:650px}.loop-heading,.features-heading{grid-template-columns:1fr 1.4fr}.loop-copy,.features-heading>p:last-child{grid-column:2}.interface-grid{grid-template-columns:minmax(0,1fr);gap:0}.loop-bridge{border-right:1px solid var(--landing-cream);border-left:1px solid var(--landing-cream);flex-direction:row;min-height:90px}.bridge-line{width:80px}.bridge-line:before{width:60px}.feature-card{min-height:280px}.final-cta{grid-template-columns:1fr;gap:48px}}@media (width<=760px){.landing-nav{grid-template-columns:1fr auto;padding:0 18px}.landing-nav nav{display:none}.nav-cta{font-size:11px}.hero-copy{padding:76px 22px 66px}.hero-copy h1{font-size:clamp(55px,17vw,82px)}.hero-summary{font-size:19px}.hero-actions{flex-direction:column;align-items:flex-start}.hero-media-wrap{min-height:470px;padding:52px 22px}.hero-carousel-caption{grid-template-columns:1fr}.hero-carousel-caption .media-eyebrow{grid-row:auto}.loop-heading,.features-heading{grid-template-columns:1fr}.loop-copy,.features-heading>p:last-child{grid-column:1}.interface-grid{margin-top:48px}.interface-card{padding:26px 20px}.feature-grid{grid-template-columns:1fr}.feature-card{min-height:580px}.feature-card h3{margin-top:58px}.final-cta{padding:32px 20px}.install-command{grid-template-columns:auto 1fr}.install-command button{grid-column:1/-1;justify-content:center}footer{grid-template-columns:1fr auto;gap:28px}footer p{display:none}}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}.primary-cta,.hero-carousel-controls>button{transition:none}.media-slot-ready video{display:none}.media-slot-ready .reduced-motion-poster{display:block}.video-toggle{display:none}}