@shahmilsaari/memory-core 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -356,11 +356,13 @@ Runs in the background and checks each file the moment you save it. You see viol
356
356
  Options:
357
357
  ```bash
358
358
  npx @shahmilsaari/memory-core watch --path src/ # watch a specific folder only
359
+ npx @shahmilsaari/memory-core watch --scan-on-start # snapshot-scan tracked files once, then keep watching
359
360
  npx @shahmilsaari/memory-core watch --verbose # show extra details
360
361
  npx @shahmilsaari/memory-core watch --debug # show prompt, diff, and raw model output
361
362
  ```
362
363
 
363
- Only checks source files — ignores `node_modules`, `dist`, config files, JSON, etc.
364
+ Only checks source files — ignores `node_modules`, `dist`, config files, JSON, etc.
365
+ `--scan-on-start` is useful after a big refactor because it refreshes current live stats automatically before normal save-based watch mode begins.
364
366
 
365
367
  ---
366
368
 
@@ -369,7 +371,7 @@ Only checks source files — ignores `node_modules`, `dist`, config files, JSON,
369
371
  ```bash
370
372
  npx @shahmilsaari/memory-core dashboard
371
373
  npx @shahmilsaari/memory-core dashboard --port 5178
372
- npx @shahmilsaari/memory-core dashboard --path src/
374
+ npx @shahmilsaari/memory-core dashboard --path /absolute/path/to/project
373
375
  npx @shahmilsaari/memory-core dashboard --no-watch
374
376
  ```
375
377
 
@@ -384,6 +386,7 @@ Starts a local Svelte dashboard at `http://localhost:5178` by default. The dashb
384
386
  - live reload for `.env`, `.memory-core.env`, `.memory-core.json`, and `.memory-core-stats.json`
385
387
 
386
388
  The WebSocket endpoint is local: `ws://localhost:5178/ws`. Runtime config changes are reloaded and pushed to the browser without restarting the dashboard after the dashboard process is running.
389
+ When `--path` is provided, it must point to the project root (the directory containing `.memory-core.json`).
387
390
 
388
391
  ---
389
392
 
@@ -394,9 +397,13 @@ npx @shahmilsaari/memory-core check --staged # check staged files
394
397
  npx @shahmilsaari/memory-core check --staged --verbose # with extra detail
395
398
  npx @shahmilsaari/memory-core check --staged --debug # show prompt, diff, and raw model output
396
399
  npx @shahmilsaari/memory-core check --ci # CI mode using memories.json
400
+ npx @shahmilsaari/memory-core check --all # scan all tracked source files (not just staged changes)
401
+ npx @shahmilsaari/memory-core check --all --path src/ # scan only tracked files under src/
397
402
  ```
398
403
 
399
- `--staged` is the same path used by the pre-commit hook. `--ci` reads `memories.json` and uses a deterministic CI-friendly diff check, so pull requests can enforce rules without a local database or Ollama setup.
404
+ `--staged` is the same path used by the pre-commit hook. `--ci` reads `memories.json` and uses a deterministic CI-friendly diff check, so pull requests can enforce rules without a local database or Ollama setup.
405
+ `--all` runs a full tracked-file snapshot check and exits non-zero if violations are found.
406
+ `--all` and `--ci` are mutually exclusive in the same command.
400
407
 
401
408
  ---
402
409
 
@@ -585,9 +592,13 @@ Generates `.github/workflows/memory-core.yml`. Adds a PR check that runs `npx @s
585
592
 
586
593
  ```bash
587
594
  npx @shahmilsaari/memory-core stats
595
+ npx @shahmilsaari/memory-core stats --reset
588
596
  ```
589
597
 
590
- Shows which rules fire most often and which files have the most violations. Useful for spotting systemic issues in the codebase.
598
+ Shows which rules fire most often and which files have the most violations.
599
+ - If live watch state exists, `stats` shows current live counters.
600
+ - Otherwise it shows historical counters recorded over time.
601
+ - Use `--reset` to clear counters and recent violation history.
591
602
 
592
603
  ---
593
604
 
@@ -966,8 +966,8 @@ var seeds = [
966
966
  // src/watcher.ts
967
967
  import { watch } from "chokidar";
968
968
  import { spawnSync } from "child_process";
969
- import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
970
- import { join as join7, relative as relative2 } from "path";
969
+ import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync5, statSync as statSync2, writeFileSync as writeFileSync3 } from "fs";
970
+ import { join as join7, relative as relative2, resolve as resolve4, sep } from "path";
971
971
  import chalk from "chalk";
972
972
 
973
973
  // src/generator.ts
