humemory 0.2.16 → 0.2.26

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/AGENTS.md CHANGED
@@ -297,14 +297,14 @@ through a caller that supplies a trusted process identity, not an HTTP attributi
297
297
 
298
298
  **Client registration** — the repo ships `.mcp.json` (Claude Code project
299
299
  scope, `HUMEMORY_AGENT=claude`). `pnpm cli sources setup` merge-registers the
300
- same server in installed Kimi Code and OpenCode configs without removing other
300
+ same server in Claude Code, Codex, Kimi Code and OpenCode configs without removing other
301
301
  MCP servers, using the identities below:
302
302
 
303
303
  | Agent | Config | `HUMEMORY_AGENT` |
304
304
  |-------|--------|------------------|
305
- | Claude Code | `.mcp.json` at repo root (shipped) | `claude` |
305
+ | Claude Code | `~/.claude.json` → `mcpServers` (user scope); `.mcp.json` at repo root remains shipped for project scope | `claude` |
306
306
  | Kimi Code | same shape in the Kimi MCP config | `kimi` |
307
- | Codex | same shape in the Codex MCP config | `codex` |
307
+ | Codex | `$CODEX_HOME/config.toml` (default `~/.codex/config.toml`) → `mcp_servers.humemory` | `codex` |
308
308
  | OpenCode | `opencode.json` → `mcp` section | `opencode` |
309
309
 
310
310
  Server entry: `bun run src/mcp/server.ts` (stdio). Every agent MUST set its
package/CHANGELOG.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.26] - 2026-11-26
4
+ **Bug Fixes:**
5
+ - publish through npm trusted publishing
6
+
7
+
8
+
9
+ ## [0.2.25] - 2026-11-25
10
+ **Chores:**
11
+ - update compatible dependencies
12
+
13
+
14
+
15
+ ## [0.2.24] - 2026-11-23
16
+ **Chores:**
17
+ - update compatible dependencies
18
+
19
+
20
+
21
+ ## [0.2.23] - 2026-11-21
22
+ **Chores:**
23
+ - update compatible dependencies
24
+
25
+
26
+
27
+ ## [0.2.22] - 2026-11-19
28
+ **Chores:**
29
+ - update compatible dependencies
30
+
31
+
32
+
33
+ ## [0.2.21] - 2026-11-17
34
+ **Chores:**
35
+ - update compatible dependencies
36
+
37
+
38
+
39
+ ## [0.2.20] - 2026-11-15
40
+ **Chores:**
41
+ - update compatible dependencies
42
+
43
+
44
+
45
+ ## [0.2.19] - 2026-11-14
46
+ **Features:**
47
+ - add Claude Code to sources setup
48
+
49
+
50
+
51
+ ## [0.2.18] - 2026-11-14
52
+ **Features:**
53
+ - add Codex setup and validate cron cues
54
+
55
+
56
+
57
+ ## [Unreleased]
58
+
59
+ - Add Claude Code user-scoped MCP registration to `sources setup`, with `--claude` and `--claude-config`.
60
+
61
+ - Reject malformed cron cues in the shared parser, CLI/dashboard form and HTTP API before storing them.
62
+ - Add Codex MCP registration to `sources setup`, with `--codex`, TOML preservation, backups and dry-run support.
63
+ - Restore CLI startup with Commander 15 while retaining the legacy `-l1`, `-l2` and `-l3` aliases.
64
+
65
+ ## [0.2.17] - 2026-10-29
66
+ **Chores:**
67
+ - update compatible dependencies
68
+
3
69
  ## [0.2.16] - 2026-09-29
4
70
  **Chores:**
5
71
  - major dependency upgrades (.)
package/README.md CHANGED
@@ -115,14 +115,31 @@ pnpm cli sources import-codex --since 7 # the last week (default)
115
115
  pnpm cli sources import-codex --all # every rollout ever recorded
116
116
  pnpm cli sources import-kimi --all
117
117
  pnpm cli sources import-opencode --all
118
- pnpm cli sources setup # register MCP in both installed clients
118
+ pnpm cli sources setup --dry-run # preview MCP registration in all four clients
119
+ pnpm cli sources setup # register MCP in Claude Code, Codex, Kimi Code and OpenCode
120
+ pnpm cli sources setup --claude # configure Claude Code only (user scope)
121
+ pnpm cli sources setup --codex # configure Codex only
119
122
  ```
120
123
 
121
124
  The resident maintenance loop sweeps new sessions from all three producers every
122
125
  15 minutes. `sources setup` merge-adds a `humemory` MCP entry without removing
123
- existing servers and pins each client identity (`kimi` or `opencode`) plus the
126
+ existing servers and pins each client identity (`claude`, `codex`, `kimi` or `opencode`) plus the
124
127
  absolute shared database path.
125
128
 
129
+ Client flags can be combined, for example `sources setup --codex --kimi`.
130
+ Claude Code uses the user-scoped `~/.claude.json`; setup preserves its per-project
131
+ state and other servers. Use `--claude-config <path>` for a different user config
132
+ file. The repository's `.mcp.json` remains a project-scoped alternative; Claude
133
+ Code gives local and project definitions priority over the user entry when they
134
+ share the same server name. See [Claude Code's MCP scopes](https://code.claude.com/docs/en/mcp#mcp-installation-scopes).
135
+ Codex uses `$CODEX_HOME/config.toml` (default `~/.codex/config.toml`);
136
+ setup preserves other settings and comments, backs up changed files to a sibling
137
+ `.bak` file, and writes atomically. Running it again with the same settings changes
138
+ nothing. Invalid files, remote `humemory` servers in Codex, and TOML layouts that
139
+ cannot be safely edited (such as inline server definitions) are refused without
140
+ rewriting the file. Codex's configuration format is documented in the
141
+ [official MCP guide](https://developers.openai.com/codex/mcp).
142
+
126
143
  Importing only *queues*; the worker still decides what becomes a trace. Jobs are
127
144
  keyed on session, so re-importing is idempotent and a thread that grew since the
128
145
  last pass contributes only its new messages. Threads codex spawned for itself
@@ -164,6 +181,13 @@ pnpm cli intent resolve # expire overdue loops, fire due deadlines
164
181
  Cue formats: `time:<ISO>`, `cron:<5-field expr>`, `event:file_open:<path>`,
165
182
  `event:branch_switch:<branch>`, `event:error_pattern:<regex>`.
166
183
 
184
+ Cron expressions use UTC and five numeric fields: minute (0–59), hour (0–23),
185
+ day of month (1–31), month (1–12), weekday (0–6, Sunday = 0). Fields accept `*`,
186
+ numbers, ranges, lists and positive steps, for example `*/15` or `1-9/2`.
187
+ The CLI, dashboard cue form and HTTP API reject malformed expressions before
188
+ storing them. For example, `0 9 * * 1` fires on Mondays at 09:00 UTC;
189
+ `0 9 * * 1,` is an error.
190
+
167
191
  Directories are resolved to absolute paths on write — a loop armed on a relative
168
192
  path would never match the `SessionStart` hook, which looks the project up by
169
193
  `process.cwd()`.
@@ -1,4 +1,4 @@
1
- export type HumemoryMcpClient = 'kimi' | 'opencode';
1
+ export type HumemoryMcpClient = 'kimi' | 'opencode' | 'codex' | 'claude';
2
2
  export interface McpClientSetupOptions {
3
3
  clients: HumemoryMcpClient[];
4
4
  projectRoot: string;
@@ -6,6 +6,8 @@ export interface McpClientSetupOptions {
6
6
  bunPath?: string;
7
7
  kimiHome?: string;
8
8
  openCodeConfig?: string;
9
+ codexHome?: string;
10
+ claudeConfig?: string;
9
11
  dryRun?: boolean;
10
12
  }
11
13
  export interface McpClientSetupEntry {
@@ -3,6 +3,7 @@ import { mkdir, readFile, writeFile, rename, rm } from 'fs/promises';
3
3
  import { randomUUID } from 'crypto';
4
4
  import { dirname, join, resolve } from 'path';
5
5
  import { homedir } from 'os';
6
+ import { isDeepStrictEqual } from 'util';
6
7
  import { databasePath } from '../core/paths.js';
7
8
  import { AdvisoryLock } from '../store/sqlite.js';
8
9
  async function readOptional(path) {
@@ -34,17 +35,23 @@ function readJson(raw, path) {
34
35
  }
35
36
  }
36
37
  async function mergeFile(path, update, dryRun) {
37
- const apply = async () => {
38
- const original = await readOptional(path);
38
+ return mergeTextFile(path, (original) => {
39
39
  const current = readJson(original, path);
40
40
  const before = JSON.stringify(current);
41
41
  const next = update(current);
42
- const changed = before !== JSON.stringify(next);
43
- if (changed && !dryRun) {
42
+ return before === JSON.stringify(next) ? original : `${JSON.stringify(next, null, 2)}\n`;
43
+ }, dryRun);
44
+ }
45
+ async function mergeTextFile(path, update, dryRun) {
46
+ const apply = async () => {
47
+ const original = await readOptional(path);
48
+ const next = update(original);
49
+ const changed = original !== next;
50
+ if (changed && next !== null && !dryRun) {
44
51
  await mkdir(dirname(path), { recursive: true });
45
52
  const temporary = `${path}.${randomUUID()}.tmp`;
46
53
  try {
47
- await writeFile(temporary, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600, flag: 'wx' });
54
+ await writeFile(temporary, next, { mode: 0o600, flag: 'wx' });
48
55
  if (original !== null)
49
56
  await writeFile(`${path}.${randomUUID()}.bak`, original, { mode: 0o600, flag: 'wx' });
50
57
  if (await readOptional(path) !== original)
@@ -62,6 +69,63 @@ async function mergeFile(path, update, dryRun) {
62
69
  await mkdir(dirname(path), { recursive: true });
63
70
  return new AdvisoryLock(path + '.setup', 50).withLock(apply);
64
71
  }
72
+ /** Encode only the server's values; the rest of the TOML stays byte-for-byte intact. */
73
+ function tomlValue(value) {
74
+ if (typeof value === 'string')
75
+ return JSON.stringify(value);
76
+ if (typeof value === 'boolean' || typeof value === 'number')
77
+ return String(value);
78
+ if (value instanceof Date)
79
+ return value.toISOString();
80
+ if (Array.isArray(value))
81
+ return `[${value.map(tomlValue).join(', ')}]`;
82
+ if (value && typeof value === 'object') {
83
+ return `{ ${Object.entries(value).map(([k, v]) => `${JSON.stringify(k)} = ${tomlValue(v)}`).join(', ')} }`;
84
+ }
85
+ throw new Error('Unsupported value in Codex humemory configuration');
86
+ }
87
+ function mergeCodexToml(original, path, server) {
88
+ const raw = original ?? '';
89
+ let current;
90
+ try {
91
+ current = Bun.TOML.parse(raw);
92
+ }
93
+ catch {
94
+ throw new Error(`Refusing to rewrite invalid TOML: ${path}`);
95
+ }
96
+ const existing = current.mcp_servers?.humemory;
97
+ if (existing !== undefined && (!existing || typeof existing !== 'object' || Array.isArray(existing))) {
98
+ throw new Error(`Refusing to rewrite invalid Codex humemory table: ${path}`);
99
+ }
100
+ if (existing?.url !== undefined)
101
+ throw new Error(`Refusing to replace a remote Codex humemory server: ${path}`);
102
+ const next = { ...existing, ...server, env: { ...existing?.env, ...server.env } };
103
+ if (isDeepStrictEqual(existing, next))
104
+ return raw;
105
+ // Recognise ordinary table headers, including quoted names. The semantic check
106
+ // below refuses inline/dotted definitions and apparent headers inside strings.
107
+ const key = `(?:mcp_servers|"mcp_servers"|'mcp_servers')\\s*\\.\\s*(?:humemory|"humemory"|'humemory')`;
108
+ const owned = new RegExp(`^\\s*\\[\\s*${key}(?:\\s*\\.[^\\]]+)?\\s*\\]\\s*(?:#.*)?$`);
109
+ let removing = false;
110
+ const kept = raw.split(/(?<=\n)/).filter((line) => {
111
+ if (/^\s*\[/.test(line))
112
+ removing = owned.test(line.trimEnd());
113
+ return !removing;
114
+ }).join('');
115
+ const eol = raw.includes('\r\n') ? '\r\n' : '\n';
116
+ const block = ['[mcp_servers.humemory]', ...Object.entries(next).map(([k, v]) => `${JSON.stringify(k)} = ${tomlValue(v)}`)].join(eol);
117
+ const result = `${kept}${kept && !kept.endsWith('\n') ? eol : ''}${eol}${block}${eol}`;
118
+ try {
119
+ const parsed = Bun.TOML.parse(result);
120
+ const expected = { ...current, mcp_servers: { ...current.mcp_servers, humemory: next } };
121
+ if (!isDeepStrictEqual(parsed, expected))
122
+ throw new Error('unrelated settings changed');
123
+ }
124
+ catch {
125
+ throw new Error(`Refusing to rewrite unsupported Codex TOML layout: ${path}`);
126
+ }
127
+ return result;
128
+ }
65
129
  export async function setupHumemoryMcpClients(options) {
66
130
  const projectRoot = resolve(options.projectRoot);
67
131
  const serverPath = join(projectRoot, 'src', 'mcp', 'server.ts');
@@ -71,16 +135,29 @@ export async function setupHumemoryMcpClients(options) {
71
135
  const dryRun = options.dryRun ?? false;
72
136
  const entries = [];
73
137
  for (const client of [...new Set(options.clients)]) {
74
- if (client === 'kimi') {
75
- const path = join(options.kimiHome ?? process.env.KIMI_CODE_HOME ?? join(homedir(), '.kimi-code'), 'mcp.json');
138
+ if (client === 'codex') {
139
+ const path = join(options.codexHome ?? process.env.CODEX_HOME ?? join(homedir(), '.codex'), 'config.toml');
140
+ const changed = await mergeTextFile(path, (original) => mergeCodexToml(original, path, {
141
+ command: bunPath,
142
+ args: ['run', serverPath],
143
+ env: { HUMEMORY_AGENT: 'codex', HUMEMORY_DB: dbPath },
144
+ }), dryRun);
145
+ entries.push({ client, path, changed });
146
+ continue;
147
+ }
148
+ if (client === 'kimi' || client === 'claude') {
149
+ const path = client === 'claude'
150
+ ? resolve(options.claudeConfig ?? join(homedir(), '.claude.json'))
151
+ : join(options.kimiHome ?? process.env.KIMI_CODE_HOME ?? join(homedir(), '.kimi-code'), 'mcp.json');
76
152
  const changed = await mergeFile(path, (current) => ({
77
153
  ...current,
78
154
  mcpServers: {
79
155
  ...(current.mcpServers ?? {}),
80
156
  humemory: {
157
+ ...(client === 'claude' ? { type: 'stdio' } : {}),
81
158
  command: bunPath,
82
159
  args: ['run', serverPath],
83
- env: { HUMEMORY_AGENT: 'kimi', HUMEMORY_DB: dbPath },
160
+ env: { HUMEMORY_AGENT: client, HUMEMORY_DB: dbPath },
84
161
  },
85
162
  },
86
163
  }), dryRun);
@@ -6,7 +6,7 @@
6
6
  * touching the production database (see docs/TESTING.md).
7
7
  */
8
8
  import { Hono } from 'hono';
9
- import { SqliteCueResolver, loopId, isDangerousPattern, MAX_PATTERN_LENGTH, MAX_MATCH_TEXT_LENGTH, } from '../core/cues.js';
9
+ import { SqliteCueResolver, parseCron, loopId, isDangerousPattern, MAX_PATTERN_LENGTH, MAX_MATCH_TEXT_LENGTH, } from '../core/cues.js';
10
10
  import { LimitExceeded, boundedString, MAX_CONTENT_LENGTH, MAX_SHORT_FIELD_LENGTH, MAX_COLLECTION_ITEMS, } from './limits.js';
11
11
  import { serverErrorBody } from './errors.js';
12
12
  const INTENTION_STATUSES = ['armed', 'fired', 'closed', 'expired'];
@@ -59,6 +59,9 @@ export function validateTriggerSpec(raw) {
59
59
  if (cron !== undefined && typeof cron !== 'string') {
60
60
  throw new BadRequest('"cron" must be a string');
61
61
  }
62
+ if (typeof cron === 'string' && !parseCron(cron)) {
63
+ throw new BadRequest('invalid cron expression: expected five fields (minute hour day month weekday), in UTC');
64
+ }
62
65
  return { kind: 'time', ...(at ? { at: at } : {}), ...(cron ? { cron: cron } : {}) };
63
66
  }
64
67
  if (spec.kind === 'event') {
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Command } from 'commander';
2
+ import { Command, Option } from 'commander';
3
3
  import { databasePath, queueDirectory } from '../core/paths.js';
4
4
  import { SQLiteStore } from '../store/sqlite.js';
5
5
  import { SqliteCueResolver, loopId, matchIntentionByShortId } from '../core/cues.js';
@@ -41,9 +41,11 @@ program
41
41
  .option('-d, --directory <dir>', 'Mental place (project)', process.cwd())
42
42
  .option('-s, --session <id>', 'Contexte d\'encodage', 'default')
43
43
  .option('-k, --keywords <tags>', 'Retrieval cues (comma-separated)', '')
44
- .option('-l1, --level1 <summary>', 'Summary for consolidation level 1')
45
- .option('-l2, --level2 <essential>', 'Gist for consolidation level 2')
46
- .option('-l3, --level3 <keywords>', 'Keywords for fast level 3 retrieval')
44
+ // Commander 15 rejects multi-character short flags in the constructor.
45
+ // Keep the historical aliases through Option's public short property.
46
+ .addOption(Object.assign(new Option('--level1 <summary>', 'Summary for consolidation level 1'), { short: '-l1' }))
47
+ .addOption(Object.assign(new Option('--level2 <essential>', 'Gist for consolidation level 2'), { short: '-l2' }))
48
+ .addOption(Object.assign(new Option('--level3 <keywords>', 'Keywords for fast level 3 retrieval'), { short: '-l3' }))
47
49
  .option('-t, --type <type>', 'Memory type (episodic/semantic/procedural)', 'semantic')
48
50
  .option('--auto', 'Auto-generate levels 1-3 locally (an injected LLM may enhance them)')
49
51
  .option('--photographic', 'Photographic mode — disable decay')
@@ -1020,20 +1022,24 @@ sources
1020
1022
  });
1021
1023
  sources
1022
1024
  .command('setup')
1023
- .description('Register humemory as a local MCP server in Kimi Code and OpenCode')
1025
+ .description('Register humemory as a local MCP server in Claude Code, Codex, Kimi Code and OpenCode')
1026
+ .option('--claude', 'Configure Claude Code only (user scope)')
1027
+ .option('--claude-config <path>', 'Override the Claude Code user config file (default ~/.claude.json)')
1028
+ .option('--codex', 'Configure Codex only (combine client flags to select several)')
1024
1029
  .option('--kimi', 'Configure Kimi Code only')
1025
1030
  .option('--opencode', 'Configure OpenCode only')
1026
1031
  .option('--dry-run', 'Show which files would change, write nothing')
1027
1032
  .action(async (options) => {
1028
1033
  const { setupHumemoryMcpClients } = await import('../agent/mcp-client-setup.js');
1029
- const clients = options.kimi || options.opencode
1030
- ? [...(options.kimi ? ['kimi'] : []), ...(options.opencode ? ['opencode'] : [])]
1031
- : ['kimi', 'opencode'];
1034
+ const clients = options.claude || options.codex || options.kimi || options.opencode
1035
+ ? [...(options.claude ? ['claude'] : []), ...(options.codex ? ['codex'] : []), ...(options.kimi ? ['kimi'] : []), ...(options.opencode ? ['opencode'] : [])]
1036
+ : ['claude', 'codex', 'kimi', 'opencode'];
1032
1037
  const projectRoot = resolve(__dirname, '../..');
1033
1038
  const result = await setupHumemoryMcpClients({
1034
1039
  clients: [...clients],
1035
1040
  projectRoot,
1036
1041
  dbPath: DB_PATH,
1042
+ claudeConfig: options.claudeConfig,
1037
1043
  dryRun: options.dryRun,
1038
1044
  });
1039
1045
  for (const entry of result) {
@@ -11,6 +11,7 @@
11
11
  * It lives in core/ rather than cli/: the same format is typed on the command
12
12
  * line and in the front-end form. One parser, tested once.
13
13
  */
14
+ import { parseCron } from './cues.js';
14
15
  export class CueArgError extends Error {
15
16
  }
16
17
  const EVENT_TYPES = ['file_open', 'branch_switch', 'error_pattern'];
@@ -32,6 +33,8 @@ export function parseCueArg(raw) {
32
33
  case 'cron': {
33
34
  if (!tail.trim())
34
35
  throw new CueArgError('cron: expects an expression — e.g. "cron:0 9 * * 1"');
36
+ if (!parseCron(tail))
37
+ throw new CueArgError('invalid cron expression: expected five fields (minute hour day month weekday), in UTC');
35
38
  return { kind: 'time', cron: tail.trim() };
36
39
  }
37
40
  case 'event': {
package/dist/core/cues.js CHANGED
@@ -26,6 +26,8 @@ function expandCronField(field, index) {
26
26
  const [min, max] = CRON_RANGES[index];
27
27
  const values = new Set();
28
28
  for (const part of field.split(',')) {
29
+ if (!/^(?:\*|[0-9]+(?:-[0-9]+)?)(?:\/[0-9]+)?$/.test(part))
30
+ return null;
29
31
  const [rangePart, stepPart] = part.split('/');
30
32
  const step = stepPart === undefined ? 1 : Number(stepPart);
31
33
  if (!Number.isInteger(step) || step < 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humemory",
3
- "version": "0.2.16",
3
+ "version": "0.2.26",
4
4
  "description": "Memory for AI agents that forgets like a human — decaying traces, inverse search, and prospective loops that resurface on a cue",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -53,30 +53,30 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@anthropic-ai/sdk": "^0.92.0",
56
- "@hono/node-server": "^2.1.3",
57
- "@huggingface/transformers": "^4.3.0",
58
- "@modelcontextprotocol/sdk": "^1.31.0",
59
- "commander": "^15.0.0",
60
- "d3": "^7.9.0",
56
+ "@hono/node-server": "^2.1.11",
57
+ "@huggingface/transformers": "^4.3.2",
58
+ "@modelcontextprotocol/sdk": "^1.32.2",
59
+ "commander": "^15.1.0",
60
+ "d3": "^7.9.2",
61
61
  "flexsearch": "^0.7.43",
62
- "hono": "^4.13.11",
63
- "react": "^19.3.0",
64
- "react-dom": "^19.3.0",
62
+ "hono": "^4.13.22",
63
+ "react": "^19.3.1",
64
+ "react-dom": "^19.3.1",
65
65
  "three": "^0.184.0",
66
- "zod": "^4.6.5"
66
+ "zod": "^4.6.7"
67
67
  },
68
68
  "devDependencies": {
69
- "@happy-dom/global-registrator": "^20.14.5",
69
+ "@happy-dom/global-registrator": "^20.14.6",
70
70
  "@medyll/idae-pnpm-release": "1.0.46",
71
71
  "@testing-library/dom": "^10.4.2",
72
72
  "@testing-library/react": "^16.3.3",
73
73
  "@types/d3": "^7.4.3",
74
74
  "@types/node": "^20.19.43",
75
- "@types/react": "^19.3.0",
75
+ "@types/react": "^19.3.2",
76
76
  "@types/react-dom": "^19.3.0",
77
77
  "@types/three": "^0.185.4",
78
- "bun-types": "^1.4.2",
79
- "js-yaml": "^5.4.2",
78
+ "bun-types": "^1.4.5",
79
+ "js-yaml": "^5.5.0",
80
80
  "tsx": "^4.23.15",
81
81
  "typescript": "^5.9.3"
82
82
  },
@@ -0,0 +1,10 @@
1
+ import{d as rJ,e as UK,f as HK,g as VK,h as UJ,i as HJ,j as g,k as d,l as mJ,m as cJ,n as GK,o as $K,r as MK,s as AK,t as wK}from"./index-23jznef0.js";import{u as nJ,v as kK,w as _K}from"./index-18hnqcxx.js";import{E as bK}from"./index-xv716176.js";var fK={value:()=>{}};function t(){for(var J=0,K=arguments.length,W={},X;J<K;++J){if(!(X=arguments[J]+"")||X in W||/[\s.]/.test(X))throw Error("illegal type: "+X);W[X]=[]}return new QJ(W)}function QJ(J){this._=J}function hK(J,K){return J.trim().split(/^|\s+/).map(function(W){var X="",Y=W.indexOf(".");if(Y>=0)X=W.slice(Y+1),W=W.slice(0,Y);if(W&&!K.hasOwnProperty(W))throw Error("unknown type: "+W);return{type:W,name:X}})}QJ.prototype=t.prototype={constructor:QJ,on:function(J,K){var W=this._,X=hK(J+"",W),Y,Z=-1,B=X.length;if(arguments.length<2){while(++Z<B)if((Y=(J=X[Z]).type)&&(Y=xK(W[Y],J.name)))return Y;return}if(K!=null&&typeof K!=="function")throw Error("invalid callback: "+K);while(++Z<B)if(Y=(J=X[Z]).type)W[Y]=tJ(W[Y],J.name,K);else if(K==null)for(Y in W)W[Y]=tJ(W[Y],J.name,null);return this},copy:function(){var J={},K=this._;for(var W in K)J[W]=K[W].slice();return new QJ(J)},call:function(J,K){if((Y=arguments.length-2)>0)for(var W=Array(Y),X=0,Y,Z;X<Y;++X)W[X]=arguments[X+2];if(!this._.hasOwnProperty(J))throw Error("unknown type: "+J);for(Z=this._[J],X=0,Y=Z.length;X<Y;++X)Z[X].value.apply(K,W)},apply:function(J,K,W){if(!this._.hasOwnProperty(J))throw Error("unknown type: "+J);for(var X=this._[J],Y=0,Z=X.length;Y<Z;++Y)X[Y].value.apply(K,W)}};function xK(J,K){for(var W=0,X=J.length,Y;W<X;++W)if((Y=J[W]).name===K)return Y.value}function tJ(J,K,W){for(var X=0,Y=J.length;X<Y;++X)if(J[X].name===K){J[X]=fK,J=J.slice(0,X).concat(J.slice(X+1));break}if(W!=null)J.push({name:K,value:W});return J}var vK={passive:!1},VJ={capture:!0,passive:!1};function bJ(J){J.stopImmediatePropagation()}function YJ(J){J.preventDefault(),J.stopImmediatePropagation()}function _J(J){var K=J.document.documentElement,W=g(J).on("dragstart.drag",YJ,VJ);if("onselectstart"in K)W.on("selectstart.drag",YJ,VJ);else K.__noselect=K.style.MozUserSelect,K.style.MozUserSelect="none"}function fJ(J,K){var W=J.document.documentElement,X=g(J).on("dragstart.drag",null);if(K)X.on("click.drag",YJ,VJ),setTimeout(function(){X.on("click.drag",null)},0);if("onselectstart"in W)X.on("selectstart.drag",null);else W.style.MozUserSelect=W.__noselect,delete W.__noselect}var RJ=(J)=>()=>J;function kJ(J,{sourceEvent:K,subject:W,target:X,identifier:Y,active:Z,x:B,y:U,dx:V,dy:H,dispatch:A}){Object.defineProperties(this,{type:{value:J,enumerable:!0,configurable:!0},sourceEvent:{value:K,enumerable:!0,configurable:!0},subject:{value:W,enumerable:!0,configurable:!0},target:{value:X,enumerable:!0,configurable:!0},identifier:{value:Y,enumerable:!0,configurable:!0},active:{value:Z,enumerable:!0,configurable:!0},x:{value:B,enumerable:!0,configurable:!0},y:{value:U,enumerable:!0,configurable:!0},dx:{value:V,enumerable:!0,configurable:!0},dy:{value:H,enumerable:!0,configurable:!0},_:{value:A}})}kJ.prototype.on=function(){var J=this._.on.apply(this._,arguments);return J===this._?this:J};function gK(J){return!J.ctrlKey&&!J.button}function yK(){return this.parentNode}function pK(J,K){return K==null?{x:J.x,y:J.y}:K}function mK(){return navigator.maxTouchPoints||"ontouchstart"in this}function eJ(){var J=gK,K=yK,W=pK,X=mK,Y={},Z=t("start","drag","end"),B=0,U,V,H,A,S=0;function Q(M){M.on("mousedown.drag",L).filter(X).on("touchstart.drag",P).on("touchmove.drag",F,vK).on("touchend.drag touchcancel.drag",$).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function L(M,T){if(A||!J.call(this,M,T))return;var E=N(this,K.call(this,M,T),M,T,"mouse");if(!E)return;g(M.view).on("mousemove.drag",I,VJ).on("mouseup.drag",R,VJ),_J(M.view),bJ(M),H=!1,U=M.clientX,V=M.clientY,E("start",M)}function I(M){if(YJ(M),!H){var T=M.clientX-U,E=M.clientY-V;H=T*T+E*E>S}Y.mouse("drag",M)}function R(M){g(M.view).on("mousemove.drag mouseup.drag",null),fJ(M.view,H),YJ(M),Y.mouse("end",M)}function P(M,T){if(!J.call(this,M,T))return;var E=M.changedTouches,q=K.call(this,M,T),b=E.length,f,k;for(f=0;f<b;++f)if(k=N(this,q,M,T,E[f].identifier,E[f]))bJ(M),k("start",M,E[f])}function F(M){var T=M.changedTouches,E=T.length,q,b;for(q=0;q<E;++q)if(b=Y[T[q].identifier])YJ(M),b("drag",M,T[q])}function $(M){var T=M.changedTouches,E=T.length,q,b;if(A)clearTimeout(A);A=setTimeout(function(){A=null},500);for(q=0;q<E;++q)if(b=Y[T[q].identifier])bJ(M),b("end",M,T[q])}function N(M,T,E,q,b,f){var k=Z.copy(),h=d(f||E,T),u,c,G;if((G=W.call(M,new kJ("beforestart",{sourceEvent:E,target:Q,identifier:b,active:B,x:h[0],y:h[1],dx:0,dy:0,dispatch:k}),q))==null)return;return u=G.x-h[0]||0,c=G.y-h[1]||0,function O(C,D,j){var z=h,w;switch(C){case"start":Y[b]=O,w=B++;break;case"end":delete Y[b],--B;case"drag":h=d(j||D,T),w=B;break}k.call(C,M,new kJ(C,{sourceEvent:D,subject:G,target:Q,identifier:b,active:w,x:h[0]+u,y:h[1]+c,dx:h[0]-z[0],dy:h[1]-z[1],dispatch:k}),q)}}return Q.filter=function(M){return arguments.length?(J=typeof M==="function"?M:RJ(!!M),Q):J},Q.container=function(M){return arguments.length?(K=typeof M==="function"?M:RJ(M),Q):K},Q.subject=function(M){return arguments.length?(W=typeof M==="function"?M:RJ(M),Q):W},Q.touchable=function(M){return arguments.length?(X=typeof M==="function"?M:RJ(!!M),Q):X},Q.on=function(){var M=Z.on.apply(Z,arguments);return M===Z?Q:M},Q.clickDistance=function(M){return arguments.length?(S=(M=+M)*M,Q):Math.sqrt(S)},Q}var ZJ=0,$J=0,GJ=0,KK=1000,CJ,MJ,SJ=0,XJ=0,OJ=0,AJ=typeof performance==="object"&&performance.now?performance:Date,WK=typeof window==="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(J){setTimeout(J,17)};function DJ(){return XJ||(WK(cK),XJ=AJ.now()+OJ)}function cK(){XJ=0}function NJ(){this._call=this._time=this._next=null}NJ.prototype=FJ.prototype={constructor:NJ,restart:function(J,K,W){if(typeof J!=="function")throw TypeError("callback is not a function");if(W=(W==null?DJ():+W)+(K==null?0:+K),!this._next&&MJ!==this){if(MJ)MJ._next=this;else CJ=this;MJ=this}this._call=J,this._time=W,hJ()},stop:function(){if(this._call)this._call=null,this._time=1/0,hJ()}};function FJ(J,K,W){var X=new NJ;return X.restart(J,K,W),X}function uK(){DJ(),++ZJ;var J=CJ,K;while(J){if((K=XJ-J._time)>=0)J._call.call(void 0,K);J=J._next}--ZJ}function JK(){XJ=(SJ=AJ.now())+OJ,ZJ=$J=0;try{uK()}finally{ZJ=0,rK(),XJ=0}}function lK(){var J=AJ.now(),K=J-SJ;if(K>KK)OJ-=K,SJ=J}function rK(){var J,K=CJ,W,X=1/0;while(K)if(K._call){if(X>K._time)X=K._time;J=K,K=K._next}else W=K._next,K._next=null,K=J?J._next=W:CJ=W;MJ=J,hJ(X)}function hJ(J){if(ZJ)return;if($J)$J=clearTimeout($J);var K=J-XJ;if(K>24){if(J<1/0)$J=setTimeout(JK,Math.ceil(J-AJ.now()-OJ)+1);if(GJ)GJ=clearInterval(GJ)}else{if(!GJ)SJ=AJ.now(),GJ=setInterval(lK,KK);ZJ=1,WK(JK)}}function xJ(J,K,W){var X=new NJ;return K=K==null?0:+K,X.restart((Y)=>{X.stop(),J(Y+K)},K,W),X}function YK(J){return((J*=2)<=1?J*J*J:(J-=2)*J*J+2)/2}var vJ=3,gX=function J(K){K=+K;function W(X){return Math.pow(X,K)}return W.exponent=J,W}(vJ),yX=function J(K){K=+K;function W(X){return 1-Math.pow(1-X,K)}return W.exponent=J,W}(vJ),pX=function J(K){K=+K;function W(X){return((X*=2)<=1?Math.pow(X,K):2-Math.pow(2-X,K))/2}return W.exponent=J,W}(vJ),dK=Math.PI,mX=dK/2;function IJ(J){return(Math.pow(2,-10*J)-0.0009765625)*1.0009775171065494}var XK=0.36363636363636365;var cX=1/XK/XK;var gJ=1.70158,uX=function J(K){K=+K;function W(X){return(X=+X)*X*(K*(X-1)+X)}return W.overshoot=J,W}(gJ),lX=function J(K){K=+K;function W(X){return--X*X*((X+1)*K+X)+1}return W.overshoot=J,W}(gJ),rX=function J(K){K=+K;function W(X){return((X*=2)<1?X*X*((K+1)*X-K):(X-=2)*X*((K+1)*X+K)+2)/2}return W.overshoot=J,W}(gJ),BJ=2*Math.PI,yJ=1,pJ=0.3,dX=function J(K,W){var X=Math.asin(1/(K=Math.max(1,K)))*(W/=BJ);function Y(Z){return K*IJ(- --Z)*Math.sin((X-Z)/W)}return Y.amplitude=function(Z){return J(Z,W*BJ)},Y.period=function(Z){return J(K,Z)},Y}(yJ,pJ),sX=function J(K,W){var X=Math.asin(1/(K=Math.max(1,K)))*(W/=BJ);function Y(Z){return 1-K*IJ(Z=+Z)*Math.sin((Z+X)/W)}return Y.amplitude=function(Z){return J(Z,W*BJ)},Y.period=function(Z){return J(K,Z)},Y}(yJ,pJ),oX=function J(K,W){var X=Math.asin(1/(K=Math.max(1,K)))*(W/=BJ);function Y(Z){return((Z=Z*2-1)<0?K*IJ(-Z)*Math.sin((X-Z)/W):2-K*IJ(Z)*Math.sin((X+Z)/W))/2}return Y.amplitude=function(Z){return J(Z,W*BJ)},Y.period=function(Z){return J(K,Z)},Y}(yJ,pJ);var sK=t("start","end","cancel","interrupt"),oK=[],FK=0,ZK=1,uJ=2,TJ=3,BK=4,lJ=5,EJ=6;function jJ(J,K,W,X,Y,Z){var B=J.__transition;if(!B)J.__transition={};else if(W in B)return;aK(J,W,{name:K,index:X,group:Y,on:sK,tween:oK,time:Z.time,delay:Z.delay,duration:Z.duration,ease:Z.ease,timer:null,state:FK})}function dJ(J,K){var W=s(J,K);if(W.state>FK)throw Error("too late; already scheduled");return W}function a(J,K){var W=s(J,K);if(W.state>TJ)throw Error("too late; already running");return W}function s(J,K){var W=J.__transition;if(!W||!(W=W[K]))throw Error("transition not found");return W}function aK(J,K,W){var X=J.__transition,Y;X[K]=W,W.timer=FJ(Z,0,W.time);function Z(H){if(W.state=ZK,W.timer.restart(B,W.delay,W.time),W.delay<=H)B(H-W.delay)}function B(H){var A,S,Q,L;if(W.state!==ZK)return V();for(A in X){if(L=X[A],L.name!==W.name)continue;if(L.state===TJ)return xJ(B);if(L.state===BK)L.state=EJ,L.timer.stop(),L.on.call("interrupt",J,J.__data__,L.index,L.group),delete X[A];else if(+A<K)L.state=EJ,L.timer.stop(),L.on.call("cancel",J,J.__data__,L.index,L.group),delete X[A]}if(xJ(function(){if(W.state===TJ)W.state=BK,W.timer.restart(U,W.delay,W.time),U(H)}),W.state=uJ,W.on.call("start",J,J.__data__,W.index,W.group),W.state!==uJ)return;W.state=TJ,Y=Array(Q=W.tween.length);for(A=0,S=-1;A<Q;++A)if(L=W.tween[A].value.call(J,J.__data__,W.index,W.group))Y[++S]=L;Y.length=S+1}function U(H){var A=H<W.duration?W.ease.call(null,H/W.duration):(W.timer.restart(V),W.state=lJ,1),S=-1,Q=Y.length;while(++S<Q)Y[S].call(J,A);if(W.state===lJ)W.on.call("end",J,J.__data__,W.index,W.group),V()}function V(){W.state=EJ,W.timer.stop(),delete X[K];for(var H in X)return;delete J.__transition}}function LJ(J,K){var W=J.__transition,X,Y,Z=!0,B;if(!W)return;K=K==null?null:K+"";for(B in W){if((X=W[B]).name!==K){Z=!1;continue}Y=X.state>uJ&&X.state<lJ,X.state=EJ,X.timer.stop(),X.on.call(Y?"interrupt":"cancel",J,J.__data__,X.index,X.group),delete W[B]}if(Z)delete J.__transition}function iK(J){return this.each(function(){LJ(this,J)})}function nK(J,K){var W,X;return function(){var Y=a(this,J),Z=Y.tween;if(Z!==W){X=W=Z;for(var B=0,U=X.length;B<U;++B)if(X[B].name===K){X=X.slice(),X.splice(B,1);break}}Y.tween=X}}function tK(J,K,W){var X,Y;if(typeof W!=="function")throw Error();return function(){var Z=a(this,J),B=Z.tween;if(B!==X){Y=(X=B).slice();for(var U={name:K,value:W},V=0,H=Y.length;V<H;++V)if(Y[V].name===K){Y[V]=U;break}if(V===H)Y.push(U)}Z.tween=Y}}function eK(J,K){var W=this._id;if(J+="",arguments.length<2){var X=s(this.node(),W).tween;for(var Y=0,Z=X.length,B;Y<Z;++Y)if((B=X[Y]).name===J)return B.value;return null}return this.each((K==null?nK:tK)(W,J,K))}function sJ(J,K,W){var X=J._id;return J.each(function(){var Y=a(this,X);(Y.value||(Y.value={}))[K]=W.apply(this,arguments)}),function(Y){return s(Y,X).value[K]}}function LK(J,K){var W;return(typeof K==="number"?GK:K instanceof mJ?cJ:(W=mJ(K))?(K=W,cJ):$K)(J,K)}function JW(J){return function(){this.removeAttribute(J)}}function KW(J){return function(){this.removeAttributeNS(J.space,J.local)}}function WW(J,K,W){var X,Y=W+"",Z;return function(){var B=this.getAttribute(J);return B===Y?null:B===X?Z:Z=K(X=B,W)}}function XW(J,K,W){var X,Y=W+"",Z;return function(){var B=this.getAttributeNS(J.space,J.local);return B===Y?null:B===X?Z:Z=K(X=B,W)}}function YW(J,K,W){var X,Y,Z;return function(){var B,U=W(this),V;if(U==null)return void this.removeAttribute(J);return B=this.getAttribute(J),V=U+"",B===V?null:B===X&&V===Y?Z:(Y=V,Z=K(X=B,U))}}function ZW(J,K,W){var X,Y,Z;return function(){var B,U=W(this),V;if(U==null)return void this.removeAttributeNS(J.space,J.local);return B=this.getAttributeNS(J.space,J.local),V=U+"",B===V?null:B===X&&V===Y?Z:(Y=V,Z=K(X=B,U))}}function BW(J,K){var W=rJ(J),X=W==="transform"?AK:LK;return this.attrTween(J,typeof K==="function"?(W.local?ZW:YW)(W,X,sJ(this,"attr."+J,K)):K==null?(W.local?KW:JW)(W):(W.local?XW:WW)(W,X,K))}function UW(J,K){return function(W){this.setAttribute(J,K.call(this,W))}}function HW(J,K){return function(W){this.setAttributeNS(J.space,J.local,K.call(this,W))}}function VW(J,K){var W,X;function Y(){var Z=K.apply(this,arguments);if(Z!==X)W=(X=Z)&&HW(J,Z);return W}return Y._value=K,Y}function GW(J,K){var W,X;function Y(){var Z=K.apply(this,arguments);if(Z!==X)W=(X=Z)&&UW(J,Z);return W}return Y._value=K,Y}function $W(J,K){var W="attr."+J;if(arguments.length<2)return(W=this.tween(W))&&W._value;if(K==null)return this.tween(W,null);if(typeof K!=="function")throw Error();var X=rJ(J);return this.tween(W,(X.local?VW:GW)(X,K))}function MW(J,K){return function(){dJ(this,J).delay=+K.apply(this,arguments)}}function AW(J,K){return K=+K,function(){dJ(this,J).delay=K}}function FW(J){var K=this._id;return arguments.length?this.each((typeof J==="function"?MW:AW)(K,J)):s(this.node(),K).delay}function LW(J,K){return function(){a(this,J).duration=+K.apply(this,arguments)}}function PW(J,K){return K=+K,function(){a(this,J).duration=K}}function QW(J){var K=this._id;return arguments.length?this.each((typeof J==="function"?LW:PW)(K,J)):s(this.node(),K).duration}function RW(J,K){if(typeof K!=="function")throw Error();return function(){a(this,J).ease=K}}function CW(J){var K=this._id;return arguments.length?this.each(RW(K,J)):s(this.node(),K).ease}function SW(J,K){return function(){var W=K.apply(this,arguments);if(typeof W!=="function")throw Error();a(this,J).ease=W}}function NW(J){if(typeof J!=="function")throw Error();return this.each(SW(this._id,J))}function OW(J){if(typeof J!=="function")J=VK(J);for(var K=this._groups,W=K.length,X=Array(W),Y=0;Y<W;++Y)for(var Z=K[Y],B=Z.length,U=X[Y]=[],V,H=0;H<B;++H)if((V=Z[H])&&J.call(V,V.__data__,H,Z))U.push(V);return new JJ(X,this._parents,this._name,this._id)}function DW(J){if(J._id!==this._id)throw Error();for(var K=this._groups,W=J._groups,X=K.length,Y=W.length,Z=Math.min(X,Y),B=Array(X),U=0;U<Z;++U)for(var V=K[U],H=W[U],A=V.length,S=B[U]=Array(A),Q,L=0;L<A;++L)if(Q=V[L]||H[L])S[L]=Q;for(;U<X;++U)B[U]=K[U];return new JJ(B,this._parents,this._name,this._id)}function IW(J){return(J+"").trim().split(/^|\s+/).every(function(K){var W=K.indexOf(".");if(W>=0)K=K.slice(0,W);return!K||K==="start"})}function TW(J,K,W){var X,Y,Z=IW(K)?dJ:a;return function(){var B=Z(this,J),U=B.on;if(U!==X)(Y=(X=U).copy()).on(K,W);B.on=Y}}function EW(J,K){var W=this._id;return arguments.length<2?s(this.node(),W).on.on(J):this.each(TW(W,J,K))}function jW(J){return function(){var K=this.parentNode;for(var W in this.__transition)if(+W!==J)return;if(K)K.removeChild(this)}}function zW(){return this.on("end.remove",jW(this._id))}function wW(J){var K=this._name,W=this._id;if(typeof J!=="function")J=UK(J);for(var X=this._groups,Y=X.length,Z=Array(Y),B=0;B<Y;++B)for(var U=X[B],V=U.length,H=Z[B]=Array(V),A,S,Q=0;Q<V;++Q)if((A=U[Q])&&(S=J.call(A,A.__data__,Q,U))){if("__data__"in A)S.__data__=A.__data__;H[Q]=S,jJ(H[Q],K,W,Q,H,s(A,W))}return new JJ(Z,this._parents,K,W)}function qW(J){var K=this._name,W=this._id;if(typeof J!=="function")J=HK(J);for(var X=this._groups,Y=X.length,Z=[],B=[],U=0;U<Y;++U)for(var V=X[U],H=V.length,A,S=0;S<H;++S)if(A=V[S]){for(var Q=J.call(A,A.__data__,S,V),L,I=s(A,W),R=0,P=Q.length;R<P;++R)if(L=Q[R])jJ(L,K,W,R,Q,I);Z.push(Q),B.push(A)}return new JJ(Z,B,K,W)}var bW=HJ.prototype.constructor;function kW(){return new bW(this._groups,this._parents)}function _W(J,K){var W,X,Y;return function(){var Z=UJ(this,J),B=(this.style.removeProperty(J),UJ(this,J));return Z===B?null:Z===W&&B===X?Y:Y=K(W=Z,X=B)}}function PK(J){return function(){this.style.removeProperty(J)}}function fW(J,K,W){var X,Y=W+"",Z;return function(){var B=UJ(this,J);return B===Y?null:B===X?Z:Z=K(X=B,W)}}function hW(J,K,W){var X,Y,Z;return function(){var B=UJ(this,J),U=W(this),V=U+"";if(U==null)V=U=(this.style.removeProperty(J),UJ(this,J));return B===V?null:B===X&&V===Y?Z:(Y=V,Z=K(X=B,U))}}function xW(J,K){var W,X,Y,Z="style."+K,B="end."+Z,U;return function(){var V=a(this,J),H=V.on,A=V.value[Z]==null?U||(U=PK(K)):void 0;if(H!==W||Y!==A)(X=(W=H).copy()).on(B,Y=A);V.on=X}}function vW(J,K,W){var X=(J+="")==="transform"?MK:LK;return K==null?this.styleTween(J,_W(J,X)).on("end.style."+J,PK(J)):typeof K==="function"?this.styleTween(J,hW(J,X,sJ(this,"style."+J,K))).each(xW(this._id,J)):this.styleTween(J,fW(J,X,K),W).on("end.style."+J,null)}function gW(J,K,W){return function(X){this.style.setProperty(J,K.call(this,X),W)}}function yW(J,K,W){var X,Y;function Z(){var B=K.apply(this,arguments);if(B!==Y)X=(Y=B)&&gW(J,B,W);return X}return Z._value=K,Z}function pW(J,K,W){var X="style."+(J+="");if(arguments.length<2)return(X=this.tween(X))&&X._value;if(K==null)return this.tween(X,null);if(typeof K!=="function")throw Error();return this.tween(X,yW(J,K,W==null?"":W))}function mW(J){return function(){this.textContent=J}}function cW(J){return function(){var K=J(this);this.textContent=K==null?"":K}}function uW(J){return this.tween("text",typeof J==="function"?cW(sJ(this,"text",J)):mW(J==null?"":J+""))}function lW(J){return function(K){this.textContent=J.call(this,K)}}function rW(J){var K,W;function X(){var Y=J.apply(this,arguments);if(Y!==W)K=(W=Y)&&lW(Y);return K}return X._value=J,X}function dW(J){var K="text";if(arguments.length<1)return(K=this.tween(K))&&K._value;if(J==null)return this.tween(K,null);if(typeof J!=="function")throw Error();return this.tween(K,rW(J))}function sW(){var J=this._name,K=this._id,W=QK();for(var X=this._groups,Y=X.length,Z=0;Z<Y;++Z)for(var B=X[Z],U=B.length,V,H=0;H<U;++H)if(V=B[H]){var A=s(V,K);jJ(V,J,W,H,B,{time:A.time+A.delay+A.duration,delay:0,duration:A.duration,ease:A.ease})}return new JJ(X,this._parents,J,W)}function oW(){var J,K,W=this,X=W._id,Y=W.size();return new Promise(function(Z,B){var U={value:B},V={value:function(){if(--Y===0)Z()}};if(W.each(function(){var H=a(this,X),A=H.on;if(A!==J)K=(J=A).copy(),K._.cancel.push(U),K._.interrupt.push(U),K._.end.push(V);H.on=K}),Y===0)Z()})}var aW=0;function JJ(J,K,W,X){this._groups=J,this._parents=K,this._name=W,this._id=X}function iW(J){return HJ().transition(J)}function QK(){return++aW}var e=HJ.prototype;JJ.prototype=iW.prototype={constructor:JJ,select:wW,selectAll:qW,selectChild:e.selectChild,selectChildren:e.selectChildren,filter:OW,merge:DW,selection:kW,transition:sW,call:e.call,nodes:e.nodes,node:e.node,size:e.size,empty:e.empty,each:e.each,on:EW,attr:BW,attrTween:$W,style:vW,styleTween:pW,text:uW,textTween:dW,remove:zW,tween:eK,delay:FW,duration:QW,ease:CW,easeVarying:NW,end:oW,[Symbol.iterator]:e[Symbol.iterator]};var nW={time:null,delay:0,duration:250,ease:YK};function tW(J,K){var W;while(!(W=J.__transition)||!(W=W[K]))if(!(J=J.parentNode))throw Error(`transition ${K} not found`);return W}function eW(J){var K,W;if(J instanceof JJ)K=J._id,J=J._name;else K=QK(),(W=nW).time=DJ(),J=J==null?null:J+"";for(var X=this._groups,Y=X.length,Z=0;Z<Y;++Z)for(var B=X[Z],U=B.length,V,H=0;H<U;++H)if(V=B[H])jJ(V,J,K,H,B,W||tW(V,K));return new JJ(X,this._parents,J,K)}HJ.prototype.interrupt=iK;HJ.prototype.transition=eW;function JX(J){let K=+this._x.call(null,J),W=+this._y.call(null,J);return CK(this.cover(K,W),K,W,J)}function CK(J,K,W,X){if(isNaN(K)||isNaN(W))return J;var Y,Z=J._root,B={data:X},U=J._x0,V=J._y0,H=J._x1,A=J._y1,S,Q,L,I,R,P,F,$;if(!Z)return J._root=B,J;while(Z.length){if(R=K>=(S=(U+H)/2))U=S;else H=S;if(P=W>=(Q=(V+A)/2))V=Q;else A=Q;if(Y=Z,!(Z=Z[F=P<<1|R]))return Y[F]=B,J}if(L=+J._x.call(null,Z.data),I=+J._y.call(null,Z.data),K===L&&W===I)return B.next=Z,Y?Y[F]=B:J._root=B,J;do{if(Y=Y?Y[F]=[,,,,]:J._root=[,,,,],R=K>=(S=(U+H)/2))U=S;else H=S;if(P=W>=(Q=(V+A)/2))V=Q;else A=Q}while((F=P<<1|R)===($=(I>=Q)<<1|L>=S));return Y[$]=Z,Y[F]=B,J}function KX(J){if(!Array.isArray(J))J=Array.from(J);let K=J.length,W=new Float64Array(K),X=new Float64Array(K),Y=1/0,Z=Y,B=-Y,U=B;for(let V=0,H,A,S;V<K;++V){if(isNaN(A=+this._x.call(null,H=J[V]))||isNaN(S=+this._y.call(null,H))){W[V]=NaN;continue}if(W[V]=A,X[V]=S,A<Y)Y=A;if(A>B)B=A;if(S<Z)Z=S;if(S>U)U=S}if(Y>B||Z>U)return this;this.cover(Y,Z).cover(B,U);for(let V=0;V<K;++V)CK(this,W[V],X[V],J[V]);return this}function WX(J,K){if(isNaN(J=+J)||isNaN(K=+K))return this;var W=this._x0,X=this._y0,Y=this._x1,Z=this._y1;if(isNaN(W))Y=(W=Math.floor(J))+1,Z=(X=Math.floor(K))+1;else{var B=Y-W||1,U=this._root,V,H;while(W>J||J>=Y||X>K||K>=Z)switch(H=(K<X)<<1|J<W,V=[,,,,],V[H]=U,U=V,B*=2,H){case 0:Y=W+B,Z=X+B;break;case 1:W=Y-B,Z=X+B;break;case 2:Y=W+B,X=Z-B;break;case 3:W=Y-B,X=Z-B;break}if(this._root&&this._root.length)this._root=U}return this._x0=W,this._y0=X,this._x1=Y,this._y1=Z,this}function XX(){var J=[];return this.visit(function(K){if(!K.length)do J.push(K.data);while(K=K.next)}),J}function YX(J){return arguments.length?this.cover(+J[0][0],+J[0][1]).cover(+J[1][0],+J[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function y(J,K,W,X,Y){this.node=J,this.x0=K,this.y0=W,this.x1=X,this.y1=Y}function ZX(J,K,W){var X,Y=this._x0,Z=this._y0,B,U,V,H,A=this._x1,S=this._y1,Q=[],L=this._root,I,R;if(L)Q.push(new y(L,Y,Z,A,S));if(W==null)W=1/0;else Y=J-W,Z=K-W,A=J+W,S=K+W,W*=W;while(I=Q.pop()){if(!(L=I.node)||(B=I.x0)>A||(U=I.y0)>S||(V=I.x1)<Y||(H=I.y1)<Z)continue;if(L.length){var P=(B+V)/2,F=(U+H)/2;if(Q.push(new y(L[3],P,F,V,H),new y(L[2],B,F,P,H),new y(L[1],P,U,V,F),new y(L[0],B,U,P,F)),R=(K>=F)<<1|J>=P)I=Q[Q.length-1],Q[Q.length-1]=Q[Q.length-1-R],Q[Q.length-1-R]=I}else{var $=J-+this._x.call(null,L.data),N=K-+this._y.call(null,L.data),M=$*$+N*N;if(M<W){var T=Math.sqrt(W=M);Y=J-T,Z=K-T,A=J+T,S=K+T,X=L.data}}}return X}function BX(J){if(isNaN(A=+this._x.call(null,J))||isNaN(S=+this._y.call(null,J)))return this;var K,W=this._root,X,Y,Z,B=this._x0,U=this._y0,V=this._x1,H=this._y1,A,S,Q,L,I,R,P,F;if(!W)return this;if(W.length)while(!0){if(I=A>=(Q=(B+V)/2))B=Q;else V=Q;if(R=S>=(L=(U+H)/2))U=L;else H=L;if(K=W,!(W=W[P=R<<1|I]))return this;if(!W.length)break;if(K[P+1&3]||K[P+2&3]||K[P+3&3])X=K,F=P}while(W.data!==J)if(Y=W,!(W=W.next))return this;if(Z=W.next)delete W.next;if(Y)return Z?Y.next=Z:delete Y.next,this;if(!K)return this._root=Z,this;if(Z?K[P]=Z:delete K[P],(W=K[0]||K[1]||K[2]||K[3])&&W===(K[3]||K[2]||K[1]||K[0])&&!W.length)if(X)X[F]=W;else this._root=W;return this}function UX(J){for(var K=0,W=J.length;K<W;++K)this.remove(J[K]);return this}function HX(){return this._root}function VX(){var J=0;return this.visit(function(K){if(!K.length)do++J;while(K=K.next)}),J}function GX(J){var K=[],W,X=this._root,Y,Z,B,U,V;if(X)K.push(new y(X,this._x0,this._y0,this._x1,this._y1));while(W=K.pop())if(!J(X=W.node,Z=W.x0,B=W.y0,U=W.x1,V=W.y1)&&X.length){var H=(Z+U)/2,A=(B+V)/2;if(Y=X[3])K.push(new y(Y,H,A,U,V));if(Y=X[2])K.push(new y(Y,Z,A,H,V));if(Y=X[1])K.push(new y(Y,H,B,U,A));if(Y=X[0])K.push(new y(Y,Z,B,H,A))}return this}function $X(J){var K=[],W=[],X;if(this._root)K.push(new y(this._root,this._x0,this._y0,this._x1,this._y1));while(X=K.pop()){var Y=X.node;if(Y.length){var Z,B=X.x0,U=X.y0,V=X.x1,H=X.y1,A=(B+V)/2,S=(U+H)/2;if(Z=Y[0])K.push(new y(Z,B,U,A,S));if(Z=Y[1])K.push(new y(Z,A,U,V,S));if(Z=Y[2])K.push(new y(Z,B,S,A,H));if(Z=Y[3])K.push(new y(Z,A,S,V,H))}W.push(X)}while(X=W.pop())J(X.node,X.x0,X.y0,X.x1,X.y1);return this}function MX(J){return J[0]}function AX(J){return arguments.length?(this._x=J,this):this._x}function FX(J){return J[1]}function LX(J){return arguments.length?(this._y=J,this):this._y}function zJ(J,K,W){var X=new oJ(K==null?MX:K,W==null?FX:W,NaN,NaN,NaN,NaN);return J==null?X:X.addAll(J)}function oJ(J,K,W,X,Y,Z){this._x=J,this._y=K,this._x0=W,this._y0=X,this._x1=Y,this._y1=Z,this._root=void 0}function RK(J){var K={data:J.data},W=K;while(J=J.next)W=W.next={data:J.data};return K}var p=zJ.prototype=oJ.prototype;p.copy=function(){var J=new oJ(this._x,this._y,this._x0,this._y0,this._x1,this._y1),K=this._root,W,X;if(!K)return J;if(!K.length)return J._root=RK(K),J;W=[{source:K,target:J._root=[,,,,]}];while(K=W.pop())for(var Y=0;Y<4;++Y)if(X=K.source[Y])if(X.length)W.push({source:X,target:K.target[Y]=[,,,,]});else K.target[Y]=RK(X);return J};p.add=JX;p.addAll=KX;p.cover=WX;p.data=XX;p.extent=YX;p.find=ZX;p.remove=BX;p.removeAll=UX;p.root=HX;p.size=VX;p.visit=GX;p.visitAfter=$X;p.x=AX;p.y=LX;function m(J){return function(){return J}}function WJ(J){return(J()-0.5)*0.000001}function PX(J){return J.x+J.vx}function QX(J){return J.y+J.vy}function OK(J){var K,W,X,Y=1,Z=1;if(typeof J!=="function")J=m(J==null?1:+J);function B(){var H,A=K.length,S,Q,L,I,R,P;for(var F=0;F<Z;++F){S=zJ(K,PX,QX).visitAfter(U);for(H=0;H<A;++H)Q=K[H],R=W[Q.index],P=R*R,L=Q.x+Q.vx,I=Q.y+Q.vy,S.visit($)}function $(N,M,T,E,q){var{data:b,r:f}=N,k=R+f;if(b){if(b.index>Q.index){var h=L-b.x-b.vx,u=I-b.y-b.vy,c=h*h+u*u;if(c<k*k){if(h===0)h=WJ(X),c+=h*h;if(u===0)u=WJ(X),c+=u*u;c=(k-(c=Math.sqrt(c)))/c*Y,Q.vx+=(h*=c)*(k=(f*=f)/(P+f)),Q.vy+=(u*=c)*k,b.vx-=h*(k=1-k),b.vy-=u*k}}return}return M>L+k||E<L-k||T>I+k||q<I-k}}function U(H){if(H.data)return H.r=W[H.data.index];for(var A=H.r=0;A<4;++A)if(H[A]&&H[A].r>H.r)H.r=H[A].r}function V(){if(!K)return;var H,A=K.length,S;W=Array(A);for(H=0;H<A;++H)S=K[H],W[S.index]=+J(S,H,K)}return B.initialize=function(H,A){K=H,X=A,V()},B.iterations=function(H){return arguments.length?(Z=+H,B):Z},B.strength=function(H){return arguments.length?(Y=+H,B):Y},B.radius=function(H){return arguments.length?(J=typeof H==="function"?H:m(+H),V(),B):J},B}function RX(J){return J.index}function SK(J,K){var W=J.get(K);if(!W)throw Error("node not found: "+K);return W}function DK(J){var K=RX,W=S,X,Y=m(30),Z,B,U,V,H,A=1;if(J==null)J=[];function S(P){return 1/Math.min(U[P.source.index],U[P.target.index])}function Q(P){for(var F=0,$=J.length;F<A;++F)for(var N=0,M,T,E,q,b,f,k;N<$;++N)M=J[N],T=M.source,E=M.target,q=E.x+E.vx-T.x-T.vx||WJ(H),b=E.y+E.vy-T.y-T.vy||WJ(H),f=Math.sqrt(q*q+b*b),f=(f-Z[N])/f*P*X[N],q*=f,b*=f,E.vx-=q*(k=V[N]),E.vy-=b*k,T.vx+=q*(k=1-k),T.vy+=b*k}function L(){if(!B)return;var P,F=B.length,$=J.length,N=new Map(B.map((T,E)=>[K(T,E,B),T])),M;for(P=0,U=Array(F);P<$;++P){if(M=J[P],M.index=P,typeof M.source!=="object")M.source=SK(N,M.source);if(typeof M.target!=="object")M.target=SK(N,M.target);U[M.source.index]=(U[M.source.index]||0)+1,U[M.target.index]=(U[M.target.index]||0)+1}for(P=0,V=Array($);P<$;++P)M=J[P],V[P]=U[M.source.index]/(U[M.source.index]+U[M.target.index]);X=Array($),I(),Z=Array($),R()}function I(){if(!B)return;for(var P=0,F=J.length;P<F;++P)X[P]=+W(J[P],P,J)}function R(){if(!B)return;for(var P=0,F=J.length;P<F;++P)Z[P]=+Y(J[P],P,J)}return Q.initialize=function(P,F){B=P,H=F,L()},Q.links=function(P){return arguments.length?(J=P,L(),Q):J},Q.id=function(P){return arguments.length?(K=P,Q):K},Q.iterations=function(P){return arguments.length?(A=+P,Q):A},Q.strength=function(P){return arguments.length?(W=typeof P==="function"?P:m(+P),I(),Q):W},Q.distance=function(P){return arguments.length?(Y=typeof P==="function"?P:m(+P),R(),Q):Y},Q}var CX=1664525,SX=1013904223,NK=4294967296;function NX(){let J=1;return()=>(J=(CX*J+SX)%NK)/NK}function OX(J){return J.x}function DX(J){return J.y}var IX=10,TX=Math.PI*(3-Math.sqrt(5));function IK(J){var K,W=1,X=0.001,Y=1-Math.pow(X,0.0033333333333333335),Z=0,B=0.6,U=new Map,V=FJ(S),H=t("tick","end"),A=NX();if(J==null)J=[];function S(){if(Q(),H.call("tick",K),W<X)V.stop(),H.call("end",K)}function Q(R){var P,F=J.length,$;if(R===void 0)R=1;for(var N=0;N<R;++N){W+=(Z-W)*Y,U.forEach(function(M){M(W)});for(P=0;P<F;++P){if($=J[P],$.fx==null)$.x+=$.vx*=B;else $.x=$.fx,$.vx=0;if($.fy==null)$.y+=$.vy*=B;else $.y=$.fy,$.vy=0}}return K}function L(){for(var R=0,P=J.length,F;R<P;++R){if(F=J[R],F.index=R,F.fx!=null)F.x=F.fx;if(F.fy!=null)F.y=F.fy;if(isNaN(F.x)||isNaN(F.y)){var $=IX*Math.sqrt(0.5+R),N=R*TX;F.x=$*Math.cos(N),F.y=$*Math.sin(N)}if(isNaN(F.vx)||isNaN(F.vy))F.vx=F.vy=0}}function I(R){if(R.initialize)R.initialize(J,A);return R}return L(),K={tick:Q,restart:function(){return V.restart(S),K},stop:function(){return V.stop(),K},nodes:function(R){return arguments.length?(J=R,L(),U.forEach(I),K):J},alpha:function(R){return arguments.length?(W=+R,K):W},alphaMin:function(R){return arguments.length?(X=+R,K):X},alphaDecay:function(R){return arguments.length?(Y=+R,K):+Y},alphaTarget:function(R){return arguments.length?(Z=+R,K):Z},velocityDecay:function(R){return arguments.length?(B=1-R,K):1-B},randomSource:function(R){return arguments.length?(A=R,U.forEach(I),K):A},force:function(R,P){return arguments.length>1?(P==null?U.delete(R):U.set(R,I(P)),K):U.get(R)},find:function(R,P,F){var $=0,N=J.length,M,T,E,q,b;if(F==null)F=1/0;else F*=F;for($=0;$<N;++$)if(q=J[$],M=R-q.x,T=P-q.y,E=M*M+T*T,E<F)b=q,F=E;return b},on:function(R,P){return arguments.length>1?(H.on(R,P),K):H.on(R)}}}function TK(){var J,K,W,X,Y=m(-30),Z,B=1,U=1/0,V=0.81;function H(L){var I,R=J.length,P=zJ(J,OX,DX).visitAfter(S);for(X=L,I=0;I<R;++I)K=J[I],P.visit(Q)}function A(){if(!J)return;var L,I=J.length,R;Z=Array(I);for(L=0;L<I;++L)R=J[L],Z[R.index]=+Y(R,L,J)}function S(L){var I=0,R,P,F=0,$,N,M;if(L.length){for($=N=M=0;M<4;++M)if((R=L[M])&&(P=Math.abs(R.value)))I+=R.value,F+=P,$+=P*R.x,N+=P*R.y;L.x=$/F,L.y=N/F}else{R=L,R.x=R.data.x,R.y=R.data.y;do I+=Z[R.data.index];while(R=R.next)}L.value=I}function Q(L,I,R,P){if(!L.value)return!0;var F=L.x-K.x,$=L.y-K.y,N=P-I,M=F*F+$*$;if(N*N/V<M){if(M<U){if(F===0)F=WJ(W),M+=F*F;if($===0)$=WJ(W),M+=$*$;if(M<B)M=Math.sqrt(B*M);K.vx+=F*L.value*X/M,K.vy+=$*L.value*X/M}return!0}else if(L.length||M>=U)return;if(L.data!==K||L.next){if(F===0)F=WJ(W),M+=F*F;if($===0)$=WJ(W),M+=$*$;if(M<B)M=Math.sqrt(B*M)}do if(L.data!==K)N=Z[L.data.index]*X/M,K.vx+=F*N,K.vy+=$*N;while(L=L.next)}return H.initialize=function(L,I){J=L,W=I,A()},H.strength=function(L){return arguments.length?(Y=typeof L==="function"?L:m(+L),A(),H):Y},H.distanceMin=function(L){return arguments.length?(B=L*L,H):Math.sqrt(B)},H.distanceMax=function(L){return arguments.length?(U=L*L,H):Math.sqrt(U)},H.theta=function(L){return arguments.length?(V=L*L,H):Math.sqrt(V)},H}function EK(J){var K=m(0.1),W,X,Y;if(typeof J!=="function")J=m(J==null?0:+J);function Z(U){for(var V=0,H=W.length,A;V<H;++V)A=W[V],A.vx+=(Y[V]-A.x)*X[V]*U}function B(){if(!W)return;var U,V=W.length;X=Array(V),Y=Array(V);for(U=0;U<V;++U)X[U]=isNaN(Y[U]=+J(W[U],U,W))?0:+K(W[U],U,W)}return Z.initialize=function(U){W=U,B()},Z.strength=function(U){return arguments.length?(K=typeof U==="function"?U:m(+U),B(),Z):K},Z.x=function(U){return arguments.length?(J=typeof U==="function"?U:m(+U),B(),Z):J},Z}function jK(J){var K=m(0.1),W,X,Y;if(typeof J!=="function")J=m(J==null?0:+J);function Z(U){for(var V=0,H=W.length,A;V<H;++V)A=W[V],A.vy+=(Y[V]-A.y)*X[V]*U}function B(){if(!W)return;var U,V=W.length;X=Array(V),Y=Array(V);for(U=0;U<V;++U)X[U]=isNaN(Y[U]=+J(W[U],U,W))?0:+K(W[U],U,W)}return Z.initialize=function(U){W=U,B()},Z.strength=function(U){return arguments.length?(K=typeof U==="function"?U:m(+U),B(),Z):K},Z.y=function(U){return arguments.length?(J=typeof U==="function"?U:m(+U),B(),Z):J},Z}var wJ=(J)=>()=>J;function EX(J,{sourceEvent:K,target:W,transform:X,dispatch:Y}){Object.defineProperties(this,{type:{value:J,enumerable:!0,configurable:!0},sourceEvent:{value:K,enumerable:!0,configurable:!0},target:{value:W,enumerable:!0,configurable:!0},transform:{value:X,enumerable:!0,configurable:!0},_:{value:Y}})}function KJ(J,K,W){this.k=J,this.x=K,this.y=W}KJ.prototype={constructor:KJ,scale:function(J){return J===1?this:new KJ(this.k*J,this.x,this.y)},translate:function(J,K){return J===0&K===0?this:new KJ(this.k,this.x+this.k*J,this.y+this.k*K)},apply:function(J){return[J[0]*this.k+this.x,J[1]*this.k+this.y]},applyX:function(J){return J*this.k+this.x},applyY:function(J){return J*this.k+this.y},invert:function(J){return[(J[0]-this.x)/this.k,(J[1]-this.y)/this.k]},invertX:function(J){return(J-this.x)/this.k},invertY:function(J){return(J-this.y)/this.k},rescaleX:function(J){return J.copy().domain(J.range().map(this.invertX,this).map(J.invert,J))},rescaleY:function(J){return J.copy().domain(J.range().map(this.invertY,this).map(J.invert,J))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var iJ=new KJ(1,0,0);jX.prototype=KJ.prototype;function jX(J){while(!J.__zoom)if(!(J=J.parentNode))return iJ;return J.__zoom}function aJ(J){J.stopImmediatePropagation()}function PJ(J){J.preventDefault(),J.stopImmediatePropagation()}function zX(J){return(!J.ctrlKey||J.type==="wheel")&&!J.button}function wX(){var J=this;if(J instanceof SVGElement){if(J=J.ownerSVGElement||J,J.hasAttribute("viewBox"))return J=J.viewBox.baseVal,[[J.x,J.y],[J.x+J.width,J.y+J.height]];return[[0,0],[J.width.baseVal.value,J.height.baseVal.value]]}return[[0,0],[J.clientWidth,J.clientHeight]]}function zK(){return this.__zoom||iJ}function qX(J){return-J.deltaY*(J.deltaMode===1?0.05:J.deltaMode?1:0.002)*(J.ctrlKey?10:1)}function bX(){return navigator.maxTouchPoints||"ontouchstart"in this}function kX(J,K,W){var X=J.invertX(K[0][0])-W[0][0],Y=J.invertX(K[1][0])-W[1][0],Z=J.invertY(K[0][1])-W[0][1],B=J.invertY(K[1][1])-W[1][1];return J.translate(Y>X?(X+Y)/2:Math.min(0,X)||Math.max(0,Y),B>Z?(Z+B)/2:Math.min(0,Z)||Math.max(0,B))}function qK(){var J=zX,K=wX,W=kX,X=qX,Y=bX,Z=[0,1/0],B=[[-1/0,-1/0],[1/0,1/0]],U=250,V=wK,H=t("start","zoom","end"),A,S,Q,L=500,I=150,R=0,P=10;function F(G){G.property("__zoom",zK).on("wheel.zoom",b,{passive:!1}).on("mousedown.zoom",f).on("dblclick.zoom",k).filter(Y).on("touchstart.zoom",h).on("touchmove.zoom",u).on("touchend.zoom touchcancel.zoom",c).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}F.transform=function(G,O,C,D){var j=G.selection?G.selection():G;if(j.property("__zoom",zK),G!==j)T(G,O,C,D);else j.interrupt().each(function(){E(this,arguments).event(D).start().zoom(null,typeof O==="function"?O.apply(this,arguments):O).end()})},F.scaleBy=function(G,O,C,D){F.scaleTo(G,function(){var j=this.__zoom.k,z=typeof O==="function"?O.apply(this,arguments):O;return j*z},C,D)},F.scaleTo=function(G,O,C,D){F.transform(G,function(){var j=K.apply(this,arguments),z=this.__zoom,w=C==null?M(j):typeof C==="function"?C.apply(this,arguments):C,_=z.invert(w),x=typeof O==="function"?O.apply(this,arguments):O;return W(N($(z,x),w,_),j,B)},C,D)},F.translateBy=function(G,O,C,D){F.transform(G,function(){return W(this.__zoom.translate(typeof O==="function"?O.apply(this,arguments):O,typeof C==="function"?C.apply(this,arguments):C),K.apply(this,arguments),B)},null,D)},F.translateTo=function(G,O,C,D,j){F.transform(G,function(){var z=K.apply(this,arguments),w=this.__zoom,_=D==null?M(z):typeof D==="function"?D.apply(this,arguments):D;return W(iJ.translate(_[0],_[1]).scale(w.k).translate(typeof O==="function"?-O.apply(this,arguments):-O,typeof C==="function"?-C.apply(this,arguments):-C),z,B)},D,j)};function $(G,O){return O=Math.max(Z[0],Math.min(Z[1],O)),O===G.k?G:new KJ(O,G.x,G.y)}function N(G,O,C){var D=O[0]-C[0]*G.k,j=O[1]-C[1]*G.k;return D===G.x&&j===G.y?G:new KJ(G.k,D,j)}function M(G){return[(+G[0][0]+ +G[1][0])/2,(+G[0][1]+ +G[1][1])/2]}function T(G,O,C,D){G.on("start.zoom",function(){E(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(D).end()}).tween("zoom",function(){var j=this,z=arguments,w=E(j,z).event(D),_=K.apply(j,z),x=C==null?M(_):typeof C==="function"?C.apply(j,z):C,o=Math.max(_[1][0]-_[0][0],_[1][1]-_[0][1]),v=j.__zoom,l=typeof O==="function"?O.apply(j,z):O,i=V(v.invert(x).concat(o/v.k),l.invert(x).concat(o/l.k));return function(r){if(r===1)r=l;else{var n=i(r),qJ=o/n[2];r=new KJ(qJ,x[0]-n[0]*qJ,x[1]-n[1]*qJ)}w.zoom(null,r)}})}function E(G,O,C){return!C&&G.__zooming||new q(G,O)}function q(G,O){this.that=G,this.args=O,this.active=0,this.sourceEvent=null,this.extent=K.apply(G,O),this.taps=0}q.prototype={event:function(G){if(G)this.sourceEvent=G;return this},start:function(){if(++this.active===1)this.that.__zooming=this,this.emit("start");return this},zoom:function(G,O){if(this.mouse&&G!=="mouse")this.mouse[1]=O.invert(this.mouse[0]);if(this.touch0&&G!=="touch")this.touch0[1]=O.invert(this.touch0[0]);if(this.touch1&&G!=="touch")this.touch1[1]=O.invert(this.touch1[0]);return this.that.__zoom=O,this.emit("zoom"),this},end:function(){if(--this.active===0)delete this.that.__zooming,this.emit("end");return this},emit:function(G){var O=g(this.that).datum();H.call(G,this.that,new EX(G,{sourceEvent:this.sourceEvent,target:F,transform:this.that.__zoom,dispatch:H}),O)}};function b(G,...O){if(!J.apply(this,arguments))return;var C=E(this,O).event(G),D=this.__zoom,j=Math.max(Z[0],Math.min(Z[1],D.k*Math.pow(2,X.apply(this,arguments)))),z=d(G);if(C.wheel){if(C.mouse[0][0]!==z[0]||C.mouse[0][1]!==z[1])C.mouse[1]=D.invert(C.mouse[0]=z);clearTimeout(C.wheel)}else if(D.k===j)return;else C.mouse=[z,D.invert(z)],LJ(this),C.start();PJ(G),C.wheel=setTimeout(w,I),C.zoom("mouse",W(N($(D,j),C.mouse[0],C.mouse[1]),C.extent,B));function w(){C.wheel=null,C.end()}}function f(G,...O){if(Q||!J.apply(this,arguments))return;var C=G.currentTarget,D=E(this,O,!0).event(G),j=g(G.view).on("mousemove.zoom",x,!0).on("mouseup.zoom",o,!0),z=d(G,C),w=G.clientX,_=G.clientY;_J(G.view),aJ(G),D.mouse=[z,this.__zoom.invert(z)],LJ(this),D.start();function x(v){if(PJ(v),!D.moved){var l=v.clientX-w,i=v.clientY-_;D.moved=l*l+i*i>R}D.event(v).zoom("mouse",W(N(D.that.__zoom,D.mouse[0]=d(v,C),D.mouse[1]),D.extent,B))}function o(v){j.on("mousemove.zoom mouseup.zoom",null),fJ(v.view,D.moved),PJ(v),D.event(v).end()}}function k(G,...O){if(!J.apply(this,arguments))return;var C=this.__zoom,D=d(G.changedTouches?G.changedTouches[0]:G,this),j=C.invert(D),z=C.k*(G.shiftKey?0.5:2),w=W(N($(C,z),D,j),K.apply(this,O),B);if(PJ(G),U>0)g(this).transition().duration(U).call(T,w,D,G);else g(this).call(F.transform,w,D,G)}function h(G,...O){if(!J.apply(this,arguments))return;var C=G.touches,D=C.length,j=E(this,O,G.changedTouches.length===D).event(G),z,w,_,x;aJ(G);for(w=0;w<D;++w)if(_=C[w],x=d(_,this),x=[x,this.__zoom.invert(x),_.identifier],!j.touch0)j.touch0=x,z=!0,j.taps=1+!!A;else if(!j.touch1&&j.touch0[2]!==x[2])j.touch1=x,j.taps=0;if(A)A=clearTimeout(A);if(z){if(j.taps<2)S=x[0],A=setTimeout(function(){A=null},L);LJ(this),j.start()}}function u(G,...O){if(!this.__zooming)return;var C=E(this,O).event(G),D=G.changedTouches,j=D.length,z,w,_,x;PJ(G);for(z=0;z<j;++z)if(w=D[z],_=d(w,this),C.touch0&&C.touch0[2]===w.identifier)C.touch0[0]=_;else if(C.touch1&&C.touch1[2]===w.identifier)C.touch1[0]=_;if(w=C.that.__zoom,C.touch1){var o=C.touch0[0],v=C.touch0[1],l=C.touch1[0],i=C.touch1[1],r=(r=l[0]-o[0])*r+(r=l[1]-o[1])*r,n=(n=i[0]-v[0])*n+(n=i[1]-v[1])*n;w=$(w,Math.sqrt(r/n)),_=[(o[0]+l[0])/2,(o[1]+l[1])/2],x=[(v[0]+i[0])/2,(v[1]+i[1])/2]}else if(C.touch0)_=C.touch0[0],x=C.touch0[1];else return;C.zoom("touch",W(N(w,_,x),C.extent,B))}function c(G,...O){if(!this.__zooming)return;var C=E(this,O).event(G),D=G.changedTouches,j=D.length,z,w;if(aJ(G),Q)clearTimeout(Q);Q=setTimeout(function(){Q=null},L);for(z=0;z<j;++z)if(w=D[z],C.touch0&&C.touch0[2]===w.identifier)delete C.touch0;else if(C.touch1&&C.touch1[2]===w.identifier)delete C.touch1;if(C.touch1&&!C.touch0)C.touch0=C.touch1,delete C.touch1;if(C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2){if(w=d(w,this),Math.hypot(S[0]-w[0],S[1]-w[1])<P){var _=g(this).on("dblclick.zoom");if(_)_.apply(this,arguments)}}}return F.wheelDelta=function(G){return arguments.length?(X=typeof G==="function"?G:wJ(+G),F):X},F.filter=function(G){return arguments.length?(J=typeof G==="function"?G:wJ(!!G),F):J},F.touchable=function(G){return arguments.length?(Y=typeof G==="function"?G:wJ(!!G),F):Y},F.extent=function(G){return arguments.length?(K=typeof G==="function"?G:wJ([[+G[0][0],+G[0][1]],[+G[1][0],+G[1][1]]]),F):K},F.scaleExtent=function(G){return arguments.length?(Z[0]=+G[0],Z[1]=+G[1],F):[Z[0],Z[1]]},F.translateExtent=function(G){return arguments.length?(B[0][0]=+G[0][0],B[1][0]=+G[1][0],B[0][1]=+G[0][1],B[1][1]=+G[1][1],F):[[B[0][0],B[0][1]],[B[1][0],B[1][1]]]},F.constrain=function(G){return arguments.length?(W=G,F):W},F.duration=function(G){return arguments.length?(U=+G,F):U},F.interpolate=function(G){return arguments.length?(V=G,F):V},F.on=function(){var G=H.on.apply(H,arguments);return G===H?F:G},F.clickDistance=function(G){return arguments.length?(R=(G=+G)*G,F):Math.sqrt(R)},F.tapDistance=function(G){return arguments.length?(P=+G,F):P},F}function QY(J={}){return async function(W){W.innerHTML="";let{memories:X}=await bK.listMemories({limit:500}),Y=W.clientWidth||1200,Z=700,B=g(W).append("svg").attr("width",Y).attr("height",Z),U=document.createElement("div");U.className="galaxy-legend",U.innerHTML=`
2
+ <div style="font-weight:600;margin-bottom:.5rem;">Decay levels</div>
3
+ ${kK.map(($,N)=>`
4
+ <div class="galaxy-legend-item">
5
+ <div class="galaxy-legend-dot" style="background:${nJ[N]};"></div>
6
+ <span>L${N} — ${_K(N)}</span>
7
+ </div>`).join("")}
8
+ <div style="margin-top:1rem;font-size:.8rem;color:var(--muted);">
9
+ Size = mnemonic strength<br>Position = mental place
10
+ </div>`,W.appendChild(U);let V=[...new Set(X.map(($)=>$.directory))],H=Math.min(Y,Z)*0.3,A=2*Math.PI/Math.max(1,V.length),S={};V.forEach(($,N)=>{S[$]={x:Y/2+H*Math.cos(N*A),y:Z/2+H*Math.sin(N*A)}});let Q=X.map(($)=>({id:$.id,directory:$.directory,saillance:$.saillance,level:$.currentLevel,photographic:$.photographic,memory:$})),L=X.filter(($)=>$.mergedIntoId&&X.some((N)=>N.id===$.mergedIntoId)).map(($)=>({source:$.id,target:$.mergedIntoId})),I=IK(Q).force("link",DK(L).id(($)=>$.id).distance(50)).force("charge",TK().strength(-30)).force("x",EK(($)=>S[$.directory]?.x??Y/2).strength(0.1)).force("y",jK(($)=>S[$.directory]?.y??Z/2).strength(0.1)).force("collision",OK().radius(($)=>Math.max(5,$.saillance/10))),R=B.append("g");B.call(qK().scaleExtent([0.3,5]).on("zoom",($)=>{R.attr("transform",$.transform)}));let P=R.append("g").selectAll("line").data(L).enter().append("line").attr("class","galaxy-link").attr("stroke","#3f3f4e").attr("stroke-opacity",0.3),F=R.append("g").selectAll("circle").data(Q).enter().append("circle").attr("class","galaxy-node").attr("r",($)=>Math.max(4,$.saillance/8)).attr("fill",($)=>nJ[$.level]).attr("opacity",($)=>Math.max(0.4,$.saillance/100)).attr("stroke",($)=>$.photographic?"#8b5cf6":"none").attr("stroke-width",($)=>$.photographic?2:0).style("cursor","pointer").on("click",($,N)=>J.onSelectMemory?.(N.id)).on("mouseover",($,N)=>{g($.target).transition().duration(200).attr("r",Math.max(6,N.saillance/6))}).on("mouseout",($,N)=>{g($.target).transition().duration(200).attr("r",Math.max(4,N.saillance/8))}).call(eJ().on("start",($,N)=>{if(!$.active)I.alphaTarget(0.3).restart();N.fx=N.x,N.fy=N.y}).on("drag",($,N)=>{N.fx=$.x,N.fy=$.y}).on("end",($,N)=>{if(!$.active)I.alphaTarget(0);N.fx=null,N.fy=null}));return R.append("g").selectAll("text").data(V).enter().append("text").attr("x",($)=>S[$].x).attr("y",($)=>S[$].y-H*0.15).attr("text-anchor","middle").attr("fill","#a1a1aa").attr("font-size","12px").attr("font-weight","600").text(($)=>$.split(/[\\/]/).pop()||$),I.on("tick",()=>{P.attr("x1",($)=>$.source.x).attr("y1",($)=>$.source.y).attr("x2",($)=>$.target.x).attr("y2",($)=>$.target.y),F.attr("cx",($)=>$.x).attr("cy",($)=>$.y)}),()=>{I.stop(),W.innerHTML=""}}}export{QY as createMount};
@@ -1,2 +1,2 @@
1
1
  var g={0:"#22c55e",1:"#eab308",2:"#f97316",3:"#ef4444",4:"#6b7280"},c=["L0 — Encoding","L1 — Consolidation","L2 — Stable","L3 — Fragile","L4 — Dormant"];function j(b){return c[b].split("—")[1]?.trim()??String(b)}
2
- export{g as t,c as u,j as v};
2
+ export{g as u,c as v,j as w};