@@ -1195,6 +1195,14 @@ var ResilientGraphRepository = class {
1195
1195
  var ChokidarWatchService = class {
1196
1196
  async start(options = {}) {
1197
1197
  await startWatch({
1198
+ path: options.path,
1199
+ verbose: options.verbose,
1200
+ debug: options.debug,
1201
+ scanOnStart: options.scanOnStart
1202
+ });
1203
+ }
1204
+ async scan(options = {}) {
1205
+ return scanFiles({
1198
1206
  path: options.path,
1199
1207
  verbose: options.verbose,
1200
1208
  debug: options.debug
@@ -1896,7 +1904,7 @@ var OUTPUT_FILES = [
1896
1904
  var AGENT_NAMES = [...new Set(OUTPUT_FILES.map((f) => f.agent))];
1897
1905
  Handlebars.registerHelper(
1898
1906
  "join",
1899
- (arr, sep) => Array.isArray(arr) ? arr.join(sep) : ""
1907
+ (arr, sep2) => Array.isArray(arr) ? arr.join(sep2) : ""
1900
1908
  );
1901
1909
  Handlebars.registerHelper(
1902
1910
  "bullet",
@@ -2284,25 +2292,62 @@ var SOURCE_EXTENSIONS3 = /\.(ts|tsx|js|jsx|py|php|rb|go|java|cs|swift|kt|rs|vue|
2284
2292
  var reasonMap = new Map(
2285
2293
  seeds.filter((s) => s.reason).map((s) => [s.content, s.reason])
2286
2294
  );
2287
- function recordViolations(violations) {
2288
- const statsPath = join7(process.cwd(), ".memory-core-stats.json");
2289
- let stats = { rules: {}, files: {} };
2290
- if (existsSync6(statsPath)) {
2291
- try {
2292
- stats = JSON.parse(readFileSync5(statsPath, "utf-8"));
2293
- } catch {
2294
- stats = { rules: {}, files: {} };
2295
+ function readStatsFile(statsPath) {
2296
+ if (!existsSync6(statsPath)) return { rules: {}, files: {} };
2297
+ try {
2298
+ return JSON.parse(readFileSync5(statsPath, "utf-8"));
2299
+ } catch {
2300
+ return { rules: {}, files: {} };
2301
+ }
2302
+ }
2303
+ function rebuildLiveCounters(byFile) {
2304
+ const rules = {};
2305
+ const files = {};
2306
+ for (const [file, violations] of Object.entries(byFile)) {
2307
+ if (!Array.isArray(violations) || violations.length === 0) continue;
2308
+ files[file] = violations.length;
2309
+ for (const violation of violations) {
2310
+ rules[violation.rule] = (rules[violation.rule] ?? 0) + 1;
2295
2311
  }
2296
2312
  }
2313
+ return { rules, files };
2314
+ }
2315
+ function resetLiveStats(cwd) {
2316
+ const statsPath = join7(cwd, ".memory-core-stats.json");
2317
+ const stats = readStatsFile(statsPath);
2318
+ stats.rules ??= {};
2319
+ stats.files ??= {};
2320
+ stats.live = {
2321
+ rules: {},
2322
+ files: {},
2323
+ byFile: {}
2324
+ };
2325
+ writeFileSync3(statsPath, JSON.stringify(stats, null, 2) + "\n", "utf-8");
2326
+ }
2327
+ function recordWatchResult(cwd, file, violations) {
2328
+ const statsPath = join7(cwd, ".memory-core-stats.json");
2329
+ const stats = readStatsFile(statsPath);
2297
2330
  stats.rules ??= {};
2298
2331
  stats.files ??= {};
2332
+ stats.live ??= { rules: {}, files: {}, byFile: {} };
2333
+ stats.live.byFile ??= {};
2334
+ if (violations.length === 0) {
2335
+ delete stats.live.byFile[file];
2336
+ } else {
2337
+ stats.live.byFile[file] = violations;
2338
+ }
2339
+ const live = rebuildLiveCounters(stats.live.byFile);
2340
+ stats.live.rules = live.rules;
2341
+ stats.live.files = live.files;
2299
2342
  for (const violation of violations) {
2300
2343
  stats.rules[violation.rule] = (stats.rules[violation.rule] ?? 0) + 1;
2301
2344
  if (violation.file) stats.files[violation.file] = (stats.files[violation.file] ?? 0) + 1;
2302
2345
  }
2303
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
2304
- const recent = violations.map((violation) => ({ ...violation, timestamp, source: "watch" }));
2305
- stats.recentViolations = [...recent, ...stats.recentViolations ?? []].slice(0, 50);
2346
+ if (violations.length > 0) {
2347
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
2348
+ const recent = violations.map((violation) => ({ ...violation, timestamp, source: "watch" }));
2349
+ stats.recentViolations = [...recent, ...stats.recentViolations ?? []].slice(0, 50);
2350
+ }
2306
2351
  writeFileSync3(statsPath, JSON.stringify(stats, null, 2) + "\n", "utf-8");
2307
2352
  }
2308
2353
  function loadConfig(cwd) {
@@ -2333,7 +2378,7 @@ function getProfileRules(config2) {
2333
2378
  }
2334
2379
  return { rules, avoids };
2335
2380
  }
2336
- async function loadRelevantRules(config2, rel, diff, fallbackRules) {
2381
+ async function loadRelevantRules(cwd, config2, rel, diff, fallbackRules) {
2337
2382
  try {
2338
2383
  const query = buildContextQuery([
2339
2384
  rel,
@@ -2344,7 +2389,7 @@ async function loadRelevantRules(config2, rel, diff, fallbackRules) {
2344
2389
  ]);
2345
2390
  const memories = await retrieveContextualMemories({
2346
2391
  query,
2347
- cwd: process.cwd(),
2392
+ cwd,
2348
2393
  config: config2,
2349
2394
  limit: 15
2350
2395
  });
@@ -2363,10 +2408,11 @@ ${violation.file}`.toLowerCase();
2363
2408
  return !allowPatterns.some((pattern) => haystack.includes(pattern.toLowerCase()));
2364
2409
  });
2365
2410
  }
2366
- async function verifyViolations(diff, violations, allowPatterns, debug) {
2411
+ async function verifyViolations(inputText, violations, allowPatterns, debug, mode = "diff") {
2367
2412
  if (violations.length === 0) return violations;
2413
+ const sourceLabel = mode === "snapshot" ? "file content" : "diff";
2368
2414
  const systemPrompt = `You are verifying candidate architecture violations.
2369
- Only keep violations that are directly supported by the diff.
2415
+ Only keep violations that are directly supported by the ${sourceLabel}.
2370
2416
  Reject speculative or weak matches.
2371
2417
  Treat these allowlisted patterns as intentional and valid:
2372
2418
  ${allowPatterns.length ? allowPatterns.map((pattern, index) => `${index + 1}. ${pattern}`).join("\n") : "(none)"}
@@ -2374,8 +2420,8 @@ ${allowPatterns.length ? allowPatterns.map((pattern, index) => `${index + 1}. ${
2374
2420
  Return strict JSON:
2375
2421
  {"violations":[{"rule":"...","file":"...","line":1,"issue":"...","suggestion":"...","reason":"..."}]}
2376
2422
  Do not include any text outside the JSON.`;
2377
- const userPrompt = `Diff:
2378
- ${diff.slice(0, 6e3)}
2423
+ const userPrompt = `${mode === "snapshot" ? "File content" : "Diff"}:
2424
+ ${inputText.slice(0, 6e3)}
2379
2425
 
2380
2426
  Candidate violations:
2381
2427
  ${JSON.stringify(violations, null, 2)}`;
@@ -2407,26 +2453,128 @@ async function loadIgnorePatterns() {
2407
2453
  return [];
2408
2454
  }
2409
2455
  }
2410
- async function checkFile(filePath, cwd, config2, verbose, debug) {
2411
- const rel = relative2(cwd, filePath);
2412
- let diff;
2413
- const headResult = spawnSync("git", ["diff", "HEAD", "--", rel], { encoding: "utf-8", cwd });
2414
- if (headResult.stdout?.trim()) {
2415
- diff = headResult.stdout;
2456
+ function normalizeForGit(pathLike) {
2457
+ return pathLike.split(sep).join("/");
2458
+ }
2459
+ function listSourceFilesFromFilesystem(dir) {
2460
+ if (!existsSync6(dir)) return [];
2461
+ const files = [];
2462
+ const stack = [dir];
2463
+ while (stack.length > 0) {
2464
+ const current = stack.pop();
2465
+ let entries = [];
2466
+ try {
2467
+ entries = readdirSync3(current);
2468
+ } catch {
2469
+ continue;
2470
+ }
2471
+ for (const entry of entries) {
2472
+ const absolute = join7(current, entry);
2473
+ let isDirectory = false;
2474
+ let isFile = false;
2475
+ try {
2476
+ const stats = statSync2(absolute);
2477
+ isDirectory = stats.isDirectory();
2478
+ isFile = stats.isFile();
2479
+ } catch {
2480
+ continue;
2481
+ }
2482
+ if (isDirectory) {
2483
+ if (entry === "node_modules" || entry === ".git" || entry === "dist" || entry === "build" || entry === "coverage") {
2484
+ continue;
2485
+ }
2486
+ stack.push(absolute);
2487
+ continue;
2488
+ }
2489
+ if (isFile && SOURCE_EXTENSIONS3.test(absolute)) files.push(absolute);
2490
+ }
2491
+ }
2492
+ return files;
2493
+ }
2494
+ function listTrackedSourceFiles(projectRoot, watchPath) {
2495
+ const relPrefix = normalizeForGit(relative2(projectRoot, watchPath));
2496
+ const inRoot = relPrefix === "" || relPrefix === ".";
2497
+ const prefixWithSlash = inRoot ? "" : `${relPrefix}/`;
2498
+ const listed = spawnSync("git", ["ls-files"], { encoding: "utf-8", cwd: projectRoot });
2499
+ if (listed.status !== 0) {
2500
+ return listSourceFilesFromFilesystem(watchPath).sort();
2501
+ }
2502
+ const files = (listed.stdout ?? "").split("\n").filter((file) => file.length > 0).filter((file) => SOURCE_EXTENSIONS3.test(file)).filter((file) => inRoot || file.startsWith(prefixWithSlash)).map((file) => join7(projectRoot, file)).filter((file) => existsSync6(file));
2503
+ return [...new Set(files)].sort();
2504
+ }
2505
+ async function runSnapshotScan(projectRoot, watchPath, config2, verbose, debug, onEvent) {
2506
+ const files = listTrackedSourceFiles(projectRoot, watchPath);
2507
+ if (files.length === 0) {
2508
+ console.log(chalk.yellow("\n No tracked source files found for scan.\n"));
2509
+ return {
2510
+ filesChecked: 0,
2511
+ filesWithViolations: 0,
2512
+ violations: 0
2513
+ };
2514
+ }
2515
+ console.log(chalk.dim(`
2516
+ scanning ${files.length} tracked source files...
2517
+ `));
2518
+ const summary = {
2519
+ filesChecked: 0,
2520
+ filesWithViolations: 0,
2521
+ violations: 0
2522
+ };
2523
+ for (const filePath of files) {
2524
+ const rel = normalizeForGit(relative2(projectRoot, filePath));
2525
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
2526
+ onEvent?.({ type: "saved", timestamp, file: rel });
2527
+ const result = await checkFile(filePath, projectRoot, config2, verbose, debug, "snapshot");
2528
+ if (result.type !== "checked") {
2529
+ if (result.type === "skipped") {
2530
+ onEvent?.({ type: "skipped", timestamp: (/* @__PURE__ */ new Date()).toISOString(), file: rel, reason: result.reason });
2531
+ } else {
2532
+ onEvent?.({ type: "error", timestamp: (/* @__PURE__ */ new Date()).toISOString(), message: result.message });
2533
+ }
2534
+ continue;
2535
+ }
2536
+ summary.filesChecked += 1;
2537
+ if (result.violations.length === 0) {
2538
+ onEvent?.({ type: "clean", timestamp: (/* @__PURE__ */ new Date()).toISOString(), file: rel });
2539
+ continue;
2540
+ }
2541
+ summary.filesWithViolations += 1;
2542
+ summary.violations += result.violations.length;
2543
+ onEvent?.({ type: "violations", timestamp: (/* @__PURE__ */ new Date()).toISOString(), file: rel, violations: result.violations });
2544
+ }
2545
+ return summary;
2546
+ }
2547
+ async function checkFile(filePath, projectRoot, config2, verbose, debug, mode = "diff") {
2548
+ const rel = relative2(projectRoot, filePath).split(sep).join("/");
2549
+ if (rel.startsWith("..")) return { type: "skipped", reason: "File is outside project root" };
2550
+ let inputText;
2551
+ if (mode === "snapshot") {
2552
+ if (!existsSync6(filePath)) return { type: "skipped", reason: "File no longer exists" };
2553
+ inputText = readFileSync5(filePath, "utf-8");
2554
+ if (!inputText.trim()) return { type: "skipped", reason: "File is empty" };
2416
2555
  } else {
2417
- const noIndexResult = spawnSync("git", ["diff", "--no-index", "/dev/null", rel], { encoding: "utf-8", cwd });
2418
- diff = noIndexResult.stdout ?? "";
2556
+ const headResult = spawnSync("git", ["diff", "HEAD", "--", rel], { encoding: "utf-8", cwd: projectRoot });
2557
+ if (headResult.stdout?.trim()) {
2558
+ inputText = headResult.stdout;
2559
+ } else {
2560
+ const noIndexResult = spawnSync("git", ["diff", "--no-index", "/dev/null", rel], {
2561
+ encoding: "utf-8",
2562
+ cwd: projectRoot
2563
+ });
2564
+ inputText = noIndexResult.stdout ?? "";
2565
+ }
2566
+ if (!inputText.trim()) return { type: "skipped", reason: "No changes compared with HEAD" };
2419
2567
  }
2420
- if (!diff.trim()) return { type: "skipped", reason: "No changes compared with HEAD" };
2421
2568
  const { rules: fallbackRules, avoids } = getProfileRules(config2);
2422
- const rules = await loadRelevantRules(config2, rel, diff, fallbackRules);
2569
+ const rules = await loadRelevantRules(projectRoot, config2, rel, inputText, fallbackRules);
2423
2570
  if (rules.length === 0) return { type: "skipped", reason: "No applicable architecture rules" };
2424
- const MAX_DIFF = 6e3;
2425
- const truncated = diff.length > MAX_DIFF;
2426
- const diffToSend = truncated ? diff.slice(0, MAX_DIFF) + "\n\n[diff truncated]" : diff;
2571
+ const MAX_INPUT = 6e3;
2572
+ const truncated = inputText.length > MAX_INPUT;
2573
+ const inputToSend = truncated ? inputText.slice(0, MAX_INPUT) + "\n\n[input truncated]" : inputText;
2427
2574
  if (verbose || debug) {
2575
+ const label = mode === "snapshot" ? "snapshot" : `${inputText.length} chars`;
2428
2576
  console.log(chalk.dim(`
2429
- [watch] checking ${rel} (${diff.length} chars)\u2026`));
2577
+ [watch] checking ${rel} (${label})\u2026`));
2430
2578
  }
2431
2579
  const rulesWithReasons = rules.map((r, i) => {
2432
2580
  const why = reasonMap.get(r);
@@ -2435,7 +2583,7 @@ async function checkFile(filePath, cwd, config2, verbose, debug) {
2435
2583
  }).join("\n");
2436
2584
  const allowPatterns = [.../* @__PURE__ */ new Set([...getAllowPatterns(config2), ...await loadIgnorePatterns()])];
2437
2585
  const astViolations = findAstDeterministicViolationsForFile(rel, {
2438
- cwd,
2586
+ cwd: projectRoot,
2439
2587
  config: config2,
2440
2588
  rules,
2441
2589
  reasonLookup: reasonMap
@@ -2443,8 +2591,9 @@ async function checkFile(filePath, cwd, config2, verbose, debug) {
2443
2591
  ...violation,
2444
2592
  severity: "error"
2445
2593
  }));
2594
+ const analysisTarget = mode === "snapshot" ? "file content" : "file diff";
2446
2595
  const systemPrompt = `You are a strict code reviewer enforcing architecture rules.
2447
- Analyze the file diff and identify ONLY clear, definite rule violations.
2596
+ Analyze the ${analysisTarget} and identify ONLY clear, definite rule violations.
2448
2597
  Use the WHY for each rule to understand intent and judge edge cases.
2449
2598
 
2450
2599
  Rules to enforce:
@@ -2464,16 +2613,19 @@ No text outside the JSON.`;
2464
2613
  console.log(chalk.dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
2465
2614
  console.log(systemPrompt);
2466
2615
  console.log(chalk.dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
2467
- console.log(chalk.gray(` [debug] diff length: ${diff.length} chars`));
2468
- console.log(chalk.dim(diffToSend));
2616
+ console.log(chalk.gray(` [debug] input length: ${inputText.length} chars`));
2617
+ console.log(chalk.dim(inputToSend));
2469
2618
  console.log(chalk.dim(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
2470
2619
  }
2471
2620
  try {
2621
+ const reviewPrompt = mode === "snapshot" ? `Review this file ${rel}:
2622
+
2623
+ ${inputToSend}` : `Review this diff for ${rel}:
2624
+
2625
+ ${inputToSend}`;
2472
2626
  const raw = await callChatModel([
2473
2627
  { role: "system", content: systemPrompt },
2474
- { role: "user", content: `Review this diff for ${rel}:
2475
-
2476
- ${diffToSend}` }
2628
+ { role: "user", content: reviewPrompt }
2477
2629
  ]);
2478
2630
  if (debug) {
2479
2631
  console.log(chalk.gray(" [debug] raw response:"));
@@ -2493,7 +2645,7 @@ ${diffToSend}` }
2493
2645
  } catch {
2494
2646
  violations = [];
2495
2647
  }
2496
- violations = await verifyViolations(diff, violations, allowPatterns, debug);
2648
+ violations = await verifyViolations(inputText, violations, allowPatterns, debug, mode);
2497
2649
  violations = [...astViolations, ...violations];
2498
2650
  violations = applyAllowPatterns(violations, allowPatterns);
2499
2651
  violations = violations.map((violation) => ({
@@ -2501,6 +2653,7 @@ ${diffToSend}` }
2501
2653
  code: violation.code ?? (violation.line ? formatCodeContext(filePath, violation.line, 1) : void 0)
2502
2654
  }));
2503
2655
  if (violations.length === 0) {
2656
+ recordWatchResult(projectRoot, rel, []);
2504
2657
  console.log(chalk.green(` \u2713 ${rel}`) + chalk.dim(" \u2014 no violations"));
2505
2658
  return { type: "checked", violations: [] };
2506
2659
  }
@@ -2522,7 +2675,7 @@ ${diffToSend}` }
2522
2675
  if (v.suggestion) console.log(chalk.green(" Fix: ") + v.suggestion);
2523
2676
  console.log();
2524
2677
  });
2525
- recordViolations(violations);
2678
+ recordWatchResult(projectRoot, rel, violations);
2526
2679
  console.log(chalk.dim(' Fix violations or run: memory-core remember "<lesson>"'));
2527
2680
  console.log();
2528
2681
  return { type: "checked", violations };
@@ -2536,6 +2689,7 @@ ${diffToSend}` }
2536
2689
  code: violation.code ?? (violation.line ? formatCodeContext(filePath, violation.line, 1) : void 0)
2537
2690
  }));
2538
2691
  if (violations.length === 0) {
2692
+ recordWatchResult(projectRoot, rel, []);
2539
2693
  console.log(chalk.green(` \u2713 ${rel}`) + chalk.dim(" \u2014 no deterministic violations"));
2540
2694
  return { type: "checked", violations: [] };
2541
2695
  }
@@ -2557,15 +2711,56 @@ ${diffToSend}` }
2557
2711
  if (v.suggestion) console.log(chalk.green(" Fix: ") + v.suggestion);
2558
2712
  console.log();
2559
2713
  });
2560
- recordViolations(violations);
2714
+ recordWatchResult(projectRoot, rel, violations);
2561
2715
  console.log(chalk.dim(' Fix violations or run: memory-core remember "<lesson>"'));
2562
2716
  console.log();
2563
2717
  return { type: "checked", violations };
2564
2718
  }
2565
2719
  }
2720
+ async function scanFiles(options = {}) {
2721
+ const projectRoot = resolve4(process.cwd());
2722
+ const watchPath = resolve4(projectRoot, options.path ?? ".");
2723
+ const config2 = loadConfig(projectRoot);
2724
+ if (!config2) {
2725
+ throw new Error("No .memory-core.json found. Run: memory-core init");
2726
+ }
2727
+ const { rules } = getProfileRules(config2);
2728
+ if (rules.length === 0) {
2729
+ console.log(chalk.yellow("\n No architecture rules configured in .memory-core.json \u2014 nothing to scan.\n"));
2730
+ return {
2731
+ filesChecked: 0,
2732
+ filesWithViolations: 0,
2733
+ violations: 0
2734
+ };
2735
+ }
2736
+ resetLiveStats(projectRoot);
2737
+ console.log(chalk.cyan("\n archmind scan \u2014 checking tracked source files\n"));
2738
+ console.log(chalk.dim(` project: ${projectRoot}`));
2739
+ console.log(chalk.dim(` path: ${watchPath}`));
2740
+ console.log(chalk.dim(` model: ${getChatProviderLabel()}`));
2741
+ console.log(chalk.dim(` rules: ${rules.length}
2742
+ `));
2743
+ const summary = await runSnapshotScan(
2744
+ projectRoot,
2745
+ watchPath,
2746
+ config2,
2747
+ options.verbose ?? false,
2748
+ options.debug ?? false,
2749
+ options.onEvent
2750
+ );
2751
+ const cleanFiles = summary.filesChecked - summary.filesWithViolations;
2752
+ console.log(chalk.bold("\n scan summary\n"));
2753
+ console.log(chalk.dim(` files checked: ${summary.filesChecked}`));
2754
+ console.log(chalk.dim(` files clean: ${cleanFiles}`));
2755
+ console.log(chalk.dim(` files with violations: ${summary.filesWithViolations}`));
2756
+ console.log(chalk.dim(` total violations: ${summary.violations}
2757
+ `));
2758
+ return summary;
2759
+ }
2566
2760
  async function startWatch(options = {}) {
2567
- const cwd = process.cwd();
2568
- const config2 = loadConfig(cwd);
2761
+ const projectRoot = resolve4(process.cwd());
2762
+ const watchPath = resolve4(projectRoot, options.path ?? ".");
2763
+ const config2 = loadConfig(projectRoot);
2569
2764
  const exitOnSetupFailure = options.exitOnSetupFailure ?? true;
2570
2765
  if (!config2) {
2571
2766
  const message = "No .memory-core.json found. Run: memory-core init";
@@ -2586,8 +2781,9 @@ async function startWatch(options = {}) {
2586
2781
  if (exitOnSetupFailure) process.exit(0);
2587
2782
  return;
2588
2783
  }
2589
- const watchPath = options.path ?? cwd;
2784
+ resetLiveStats(projectRoot);
2590
2785
  console.log(chalk.cyan("\n archmind watch \u2014 real-time rule enforcement\n"));
2786
+ console.log(chalk.dim(` project: ${projectRoot}`));
2591
2787
  console.log(chalk.dim(` watching: ${watchPath}`));
2592
2788
  console.log(chalk.dim(` model: ${getChatProviderLabel()}`));
2593
2789
  console.log(chalk.dim(` rules: ${rules.length}`));
@@ -2599,6 +2795,18 @@ async function startWatch(options = {}) {
2599
2795
  model: getChatProviderLabel(),
2600
2796
  rules: rules.length
2601
2797
  });
2798
+ if (options.scanOnStart) {
2799
+ console.log(chalk.dim(" running initial snapshot scan before watch events..."));
2800
+ await runSnapshotScan(
2801
+ projectRoot,
2802
+ watchPath,
2803
+ config2,
2804
+ options.verbose ?? false,
2805
+ options.debug ?? false,
2806
+ options.onEvent
2807
+ );
2808
+ console.log(chalk.dim(" initial scan complete.\n"));
2809
+ }
2602
2810
  const pending = /* @__PURE__ */ new Map();
2603
2811
  const watcher = watch(watchPath, {
2604
2812
  ignored: [
@@ -2620,13 +2828,26 @@ async function startWatch(options = {}) {
2620
2828
  if (pending.has(filePath)) clearTimeout(pending.get(filePath));
2621
2829
  const timer = setTimeout(async () => {
2622
2830
  pending.delete(filePath);
2623
- const rel = relative2(cwd, filePath);
2831
+ const rel = normalizeForGit(relative2(projectRoot, filePath));
2832
+ if (rel.startsWith("..")) return;
2624
2833
  const timestamp = /* @__PURE__ */ new Date();
2625
2834
  console.log(chalk.dim(`
2626
2835
  [${timestamp.toLocaleTimeString()}] saved: ${rel}`));
2627
2836
  options.onEvent?.({ type: "saved", timestamp: timestamp.toISOString(), file: rel });
2628
- const result = await checkFile(filePath, cwd, config2, options.verbose ?? false, options.debug ?? false);
2837
+ const result = await checkFile(
2838
+ filePath,
2839
+ projectRoot,
2840
+ config2,
2841
+ options.verbose ?? false,
2842
+ options.debug ?? false,
2843
+ "diff"
2844
+ );
2629
2845
  if (result.type === "skipped") {
2846
+ if (result.reason === "No changes compared with HEAD") {
2847
+ recordWatchResult(projectRoot, rel, []);
2848
+ options.onEvent?.({ type: "clean", timestamp: (/* @__PURE__ */ new Date()).toISOString(), file: rel });
2849
+ return;
2850
+ }
2630
2851
  options.onEvent?.({ type: "skipped", timestamp: (/* @__PURE__ */ new Date()).toISOString(), file: rel, reason: result.reason });
2631
2852
  return;
2632
2853
  }
@@ -2645,6 +2866,12 @@ async function startWatch(options = {}) {
2645
2866
  };
2646
2867
  watcher.on("add", handle);
2647
2868
  watcher.on("change", handle);
2869
+ watcher.on("unlink", (filePath) => {
2870
+ const rel = normalizeForGit(relative2(projectRoot, filePath));
2871
+ if (rel.startsWith("..")) return;
2872
+ recordWatchResult(projectRoot, rel, []);
2873
+ options.onEvent?.({ type: "clean", timestamp: (/* @__PURE__ */ new Date()).toISOString(), file: rel });
2874
+ });
2648
2875
  watcher.on("error", (err) => {
2649
2876
  const message = err instanceof Error ? err.message : String(err);
2650
2877
  console.error(chalk.red(` watcher error: ${message}`));
package/dist/cli.js CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  retrieveMemorySelection,
21
21
  runMigrations,
22
22
  seeds
23
- } from "./chunk-PDQXIKL7.js";
23
+ } from "./chunk-WJG77BPO.js";
24
24
 
25
25
  // src/cli.ts
26
26
  import { Command } from "commander";
@@ -2073,8 +2073,23 @@ program.command("uninstall").description("Remove memory-core from the current pr
2073
2073
  console.log(chalk2.gray(" \u2713 cleaned .gitignore memory-core block"));
2074
2074
  }
2075
2075
  });
2076
- program.command("stats").description("Show violation counters recorded by check and watch").action(() => {
2076
+ program.command("stats").description("Show violation counters recorded by check and watch").option("--reset", "Reset violation counters and recent history").action((opts) => {
2077
2077
  const statsPath = join3(process.cwd(), ".memory-core-stats.json");
2078
+ if (opts.reset) {
2079
+ const emptyStats = {
2080
+ rules: {},
2081
+ files: {},
2082
+ live: {
2083
+ rules: {},
2084
+ files: {},
2085
+ byFile: {}
2086
+ },
2087
+ recentViolations: []
2088
+ };
2089
+ writeFileSync3(statsPath, JSON.stringify(emptyStats, null, 2) + "\n", "utf-8");
2090
+ console.log(chalk2.green("\n Violation stats reset.\n"));
2091
+ return;
2092
+ }
2078
2093
  if (!existsSync3(statsPath)) {
2079
2094
  console.log(chalk2.yellow("\n No violation stats recorded yet.\n"));
2080
2095
  return;
@@ -2088,12 +2103,31 @@ program.command("stats").description("Show violation counters recorded by check
2088
2103
  console.log(` ${index + 1}. ${truncate(name, 44).padEnd(46)} ${count}`);
2089
2104
  });
2090
2105
  };
2091
- printTop("Top rules", stats.rules);
2092
- printTop("Top files", stats.files);
2093
- console.log();
2106
+ const liveRules = stats.live?.rules ?? {};
2107
+ const liveFiles = stats.live?.files ?? {};
2108
+ const hasLiveState = !!stats.live;
2109
+ const hasLiveViolations = Object.keys(liveRules).length > 0 || Object.keys(liveFiles).length > 0;
2110
+ printTop(
2111
+ hasLiveState ? "Top rules (current watch state)" : "Top rules",
2112
+ hasLiveState ? liveRules : stats.rules
2113
+ );
2114
+ printTop(
2115
+ hasLiveState ? "Top files (current watch state)" : "Top files",
2116
+ hasLiveState ? liveFiles : stats.files
2117
+ );
2118
+ if (!hasLiveState) {
2119
+ console.log(chalk2.dim("\n Note: these counters are historical events, not live current code state."));
2120
+ console.log(chalk2.dim(" Start watch for live counters, or reset with: memory-core stats --reset\n"));
2121
+ } else {
2122
+ if (hasLiveViolations) {
2123
+ console.log(chalk2.dim("\n Live counters auto-refresh while watch is running.\n"));
2124
+ } else {
2125
+ console.log(chalk2.dim("\n Current live state has no violations.\n"));
2126
+ }
2127
+ }
2094
2128
  });
2095
2129
  program.command("dashboard").description("Start the live Svelte dashboard with WebSocket watch events").option("-p, --port <port>", "Dashboard port", "5178").option("--path <dir>", "Directory to watch (default: current directory)").option("--no-watch", "Serve the dashboard without starting file watch").action(async (opts) => {
2096
- const { startDashboard } = await import("./dashboard-server-AUX4BQP6.js");
2130
+ const { startDashboard } = await import("./dashboard-server-OEDFMSFB.js");
2097
2131
  await startDashboard({
2098
2132
  port: parseInt(opts.port, 10),
2099
2133
  path: opts.path,
@@ -2497,16 +2531,30 @@ hook.command("install").description("Install pre-commit hook (advisory mode by d
2497
2531
  hook.command("uninstall").description("Remove the pre-commit hook").action(() => {
2498
2532
  uninstallHook();
2499
2533
  });
2500
- program.command("check").description("Check staged changes against architecture rules (used by pre-commit hook)").option("--staged", "Check git staged diff (default behaviour)").option("--ci", `Check CI diff using ${MEMORY_FILE}`).option("--verbose", "Show model and diff details").option("--debug", "Show prompt, diff, and raw model response").action(async (opts) => {
2534
+ program.command("check").description("Check staged changes against architecture rules (used by pre-commit hook)").option("--staged", "Check git staged diff (default behaviour)").option("--ci", `Check CI diff using ${MEMORY_FILE}`).option("--all", "Check all tracked source files, including already-committed files").option("--path <dir>", "Directory to check for --all mode (default: current directory)").option("--verbose", "Show model and diff details").option("--debug", "Show prompt, diff, and raw model response").action(async (opts) => {
2535
+ if (opts.ci && opts.all) {
2536
+ console.error(chalk2.red("\n Choose one mode: --ci or --all.\n"));
2537
+ process.exit(1);
2538
+ }
2501
2539
  if (opts.ci) {
2502
2540
  await checkCi({ verbose: opts.verbose ?? false, debug: opts.debug ?? false });
2503
2541
  return;
2504
2542
  }
2543
+ if (opts.all) {
2544
+ const summary = await phase1.providers.watchService.scan({
2545
+ path: opts.path,
2546
+ verbose: opts.verbose,
2547
+ debug: opts.debug
2548
+ });
2549
+ if (summary.violations > 0) process.exit(1);
2550
+ return;
2551
+ }
2505
2552
  await checkStaged({ verbose: opts.verbose ?? false, debug: opts.debug ?? false });
2506
2553
  });
2507
- program.command("watch").description("Watch source files and check violations in real-time on every save").option("--path <dir>", "Directory to watch (default: current directory)").option("--verbose", "Show diff size and model details per file").option("--debug", "Show prompt, diff, and raw model response").action(async (opts) => {
2554
+ program.command("watch").description("Watch source files and check violations in real-time on every save").option("--path <dir>", "Directory to watch (default: current directory)").option("--scan-on-start", "Run an initial full snapshot scan before watching file changes").option("--verbose", "Show diff size and model details per file").option("--debug", "Show prompt, diff, and raw model response").action(async (opts) => {
2508
2555
  await phase1.providers.watchService.start({
2509
2556
  path: opts.path,
2557
+ scanOnStart: opts.scanOnStart,
2510
2558
  verbose: opts.verbose,
2511
2559
  debug: opts.debug
2512
2560
  });
@@ -0,0 +1,2 @@
1
+ var ql=Object.defineProperty;var zn=e=>{throw TypeError(e)};var Ul=(e,t,s)=>t in e?ql(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Fe=(e,t,s)=>Ul(e,typeof t!="symbol"?t+"":t,s),tr=(e,t,s)=>t.has(e)||zn("Cannot "+s);var c=(e,t,s)=>(tr(e,t,"read from private field"),s?s.call(e):t.get(e)),N=(e,t,s)=>t.has(e)?zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),D=(e,t,s,r)=>(tr(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s),U=(e,t,s)=>(tr(e,t,"access private method"),s);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const u of i.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();const Vl=!1;var wr=Array.isArray,zl=Array.prototype.indexOf,Vt=Array.prototype.includes,Ws=Array.from,Hl=Object.defineProperty,is=Object.getOwnPropertyDescriptor,ua=Object.getOwnPropertyDescriptors,Bl=Object.prototype,Kl=Array.prototype,Er=Object.getPrototypeOf,Hn=Object.isExtensible;const Yl=()=>{};function Gl(e){return e()}function lr(e){for(var t=0;t<e.length;t++)e[t]()}function va(){var e,t,s=new Promise((r,a)=>{e=r,t=a});return{promise:s,resolve:e,reject:t}}const le=2,zt=4,bs=8,da=1<<24,Be=16,$e=32,vt=64,or=128,Re=512,X=1024,re=2048,We=4096,ce=8192,Ce=16384,Dt=32768,Bn=1<<25,Ht=65536,cr=1<<17,Jl=1<<18,Yt=1<<19,pa=1<<20,He=1<<25,Rt=65536,Fs=1<<21,fs=1<<22,ft=1<<23,kt=Symbol("$state"),Xe=new class extends Error{constructor(){super(...arguments);Fe(this,"name","StaleReactionError");Fe(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};function _a(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Ql(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Xl(e,t,s){throw new Error("https://svelte.dev/e/each_key_duplicate")}function Zl(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function eo(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function to(e){throw new Error("https://svelte.dev/e/effect_orphan")}function so(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function ro(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function no(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function ao(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function io(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const lo=1,oo=2,ha=4,co=8,fo=16,uo=2,ee=Symbol(),ga="http://www.w3.org/1999/xhtml";function vo(){console.warn("https://svelte.dev/e/derived_inert")}function po(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function _o(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function ba(e){return e===this.v}function ho(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function ma(e){return!ho(e,this.v)}let ms=!1,go=!1;function bo(){ms=!0}let z=null;function Bt(e){z=e}function ya(e,t=!1,s){z={p:z,i:!1,c:null,e:null,s:e,x:null,r:O,l:ms&&!t?{s:null,u:null,$:[]}:null}}function wa(e){var t=z,s=t.e;if(s!==null){t.e=null;for(var r of s)Ua(r)}return t.i=!0,z=t.p,{}}function ys(){return!ms||z!==null&&z.l===null}let gt=[];function Ea(){var e=gt;gt=[],lr(e)}function ut(e){if(gt.length===0&&!ls){var t=gt;queueMicrotask(()=>{t===gt&&Ea()})}gt.push(e)}function mo(){for(;gt.length>0;)Ea()}function xa(e){var t=O;if(t===null)return I.f|=ft,e;if(!(t.f&Dt)&&!(t.f&zt))throw e;ct(e,t)}function ct(e,t){for(;t!==null;){if(t.f&or){if(!(t.f&Dt))throw e;try{t.b.error(e);return}catch(s){e=s}}t=t.parent}throw e}const yo=-7169;function Y(e,t){e.f=e.f&yo|t}function xr(e){e.f&Re||e.deps===null?Y(e,X):Y(e,We)}function ka(e){if(e!==null)for(const t of e)!(t.f&le)||!(t.f&Rt)||(t.f^=Rt,ka(t.deps))}function Sa(e,t,s){e.f&re?t.add(e):e.f&We&&s.add(e),ka(e.deps),Y(e,X)}const ht=new Set;let S=null,se=null,fr=null,ls=!1,sr=!1,Pt=null,Rs=null;var Kn=0;let wo=1;var jt,$t,mt,Ze,Ue,vs,be,ds,lt,et,Ve,Wt,qt,yt,Z,Cs,Ta,Ns,ur,Ms,Eo;const Ps=class Ps{constructor(){N(this,Z);Fe(this,"id",wo++);Fe(this,"current",new Map);Fe(this,"previous",new Map);N(this,jt,new Set);N(this,$t,new Set);N(this,mt,new Set);N(this,Ze,new Map);N(this,Ue,new Map);N(this,vs,null);N(this,be,[]);N(this,ds,[]);N(this,lt,new Set);N(this,et,new Set);N(this,Ve,new Map);N(this,Wt,new Set);Fe(this,"is_fork",!1);N(this,qt,!1);N(this,yt,new Set)}skip_effect(t){c(this,Ve).has(t)||c(this,Ve).set(t,{d:[],m:[]}),c(this,Wt).delete(t)}unskip_effect(t,s=r=>this.schedule(r)){var r=c(this,Ve).get(t);if(r){c(this,Ve).delete(t);for(var a of r.d)Y(a,re),s(a);for(a of r.m)Y(a,We),s(a)}c(this,Wt).add(t)}capture(t,s,r=!1){t.v!==ee&&!this.previous.has(t)&&this.previous.set(t,t.v),t.f&ft||(this.current.set(t,[s,r]),se==null||se.set(t,s)),this.is_fork||(t.v=s)}activate(){S=this}deactivate(){S=null,se=null}flush(){try{sr=!0,S=this,U(this,Z,Ns).call(this)}finally{Kn=0,fr=null,Pt=null,Rs=null,sr=!1,S=null,se=null,St.clear()}}discard(){for(const t of c(this,$t))t(this);c(this,$t).clear(),c(this,mt).clear(),ht.delete(this)}register_created_effect(t){c(this,ds).push(t)}increment(t,s){let r=c(this,Ze).get(s)??0;if(c(this,Ze).set(s,r+1),t){let a=c(this,Ue).get(s)??0;c(this,Ue).set(s,a+1)}}decrement(t,s,r){let a=c(this,Ze).get(s)??0;if(a===1?c(this,Ze).delete(s):c(this,Ze).set(s,a-1),t){let i=c(this,Ue).get(s)??0;i===1?c(this,Ue).delete(s):c(this,Ue).set(s,i-1)}c(this,qt)||r||(D(this,qt,!0),ut(()=>{D(this,qt,!1),this.flush()}))}transfer_effects(t,s){for(const r of t)c(this,lt).add(r);for(const r of s)c(this,et).add(r);t.clear(),s.clear()}oncommit(t){c(this,jt).add(t)}ondiscard(t){c(this,$t).add(t)}on_fork_commit(t){c(this,mt).add(t)}run_fork_commit_callbacks(){for(const t of c(this,mt))t(this);c(this,mt).clear()}settled(){return(c(this,vs)??D(this,vs,va())).promise}static ensure(){if(S===null){const t=S=new Ps;sr||(ht.add(S),ls||ut(()=>{S===t&&t.flush()}))}return S}apply(){{se=null;return}}schedule(t){var a;if(fr=t,(a=t.b)!=null&&a.is_pending&&t.f&(zt|bs|da)&&!(t.f&Dt)){t.b.defer_effect(t);return}for(var s=t;s.parent!==null;){s=s.parent;var r=s.f;if(Pt!==null&&s===O&&(I===null||!(I.f&le)))return;if(r&(vt|$e)){if(!(r&X))return;s.f^=X}}c(this,be).push(s)}};jt=new WeakMap,$t=new WeakMap,mt=new WeakMap,Ze=new WeakMap,Ue=new WeakMap,vs=new WeakMap,be=new WeakMap,ds=new WeakMap,lt=new WeakMap,et=new WeakMap,Ve=new WeakMap,Wt=new WeakMap,qt=new WeakMap,yt=new WeakMap,Z=new WeakSet,Cs=function(){return this.is_fork||c(this,Ue).size>0},Ta=function(){for(const r of c(this,yt))for(const a of c(r,Ue).keys()){for(var t=!1,s=a;s.parent!==null;){if(c(this,Ve).has(s)){t=!0;break}s=s.parent}if(!t)return!0}return!1},Ns=function(){var d,v;if(Kn++>1e3&&(ht.delete(this),ko()),!U(this,Z,Cs).call(this)){for(const p of c(this,lt))c(this,et).delete(p),Y(p,re),this.schedule(p);for(const p of c(this,et))Y(p,We),this.schedule(p)}const t=c(this,be);D(this,be,[]),this.apply();var s=Pt=[],r=[],a=Rs=[];for(const p of t)try{U(this,Z,ur).call(this,p,s,r)}catch(g){throw Ca(p),g}if(S=null,a.length>0){var i=Ps.ensure();for(const p of a)i.schedule(p)}if(Pt=null,Rs=null,U(this,Z,Cs).call(this)||U(this,Z,Ta).call(this)){U(this,Z,Ms).call(this,r),U(this,Z,Ms).call(this,s);for(const[p,g]of c(this,Ve))Ra(p,g)}else{c(this,Ze).size===0&&ht.delete(this),c(this,lt).clear(),c(this,et).clear();for(const p of c(this,jt))p(this);c(this,jt).clear(),Yn(r),Yn(s),(d=c(this,vs))==null||d.resolve()}var u=S;if(c(this,be).length>0){const p=u??(u=this);c(p,be).push(...c(this,be).filter(g=>!c(p,be).includes(g)))}u!==null&&(ht.add(u),U(v=u,Z,Ns).call(v))},ur=function(t,s,r){t.f^=X;for(var a=t.first;a!==null;){var i=a.f,u=(i&($e|vt))!==0,d=u&&(i&X)!==0,v=d||(i&ce)!==0||c(this,Ve).has(a);if(!v&&a.fn!==null){u?a.f^=X:i&zt?s.push(a):Gt(a)&&(i&Be&&c(this,et).add(a),Mt(a));var p=a.first;if(p!==null){a=p;continue}}for(;a!==null;){var g=a.next;if(g!==null){a=g;break}a=a.parent}}},Ms=function(t){for(var s=0;s<t.length;s+=1)Sa(t[s],c(this,lt),c(this,et))},Eo=function(){var g,E,w;for(const y of ht){var t=y.id<this.id,s=[];for(const[o,[T,m]]of this.current){if(y.current.has(o)){var r=y.current.get(o)[0];if(t&&T!==r)y.current.set(o,[T,m]);else continue}s.push(o)}var a=[...y.current.keys()].filter(o=>!this.current.has(o));if(a.length===0)t&&y.discard();else if(s.length>0){if(t)for(const o of c(this,Wt))y.unskip_effect(o,T=>{var m;T.f&(Be|fs)?y.schedule(T):U(m=y,Z,Ms).call(m,[T])});y.activate();var i=new Set,u=new Map;for(var d of s)Aa(d,a,i,u);u=new Map;var v=[...y.current.keys()].filter(o=>this.current.has(o)?this.current.get(o)[0]!==o:!0);for(const o of c(this,ds))!(o.f&(Ce|ce|cr))&&kr(o,v,u)&&(o.f&(fs|Be)?(Y(o,re),y.schedule(o)):c(y,lt).add(o));if(c(y,be).length>0){y.apply();for(var p of c(y,be))U(g=y,Z,ur).call(g,p,[],[]);D(y,be,[])}y.deactivate()}}for(const y of ht)c(y,yt).has(this)&&(c(y,yt).delete(this),c(y,yt).size===0&&!U(E=y,Z,Cs).call(E)&&(y.activate(),U(w=y,Z,Ns).call(w)))};let Ct=Ps;function xo(e){var t=ls;ls=!0;try{for(var s;;){if(mo(),S===null)return s;S.flush()}}finally{ls=t}}function ko(){try{so()}catch(e){ct(e,fr)}}let Le=null;function Yn(e){var t=e.length;if(t!==0){for(var s=0;s<t;){var r=e[s++];if(!(r.f&(Ce|ce))&&Gt(r)&&(Le=new Set,Mt(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&za(r),(Le==null?void 0:Le.size)>0)){St.clear();for(const a of Le){if(a.f&(Ce|ce))continue;const i=[a];let u=a.parent;for(;u!==null;)Le.has(u)&&(Le.delete(u),i.push(u)),u=u.parent;for(let d=i.length-1;d>=0;d--){const v=i[d];v.f&(Ce|ce)||Mt(v)}}Le.clear()}}Le=null}}function Aa(e,t,s,r){if(!s.has(e)&&(s.add(e),e.reactions!==null))for(const a of e.reactions){const i=a.f;i&le?Aa(a,t,s,r):i&(fs|Be)&&!(i&re)&&kr(a,t,r)&&(Y(a,re),Sr(a))}}function kr(e,t,s){const r=s.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const a of e.deps){if(Vt.call(t,a))return!0;if(a.f&le&&kr(a,t,s))return s.set(a,!0),!0}return s.set(e,!1),!1}function Sr(e){S.schedule(e)}function Ra(e,t){if(!(e.f&$e&&e.f&X)){e.f&re?t.d.push(e):e.f&We&&t.m.push(e),Y(e,X);for(var s=e.first;s!==null;)Ra(s,t),s=s.next}}function Ca(e){Y(e,X);for(var t=e.first;t!==null;)Ca(t),t=t.next}function So(e){let t=0,s=Nt(0),r;return()=>{Cr()&&(n(s),Us(()=>(t===0&&(r=b(()=>e(()=>os(s)))),t+=1,()=>{ut(()=>{t-=1,t===0&&(r==null||r(),r=void 0,os(s))})})))}}var To=Ht|Yt;function Ao(e,t,s,r){new Ro(e,t,s,r)}var ke,yr,Se,wt,ue,Te,oe,me,tt,Et,ot,Ut,ps,_s,st,js,G,Co,No,Mo,vr,Ds,Os,dr,pr;class Ro{constructor(t,s,r,a){N(this,G);Fe(this,"parent");Fe(this,"is_pending",!1);Fe(this,"transform_error");N(this,ke);N(this,yr,null);N(this,Se);N(this,wt);N(this,ue);N(this,Te,null);N(this,oe,null);N(this,me,null);N(this,tt,null);N(this,Et,0);N(this,ot,0);N(this,Ut,!1);N(this,ps,new Set);N(this,_s,new Set);N(this,st,null);N(this,js,So(()=>(D(this,st,Nt(c(this,Et))),()=>{D(this,st,null)})));var i;D(this,ke,t),D(this,Se,s),D(this,wt,u=>{var d=O;d.b=this,d.f|=or,r(u)}),this.parent=O.b,this.transform_error=a??((i=this.parent)==null?void 0:i.transform_error)??(u=>u),D(this,ue,Mr(()=>{U(this,G,vr).call(this)},To))}defer_effect(t){Sa(t,c(this,ps),c(this,_s))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!c(this,Se).pending}update_pending_count(t,s){U(this,G,dr).call(this,t,s),D(this,Et,c(this,Et)+t),!(!c(this,st)||c(this,Ut))&&(D(this,Ut,!0),ut(()=>{D(this,Ut,!1),c(this,st)&&Kt(c(this,st),c(this,Et))}))}get_effect_pending(){return c(this,js).call(this),n(c(this,st))}error(t){if(!c(this,Se).onerror&&!c(this,Se).failed)throw t;S!=null&&S.is_fork?(c(this,Te)&&S.skip_effect(c(this,Te)),c(this,oe)&&S.skip_effect(c(this,oe)),c(this,me)&&S.skip_effect(c(this,me)),S.on_fork_commit(()=>{U(this,G,pr).call(this,t)})):U(this,G,pr).call(this,t)}}ke=new WeakMap,yr=new WeakMap,Se=new WeakMap,wt=new WeakMap,ue=new WeakMap,Te=new WeakMap,oe=new WeakMap,me=new WeakMap,tt=new WeakMap,Et=new WeakMap,ot=new WeakMap,Ut=new WeakMap,ps=new WeakMap,_s=new WeakMap,st=new WeakMap,js=new WeakMap,G=new WeakSet,Co=function(){try{D(this,Te,Ae(()=>c(this,wt).call(this,c(this,ke))))}catch(t){this.error(t)}},No=function(t){const s=c(this,Se).failed;s&&D(this,me,Ae(()=>{s(c(this,ke),()=>t,()=>()=>{})}))},Mo=function(){const t=c(this,Se).pending;t&&(this.is_pending=!0,D(this,oe,Ae(()=>t(c(this,ke)))),ut(()=>{var s=D(this,tt,document.createDocumentFragment()),r=rt();s.append(r),D(this,Te,U(this,G,Os).call(this,()=>Ae(()=>c(this,wt).call(this,r)))),c(this,ot)===0&&(c(this,ke).before(s),D(this,tt,null),Tt(c(this,oe),()=>{D(this,oe,null)}),U(this,G,Ds).call(this,S))}))},vr=function(){try{if(this.is_pending=this.has_pending_snippet(),D(this,ot,0),D(this,Et,0),D(this,Te,Ae(()=>{c(this,wt).call(this,c(this,ke))})),c(this,ot)>0){var t=D(this,tt,document.createDocumentFragment());Ir(c(this,Te),t);const s=c(this,Se).pending;D(this,oe,Ae(()=>s(c(this,ke))))}else U(this,G,Ds).call(this,S)}catch(s){this.error(s)}},Ds=function(t){this.is_pending=!1,t.transfer_effects(c(this,ps),c(this,_s))},Os=function(t){var s=O,r=I,a=z;De(c(this,ue)),Me(c(this,ue)),Bt(c(this,ue).ctx);try{return Ct.ensure(),t()}catch(i){return xa(i),null}finally{De(s),Me(r),Bt(a)}},dr=function(t,s){var r;if(!this.has_pending_snippet()){this.parent&&U(r=this.parent,G,dr).call(r,t,s);return}D(this,ot,c(this,ot)+t),c(this,ot)===0&&(U(this,G,Ds).call(this,s),c(this,oe)&&Tt(c(this,oe),()=>{D(this,oe,null)}),c(this,tt)&&(c(this,ke).before(c(this,tt)),D(this,tt,null)))},pr=function(t){c(this,Te)&&(de(c(this,Te)),D(this,Te,null)),c(this,oe)&&(de(c(this,oe)),D(this,oe,null)),c(this,me)&&(de(c(this,me)),D(this,me,null));var s=c(this,Se).onerror;let r=c(this,Se).failed;var a=!1,i=!1;const u=()=>{if(a){_o();return}a=!0,i&&io(),c(this,me)!==null&&Tt(c(this,me),()=>{D(this,me,null)}),U(this,G,Os).call(this,()=>{U(this,G,vr).call(this)})},d=v=>{try{i=!0,s==null||s(v,u),i=!1}catch(p){ct(p,c(this,ue)&&c(this,ue).parent)}r&&D(this,me,U(this,G,Os).call(this,()=>{try{return Ae(()=>{var p=O;p.b=this,p.f|=or,r(c(this,ke),()=>v,()=>u)})}catch(p){return ct(p,c(this,ue).parent),null}}))};ut(()=>{var v;try{v=this.transform_error(t)}catch(p){ct(p,c(this,ue)&&c(this,ue).parent);return}v!==null&&typeof v=="object"&&typeof v.then=="function"?v.then(d,p=>ct(p,c(this,ue)&&c(this,ue).parent)):d(v)})};function Do(e,t,s,r){const a=ys()?Tr:Ma;var i=e.filter(w=>!w.settled);if(s.length===0&&i.length===0){r(t.map(a));return}var u=O,d=Oo(),v=i.length===1?i[0].promise:i.length>1?Promise.all(i.map(w=>w.promise)):null;function p(w){d();try{r(w)}catch(y){u.f&Ce||ct(y,u)}Ls()}if(s.length===0){v.then(()=>p(t.map(a)));return}var g=Na();function E(){Promise.all(s.map(w=>Io(w))).then(w=>p([...t.map(a),...w])).catch(w=>ct(w,u)).finally(()=>g())}v?v.then(()=>{d(),E(),Ls()}):E()}function Oo(){var e=O,t=I,s=z,r=S;return function(i=!0){De(e),Me(t),Bt(s),i&&!(e.f&Ce)&&(r==null||r.activate(),r==null||r.apply())}}function Ls(e=!0){De(null),Me(null),Bt(null),e&&(S==null||S.deactivate())}function Na(){var e=O,t=e.b,s=S,r=t.is_rendered();return t.update_pending_count(1,s),s.increment(r,e),(a=!1)=>{t.update_pending_count(-1,s),s.decrement(r,e,a)}}function Tr(e){var t=le|re;return O!==null&&(O.f|=Yt),{ctx:z,deps:null,effects:null,equals:ba,f:t,fn:e,reactions:null,rv:0,v:ee,wv:0,parent:O,ac:null}}function Io(e,t,s){let r=O;r===null&&Ql();var a=void 0,i=Nt(ee),u=!I,d=new Map;return Go(()=>{var y;var v=O,p=va();a=p.promise;try{Promise.resolve(e()).then(p.resolve,p.reject).finally(Ls)}catch(o){p.reject(o),Ls()}var g=S;if(u){if(v.f&Dt)var E=Na();if(r.b.is_rendered())(y=d.get(g))==null||y.reject(Xe),d.delete(g);else{for(const o of d.values())o.reject(Xe);d.clear()}d.set(g,p)}const w=(o,T=void 0)=>{if(E){var m=T===Xe;E(m)}if(!(T===Xe||v.f&Ce)){if(g.activate(),T)i.f|=ft,Kt(i,T);else{i.f&ft&&(i.f^=ft),Kt(i,o);for(const[R,$]of d){if(d.delete(R),R===g)break;$.reject(Xe)}}g.deactivate()}};p.promise.then(w,o=>w(null,o||"unknown"))}),Nr(()=>{for(const v of d.values())v.reject(Xe)}),new Promise(v=>{function p(g){function E(){g===a?v(i):p(a)}g.then(E,E)}p(a)})}function Ma(e){const t=Tr(e);return t.equals=ma,t}function Fo(e){var t=e.effects;if(t!==null){e.effects=null;for(var s=0;s<t.length;s+=1)de(t[s])}}function Ar(e){var t,s=O,r=e.parent;if(!dt&&r!==null&&r.f&(Ce|ce))return vo(),e.v;De(r);try{e.f&=~Rt,Fo(e),t=Ja(e)}finally{De(s)}return t}function Da(e){var t=Ar(e);if(!e.equals(t)&&(e.wv=Ya(),(!(S!=null&&S.is_fork)||e.deps===null)&&(S!==null?S.capture(e,t,!0):e.v=t,e.deps===null))){Y(e,X);return}dt||(se!==null?(Cr()||S!=null&&S.is_fork)&&se.set(e,t):xr(e))}function Lo(e){var t,s;if(e.effects!==null)for(const r of e.effects)(r.teardown||r.ac)&&((t=r.teardown)==null||t.call(r),(s=r.ac)==null||s.abort(Xe),r.teardown=Yl,r.ac=null,us(r,0),Dr(r))}function Oa(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&Mt(t)}let _r=new Set;const St=new Map;let Ia=!1;function Nt(e,t){var s={f:0,v:e,reactions:null,equals:ba,rv:0,wv:0};return s}function at(e,t){const s=Nt(e);return Xo(s),s}function Q(e,t=!1,s=!0){var a;const r=Nt(e);return t||(r.equals=ma),ms&&s&&z!==null&&z.l!==null&&((a=z.l).s??(a.s=[])).push(r),r}function ts(e,t){return M(e,b(()=>n(e))),t}function M(e,t,s=!1){I!==null&&(!je||I.f&cr)&&ys()&&I.f&(le|Be|fs|cr)&&(Ne===null||!Vt.call(Ne,e))&&ao();let r=s?ns(t):t;return Kt(e,r,Rs)}function Kt(e,t,s=null){if(!e.equals(t)){St.set(e,dt?t:e.v);var r=Ct.ensure();if(r.capture(e,t),e.f&le){const a=e;e.f&re&&Ar(a),se===null&&xr(a)}e.wv=Ya(),Fa(e,re,s),ys()&&O!==null&&O.f&X&&!(O.f&($e|vt))&&(xe===null?Zo([e]):xe.push(e)),!r.is_fork&&_r.size>0&&!Ia&&Po()}return t}function Po(){Ia=!1;for(const e of _r)e.f&X&&Y(e,We),Gt(e)&&Mt(e);_r.clear()}function os(e){M(e,e.v+1)}function Fa(e,t,s){var r=e.reactions;if(r!==null)for(var a=ys(),i=r.length,u=0;u<i;u++){var d=r[u],v=d.f;if(!(!a&&d===O)){var p=(v&re)===0;if(p&&Y(d,t),v&le){var g=d;se==null||se.delete(g),v&Rt||(v&Re&&(O===null||!(O.f&Fs))&&(d.f|=Rt),Fa(g,We,s))}else if(p){var E=d;v&Be&&Le!==null&&Le.add(E),s!==null?s.push(E):Sr(E)}}}}function ns(e){if(typeof e!="object"||e===null||kt in e)return e;const t=Er(e);if(t!==Bl&&t!==Kl)return e;var s=new Map,r=wr(e),a=at(0),i=At,u=d=>{if(At===i)return d();var v=I,p=At;Me(null),Zn(i);var g=d();return Me(v),Zn(p),g};return r&&s.set("length",at(e.length)),new Proxy(e,{defineProperty(d,v,p){(!("value"in p)||p.configurable===!1||p.enumerable===!1||p.writable===!1)&&ro();var g=s.get(v);return g===void 0?u(()=>{var E=at(p.value);return s.set(v,E),E}):M(g,p.value,!0),!0},deleteProperty(d,v){var p=s.get(v);if(p===void 0){if(v in d){const g=u(()=>at(ee));s.set(v,g),os(a)}}else M(p,ee),os(a);return!0},get(d,v,p){var y;if(v===kt)return e;var g=s.get(v),E=v in d;if(g===void 0&&(!E||(y=is(d,v))!=null&&y.writable)&&(g=u(()=>{var o=ns(E?d[v]:ee),T=at(o);return T}),s.set(v,g)),g!==void 0){var w=n(g);return w===ee?void 0:w}return Reflect.get(d,v,p)},getOwnPropertyDescriptor(d,v){var p=Reflect.getOwnPropertyDescriptor(d,v);if(p&&"value"in p){var g=s.get(v);g&&(p.value=n(g))}else if(p===void 0){var E=s.get(v),w=E==null?void 0:E.v;if(E!==void 0&&w!==ee)return{enumerable:!0,configurable:!0,value:w,writable:!0}}return p},has(d,v){var w;if(v===kt)return!0;var p=s.get(v),g=p!==void 0&&p.v!==ee||Reflect.has(d,v);if(p!==void 0||O!==null&&(!g||(w=is(d,v))!=null&&w.writable)){p===void 0&&(p=u(()=>{var y=g?ns(d[v]):ee,o=at(y);return o}),s.set(v,p));var E=n(p);if(E===ee)return!1}return g},set(d,v,p,g){var L;var E=s.get(v),w=v in d;if(r&&v==="length")for(var y=p;y<E.v;y+=1){var o=s.get(y+"");o!==void 0?M(o,ee):y in d&&(o=u(()=>at(ee)),s.set(y+"",o))}if(E===void 0)(!w||(L=is(d,v))!=null&&L.writable)&&(E=u(()=>at(void 0)),M(E,ns(p)),s.set(v,E));else{w=E.v!==ee;var T=u(()=>ns(p));M(E,T)}var m=Reflect.getOwnPropertyDescriptor(d,v);if(m!=null&&m.set&&m.set.call(g,p),!w){if(r&&typeof v=="string"){var R=s.get("length"),$=Number(v);Number.isInteger($)&&$>=R.v&&M(R,$+1)}os(a)}return!0},ownKeys(d){n(a);var v=Reflect.ownKeys(d).filter(E=>{var w=s.get(E);return w===void 0||w.v!==ee});for(var[p,g]of s)g.v!==ee&&!(p in d)&&v.push(p);return v},setPrototypeOf(){no()}})}function Gn(e){try{if(e!==null&&typeof e=="object"&&kt in e)return e[kt]}catch{}return e}function jo(e,t){return Object.is(Gn(e),Gn(t))}var Jn,La,Pa,ja;function $o(){if(Jn===void 0){Jn=window,La=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,s=Text.prototype;Pa=is(t,"firstChild").get,ja=is(t,"nextSibling").get,Hn(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Hn(s)&&(s.__t=void 0)}}function rt(e=""){return document.createTextNode(e)}function Rr(e){return Pa.call(e)}function ws(e){return ja.call(e)}function _(e,t){return Rr(e)}function Wo(e,t=!1){{var s=Rr(e);return s instanceof Comment&&s.data===""?ws(s):s}}function h(e,t=1,s=!1){let r=e;for(;t--;)r=ws(r);return r}function qo(e){e.textContent=""}function $a(){return!1}function Uo(e,t,s){return document.createElementNS(ga,e,void 0)}let Qn=!1;function Vo(){Qn||(Qn=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const s of e.target.elements)(t=s.__on_r)==null||t.call(s)})},{capture:!0}))}function qs(e){var t=I,s=O;Me(null),De(null);try{return e()}finally{Me(t),De(s)}}function Wa(e,t,s,r=s){e.addEventListener(t,()=>qs(s));const a=e.__on_r;a?e.__on_r=()=>{a(),r(!0)}:e.__on_r=()=>r(!0),Vo()}function qa(e){O===null&&(I===null&&to(),eo()),dt&&Zl()}function zo(e,t){var s=t.last;s===null?t.last=t.first=e:(s.next=e,e.prev=s,t.last=e)}function Ke(e,t){var s=O;s!==null&&s.f&ce&&(e|=ce);var r={ctx:z,deps:null,nodes:null,f:e|re|Re,first:null,fn:t,last:null,next:null,parent:s,b:s&&s.b,prev:null,teardown:null,wv:0,ac:null};S==null||S.register_created_effect(r);var a=r;if(e&zt)Pt!==null?Pt.push(r):Ct.ensure().schedule(r);else if(t!==null){try{Mt(r)}catch(u){throw de(r),u}a.deps===null&&a.teardown===null&&a.nodes===null&&a.first===a.last&&!(a.f&Yt)&&(a=a.first,e&Be&&e&Ht&&a!==null&&(a.f|=Ht))}if(a!==null&&(a.parent=s,s!==null&&zo(a,s),I!==null&&I.f&le&&!(e&vt))){var i=I;(i.effects??(i.effects=[])).push(a)}return r}function Cr(){return I!==null&&!je}function Nr(e){const t=Ke(bs,null);return Y(t,X),t.teardown=e,t}function hr(e){qa();var t=O.f,s=!I&&(t&$e)!==0&&(t&Dt)===0;if(s){var r=z;(r.e??(r.e=[])).push(e)}else return Ua(e)}function Ua(e){return Ke(zt|pa,e)}function Ho(e){return qa(),Ke(bs|pa,e)}function Bo(e){Ct.ensure();const t=Ke(vt|Yt,e);return(s={})=>new Promise(r=>{s.outro?Tt(t,()=>{de(t),r(void 0)}):(de(t),r(void 0))})}function Ko(e){return Ke(zt,e)}function Ee(e,t){var s=z,r={effect:null,ran:!1,deps:e};s.l.$.push(r),r.effect=Us(()=>{if(e(),!r.ran){r.ran=!0;var a=O;try{De(a.parent),b(t)}finally{De(a)}}})}function Yo(){var e=z;Us(()=>{for(var t of e.l.$){t.deps();var s=t.effect;s.f&X&&s.deps!==null&&Y(s,We),Gt(s)&&Mt(s),t.ran=!1}})}function Go(e){return Ke(fs|Yt,e)}function Us(e,t=0){return Ke(bs|t,e)}function V(e,t=[],s=[],r=[]){Do(r,t,s,a=>{Ke(bs,()=>e(...a.map(n)))})}function Mr(e,t=0){var s=Ke(Be|t,e);return s}function Ae(e){return Ke($e|Yt,e)}function Va(e){var t=e.teardown;if(t!==null){const s=dt,r=I;Xn(!0),Me(null);try{t.call(null)}finally{Xn(s),Me(r)}}}function Dr(e,t=!1){var s=e.first;for(e.first=e.last=null;s!==null;){const a=s.ac;a!==null&&qs(()=>{a.abort(Xe)});var r=s.next;s.f&vt?s.parent=null:de(s,t),s=r}}function Jo(e){for(var t=e.first;t!==null;){var s=t.next;t.f&$e||de(t),t=s}}function de(e,t=!0){var s=!1;(t||e.f&Jl)&&e.nodes!==null&&e.nodes.end!==null&&(Qo(e.nodes.start,e.nodes.end),s=!0),Y(e,Bn),Dr(e,t&&!s),us(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(const i of r)i.stop();Va(e),e.f^=Bn,e.f|=Ce;var a=e.parent;a!==null&&a.first!==null&&za(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Qo(e,t){for(;e!==null;){var s=e===t?null:ws(e);e.remove(),e=s}}function za(e){var t=e.parent,s=e.prev,r=e.next;s!==null&&(s.next=r),r!==null&&(r.prev=s),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=s))}function Tt(e,t,s=!0){var r=[];Ha(e,r,!0);var a=()=>{s&&de(e),t&&t()},i=r.length;if(i>0){var u=()=>--i||a();for(var d of r)d.out(u)}else a()}function Ha(e,t,s){if(!(e.f&ce)){e.f^=ce;var r=e.nodes&&e.nodes.t;if(r!==null)for(const d of r)(d.is_global||s)&&t.push(d);for(var a=e.first;a!==null;){var i=a.next;if(!(a.f&vt)){var u=(a.f&Ht)!==0||(a.f&$e)!==0&&(e.f&Be)!==0;Ha(a,t,u?s:!1)}a=i}}}function Or(e){Ba(e,!0)}function Ba(e,t){if(e.f&ce){e.f^=ce,e.f&X||(Y(e,re),Ct.ensure().schedule(e));for(var s=e.first;s!==null;){var r=s.next,a=(s.f&Ht)!==0||(s.f&$e)!==0;Ba(s,a?t:!1),s=r}var i=e.nodes&&e.nodes.t;if(i!==null)for(const u of i)(u.is_global||t)&&u.in()}}function Ir(e,t){if(e.nodes)for(var s=e.nodes.start,r=e.nodes.end;s!==null;){var a=s===r?null:ws(s);t.append(s),s=a}}let Is=!1,dt=!1;function Xn(e){dt=e}let I=null,je=!1;function Me(e){I=e}let O=null;function De(e){O=e}let Ne=null;function Xo(e){I!==null&&(Ne===null?Ne=[e]:Ne.push(e))}let ve=null,ge=0,xe=null;function Zo(e){xe=e}let Ka=1,bt=0,At=bt;function Zn(e){At=e}function Ya(){return++Ka}function Gt(e){var t=e.f;if(t&re)return!0;if(t&le&&(e.f&=~Rt),t&We){for(var s=e.deps,r=s.length,a=0;a<r;a++){var i=s[a];if(Gt(i)&&Da(i),i.wv>e.wv)return!0}t&Re&&se===null&&Y(e,X)}return!1}function Ga(e,t,s=!0){var r=e.reactions;if(r!==null&&!(Ne!==null&&Vt.call(Ne,e)))for(var a=0;a<r.length;a++){var i=r[a];i.f&le?Ga(i,t,!1):t===i&&(s?Y(i,re):i.f&X&&Y(i,We),Sr(i))}}function Ja(e){var T;var t=ve,s=ge,r=xe,a=I,i=Ne,u=z,d=je,v=At,p=e.f;ve=null,ge=0,xe=null,I=p&($e|vt)?null:e,Ne=null,Bt(e.ctx),je=!1,At=++bt,e.ac!==null&&(qs(()=>{e.ac.abort(Xe)}),e.ac=null);try{e.f|=Fs;var g=e.fn,E=g();e.f|=Dt;var w=e.deps,y=S==null?void 0:S.is_fork;if(ve!==null){var o;if(y||us(e,ge),w!==null&&ge>0)for(w.length=ge+ve.length,o=0;o<ve.length;o++)w[ge+o]=ve[o];else e.deps=w=ve;if(Cr()&&e.f&Re)for(o=ge;o<w.length;o++)((T=w[o]).reactions??(T.reactions=[])).push(e)}else!y&&w!==null&&ge<w.length&&(us(e,ge),w.length=ge);if(ys()&&xe!==null&&!je&&w!==null&&!(e.f&(le|We|re)))for(o=0;o<xe.length;o++)Ga(xe[o],e);if(a!==null&&a!==e){if(bt++,a.deps!==null)for(let m=0;m<s;m+=1)a.deps[m].rv=bt;if(t!==null)for(const m of t)m.rv=bt;xe!==null&&(r===null?r=xe:r.push(...xe))}return e.f&ft&&(e.f^=ft),E}catch(m){return xa(m)}finally{e.f^=Fs,ve=t,ge=s,xe=r,I=a,Ne=i,Bt(u),je=d,At=v}}function ec(e,t){let s=t.reactions;if(s!==null){var r=zl.call(s,e);if(r!==-1){var a=s.length-1;a===0?s=t.reactions=null:(s[r]=s[a],s.pop())}}if(s===null&&t.f&le&&(ve===null||!Vt.call(ve,t))){var i=t;i.f&Re&&(i.f^=Re,i.f&=~Rt),i.v!==ee&&xr(i),Lo(i),us(i,0)}}function us(e,t){var s=e.deps;if(s!==null)for(var r=t;r<s.length;r++)ec(e,s[r])}function Mt(e){var t=e.f;if(!(t&Ce)){Y(e,X);var s=O,r=Is;O=e,Is=!0;try{t&(Be|da)?Jo(e):Dr(e),Va(e);var a=Ja(e);e.teardown=typeof a=="function"?a:null,e.wv=Ka;var i;Vl&&go&&e.f&re&&e.deps}finally{Is=r,O=s}}}async function tc(){await Promise.resolve(),xo()}function n(e){var t=e.f,s=(t&le)!==0;if(I!==null&&!je){var r=O!==null&&(O.f&Ce)!==0;if(!r&&(Ne===null||!Vt.call(Ne,e))){var a=I.deps;if(I.f&Fs)e.rv<bt&&(e.rv=bt,ve===null&&a!==null&&a[ge]===e?ge++:ve===null?ve=[e]:ve.push(e));else{(I.deps??(I.deps=[])).push(e);var i=e.reactions;i===null?e.reactions=[I]:Vt.call(i,I)||i.push(I)}}}if(dt&&St.has(e))return St.get(e);if(s){var u=e;if(dt){var d=u.v;return(!(u.f&X)&&u.reactions!==null||Xa(u))&&(d=Ar(u)),St.set(u,d),d}var v=(u.f&Re)===0&&!je&&I!==null&&(Is||(I.f&Re)!==0),p=(u.f&Dt)===0;Gt(u)&&(v&&(u.f|=Re),Da(u)),v&&!p&&(Oa(u),Qa(u))}if(se!=null&&se.has(e))return se.get(e);if(e.f&ft)throw e.v;return e.v}function Qa(e){if(e.f|=Re,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),t.f&le&&!(t.f&Re)&&(Oa(t),Qa(t))}function Xa(e){if(e.v===ee)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(St.has(t)||t.f&le&&Xa(t))return!0;return!1}function b(e){var t=je;try{return je=!0,e()}finally{je=t}}function sc(e){if(!(typeof e!="object"||!e||e instanceof EventTarget)){if(kt in e)gr(e);else if(!Array.isArray(e))for(let t in e){const s=e[t];typeof s=="object"&&s&&kt in s&&gr(s)}}}function gr(e,t=new Set){if(typeof e=="object"&&e!==null&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let r in e)try{gr(e[r],t)}catch{}const s=Er(e);if(s!==Object.prototype&&s!==Array.prototype&&s!==Map.prototype&&s!==Set.prototype&&s!==Date.prototype){const r=ua(s);for(let a in r){const i=r[a].get;if(i)try{i.call(e)}catch{}}}}}const rc=["touchstart","touchmove"];function nc(e){return rc.includes(e)}const Ss=Symbol("events"),ac=new Set,ea=new Set;function ic(e,t,s,r={}){function a(i){if(r.capture||br.call(t,i),!i.cancelBubble)return qs(()=>s==null?void 0:s.call(this,i))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?ut(()=>{t.addEventListener(e,a,r)}):t.addEventListener(e,a,r),a}function ta(e,t,s,r,a){var i={capture:r,passive:a},u=ic(e,t,s,i);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Nr(()=>{t.removeEventListener(e,u,i)})}let sa=null;function br(e){var m,R;var t=this,s=t.ownerDocument,r=e.type,a=((m=e.composedPath)==null?void 0:m.call(e))||[],i=a[0]||e.target;sa=e;var u=0,d=sa===e&&e[Ss];if(d){var v=a.indexOf(d);if(v!==-1&&(t===document||t===window)){e[Ss]=t;return}var p=a.indexOf(t);if(p===-1)return;v<=p&&(u=v)}if(i=a[u]||e.target,i!==t){Hl(e,"currentTarget",{configurable:!0,get(){return i||s}});var g=I,E=O;Me(null),De(null);try{for(var w,y=[];i!==null;){var o=i.assignedSlot||i.parentNode||i.host||null;try{var T=(R=i[Ss])==null?void 0:R[r];T!=null&&(!i.disabled||e.target===i)&&T.call(i,e)}catch($){w?y.push($):w=$}if(e.cancelBubble||o===t||o===null)break;i=o}if(w){for(let $ of y)queueMicrotask(()=>{throw $});throw w}}finally{e[Ss]=t,delete e.currentTarget,Me(g),De(E)}}}var ca;const rr=((ca=globalThis==null?void 0:globalThis.window)==null?void 0:ca.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function lc(e){return(rr==null?void 0:rr.createHTML(e))??e}function oc(e){var t=Uo("template");return t.innerHTML=lc(e.replaceAll("<!>","<!---->")),t.content}function Fr(e,t){var s=O;s.nodes===null&&(s.nodes={start:e,end:t,a:null,t:null})}function W(e,t){var s=(t&uo)!==0,r,a=!e.startsWith("<!>");return()=>{r===void 0&&(r=oc(a?e:"<!>"+e),r=Rr(r));var i=s||La?document.importNode(r,!0):r.cloneNode(!0);return Fr(i,i),i}}function ra(e=""){{var t=rt(e+"");return Fr(t,t),t}}function cc(){var e=document.createDocumentFragment(),t=document.createComment(""),s=rt();return e.append(t,s),Fr(t,s),e}function P(e,t){e!==null&&e.before(t)}function x(e,t){var s=t==null?"":typeof t=="object"?`${t}`:t;s!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=s,e.nodeValue=`${s}`)}function fc(e,t){return uc(e,t)}const Ts=new Map;function uc(e,{target:t,anchor:s,props:r={},events:a,context:i,intro:u=!0,transformError:d}){$o();var v=void 0,p=Bo(()=>{var g=s??t.appendChild(rt());Ao(g,{pending:()=>{}},y=>{ya({});var o=z;i&&(o.c=i),a&&(r.$$events=a),v=e(y,r)||{},wa()},d);var E=new Set,w=y=>{for(var o=0;o<y.length;o++){var T=y[o];if(!E.has(T)){E.add(T);var m=nc(T);for(const L of[t,document]){var R=Ts.get(L);R===void 0&&(R=new Map,Ts.set(L,R));var $=R.get(T);$===void 0?(L.addEventListener(T,br,{passive:m}),R.set(T,1)):R.set(T,$+1)}}}};return w(Ws(ac)),ea.add(w),()=>{var m;for(var y of E)for(const R of[t,document]){var o=Ts.get(R),T=o.get(y);--T==0?(R.removeEventListener(y,br),o.delete(y),o.size===0&&Ts.delete(R)):o.set(y,T)}ea.delete(w),g!==s&&((m=g.parentNode)==null||m.removeChild(g))}});return vc.set(v,p),v}let vc=new WeakMap;var Pe,ze,ye,xt,hs,gs,$s;class dc{constructor(t,s=!0){Fe(this,"anchor");N(this,Pe,new Map);N(this,ze,new Map);N(this,ye,new Map);N(this,xt,new Set);N(this,hs,!0);N(this,gs,t=>{if(c(this,Pe).has(t)){var s=c(this,Pe).get(t),r=c(this,ze).get(s);if(r)Or(r),c(this,xt).delete(s);else{var a=c(this,ye).get(s);a&&(c(this,ze).set(s,a.effect),c(this,ye).delete(s),a.fragment.lastChild.remove(),this.anchor.before(a.fragment),r=a.effect)}for(const[i,u]of c(this,Pe)){if(c(this,Pe).delete(i),i===t)break;const d=c(this,ye).get(u);d&&(de(d.effect),c(this,ye).delete(u))}for(const[i,u]of c(this,ze)){if(i===s||c(this,xt).has(i))continue;const d=()=>{if(Array.from(c(this,Pe).values()).includes(i)){var p=document.createDocumentFragment();Ir(u,p),p.append(rt()),c(this,ye).set(i,{effect:u,fragment:p})}else de(u);c(this,xt).delete(i),c(this,ze).delete(i)};c(this,hs)||!r?(c(this,xt).add(i),Tt(u,d,!1)):d()}}});N(this,$s,t=>{c(this,Pe).delete(t);const s=Array.from(c(this,Pe).values());for(const[r,a]of c(this,ye))s.includes(r)||(de(a.effect),c(this,ye).delete(r))});this.anchor=t,D(this,hs,s)}ensure(t,s){var r=S,a=$a();if(s&&!c(this,ze).has(t)&&!c(this,ye).has(t))if(a){var i=document.createDocumentFragment(),u=rt();i.append(u),c(this,ye).set(t,{effect:Ae(()=>s(u)),fragment:i})}else c(this,ze).set(t,Ae(()=>s(this.anchor)));if(c(this,Pe).set(r,t),a){for(const[d,v]of c(this,ze))d===t?r.unskip_effect(v):r.skip_effect(v);for(const[d,v]of c(this,ye))d===t?r.unskip_effect(v.effect):r.skip_effect(v.effect);r.oncommit(c(this,gs)),r.ondiscard(c(this,$s))}else c(this,gs).call(this,r)}}Pe=new WeakMap,ze=new WeakMap,ye=new WeakMap,xt=new WeakMap,hs=new WeakMap,gs=new WeakMap,$s=new WeakMap;function fe(e,t,s=!1){var r=new dc(e),a=s?Ht:0;function i(u,d){r.ensure(u,d)}Mr(()=>{var u=!1;t((d,v=0)=>{u=!0,i(v,d)}),u||i(-1,null)},a)}function pc(e,t,s){for(var r=[],a=t.length,i,u=t.length,d=0;d<a;d++){let E=t[d];Tt(E,()=>{if(i){if(i.pending.delete(E),i.done.add(E),i.pending.size===0){var w=e.outrogroups;mr(e,Ws(i.done)),w.delete(i),w.size===0&&(e.outrogroups=null)}}else u-=1},!1)}if(u===0){var v=r.length===0&&s!==null;if(v){var p=s,g=p.parentNode;qo(g),g.append(p),e.items.clear()}mr(e,t,!v)}else i={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(i)}function mr(e,t,s=!0){var r;if(e.pending.size>0){r=new Set;for(const u of e.pending.values())for(const d of u)r.add(e.items.get(d).e)}for(var a=0;a<t.length;a++){var i=t[a];if(r!=null&&r.has(i)){i.f|=He;const u=document.createDocumentFragment();Ir(i,u)}else de(t[a],s)}}var na;function Lt(e,t,s,r,a,i=null){var u=e,d=new Map,v=(t&ha)!==0;if(v){var p=e;u=p.appendChild(rt())}var g=null,E=Ma(()=>{var L=s();return wr(L)?L:L==null?[]:Ws(L)}),w,y=new Map,o=!0;function T(L){$.effect.f&Ce||($.pending.delete(L),$.fallback=g,_c($,w,u,t,r),g!==null&&(w.length===0?g.f&He?(g.f^=He,as(g,null,u)):Or(g):Tt(g,()=>{g=null})))}function m(L){$.pending.delete(L)}var R=Mr(()=>{w=n(E);for(var L=w.length,J=new Set,ne=S,qe=$a(),F=0;F<L;F+=1){var Ye=w[F],nt=r(Ye,F),ae=o?null:d.get(nt);ae?(ae.v&&Kt(ae.v,Ye),ae.i&&Kt(ae.i,F),qe&&ne.unskip_effect(ae.e)):(ae=hc(d,o?u:na??(na=rt()),Ye,nt,F,a,t,s),o||(ae.e.f|=He),d.set(nt,ae)),J.add(nt)}if(L===0&&i&&!g&&(o?g=Ae(()=>i(u)):(g=Ae(()=>i(na??(na=rt()))),g.f|=He)),L>J.size&&Xl(),!o)if(y.set(ne,J),qe){for(const[pt,Ge]of d)J.has(pt)||ne.skip_effect(Ge.e);ne.oncommit(T),ne.ondiscard(m)}else T(ne);n(E)}),$={effect:R,items:d,pending:y,outrogroups:null,fallback:g};o=!1}function ss(e){for(;e!==null&&!(e.f&$e);)e=e.next;return e}function _c(e,t,s,r,a){var ae,pt,Ge,Es,Jt,Qt,Xt,Zt,xs;var i=(r&co)!==0,u=t.length,d=e.items,v=ss(e.effect.first),p,g=null,E,w=[],y=[],o,T,m,R;if(i)for(R=0;R<u;R+=1)o=t[R],T=a(o,R),m=d.get(T).e,m.f&He||((pt=(ae=m.nodes)==null?void 0:ae.a)==null||pt.measure(),(E??(E=new Set)).add(m));for(R=0;R<u;R+=1){if(o=t[R],T=a(o,R),m=d.get(T).e,e.outrogroups!==null)for(const pe of e.outrogroups)pe.pending.delete(m),pe.done.delete(m);if(m.f&ce&&(Or(m),i&&((Es=(Ge=m.nodes)==null?void 0:Ge.a)==null||Es.unfix(),(E??(E=new Set)).delete(m))),m.f&He)if(m.f^=He,m===v)as(m,null,s);else{var $=g?g.next:v;m===e.effect.last&&(e.effect.last=m.prev),m.prev&&(m.prev.next=m.next),m.next&&(m.next.prev=m.prev),it(e,g,m),it(e,m,$),as(m,$,s),g=m,w=[],y=[],v=ss(g.next);continue}if(m!==v){if(p!==void 0&&p.has(m)){if(w.length<y.length){var L=y[0],J;g=L.prev;var ne=w[0],qe=w[w.length-1];for(J=0;J<w.length;J+=1)as(w[J],L,s);for(J=0;J<y.length;J+=1)p.delete(y[J]);it(e,ne.prev,qe.next),it(e,g,ne),it(e,qe,L),v=L,g=qe,R-=1,w=[],y=[]}else p.delete(m),as(m,v,s),it(e,m.prev,m.next),it(e,m,g===null?e.effect.first:g.next),it(e,g,m),g=m;continue}for(w=[],y=[];v!==null&&v!==m;)(p??(p=new Set)).add(v),y.push(v),v=ss(v.next);if(v===null)continue}m.f&He||w.push(m),g=m,v=ss(m.next)}if(e.outrogroups!==null){for(const pe of e.outrogroups)pe.pending.size===0&&(mr(e,Ws(pe.done)),(Jt=e.outrogroups)==null||Jt.delete(pe));e.outrogroups.size===0&&(e.outrogroups=null)}if(v!==null||p!==void 0){var F=[];if(p!==void 0)for(m of p)m.f&ce||F.push(m);for(;v!==null;)!(v.f&ce)&&v!==e.fallback&&F.push(v),v=ss(v.next);var Ye=F.length;if(Ye>0){var nt=r&ha&&u===0?s:null;if(i){for(R=0;R<Ye;R+=1)(Xt=(Qt=F[R].nodes)==null?void 0:Qt.a)==null||Xt.measure();for(R=0;R<Ye;R+=1)(xs=(Zt=F[R].nodes)==null?void 0:Zt.a)==null||xs.fix()}pc(e,F,nt)}}i&&ut(()=>{var pe,ks;if(E!==void 0)for(m of E)(ks=(pe=m.nodes)==null?void 0:pe.a)==null||ks.apply()})}function hc(e,t,s,r,a,i,u,d){var v=u&lo?u&fo?Nt(s):Q(s,!1,!1):null,p=u&oo?Nt(a):null;return{v,i:p,e:Ae(()=>(i(t,v??s,p??a,d),()=>{e.delete(r)}))}}function as(e,t,s){if(e.nodes)for(var r=e.nodes.start,a=e.nodes.end,i=t&&!(t.f&He)?t.nodes.start:s;r!==null;){var u=ws(r);if(i.before(r),r===a)return;r=u}}function it(e,t,s){t===null?e.effect.first=s:t.next=s,s===null?e.effect.last=t:s.prev=t}const aa=[...`
2
+ \r\f \v\uFEFF`];function gc(e,t,s){var r=e==null?"":""+e;if(s){for(var a of Object.keys(s))if(s[a])r=r?r+" "+a:a;else if(r.length)for(var i=a.length,u=0;(u=r.indexOf(a,u))>=0;){var d=u+i;(u===0||aa.includes(r[u-1]))&&(d===r.length||aa.includes(r[d]))?r=(u===0?"":r.substring(0,u))+r.substring(d+1):u=d}}return r===""?null:r}function bc(e,t){return e==null?null:String(e)}function rs(e,t,s,r,a,i){var u=e.__className;if(u!==s||u===void 0){var d=gc(s,r,i);d==null?e.removeAttribute("class"):e.className=d,e.__className=s}else if(i&&a!==i)for(var v in i){var p=!!i[v];(a==null||p!==!!a[v])&&e.classList.toggle(v,p)}return i}function ia(e,t,s,r){var a=e.__style;if(a!==t){var i=bc(t);i==null?e.removeAttribute("style"):e.style.cssText=i,e.__style=t}return r}function Za(e,t,s=!1){if(e.multiple){if(t==null)return;if(!wr(t))return po();for(var r of e.options)r.selected=t.includes(cs(r));return}for(r of e.options){var a=cs(r);if(jo(a,t)){r.selected=!0;return}}(!s||t!==void 0)&&(e.selectedIndex=-1)}function mc(e){var t=new MutationObserver(()=>{Za(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Nr(()=>{t.disconnect()})}function nr(e,t,s=t){var r=new WeakSet,a=!0;Wa(e,"change",i=>{var u=i?"[selected]":":checked",d;if(e.multiple)d=[].map.call(e.querySelectorAll(u),cs);else{var v=e.querySelector(u)??e.querySelector("option:not([disabled])");d=v&&cs(v)}s(d),e.__value=d,S!==null&&r.add(S)}),Ko(()=>{var i=t();if(e===document.activeElement){var u=S;if(r.has(u))return}if(Za(e,i,a),a&&i===void 0){var d=e.querySelector(":checked");d!==null&&(i=cs(d),s(i))}e.__value=i,a=!1}),mc(e)}function cs(e){return"__value"in e?e.__value:e.value}const yc=Symbol("is custom element"),wc=Symbol("is html");function Ec(e,t,s,r){var a=xc(e);a[t]!==(a[t]=s)&&(s==null?e.removeAttribute(t):typeof s!="string"&&kc(e).includes(t)?e[t]=s:e.setAttribute(t,s))}function xc(e){return e.__attributes??(e.__attributes={[yc]:e.nodeName.includes("-"),[wc]:e.namespaceURI===ga})}var la=new Map;function kc(e){var t=e.getAttribute("is")||e.nodeName,s=la.get(t);if(s)return s;la.set(t,s=[]);for(var r,a=e,i=Element.prototype;i!==a;){r=ua(a);for(var u in r)r[u].set&&s.push(u);a=Er(a)}return s}function As(e,t,s=t){var r=new WeakSet;Wa(e,"input",async a=>{var i=a?e.defaultValue:e.value;if(i=ar(e)?ir(i):i,s(i),S!==null&&r.add(S),await tc(),i!==(i=t())){var u=e.selectionStart,d=e.selectionEnd,v=e.value.length;if(e.value=i??"",d!==null){var p=e.value.length;u===d&&d===v&&p>v?(e.selectionStart=p,e.selectionEnd=p):(e.selectionStart=u,e.selectionEnd=Math.min(d,p))}}}),b(t)==null&&e.value&&(s(ar(e)?ir(e.value):e.value),S!==null&&r.add(S)),Us(()=>{var a=t();if(e===document.activeElement){var i=S;if(r.has(i))return}ar(e)&&a===ir(e.value)||e.type==="date"&&!a&&!e.value||a!==e.value&&(e.value=a??"")})}function ar(e){var t=e.type;return t==="number"||t==="range"}function ir(e){return e===""?null:+e}function Sc(e){return function(...t){var s=t[0];return s.preventDefault(),e==null?void 0:e.apply(this,t)}}function Tc(e=!1){const t=z,s=t.l.u;if(!s)return;let r=()=>sc(t.s);if(e){let a=0,i={};const u=Tr(()=>{let d=!1;const v=t.s;for(const p in v)v[p]!==i[p]&&(i[p]=v[p],d=!0);return d&&a++,a});r=()=>n(u)}s.b.length&&Ho(()=>{oa(t,r),lr(s.b)}),hr(()=>{const a=b(()=>s.m.map(Gl));return()=>{for(const i of a)typeof i=="function"&&i()}}),s.a.length&&hr(()=>{oa(t,r),lr(s.a)})}function oa(e,t){if(e.l.s)for(const s of e.l.s)n(s);t()}function Ac(e){z===null&&_a(),ms&&z.l!==null?Cc(z).m.push(e):hr(()=>{const t=b(e);if(typeof t=="function")return t})}function Rc(e){z===null&&_a(),Ac(()=>()=>b(e))}function Cc(e){var t=e.l;return t.u??(t.u={a:[],b:[],m:[]})}const Nc="5";var fa;typeof window<"u"&&((fa=window.__svelte??(window.__svelte={})).v??(fa.v=new Set)).add(Nc);bo();var Mc=W('<div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Watch issue</span><strong class="status-warn svelte-d3ct2b"> </strong></div>'),Dc=W('<section class="notice svelte-d3ct2b"> </section>'),Oc=W('<section class="notice danger svelte-d3ct2b"> </section>'),Ic=W('<p class="terminal-line svelte-d3ct2b"><time class="svelte-d3ct2b">--:--:--</time><span class="sys svelte-d3ct2b">SYS</span><strong class="svelte-d3ct2b">Waiting for memory-core watch output...</strong></p>'),Fc=W('<strong class="svelte-d3ct2b"> </strong>'),Lc=W('<strong class="svelte-d3ct2b"> </strong>'),Pc=W('<strong class="svelte-d3ct2b"> </strong>'),jc=W('<strong class="svelte-d3ct2b"> </strong>'),$c=W('<strong class="svelte-d3ct2b"> </strong>'),Wc=W('<p class="svelte-d3ct2b"><b class="svelte-d3ct2b">Why:</b> </p>'),qc=W('<p class="svelte-d3ct2b"><b class="svelte-d3ct2b">Issue:</b> </p>'),Uc=W('<p class="svelte-d3ct2b"><b class="svelte-d3ct2b">Fix:</b> </p>'),Vc=W('<pre class="svelte-d3ct2b"> </pre>'),zc=W('<div class="terminal-detail svelte-d3ct2b"><p class="svelte-d3ct2b"> </p> <p class="svelte-d3ct2b"><b class="svelte-d3ct2b">Rule:</b> </p> <!> <!> <!> <!></div>'),Hc=W('<section><p class="terminal-line svelte-d3ct2b"><time class="svelte-d3ct2b"> </time> <span class="svelte-d3ct2b"> </span> <!></p> <!></section>'),Bc=W('<div class="metric-row svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b"> </span> <strong class="svelte-d3ct2b"> </strong></div> <i class="svelte-d3ct2b"></i></div>'),Kc=W('<p class="empty svelte-d3ct2b">No rule counters yet.</p>'),Yc=W('<div class="metric-row warning svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b"> </span> <strong class="svelte-d3ct2b"> </strong></div> <i class="svelte-d3ct2b"></i></div>'),Gc=W('<p class="empty svelte-d3ct2b">No file counters yet.</p>'),Jc=W('<small class="svelte-d3ct2b"> </small>'),Qc=W('<small class="svelte-d3ct2b"> </small>'),Xc=W('<section class="commit-item svelte-d3ct2b"><div class="commit-meta svelte-d3ct2b"><span> </span> <time> </time></div> <strong class="svelte-d3ct2b"> </strong> <p class="svelte-d3ct2b"> </p> <!> <!></section>'),Zc=W('<p class="empty svelte-d3ct2b">No commit hook violations recorded yet.</p>'),ef=W('<small class="svelte-d3ct2b"> </small>'),tf=W('<div class="rule-item svelte-d3ct2b"><div><div class="rule-meta svelte-d3ct2b"><span class="svelte-d3ct2b"> </span> <code class="svelte-d3ct2b"> </code></div> <p class="svelte-d3ct2b"> </p> <!></div> <button class="svelte-d3ct2b">Delete</button></div>'),sf=W('<p class="empty svelte-d3ct2b">No rules match the current filters.</p>'),rf=W('<div class="command-center svelte-d3ct2b"><aside class="sidebar svelte-d3ct2b"><div class="brand svelte-d3ct2b"><h1 class="svelte-d3ct2b">memory-core</h1> <span class="svelte-d3ct2b">command center</span></div> <nav aria-label="Dashboard navigation" class="svelte-d3ct2b"><a class="nav-item active svelte-d3ct2b" href="/"><span class="nav-icon svelte-d3ct2b">[]</span> <span>Command Center</span></a></nav> <div class="sidebar-footer svelte-d3ct2b"><div><i class="svelte-d3ct2b"></i> </div> <small class="svelte-d3ct2b"> </small></div></aside> <div class="workspace svelte-d3ct2b"><header class="topbar svelte-d3ct2b"><div class="topbar-left svelte-d3ct2b"><button class="icon-button mobile-menu svelte-d3ct2b" aria-label="Menu">=</button> <div><i class="svelte-d3ct2b"></i> <span> </span></div></div> <div class="header-metrics svelte-d3ct2b" aria-label="Global metrics"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Violations</span> <strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Files</span> <strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Rules</span> <strong class="svelte-d3ct2b"> </strong></div></div> <div class="top-actions svelte-d3ct2b" aria-label="Status shortcuts"><button class="icon-button svelte-d3ct2b" title="Warnings" aria-label="Warnings">!</button> <button class="icon-button svelte-d3ct2b" title="Rules" aria-label="Rules">R</button> <button class="icon-button svelte-d3ct2b" title="Database" aria-label="Database">DB</button> <button class="icon-button svelte-d3ct2b" title="Network" aria-label="Network">LAN</button></div></header> <main class="canvas svelte-d3ct2b"><section class="status-grid svelte-d3ct2b"><article class="glass-panel status-card svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Project</h2> <span class="svelte-d3ct2b"> </span></div> <div class="data-list svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Name</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Type</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Language</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Architecture</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Watcher</span><strong class="svelte-d3ct2b"> </strong></div> <!></div></article> <article class="glass-panel status-card svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Runtime</h2> <span class="svelte-d3ct2b"> </span></div> <div class="data-list svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Provider</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Check model</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Check status</span> <strong><!></strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Embedding</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Ollama URL</span><strong class="svelte-d3ct2b"> </strong></div></div></article> <article class="glass-panel status-card svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">PostgreSQL</h2> <span> </span></div> <div class="data-list svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Database</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">User</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Host</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">URL</span><strong class="svelte-d3ct2b"> </strong></div></div></article></section> <!> <!> <section class="terminal-panel glass-panel svelte-d3ct2b"><div class="terminal-head svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="terminal-icon svelte-d3ct2b">&gt;_</span> <h2 class="svelte-d3ct2b">Live Feed</h2></div> <div class="window-dots svelte-d3ct2b" aria-hidden="true"><i class="svelte-d3ct2b"></i><i class="svelte-d3ct2b"></i><i class="svelte-d3ct2b"></i></div></div> <div class="terminal-body svelte-d3ct2b"><!> <!></div></section> <section class="content-grid svelte-d3ct2b"><article class="glass-panel stats-panel svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Stats</h2> <span class="svelte-d3ct2b">Recorded</span></div> <div class="stat-block svelte-d3ct2b"><h3 class="svelte-d3ct2b">Most Violated Rules</h3> <!></div> <div class="stat-block svelte-d3ct2b"><h3 class="svelte-d3ct2b">Problem Files</h3> <!></div> <div class="summary-strip svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Clean</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Issues</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Events</span><strong class="svelte-d3ct2b"> </strong></div></div></article> <article class="glass-panel commit-watch svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Commit Watch</h2> <span class="svelte-d3ct2b"> </span></div> <div class="commit-list svelte-d3ct2b"></div></article> <article class="glass-panel rule-engine svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Rule Engine</h2> <span class="svelte-d3ct2b"> </span></div> <form class="rule-form svelte-d3ct2b"><div class="control-grid svelte-d3ct2b"><select class="svelte-d3ct2b"><option>Rule</option><option>Decision</option><option>Pattern</option><option>Ignore</option></select> <select class="svelte-d3ct2b"><option>Project</option><option>Global</option></select></div> <textarea rows="3" placeholder="Rule or decision" class="svelte-d3ct2b"></textarea> <div class="control-grid svelte-d3ct2b"><input placeholder="Reason" class="svelte-d3ct2b"/> <input placeholder="Tags" class="svelte-d3ct2b"/></div> <button class="svelte-d3ct2b"> </button></form> <div class="control-grid filters svelte-d3ct2b"><select class="svelte-d3ct2b"><option>All types</option><option>Rules</option><option>Decisions</option><option>Patterns</option><option>Ignores</option></select> <input placeholder="Search rules..." class="svelte-d3ct2b"/></div> <div class="rule-list svelte-d3ct2b"></div></article></section></main></div></div>');function nf(e,t){ya(t,!1);const s=Q(),r=Q(),a=Q(),i=Q(),u=Q(),d=Q(),v=Q(),p=Q(),g=Q(),E=Q(),w=Q(),y=Q();let o=Q({config:null,stats:{rules:{},files:{},topRules:[],topFiles:[]},files:[],memories:[]}),T=Q([]),m=Q(!1),R=Q("all"),$=Q(""),L=Q(!1),J=Q(""),ne,qe=!1,F=Q({type:"rule",scope:"project",content:"",reason:"",tags:"dashboard"});const Ye=()=>{var l;return((l=n(o).runtime)==null?void 0:l.project.name)??"memory-core"},nt=()=>{var A,C;const l=((A=n(o).runtime)==null?void 0:A.project.declaredArchitectures)??[],f=((C=n(o).runtime)==null?void 0:C.project.activeArchitectures)??[];return l.length>0?l.join(", "):f.length>0?f.join(", "):"none"};function ae(l){M(T,[{...l,id:crypto.randomUUID()},...n(T)].slice(0,80))}function pt(l){return l.type==="saved"?{type:"saved",timestamp:l.timestamp,file:l.file}:l.type==="clean"?{type:"clean",timestamp:l.timestamp,file:l.file}:l.type==="skipped"?{type:"skipped",timestamp:l.timestamp,file:l.file,reason:l.reason}:l.type==="violations"?{type:"violations",timestamp:l.timestamp,file:l.file,violations:l.violations}:l.type==="error"?{type:"error",timestamp:l.timestamp,message:l.message}:l.type==="ready"?{type:"system",timestamp:l.timestamp,message:`Watching ${l.path} | ${l.rules} rules | ${l.model}`}:{type:"system",timestamp:l.timestamp,message:"Watch stopped"}}function Ge(l){const f=n(o).files??[],A=f.findIndex(H=>H.file===l.file),C=f.slice();return A===-1?C.push(l):C[A]=l,C.sort((H,ie)=>ie.lastSeen.localeCompare(H.lastSeen))}function Es(l){const f=n(o).watcher??{enabled:!0,running:!1,path:void 0,model:void 0,rules:void 0,lastEventAt:void 0,error:void 0};let A=n(o).files,C={...f,lastEventAt:l.timestamp,enabled:!0};l.type==="ready"&&(C={...C,running:!0,error:void 0,path:l.path,model:l.model,rules:l.rules}),l.type==="saved"&&(A=Ge({file:l.file,status:"checking",lastSeen:l.timestamp,violations:[]})),l.type==="clean"&&(A=Ge({file:l.file,status:"clean",lastSeen:l.timestamp,violations:[]})),l.type==="skipped"&&(A=Ge({file:l.file,status:"skipped",lastSeen:l.timestamp,violations:[],message:l.reason})),l.type==="violations"&&(A=Ge({file:l.file,status:"violations",lastSeen:l.timestamp,violations:l.violations})),l.type==="error"&&(C={...C,running:!1,error:l.message}),l.type==="stopped"&&(C={...C,running:!1});const H=[l,...n(o).events??[]].slice(0,100);M(o,{...n(o),files:A,events:H,watcher:C})}function Jt(l=[]){M(T,l.map(pt).map(f=>({...f,id:crypto.randomUUID()})).reverse().slice(0,80))}function Qt(l){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(l))}function Xt(l){return Math.max(1,...l.map(f=>f.count))}function Zt(l,f){const A=l.file||f;return l.line?`${A}:${l.line}`:A}function xs(l){return l.type==="saved"?"SAVE":l.type==="clean"?"OK":l.type==="skipped"?"SKIP":l.type==="violations"?"FAIL":l.type==="error"?"WARN":"SYS"}async function pe(){const l=await fetch("/api/snapshot");M(o,await l.json()),Jt(n(o).events)}async function ks(){if(!qe&&document.visibilityState!=="hidden"){qe=!0;try{const l=await fetch("/api/stats",{cache:"no-store"});if(!l.ok)return;const f=await l.json();if(!f.stats)return;M(o,{...n(o),stats:f.stats})}catch{}finally{qe=!1}}}function ei(){ne&&clearInterval(ne),ne=setInterval(()=>{ks()},2e3)}function Lr(){const l=location.protocol==="https:"?"wss:":"ws:",f=new WebSocket(`${l}//${location.host}/ws`);f.addEventListener("open",()=>{M(m,!0),ae({type:"system",timestamp:new Date().toISOString(),message:"Dashboard connected"})}),f.addEventListener("close",()=>{M(m,!1),ae({type:"error",timestamp:new Date().toISOString(),message:"Dashboard disconnected"}),setTimeout(Lr,1500)}),f.addEventListener("message",A=>{const C=JSON.parse(A.data);if(C.type==="snapshot"){M(o,C.snapshot),n(T).length===0&&Jt(n(o).events);return}C.type==="watch"&&(Es(C.event),ae(pt(C.event)))})}async function ti(){if(n(F).content.trim()){M(L,!0),M(J,"");try{const l=await fetch("/api/memories",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n(F))});if(!l.ok)throw new Error((await l.json()).error??"Save failed");M(F,{type:"rule",scope:"project",content:"",reason:"",tags:"dashboard"}),await pe()}catch(l){M(J,l.message)}finally{M(L,!1)}}}async function si(l){M(J,"");const f=await fetch(`/api/memories/${l}`,{method:"DELETE"});if(!f.ok){M(J,(await f.json()).error??"Delete failed");return}await pe()}pe().catch(l=>{M(J,l.message)}),Lr(),ei(),Rc(()=>{ne&&(clearInterval(ne),ne=void 0)}),Ee(()=>(n(o),n(R),n($)),()=>{M(s,n(o).memories.filter(l=>{const f=n(R)==="all"||l.type===n(R),A=`${l.type} ${l.scope} ${l.content} ${l.reason??""} ${l.tags.join(" ")}`.toLowerCase();return f&&A.includes(n($).toLowerCase())}))}),Ee(()=>n(o),()=>{M(r,Object.values(n(o).stats.files??{}).reduce((l,f)=>l+f,0))}),Ee(()=>n(o),()=>{M(a,n(o).files.filter(l=>l.status==="clean").length)}),Ee(()=>n(o),()=>{M(i,Object.values(n(o).stats.rules).reduce((l,f)=>l+f,0))}),Ee(()=>n(o),()=>{M(u,n(o).stats.recentViolations??[])}),Ee(()=>n(u),()=>{M(d,n(u).filter(l=>l.source==="hook"||l.source==="ci"))}),Ee(()=>n(r),()=>{M(v,n(r))}),Ee(()=>n(o),()=>{M(p,Object.keys(n(o).stats.files??{}).length)}),Ee(()=>n(o),()=>{M(g,n(o).memories.filter(l=>["rule","pattern","decision"].includes(l.type)).length)}),Ee(()=>n(o),()=>{var l;M(E,((l=n(o).memoryCount)==null?void 0:l.total)??n(o).memories.length)}),Ee(()=>n(o),()=>{var l;M(w,((l=n(o).memoryCount)==null?void 0:l.relevant)??n(o).memories.length)}),Ee(()=>(n(m),n(o)),()=>{var l,f;M(y,n(m)?((l=n(o).watcher)==null?void 0:l.enabled)===!1?{live:!1,label:"Watch off"}:(f=n(o).watcher)!=null&&f.running?{live:!0,label:"Watcher live"}:{live:!1,label:"Watcher idle"}:{live:!1,label:"Disconnected"})}),Yo(),Tc();var Pr=rf(),jr=_(Pr),ri=h(_(jr),4),Vs=_(ri);let $r;var ni=h(_(Vs)),ai=h(Vs,2),ii=_(ai),li=h(jr,2),Wr=_(li),qr=_(Wr),Ur=h(_(qr),2);let Vr;var oi=h(_(Ur),2),ci=_(oi),fi=h(qr,2),zr=_(fi),ui=h(_(zr),2),vi=_(ui),Hr=h(zr,2),di=h(_(Hr),2),pi=_(di),_i=h(Hr,2),hi=h(_(_i),2),gi=_(hi),bi=h(Wr,2),Br=_(bi),Kr=_(Br),Yr=_(Kr),mi=h(_(Yr),2),yi=_(mi),wi=h(Yr,2),Gr=_(wi),Ei=h(_(Gr)),xi=_(Ei),Jr=h(Gr,2),ki=h(_(Jr)),Si=_(ki),Qr=h(Jr,2),Ti=h(_(Qr)),Ai=_(Ti),Xr=h(Qr,2),Ri=h(_(Xr)),Ci=_(Ri),Zr=h(Xr,2),Ni=h(_(Zr)),Mi=_(Ni),Di=h(Zr,2);{var Oi=l=>{var f=Mc(),A=h(_(f)),C=_(A);V(()=>x(C,(n(o),b(()=>n(o).watcher.error)))),P(l,f)};fe(Di,l=>{n(o),b(()=>{var f;return(f=n(o).watcher)==null?void 0:f.error})&&l(Oi)})}var en=h(Kr,2),tn=_(en),Ii=h(_(tn),2),Fi=_(Ii),Li=h(tn,2),sn=_(Li),Pi=h(_(sn)),ji=_(Pi),rn=h(sn,2),$i=h(_(rn)),Wi=_($i),nn=h(rn,2),an=h(_(nn),2);let ln;var qi=_(an);{var Ui=l=>{var f=ra();V(()=>x(f,(n(o),b(()=>{var A;return(A=n(o).runtime)!=null&&A.model.checkModelInstalled?"installed":"missing"})))),P(l,f)},Vi=l=>{var f=ra();V(()=>x(f,(n(o),b(()=>{var A;return(A=n(o).runtime)!=null&&A.model.apiKeyConfigured?"api key set":"api key missing"})))),P(l,f)};fe(qi,l=>{n(o),b(()=>{var f;return((f=n(o).runtime)==null?void 0:f.model.provider)==="ollama"})?l(Ui):l(Vi,-1)})}var on=h(nn,2),zi=h(_(on)),Hi=_(zi),Bi=h(on,2),Ki=h(_(Bi)),Yi=_(Ki),Gi=h(en,2),cn=_(Gi),fn=h(_(cn),2);let un;var Ji=_(fn),Qi=h(cn,2),vn=_(Qi),Xi=h(_(vn)),Zi=_(Xi),dn=h(vn,2),el=h(_(dn)),tl=_(el),pn=h(dn,2),sl=h(_(pn)),rl=_(sl),nl=h(pn,2),al=h(_(nl)),il=_(al),_n=h(Br,2);{var ll=l=>{var f=Dc(),A=_(f);V(()=>x(A,(n(o),b(()=>n(o).dbError)))),P(l,f)};fe(_n,l=>{n(o),b(()=>n(o).dbError)&&l(ll)})}var hn=h(_n,2);{var ol=l=>{var f=Oc(),A=_(f);V(()=>x(A,n(J))),P(l,f)};fe(hn,l=>{n(J)&&l(ol)})}var gn=h(hn,2),cl=h(_(gn),2),bn=_(cl);{var fl=l=>{var f=Ic();P(l,f)};fe(bn,l=>{n(T),b(()=>n(T).length===0)&&l(fl)})}var ul=h(bn,2);Lt(ul,1,()=>(n(T),b(()=>[...n(T)].reverse())),l=>l.id,(l,f)=>{var A=Hc();let C;var H=_(A),ie=_(H),we=_(ie),_e=h(ie,2),k=_(_e),q=h(_e,2);{var Je=j=>{var B=Fc(),Oe=_(B);V(()=>x(Oe,(n(f),b(()=>n(f).message)))),P(j,B)},es=j=>{var B=Lc(),Oe=_(B);V(()=>x(Oe,`saved: ${n(f),b(()=>n(f).file)??""}`)),P(j,B)},Ot=j=>{var B=Pc(),Oe=_(B);V(()=>x(Oe,`${n(f),b(()=>n(f).file)??""} - no violations`)),P(j,B)},It=j=>{var B=jc(),Oe=_(B);V(()=>x(Oe,`${n(f),b(()=>n(f).file)??""} - skipped: ${n(f),b(()=>n(f).reason)??""}`)),P(j,B)},Qe=j=>{var B=$c(),Oe=_(B);V(()=>x(Oe,`${n(f),b(()=>n(f).violations.length)??""} violation${n(f),b(()=>n(f).violations.length===1?"":"s")??""} in ${n(f),b(()=>n(f).file)??""}`)),P(j,B)};fe(q,j=>{n(f),b(()=>n(f).type==="system"||n(f).type==="error")?j(Je):(n(f),b(()=>n(f).type==="saved")?j(es,1):(n(f),b(()=>n(f).type==="clean")?j(Ot,2):(n(f),b(()=>n(f).type==="skipped")?j(It,3):j(Qe,-1))))})}var Ft=h(H,2);{var he=j=>{var B=cc(),Oe=Wo(B);Lt(Oe,3,()=>(n(f),b(()=>n(f).violations)),(Pn,K)=>`${n(f).id}-${K}`,(Pn,K,Ol)=>{var jn=zc(),$n=_(jn),Il=_($n),Wn=h($n,2),Fl=h(_(Wn)),qn=h(Wn,2);{var Ll=te=>{var Ie=Wc(),_t=h(_(Ie));V(()=>x(_t,` ${n(K),b(()=>n(K).reason)??""}`)),P(te,Ie)};fe(qn,te=>{n(K),b(()=>n(K).reason)&&te(Ll)})}var Un=h(qn,2);{var Pl=te=>{var Ie=qc(),_t=h(_(Ie));V(()=>x(_t,` ${n(K),b(()=>n(K).issue)??""}`)),P(te,Ie)};fe(Un,te=>{n(K),b(()=>n(K).issue)&&te(Pl)})}var Vn=h(Un,2);{var jl=te=>{var Ie=Uc(),_t=h(_(Ie));V(()=>x(_t,` ${n(K),b(()=>n(K).suggestion)??""}`)),P(te,Ie)};fe(Vn,te=>{n(K),b(()=>n(K).suggestion)&&te(jl)})}var $l=h(Vn,2);{var Wl=te=>{var Ie=Vc(),_t=_(Ie);V(()=>x(_t,(n(K),b(()=>n(K).code)))),P(te,Ie)};fe($l,te=>{n(K),b(()=>n(K).code)&&te(Wl)})}V(te=>{x(Il,`[${n(Ol)+1}] ${te??""}`),x(Fl,` ${n(K),b(()=>n(K).rule)??""}`)},[()=>(n(K),n(f),b(()=>Zt(n(K),n(f).file)))]),P(Pn,jn)}),P(j,B)};fe(Ft,j=>{n(f),b(()=>n(f).type==="violations")&&j(he)})}V((j,B)=>{C=rs(A,1,"svelte-d3ct2b",null,C,{"error-line":n(f).type==="error","ok-line":n(f).type==="clean","violation-line":n(f).type==="violations"}),x(we,j),x(k,B)},[()=>(n(f),b(()=>Qt(n(f).timestamp))),()=>(n(f),b(()=>xs(n(f))))]),P(l,A)});var vl=h(gn,2),mn=_(vl),yn=h(_(mn),2),dl=h(_(yn),2);Lt(dl,1,()=>(n(o),b(()=>n(o).stats.topRules.slice(0,5))),l=>l.name,(l,f)=>{var A=Bc(),C=_(A),H=_(C),ie=_(H),we=h(H,2),_e=_(we),k=h(C,2);V(q=>{x(ie,(n(f),b(()=>n(f).name))),x(_e,(n(f),b(()=>n(f).count))),ia(k,q)},[()=>(n(f),n(o),b(()=>`width: ${n(f).count/Xt(n(o).stats.topRules)*100}%`))]),P(l,A)},l=>{var f=Kc();P(l,f)});var wn=h(yn,2),pl=h(_(wn),2);Lt(pl,1,()=>(n(o),b(()=>n(o).stats.topFiles.slice(0,5))),l=>l.name,(l,f)=>{var A=Yc(),C=_(A),H=_(C),ie=_(H),we=h(H,2),_e=_(we),k=h(C,2);V(q=>{x(ie,(n(f),b(()=>n(f).name))),x(_e,(n(f),b(()=>n(f).count))),ia(k,q)},[()=>(n(f),n(o),b(()=>`width: ${n(f).count/Xt(n(o).stats.topFiles)*100}%`))]),P(l,A)},l=>{var f=Gc();P(l,f)});var _l=h(wn,2),En=_(_l),hl=h(_(En)),gl=_(hl),xn=h(En,2),bl=h(_(xn)),ml=_(bl),yl=h(xn,2),wl=h(_(yl)),El=_(wl),kn=h(mn,2),Sn=_(kn),xl=h(_(Sn),2),kl=_(xl),Sl=h(Sn,2);Lt(Sl,7,()=>(n(d),b(()=>n(d).slice(0,8))),(l,f)=>`${l.timestamp}-${f}`,(l,f)=>{var A=Xc(),C=_(A),H=_(C),ie=_(H),we=h(H,2),_e=_(we),k=h(C,2),q=_(k),Je=h(k,2),es=_(Je),Ot=h(Je,2);{var It=he=>{var j=Jc(),B=_(j);V(()=>x(B,(n(f),b(()=>n(f).issue)))),P(he,j)};fe(Ot,he=>{n(f),b(()=>n(f).issue)&&he(It)})}var Qe=h(Ot,2);{var Ft=he=>{var j=Qc(),B=_(j);V(()=>x(B,(n(f),b(()=>n(f).suggestion)))),P(he,j)};fe(Qe,he=>{n(f),b(()=>n(f).suggestion)&&he(Ft)})}V((he,j)=>{x(ie,(n(f),b(()=>n(f).source==="ci"?"CI":"Hook"))),x(_e,he),x(q,(n(f),b(()=>n(f).rule))),x(es,j)},[()=>(n(f),b(()=>Qt(n(f).timestamp))),()=>(n(f),b(()=>Zt(n(f),n(f).file||"staged diff")))]),P(l,A)},l=>{var f=Zc();P(l,f)});var Tl=h(kn,2),Tn=_(Tl),Al=h(_(Tn),2),Rl=_(Al),zs=h(Tn,2),An=_(zs),Hs=_(An),Bs=_(Hs);Bs.value=Bs.__value="rule";var Ks=h(Bs);Ks.value=Ks.__value="decision";var Ys=h(Ks);Ys.value=Ys.__value="pattern";var Rn=h(Ys);Rn.value=Rn.__value="ignore";var Cn=h(Hs,2),Gs=_(Cn);Gs.value=Gs.__value="project";var Nn=h(Gs);Nn.value=Nn.__value="global";var Mn=h(An,2),Dn=h(Mn,2),On=_(Dn),Cl=h(On,2),In=h(Dn,2),Nl=_(In),Fn=h(zs,2),Js=_(Fn),Qs=_(Js);Qs.value=Qs.__value="all";var Xs=h(Qs);Xs.value=Xs.__value="rule";var Zs=h(Xs);Zs.value=Zs.__value="decision";var er=h(Zs);er.value=er.__value="pattern";var Ln=h(er);Ln.value=Ln.__value="ignore";var Ml=h(Js,2),Dl=h(Fn,2);Lt(Dl,5,()=>n(s),l=>l.id,(l,f)=>{var A=tf(),C=_(A),H=_(C),ie=_(H),we=_(ie),_e=h(ie,2),k=_(_e),q=h(H,2),Je=_(q),es=h(q,2);{var Ot=Qe=>{var Ft=ef(),he=_(Ft);V(()=>x(he,(n(f),b(()=>n(f).reason)))),P(Qe,Ft)};fe(es,Qe=>{n(f),b(()=>n(f).reason)&&Qe(Ot)})}var It=h(C,2);V(Qe=>{x(we,(n(f),b(()=>n(f).scope))),x(k,`Rule-${Qe??""}`),x(Je,(n(f),b(()=>n(f).content))),Ec(It,"aria-label",(n(f),b(()=>`Delete ${n(f).id}`)))},[()=>(n(f),b(()=>String(n(f).id).padStart(3,"0")))]),ta("click",It,()=>si(n(f).id)),P(l,A)},l=>{var f=sf();P(l,f)}),V((l,f,A)=>{var C,H,ie,we,_e;$r=rs(Vs,1,"status-chip svelte-d3ct2b",null,$r,{live:n(y).live}),x(ni,` ${n(y),b(()=>n(y).label)??""}`),x(ii,(n(o),b(()=>{var k;return((k=n(o).runtime)==null?void 0:k.model.label)??"runtime pending"}))),Vr=rs(Ur,1,"live-label svelte-d3ct2b",null,Vr,{live:n(y).live}),x(ci,(n(y),b(()=>n(y).label))),x(vi,n(v)),x(pi,n(p)),x(gi,n(g)),x(yi,(n(o),b(()=>{var k;return(k=n(o).runtime)!=null&&k.project.initialized?"Initialized":"Not initialized"}))),x(xi,l),x(Si,(n(o),b(()=>{var k;return((k=n(o).runtime)==null?void 0:k.project.type)??"unknown"}))),x(Ai,(n(o),b(()=>{var k;return((k=n(o).runtime)==null?void 0:k.project.language)??"unknown"}))),x(Ci,f),x(Mi,(n(o),b(()=>{var k,q;return((k=n(o).watcher)==null?void 0:k.enabled)===!1?"disabled":(q=n(o).watcher)!=null&&q.running?"running":"idle"}))),x(Fi,(n(o),b(()=>{var k;return((k=n(o).runtime)==null?void 0:k.model.label)??"pending"}))),x(ji,(n(o),b(()=>{var k;return((k=n(o).runtime)==null?void 0:k.model.provider)??"unknown"}))),x(Wi,(n(o),b(()=>{var k,q,Je;return((k=n(o).runtime)==null?void 0:k.model.checkModelResolved)??((q=n(o).runtime)==null?void 0:q.model.checkModel)??((Je=n(o).runtime)==null?void 0:Je.model.chatModel)??"unknown"}))),ln=rs(an,1,"svelte-d3ct2b",null,ln,{"status-ok":((C=n(o).runtime)==null?void 0:C.model.checkModelInstalled)||((H=n(o).runtime)==null?void 0:H.model.apiKeyConfigured),"status-warn":((ie=n(o).runtime)==null?void 0:ie.model.checkModelInstalled)===!1||((we=n(o).runtime)==null?void 0:we.model.error)}),x(Hi,(n(o),b(()=>{var k,q;return((k=n(o).runtime)==null?void 0:k.model.embeddingModelResolved)??((q=n(o).runtime)==null?void 0:q.model.embeddingModel)??"unknown"}))),x(Yi,(n(o),b(()=>{var k;return((k=n(o).runtime)==null?void 0:k.model.ollamaUrl)??"unknown"}))),un=rs(fn,1,"svelte-d3ct2b",null,un,{success:(_e=n(o).runtime)==null?void 0:_e.postgres.connected}),x(Ji,(n(o),b(()=>{var k;return(k=n(o).runtime)!=null&&k.postgres.connected?"Connected":"Not connected"}))),x(Zi,(n(o),b(()=>{var k,q;return((k=n(o).runtime)==null?void 0:k.postgres.serverDatabase)??((q=n(o).runtime)==null?void 0:q.postgres.database)??"unknown"}))),x(tl,(n(o),b(()=>{var k,q;return((k=n(o).runtime)==null?void 0:k.postgres.serverUser)??((q=n(o).runtime)==null?void 0:q.postgres.user)??"unknown"}))),x(rl,`${n(o),b(()=>{var k;return((k=n(o).runtime)==null?void 0:k.postgres.host)??"unknown"})??""}${n(o),b(()=>{var k;return(k=n(o).runtime)!=null&&k.postgres.port?`:${n(o).runtime.postgres.port}`:""})??""}`),x(il,(n(o),b(()=>{var k;return((k=n(o).runtime)==null?void 0:k.postgres.url)??"(not set)"}))),x(gl,n(a)),x(ml,n(v)),x(El,n(i)),x(kl,`${n(d),b(()=>n(d).length)??""} recent`),x(Rl,`${n(g)??""} rules active`),In.disabled=A,x(Nl,n(L)?"Saving...":"Add New Architecture Rule")},[()=>b(Ye),()=>b(nt),()=>(n(L),n(F),b(()=>n(L)||!n(F).content.trim()))]),nr(Hs,()=>n(F).type,l=>ts(F,n(F).type=l)),nr(Cn,()=>n(F).scope,l=>ts(F,n(F).scope=l)),As(Mn,()=>n(F).content,l=>ts(F,n(F).content=l)),As(On,()=>n(F).reason,l=>ts(F,n(F).reason=l)),As(Cl,()=>n(F).tags,l=>ts(F,n(F).tags=l)),ta("submit",zs,Sc(ti)),nr(Js,()=>n(R),l=>M(R,l)),As(Ml,()=>n($),l=>M($,l)),P(e,Pr),wa()}fc(nf,{target:document.getElementById("app")});
@@ -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>Memory Core Dashboard</title>
7
- <script type="module" crossorigin src="/assets/index-C612Qqha.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-D7EPH82B.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-CJyZEmIe.css">
9
9
  </head>
10
10
  <body>
@@ -12,13 +12,13 @@ import {
12
12
  saveMemory,
13
13
  startWatch,
14
14
  updateMemory
15
- } from "./chunk-PDQXIKL7.js";
15
+ } from "./chunk-WJG77BPO.js";
16
16
 
17
17
  // src/dashboard-server.ts
18
18
  import { createHash } from "crypto";
19
19
  import { createReadStream, existsSync, readFileSync, watch } from "fs";
20
20
  import { createServer } from "http";
21
- import { extname, join, normalize, relative } from "path";
21
+ import { extname, join, normalize, relative, resolve } from "path";
22
22
  import { fileURLToPath } from "url";
23
23
  import chalk from "chalk";
24
24
  var clients = /* @__PURE__ */ new Set();
@@ -46,6 +46,7 @@ var snapshotBroadcastTimer;
46
46
  var snapshotBroadcastInFlight = false;
47
47
  var snapshotBroadcastQueued = false;
48
48
  var snapshotBroadcastForceRefresh = false;
49
+ var projectRoot = process.cwd();
49
50
  function readJsonFile(path, fallback) {
50
51
  if (!existsSync(path)) return fallback;
51
52
  try {
@@ -55,7 +56,7 @@ function readJsonFile(path, fallback) {
55
56
  }
56
57
  }
57
58
  function readProjectConfig() {
58
- return readJsonFile(join(process.cwd(), ".memory-core.json"), null);
59
+ return readJsonFile(join(projectRoot, ".memory-core.json"), null);
59
60
  }
60
61
  function parseEnvFile(raw) {
61
62
  const values = {};
@@ -71,8 +72,8 @@ function parseEnvFile(raw) {
71
72
  return values;
72
73
  }
73
74
  function getRuntimeEnvPath() {
74
- const memoryEnv = join(process.cwd(), ".memory-core.env");
75
- return existsSync(memoryEnv) ? memoryEnv : join(process.cwd(), ".env");
75
+ const memoryEnv = join(projectRoot, ".memory-core.env");
76
+ return existsSync(memoryEnv) ? memoryEnv : join(projectRoot, ".env");
76
77
  }
77
78
  function reloadRuntimeEnv() {
78
79
  const envPath = getRuntimeEnvPath();
@@ -91,18 +92,20 @@ function invalidateSnapshotBase() {
91
92
  snapshotBaseCache = void 0;
92
93
  }
93
94
  function readStats() {
94
- return readJsonFile(join(process.cwd(), ".memory-core-stats.json"), { rules: {}, files: {} });
95
+ return readJsonFile(join(projectRoot, ".memory-core-stats.json"), { rules: {}, files: {} });
95
96
  }
96
97
  function topEntries(values = {}, limit = 8) {
97
98
  return Object.entries(values).sort((a, b) => b[1] - a[1]).slice(0, limit).map(([name, count]) => ({ name, count }));
98
99
  }
99
100
  function buildStatsPayload() {
100
101
  const stats = readStats();
102
+ const rules = stats.live?.rules ?? stats.rules ?? {};
103
+ const files = stats.live?.files ?? stats.files ?? {};
101
104
  return {
102
- rules: stats.rules ?? {},
103
- files: stats.files ?? {},
104
- topRules: topEntries(stats.rules),
105
- topFiles: topEntries(stats.files),
105
+ rules,
106
+ files,
107
+ topRules: topEntries(rules),
108
+ topFiles: topEntries(files),
106
109
  recentViolations: stats.recentViolations ?? []
107
110
  };
108
111
  }
@@ -206,12 +209,12 @@ async function getModelStatus(forceRefresh = false) {
206
209
  return status;
207
210
  }
208
211
  async function getRuntimeStatus(config) {
209
- const detected = detectProject(process.cwd());
212
+ const detected = detectProject(projectRoot);
210
213
  const declaredArchitectures = [
211
214
  config?.backendArchitecture,
212
215
  config?.frontendFramework
213
216
  ].filter((value) => typeof value === "string" && value.length > 0);
214
- const activeArchitectures = inferProjectArchitectures(process.cwd(), config);
217
+ const activeArchitectures = inferProjectArchitectures(projectRoot, config);
215
218
  const database = parseDatabaseUrl(Config.databaseUrl);
216
219
  let postgres = {
217
220
  ...database,
@@ -242,7 +245,7 @@ async function getRuntimeStatus(config) {
242
245
  const model = await modelPromise;
243
246
  return {
244
247
  project: {
245
- name: config?.projectName ?? process.cwd().split("/").pop() ?? "project",
248
+ name: config?.projectName ?? projectRoot.split("/").pop() ?? "project",
246
249
  type: config?.projectType ?? "unknown",
247
250
  language: config?.language ?? detected.language,
248
251
  initialized: config !== null,
@@ -376,7 +379,7 @@ async function handleApi(req, res, url) {
376
379
  return;
377
380
  }
378
381
  const config = readProjectConfig();
379
- const activeArchitectures = inferProjectArchitectures(process.cwd(), config);
382
+ const activeArchitectures = inferProjectArchitectures(projectRoot, config);
380
383
  await saveMemory({
381
384
  type: typeof body.type === "string" ? body.type : "rule",
382
385
  scope: typeof body.scope === "string" ? body.scope : "project",
@@ -635,14 +638,14 @@ function startConfigWatch() {
635
638
  }, 150);
636
639
  };
637
640
  for (const file of watchedFiles) {
638
- const filePath = join(process.cwd(), file);
641
+ const filePath = join(projectRoot, file);
639
642
  if (!existsSync(filePath)) continue;
640
643
  watchedPaths.add(filePath);
641
644
  watchers.push(watch(filePath, () => reload(filePath)));
642
645
  }
643
- watchers.push(watch(process.cwd(), (_eventType, filename) => {
646
+ watchers.push(watch(projectRoot, (_eventType, filename) => {
644
647
  if (typeof filename !== "string" || !watchedFiles.includes(filename)) return;
645
- const filePath = join(process.cwd(), filename);
648
+ const filePath = join(projectRoot, filename);
646
649
  if (!existsSync(filePath)) return;
647
650
  if (!watchedPaths.has(filePath)) {
648
651
  watchedPaths.add(filePath);
@@ -656,6 +659,7 @@ function startConfigWatch() {
656
659
  };
657
660
  }
658
661
  async function startDashboard(options = {}) {
662
+ projectRoot = resolve(options.path ?? process.cwd());
659
663
  reloadRuntimeEnv();
660
664
  const port = options.port ?? 5178;
661
665
  const stopConfigWatch = startConfigWatch();
@@ -683,8 +687,8 @@ async function startDashboard(options = {}) {
683
687
  }
684
688
  void closePool();
685
689
  });
686
- await new Promise((resolve) => {
687
- server.listen(port, resolve);
690
+ await new Promise((resolve2) => {
691
+ server.listen(port, resolve2);
688
692
  });
689
693
  console.log(chalk.green(`
690
694
  Dashboard: http://localhost:${port}
@@ -692,7 +696,7 @@ async function startDashboard(options = {}) {
692
696
  if (options.watch ?? true) {
693
697
  watcherStatus.enabled = true;
694
698
  void startWatch({
695
- path: options.path,
699
+ path: projectRoot,
696
700
  onEvent: handleWatchEvent,
697
701
  exitOnSetupFailure: false
698
702
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shahmilsaari/memory-core",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Universal AI memory core — generate AI context files from architecture profiles with RAG support",
5
5
  "homepage": "https://memory-core.shahmilsaari.my/",
6
6
  "type": "module",
@@ -1,2 +0,0 @@
1
- var Ul=Object.defineProperty;var zn=e=>{throw TypeError(e)};var Vl=(e,t,s)=>t in e?Ul(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Pe=(e,t,s)=>Vl(e,typeof t!="symbol"?t+"":t,s),tr=(e,t,s)=>t.has(e)||zn("Cannot "+s);var o=(e,t,s)=>(tr(e,t,"read from private field"),s?s.call(e):t.get(e)),N=(e,t,s)=>t.has(e)?zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),D=(e,t,s,r)=>(tr(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s),U=(e,t,s)=>(tr(e,t,"access private method"),s);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const v of i.addedNodes)v.tagName==="LINK"&&v.rel==="modulepreload"&&r(v)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();const zl=!1;var wr=Array.isArray,Hl=Array.prototype.indexOf,Ht=Array.prototype.includes,Ws=Array.from,Bl=Object.defineProperty,os=Object.getOwnPropertyDescriptor,ua=Object.getOwnPropertyDescriptors,Kl=Object.prototype,Yl=Array.prototype,Er=Object.getPrototypeOf,Hn=Object.isExtensible;const Gl=()=>{};function Jl(e){return e()}function lr(e){for(var t=0;t<e.length;t++)e[t]()}function va(){var e,t,s=new Promise((r,a)=>{e=r,t=a});return{promise:s,resolve:e,reject:t}}const le=2,Bt=4,ys=8,da=1<<24,Ke=16,qe=32,vt=64,or=128,Ce=512,Q=1024,ae=2048,Ue=4096,ce=8192,Ne=16384,It=32768,Bn=1<<25,Kt=65536,cr=1<<17,Ql=1<<18,Jt=1<<19,pa=1<<20,Be=1<<25,Ct=65536,Fs=1<<21,vs=1<<22,ft=1<<23,St=Symbol("$state"),Qe=new class extends Error{constructor(){super(...arguments);Pe(this,"name","StaleReactionError");Pe(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};function _a(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Xl(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Zl(e,t,s){throw new Error("https://svelte.dev/e/each_key_duplicate")}function eo(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function to(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function so(e){throw new Error("https://svelte.dev/e/effect_orphan")}function ro(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function no(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function ao(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function io(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function lo(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const oo=1,co=2,ha=4,fo=8,uo=16,vo=2,ee=Symbol(),ga="http://www.w3.org/1999/xhtml";function po(){console.warn("https://svelte.dev/e/derived_inert")}function _o(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function ho(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function ba(e){return e===this.v}function go(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function ma(e){return!go(e,this.v)}let ws=!1,bo=!1;function mo(){ws=!0}let z=null;function Yt(e){z=e}function ya(e,t=!1,s){z={p:z,i:!1,c:null,e:null,s:e,x:null,r:I,l:ws&&!t?{s:null,u:null,$:[]}:null}}function wa(e){var t=z,s=t.e;if(s!==null){t.e=null;for(var r of s)Ua(r)}return t.i=!0,z=t.p,{}}function Es(){return!ws||z!==null&&z.l===null}let bt=[];function Ea(){var e=bt;bt=[],lr(e)}function ut(e){if(bt.length===0&&!cs){var t=bt;queueMicrotask(()=>{t===bt&&Ea()})}bt.push(e)}function yo(){for(;bt.length>0;)Ea()}function xa(e){var t=I;if(t===null)return O.f|=ft,e;if(!(t.f&It)&&!(t.f&Bt))throw e;ct(e,t)}function ct(e,t){for(;t!==null;){if(t.f&or){if(!(t.f&It))throw e;try{t.b.error(e);return}catch(s){e=s}}t=t.parent}throw e}const wo=-7169;function G(e,t){e.f=e.f&wo|t}function xr(e){e.f&Ce||e.deps===null?G(e,Q):G(e,Ue)}function ka(e){if(e!==null)for(const t of e)!(t.f&le)||!(t.f&Ct)||(t.f^=Ct,ka(t.deps))}function Sa(e,t,s){e.f&ae?t.add(e):e.f&Ue&&s.add(e),ka(e.deps),G(e,Q)}const gt=new Set;let T=null,ne=null,fr=null,cs=!1,sr=!1,$t=null,Rs=null;var Kn=0;let Eo=1;var Wt,qt,yt,Xe,Ve,ps,ye,_s,lt,Ze,ze,Ut,Vt,wt,X,Cs,Ta,Ns,ur,Ms,xo;const Ps=class Ps{constructor(){N(this,X);Pe(this,"id",Eo++);Pe(this,"current",new Map);Pe(this,"previous",new Map);N(this,Wt,new Set);N(this,qt,new Set);N(this,yt,new Set);N(this,Xe,new Map);N(this,Ve,new Map);N(this,ps,null);N(this,ye,[]);N(this,_s,[]);N(this,lt,new Set);N(this,Ze,new Set);N(this,ze,new Map);N(this,Ut,new Set);Pe(this,"is_fork",!1);N(this,Vt,!1);N(this,wt,new Set)}skip_effect(t){o(this,ze).has(t)||o(this,ze).set(t,{d:[],m:[]}),o(this,Ut).delete(t)}unskip_effect(t,s=r=>this.schedule(r)){var r=o(this,ze).get(t);if(r){o(this,ze).delete(t);for(var a of r.d)G(a,ae),s(a);for(a of r.m)G(a,Ue),s(a)}o(this,Ut).add(t)}capture(t,s,r=!1){t.v!==ee&&!this.previous.has(t)&&this.previous.set(t,t.v),t.f&ft||(this.current.set(t,[s,r]),ne==null||ne.set(t,s)),this.is_fork||(t.v=s)}activate(){T=this}deactivate(){T=null,ne=null}flush(){try{sr=!0,T=this,U(this,X,Ns).call(this)}finally{Kn=0,fr=null,$t=null,Rs=null,sr=!1,T=null,ne=null,Tt.clear()}}discard(){for(const t of o(this,qt))t(this);o(this,qt).clear(),o(this,yt).clear(),gt.delete(this)}register_created_effect(t){o(this,_s).push(t)}increment(t,s){let r=o(this,Xe).get(s)??0;if(o(this,Xe).set(s,r+1),t){let a=o(this,Ve).get(s)??0;o(this,Ve).set(s,a+1)}}decrement(t,s,r){let a=o(this,Xe).get(s)??0;if(a===1?o(this,Xe).delete(s):o(this,Xe).set(s,a-1),t){let i=o(this,Ve).get(s)??0;i===1?o(this,Ve).delete(s):o(this,Ve).set(s,i-1)}o(this,Vt)||r||(D(this,Vt,!0),ut(()=>{D(this,Vt,!1),this.flush()}))}transfer_effects(t,s){for(const r of t)o(this,lt).add(r);for(const r of s)o(this,Ze).add(r);t.clear(),s.clear()}oncommit(t){o(this,Wt).add(t)}ondiscard(t){o(this,qt).add(t)}on_fork_commit(t){o(this,yt).add(t)}run_fork_commit_callbacks(){for(const t of o(this,yt))t(this);o(this,yt).clear()}settled(){return(o(this,ps)??D(this,ps,va())).promise}static ensure(){if(T===null){const t=T=new Ps;sr||(gt.add(T),cs||ut(()=>{T===t&&t.flush()}))}return T}apply(){{ne=null;return}}schedule(t){var a;if(fr=t,(a=t.b)!=null&&a.is_pending&&t.f&(Bt|ys|da)&&!(t.f&It)){t.b.defer_effect(t);return}for(var s=t;s.parent!==null;){s=s.parent;var r=s.f;if($t!==null&&s===I&&(O===null||!(O.f&le)))return;if(r&(vt|qe)){if(!(r&Q))return;s.f^=Q}}o(this,ye).push(s)}};Wt=new WeakMap,qt=new WeakMap,yt=new WeakMap,Xe=new WeakMap,Ve=new WeakMap,ps=new WeakMap,ye=new WeakMap,_s=new WeakMap,lt=new WeakMap,Ze=new WeakMap,ze=new WeakMap,Ut=new WeakMap,Vt=new WeakMap,wt=new WeakMap,X=new WeakSet,Cs=function(){return this.is_fork||o(this,Ve).size>0},Ta=function(){for(const r of o(this,wt))for(const a of o(r,Ve).keys()){for(var t=!1,s=a;s.parent!==null;){if(o(this,ze).has(s)){t=!0;break}s=s.parent}if(!t)return!0}return!1},Ns=function(){var d,f;if(Kn++>1e3&&(gt.delete(this),So()),!U(this,X,Cs).call(this)){for(const p of o(this,lt))o(this,Ze).delete(p),G(p,ae),this.schedule(p);for(const p of o(this,Ze))G(p,Ue),this.schedule(p)}const t=o(this,ye);D(this,ye,[]),this.apply();var s=$t=[],r=[],a=Rs=[];for(const p of t)try{U(this,X,ur).call(this,p,s,r)}catch(g){throw Ca(p),g}if(T=null,a.length>0){var i=Ps.ensure();for(const p of a)i.schedule(p)}if($t=null,Rs=null,U(this,X,Cs).call(this)||U(this,X,Ta).call(this)){U(this,X,Ms).call(this,r),U(this,X,Ms).call(this,s);for(const[p,g]of o(this,ze))Ra(p,g)}else{o(this,Xe).size===0&&gt.delete(this),o(this,lt).clear(),o(this,Ze).clear();for(const p of o(this,Wt))p(this);o(this,Wt).clear(),Yn(r),Yn(s),(d=o(this,ps))==null||d.resolve()}var v=T;if(o(this,ye).length>0){const p=v??(v=this);o(p,ye).push(...o(this,ye).filter(g=>!o(p,ye).includes(g)))}v!==null&&(gt.add(v),U(f=v,X,Ns).call(f))},ur=function(t,s,r){t.f^=Q;for(var a=t.first;a!==null;){var i=a.f,v=(i&(qe|vt))!==0,d=v&&(i&Q)!==0,f=d||(i&ce)!==0||o(this,ze).has(a);if(!f&&a.fn!==null){v?a.f^=Q:i&Bt?s.push(a):Qt(a)&&(i&Ke&&o(this,Ze).add(a),Dt(a));var p=a.first;if(p!==null){a=p;continue}}for(;a!==null;){var g=a.next;if(g!==null){a=g;break}a=a.parent}}},Ms=function(t){for(var s=0;s<t.length;s+=1)Sa(t[s],o(this,lt),o(this,Ze))},xo=function(){var g,x,w;for(const E of gt){var t=E.id<this.id,s=[];for(const[m,[u,y]]of this.current){if(E.current.has(m)){var r=E.current.get(m)[0];if(t&&u!==r)E.current.set(m,[u,y]);else continue}s.push(m)}var a=[...E.current.keys()].filter(m=>!this.current.has(m));if(a.length===0)t&&E.discard();else if(s.length>0){if(t)for(const m of o(this,Ut))E.unskip_effect(m,u=>{var y;u.f&(Ke|vs)?E.schedule(u):U(y=E,X,Ms).call(y,[u])});E.activate();var i=new Set,v=new Map;for(var d of s)Aa(d,a,i,v);v=new Map;var f=[...E.current.keys()].filter(m=>this.current.has(m)?this.current.get(m)[0]!==m:!0);for(const m of o(this,_s))!(m.f&(Ne|ce|cr))&&kr(m,f,v)&&(m.f&(vs|Ke)?(G(m,ae),E.schedule(m)):o(E,lt).add(m));if(o(E,ye).length>0){E.apply();for(var p of o(E,ye))U(g=E,X,ur).call(g,p,[],[]);D(E,ye,[])}E.deactivate()}}for(const E of gt)o(E,wt).has(this)&&(o(E,wt).delete(this),o(E,wt).size===0&&!U(x=E,X,Cs).call(x)&&(E.activate(),U(w=E,X,Ns).call(w)))};let Nt=Ps;function ko(e){var t=cs;cs=!0;try{for(var s;;){if(yo(),T===null)return s;T.flush()}}finally{cs=t}}function So(){try{ro()}catch(e){ct(e,fr)}}let je=null;function Yn(e){var t=e.length;if(t!==0){for(var s=0;s<t;){var r=e[s++];if(!(r.f&(Ne|ce))&&Qt(r)&&(je=new Set,Dt(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&za(r),(je==null?void 0:je.size)>0)){Tt.clear();for(const a of je){if(a.f&(Ne|ce))continue;const i=[a];let v=a.parent;for(;v!==null;)je.has(v)&&(je.delete(v),i.push(v)),v=v.parent;for(let d=i.length-1;d>=0;d--){const f=i[d];f.f&(Ne|ce)||Dt(f)}}je.clear()}}je=null}}function Aa(e,t,s,r){if(!s.has(e)&&(s.add(e),e.reactions!==null))for(const a of e.reactions){const i=a.f;i&le?Aa(a,t,s,r):i&(vs|Ke)&&!(i&ae)&&kr(a,t,r)&&(G(a,ae),Sr(a))}}function kr(e,t,s){const r=s.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const a of e.deps){if(Ht.call(t,a))return!0;if(a.f&le&&kr(a,t,s))return s.set(a,!0),!0}return s.set(e,!1),!1}function Sr(e){T.schedule(e)}function Ra(e,t){if(!(e.f&qe&&e.f&Q)){e.f&ae?t.d.push(e):e.f&Ue&&t.m.push(e),G(e,Q);for(var s=e.first;s!==null;)Ra(s,t),s=s.next}}function Ca(e){G(e,Q);for(var t=e.first;t!==null;)Ca(t),t=t.next}function To(e){let t=0,s=Mt(0),r;return()=>{Cr()&&(n(s),Us(()=>(t===0&&(r=b(()=>e(()=>fs(s)))),t+=1,()=>{ut(()=>{t-=1,t===0&&(r==null||r(),r=void 0,fs(s))})})))}}var Ao=Kt|Jt;function Ro(e,t,s,r){new Co(e,t,s,r)}var Se,yr,Te,Et,ve,Ae,oe,we,et,xt,ot,zt,hs,gs,tt,js,J,No,Mo,Do,vr,Ds,Is,dr,pr;class Co{constructor(t,s,r,a){N(this,J);Pe(this,"parent");Pe(this,"is_pending",!1);Pe(this,"transform_error");N(this,Se);N(this,yr,null);N(this,Te);N(this,Et);N(this,ve);N(this,Ae,null);N(this,oe,null);N(this,we,null);N(this,et,null);N(this,xt,0);N(this,ot,0);N(this,zt,!1);N(this,hs,new Set);N(this,gs,new Set);N(this,tt,null);N(this,js,To(()=>(D(this,tt,Mt(o(this,xt))),()=>{D(this,tt,null)})));var i;D(this,Se,t),D(this,Te,s),D(this,Et,v=>{var d=I;d.b=this,d.f|=or,r(v)}),this.parent=I.b,this.transform_error=a??((i=this.parent)==null?void 0:i.transform_error)??(v=>v),D(this,ve,Mr(()=>{U(this,J,vr).call(this)},Ao))}defer_effect(t){Sa(t,o(this,hs),o(this,gs))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!o(this,Te).pending}update_pending_count(t,s){U(this,J,dr).call(this,t,s),D(this,xt,o(this,xt)+t),!(!o(this,tt)||o(this,zt))&&(D(this,zt,!0),ut(()=>{D(this,zt,!1),o(this,tt)&&Gt(o(this,tt),o(this,xt))}))}get_effect_pending(){return o(this,js).call(this),n(o(this,tt))}error(t){if(!o(this,Te).onerror&&!o(this,Te).failed)throw t;T!=null&&T.is_fork?(o(this,Ae)&&T.skip_effect(o(this,Ae)),o(this,oe)&&T.skip_effect(o(this,oe)),o(this,we)&&T.skip_effect(o(this,we)),T.on_fork_commit(()=>{U(this,J,pr).call(this,t)})):U(this,J,pr).call(this,t)}}Se=new WeakMap,yr=new WeakMap,Te=new WeakMap,Et=new WeakMap,ve=new WeakMap,Ae=new WeakMap,oe=new WeakMap,we=new WeakMap,et=new WeakMap,xt=new WeakMap,ot=new WeakMap,zt=new WeakMap,hs=new WeakMap,gs=new WeakMap,tt=new WeakMap,js=new WeakMap,J=new WeakSet,No=function(){try{D(this,Ae,Re(()=>o(this,Et).call(this,o(this,Se))))}catch(t){this.error(t)}},Mo=function(t){const s=o(this,Te).failed;s&&D(this,we,Re(()=>{s(o(this,Se),()=>t,()=>()=>{})}))},Do=function(){const t=o(this,Te).pending;t&&(this.is_pending=!0,D(this,oe,Re(()=>t(o(this,Se)))),ut(()=>{var s=D(this,et,document.createDocumentFragment()),r=st();s.append(r),D(this,Ae,U(this,J,Is).call(this,()=>Re(()=>o(this,Et).call(this,r)))),o(this,ot)===0&&(o(this,Se).before(s),D(this,et,null),At(o(this,oe),()=>{D(this,oe,null)}),U(this,J,Ds).call(this,T))}))},vr=function(){try{if(this.is_pending=this.has_pending_snippet(),D(this,ot,0),D(this,xt,0),D(this,Ae,Re(()=>{o(this,Et).call(this,o(this,Se))})),o(this,ot)>0){var t=D(this,et,document.createDocumentFragment());Or(o(this,Ae),t);const s=o(this,Te).pending;D(this,oe,Re(()=>s(o(this,Se))))}else U(this,J,Ds).call(this,T)}catch(s){this.error(s)}},Ds=function(t){this.is_pending=!1,t.transfer_effects(o(this,hs),o(this,gs))},Is=function(t){var s=I,r=O,a=z;Ie(o(this,ve)),De(o(this,ve)),Yt(o(this,ve).ctx);try{return Nt.ensure(),t()}catch(i){return xa(i),null}finally{Ie(s),De(r),Yt(a)}},dr=function(t,s){var r;if(!this.has_pending_snippet()){this.parent&&U(r=this.parent,J,dr).call(r,t,s);return}D(this,ot,o(this,ot)+t),o(this,ot)===0&&(U(this,J,Ds).call(this,s),o(this,oe)&&At(o(this,oe),()=>{D(this,oe,null)}),o(this,et)&&(o(this,Se).before(o(this,et)),D(this,et,null)))},pr=function(t){o(this,Ae)&&(pe(o(this,Ae)),D(this,Ae,null)),o(this,oe)&&(pe(o(this,oe)),D(this,oe,null)),o(this,we)&&(pe(o(this,we)),D(this,we,null));var s=o(this,Te).onerror;let r=o(this,Te).failed;var a=!1,i=!1;const v=()=>{if(a){ho();return}a=!0,i&&lo(),o(this,we)!==null&&At(o(this,we),()=>{D(this,we,null)}),U(this,J,Is).call(this,()=>{U(this,J,vr).call(this)})},d=f=>{try{i=!0,s==null||s(f,v),i=!1}catch(p){ct(p,o(this,ve)&&o(this,ve).parent)}r&&D(this,we,U(this,J,Is).call(this,()=>{try{return Re(()=>{var p=I;p.b=this,p.f|=or,r(o(this,Se),()=>f,()=>v)})}catch(p){return ct(p,o(this,ve).parent),null}}))};ut(()=>{var f;try{f=this.transform_error(t)}catch(p){ct(p,o(this,ve)&&o(this,ve).parent);return}f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(d,p=>ct(p,o(this,ve)&&o(this,ve).parent)):d(f)})};function Io(e,t,s,r){const a=Es()?Tr:Ma;var i=e.filter(w=>!w.settled);if(s.length===0&&i.length===0){r(t.map(a));return}var v=I,d=Oo(),f=i.length===1?i[0].promise:i.length>1?Promise.all(i.map(w=>w.promise)):null;function p(w){d();try{r(w)}catch(E){v.f&Ne||ct(E,v)}Ls()}if(s.length===0){f.then(()=>p(t.map(a)));return}var g=Na();function x(){Promise.all(s.map(w=>Fo(w))).then(w=>p([...t.map(a),...w])).catch(w=>ct(w,v)).finally(()=>g())}f?f.then(()=>{d(),x(),Ls()}):x()}function Oo(){var e=I,t=O,s=z,r=T;return function(i=!0){Ie(e),De(t),Yt(s),i&&!(e.f&Ne)&&(r==null||r.activate(),r==null||r.apply())}}function Ls(e=!0){Ie(null),De(null),Yt(null),e&&(T==null||T.deactivate())}function Na(){var e=I,t=e.b,s=T,r=t.is_rendered();return t.update_pending_count(1,s),s.increment(r,e),(a=!1)=>{t.update_pending_count(-1,s),s.decrement(r,e,a)}}function Tr(e){var t=le|ae;return I!==null&&(I.f|=Jt),{ctx:z,deps:null,effects:null,equals:ba,f:t,fn:e,reactions:null,rv:0,v:ee,wv:0,parent:I,ac:null}}function Fo(e,t,s){let r=I;r===null&&Xl();var a=void 0,i=Mt(ee),v=!O,d=new Map;return Jo(()=>{var E;var f=I,p=va();a=p.promise;try{Promise.resolve(e()).then(p.resolve,p.reject).finally(Ls)}catch(m){p.reject(m),Ls()}var g=T;if(v){if(f.f&It)var x=Na();if(r.b.is_rendered())(E=d.get(g))==null||E.reject(Qe),d.delete(g);else{for(const m of d.values())m.reject(Qe);d.clear()}d.set(g,p)}const w=(m,u=void 0)=>{if(x){var y=u===Qe;x(y)}if(!(u===Qe||f.f&Ne)){if(g.activate(),u)i.f|=ft,Gt(i,u);else{i.f&ft&&(i.f^=ft),Gt(i,m);for(const[R,j]of d){if(d.delete(R),R===g)break;j.reject(Qe)}}g.deactivate()}};p.promise.then(w,m=>w(null,m||"unknown"))}),Nr(()=>{for(const f of d.values())f.reject(Qe)}),new Promise(f=>{function p(g){function x(){g===a?f(i):p(a)}g.then(x,x)}p(a)})}function Ma(e){const t=Tr(e);return t.equals=ma,t}function Lo(e){var t=e.effects;if(t!==null){e.effects=null;for(var s=0;s<t.length;s+=1)pe(t[s])}}function Ar(e){var t,s=I,r=e.parent;if(!dt&&r!==null&&r.f&(Ne|ce))return po(),e.v;Ie(r);try{e.f&=~Ct,Lo(e),t=Ja(e)}finally{Ie(s)}return t}function Da(e){var t=Ar(e);if(!e.equals(t)&&(e.wv=Ya(),(!(T!=null&&T.is_fork)||e.deps===null)&&(T!==null?T.capture(e,t,!0):e.v=t,e.deps===null))){G(e,Q);return}dt||(ne!==null?(Cr()||T!=null&&T.is_fork)&&ne.set(e,t):xr(e))}function Po(e){var t,s;if(e.effects!==null)for(const r of e.effects)(r.teardown||r.ac)&&((t=r.teardown)==null||t.call(r),(s=r.ac)==null||s.abort(Qe),r.teardown=Gl,r.ac=null,ds(r,0),Dr(r))}function Ia(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&Dt(t)}let _r=new Set;const Tt=new Map;let Oa=!1;function Mt(e,t){var s={f:0,v:e,reactions:null,equals:ba,rv:0,wv:0};return s}function at(e,t){const s=Mt(e);return Zo(s),s}function Y(e,t=!1,s=!0){var a;const r=Mt(e);return t||(r.equals=ma),ws&&s&&z!==null&&z.l!==null&&((a=z.l).s??(a.s=[])).push(r),r}function rs(e,t){return M(e,b(()=>n(e))),t}function M(e,t,s=!1){O!==null&&(!We||O.f&cr)&&Es()&&O.f&(le|Ke|vs|cr)&&(Me===null||!Ht.call(Me,e))&&io();let r=s?is(t):t;return Gt(e,r,Rs)}function Gt(e,t,s=null){if(!e.equals(t)){Tt.set(e,dt?t:e.v);var r=Nt.ensure();if(r.capture(e,t),e.f&le){const a=e;e.f&ae&&Ar(a),ne===null&&xr(a)}e.wv=Ya(),Fa(e,ae,s),Es()&&I!==null&&I.f&Q&&!(I.f&(qe|vt))&&(ke===null?ec([e]):ke.push(e)),!r.is_fork&&_r.size>0&&!Oa&&jo()}return t}function jo(){Oa=!1;for(const e of _r)e.f&Q&&G(e,Ue),Qt(e)&&Dt(e);_r.clear()}function fs(e){M(e,e.v+1)}function Fa(e,t,s){var r=e.reactions;if(r!==null)for(var a=Es(),i=r.length,v=0;v<i;v++){var d=r[v],f=d.f;if(!(!a&&d===I)){var p=(f&ae)===0;if(p&&G(d,t),f&le){var g=d;ne==null||ne.delete(g),f&Ct||(f&Ce&&(I===null||!(I.f&Fs))&&(d.f|=Ct),Fa(g,Ue,s))}else if(p){var x=d;f&Ke&&je!==null&&je.add(x),s!==null?s.push(x):Sr(x)}}}}function is(e){if(typeof e!="object"||e===null||St in e)return e;const t=Er(e);if(t!==Kl&&t!==Yl)return e;var s=new Map,r=wr(e),a=at(0),i=Rt,v=d=>{if(Rt===i)return d();var f=O,p=Rt;De(null),Zn(i);var g=d();return De(f),Zn(p),g};return r&&s.set("length",at(e.length)),new Proxy(e,{defineProperty(d,f,p){(!("value"in p)||p.configurable===!1||p.enumerable===!1||p.writable===!1)&&no();var g=s.get(f);return g===void 0?v(()=>{var x=at(p.value);return s.set(f,x),x}):M(g,p.value,!0),!0},deleteProperty(d,f){var p=s.get(f);if(p===void 0){if(f in d){const g=v(()=>at(ee));s.set(f,g),fs(a)}}else M(p,ee),fs(a);return!0},get(d,f,p){var E;if(f===St)return e;var g=s.get(f),x=f in d;if(g===void 0&&(!x||(E=os(d,f))!=null&&E.writable)&&(g=v(()=>{var m=is(x?d[f]:ee),u=at(m);return u}),s.set(f,g)),g!==void 0){var w=n(g);return w===ee?void 0:w}return Reflect.get(d,f,p)},getOwnPropertyDescriptor(d,f){var p=Reflect.getOwnPropertyDescriptor(d,f);if(p&&"value"in p){var g=s.get(f);g&&(p.value=n(g))}else if(p===void 0){var x=s.get(f),w=x==null?void 0:x.v;if(x!==void 0&&w!==ee)return{enumerable:!0,configurable:!0,value:w,writable:!0}}return p},has(d,f){var w;if(f===St)return!0;var p=s.get(f),g=p!==void 0&&p.v!==ee||Reflect.has(d,f);if(p!==void 0||I!==null&&(!g||(w=os(d,f))!=null&&w.writable)){p===void 0&&(p=v(()=>{var E=g?is(d[f]):ee,m=at(E);return m}),s.set(f,p));var x=n(p);if(x===ee)return!1}return g},set(d,f,p,g){var L;var x=s.get(f),w=f in d;if(r&&f==="length")for(var E=p;E<x.v;E+=1){var m=s.get(E+"");m!==void 0?M(m,ee):E in d&&(m=v(()=>at(ee)),s.set(E+"",m))}if(x===void 0)(!w||(L=os(d,f))!=null&&L.writable)&&(x=v(()=>at(void 0)),M(x,is(p)),s.set(f,x));else{w=x.v!==ee;var u=v(()=>is(p));M(x,u)}var y=Reflect.getOwnPropertyDescriptor(d,f);if(y!=null&&y.set&&y.set.call(g,p),!w){if(r&&typeof f=="string"){var R=s.get("length"),j=Number(f);Number.isInteger(j)&&j>=R.v&&M(R,j+1)}fs(a)}return!0},ownKeys(d){n(a);var f=Reflect.ownKeys(d).filter(x=>{var w=s.get(x);return w===void 0||w.v!==ee});for(var[p,g]of s)g.v!==ee&&!(p in d)&&f.push(p);return f},setPrototypeOf(){ao()}})}function Gn(e){try{if(e!==null&&typeof e=="object"&&St in e)return e[St]}catch{}return e}function $o(e,t){return Object.is(Gn(e),Gn(t))}var Jn,La,Pa,ja;function Wo(){if(Jn===void 0){Jn=window,La=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,s=Text.prototype;Pa=os(t,"firstChild").get,ja=os(t,"nextSibling").get,Hn(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Hn(s)&&(s.__t=void 0)}}function st(e=""){return document.createTextNode(e)}function Rr(e){return Pa.call(e)}function xs(e){return ja.call(e)}function _(e,t){return Rr(e)}function qo(e,t=!1){{var s=Rr(e);return s instanceof Comment&&s.data===""?xs(s):s}}function h(e,t=1,s=!1){let r=e;for(;t--;)r=xs(r);return r}function Uo(e){e.textContent=""}function $a(){return!1}function Vo(e,t,s){return document.createElementNS(ga,e,void 0)}let Qn=!1;function zo(){Qn||(Qn=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const s of e.target.elements)(t=s.__on_r)==null||t.call(s)})},{capture:!0}))}function qs(e){var t=O,s=I;De(null),Ie(null);try{return e()}finally{De(t),Ie(s)}}function Wa(e,t,s,r=s){e.addEventListener(t,()=>qs(s));const a=e.__on_r;a?e.__on_r=()=>{a(),r(!0)}:e.__on_r=()=>r(!0),zo()}function qa(e){I===null&&(O===null&&so(),to()),dt&&eo()}function Ho(e,t){var s=t.last;s===null?t.last=t.first=e:(s.next=e,e.prev=s,t.last=e)}function Ye(e,t){var s=I;s!==null&&s.f&ce&&(e|=ce);var r={ctx:z,deps:null,nodes:null,f:e|ae|Ce,first:null,fn:t,last:null,next:null,parent:s,b:s&&s.b,prev:null,teardown:null,wv:0,ac:null};T==null||T.register_created_effect(r);var a=r;if(e&Bt)$t!==null?$t.push(r):Nt.ensure().schedule(r);else if(t!==null){try{Dt(r)}catch(v){throw pe(r),v}a.deps===null&&a.teardown===null&&a.nodes===null&&a.first===a.last&&!(a.f&Jt)&&(a=a.first,e&Ke&&e&Kt&&a!==null&&(a.f|=Kt))}if(a!==null&&(a.parent=s,s!==null&&Ho(a,s),O!==null&&O.f&le&&!(e&vt))){var i=O;(i.effects??(i.effects=[])).push(a)}return r}function Cr(){return O!==null&&!We}function Nr(e){const t=Ye(ys,null);return G(t,Q),t.teardown=e,t}function hr(e){qa();var t=I.f,s=!O&&(t&qe)!==0&&(t&It)===0;if(s){var r=z;(r.e??(r.e=[])).push(e)}else return Ua(e)}function Ua(e){return Ye(Bt|pa,e)}function Bo(e){return qa(),Ye(ys|pa,e)}function Ko(e){Nt.ensure();const t=Ye(vt|Jt,e);return(s={})=>new Promise(r=>{s.outro?At(t,()=>{pe(t),r(void 0)}):(pe(t),r(void 0))})}function Yo(e){return Ye(Bt,e)}function be(e,t){var s=z,r={effect:null,ran:!1,deps:e};s.l.$.push(r),r.effect=Us(()=>{if(e(),!r.ran){r.ran=!0;var a=I;try{Ie(a.parent),b(t)}finally{Ie(a)}}})}function Go(){var e=z;Us(()=>{for(var t of e.l.$){t.deps();var s=t.effect;s.f&Q&&s.deps!==null&&G(s,Ue),Qt(s)&&Dt(s),t.ran=!1}})}function Jo(e){return Ye(vs|Jt,e)}function Us(e,t=0){return Ye(ys|t,e)}function V(e,t=[],s=[],r=[]){Io(r,t,s,a=>{Ye(ys,()=>e(...a.map(n)))})}function Mr(e,t=0){var s=Ye(Ke|t,e);return s}function Re(e){return Ye(qe|Jt,e)}function Va(e){var t=e.teardown;if(t!==null){const s=dt,r=O;Xn(!0),De(null);try{t.call(null)}finally{Xn(s),De(r)}}}function Dr(e,t=!1){var s=e.first;for(e.first=e.last=null;s!==null;){const a=s.ac;a!==null&&qs(()=>{a.abort(Qe)});var r=s.next;s.f&vt?s.parent=null:pe(s,t),s=r}}function Qo(e){for(var t=e.first;t!==null;){var s=t.next;t.f&qe||pe(t),t=s}}function pe(e,t=!0){var s=!1;(t||e.f&Ql)&&e.nodes!==null&&e.nodes.end!==null&&(Xo(e.nodes.start,e.nodes.end),s=!0),G(e,Bn),Dr(e,t&&!s),ds(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(const i of r)i.stop();Va(e),e.f^=Bn,e.f|=Ne;var a=e.parent;a!==null&&a.first!==null&&za(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Xo(e,t){for(;e!==null;){var s=e===t?null:xs(e);e.remove(),e=s}}function za(e){var t=e.parent,s=e.prev,r=e.next;s!==null&&(s.next=r),r!==null&&(r.prev=s),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=s))}function At(e,t,s=!0){var r=[];Ha(e,r,!0);var a=()=>{s&&pe(e),t&&t()},i=r.length;if(i>0){var v=()=>--i||a();for(var d of r)d.out(v)}else a()}function Ha(e,t,s){if(!(e.f&ce)){e.f^=ce;var r=e.nodes&&e.nodes.t;if(r!==null)for(const d of r)(d.is_global||s)&&t.push(d);for(var a=e.first;a!==null;){var i=a.next;if(!(a.f&vt)){var v=(a.f&Kt)!==0||(a.f&qe)!==0&&(e.f&Ke)!==0;Ha(a,t,v?s:!1)}a=i}}}function Ir(e){Ba(e,!0)}function Ba(e,t){if(e.f&ce){e.f^=ce,e.f&Q||(G(e,ae),Nt.ensure().schedule(e));for(var s=e.first;s!==null;){var r=s.next,a=(s.f&Kt)!==0||(s.f&qe)!==0;Ba(s,a?t:!1),s=r}var i=e.nodes&&e.nodes.t;if(i!==null)for(const v of i)(v.is_global||t)&&v.in()}}function Or(e,t){if(e.nodes)for(var s=e.nodes.start,r=e.nodes.end;s!==null;){var a=s===r?null:xs(s);t.append(s),s=a}}let Os=!1,dt=!1;function Xn(e){dt=e}let O=null,We=!1;function De(e){O=e}let I=null;function Ie(e){I=e}let Me=null;function Zo(e){O!==null&&(Me===null?Me=[e]:Me.push(e))}let de=null,me=0,ke=null;function ec(e){ke=e}let Ka=1,mt=0,Rt=mt;function Zn(e){Rt=e}function Ya(){return++Ka}function Qt(e){var t=e.f;if(t&ae)return!0;if(t&le&&(e.f&=~Ct),t&Ue){for(var s=e.deps,r=s.length,a=0;a<r;a++){var i=s[a];if(Qt(i)&&Da(i),i.wv>e.wv)return!0}t&Ce&&ne===null&&G(e,Q)}return!1}function Ga(e,t,s=!0){var r=e.reactions;if(r!==null&&!(Me!==null&&Ht.call(Me,e)))for(var a=0;a<r.length;a++){var i=r[a];i.f&le?Ga(i,t,!1):t===i&&(s?G(i,ae):i.f&Q&&G(i,Ue),Sr(i))}}function Ja(e){var u;var t=de,s=me,r=ke,a=O,i=Me,v=z,d=We,f=Rt,p=e.f;de=null,me=0,ke=null,O=p&(qe|vt)?null:e,Me=null,Yt(e.ctx),We=!1,Rt=++mt,e.ac!==null&&(qs(()=>{e.ac.abort(Qe)}),e.ac=null);try{e.f|=Fs;var g=e.fn,x=g();e.f|=It;var w=e.deps,E=T==null?void 0:T.is_fork;if(de!==null){var m;if(E||ds(e,me),w!==null&&me>0)for(w.length=me+de.length,m=0;m<de.length;m++)w[me+m]=de[m];else e.deps=w=de;if(Cr()&&e.f&Ce)for(m=me;m<w.length;m++)((u=w[m]).reactions??(u.reactions=[])).push(e)}else!E&&w!==null&&me<w.length&&(ds(e,me),w.length=me);if(Es()&&ke!==null&&!We&&w!==null&&!(e.f&(le|Ue|ae)))for(m=0;m<ke.length;m++)Ga(ke[m],e);if(a!==null&&a!==e){if(mt++,a.deps!==null)for(let y=0;y<s;y+=1)a.deps[y].rv=mt;if(t!==null)for(const y of t)y.rv=mt;ke!==null&&(r===null?r=ke:r.push(...ke))}return e.f&ft&&(e.f^=ft),x}catch(y){return xa(y)}finally{e.f^=Fs,de=t,me=s,ke=r,O=a,Me=i,Yt(v),We=d,Rt=f}}function tc(e,t){let s=t.reactions;if(s!==null){var r=Hl.call(s,e);if(r!==-1){var a=s.length-1;a===0?s=t.reactions=null:(s[r]=s[a],s.pop())}}if(s===null&&t.f&le&&(de===null||!Ht.call(de,t))){var i=t;i.f&Ce&&(i.f^=Ce,i.f&=~Ct),i.v!==ee&&xr(i),Po(i),ds(i,0)}}function ds(e,t){var s=e.deps;if(s!==null)for(var r=t;r<s.length;r++)tc(e,s[r])}function Dt(e){var t=e.f;if(!(t&Ne)){G(e,Q);var s=I,r=Os;I=e,Os=!0;try{t&(Ke|da)?Qo(e):Dr(e),Va(e);var a=Ja(e);e.teardown=typeof a=="function"?a:null,e.wv=Ka;var i;zl&&bo&&e.f&ae&&e.deps}finally{Os=r,I=s}}}async function sc(){await Promise.resolve(),ko()}function n(e){var t=e.f,s=(t&le)!==0;if(O!==null&&!We){var r=I!==null&&(I.f&Ne)!==0;if(!r&&(Me===null||!Ht.call(Me,e))){var a=O.deps;if(O.f&Fs)e.rv<mt&&(e.rv=mt,de===null&&a!==null&&a[me]===e?me++:de===null?de=[e]:de.push(e));else{(O.deps??(O.deps=[])).push(e);var i=e.reactions;i===null?e.reactions=[O]:Ht.call(i,O)||i.push(O)}}}if(dt&&Tt.has(e))return Tt.get(e);if(s){var v=e;if(dt){var d=v.v;return(!(v.f&Q)&&v.reactions!==null||Xa(v))&&(d=Ar(v)),Tt.set(v,d),d}var f=(v.f&Ce)===0&&!We&&O!==null&&(Os||(O.f&Ce)!==0),p=(v.f&It)===0;Qt(v)&&(f&&(v.f|=Ce),Da(v)),f&&!p&&(Ia(v),Qa(v))}if(ne!=null&&ne.has(e))return ne.get(e);if(e.f&ft)throw e.v;return e.v}function Qa(e){if(e.f|=Ce,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),t.f&le&&!(t.f&Ce)&&(Ia(t),Qa(t))}function Xa(e){if(e.v===ee)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(Tt.has(t)||t.f&le&&Xa(t))return!0;return!1}function b(e){var t=We;try{return We=!0,e()}finally{We=t}}function rc(e){if(!(typeof e!="object"||!e||e instanceof EventTarget)){if(St in e)gr(e);else if(!Array.isArray(e))for(let t in e){const s=e[t];typeof s=="object"&&s&&St in s&&gr(s)}}}function gr(e,t=new Set){if(typeof e=="object"&&e!==null&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let r in e)try{gr(e[r],t)}catch{}const s=Er(e);if(s!==Object.prototype&&s!==Array.prototype&&s!==Map.prototype&&s!==Set.prototype&&s!==Date.prototype){const r=ua(s);for(let a in r){const i=r[a].get;if(i)try{i.call(e)}catch{}}}}}const nc=["touchstart","touchmove"];function ac(e){return nc.includes(e)}const Ss=Symbol("events"),ic=new Set,ea=new Set;function lc(e,t,s,r={}){function a(i){if(r.capture||br.call(t,i),!i.cancelBubble)return qs(()=>s==null?void 0:s.call(this,i))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?ut(()=>{t.addEventListener(e,a,r)}):t.addEventListener(e,a,r),a}function ta(e,t,s,r,a){var i={capture:r,passive:a},v=lc(e,t,s,i);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Nr(()=>{t.removeEventListener(e,v,i)})}let sa=null;function br(e){var y,R;var t=this,s=t.ownerDocument,r=e.type,a=((y=e.composedPath)==null?void 0:y.call(e))||[],i=a[0]||e.target;sa=e;var v=0,d=sa===e&&e[Ss];if(d){var f=a.indexOf(d);if(f!==-1&&(t===document||t===window)){e[Ss]=t;return}var p=a.indexOf(t);if(p===-1)return;f<=p&&(v=f)}if(i=a[v]||e.target,i!==t){Bl(e,"currentTarget",{configurable:!0,get(){return i||s}});var g=O,x=I;De(null),Ie(null);try{for(var w,E=[];i!==null;){var m=i.assignedSlot||i.parentNode||i.host||null;try{var u=(R=i[Ss])==null?void 0:R[r];u!=null&&(!i.disabled||e.target===i)&&u.call(i,e)}catch(j){w?E.push(j):w=j}if(e.cancelBubble||m===t||m===null)break;i=m}if(w){for(let j of E)queueMicrotask(()=>{throw j});throw w}}finally{e[Ss]=t,delete e.currentTarget,De(g),Ie(x)}}}var ca;const rr=((ca=globalThis==null?void 0:globalThis.window)==null?void 0:ca.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function oc(e){return(rr==null?void 0:rr.createHTML(e))??e}function cc(e){var t=Vo("template");return t.innerHTML=oc(e.replaceAll("<!>","<!---->")),t.content}function Fr(e,t){var s=I;s.nodes===null&&(s.nodes={start:e,end:t,a:null,t:null})}function W(e,t){var s=(t&vo)!==0,r,a=!e.startsWith("<!>");return()=>{r===void 0&&(r=cc(a?e:"<!>"+e),r=Rr(r));var i=s||La?document.importNode(r,!0):r.cloneNode(!0);return Fr(i,i),i}}function ra(e=""){{var t=st(e+"");return Fr(t,t),t}}function fc(){var e=document.createDocumentFragment(),t=document.createComment(""),s=st();return e.append(t,s),Fr(t,s),e}function F(e,t){e!==null&&e.before(t)}function k(e,t){var s=t==null?"":typeof t=="object"?`${t}`:t;s!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=s,e.nodeValue=`${s}`)}function uc(e,t){return vc(e,t)}const Ts=new Map;function vc(e,{target:t,anchor:s,props:r={},events:a,context:i,intro:v=!0,transformError:d}){Wo();var f=void 0,p=Ko(()=>{var g=s??t.appendChild(st());Ro(g,{pending:()=>{}},E=>{ya({});var m=z;i&&(m.c=i),a&&(r.$$events=a),f=e(E,r)||{},wa()},d);var x=new Set,w=E=>{for(var m=0;m<E.length;m++){var u=E[m];if(!x.has(u)){x.add(u);var y=ac(u);for(const L of[t,document]){var R=Ts.get(L);R===void 0&&(R=new Map,Ts.set(L,R));var j=R.get(u);j===void 0?(L.addEventListener(u,br,{passive:y}),R.set(u,1)):R.set(u,j+1)}}}};return w(Ws(ic)),ea.add(w),()=>{var y;for(var E of x)for(const R of[t,document]){var m=Ts.get(R),u=m.get(E);--u==0?(R.removeEventListener(E,br),m.delete(E),m.size===0&&Ts.delete(R)):m.set(E,u)}ea.delete(w),g!==s&&((y=g.parentNode)==null||y.removeChild(g))}});return dc.set(f,p),f}let dc=new WeakMap;var $e,He,Ee,kt,bs,ms,$s;class pc{constructor(t,s=!0){Pe(this,"anchor");N(this,$e,new Map);N(this,He,new Map);N(this,Ee,new Map);N(this,kt,new Set);N(this,bs,!0);N(this,ms,t=>{if(o(this,$e).has(t)){var s=o(this,$e).get(t),r=o(this,He).get(s);if(r)Ir(r),o(this,kt).delete(s);else{var a=o(this,Ee).get(s);a&&(o(this,He).set(s,a.effect),o(this,Ee).delete(s),a.fragment.lastChild.remove(),this.anchor.before(a.fragment),r=a.effect)}for(const[i,v]of o(this,$e)){if(o(this,$e).delete(i),i===t)break;const d=o(this,Ee).get(v);d&&(pe(d.effect),o(this,Ee).delete(v))}for(const[i,v]of o(this,He)){if(i===s||o(this,kt).has(i))continue;const d=()=>{if(Array.from(o(this,$e).values()).includes(i)){var p=document.createDocumentFragment();Or(v,p),p.append(st()),o(this,Ee).set(i,{effect:v,fragment:p})}else pe(v);o(this,kt).delete(i),o(this,He).delete(i)};o(this,bs)||!r?(o(this,kt).add(i),At(v,d,!1)):d()}}});N(this,$s,t=>{o(this,$e).delete(t);const s=Array.from(o(this,$e).values());for(const[r,a]of o(this,Ee))s.includes(r)||(pe(a.effect),o(this,Ee).delete(r))});this.anchor=t,D(this,bs,s)}ensure(t,s){var r=T,a=$a();if(s&&!o(this,He).has(t)&&!o(this,Ee).has(t))if(a){var i=document.createDocumentFragment(),v=st();i.append(v),o(this,Ee).set(t,{effect:Re(()=>s(v)),fragment:i})}else o(this,He).set(t,Re(()=>s(this.anchor)));if(o(this,$e).set(r,t),a){for(const[d,f]of o(this,He))d===t?r.unskip_effect(f):r.skip_effect(f);for(const[d,f]of o(this,Ee))d===t?r.unskip_effect(f.effect):r.skip_effect(f.effect);r.oncommit(o(this,ms)),r.ondiscard(o(this,$s))}else o(this,ms).call(this,r)}}$e=new WeakMap,He=new WeakMap,Ee=new WeakMap,kt=new WeakMap,bs=new WeakMap,ms=new WeakMap,$s=new WeakMap;function ue(e,t,s=!1){var r=new pc(e),a=s?Kt:0;function i(v,d){r.ensure(v,d)}Mr(()=>{var v=!1;t((d,f=0)=>{v=!0,i(f,d)}),v||i(-1,null)},a)}function _c(e,t,s){for(var r=[],a=t.length,i,v=t.length,d=0;d<a;d++){let x=t[d];At(x,()=>{if(i){if(i.pending.delete(x),i.done.add(x),i.pending.size===0){var w=e.outrogroups;mr(e,Ws(i.done)),w.delete(i),w.size===0&&(e.outrogroups=null)}}else v-=1},!1)}if(v===0){var f=r.length===0&&s!==null;if(f){var p=s,g=p.parentNode;Uo(g),g.append(p),e.items.clear()}mr(e,t,!f)}else i={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(i)}function mr(e,t,s=!0){var r;if(e.pending.size>0){r=new Set;for(const v of e.pending.values())for(const d of v)r.add(e.items.get(d).e)}for(var a=0;a<t.length;a++){var i=t[a];if(r!=null&&r.has(i)){i.f|=Be;const v=document.createDocumentFragment();Or(i,v)}else pe(t[a],s)}}var na;function jt(e,t,s,r,a,i=null){var v=e,d=new Map,f=(t&ha)!==0;if(f){var p=e;v=p.appendChild(st())}var g=null,x=Ma(()=>{var L=s();return wr(L)?L:L==null?[]:Ws(L)}),w,E=new Map,m=!0;function u(L){j.effect.f&Ne||(j.pending.delete(L),j.fallback=g,hc(j,w,v,t,r),g!==null&&(w.length===0?g.f&Be?(g.f^=Be,ls(g,null,v)):Ir(g):At(g,()=>{g=null})))}function y(L){j.pending.delete(L)}var R=Mr(()=>{w=n(x);for(var L=w.length,Z=new Set,te=T,_e=$a(),se=0;se<L;se+=1){var $=w[se],rt=r($,se),fe=m?null:d.get(rt);fe?(fe.v&&Gt(fe.v,$),fe.i&&Gt(fe.i,se),_e&&te.unskip_effect(fe.e)):(fe=gc(d,m?v:na??(na=st()),$,rt,se,a,t,s),m||(fe.e.f|=Be),d.set(rt,fe)),Z.add(rt)}if(L===0&&i&&!g&&(m?g=Re(()=>i(v)):(g=Re(()=>i(na??(na=st()))),g.f|=Be)),L>Z.size&&Zl(),!m)if(E.set(te,Z),_e){for(const[nt,pt]of d)Z.has(nt)||te.skip_effect(pt.e);te.oncommit(u),te.ondiscard(y)}else u(te);n(x)}),j={effect:R,items:d,pending:E,outrogroups:null,fallback:g};m=!1}function ns(e){for(;e!==null&&!(e.f&qe);)e=e.next;return e}function hc(e,t,s,r,a){var fe,nt,pt,_t,ks,Xt,Zt,es,ts;var i=(r&fo)!==0,v=t.length,d=e.items,f=ns(e.effect.first),p,g=null,x,w=[],E=[],m,u,y,R;if(i)for(R=0;R<v;R+=1)m=t[R],u=a(m,R),y=d.get(u).e,y.f&Be||((nt=(fe=y.nodes)==null?void 0:fe.a)==null||nt.measure(),(x??(x=new Set)).add(y));for(R=0;R<v;R+=1){if(m=t[R],u=a(m,R),y=d.get(u).e,e.outrogroups!==null)for(const Oe of e.outrogroups)Oe.pending.delete(y),Oe.done.delete(y);if(y.f&ce&&(Ir(y),i&&((_t=(pt=y.nodes)==null?void 0:pt.a)==null||_t.unfix(),(x??(x=new Set)).delete(y))),y.f&Be)if(y.f^=Be,y===f)ls(y,null,s);else{var j=g?g.next:f;y===e.effect.last&&(e.effect.last=y.prev),y.prev&&(y.prev.next=y.next),y.next&&(y.next.prev=y.prev),it(e,g,y),it(e,y,j),ls(y,j,s),g=y,w=[],E=[],f=ns(g.next);continue}if(y!==f){if(p!==void 0&&p.has(y)){if(w.length<E.length){var L=E[0],Z;g=L.prev;var te=w[0],_e=w[w.length-1];for(Z=0;Z<w.length;Z+=1)ls(w[Z],L,s);for(Z=0;Z<E.length;Z+=1)p.delete(E[Z]);it(e,te.prev,_e.next),it(e,g,te),it(e,_e,L),f=L,g=_e,R-=1,w=[],E=[]}else p.delete(y),ls(y,f,s),it(e,y.prev,y.next),it(e,y,g===null?e.effect.first:g.next),it(e,g,y),g=y;continue}for(w=[],E=[];f!==null&&f!==y;)(p??(p=new Set)).add(f),E.push(f),f=ns(f.next);if(f===null)continue}y.f&Be||w.push(y),g=y,f=ns(y.next)}if(e.outrogroups!==null){for(const Oe of e.outrogroups)Oe.pending.size===0&&(mr(e,Ws(Oe.done)),(ks=e.outrogroups)==null||ks.delete(Oe));e.outrogroups.size===0&&(e.outrogroups=null)}if(f!==null||p!==void 0){var se=[];if(p!==void 0)for(y of p)y.f&ce||se.push(y);for(;f!==null;)!(f.f&ce)&&f!==e.fallback&&se.push(f),f=ns(f.next);var $=se.length;if($>0){var rt=r&ha&&v===0?s:null;if(i){for(R=0;R<$;R+=1)(Zt=(Xt=se[R].nodes)==null?void 0:Xt.a)==null||Zt.measure();for(R=0;R<$;R+=1)(ts=(es=se[R].nodes)==null?void 0:es.a)==null||ts.fix()}_c(e,se,rt)}}i&&ut(()=>{var Oe,Ot;if(x!==void 0)for(y of x)(Ot=(Oe=y.nodes)==null?void 0:Oe.a)==null||Ot.apply()})}function gc(e,t,s,r,a,i,v,d){var f=v&oo?v&uo?Mt(s):Y(s,!1,!1):null,p=v&co?Mt(a):null;return{v:f,i:p,e:Re(()=>(i(t,f??s,p??a,d),()=>{e.delete(r)}))}}function ls(e,t,s){if(e.nodes)for(var r=e.nodes.start,a=e.nodes.end,i=t&&!(t.f&Be)?t.nodes.start:s;r!==null;){var v=xs(r);if(i.before(r),r===a)return;r=v}}function it(e,t,s){t===null?e.effect.first=s:t.next=s,s===null?e.effect.last=t:s.prev=t}const aa=[...`
2
- \r\f \v\uFEFF`];function bc(e,t,s){var r=e==null?"":""+e;if(s){for(var a of Object.keys(s))if(s[a])r=r?r+" "+a:a;else if(r.length)for(var i=a.length,v=0;(v=r.indexOf(a,v))>=0;){var d=v+i;(v===0||aa.includes(r[v-1]))&&(d===r.length||aa.includes(r[d]))?r=(v===0?"":r.substring(0,v))+r.substring(d+1):v=d}}return r===""?null:r}function mc(e,t){return e==null?null:String(e)}function as(e,t,s,r,a,i){var v=e.__className;if(v!==s||v===void 0){var d=bc(s,r,i);d==null?e.removeAttribute("class"):e.className=d,e.__className=s}else if(i&&a!==i)for(var f in i){var p=!!i[f];(a==null||p!==!!a[f])&&e.classList.toggle(f,p)}return i}function ia(e,t,s,r){var a=e.__style;if(a!==t){var i=mc(t);i==null?e.removeAttribute("style"):e.style.cssText=i,e.__style=t}return r}function Za(e,t,s=!1){if(e.multiple){if(t==null)return;if(!wr(t))return _o();for(var r of e.options)r.selected=t.includes(us(r));return}for(r of e.options){var a=us(r);if($o(a,t)){r.selected=!0;return}}(!s||t!==void 0)&&(e.selectedIndex=-1)}function yc(e){var t=new MutationObserver(()=>{Za(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Nr(()=>{t.disconnect()})}function nr(e,t,s=t){var r=new WeakSet,a=!0;Wa(e,"change",i=>{var v=i?"[selected]":":checked",d;if(e.multiple)d=[].map.call(e.querySelectorAll(v),us);else{var f=e.querySelector(v)??e.querySelector("option:not([disabled])");d=f&&us(f)}s(d),e.__value=d,T!==null&&r.add(T)}),Yo(()=>{var i=t();if(e===document.activeElement){var v=T;if(r.has(v))return}if(Za(e,i,a),a&&i===void 0){var d=e.querySelector(":checked");d!==null&&(i=us(d),s(i))}e.__value=i,a=!1}),yc(e)}function us(e){return"__value"in e?e.__value:e.value}const wc=Symbol("is custom element"),Ec=Symbol("is html");function xc(e,t,s,r){var a=kc(e);a[t]!==(a[t]=s)&&(s==null?e.removeAttribute(t):typeof s!="string"&&Sc(e).includes(t)?e[t]=s:e.setAttribute(t,s))}function kc(e){return e.__attributes??(e.__attributes={[wc]:e.nodeName.includes("-"),[Ec]:e.namespaceURI===ga})}var la=new Map;function Sc(e){var t=e.getAttribute("is")||e.nodeName,s=la.get(t);if(s)return s;la.set(t,s=[]);for(var r,a=e,i=Element.prototype;i!==a;){r=ua(a);for(var v in r)r[v].set&&s.push(v);a=Er(a)}return s}function As(e,t,s=t){var r=new WeakSet;Wa(e,"input",async a=>{var i=a?e.defaultValue:e.value;if(i=ar(e)?ir(i):i,s(i),T!==null&&r.add(T),await sc(),i!==(i=t())){var v=e.selectionStart,d=e.selectionEnd,f=e.value.length;if(e.value=i??"",d!==null){var p=e.value.length;v===d&&d===f&&p>f?(e.selectionStart=p,e.selectionEnd=p):(e.selectionStart=v,e.selectionEnd=Math.min(d,p))}}}),b(t)==null&&e.value&&(s(ar(e)?ir(e.value):e.value),T!==null&&r.add(T)),Us(()=>{var a=t();if(e===document.activeElement){var i=T;if(r.has(i))return}ar(e)&&a===ir(e.value)||e.type==="date"&&!a&&!e.value||a!==e.value&&(e.value=a??"")})}function ar(e){var t=e.type;return t==="number"||t==="range"}function ir(e){return e===""?null:+e}function Tc(e){return function(...t){var s=t[0];return s.preventDefault(),e==null?void 0:e.apply(this,t)}}function Ac(e=!1){const t=z,s=t.l.u;if(!s)return;let r=()=>rc(t.s);if(e){let a=0,i={};const v=Tr(()=>{let d=!1;const f=t.s;for(const p in f)f[p]!==i[p]&&(i[p]=f[p],d=!0);return d&&a++,a});r=()=>n(v)}s.b.length&&Bo(()=>{oa(t,r),lr(s.b)}),hr(()=>{const a=b(()=>s.m.map(Jl));return()=>{for(const i of a)typeof i=="function"&&i()}}),s.a.length&&hr(()=>{oa(t,r),lr(s.a)})}function oa(e,t){if(e.l.s)for(const s of e.l.s)n(s);t()}function Rc(e){z===null&&_a(),ws&&z.l!==null?Nc(z).m.push(e):hr(()=>{const t=b(e);if(typeof t=="function")return t})}function Cc(e){z===null&&_a(),Rc(()=>()=>b(e))}function Nc(e){var t=e.l;return t.u??(t.u={a:[],b:[],m:[]})}const Mc="5";var fa;typeof window<"u"&&((fa=window.__svelte??(window.__svelte={})).v??(fa.v=new Set)).add(Mc);mo();var Dc=W('<div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Watch issue</span><strong class="status-warn svelte-d3ct2b"> </strong></div>'),Ic=W('<section class="notice svelte-d3ct2b"> </section>'),Oc=W('<section class="notice danger svelte-d3ct2b"> </section>'),Fc=W('<p class="terminal-line svelte-d3ct2b"><time class="svelte-d3ct2b">--:--:--</time><span class="sys svelte-d3ct2b">SYS</span><strong class="svelte-d3ct2b">Waiting for memory-core watch output...</strong></p>'),Lc=W('<strong class="svelte-d3ct2b"> </strong>'),Pc=W('<strong class="svelte-d3ct2b"> </strong>'),jc=W('<strong class="svelte-d3ct2b"> </strong>'),$c=W('<strong class="svelte-d3ct2b"> </strong>'),Wc=W('<strong class="svelte-d3ct2b"> </strong>'),qc=W('<p class="svelte-d3ct2b"><b class="svelte-d3ct2b">Why:</b> </p>'),Uc=W('<p class="svelte-d3ct2b"><b class="svelte-d3ct2b">Issue:</b> </p>'),Vc=W('<p class="svelte-d3ct2b"><b class="svelte-d3ct2b">Fix:</b> </p>'),zc=W('<pre class="svelte-d3ct2b"> </pre>'),Hc=W('<div class="terminal-detail svelte-d3ct2b"><p class="svelte-d3ct2b"> </p> <p class="svelte-d3ct2b"><b class="svelte-d3ct2b">Rule:</b> </p> <!> <!> <!> <!></div>'),Bc=W('<section><p class="terminal-line svelte-d3ct2b"><time class="svelte-d3ct2b"> </time> <span class="svelte-d3ct2b"> </span> <!></p> <!></section>'),Kc=W('<div class="metric-row svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b"> </span> <strong class="svelte-d3ct2b"> </strong></div> <i class="svelte-d3ct2b"></i></div>'),Yc=W('<p class="empty svelte-d3ct2b">No rule counters yet.</p>'),Gc=W('<div class="metric-row warning svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b"> </span> <strong class="svelte-d3ct2b"> </strong></div> <i class="svelte-d3ct2b"></i></div>'),Jc=W('<p class="empty svelte-d3ct2b">No file counters yet.</p>'),Qc=W('<small class="svelte-d3ct2b"> </small>'),Xc=W('<small class="svelte-d3ct2b"> </small>'),Zc=W('<section class="commit-item svelte-d3ct2b"><div class="commit-meta svelte-d3ct2b"><span> </span> <time> </time></div> <strong class="svelte-d3ct2b"> </strong> <p class="svelte-d3ct2b"> </p> <!> <!></section>'),ef=W('<p class="empty svelte-d3ct2b">No commit hook violations recorded yet.</p>'),tf=W('<small class="svelte-d3ct2b"> </small>'),sf=W('<div class="rule-item svelte-d3ct2b"><div><div class="rule-meta svelte-d3ct2b"><span class="svelte-d3ct2b"> </span> <code class="svelte-d3ct2b"> </code></div> <p class="svelte-d3ct2b"> </p> <!></div> <button class="svelte-d3ct2b">Delete</button></div>'),rf=W('<p class="empty svelte-d3ct2b">No rules match the current filters.</p>'),nf=W('<div class="command-center svelte-d3ct2b"><aside class="sidebar svelte-d3ct2b"><div class="brand svelte-d3ct2b"><h1 class="svelte-d3ct2b">memory-core</h1> <span class="svelte-d3ct2b">command center</span></div> <nav aria-label="Dashboard navigation" class="svelte-d3ct2b"><a class="nav-item active svelte-d3ct2b" href="/"><span class="nav-icon svelte-d3ct2b">[]</span> <span>Command Center</span></a></nav> <div class="sidebar-footer svelte-d3ct2b"><div><i class="svelte-d3ct2b"></i> </div> <small class="svelte-d3ct2b"> </small></div></aside> <div class="workspace svelte-d3ct2b"><header class="topbar svelte-d3ct2b"><div class="topbar-left svelte-d3ct2b"><button class="icon-button mobile-menu svelte-d3ct2b" aria-label="Menu">=</button> <div><i class="svelte-d3ct2b"></i> <span> </span></div></div> <div class="header-metrics svelte-d3ct2b" aria-label="Global metrics"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Violations</span> <strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Files</span> <strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Rules</span> <strong class="svelte-d3ct2b"> </strong></div></div> <div class="top-actions svelte-d3ct2b" aria-label="Status shortcuts"><button class="icon-button svelte-d3ct2b" title="Warnings" aria-label="Warnings">!</button> <button class="icon-button svelte-d3ct2b" title="Rules" aria-label="Rules">R</button> <button class="icon-button svelte-d3ct2b" title="Database" aria-label="Database">DB</button> <button class="icon-button svelte-d3ct2b" title="Network" aria-label="Network">LAN</button></div></header> <main class="canvas svelte-d3ct2b"><section class="status-grid svelte-d3ct2b"><article class="glass-panel status-card svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Project</h2> <span class="svelte-d3ct2b"> </span></div> <div class="data-list svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Name</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Type</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Language</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Architecture</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Watcher</span><strong class="svelte-d3ct2b"> </strong></div> <!></div></article> <article class="glass-panel status-card svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Runtime</h2> <span class="svelte-d3ct2b"> </span></div> <div class="data-list svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Provider</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Check model</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Check status</span> <strong><!></strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Embedding</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Ollama URL</span><strong class="svelte-d3ct2b"> </strong></div></div></article> <article class="glass-panel status-card svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">PostgreSQL</h2> <span> </span></div> <div class="data-list svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Database</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">User</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Host</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">URL</span><strong class="svelte-d3ct2b"> </strong></div></div></article></section> <!> <!> <section class="terminal-panel glass-panel svelte-d3ct2b"><div class="terminal-head svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="terminal-icon svelte-d3ct2b">&gt;_</span> <h2 class="svelte-d3ct2b">Live Feed</h2></div> <div class="window-dots svelte-d3ct2b" aria-hidden="true"><i class="svelte-d3ct2b"></i><i class="svelte-d3ct2b"></i><i class="svelte-d3ct2b"></i></div></div> <div class="terminal-body svelte-d3ct2b"><!> <!></div></section> <section class="content-grid svelte-d3ct2b"><article class="glass-panel stats-panel svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Stats</h2> <span class="svelte-d3ct2b">Recorded</span></div> <div class="stat-block svelte-d3ct2b"><h3 class="svelte-d3ct2b">Most Violated Rules</h3> <!></div> <div class="stat-block svelte-d3ct2b"><h3 class="svelte-d3ct2b">Problem Files</h3> <!></div> <div class="summary-strip svelte-d3ct2b"><div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Clean</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Issues</span><strong class="svelte-d3ct2b"> </strong></div> <div class="svelte-d3ct2b"><span class="svelte-d3ct2b">Events</span><strong class="svelte-d3ct2b"> </strong></div></div></article> <article class="glass-panel commit-watch svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Commit Watch</h2> <span class="svelte-d3ct2b"> </span></div> <div class="commit-list svelte-d3ct2b"></div></article> <article class="glass-panel rule-engine svelte-d3ct2b"><div class="card-head svelte-d3ct2b"><h2 class="svelte-d3ct2b">Rule Engine</h2> <span class="svelte-d3ct2b"> </span></div> <form class="rule-form svelte-d3ct2b"><div class="control-grid svelte-d3ct2b"><select class="svelte-d3ct2b"><option>Rule</option><option>Decision</option><option>Pattern</option><option>Ignore</option></select> <select class="svelte-d3ct2b"><option>Project</option><option>Global</option></select></div> <textarea rows="3" placeholder="Rule or decision" class="svelte-d3ct2b"></textarea> <div class="control-grid svelte-d3ct2b"><input placeholder="Reason" class="svelte-d3ct2b"/> <input placeholder="Tags" class="svelte-d3ct2b"/></div> <button class="svelte-d3ct2b"> </button></form> <div class="control-grid filters svelte-d3ct2b"><select class="svelte-d3ct2b"><option>All types</option><option>Rules</option><option>Decisions</option><option>Patterns</option><option>Ignores</option></select> <input placeholder="Search rules..." class="svelte-d3ct2b"/></div> <div class="rule-list svelte-d3ct2b"></div></article></section></main></div></div>');function af(e,t){ya(t,!1);const s=Y(),r=Y(),a=Y(),i=Y(),v=Y(),d=Y(),f=Y(),p=Y(),g=Y(),x=Y(),w=Y(),E=Y(),m=Y();let u=Y({config:null,stats:{rules:{},files:{},topRules:[],topFiles:[]},files:[],memories:[]}),y=Y([]),R=Y(!1),j=Y("all"),L=Y(""),Z=Y(!1),te=Y(""),_e,se=!1,$=Y({type:"rule",scope:"project",content:"",reason:"",tags:"dashboard"});const rt=()=>{var l;return((l=n(u).runtime)==null?void 0:l.project.name)??"memory-core"},fe=()=>{var A,C;const l=((A=n(u).runtime)==null?void 0:A.project.declaredArchitectures)??[],c=((C=n(u).runtime)==null?void 0:C.project.activeArchitectures)??[];return l.length>0?l.join(", "):c.length>0?c.join(", "):"none"};function nt(l){M(y,[{...l,id:crypto.randomUUID()},...n(y)].slice(0,80))}function pt(l){return l.type==="saved"?{type:"saved",timestamp:l.timestamp,file:l.file}:l.type==="clean"?{type:"clean",timestamp:l.timestamp,file:l.file}:l.type==="skipped"?{type:"skipped",timestamp:l.timestamp,file:l.file,reason:l.reason}:l.type==="violations"?{type:"violations",timestamp:l.timestamp,file:l.file,violations:l.violations}:l.type==="error"?{type:"error",timestamp:l.timestamp,message:l.message}:l.type==="ready"?{type:"system",timestamp:l.timestamp,message:`Watching ${l.path} | ${l.rules} rules | ${l.model}`}:{type:"system",timestamp:l.timestamp,message:"Watch stopped"}}function _t(l){const c=n(u).files??[],A=c.findIndex(H=>H.file===l.file),C=c.slice();return A===-1?C.push(l):C[A]=l,C.sort((H,ie)=>ie.lastSeen.localeCompare(H.lastSeen))}function ks(l){const c=n(u).watcher??{enabled:!0,running:!1,path:void 0,model:void 0,rules:void 0,lastEventAt:void 0,error:void 0};let A=n(u).files,C={...c,lastEventAt:l.timestamp,enabled:!0};l.type==="ready"&&(C={...C,running:!0,error:void 0,path:l.path,model:l.model,rules:l.rules}),l.type==="saved"&&(A=_t({file:l.file,status:"checking",lastSeen:l.timestamp,violations:[]})),l.type==="clean"&&(A=_t({file:l.file,status:"clean",lastSeen:l.timestamp,violations:[]})),l.type==="skipped"&&(A=_t({file:l.file,status:"skipped",lastSeen:l.timestamp,violations:[],message:l.reason})),l.type==="violations"&&(A=_t({file:l.file,status:"violations",lastSeen:l.timestamp,violations:l.violations})),l.type==="error"&&(C={...C,running:!1,error:l.message}),l.type==="stopped"&&(C={...C,running:!1});const H=[l,...n(u).events??[]].slice(0,100);M(u,{...n(u),files:A,events:H,watcher:C})}function Xt(l=[]){M(y,l.map(pt).map(c=>({...c,id:crypto.randomUUID()})).reverse().slice(0,80))}function Zt(l){return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(l))}function es(l){return Math.max(1,...l.map(c=>c.count))}function ts(l,c){const A=l.file||c;return l.line?`${A}:${l.line}`:A}function Oe(l){return l.type==="saved"?"SAVE":l.type==="clean"?"OK":l.type==="skipped"?"SKIP":l.type==="violations"?"FAIL":l.type==="error"?"WARN":"SYS"}async function Ot(){const l=await fetch("/api/snapshot");M(u,await l.json()),Xt(n(u).events)}async function ei(){if(!se&&document.visibilityState!=="hidden"){se=!0;try{const l=await fetch("/api/stats",{cache:"no-store"});if(!l.ok)return;const c=await l.json();if(!c.stats)return;M(u,{...n(u),stats:c.stats})}catch{}finally{se=!1}}}function ti(){_e&&clearInterval(_e),_e=setInterval(()=>{ei()},2e3)}function Lr(){const l=location.protocol==="https:"?"wss:":"ws:",c=new WebSocket(`${l}//${location.host}/ws`);c.addEventListener("open",()=>{M(R,!0),nt({type:"system",timestamp:new Date().toISOString(),message:"Dashboard connected"})}),c.addEventListener("close",()=>{M(R,!1),nt({type:"error",timestamp:new Date().toISOString(),message:"Dashboard disconnected"}),setTimeout(Lr,1500)}),c.addEventListener("message",A=>{const C=JSON.parse(A.data);if(C.type==="snapshot"){M(u,C.snapshot),n(y).length===0&&Xt(n(u).events);return}C.type==="watch"&&(ks(C.event),nt(pt(C.event)))})}async function si(){if(n($).content.trim()){M(Z,!0),M(te,"");try{const l=await fetch("/api/memories",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n($))});if(!l.ok)throw new Error((await l.json()).error??"Save failed");M($,{type:"rule",scope:"project",content:"",reason:"",tags:"dashboard"}),await Ot()}catch(l){M(te,l.message)}finally{M(Z,!1)}}}async function ri(l){M(te,"");const c=await fetch(`/api/memories/${l}`,{method:"DELETE"});if(!c.ok){M(te,(await c.json()).error??"Delete failed");return}await Ot()}Ot().catch(l=>{M(te,l.message)}),Lr(),ti(),Cc(()=>{_e&&(clearInterval(_e),_e=void 0)}),be(()=>(n(u),n(j),n(L)),()=>{M(s,n(u).memories.filter(l=>{const c=n(j)==="all"||l.type===n(j),A=`${l.type} ${l.scope} ${l.content} ${l.reason??""} ${l.tags.join(" ")}`.toLowerCase();return c&&A.includes(n(L).toLowerCase())}))}),be(()=>n(u),()=>{M(r,n(u).files.reduce((l,c)=>l+c.violations.length,0))}),be(()=>n(u),()=>{M(a,n(u).files.filter(l=>l.status==="clean").length)}),be(()=>n(u),()=>{M(i,n(u).files.filter(l=>l.status==="violations").length)}),be(()=>n(u),()=>{M(v,Object.values(n(u).stats.rules).reduce((l,c)=>l+c,0))}),be(()=>n(u),()=>{M(d,n(u).stats.recentViolations??[])}),be(()=>n(d),()=>{M(f,n(d).filter(l=>l.source==="hook"||l.source==="ci"))}),be(()=>(n(r),n(f)),()=>{M(p,n(r)+n(f).length)}),be(()=>(n(u),n(f)),()=>{M(g,new Set([...n(u).files.map(l=>l.file),...n(f).map(l=>l.file).filter(Boolean)]).size)}),be(()=>n(u),()=>{M(x,n(u).memories.filter(l=>["rule","pattern","decision"].includes(l.type)).length)}),be(()=>n(u),()=>{var l;M(w,((l=n(u).memoryCount)==null?void 0:l.total)??n(u).memories.length)}),be(()=>n(u),()=>{var l;M(E,((l=n(u).memoryCount)==null?void 0:l.relevant)??n(u).memories.length)}),be(()=>(n(R),n(u)),()=>{var l,c;M(m,n(R)?((l=n(u).watcher)==null?void 0:l.enabled)===!1?{live:!1,label:"Watch off"}:(c=n(u).watcher)!=null&&c.running?{live:!0,label:"Watcher live"}:{live:!1,label:"Watcher idle"}:{live:!1,label:"Disconnected"})}),Go(),Ac();var Pr=nf(),jr=_(Pr),ni=h(_(jr),4),Vs=_(ni);let $r;var ai=h(_(Vs)),ii=h(Vs,2),li=_(ii),oi=h(jr,2),Wr=_(oi),qr=_(Wr),Ur=h(_(qr),2);let Vr;var ci=h(_(Ur),2),fi=_(ci),ui=h(qr,2),zr=_(ui),vi=h(_(zr),2),di=_(vi),Hr=h(zr,2),pi=h(_(Hr),2),_i=_(pi),hi=h(Hr,2),gi=h(_(hi),2),bi=_(gi),mi=h(Wr,2),Br=_(mi),Kr=_(Br),Yr=_(Kr),yi=h(_(Yr),2),wi=_(yi),Ei=h(Yr,2),Gr=_(Ei),xi=h(_(Gr)),ki=_(xi),Jr=h(Gr,2),Si=h(_(Jr)),Ti=_(Si),Qr=h(Jr,2),Ai=h(_(Qr)),Ri=_(Ai),Xr=h(Qr,2),Ci=h(_(Xr)),Ni=_(Ci),Zr=h(Xr,2),Mi=h(_(Zr)),Di=_(Mi),Ii=h(Zr,2);{var Oi=l=>{var c=Dc(),A=h(_(c)),C=_(A);V(()=>k(C,(n(u),b(()=>n(u).watcher.error)))),F(l,c)};ue(Ii,l=>{n(u),b(()=>{var c;return(c=n(u).watcher)==null?void 0:c.error})&&l(Oi)})}var en=h(Kr,2),tn=_(en),Fi=h(_(tn),2),Li=_(Fi),Pi=h(tn,2),sn=_(Pi),ji=h(_(sn)),$i=_(ji),rn=h(sn,2),Wi=h(_(rn)),qi=_(Wi),nn=h(rn,2),an=h(_(nn),2);let ln;var Ui=_(an);{var Vi=l=>{var c=ra();V(()=>k(c,(n(u),b(()=>{var A;return(A=n(u).runtime)!=null&&A.model.checkModelInstalled?"installed":"missing"})))),F(l,c)},zi=l=>{var c=ra();V(()=>k(c,(n(u),b(()=>{var A;return(A=n(u).runtime)!=null&&A.model.apiKeyConfigured?"api key set":"api key missing"})))),F(l,c)};ue(Ui,l=>{n(u),b(()=>{var c;return((c=n(u).runtime)==null?void 0:c.model.provider)==="ollama"})?l(Vi):l(zi,-1)})}var on=h(nn,2),Hi=h(_(on)),Bi=_(Hi),Ki=h(on,2),Yi=h(_(Ki)),Gi=_(Yi),Ji=h(en,2),cn=_(Ji),fn=h(_(cn),2);let un;var Qi=_(fn),Xi=h(cn,2),vn=_(Xi),Zi=h(_(vn)),el=_(Zi),dn=h(vn,2),tl=h(_(dn)),sl=_(tl),pn=h(dn,2),rl=h(_(pn)),nl=_(rl),al=h(pn,2),il=h(_(al)),ll=_(il),_n=h(Br,2);{var ol=l=>{var c=Ic(),A=_(c);V(()=>k(A,(n(u),b(()=>n(u).dbError)))),F(l,c)};ue(_n,l=>{n(u),b(()=>n(u).dbError)&&l(ol)})}var hn=h(_n,2);{var cl=l=>{var c=Oc(),A=_(c);V(()=>k(A,n(te))),F(l,c)};ue(hn,l=>{n(te)&&l(cl)})}var gn=h(hn,2),fl=h(_(gn),2),bn=_(fl);{var ul=l=>{var c=Fc();F(l,c)};ue(bn,l=>{n(y),b(()=>n(y).length===0)&&l(ul)})}var vl=h(bn,2);jt(vl,1,()=>(n(y),b(()=>[...n(y)].reverse())),l=>l.id,(l,c)=>{var A=Bc();let C;var H=_(A),ie=_(H),xe=_(ie),he=h(ie,2),S=_(he),q=h(he,2);{var Ge=P=>{var B=Lc(),Fe=_(B);V(()=>k(Fe,(n(c),b(()=>n(c).message)))),F(P,B)},ss=P=>{var B=Pc(),Fe=_(B);V(()=>k(Fe,`saved: ${n(c),b(()=>n(c).file)??""}`)),F(P,B)},Ft=P=>{var B=jc(),Fe=_(B);V(()=>k(Fe,`${n(c),b(()=>n(c).file)??""} - no violations`)),F(P,B)},Lt=P=>{var B=$c(),Fe=_(B);V(()=>k(Fe,`${n(c),b(()=>n(c).file)??""} - skipped: ${n(c),b(()=>n(c).reason)??""}`)),F(P,B)},Je=P=>{var B=Wc(),Fe=_(B);V(()=>k(Fe,`${n(c),b(()=>n(c).violations.length)??""} violation${n(c),b(()=>n(c).violations.length===1?"":"s")??""} in ${n(c),b(()=>n(c).file)??""}`)),F(P,B)};ue(q,P=>{n(c),b(()=>n(c).type==="system"||n(c).type==="error")?P(Ge):(n(c),b(()=>n(c).type==="saved")?P(ss,1):(n(c),b(()=>n(c).type==="clean")?P(Ft,2):(n(c),b(()=>n(c).type==="skipped")?P(Lt,3):P(Je,-1))))})}var Pt=h(H,2);{var ge=P=>{var B=fc(),Fe=qo(B);jt(Fe,3,()=>(n(c),b(()=>n(c).violations)),(Pn,K)=>`${n(c).id}-${K}`,(Pn,K,Ol)=>{var jn=Hc(),$n=_(jn),Fl=_($n),Wn=h($n,2),Ll=h(_(Wn)),qn=h(Wn,2);{var Pl=re=>{var Le=qc(),ht=h(_(Le));V(()=>k(ht,` ${n(K),b(()=>n(K).reason)??""}`)),F(re,Le)};ue(qn,re=>{n(K),b(()=>n(K).reason)&&re(Pl)})}var Un=h(qn,2);{var jl=re=>{var Le=Uc(),ht=h(_(Le));V(()=>k(ht,` ${n(K),b(()=>n(K).issue)??""}`)),F(re,Le)};ue(Un,re=>{n(K),b(()=>n(K).issue)&&re(jl)})}var Vn=h(Un,2);{var $l=re=>{var Le=Vc(),ht=h(_(Le));V(()=>k(ht,` ${n(K),b(()=>n(K).suggestion)??""}`)),F(re,Le)};ue(Vn,re=>{n(K),b(()=>n(K).suggestion)&&re($l)})}var Wl=h(Vn,2);{var ql=re=>{var Le=zc(),ht=_(Le);V(()=>k(ht,(n(K),b(()=>n(K).code)))),F(re,Le)};ue(Wl,re=>{n(K),b(()=>n(K).code)&&re(ql)})}V(re=>{k(Fl,`[${n(Ol)+1}] ${re??""}`),k(Ll,` ${n(K),b(()=>n(K).rule)??""}`)},[()=>(n(K),n(c),b(()=>ts(n(K),n(c).file)))]),F(Pn,jn)}),F(P,B)};ue(Pt,P=>{n(c),b(()=>n(c).type==="violations")&&P(ge)})}V((P,B)=>{C=as(A,1,"svelte-d3ct2b",null,C,{"error-line":n(c).type==="error","ok-line":n(c).type==="clean","violation-line":n(c).type==="violations"}),k(xe,P),k(S,B)},[()=>(n(c),b(()=>Zt(n(c).timestamp))),()=>(n(c),b(()=>Oe(n(c))))]),F(l,A)});var dl=h(gn,2),mn=_(dl),yn=h(_(mn),2),pl=h(_(yn),2);jt(pl,1,()=>(n(u),b(()=>n(u).stats.topRules.slice(0,5))),l=>l.name,(l,c)=>{var A=Kc(),C=_(A),H=_(C),ie=_(H),xe=h(H,2),he=_(xe),S=h(C,2);V(q=>{k(ie,(n(c),b(()=>n(c).name))),k(he,(n(c),b(()=>n(c).count))),ia(S,q)},[()=>(n(c),n(u),b(()=>`width: ${n(c).count/es(n(u).stats.topRules)*100}%`))]),F(l,A)},l=>{var c=Yc();F(l,c)});var wn=h(yn,2),_l=h(_(wn),2);jt(_l,1,()=>(n(u),b(()=>n(u).stats.topFiles.slice(0,5))),l=>l.name,(l,c)=>{var A=Gc(),C=_(A),H=_(C),ie=_(H),xe=h(H,2),he=_(xe),S=h(C,2);V(q=>{k(ie,(n(c),b(()=>n(c).name))),k(he,(n(c),b(()=>n(c).count))),ia(S,q)},[()=>(n(c),n(u),b(()=>`width: ${n(c).count/es(n(u).stats.topFiles)*100}%`))]),F(l,A)},l=>{var c=Jc();F(l,c)});var hl=h(wn,2),En=_(hl),gl=h(_(En)),bl=_(gl),xn=h(En,2),ml=h(_(xn)),yl=_(ml),wl=h(xn,2),El=h(_(wl)),xl=_(El),kn=h(mn,2),Sn=_(kn),kl=h(_(Sn),2),Sl=_(kl),Tl=h(Sn,2);jt(Tl,7,()=>(n(f),b(()=>n(f).slice(0,8))),(l,c)=>`${l.timestamp}-${c}`,(l,c)=>{var A=Zc(),C=_(A),H=_(C),ie=_(H),xe=h(H,2),he=_(xe),S=h(C,2),q=_(S),Ge=h(S,2),ss=_(Ge),Ft=h(Ge,2);{var Lt=ge=>{var P=Qc(),B=_(P);V(()=>k(B,(n(c),b(()=>n(c).issue)))),F(ge,P)};ue(Ft,ge=>{n(c),b(()=>n(c).issue)&&ge(Lt)})}var Je=h(Ft,2);{var Pt=ge=>{var P=Xc(),B=_(P);V(()=>k(B,(n(c),b(()=>n(c).suggestion)))),F(ge,P)};ue(Je,ge=>{n(c),b(()=>n(c).suggestion)&&ge(Pt)})}V((ge,P)=>{k(ie,(n(c),b(()=>n(c).source==="ci"?"CI":"Hook"))),k(he,ge),k(q,(n(c),b(()=>n(c).rule))),k(ss,P)},[()=>(n(c),b(()=>Zt(n(c).timestamp))),()=>(n(c),b(()=>ts(n(c),n(c).file||"staged diff")))]),F(l,A)},l=>{var c=ef();F(l,c)});var Al=h(kn,2),Tn=_(Al),Rl=h(_(Tn),2),Cl=_(Rl),zs=h(Tn,2),An=_(zs),Hs=_(An),Bs=_(Hs);Bs.value=Bs.__value="rule";var Ks=h(Bs);Ks.value=Ks.__value="decision";var Ys=h(Ks);Ys.value=Ys.__value="pattern";var Rn=h(Ys);Rn.value=Rn.__value="ignore";var Cn=h(Hs,2),Gs=_(Cn);Gs.value=Gs.__value="project";var Nn=h(Gs);Nn.value=Nn.__value="global";var Mn=h(An,2),Dn=h(Mn,2),In=_(Dn),Nl=h(In,2),On=h(Dn,2),Ml=_(On),Fn=h(zs,2),Js=_(Fn),Qs=_(Js);Qs.value=Qs.__value="all";var Xs=h(Qs);Xs.value=Xs.__value="rule";var Zs=h(Xs);Zs.value=Zs.__value="decision";var er=h(Zs);er.value=er.__value="pattern";var Ln=h(er);Ln.value=Ln.__value="ignore";var Dl=h(Js,2),Il=h(Fn,2);jt(Il,5,()=>n(s),l=>l.id,(l,c)=>{var A=sf(),C=_(A),H=_(C),ie=_(H),xe=_(ie),he=h(ie,2),S=_(he),q=h(H,2),Ge=_(q),ss=h(q,2);{var Ft=Je=>{var Pt=tf(),ge=_(Pt);V(()=>k(ge,(n(c),b(()=>n(c).reason)))),F(Je,Pt)};ue(ss,Je=>{n(c),b(()=>n(c).reason)&&Je(Ft)})}var Lt=h(C,2);V(Je=>{k(xe,(n(c),b(()=>n(c).scope))),k(S,`Rule-${Je??""}`),k(Ge,(n(c),b(()=>n(c).content))),xc(Lt,"aria-label",(n(c),b(()=>`Delete ${n(c).id}`)))},[()=>(n(c),b(()=>String(n(c).id).padStart(3,"0")))]),ta("click",Lt,()=>ri(n(c).id)),F(l,A)},l=>{var c=rf();F(l,c)}),V((l,c,A)=>{var C,H,ie,xe,he;$r=as(Vs,1,"status-chip svelte-d3ct2b",null,$r,{live:n(m).live}),k(ai,` ${n(m),b(()=>n(m).label)??""}`),k(li,(n(u),b(()=>{var S;return((S=n(u).runtime)==null?void 0:S.model.label)??"runtime pending"}))),Vr=as(Ur,1,"live-label svelte-d3ct2b",null,Vr,{live:n(m).live}),k(fi,(n(m),b(()=>n(m).label))),k(di,n(p)),k(_i,n(g)),k(bi,n(x)),k(wi,(n(u),b(()=>{var S;return(S=n(u).runtime)!=null&&S.project.initialized?"Initialized":"Not initialized"}))),k(ki,l),k(Ti,(n(u),b(()=>{var S;return((S=n(u).runtime)==null?void 0:S.project.type)??"unknown"}))),k(Ri,(n(u),b(()=>{var S;return((S=n(u).runtime)==null?void 0:S.project.language)??"unknown"}))),k(Ni,c),k(Di,(n(u),b(()=>{var S,q;return((S=n(u).watcher)==null?void 0:S.enabled)===!1?"disabled":(q=n(u).watcher)!=null&&q.running?"running":"idle"}))),k(Li,(n(u),b(()=>{var S;return((S=n(u).runtime)==null?void 0:S.model.label)??"pending"}))),k($i,(n(u),b(()=>{var S;return((S=n(u).runtime)==null?void 0:S.model.provider)??"unknown"}))),k(qi,(n(u),b(()=>{var S,q,Ge;return((S=n(u).runtime)==null?void 0:S.model.checkModelResolved)??((q=n(u).runtime)==null?void 0:q.model.checkModel)??((Ge=n(u).runtime)==null?void 0:Ge.model.chatModel)??"unknown"}))),ln=as(an,1,"svelte-d3ct2b",null,ln,{"status-ok":((C=n(u).runtime)==null?void 0:C.model.checkModelInstalled)||((H=n(u).runtime)==null?void 0:H.model.apiKeyConfigured),"status-warn":((ie=n(u).runtime)==null?void 0:ie.model.checkModelInstalled)===!1||((xe=n(u).runtime)==null?void 0:xe.model.error)}),k(Bi,(n(u),b(()=>{var S,q;return((S=n(u).runtime)==null?void 0:S.model.embeddingModelResolved)??((q=n(u).runtime)==null?void 0:q.model.embeddingModel)??"unknown"}))),k(Gi,(n(u),b(()=>{var S;return((S=n(u).runtime)==null?void 0:S.model.ollamaUrl)??"unknown"}))),un=as(fn,1,"svelte-d3ct2b",null,un,{success:(he=n(u).runtime)==null?void 0:he.postgres.connected}),k(Qi,(n(u),b(()=>{var S;return(S=n(u).runtime)!=null&&S.postgres.connected?"Connected":"Not connected"}))),k(el,(n(u),b(()=>{var S,q;return((S=n(u).runtime)==null?void 0:S.postgres.serverDatabase)??((q=n(u).runtime)==null?void 0:q.postgres.database)??"unknown"}))),k(sl,(n(u),b(()=>{var S,q;return((S=n(u).runtime)==null?void 0:S.postgres.serverUser)??((q=n(u).runtime)==null?void 0:q.postgres.user)??"unknown"}))),k(nl,`${n(u),b(()=>{var S;return((S=n(u).runtime)==null?void 0:S.postgres.host)??"unknown"})??""}${n(u),b(()=>{var S;return(S=n(u).runtime)!=null&&S.postgres.port?`:${n(u).runtime.postgres.port}`:""})??""}`),k(ll,(n(u),b(()=>{var S;return((S=n(u).runtime)==null?void 0:S.postgres.url)??"(not set)"}))),k(bl,n(a)),k(yl,n(p)),k(xl,n(v)),k(Sl,`${n(f),b(()=>n(f).length)??""} recent`),k(Cl,`${n(x)??""} rules active`),On.disabled=A,k(Ml,n(Z)?"Saving...":"Add New Architecture Rule")},[()=>b(rt),()=>b(fe),()=>(n(Z),n($),b(()=>n(Z)||!n($).content.trim()))]),nr(Hs,()=>n($).type,l=>rs($,n($).type=l)),nr(Cn,()=>n($).scope,l=>rs($,n($).scope=l)),As(Mn,()=>n($).content,l=>rs($,n($).content=l)),As(In,()=>n($).reason,l=>rs($,n($).reason=l)),As(Nl,()=>n($).tags,l=>rs($,n($).tags=l)),ta("submit",zs,Tc(si)),nr(Js,()=>n(j),l=>M(j,l)),As(Dl,()=>n(L),l=>M(L,l)),F(e,Pr),wa()}uc(af,{target:document.getElementById("app")});