diff --git a/api/automation_engine.py b/api/automation_engine.py new file mode 100644 index 0000000000000000000000000000000000000000..fad0d3a727032debd2496582e142c32b2afdb4e2 --- /dev/null +++ b/api/automation_engine.py @@ -0,0 +1,1377 @@ +"""automation_engine.py — wave-18 item 5 (contract C4-AUTO): the automation RUNTIME. + +THE SHAPE, and why it is this shape. An automation is a DEFINITION that lives in the tenant +store and a RUN that lives in this process. The definition is durable, small and rarely written; +the run is hot, chatty and worthless five minutes later. Conflating them is the failure this file +is built to avoid, and it has two halves: + + * **Run state is NEVER persisted while it is running.** A `state: 'running'` written to the + store outlives the process that wrote it, so a container restart mid-run leaves an automation + that can never run again — the 409 sees a `running` nothing will ever clear. Hot state lives + in `_RUNNING` (a process dict, cleared by definition on restart) and the store is written + exactly ONCE per run, at the end. + * **One coalesced store update per run per bucket.** `core/store.py` coalesces on a 20 s + floor per key against a 256-commits/hour repo budget, so a per-ROW write is the wrong shape + by two orders of magnitude — the S&P demo alone is ~500 rows. Every runner below computes + its whole result first and commits it in a single `update` callback. + +WHAT IS VENDORED HERE AND WHY. `.claude/skills/browse/scrape.py` is not on `sys.path` and is not +deployed, so its extraction core is copied into this file (the wave doc's instruction), ported +httpx → requests (the only HTTP dependency this API already carries). The SSRF rail comes with +it, HARDENED rather than merely preserved — see `guard`/`fetch`. That hardening is the point: +the skill version takes a URL from a developer on a CLI; this takes one from a request body. +""" +from __future__ import annotations + +import datetime as _dt +import ipaddress +import json +import os +import re +import socket +import threading +import time +from urllib.parse import urljoin, urlparse + +import requests + +try: # the parser the extraction half needs + from bs4 import BeautifulSoup +except Exception: # pragma: no cover — deploy lag; see mailbox ② + BeautifulSoup = None + +# --------------------------------------------------------------------------------------------- +# THE BUCKET (C4-AUTO) +# --------------------------------------------------------------------------------------------- + +#: The per-tenant store key. Colocated with its reader, the `routes_nav._NAV_PREFS_KEY` pattern. +STORE_KEY = "automations" +#: The user-table bucket. ⚠ Read/written HERE through `TenantRuntime`, never through +#: `core.user_tables` — that module writes the UNPREFIXED module-global key, which is correct for +#: tenant #0 (empty prefix) and silently cross-tenant for every R2 tenant after it. Booked in the +#: session-D mailbox as a finding against A's file rather than fixed from here. +UT_STORE_KEY = "user_tables" +UT_PREFIX = "ut_" + +MAX_AUTOMATIONS = 40 +MAX_RUNS = 20 # trimmed history per automation +MAX_NAME = 80 +MAX_UT_ROWS = 5000 # mirrors core.user_tables.MAX_ROWS +MAX_UT_TABLES = 40 + +KINDS = ("scrape_db", "field_instagram") +EXTRACTS = ("table", "jsonld") +STATES = ("idle", "running", "ok", "error", "partial") + +#: Schedule presets the editor offers. Kept here (not in the client) so the vocabulary the UI +#: shows and the vocabulary the parser accepts cannot drift. +CRON_PRESETS = [ + {"cron": "*/15 * * * *", "label": "Every 15 minutes"}, + {"cron": "0 * * * *", "label": "Hourly"}, + {"cron": "0 6 * * *", "label": "Daily at 06:00"}, + {"cron": "0 6 * * 1", "label": "Weekly (Monday 06:00)"}, + {"cron": "0 6 1 * *", "label": "Monthly (1st, 06:00)"}, +] + +UA = "Mozilla/5.0 (compatible; AIOS-automation/1.0; +https://aios.local/automation)" + + +def _now(): + return _dt.datetime.now() + + +def _stamp(dt=None): + return (dt or _now()).strftime("%Y-%m-%d %H:%M") + + +def _iso(dt=None): + return (dt or _now()).strftime("%Y-%m-%dT%H:%M:%S") + + +def _parse_iso(s): + try: + return _dt.datetime.strptime(str(s)[:19], "%Y-%m-%dT%H:%M:%S") + except Exception: + return None + + +# --------------------------------------------------------------------------------------------- +# THE SSRF RAIL — vendored from scrape.py `guard`, then hardened for a SERVER-SIDE fetcher +# --------------------------------------------------------------------------------------------- +# The skill version guards the URL a developer typed. This one guards a URL that arrived in a +# request body, which changes the threat model in two ways the original does not cover: +# +# 1. REDIRECTS. `httpx.Client(follow_redirects=True)` / `requests.get(allow_redirects=True)` +# never re-enter the guard, so `http://evil.example/x` → 302 → `http://169.254.169.254/…` +# sails straight past a guard that only ever saw the first URL. The negative control ("a +# localhost URL is refused") would still pass while the rail was wide open. `fetch` below +# therefore takes the hops MANUALLY and re-guards every one. +# 2. DNS. A perfectly public hostname may resolve to a private address. `guard` resolves the +# host and checks EVERY answer, not just the literal. +# +# ⚠ STATED, NOT HIDDEN: this is check-then-connect, so a DNS-rebinding attacker who flips the +# record between the guard and the socket is not stopped by it. Closing that needs a pinned +# connection to the validated IP (a custom adapter). Out of scope for v1 and recorded here rather +# than implied away — the rail refuses the realistic cases and says what it does not cover. + +class Refused(ValueError): + """The rail refused a URL. A distinct type so a refusal is never logged as a fetch error.""" + + +def _ip_public(ip): + return not (ip.is_private or ip.is_loopback or ip.is_link_local + or ip.is_reserved or ip.is_unspecified or ip.is_multicast) + + +def guard(url, allowed=()): + """PUBLIC-WEB-ONLY rail: http(s) only, no loopback/private/link-local host, DNS answers + checked too, plus the optional `--allowed` domain rail scrape.py carries.""" + p = urlparse(url or "") + if p.scheme not in ("http", "https"): + raise Refused(f"only http(s) allowed, not {p.scheme!r}") + host = (p.hostname or "").strip() + if not host: + raise Refused("no host in the URL") + low = host.lower() + if (low in ("localhost", "localhost.localdomain") + or low.endswith(".local") or low.endswith(".internal") + or low.endswith(".localhost")): + raise Refused(f"refused non-public host {host!r} (public web only)") + try: # a bare-IP host is decided on the literal + ip = ipaddress.ip_address(low) + except ValueError: + ip = None + if ip is not None and not _ip_public(ip): + raise Refused(f"refused non-public IP {host} (public web only)") + if allowed and not any(low == d.lower() or low.endswith("." + d.lower()) for d in allowed): + raise Refused(f"host {host!r} not in the allowed domains {list(allowed)}") + if ip is None: + try: + infos = socket.getaddrinfo(host, None) + except Exception as e: + raise Refused(f"could not resolve {host!r}: {type(e).__name__}") + for info in infos: + addr = info[4][0] + try: + resolved = ipaddress.ip_address(addr.split("%")[0]) + except ValueError: + continue + if not _ip_public(resolved): + raise Refused( + f"refused {host!r}: it resolves to the non-public address {resolved}") + return True + + +def fetch(url, timeout=20.0, max_kb=2048, allowed=(), max_hops=5, headers=None): + """GET `url`, taking redirects BY HAND so every hop passes `guard`. + + Returns `(status, final_url, body_bytes)`. A hop chain longer than `max_hops` is a refusal, + not a silent truncation — an endless redirect is indistinguishable from an attempt to walk + the fetcher somewhere it was told not to go. + """ + current = url + hdrs = {"User-Agent": UA, "Accept-Language": "en-US,en;q=0.9"} + hdrs.update(headers or {}) + for _hop in range(max_hops + 1): + guard(current, allowed) + r = requests.get(current, timeout=timeout, headers=hdrs, + allow_redirects=False, stream=True) + if r.status_code in (301, 302, 303, 307, 308): + loc = r.headers.get("Location") + r.close() + if not loc: + raise Refused(f"redirect {r.status_code} with no Location header") + current = urljoin(current, loc) + continue + body = r.raw.read(max_kb * 1024, decode_content=True) or b"" + status, final = r.status_code, str(r.url) + r.close() + return status, final, body + raise Refused(f"more than {max_hops} redirects — refusing to follow further") + + +# --------------------------------------------------------------------------------------------- +# EXTRACTION — vendored from scrape.py, unchanged in behaviour +# --------------------------------------------------------------------------------------------- + +def _soup(body): + if BeautifulSoup is None: + raise RuntimeError( + "beautifulsoup4 is not installed in this environment — the automation engine's " + "extraction half needs it (see the wave-18 mailbox: add beautifulsoup4 + lxml to " + "aios-web/requirements.txt).") + try: + return BeautifulSoup(body, "lxml") + except Exception: + return BeautifulSoup(body, "html.parser") + + +def tables(soup): + """Every HTML table as rows. Dict rows when the first row looks like a header.""" + out = [] + for t in soup.find_all("table"): + rows = [] + for tr in t.find_all("tr"): + cells = [c.get_text(" ", strip=True) for c in tr.find_all(["th", "td"])] + if cells: + rows.append(cells) + if not rows: + continue + head, body = rows[0], rows[1:] + if body and len(head) == len(body[0]) and all(head): + out.append([dict(zip(head, r)) for r in body if len(r) == len(head)]) + else: + out.append(rows) + return out + + +def jsonld(soup): + out = [] + for s in soup.find_all("script", attrs={"type": "application/ld+json"}): + try: + out.append(json.loads(s.string or s.get_text())) + except Exception: + pass + return out + + +def meta(soup): + m = {} + if soup.title and soup.title.string: + m["title"] = soup.title.string.strip() + for tag in soup.find_all("meta"): + k = tag.get("name") or tag.get("property") + v = tag.get("content") + if k and v and (k in ("description", "keywords", "author") + or k.startswith(("og:", "twitter:"))): + m[k] = v.strip() + return m + + +def preview(url, extract="table", table_index=0, allowed=()): + """The field-map preview the editor calls BEFORE anything is created: what columns does this + page actually offer, and what do the first rows look like? Never writes.""" + status, final, body = fetch(url, allowed=allowed) + if not (200 <= status < 300): + return {"ok": False, "status": status, "url": final, + "note": f"the page answered {status} — it may be bot-gated or gone", + "columns": [], "sample": [], "rowCount": 0} + soup = _soup(body) + rows = [] + if extract == "jsonld": + blocks = jsonld(soup) + flat = [] + for b in blocks: + if isinstance(b, list): + flat.extend([x for x in b if isinstance(x, dict)]) + elif isinstance(b, dict): + items = b.get("itemListElement") + flat.extend([x for x in items if isinstance(x, dict)] if isinstance(items, list) + else [b]) + rows = [{k: _scalar(v) for k, v in d.items()} for d in flat] + else: + found = tables(soup) + idx = max(0, min(int(table_index or 0), len(found) - 1)) if found else 0 + picked = found[idx] if found else [] + rows = [r for r in picked if isinstance(r, dict)] + cols, seen = [], set() + for r in rows[:50]: + for k in r: + if k not in seen: + seen.add(k) + cols.append(k) + return {"ok": True, "status": status, "url": final, "columns": cols, + "sample": rows[:8], "rowCount": len(rows), + "tableCount": len(tables(soup)) if extract != "jsonld" else 0, + "title": (meta(soup) or {}).get("title", "")} + + +def _scalar(v): + if isinstance(v, (str, int, float)) and not isinstance(v, bool): + return str(v) + if isinstance(v, bool): + return "1" if v else "" + if isinstance(v, dict): + return str(v.get("name") or v.get("@id") or "") + if isinstance(v, list): + return ", ".join(_scalar(x) for x in v[:8]) + return "" + + +# --------------------------------------------------------------------------------------------- +# CRON — a 5-field parser and a "what was the last fire time" walk +# --------------------------------------------------------------------------------------------- +# Deliberately NOT `croniter` (a dependency for ~60 lines) and deliberately NOT a forward +# scheduler. The question a tick asks is backwards-looking — *"was there a scheduled minute +# between the last run and now?"* — and answering it that way is what makes a missed tick +# self-healing: a container that was asleep for two hours runs once on wake, not eleven times and +# not never. + +_FIELD_RANGES = [(0, 59), (0, 23), (1, 31), (1, 12), (0, 6)] + + +def _parse_field(spec, lo, hi): + out = set() + for part in str(spec).split(","): + part = part.strip() + if not part: + raise ValueError("empty cron field part") + step = 1 + if "/" in part: + part, _, s = part.partition("/") + step = int(s) + if step < 1: + raise ValueError("cron step must be >= 1") + if part in ("*", "?"): + a, b = lo, hi + elif "-" in part.lstrip("-"): + a_s, _, b_s = part.partition("-") + a, b = int(a_s), int(b_s) + else: + a = b = int(part) + if a < lo or b > hi or a > b: + raise ValueError(f"cron value {part!r} out of range {lo}..{hi}") + out.update(range(a, b + 1, step)) + return out + + +def parse_cron(expr): + """`'m h dom mon dow'` → `(minutes, hours, doms, months, dows, dom_restricted, dow_restricted)`. + + Raises ValueError on anything malformed — a schedule that cannot be parsed must be refused at + WRITE time, because a cron string nobody can evaluate is an automation that silently never + runs and reports no error anywhere. + """ + parts = str(expr or "").split() + if len(parts) != 5: + raise ValueError("a cron schedule has exactly 5 fields: minute hour day month weekday") + sets = [_parse_field(p, lo, hi) for p, (lo, hi) in zip(parts, _FIELD_RANGES)] + dom_r = parts[2].strip() not in ("*", "?") + dow_r = parts[4].strip() not in ("*", "?") + return (sets[0], sets[1], sets[2], sets[3], sets[4] | ({0} if 7 in sets[4] else set()), + dom_r, dow_r) + + +def _day_matches(day, doms, months, dows, dom_r, dow_r): + if day.month not in months: + return False + # POSIX rule: with BOTH day-of-month and weekday restricted the match is the UNION, not the + # intersection. `0 6 1 * 1` means "the 1st, and every Monday" — getting this backwards makes + # a schedule that looks right fire almost never. + dow = (day.weekday() + 1) % 7 # python Mon=0 -> cron Sun=0 + if dom_r and dow_r: + return day.day in doms or dow in dows + if dom_r: + return day.day in doms + if dow_r: + return dow in dows + return True + + +def prev_fire(expr, now=None, lookback_days=400): + """The most recent scheduled minute at or before `now`, or None inside the lookback. + + Walks by DAY (≤400 iterations) rather than by minute (≥500k) — the day fields decide first, + and only a matching day needs its hours/minutes searched. + """ + minutes, hours, doms, months, dows, dom_r, dow_r = parse_cron(expr) + now = (now or _now()).replace(second=0, microsecond=0) + for back in range(lookback_days + 1): + day = (now - _dt.timedelta(days=back)).date() + if not _day_matches(day, doms, months, dows, dom_r, dow_r): + continue + same_day = back == 0 + for h in sorted(hours, reverse=True): + if same_day and h > now.hour: + continue + for m in sorted(minutes, reverse=True): + if same_day and h == now.hour and m > now.minute: + continue + return _dt.datetime(day.year, day.month, day.day, h, m) + return None + + +def is_due(defn, now=None): + """Should the scheduler run this automation right now? + + Due when a scheduled minute exists strictly AFTER the reference point (the last run, else the + moment the schedule was enabled, else creation) and at or before now. Anchoring on + `enabledAt` rather than firing on the first tick is what stops "enable a daily 06:00 job at + 14:00" from running immediately and looking like a bug. + """ + if not isinstance(defn, dict): + return False + sched = defn.get("schedule") or {} + if not sched.get("enabled"): + return False + try: + fire = prev_fire(sched.get("cron"), now=now) + except ValueError: + return False + if fire is None: + return False + since = (_parse_iso((defn.get("status") or {}).get("lastRunAt")) + or _parse_iso(sched.get("enabledAt")) + or _parse_iso(defn.get("created"))) + return since is None or fire > since + + +def next_fire(expr, now=None, lookahead_days=400): + """The next scheduled minute strictly after `now` — display only (the rail is `is_due`).""" + try: + minutes, hours, doms, months, dows, dom_r, dow_r = parse_cron(expr) + except ValueError: + return None + now = (now or _now()).replace(second=0, microsecond=0) + for ahead in range(lookahead_days + 1): + day = (now + _dt.timedelta(days=ahead)).date() + if not _day_matches(day, doms, months, dows, dom_r, dow_r): + continue + same_day = ahead == 0 + for h in sorted(hours): + if same_day and h < now.hour: + continue + for m in sorted(minutes): + if same_day and h == now.hour and m <= now.minute: + continue + return _dt.datetime(day.year, day.month, day.day, h, m) + return None + + +# --------------------------------------------------------------------------------------------- +# THE UPSERT — pure, so the arithmetic is testable without a store or a network +# --------------------------------------------------------------------------------------------- + +def upsert_rows(existing, incoming, key_field): + """Merge scraped rows into a user table's rows BY KEY. Returns `(rows, counts)`. + + THE RULE THAT MATTERS: **an orphan is COUNTED, NEVER DELETED.** A row that has stopped + appearing on the source page has not necessarily stopped existing — the page changed its + filter, the fetch was partial, the site paginated. Deleting on absence turns any upstream + hiccup into silent data loss, and the row may be carrying user-typed overlay values in + columns the scrape never touches. So the run reports `orphans: N` and leaves them alone. + + Only MAPPED keys are written: a re-run never clobbers a column a user added by hand. + """ + rows = {str(k): dict(v or {}) for k, v in (existing or {}).items()} + counts = {"inserted": 0, "updated": 0, "unchanged": 0, + "skipped": 0, "duplicates": 0, "orphans": 0} + by_key, dupe_ids = {}, set() + for rid, row in rows.items(): + kv = str(row.get(key_field, "") or "").strip() + if not kv: + continue + if kv in by_key: + dupe_ids.add(rid) # a pre-existing duplicate: first id wins, second left + continue + by_key[kv] = rid + next_id = max((int(r) for r in rows if str(r).isdigit()), default=0) + 1 + seen_keys, incoming_dupes = set(), 0 + for src in incoming or []: + kv = str((src or {}).get(key_field, "") or "").strip() + if not kv: + counts["skipped"] += 1 # no key -> cannot be upserted; never guessed + continue + if kv in seen_keys: + incoming_dupes += 1 # the SOURCE listed it twice; first wins + continue + seen_keys.add(kv) + rid = by_key.get(kv) + if rid is None: + if len(rows) >= MAX_UT_ROWS: + counts["skipped"] += 1 + continue + rid = str(next_id) + next_id += 1 + rows[rid] = dict(src) + by_key[kv] = rid + counts["inserted"] += 1 + continue + before = rows[rid] + changed = {k: v for k, v in src.items() if str(before.get(k, "")) != str(v)} + if changed: + before.update(src) + counts["updated"] += 1 + else: + counts["unchanged"] += 1 + counts["duplicates"] = incoming_dupes + len(dupe_ids) + counts["orphans"] = sum( + 1 for kv, rid in by_key.items() if kv not in seen_keys and rid not in dupe_ids) + return rows, counts + + +# --------------------------------------------------------------------------------------------- +# USER TABLES — read/write through the RUNTIME (never core.user_tables' module-global key) +# --------------------------------------------------------------------------------------------- + +def _ut_slug(label): + s = re.sub(r"[^a-z0-9]+", "_", str(label or "").strip().lower()).strip("_") + return (s or "table")[:40] + + +def ut_all(rt): + try: + return dict(rt.get(UT_STORE_KEY) or {}) + except Exception: + return {} + + +def ut_get(rt, key): + return ut_all(rt).get(str(key)) + + +def ut_ensure(rt, label, fields, username="automation", key=None): + """Create the table if it is missing; return its key. Idempotent — a re-run of an automation + that owns a table must not spawn `ut_x_2`, so the key is DERIVED from the label (or given) + and an existing table with that key is adopted, not duplicated. + + Fields are MERGED, never replaced: a user who added a column to an automation's table keeps + it, and a new source column joins on the next run. + """ + key = str(key or (UT_PREFIX + _ut_slug(label))) + if not key.startswith(UT_PREFIX): + key = UT_PREFIX + key + wanted = list(fields or []) + created = _iso() + + # ⚠ SKIP THE WRITE WHEN NOTHING WOULD CHANGE. Without this, every re-run spends a store + # commit re-writing an identical definition — against a 20 s flush floor and a 256/hr repo + # budget, an idempotent helper that always writes is the same defect as a per-row insert. + have = ut_get(rt, key) + if have is not None and not [f for f in wanted + if f.get("key") not in {g.get("key") + for g in (have.get("fields") or [])}]: + return key + + def _up(cur): + cur = cur if isinstance(cur, dict) else {} + t = cur.get(key) + if t is None: + if len(cur) >= MAX_UT_TABLES: + return cur + cur[key] = {"key": key, "label": str(label)[:60], "source": "Automation", + "createdBy": username, "created": created, + "fields": wanted, "rows": {}} + return cur + have = {f.get("key") for f in (t.get("fields") or [])} + for f in wanted: + if f.get("key") not in have: + t.setdefault("fields", []).append(f) + have.add(f.get("key")) + # An automation's table SAYS an automation owns it — the nav badge reads from this. + t["source"] = t.get("source") or "Automation" + return cur + + rt.update(UT_STORE_KEY, _up, flush="sync") + return key + + +def ut_write_rows(rt, key, rows): + """ONE store update for the WHOLE row set — the flush-ceiling rule (see the module header).""" + def _up(cur): + cur = cur if isinstance(cur, dict) else {} + t = cur.get(key) + if t is not None: + t["rows"] = rows + return cur + rt.update(UT_STORE_KEY, _up, flush="sync") + + +def ut_set_cell(rt, key, row_id, field_key, value, extra_rows=None): + """Write one automation-owned cell (+ optional whole extra tables) in ONE update.""" + def _up(cur): + cur = cur if isinstance(cur, dict) else {} + t = cur.get(key) + if t is not None: + t.setdefault("rows", {}).setdefault(str(row_id), {})[field_key] = value + for k, rws in (extra_rows or {}).items(): + tt = cur.get(k) + if tt is not None: + tt["rows"] = rws + return cur + rt.update(UT_STORE_KEY, _up, flush="sync") + + +def field_def(text_key, label, ftype="text"): + return {"key": text_key, "label": label, "type": ftype, "source": "overlay"} + + +# --------------------------------------------------------------------------------------------- +# DEFINITIONS — validation and the bucket's read/write half +# --------------------------------------------------------------------------------------------- + +def _s(v, n=200): + return str(v if v is not None else "")[:n] + + +def clean_config(kind, raw): + """Validate a kind's config. Returns `(config, error)`; error is a user-facing sentence.""" + raw = raw if isinstance(raw, dict) else {} + if kind == "scrape_db": + url = _s(raw.get("url"), 2000).strip() + if not url: + return None, "a source URL is required" + try: + guard(url) + except Refused as e: + return None, str(e) + extract = raw.get("extract") if raw.get("extract") in EXTRACTS else "table" + fmap = {} + for k, v in list((raw.get("fieldMap") or {}).items())[:60]: + tk = re.sub(r"[^a-z0-9_]+", "_", _s(v, 60).strip().lower()).strip("_") + if tk: + fmap[_s(k, 120)] = tk[:60] + if not fmap: + return None, "map at least one source column to a field" + key_field = _s(raw.get("keyField"), 60).strip() + if key_field not in fmap.values(): + return None, "the key field must be one of the mapped fields" + target = _s(raw.get("targetTable"), 60).strip() + if target and not target.startswith(UT_PREFIX): + target = UT_PREFIX + target + return {"url": url, "extract": extract, + "tableIndex": max(0, min(int(raw.get("tableIndex") or 0), 50)), + "fieldMap": fmap, "keyField": key_field, + "targetTable": target, + "targetLabel": _s(raw.get("targetLabel"), 60).strip() or "Scraped table"}, None + if kind == "field_instagram": + table = _s(raw.get("targetTable"), 60).strip() + if not table.startswith(UT_PREFIX): + return None, "an Instagram automation runs against a blank database (ut_*)" + fkey = _s(raw.get("fieldKey"), 80).strip() + if not fkey: + return None, "pick the automation column this run writes into" + return {"targetTable": table, "fieldKey": fkey, + "urlField": _s(raw.get("urlField"), 80).strip(), + "maxPosts": max(1, min(int(raw.get("maxPosts") or 24), 200))}, None + return None, f"unknown automation kind {kind!r}" + + +def clean_schedule(raw, previous=None): + """Validate `{cron, enabled}` and stamp `enabledAt` on the OFF→ON edge (the anchor `is_due` + measures from — without it, enabling a daily job fires it immediately).""" + raw = raw if isinstance(raw, dict) else {} + cron = _s(raw.get("cron"), 120).strip() or "0 6 * * *" + parse_cron(cron) # raises -> the route answers 400 + enabled = bool(raw.get("enabled")) + prev = previous or {} + out = {"cron": cron, "enabled": enabled} + if enabled: + out["enabledAt"] = (prev.get("enabledAt") if prev.get("enabled") else None) or _iso() + return out + + +def clean_definition(raw, previous=None, username=""): + """Whole-definition validation. Returns `(defn, error)`.""" + raw = raw if isinstance(raw, dict) else {} + prev = previous or {} + kind = _s(raw.get("kind") or prev.get("kind"), 40) + if kind not in KINDS: + return None, f"unknown automation kind {kind!r}" + name = " ".join(_s(raw.get("name") or prev.get("name") or "", MAX_NAME).split()) + if not name: + return None, "name the automation" + cfg_raw = raw.get("config") if isinstance(raw.get("config"), dict) else prev.get("config") + config, err = clean_config(kind, cfg_raw) + if err: + return None, err + try: + schedule = clean_schedule( + raw.get("schedule") if isinstance(raw.get("schedule"), dict) + else prev.get("schedule"), prev.get("schedule")) + except ValueError as e: + return None, str(e) + return { + "id": _s(prev.get("id") or raw.get("id"), 40), + "name": name, "kind": kind, "config": config, "schedule": schedule, + "status": prev.get("status") or {"state": "idle", "lastRunAt": "", "lastSummary": ""}, + "runs": list(prev.get("runs") or [])[:MAX_RUNS], + "created": prev.get("created") or _iso(), + "createdBy": prev.get("createdBy") or username, + }, None + + +def all_definitions(rt): + try: + return dict(rt.get(STORE_KEY) or {}) + except Exception: + return {} + + +def _new_id(existing): + n = 1 + while f"auto_{n}" in existing: + n += 1 + return f"auto_{n}" + + +def create(rt, raw, username=""): + existing = all_definitions(rt) + if len(existing) >= MAX_AUTOMATIONS: + return None, f"this workspace is at the {MAX_AUTOMATIONS}-automation limit" + defn, err = clean_definition(raw, None, username) + if err: + return None, err + defn["id"] = _new_id(existing) + + def _up(cur): + cur = cur if isinstance(cur, dict) else {} + cur[defn["id"]] = defn + return cur + + rt.update(STORE_KEY, _up, flush="sync") + return defn, None + + +def patch(rt, auto_id, raw, username=""): + existing = all_definitions(rt) + prev = existing.get(str(auto_id)) + if prev is None: + return None, "no such automation" + merged = dict(prev) + for k in ("name", "config", "schedule", "kind"): + if k in (raw or {}): + merged[k] = raw[k] + defn, err = clean_definition(merged, prev, username) + if err: + return None, err + defn["id"] = str(auto_id) + + def _up(cur): + cur = cur if isinstance(cur, dict) else {} + cur[defn["id"]] = defn + return cur + + rt.update(STORE_KEY, _up, flush="sync") + return defn, None + + +def remove(rt, auto_id): + def _up(cur): + cur = cur if isinstance(cur, dict) else {} + cur.pop(str(auto_id), None) + return cur + rt.update(STORE_KEY, _up, flush="sync") + + +# --------------------------------------------------------------------------------------------- +# RUN STATE — process memory only (see the module header for why this may never be persisted) +# --------------------------------------------------------------------------------------------- + +_RUN_LOCK = threading.RLock() +_RUNNING = {} # (tenant, id) -> {'startedAt', 'step'} + + +def running(tenant, auto_id): + with _RUN_LOCK: + return dict(_RUNNING.get((tenant, str(auto_id))) or {}) or None + + +def _claim(tenant, auto_id): + with _RUN_LOCK: + if (tenant, str(auto_id)) in _RUNNING: + return False + _RUNNING[(tenant, str(auto_id))] = {"startedAt": _iso(), "step": "starting"} + return True + + +def _step(tenant, auto_id, text): + with _RUN_LOCK: + cur = _RUNNING.get((tenant, str(auto_id))) + if cur is not None: + cur["step"] = text + + +def _release(tenant, auto_id): + with _RUN_LOCK: + _RUNNING.pop((tenant, str(auto_id)), None) + + +def _commit_run(rt, auto_id, state, summary, counts, ok, affected=None): + """THE ONE store write a run performs on the `automations` bucket.""" + entry = {"ts": _iso(), "ok": bool(ok), "summary": _s(summary, 400), + "counts": {k: int(v) for k, v in (counts or {}).items() + if isinstance(v, (int, float))}, + "affected": list(affected or [])[:200]} + + def _up(cur): + cur = cur if isinstance(cur, dict) else {} + d = cur.get(str(auto_id)) + if d is None: + return cur + d["status"] = {"state": state, "lastRunAt": entry["ts"], + "lastSummary": entry["summary"]} + d["runs"] = ([entry] + list(d.get("runs") or []))[:MAX_RUNS] + return cur + + rt.update(STORE_KEY, _up, flush="sync") + return entry + + +# --------------------------------------------------------------------------------------------- +# INSTAGRAM (R7) — ANONYMOUS PUBLIC ENDPOINTS ONLY +# --------------------------------------------------------------------------------------------- +# The rails, restated because they are the whole reason this is allowed to exist: **no login, no +# credentials, no session cookie, public data only.** Nothing here authenticates, and nothing +# here should ever be given something to authenticate WITH. +# +# ⚠ HONEST STATUSES ARE THE FEATURE. Instagram rate-limits and outright blocks datacenter egress +# (the HF Space and any AWS Lambda are both in that class), and its anonymous surface has been +# progressively closed for years. So this returns a STATE — ok / partial / blocked / error — and +# the cell says which. A pull that quietly wrote zero posts and reported success would be worse +# than no automation at all: the table would look maintained and be empty. +# +# THE LADDER, tried in order with pacing between rungs. Each rung records how it did in `via`, +# so a run history answers "what still works anonymously?" from data rather than from memory. + +PACE_SECONDS = float(os.environ.get("AIOS_IG_PACE_SECONDS") or 2.5) +IG_APP_ID = "936619743392459" # the public web client id the browser itself sends +IG_MAX_RETRIES = 2 + +SNAPSHOT_FIELDS = [ + field_def("snapshot_key", "Snapshot"), field_def("influencer_key", "Influencer"), + field_def("pulled_at", "Pulled at"), field_def("followers", "Followers"), + field_def("following", "Following"), field_def("posts_count", "Posts"), + field_def("full_name", "Name"), field_def("bio", "Bio"), + field_def("verified", "Verified"), field_def("source", "Read via"), + field_def("approx", "Counts are approximate"), +] +POST_FIELDS = [ + field_def("shortcode", "Shortcode"), field_def("influencer_key", "Influencer"), + field_def("posted_at", "Posted at"), field_def("type", "Type"), + field_def("caption", "Caption"), field_def("url", "URL", "url"), +] +POST_SNAPSHOT_FIELDS = [ + field_def("post_snapshot_key", "Snapshot"), field_def("shortcode", "Shortcode"), + field_def("pulled_at", "Pulled at"), field_def("likes", "Likes"), + field_def("comments", "Comments"), +] + + +def ig_handle(url): + """The handle out of a profile URL (or a bare handle). '' when it is not one.""" + raw = str(url or "").strip() + if not raw: + return "" + if raw.startswith("@"): + return re.sub(r"[^A-Za-z0-9._]", "", raw[1:])[:40] + if "instagram.com" not in raw: + return re.sub(r"[^A-Za-z0-9._]", "", raw)[:40] if "/" not in raw else "" + path = urlparse(raw if "//" in raw else "https://" + raw).path.strip("/") + first = (path.split("/") or [""])[0] + if first in ("p", "reel", "reels", "explore", "accounts", "stories", ""): + return "" + return re.sub(r"[^A-Za-z0-9._]", "", first)[:40] + + +def _ig_get(url, headers=None, timeout=20.0): + """One anonymous GET with 429 backoff. Returns `(status, body_bytes, note)`.""" + delay = PACE_SECONDS + for attempt in range(IG_MAX_RETRIES + 1): + try: + status, _final, body = fetch(url, timeout=timeout, headers=headers, max_kb=4096) + except Refused: + raise + except Exception as e: # noqa: BLE001 + return 0, b"", f"{type(e).__name__}: {str(e)[:120]}" + if status == 429 and attempt < IG_MAX_RETRIES: + time.sleep(delay) + delay *= 2 # exponential, never a tight retry + continue + return status, body, "" + return 429, b"", "rate limited after retries" + + +def _ig_int(v): + try: + return int(v) + except Exception: + return None + + +def _profile_from_web_api(node, handle): + return { + "username": node.get("username") or handle, + "full_name": node.get("full_name") or "", + "bio": node.get("biography") or "", + "followers": _ig_int((node.get("edge_followed_by") or {}).get("count")), + "following": _ig_int((node.get("edge_follow") or {}).get("count")), + "posts_count": _ig_int((node.get("edge_owner_to_timeline_media") or {}).get("count")), + "verified": "1" if node.get("is_verified") else "", + } + + +def _posts_from_edges(edges): + out = [] + for e in edges or []: + n = (e or {}).get("node") or {} + code = n.get("shortcode") + if not code: + continue + caption = "" + for ce in ((n.get("edge_media_to_caption") or {}).get("edges") or []): + caption = ((ce or {}).get("node") or {}).get("text") or "" + break + ts = n.get("taken_at_timestamp") + out.append({ + "shortcode": code, + "posted_at": (_dt.datetime.fromtimestamp(ts).strftime("%Y-%m-%d %H:%M") + if isinstance(ts, (int, float)) else ""), + "type": ("video" if n.get("is_video") else + "carousel" if n.get("__typename") == "GraphSidecar" else "image"), + "caption": caption, + "url": f"https://www.instagram.com/p/{code}/", + "likes": _ig_int((n.get("edge_liked_by") or n.get("edge_media_preview_like") + or {}).get("count")), + "comments": _ig_int((n.get("edge_media_to_comment") or {}).get("count")), + }) + return out + + +_OG_COUNTS = re.compile( + r"([\d.,KMkm]+)\s+Followers?,\s*([\d.,KMkm]+)\s+Following,\s*([\d.,KMkm]+)\s+Posts?") + + +def _loose_count(txt): + """'1.2M' / '12,345' -> int. IG's og:description abbreviates, so the snapshot is honest + about being approximate rather than pretending to a precision it does not have.""" + t = str(txt or "").strip().replace(",", "") + mult = 1 + if t[-1:].lower() == "k": + mult, t = 1_000, t[:-1] + elif t[-1:].lower() == "m": + mult, t = 1_000_000, t[:-1] + try: + return int(float(t) * mult) + except Exception: + return None + + +def pull_profile(url, max_posts=24, log=print): + """Everything anonymously readable about one public profile. + + Returns `{state, profile, posts, via, note}` with state ∈ ok | partial | blocked | error. + `partial` means the identity was read but the media was not — which is the outcome the + anonymous surface most often gives, and saying so is the point. + """ + handle = ig_handle(url) + if not handle: + return {"state": "error", "note": f"{url!r} is not an Instagram profile URL", + "profile": {}, "posts": [], "via": ""} + attempts = [] + + # RUNG 1 — the web client's own profile endpoint. Public, no cookie; the one that used to + # carry both the profile AND the first page of media in a single answer. + api = f"https://www.instagram.com/api/v1/users/web_profile_info/?username={handle}" + status, body, note = _ig_get(api, headers={ + "X-IG-App-ID": IG_APP_ID, "Accept": "*/*", + "Referer": f"https://www.instagram.com/{handle}/"}) + attempts.append(f"web_profile_info:{status or note}") + if 200 <= status < 300 and body: + try: + node = ((json.loads(body.decode("utf-8", "replace")) or {}) + .get("data") or {}).get("user") or {} + except Exception: + node = {} + if node: + profile = _profile_from_web_api(node, handle) + media = node.get("edge_owner_to_timeline_media") or {} + posts = _posts_from_edges(media.get("edges"))[:max_posts] + page = media.get("page_info") or {} + if page.get("has_next_page") and page.get("end_cursor") and len(posts) < max_posts: + more, pnote = _paginate(node.get("id"), page.get("end_cursor"), + max_posts - len(posts), log) + posts.extend(more) + if pnote: + attempts.append(pnote) + state = "ok" if posts else "partial" + return {"state": state, "profile": profile, "posts": posts, + "via": "web_profile_info", + "note": "" if posts else "profile read; media edges empty (" + + ", ".join(attempts) + ")"} + + time.sleep(PACE_SECONDS) + + # RUNG 2 — the profile HTML. Its og:description carries the three counts even when every + # JSON surface refuses, so it is the honest floor: identity without media. + status, body, note = _ig_get(f"https://www.instagram.com/{handle}/") + attempts.append(f"html:{status or note}") + if 200 <= status < 300 and body: + text = body.decode("utf-8", "replace") + if "/accounts/login" in text[:4000] and "og:description" not in text: + return {"state": "blocked", "profile": {}, "posts": [], "via": "html", + "note": "Instagram served the login wall (" + ", ".join(attempts) + ")"} + desc = "" + m = re.search(r']+property="og:description"[^>]+content="([^"]*)"', text) + if m: + desc = m.group(1) + counts = _OG_COUNTS.search(desc or "") + title = "" + mt = re.search(r']+property="og:title"[^>]+content="([^"]*)"', text) + if mt: + title = mt.group(1) + if counts: + profile = { + "username": handle, "full_name": title.split("(")[0].strip(), + # ⚠ NO BIO. `og:description` on a profile page is + # "204K Followers, 5,245 Following, 750 Posts - See Instagram photos and videos + # from Inayma (@inayma)" — the tail is Instagram's own boilerplate, not the + # person's biography. Storing it would fill a Bio column with the same sentence + # for every influencer, which reads as data and is not. Measured 2026-08-04. + "bio": "", + "followers": _loose_count(counts.group(1)), + "following": _loose_count(counts.group(2)), + "posts_count": _loose_count(counts.group(3)), + "verified": "", + # The page abbreviates ("204K"), so the number is the page's rounding, not a + # count we read. Recorded on the row rather than left for someone to discover + # when 204,000 fails to reconcile with anything. + "approx": "1", + } + return {"state": "partial", "profile": profile, "posts": [], "via": "og:description", + "note": "counts are the page's own abbreviations; media is not anonymously " + "readable (" + ", ".join(attempts) + ")"} + if status in (401, 403, 429) or status == 0: + return {"state": "blocked", "profile": {}, "posts": [], "via": "", + "note": f"Instagram refused the anonymous read ({', '.join(attempts)})"} + return {"state": "error", "profile": {}, "posts": [], "via": "", + "note": f"nothing anonymously readable ({', '.join(attempts)})"} + + +#: The historical anonymous media query. Kept because trying it and RECORDING the refusal is +#: what makes "as deep as anonymously accessible" (R7) a measurement instead of an assumption. +IG_MEDIA_QUERY_HASH = "e769aa130647d2354c40ea6a439bfc08" + + +def _paginate(user_id, cursor, want, log=print): + """Walk further back through the media edges while the anonymous surface allows it.""" + out, note = [], "" + while user_id and cursor and len(out) < want: + time.sleep(PACE_SECONDS) + variables = json.dumps({"id": str(user_id), "first": min(50, want - len(out)), + "after": cursor}, separators=(",", ":")) + url = (f"https://www.instagram.com/graphql/query/?query_hash={IG_MEDIA_QUERY_HASH}" + f"&variables={requests.utils.quote(variables)}") + status, body, err = _ig_get(url, headers={"X-IG-App-ID": IG_APP_ID}) + if not (200 <= status < 300) or not body: + note = f"graphql:{status or err}" + break + try: + media = (((json.loads(body.decode("utf-8", "replace")) or {}).get("data") or {}) + .get("user") or {}).get("edge_owner_to_timeline_media") or {} + except Exception: + note = "graphql:unparseable" + break + edges = media.get("edges") or [] + if not edges: + note = "graphql:empty" + break + out.extend(_posts_from_edges(edges)) + page = media.get("page_info") or {} + if not page.get("has_next_page"): + break + cursor = page.get("end_cursor") + return out[:want], note + + +# --------------------------------------------------------------------------------------------- +# RUNNERS +# --------------------------------------------------------------------------------------------- + +def run_scrape_db(rt, defn, username="automation", log=print): + """Automation #1 (R6): a public page → a blank database, re-runnable, UPSERT by key.""" + cfg = defn.get("config") or {} + fmap, key_field = cfg.get("fieldMap") or {}, cfg.get("keyField") + status, final, body = fetch(cfg["url"]) + if not (200 <= status < 300): + return ("error", f"{cfg['url']} answered {status} — nothing was written", + {"status": status}, []) + soup = _soup(body) + if cfg.get("extract") == "jsonld": + blocks = jsonld(soup) + flat = [] + for b in blocks: + if isinstance(b, list): + flat.extend([x for x in b if isinstance(x, dict)]) + elif isinstance(b, dict): + items = b.get("itemListElement") + flat.extend([x for x in items if isinstance(x, dict)] if isinstance(items, list) + else [b]) + raw_rows = [{k: _scalar(v) for k, v in d.items()} for d in flat] + else: + found = tables(soup) + idx = max(0, min(int(cfg.get("tableIndex") or 0), len(found) - 1)) if found else 0 + raw_rows = [r for r in (found[idx] if found else []) if isinstance(r, dict)] + if not raw_rows: + return ("error", "the page parsed but the selected table had no rows", {"rows": 0}, []) + + incoming = [] + for r in raw_rows: + mapped = {tgt: _s(r.get(src, ""), 500) for src, tgt in fmap.items()} + if any(v for v in mapped.values()): + incoming.append(mapped) + + fields = [field_def(tgt, src if len(src) <= 60 else src[:60]) + for src, tgt in fmap.items()] + # the key column leads, so the table opens on the identity it is upserted by + fields.sort(key=lambda f: 0 if f["key"] == key_field else 1) + table_key = ut_ensure(rt, cfg.get("targetLabel") or defn.get("name") or "Scraped table", + fields, username, key=cfg.get("targetTable") or None) + t = ut_get(rt, table_key) or {} + rows, counts = upsert_rows(t.get("rows") or {}, incoming, key_field) + ut_write_rows(rt, table_key, rows) + counts["source_rows"] = len(incoming) + affected = [rid for rid, row in rows.items() + if str(row.get(key_field, "")) in {str(i.get(key_field)) for i in incoming}][:200] + summary = (f"{counts['inserted']} new, {counts['updated']} updated, " + f"{counts['unchanged']} unchanged, {counts['orphans']} no longer on the page " + f"(kept)") + state = "partial" if counts["skipped"] else "ok" + log(f"[aios-auto] scrape_db {defn.get('id')} -> {table_key}: {summary}") + return (state, summary, counts, affected) + + +def run_field_instagram(rt, defn, username="automation", log=print): + """Automation #2 (R7): for every row of a blank database that carries a profile URL, pull + the public profile anonymously and write a status string into the automation column.""" + cfg = defn.get("config") or {} + table_key, fkey = cfg.get("targetTable"), cfg.get("fieldKey") + t = ut_get(rt, table_key) + if not t: + return ("error", f"{table_key} is not a database in this workspace", {}, []) + url_field = cfg.get("urlField") or _auto_url_field(t, fkey) + if not url_field: + return ("error", "the automation column has no URL field bound to it", {}, []) + rows = dict(t.get("rows") or {}) + # the relational tables the pull lands in (R7): every row timestamped for time-range filters + snap_key = ut_ensure(rt, "IG snapshots", SNAPSHOT_FIELDS, username, key="ut_ig_snapshots") + post_key = ut_ensure(rt, "IG posts", POST_FIELDS, username, key="ut_ig_posts") + ps_key = ut_ensure(rt, "IG post snapshots", POST_SNAPSHOT_FIELDS, username, + key="ut_ig_post_snapshots") + snaps = dict((ut_get(rt, snap_key) or {}).get("rows") or {}) + posts = dict((ut_get(rt, post_key) or {}).get("rows") or {}) + psnaps = dict((ut_get(rt, ps_key) or {}).get("rows") or {}) + + counts = {"profiles": 0, "ok": 0, "partial": 0, "blocked": 0, "error": 0, + "posts": 0, "new_posts": 0} + cells, affected, notes = {}, [], [] + targets = [(rid, str(r.get(url_field, "") or "").strip()) + for rid, r in rows.items() if str(r.get(url_field, "") or "").strip()] + for i, (rid, url) in enumerate(targets): + if i: + time.sleep(PACE_SECONDS) # ≥2 s between profiles (R7) + counts["profiles"] += 1 + res = pull_profile(url, max_posts=cfg.get("maxPosts") or 24, log=log) + pulled = _iso() + if res["state"] == "ok" or res["state"] == "partial": + counts["ok" if res["state"] == "ok" else "partial"] += 1 + prof = res["profile"] + snaps, _c = upsert_rows( + snaps, [{"snapshot_key": f"{prof['username']}@{pulled}", + "influencer_key": prof["username"], "pulled_at": pulled, + "followers": _s(prof.get("followers")), "following": _s(prof.get("following")), + "posts_count": _s(prof.get("posts_count")), "full_name": _s(prof.get("full_name")), + "bio": _s(prof.get("bio"), 500), "verified": _s(prof.get("verified")), + "source": _s(res.get("via")), "approx": _s(prof.get("approx"))}], + "snapshot_key") + new_posts = 0 + for p in res.get("posts") or []: + posts, pc = upsert_rows(posts, [{ + "shortcode": p["shortcode"], "influencer_key": prof["username"], + "posted_at": _s(p.get("posted_at")), "type": _s(p.get("type")), + "caption": _s(p.get("caption"), 800), "url": _s(p.get("url"), 300), + }], "shortcode") + new_posts += pc["inserted"] + psnaps, _pc = upsert_rows(psnaps, [{ + "post_snapshot_key": f"{p['shortcode']}@{pulled}", + "shortcode": p["shortcode"], "pulled_at": pulled, + "likes": _s(p.get("likes")), "comments": _s(p.get("comments")), + }], "post_snapshot_key") + counts["posts"] += len(res.get("posts") or []) + counts["new_posts"] += new_posts + detail = f"{prof.get('followers') or '?'} followers" + if res.get("posts"): + detail += f", {len(res['posts'])} posts" + elif res["state"] == "partial": + detail += ", posts not anonymously readable" + cells[rid] = f"{res['state']} · {_stamp()} · {detail}" + elif res["state"] == "blocked": + counts["blocked"] += 1 + cells[rid] = f"blocked · {_stamp()} · {_s(res.get('note'), 90)}" + notes.append(res.get("note") or "blocked") + else: + counts["error"] += 1 + cells[rid] = f"error · {_stamp()} · {_s(res.get('note'), 90)}" + notes.append(res.get("note") or "error") + affected.append(rid) + + def _up(cur): + cur = cur if isinstance(cur, dict) else {} + tt = cur.get(table_key) + if tt is not None: + for rid, val in cells.items(): + tt.setdefault("rows", {}).setdefault(str(rid), {})[fkey] = val + for k, rws in ((snap_key, snaps), (post_key, posts), (ps_key, psnaps)): + tgt = cur.get(k) + if tgt is not None: + tgt["rows"] = rws + return cur + + rt.update(UT_STORE_KEY, _up, flush="sync") # ONE coalesced update for all four tables + # ⚠ A RUN IS ONLY 'ok' IF EVERY PROFILE WAS. The first live run rolled up to 'ok' while + # every CELL said `partial`, because the rollup only asked about blocked/error — so the rail + # showed a green dot over a table with no posts in it. A summary that disagrees with the + # cells it summarises is the failure this whole module's honest-status rule exists to + # prevent, so `partial` now propagates. Measured 2026-08-04. + read = counts["ok"] + counts["partial"] + if not read: + state = "error" if counts["error"] else "partial" if counts["blocked"] else "ok" + elif counts["blocked"] or counts["error"] or counts["partial"]: + state = "partial" + else: + state = "ok" + summary = (f"{read}/{counts['profiles']} profiles read, {counts['posts']} posts " + f"({counts['new_posts']} new)") + if counts["partial"]: + summary += f", {counts['partial']} profile-only (posts not anonymously readable)" + if counts["blocked"]: + summary += f", {counts['blocked']} blocked by Instagram" + if notes: + summary += f" — {notes[0][:120]}" + return (state, summary, counts, affected) + + +def _auto_url_field(table, fkey): + """The URL field an automation column is bound to: its own `automation.urlField`, else the + first url-typed column on the table. Never guessed silently — the caller reports which.""" + for f in table.get("fields") or []: + if f.get("key") == fkey: + bound = ((f.get("automation") or {}).get("urlField") or "").strip() + if bound: + return bound + for f in table.get("fields") or []: + if f.get("type") == "url": + return f.get("key") + return "" + + +RUNNERS = {"scrape_db": run_scrape_db, "field_instagram": run_field_instagram} + + +def run_now(rt, tenant, auto_id, username="automation", log=print): + """Execute one automation SYNCHRONOUSLY. The route wraps this in a thread; the tick calls it + directly. Returns the run entry, or None when it was already running (the 409).""" + defn = all_definitions(rt).get(str(auto_id)) + if defn is None: + return None + if not _claim(tenant, auto_id): + return None + try: + _step(tenant, auto_id, "running") + runner = RUNNERS.get(defn.get("kind")) + if runner is None: + return _commit_run(rt, auto_id, "error", + f"unknown automation kind {defn.get('kind')!r}", {}, False) + try: + state, summary, counts, affected = runner(rt, defn, username=username, log=log) + except Refused as e: + return _commit_run(rt, auto_id, "error", f"refused: {e}", {}, False) + except Exception as e: # noqa: BLE001 + log(f"[aios-auto] run {auto_id} failed: {type(e).__name__}: {e}") + return _commit_run(rt, auto_id, "error", + f"{type(e).__name__}: {str(e)[:200]}", {}, False) + return _commit_run(rt, auto_id, state, summary, counts, state != "error", affected) + finally: + _release(tenant, auto_id) + + +def run_async(rt, tenant, auto_id, username="automation", log=print): + """Start a run on a background thread. False when one is already in flight (→ 409).""" + if running(tenant, auto_id): + return False + th = threading.Thread(target=run_now, args=(rt, tenant, auto_id, username, log), + daemon=True, name=f"automation-{tenant}-{auto_id}") + th.start() + return True + + +# --------------------------------------------------------------------------------------------- +# THE TICK + the in-process scheduler +# --------------------------------------------------------------------------------------------- + +def due_ids(rt, now=None): + """Which of this tenant's automations a tick at `now` should start. Pure over the store.""" + return sorted(aid for aid, d in all_definitions(rt).items() if is_due(d, now)) + + +def tick(rt, tenant, now=None, log=print): + """Fire every due automation for ONE tenant. Returns the ids started.""" + started = [] + for aid in due_ids(rt, now): + if run_async(rt, tenant, aid, username="scheduler", log=log): + started.append(aid) + if started: + log(f"[aios-auto] tick {tenant}: started {', '.join(started)}") + return started + + +def tick_all(now=None, log=print): + """Every registered tenant. Fail-quiet per tenant: one tenant's broken store must not stop + the others' schedules.""" + from harness import runtime as _rt + out = {} + for slug in _rt.known_tenants(): + try: + out[slug] = tick(_rt.get_runtime(slug), slug, now=now, log=log) + except Exception as e: # noqa: BLE001 + log(f"[aios-auto] tick {slug} skipped: {type(e).__name__}: {e}") + return out + + +#: How often the in-process scheduler wakes. A minute is the cron resolution; anything finer +#: would be a busy loop against a vocabulary that cannot express it. +TICK_SECONDS = int(os.environ.get("AIOS_AUTOMATION_TICK_SECONDS") or 60) +_SCHEDULER = [None] + + +def scheduler_loop(log=print): + """The resync-daemon pattern (`api/main.py:313`): sleep FIRST, then work. + + Sleeping first is deliberate and load-bearing for the gate battery — `verify_api` and + `verify_seam` import this module through `main.py`, run against fake stores in seconds and + exit. A loop that ticked on entry would fire inside them. + """ + while True: + time.sleep(TICK_SECONDS) + try: + tick_all(log=log) + except Exception as e: # noqa: BLE001 + log(f"[aios-auto] scheduler tick failed: {type(e).__name__}: {e}") + + +def start_scheduler(log=print): + """Start the loop once per process. **OPT-IN: `AIOS_AUTOMATIONS=1`.** + + ⚠ AMENDED 2026-08-03 (D), and the reason is a measurement rather than a preference. The wave + brief specified this thread DEFAULT-ON for the API. Then `verify_api.py` was timed: **196 + seconds**, i.e. more than three 60 s tick intervals. A default-on scheduler therefore fires + two or three times inside a gate that imports `main.py` — and while a tick over a fake store + finds nothing due, `tick_all` reaches `runtime.get_runtime()`, which BUILDS tenants and + mutates the LRU cache that `verify_api`'s own isolation assertions read. A background thread + that can move a gate's subject is a flaky suite waiting to happen. + + So it takes the convention `main.py:353` already established for exactly this hazard — + `AIOS_PREWARM=1` — for exactly the reason stated there: env-gated rather than a startup + event, so importing this module in a gate can never fire anything. The DEPLOY sets it; the + external EventBridge tick (R5) does not depend on it either way, since that POSTs the + endpoint rather than riding this thread. + """ + if os.environ.get("AIOS_AUTOMATIONS") != "1": + return False + if _SCHEDULER[0] is not None: + return False + th = threading.Thread(target=scheduler_loop, kwargs={"log": log}, + daemon=True, name="automation-scheduler") + _SCHEDULER[0] = th + th.start() + return True diff --git a/api/deps.py b/api/deps.py index 62b057b6bf18fd663329f03da277ffac5f86e644..b59d70a10dd56654aed8ef643475567e997270f5 100644 --- a/api/deps.py +++ b/api/deps.py @@ -50,9 +50,20 @@ class Session: return perms.is_admin(self.user) def require(self, module_key): - """403 unless this session may open `module_key`. Returns nothing — it is a gate.""" + """403 unless this session may open `module_key`. Returns nothing — it is a gate. + + TWO walls, both fail-closed (wave 18, C1-TENANT): the ACCOUNT grant (`perms.may_open`) + and the TENANT catalogue — a registry module a tenant has not enabled is 403 even for + that tenant's admin, or a freshly provisioned Nurilab admin (role=admin ⇒ may_open + everything) would open Royal's Odoo-backed surfaces through any module route. One + chokepoint: `module_gate` and every inline `session.require` pass through here.""" if not perms.may_open(self.user, module_key): raise err(403, "forbidden", f"your account does not have access to {module_key}") + tcfg = getattr(self.runtime.tenant, "config", None) or {} + tmods = tcfg.get("modules", "all") + if tmods != "all" and str(module_key) not in {str(k) for k in (tmods or [])}: + raise err(403, "forbidden", + f"this workspace does not include {module_key}") def _user_for(claims): @@ -83,6 +94,7 @@ def _user_for(claims): uname = (claims.get("u") or "").strip().lower() if not uname: return None + claim_tenant = str(claims.get("t") or "").strip().lower() try: reg = users.registry() or {} except Exception: @@ -90,10 +102,23 @@ def _user_for(claims): rec = reg.get(uname) if (rec and rec.get("active", True) and int(rec.get("epoch") or 0) == int(claims.get("e") or 0)): - return users._public(uname, rec) - if uname == "admin" and os.environ.get("APP_PASSWORD", ""): + pub = users._public(uname, rec) + # ⛔ Wave 18 (C1-TENANT, R1): the cookie's tenant must be THE ACCOUNT'S tenant. Before + # this line, any valid credential could mint a session for any registered slug + # (login validated the slug's existence, never the membership) — with + # AIOS_ENABLE_QA_TENANT=1 that was a working cross-tenant session. A signature proves + # the cookie is ours; THIS proves the account belongs where the cookie says it does. + if claim_tenant != pub.get("tenant", "royal-imports"): + return None + return pub + if (uname == "admin" and os.environ.get("APP_PASSWORD", "") + and claim_tenant == "royal-imports"): + # The emergency master is TENANT #0's break-glass, not the platform's: a synthetic + # all-access identity minted into another tenant's session would be the exact + # cross-tenant widening the rule above closes. return {"username": "admin", "name": "Administrator", "role": "admin", - "bus": "all", "modules": "all", "epoch": int(claims.get("e") or 0)} + "bus": "all", "modules": "all", "tenant": "royal-imports", + "epoch": int(claims.get("e") or 0)} return None diff --git a/api/main.py b/api/main.py index 1e51f5cd75e119575d532d816112febc6256db5e..9e1416617dae9c2abf0fe316262698500ccf45a2 100644 --- a/api/main.py +++ b/api/main.py @@ -55,13 +55,17 @@ from starlette.exceptions import HTTPException as StarletteHTTPException # noqa import aios_session # noqa: E402 import routes_admin # noqa: E402 +import routes_assets # noqa: E402 (wave 18 C2-ASSET — catalog product imagery) import routes_auth # noqa: E402 +import routes_automation # noqa: E402 (wave 18 C4-AUTO — SESSION D's router, mounted by A) import routes_customers # noqa: E402 import routes_grid # noqa: E402 +import routes_keychain # noqa: E402 (wave 18 C7 — keychain + connectors admin surfaces) import routes_nav # noqa: E402 import routes_pages # noqa: E402 import routes_products # noqa: E402 (wave 15 C-TOPIC — gated, not yet in the nav) import routes_records # noqa: E402 +import routes_tables # noqa: E402 (wave 18 C3-UT — user-created databases over the wire) from core import grid_events # noqa: E402 from deps import Session, module_gate # noqa: E402 @@ -163,6 +167,8 @@ app.include_router(routes_auth.router) app.include_router(routes_nav.router) app.include_router(routes_customers.router) app.include_router(routes_products.router) +app.include_router(routes_assets.router) +app.include_router(routes_tables.router) app.include_router(routes_grid.router) app.include_router(routes_records.router) # EXIT wave 2: the Y1 page-data envelope (one route for every ported dashboard) and Y4's user @@ -170,6 +176,8 @@ app.include_router(routes_records.router) # a new page is a builder module plus one registry line, and nothing here changes. app.include_router(routes_pages.router) app.include_router(routes_admin.router) +app.include_router(routes_automation.router) +app.include_router(routes_keychain.router) # --- DEPRECATED ALIASES (removed when S2's shell flips; kept so the current bundle keeps working) diff --git a/api/routes_admin.py b/api/routes_admin.py index 5289c39a9502ade3ff91464875050f2539d74758..e57001dfbb1b5ea97ee759aefe1322b36246aea7 100644 --- a/api/routes_admin.py +++ b/api/routes_admin.py @@ -90,6 +90,7 @@ def _view(uname, rec): "modules": rec.get("modules", "all"), "agent": rec.get("agent") or None, "email": rec.get("email") or None, + "tenant": _tenant_of(rec), "active": bool(rec.get("active", True)), # The session-revocation handle. An admin needs it: it is the only visible evidence # that "sign them out everywhere" actually happened. @@ -202,11 +203,22 @@ def _clean_modules(v): return sorted(set(out)) +def _tenant_of(rec): + """The account's company, with the pre-wave default. ONE spelling of the default, used by + every admin route — two spellings is how a tenant wall grows a gap.""" + return str((rec or {}).get("tenant") or "royal-imports").strip().lower() + + # ── the routes ─────────────────────────────────────────────────────────────────────────────────── @router.get("/admin/users") def list_users(session: Session = Depends(admin_gate)): + """Wave 18 (C1-TENANT): scoped to the CALLER'S tenant. The user registry is a global + control-plane bucket, so without this filter a Nurilab admin would read Royal's whole + roster — names, emails, agents — from one URL.""" reg = _registry() - return {"users": [_view(u, reg[u]) for u in sorted(reg)]} + mine = _tenant_of(session.user) + return {"users": [_view(u, reg[u]) for u in sorted(reg) + if _tenant_of(reg[u]) == mine]} @router.post("/admin/users", status_code=201) @@ -234,8 +246,10 @@ def create_user(body: dict = Body(default=None), session: Session = Depends(admi if uname in _registry(): raise err(409, "user_exists", f"{uname} already exists — PATCH it to change it") + # Wave 18 (C1-TENANT): an admin creates accounts in their OWN company, never another's — + # the tenant is stamped from the session, not taken from the body. users.create_user(uname, pw, name, role=role, bus=bus, modules=modules, - agent=agent, email=email) + agent=agent, email=email, tenant=_tenant_of(session.user)) reg = _registry() if uname not in reg: # The store accepted the write and does not have it. Reporting 201 here would be the @@ -258,7 +272,9 @@ def update_user(username: str, body: dict = Body(default=None), body = body if isinstance(body, dict) else {} reg = _registry() uname = str(username or "").strip().lower() - if uname not in reg: + if uname not in reg or _tenant_of(reg[uname]) != _tenant_of(session.user): + # Wave 18 (C1-TENANT): a cross-tenant username answers exactly like a missing one — + # 404, never 403, because "that account exists in another company" is itself a leak. raise err(404, "no_such_user", f"no account named {uname!r}") if not body: raise err(400, "empty_patch", "no fields to update") @@ -314,7 +330,9 @@ def set_password(username: str, body: dict = Body(default=None), """ reg = _registry() uname = str(username or "").strip().lower() - if uname not in reg: + if uname not in reg or _tenant_of(reg[uname]) != _tenant_of(session.user): + # Wave 18 (C1-TENANT): a cross-tenant username answers exactly like a missing one — + # 404, never 403, because "that account exists in another company" is itself a leak. raise err(404, "no_such_user", f"no account named {uname!r}") pw = _clean_password((body or {}).get("password")) before = int(reg[uname].get("epoch") or 0) @@ -643,7 +661,9 @@ def get_perms(username: str, session: Session = Depends(admin_gate)): """This account's permission block plus the field schema the editor needs to render it.""" reg = _registry() uname = str(username or "").strip().lower() - if uname not in reg: + if uname not in reg or _tenant_of(reg[uname]) != _tenant_of(session.user): + # Wave 18 (C1-TENANT): a cross-tenant username answers exactly like a missing one — + # 404, never 403, because "that account exists in another company" is itself a leak. raise err(404, "no_such_user", f"no account named {uname!r}") import core.perm_scope as perm_scope @@ -691,7 +711,9 @@ def put_perms(username: str, body: dict = Body(default=None), body = body if isinstance(body, dict) else {} reg = _registry() uname = str(username or "").strip().lower() - if uname not in reg: + if uname not in reg or _tenant_of(reg[uname]) != _tenant_of(session.user): + # Wave 18 (C1-TENANT): a cross-tenant username answers exactly like a missing one — + # 404, never 403, because "that account exists in another company" is itself a leak. raise err(404, "no_such_user", f"no account named {uname!r}") if "perms" not in body: raise err(400, "empty_patch", "no perms to save") diff --git a/api/routes_assets.py b/api/routes_assets.py new file mode 100644 index 0000000000000000000000000000000000000000..41725828134fc03f20b54d4dbf2395b01eaa99d5 --- /dev/null +++ b/api/routes_assets.py @@ -0,0 +1,165 @@ +"""routes_assets.py — product image service (wave 18, contract C2-ASSET). + +Serves the catalog's product imagery. Two sources, checked in order: + + 1. `AIOS_ASSET_DIR` — a local directory of master images whose FILENAME STEM is the product + `code` (Odoo default_code, case-insensitive). Dev mode: the owner's master folder on this + machine. Derivatives are generated on demand into a disk cache. + 2. `AIOS_ASSET_REPO` — a private HF dataset (default `royal-imports/product-assets`) laid out + by `royalimports_os/ingest_product_assets.py`: + assets/products/orig/ originals, archived verbatim (R9) + assets/products/web/.png ~800px alpha-preserving derivative + manifest.json {"codes": {"": {"ext": ".png"}}, ...} + Files download once per container into the HF cache; responses carry immutable cache + headers so the browser re-fetches nothing. + +QUALITY (R9): `q=web` = the low-res derivative the app displays; `q=print` and `q=orig` BOTH +serve the ORIGINAL bytes — v1's "high quality" IS the master file (dated amendment in the wave +doc). The gate is the PRODUCT grant: images decorate the product surface, so whoever may open +`product_data` may fetch them; nobody else may. + +Codes are validated against a closed charset before they touch a filesystem or a repo path — +a path separator can never reach the lookup, so traversal is refused at the door (400), and an +unknown code is 404 `asset_not_found`, never an empty 200. +""" +import os +import re +import tempfile +import time +from pathlib import Path + +from fastapi import Depends +from fastapi import APIRouter +from fastapi.responses import FileResponse + +from deps import Session, err, module_gate + +router = APIRouter(prefix="/api/v1") + +#: Same grant as the product surface these images decorate (routes_products.MODULE, restated +#: here to avoid importing that module for one string). +MODULE = "product_data" + +_WEB_EDGE = 800 # max edge (px) of the in-app derivative +_QUALITIES = ("web", "print", "orig") +_EXT_MEDIA = {".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg"} +#: closed charset — no slashes, no backslashes, no colons, so a code can never be a path. +_CODE_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9 ._+&()\-]{0,63}$") +_IMMUTABLE = "public, max-age=31536000, immutable" + +#: per-process index of the local master dir: rebuilt when the dir path or its mtime changes. +_DIR_INDEX = {"path": None, "mtime": None, "map": {}} + + +def _norm(code): + return str(code or "").strip().upper() + + +def _local_dir(): + d = os.environ.get("AIOS_ASSET_DIR", "").strip() + if not d: + return None + p = Path(d) + return p if p.is_dir() else None + + +def _cache_root(): + root = Path(os.environ.get("AIOS_ASSET_CACHE", "").strip() + or Path(tempfile.gettempdir()) / "aios_asset_cache") + root.mkdir(parents=True, exist_ok=True) + return root + + +def _dir_index(d): + """{CODE: Path} over the master dir. Two files sharing an upper-cased stem keep the + lexicographically first — the same rule the ingest script applies, so dir mode and repo + mode resolve identically.""" + try: + mtime = d.stat().st_mtime_ns + except OSError: + return {} + if _DIR_INDEX["path"] == str(d) and _DIR_INDEX["mtime"] == mtime: + return _DIR_INDEX["map"] + idx = {} + for p in sorted(d.iterdir()): + if not p.is_file() or p.name.startswith("."): + continue + if p.suffix.lower() not in _EXT_MEDIA: + continue + idx.setdefault(p.stem.upper(), p) + _DIR_INDEX.update(path=str(d), mtime=mtime, map=idx) + return idx + + +def _web_derivative(src, code): + """The ~800px alpha-preserving PNG for one master file, built lazily into the disk cache. + Rebuilt when the master is newer than the cached copy.""" + out = _cache_root() / "web" + out.mkdir(parents=True, exist_ok=True) + dst = out / f"{code}.png" + try: + if dst.is_file() and dst.stat().st_mtime >= src.stat().st_mtime: + return dst + except OSError: + pass + try: + from PIL import Image + except ImportError: + raise err(503, "pillow_missing", + "image derivatives need Pillow — `pip install pillow` on this host") + with Image.open(src) as im: + im.load() + if im.mode not in ("RGBA", "RGB", "LA", "L"): + im = im.convert("RGBA") + im.thumbnail((_WEB_EDGE, _WEB_EDGE)) + im.save(dst, format="PNG", optimize=True) + return dst + + +def _assets(): + """The asset SOURCE lives in `royalimports_os/core/assets.py`, not here. + + ⛔ NOT TIDINESS — a CONTRACT. `ops/verify_portability.py` B1/B2 assert the HuggingFace SDK + appears only in its declared homes and NEVER under `aios-web/api/`, because this process is + meant to lift to Hetzner/EC2 without a hub client. The first version of this file imported + `huggingface_hub` directly and the gate caught it.""" + import core.assets as assets + return assets + + +@router.get("/assets/products") +def asset_manifest(session: Session = Depends(module_gate(MODULE))): + """The codes that HAVE an image — so the catalog designer can mark gaps instead of + rendering broken tiles. `source` names which backend answered.""" + d = _local_dir() + if d is not None: + return {"codes": sorted(_dir_index(d).keys()), "source": "dir"} + codes = _assets().manifest() + if codes: + return {"codes": sorted(codes.keys()), "source": "repo"} + return {"codes": [], "source": "none"} + + +@router.get("/assets/products/{code}") +def product_asset(code: str, q: str = "web", + session: Session = Depends(module_gate(MODULE))): + if q not in _QUALITIES: + raise err(400, "bad_quality", f"q must be one of {', '.join(_QUALITIES)}") + norm = _norm(code) + if not _CODE_RE.match(norm): + raise err(400, "bad_code", "that is not a product code") + + path = None + d = _local_dir() + if d is not None: + src = _dir_index(d).get(norm) + if src is not None: + path = _web_derivative(src, norm) if q == "web" else src + if path is None: + path = _assets().fetch(norm, q) + if path is None or not Path(path).is_file(): + raise err(404, "asset_not_found", f"no image for {norm}") + + media = _EXT_MEDIA.get(Path(path).suffix.lower(), "application/octet-stream") + return FileResponse(str(path), media_type=media, + headers={"Cache-Control": _IMMUTABLE}) diff --git a/api/routes_auth.py b/api/routes_auth.py index 3a55cc59e1eea79fb8dfd3b5bbb83537adf9a6d7..3d4e9b81fbd7205e91850384d25778fd57ab9a2d 100644 --- a/api/routes_auth.py +++ b/api/routes_auth.py @@ -70,6 +70,9 @@ def _public_user(user): the epoch is a server-side revocation handle and a client has no use for it.""" return {"username": user.get("username", ""), "name": user.get("name", ""), "role": user.get("role", "user"), + # Wave 18 (C1-TENANT, R1): the company this session is bound to — the client shows + # it and tests assert the binding; the SERVER-side truth stays in the signed cookie. + "tenant": str(user.get("tenant") or "royal-imports").strip().lower(), "bus": perms.allowed_bu_labels(user), "team_id": perms.scope_team_id(user), "agent": perms.scope_agent(user), @@ -128,21 +131,22 @@ def clear_avatar(session: Session = Depends(require_session)): @router.post("/login") def login(request: Request, response: Response, body: dict = Body(default=None)): + """Wave 18 (C1-TENANT, R1): ONE login box — the ACCOUNT decides the tenant. + + The pre-wave flow validated a caller-posted tenant slug and minted the session for it, so + the same credential could sign in to any registered tenant. Now the credential resolves + FIRST (username or email — `users.verify` takes both) and the session binds to the tenant + ON THE RECORD; the posted `tenant` field is accepted for wire-compat and ignored. An + account whose tenant no longer resolves (deleted / suspended record) gets the same 401 as + a bad password — "which tenants exist" is not the login form's question to answer. + """ body = body or {} uname = str(body.get("username") or "").strip().lower() pw = str(body.get("password") or "") - tenant = str(body.get("tenant") or "royal-imports").strip().lower() - - # The tenant is validated BEFORE the credential check so an unknown slug can never mint a - # cookie — but it answers with the SAME 401 as a bad password, because "that tenant does not - # exist" is a fact about our customer list. - from harness import runtime - try: - runtime.get_runtime(tenant) - except KeyError: - raise err(401, "invalid_credentials", "that username and password do not match") - throttle_key = (tenant, uname) + # Throttle on the IDENTIFIER alone: the tenant is not known until the credential resolves, + # and a per-(tenant, uname) key would let an attacker reset their budget by rotating slugs. + throttle_key = ("*", uname) wait = _throttled(throttle_key) if wait: raise err(429, "too_many_attempts", @@ -161,6 +165,14 @@ def login(request: Request, response: Response, body: dict = Body(default=None)) _note_failure(throttle_key) raise err(401, "invalid_credentials", "that username and password do not match") + tenant = str(user.get("tenant") or "royal-imports").strip().lower() + from harness import runtime + try: + runtime.get_runtime(tenant) + except KeyError: + _note_failure(throttle_key) + raise err(401, "invalid_credentials", "that username and password do not match") + _clear_failures(throttle_key) value, _claims = aios_session.mint(tenant, user["username"], int(user.get("epoch") or 0)) aios_session.set_cookie(response, request, value) diff --git a/api/routes_automation.py b/api/routes_automation.py new file mode 100644 index 0000000000000000000000000000000000000000..9bf657990d5c5676d43a53f88d5b4754cbba3f08 --- /dev/null +++ b/api/routes_automation.py @@ -0,0 +1,217 @@ +"""routes_automation.py — wave-18 item 5 (contract C4-AUTO): the automation surface's API. + +The router is thin on purpose: everything that can be wrong about an automation — a malformed +cron, a URL the SSRF rail refuses, a key field that is not one of the mapped columns — is decided +in `automation_engine`, which is a pure-ish module a gate can drive without a server. This file +does auth, shape and status codes. + +⛔ THE TICK ENDPOINT IS THE ONE UNAUTHENTICATED ROUTE, AND IT IS FAIL-CLOSED TWICE OVER. It takes +no session (an external cron has no cookie), so it is gated on a shared secret in +`X-AIOS-TICK-TOKEN`; and when `AIOS_AUTOMATION_TICK_TOKEN` is UNSET the route refuses everything +rather than admitting everyone. A "no token configured means no check" default is how an internal +trigger becomes a public one — the same class of mistake as an empty-200 permission answer. +""" +import os +import time + +from fastapi import APIRouter, Body, Depends, Header, Request + +import automation_engine as engine +from deps import Session, err, module_gate, require_session + +router = APIRouter(prefix="/api/v1") + +#: The registry key this surface carries (C-AUTONAV — A adds the row; the gate is live now, so +#: the day the row lands the wall is already the one that was tested). +MODULE = "automation" + +_GATE = module_gate(MODULE) + + +def _wire(defn, tenant): + """One automation, as the client reads it. `running` is PROCESS state, never store state — + see the engine header on why a persisted 'running' is a permanent lock.""" + live = engine.running(tenant, defn.get("id")) + sched = defn.get("schedule") or {} + nxt = engine.next_fire(sched.get("cron")) if sched.get("enabled") else None + status = dict(defn.get("status") or {}) + if live: + status = {**status, "state": "running", "startedAt": live.get("startedAt"), + "step": live.get("step")} + return { + "id": defn.get("id"), "name": defn.get("name"), "kind": defn.get("kind"), + "config": defn.get("config") or {}, "schedule": sched, "status": status, + "runs": list(defn.get("runs") or [])[:engine.MAX_RUNS], + "created": defn.get("created"), "createdBy": defn.get("createdBy"), + "nextRunAt": nxt.strftime("%Y-%m-%d %H:%M") if nxt else "", + "running": bool(live), + } + + +@router.get("/automations") +def list_automations(session: Session = Depends(_GATE)): + """`{automations: [...], kinds: [...], cronPresets: [...]}` — the rail's whole payload. + + The vocabularies ride WITH the list rather than sitting in a client constant: the cron + presets and the kind list are the server's, and a client copy of either is a thing that goes + stale silently (the editor would offer a preset the parser rejects).""" + defs = engine.all_definitions(session.runtime) + items = [_wire(d, session.tenant) for _, d in + sorted(defs.items(), key=lambda kv: (kv[1].get("name") or "").lower())] + return {"automations": items, + "kinds": [{"key": "scrape_db", "label": "Web page to database"}, + {"key": "field_instagram", "label": "Instagram profile column"}], + "cronPresets": engine.CRON_PRESETS, + "storeAvailable": bool(session.runtime.available())} + + +@router.get("/automations/tables") +def automation_tables(session: Session = Depends(_GATE)): + """The blank databases an automation can target, with their fields. + + ⚠ A READ-ONLY MIRROR of C3-UT's `GET /api/v1/tables`, under this router's own prefix so the + two can never collide. It exists because the automation editor needs the table+field list to + build a config at all, and D must not block on A's route landing. When C3-UT is live this + keeps working (same bucket) — it is a duplicate reader, never a second writer. + """ + out = [] + for key, t in sorted(engine.ut_all(session.runtime).items(), + key=lambda kv: (kv[1].get("label") or "").lower()): + if not (session.admin or t.get("createdBy") in (session.uname, "automation", + "scheduler")): + continue # user_tables.may_open's rule, mirrored fail-closed + out.append({"key": key, "label": t.get("label") or key, + "source": t.get("source") or "Blank", + "rowCount": len(t.get("rows") or {}), + "fields": [{"key": f.get("key"), "label": f.get("label"), + "type": f.get("type") or "text", + "automation": f.get("automation") or None} + for f in (t.get("fields") or [])]}) + return {"tables": out} + + +@router.get("/automations/{auto_id}") +def get_automation(auto_id: str, session: Session = Depends(_GATE)): + defn = engine.all_definitions(session.runtime).get(str(auto_id)) + if defn is None: + raise err(404, "unknown_automation", "no automation with that id") + return {"automation": _wire(defn, session.tenant)} + + +@router.post("/automations") +def create_automation(body: dict = Body(default=None), session: Session = Depends(_GATE)): + if not session.runtime.available(): + raise err(503, "store_unavailable", "the tenant store is unavailable — nothing was saved") + defn, error = engine.create(session.runtime, body or {}, username=session.uname) + if error: + raise err(400, "invalid_automation", error) + return {"automation": _wire(defn, session.tenant)} + + +@router.patch("/automations/{auto_id}") +def patch_automation(auto_id: str, body: dict = Body(default=None), + session: Session = Depends(_GATE)): + if not session.runtime.available(): + raise err(503, "store_unavailable", "the tenant store is unavailable — nothing was saved") + defn, error = engine.patch(session.runtime, auto_id, body or {}, username=session.uname) + if error: + raise err(400 if error != "no such automation" else 404, + "invalid_automation" if error != "no such automation" else "unknown_automation", + error) + return {"automation": _wire(defn, session.tenant)} + + +@router.delete("/automations/{auto_id}") +def delete_automation(auto_id: str, session: Session = Depends(_GATE)): + """Delete the DEFINITION. ⚠ The database it filled is NOT touched — an automation is the + thing that writes rows, not the thing that owns them, and deleting a job must never be a way + to lose data (the same rule the orphan count encodes).""" + if engine.running(session.tenant, auto_id): + raise err(409, "automation_running", "it is running — wait for it to finish") + engine.remove(session.runtime, auto_id) + return {"deleted": str(auto_id)} + + +@router.post("/automations/preview") +def preview_source(body: dict = Body(default=None), session: Session = Depends(_GATE)): + """What does this URL actually offer? The field-map step — never writes anything.""" + body = body or {} + url = str(body.get("url") or "").strip() + if not url: + raise err(400, "no_url", "give a page URL to read") + try: + return engine.preview(url, str(body.get("extract") or "table"), + int(body.get("tableIndex") or 0)) + except engine.Refused as e: + raise err(400, "refused_url", str(e)) + except Exception as e: # noqa: BLE001 + raise err(502, "fetch_failed", f"could not read that page — {type(e).__name__}: " + f"{str(e)[:160]}") + + +@router.post("/automations/{auto_id}/run") +def run_automation(auto_id: str, session: Session = Depends(_GATE)): + """Start a run on a background thread. 409 when one is already in flight.""" + defn = engine.all_definitions(session.runtime).get(str(auto_id)) + if defn is None: + raise err(404, "unknown_automation", "no automation with that id") + if not engine.run_async(session.runtime, session.tenant, auto_id, username=session.uname): + raise err(409, "automation_running", "that automation is already running") + return {"started": str(auto_id), "startedAt": time.strftime("%Y-%m-%dT%H:%M:%S")} + + +@router.post("/automations/tick") +def tick(request: Request, x_aios_tick_token: str = Header(default="")): + """Fire every due schedule, for every tenant. The durable-cron entry point (R5). + + Unauthenticated BY DESIGN and gated on a shared secret instead — an EventBridge rule has no + cookie. Refuses when the secret is not configured (see the module header).""" + want = os.environ.get("AIOS_AUTOMATION_TICK_TOKEN") or "" + if not want: + raise err(403, "tick_disabled", + "AIOS_AUTOMATION_TICK_TOKEN is not configured — the tick endpoint is closed") + got = x_aios_tick_token or request.headers.get("X-AIOS-TICK-TOKEN") or "" + if got != want: + raise err(403, "bad_tick_token", "that token is not valid for this deployment") + started = engine.tick_all() + return {"started": started, "at": time.strftime("%Y-%m-%dT%H:%M:%S")} + + +@router.get("/automations/{auto_id}/rows") +def run_rows(auto_id: str, session: Session = Depends(_GATE)): + """The rows the LAST run touched — the drill-down behind a run's counts. + + Every count in this product drills to the exact rows behind it ([[no-unverifiable-aggregates]]); + a run history that said "412 updated" and could not show which would be the thing that rule + exists to forbid. + """ + defn = engine.all_definitions(session.runtime).get(str(auto_id)) + if defn is None: + raise err(404, "unknown_automation", "no automation with that id") + last = (defn.get("runs") or [{}])[0] + table_key = (defn.get("config") or {}).get("targetTable") or "" + t = engine.ut_get(session.runtime, table_key) or {} + rows = t.get("rows") or {} + ids = [str(i) for i in (last.get("affected") or [])] + return {"table": table_key, "label": t.get("label") or table_key, + "fields": [{"key": f.get("key"), "label": f.get("label")} + for f in (t.get("fields") or [])], + "rows": [{"id": i, **(rows.get(i) or {})} for i in ids if i in rows], + "truncated": len(ids) >= 200} + + +# --- the in-process scheduler ------------------------------------------------------------ +# ⚠ OPT-IN (`AIOS_AUTOMATIONS=1`), and that is an AMENDMENT to the wave brief's "default-on", +# made on a measurement: `verify_api.py` runs for 196 s, i.e. longer than three tick intervals, +# and `tick_all` reaches `runtime.get_runtime()` — which builds tenants and moves the LRU cache +# that verify_api's own isolation checks read. Default-on would put a background thread inside +# the subject of another session's gate. `AIOS_PREWARM=1` at `main.py:353` is the same decision +# for the same reason, so this follows it rather than inventing a second convention. +# +# The loop also SLEEPS FIRST (`engine.scheduler_loop`) — defence in depth, proven in +# verify_automation.py section T rather than assumed. +# +# ⛔ THE DEPLOY MUST SET `AIOS_AUTOMATIONS=1` (with `AIOS_AUTOMATION_TICK_TOKEN`) or schedules +# only ever fire from the external cron POSTing /automations/tick. Both paths work; neither is +# implicit. Booked in the session-D mailbox. +engine.start_scheduler() diff --git a/api/routes_grid.py b/api/routes_grid.py index 592bbaa4368384e4d65608dcbf3c4b1c108f71c2..b2d3e252be38f062c7a7e611067ebb7aec12acf5 100644 --- a/api/routes_grid.py +++ b/api/routes_grid.py @@ -47,20 +47,32 @@ def _ctx(session: Session, fields, pids, **kw): # contract the hidden-field closure runs over, and the TABLE OPS the write lands in. # Getting any one of them from the other topic is the "validated against the wrong field # contract" near-miss the wave-15 routes_products header warned about. - if kw.get("scope_key") == "product": + scope_key = str(kw.get("scope_key") or "") + if scope_key == "product": import modules.product_data as pd from routes_products import MODULE as _PMOD, pd_fields module, canonical = _PMOD, pd_fields(consolidated=True) kw.setdefault("table", pd.TABLE_OPS) + hidden = perm_scope.hidden_keys(session.user, module, canonical) + elif scope_key.startswith("ut_"): + # Wave 18 C3-UT: a user table has no module in the permission wall (its wall is + # `user_tables.may_open`, already applied by the assembly this route ran first), so + # the hidden-field closure is EMPTY rather than borrowed from another topic's contract. + import core.table_store as table_store + + kw.setdefault("table", + table_store.make(f"{scope_key}_table_workspace", st=session.runtime)) + hidden = frozenset() else: module, canonical = MODULE, aios_grid.FIELDS + hidden = perm_scope.hidden_keys(session.user, module, canonical) return grid_events.EventCtx( uname=session.uname, allowed_pids=pids, fields=fields, admin=session.admin, # C-PERM: the write wall's field half, on the EVENTS transport too. This route takes the # component's event objects verbatim, so a hidden key would otherwise arrive here with # nothing between it and the store. - hidden_keys=perm_scope.hidden_keys(session.user, module, canonical), + hidden_keys=hidden, fallback_ws=None, seen_ids={}, **kw) @@ -74,8 +86,15 @@ _SCOPES = ("customer", "cohort", "product") def _scope_or_400(raw): """⛔ REFUSE AN UNKNOWN SCOPE, never default it. A typo silently served as `customer` would hand a user the whole book on a page they opened to see one cohort — the widening direction, - which is the one that must fail closed.""" + which is the one that must fail closed. + + Wave 18 (C3-UT): a `ut_`-prefixed scope names a USER TABLE and passes through here — + existence and the per-table wall are enforced by `routes_tables.ut_assembly` (404/403), + which every consumer of such a scope goes through. Passing an unknown ut key therefore + still fails closed, just one layer down where the store can actually be consulted.""" scope = (raw or "customer").strip().lower() + if scope.startswith("ut_"): + return scope if scope not in _SCOPES: raise err(400, "bad_scope", f"scope must be one of {', '.join(_SCOPES)} — refusing to guess") @@ -102,6 +121,35 @@ def workspace(scope: str = "customer", from routes_customers import grid_assembly scope = _scope_or_400(scope) + # ── Wave 18 C3-UT: a USER TABLE'S workspace — the third topic through the one wire. The + # storage key has no (bu, agent) because a user table has no Odoo scope; per-user by the + # table's own wall (creator or admin, `user_tables.may_open`). + if scope.startswith("ut_"): + from routes_tables import ut_assembly + + storage_key = f"{session.tenant}:{scope}:{session.uname}" + try: + g = ut_assembly(session, scope, storage_key=storage_key) + except grid_events.StoreUnavailable: + raise err(503, "store_unavailable", "the tenant store is unavailable") + workspace = g["workspace"] + workspace["overlays"] = g["ws"].get("overlays") or {} + workspace["measures"] = g["measures"] + workspace["measureSets"] = g["measure_sets"] + workspace["derived"] = {} + workspace["viewer"] = {"name": session.uname, "isAdmin": bool(session.admin)} + try: + from core import users as _users + workspace["userOptions"] = _users.assignable_people(tenant=session.tenant) + workspace["userAvatars"] = {k: v for k, v in + _users.avatar_map(tenant=session.tenant).items() + if str(v).startswith("data:image/")} + except Exception: + workspace["userOptions"] = [] + workspace["userAvatars"] = {} + workspace["scopeKey"] = scope + return {"workspace": workspace} + # ── Wave 16 C-TOPIC: the PRODUCT surface has its own assembly (own pool, own field # contract, own workspace BUCKET) and the contract's own storage key. It branches before # the customer derivation because the customer storage key embeds (bu, agent) while the @@ -129,8 +177,9 @@ def workspace(scope: str = "customer", workspace["viewer"] = {"name": session.uname, "isAdmin": bool(session.admin)} try: from core import users as _users - workspace["userOptions"] = _users.assignable_people() - workspace["userAvatars"] = {k: v for k, v in _users.avatar_map().items() + workspace["userOptions"] = _users.assignable_people(tenant=session.tenant) + workspace["userAvatars"] = {k: v for k, v in + _users.avatar_map(tenant=session.tenant).items() if str(v).startswith("data:image/")} except Exception: workspace["userOptions"] = [] @@ -184,11 +233,12 @@ def workspace(scope: str = "customer", workspace["viewer"] = {"name": session.uname, "isAdmin": bool(session.admin)} try: from core import users as _users - workspace["userOptions"] = _users.assignable_people() + workspace["userOptions"] = _users.assignable_people(tenant=session.tenant) # Wave 14 C-AVATAR — the options vocabulary's companion: display name -> data URL. # Absent entries fall back to the client's initials disc; a non-data: value is # dropped (defence in depth beside the write-side wall in routes_auth). - workspace["userAvatars"] = {k: v for k, v in _users.avatar_map().items() + workspace["userAvatars"] = {k: v for k, v in + _users.avatar_map(tenant=session.tenant).items() if str(v).startswith("data:image/")} except Exception: workspace["userOptions"] = [] @@ -291,10 +341,10 @@ def grid_timeseries(body: dict = Body(default=None), scope: str = "customer", # product pids are CRC32 hashes and would mostly fall outside the customer book anyway, # but "mostly" is not a wall. The client hides the mode for this topic; this is the # server's half of the same refusal. - if _scope_or_400(scope) == "product": + _sc = _scope_or_400(scope) + if _sc == "product" or _sc.startswith("ut_"): raise err(400, "bad_timeseries", - "the product surface has no time-series channel yet — measures are " - "customer-grain") + "this surface has no time-series channel — measures are customer-grain") body = body or {} bucket = body.get("bucket") @@ -492,7 +542,8 @@ def grid_calendar_metrics(body: dict = Body(default=None), scope: str = "custome # The same refusal the TS channel makes, for the same reason: measures are customer-grain # and product pids are CRC32 hashes of SKU codes. "Mostly outside the book" is not a wall. - if _scope_or_400(scope) == "product": + _sc_cal = _scope_or_400(scope) + if _sc_cal == "product" or _sc_cal.startswith("ut_"): raise err(400, "bad_calendar_metrics", "the product surface has no measure channel yet — measures are customer-grain") @@ -645,6 +696,12 @@ def grid_events_route(body: dict = Body(default=None), session.require(PRODUCT_MODULE) # the route's own dependency asserts only customer_data g = product_assembly(session, consume_corrections=False) + elif scope.startswith("ut_"): + # Wave 18 C3-UT — the user-table wall (creator/admin) is inside the assembly; the + # measure/cohort context is honestly EMPTY (customer-grain machinery, no meaning here). + from routes_tables import ut_assembly + + g = ut_assembly(session, scope, consume_corrections=False) else: g = grid_assembly(session, scope=scope, consume_corrections=False) # ⚠ THE MEASURE CONTEXT IS NOT OPTIONAL (2026-07-31). Without `measure_offer`, @@ -698,7 +755,7 @@ def grid_events_route(body: dict = Body(default=None), # ⚠ AND IT IS A SHORTCUT, NOT A PATH. Any failure is swallowed: `WORKSPACE_STALE` still # fires from `rerender`, and the re-read still delivers these values exactly as it does # today. Nothing depends on this having worked. - if out["rerender"] and scope != "product" and any( + if out["rerender"] and scope in ("customer", "cohort") and any( isinstance(e, dict) and e.get("type") == "field_upsert" and str(((e.get("field") or {}) if isinstance(e.get("field"), dict) else {}) .get("key") or "").startswith("measure_") diff --git a/api/routes_keychain.py b/api/routes_keychain.py new file mode 100644 index 0000000000000000000000000000000000000000..1d6795e91cfe0f4b3094a3dfebf00e1932910097 --- /dev/null +++ b/api/routes_keychain.py @@ -0,0 +1,143 @@ +"""routes_keychain.py — Keychains + Connectors admin surfaces (wave 18, C7 / R3). + +Keychain: encrypted per-tenant credential entries (`core/keychain.py`). The routes NEVER +return a decrypted field — list rows carry a masked preview, and the decrypt function is a +connector-layer internal. Connectors: the tenant's data sources as STATUS rows — Royal's +env-configured Odoo, keychain-held sources — plus R3's guardrail: the **Unsynced records** +count (rows holding overlay data whose pids the current pool no longer serves; counted and +drillable, never silently dropped) and a pause toggle whose v1 semantics are stated honestly +in the payload (`pausedNote`): pausing marks intent and warns; the source cutover ships with +the keychain cutover wave R3 staged. +""" +import os + +from fastapi import Body, Depends +from fastapi import APIRouter + +from deps import Session, err +from routes_admin import admin_gate + +router = APIRouter(prefix="/api/v1") + +_CONNECTOR_FLAGS_KEY = "connectors" + + +def _kc(): + import core.keychain as keychain + return keychain + + +@router.get("/admin/keychain") +def list_keychain(session: Session = Depends(admin_gate)): + kc = _kc() + return {"entries": kc.list_entries(session.runtime), "locked": not kc.unlocked()} + + +@router.post("/admin/keychain", status_code=201) +def add_key(body: dict = Body(default=None), session: Session = Depends(admin_gate)): + kc = _kc() + body = body or {} + if not session.runtime.available(): + raise err(503, "store_unavailable", "the tenant store is unavailable") + try: + row = kc.add_entry(session.runtime, body.get("label"), body.get("type"), + body.get("fields"), session.uname) + except kc.KeychainLocked as e: + raise err(503, "keychain_locked", + f"the keychain is locked — {e}. A secret is never stored unencrypted.") + except ValueError as e: + raise err(400, "bad_entry", str(e)) + except Exception: + raise err(503, "store_unavailable", "the entry was not saved — try again") + return {"entry": row} + + +@router.delete("/admin/keychain/{entry_id}") +def delete_key(entry_id: str, session: Session = Depends(admin_gate)): + try: + _kc().delete_entry(session.runtime, entry_id) + except Exception: + raise err(503, "store_unavailable", "the delete did not land — try again") + return {"ok": True} + + +@router.post("/admin/keychain/{entry_id}/test") +def test_key(entry_id: str, session: Session = Depends(admin_gate)): + return _kc().test_entry(session.runtime, entry_id) + + +def _unsynced_customer_records(session): + """R3's guardrail, tenant #0's customer topic: overlay-holding pids the CURRENT pool no + longer serves. Overlays are unioned across EVERY user of the table (the guardrail is a + tenant fact, not a per-user one). Honest degradation: when the pool cannot be built the + answer is `known: False`, never a fabricated zero.""" + try: + import core.table_store as table_store + bucket = session.runtime.get("customer_table_workspace") or {} + overlay_pids = {} + for uname, ws in bucket.items(): + if uname == table_store.SHARED_KEY or not isinstance(ws, dict): + continue + for pid, cells in (ws.get("overlays") or {}).items(): + if isinstance(cells, dict) and cells: + overlay_pids.setdefault(str(pid), cells) + if not overlay_pids: + return {"known": True, "count": 0, "rows": []} + from routes_customers import allowed_pids + pool = {str(p) for p in allowed_pids(session)} + orphans = sorted((p for p in overlay_pids if p not in pool), key=lambda x: int(x) + if str(x).isdigit() else 0) + rows = [] + for p in orphans[:50]: + cells = overlay_pids[p] + hint = next((str(v) for v in cells.values() if str(v).strip()), "") + rows.append({"pid": int(p) if str(p).isdigit() else p, + "fields": len(cells), "hint": hint[:80]}) + return {"known": True, "count": len(orphans), "rows": rows, + "shown": min(len(orphans), 50)} + except Exception as e: + return {"known": False, "count": None, "rows": [], + "note": f"pool unavailable — {type(e).__name__}"} + + +@router.get("/admin/connectors") +def connectors(session: Session = Depends(admin_gate)): + kc = _kc() + flags = session.runtime.get(_CONNECTOR_FLAGS_KEY) or {} + rows = [] + if session.tenant == "royal-imports" and os.environ.get("ODOO_URL"): + rows.append({"key": "odoo-env", "label": "Odoo (environment)", "type": "odoo", + "source": "env", + "paused": bool((flags.get("odoo-env") or {}).get("paused"))}) + for e in kc.list_entries(session.runtime): + rows.append({"key": e["id"], "label": e["label"], "type": e["type"], + "source": "keychain", "preview": e["preview"], + "paused": bool((flags.get(e["id"]) or {}).get("paused"))}) + out = {"connectors": rows, "locked": not kc.unlocked(), + # R3, stated where the UI reads it: pausing never deletes anything — overlays, + # notes and custom fields stay; serving from the last snapshot + automatic resync + # arrives with the cutover wave. The pause flag records intent TODAY. + "pausedNote": ("Pausing a connector never deletes data — notes, custom fields and " + "views stay. Snapshot serving while paused arrives with the " + "connector cutover; until then Royal's surfaces keep reading live.")} + if session.tenant == "royal-imports": + out["unsynced"] = _unsynced_customer_records(session) + return out + + +@router.post("/admin/connectors/{key}/pause") +def pause_connector(key: str, body: dict = Body(default=None), + session: Session = Depends(admin_gate)): + paused = bool((body or {}).get("paused")) + if not session.runtime.available(): + raise err(503, "store_unavailable", "the tenant store is unavailable") + + def _up(cur): + cur[str(key)] = {"paused": paused} + return cur + + try: + session.runtime.update(_CONNECTOR_FLAGS_KEY, _up) + except Exception: + raise err(503, "store_unavailable", "the change was not saved — try again") + return {"key": key, "paused": paused} diff --git a/api/routes_nav.py b/api/routes_nav.py index a2f53b2979ac281496421f5b21eebc3e756992e2..21be6647e57d9be1beaf683e3a44058cb7a195a7 100644 --- a/api/routes_nav.py +++ b/api/routes_nav.py @@ -67,11 +67,41 @@ def nav(session: Session = Depends(require_session)): gets an explicit 403 — an empty 200 is indistinguishable from "the registry is empty" and is how a permission bug hides in plain sight (X2's never-an-empty-200 rule). """ - pages = perms.nav_pages(session.user) + pages = list(perms.nav_pages(session.user) or []) + # Wave 18 C1-TENANT: the REGISTRY is the product's module catalogue — tenant #0's world. + # A tenant record may enable a subset (`modules: [...]`); absent/'all' means everything + # (royal-imports and the compiled builders). A blank tenant enables NOTHING: its nav is + # its own databases, which is what "different set of databases at later waves" means. + tcfg = getattr(session.runtime.tenant, "config", None) or {} + tmods = tcfg.get("modules", "all") + if tmods != "all": + allowed = {str(k) for k in (tmods or [])} + pages = [p for p in pages + if p.get("key") in allowed or (p.get("parent") or "") in allowed] + # Wave 18 C3-UT: this tenant's user-created databases, merged AFTER the registry rows — + # the host does the same at app.py:7796. Filtered by the per-table wall (`may_open`), so + # the nav cannot offer a row the table routes would refuse. + try: + import core.user_tables as user_tables + for e in user_tables.nav_entries(viewer=session.uname, is_admin=session.admin, + st=session.runtime): + pages.append({"key": e["key"], "label": e["label"], + "source": e.get("source") or "Blank", "chrome": "main"}) + except Exception: + pass # a store blip must not take the whole nav down with it if not pages: + if tmods != "all": + # A provisioned tenant with no modules and no databases YET is a legitimate empty + # state, not a misconfigured account — the client renders "create your first + # database", and X2's never-an-empty-200 rule is honoured by saying WHY it is + # empty rather than leaving 200-[] ambiguous. + return {"pages": [], "landing": None, "empty": "no_databases"} raise err(403, "no_surfaces", "your account has no dashboards assigned — ask an administrator") - return {"pages": pages, "landing": perms.landing_page(session.user)} + landing = perms.landing_page(session.user) + if landing and not any(p.get("key") == landing for p in pages): + landing = pages[0].get("key") + return {"pages": pages, "landing": landing} @router.get("/nav/prefs") @@ -116,6 +146,21 @@ def nav_schema(key: str, session: Session = Depends(require_session)): """The database's schema drawer payload: its field contract + the semantic measures this session may build with. Fail-closed on the SAME predicate as the nav — a key the session may not open answers 403, never a redacted schema.""" + # Wave 18 C3-UT: a user table's schema is its own definition, walled by ITS predicate + # (`may_open`) rather than the module grant machinery — `session.require` would 403 every + # ut key because a user table is deliberately not a module. + if key.startswith("ut_"): + import core.user_tables as user_tables + defn = user_tables.get(key, st=session.runtime) + if not defn or not user_tables.may_open(key, session.uname, session.admin, + st=session.runtime): + raise err(403, "forbidden", "that database belongs to another user") + return {"key": key, "label": defn.get("label") or key, + "source": defn.get("source") or "Blank", + "fields": [{"key": f["key"], "label": f["label"], "type": f["type"], + "source": f.get("source") or "overlay", "description": ""} + for f in (defn.get("fields") or [])], + "measures": []} session.require(key) pages = perms.nav_pages(session.user) or [] page = next((p for p in pages if p.get("key") == key), None) diff --git a/api/routes_tables.py b/api/routes_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..fff7f982df514cbbca2eba42dcd8a75b2a83505c --- /dev/null +++ b/api/routes_tables.py @@ -0,0 +1,239 @@ +"""routes_tables.py — USER TABLES over the wire (wave 18, contract C3-UT). + +The runtime-database primitive: `core/user_tables.py` (wave-9 C6, host-only until now) served +through the SAME grid machinery every other topic rides — `table_store` for the per-user +workspace strata, `aios_grid.workspace_wire` for the wire shape, `core.grid_events` for every +durable write except rows. Rows are the one genuinely new channel: the events seam has no row +event types (the user_tables docstring's `row_add` gate was described, never built), so row +add/delete/patch are REST endpoints here, walled by `user_tables.is_user_table` + +`user_tables.may_open` — a connector-backed table can never accept an invented row. + +TENANCY: every store touch goes through `session.runtime` (the tenant's store handle), so a +Nurilab admin's tables live under Nurilab's prefix/repo, and the isolation gate's proof #3 +covers them for free. + +VISIBILITY is `user_tables.may_open` — creator or admin, fail-closed. There is no module grant +to check because a user table is not a module; the per-table wall is the whole wall, and it is +applied in `_defn_or_refuse` before any payload is built. +""" +import time + +from fastapi import Body, Depends +from fastapi import APIRouter + +from deps import Session, err, require_session + +router = APIRouter(prefix="/api/v1") + + +def _ut(): + import core.user_tables as user_tables + return user_tables + + +def _ops(session, table_key): + import core.table_store as table_store + return table_store.make(f"{table_key}_table_workspace", st=session.runtime) + + +def _defn_or_refuse(session, table_key): + """The per-table wall: 404 for a key that does not exist, 403 for one this session may not + open. 404-before-403 leaks nothing useful — ut keys are guessable slugs, and 'exists but + not yours' is exactly what may_open is for.""" + ut = _ut() + defn = ut.get(table_key, st=session.runtime) + if not defn: + raise err(404, "unknown_table", "that database does not exist") + if not ut.may_open(table_key, session.uname, session.admin, st=session.runtime): + raise err(403, "forbidden", "that database belongs to another user") + return defn + + +def ut_assembly(session: Session, table_key: str, storage_key: str = "", + consume_corrections: bool = True): + """The user-table mirror of `grid_assembly` / `product_assembly` — SAME g-dict keys, so + `/workspace` and the events route consume any of the three interchangeably. + + Honest absences: `measures`/`measure_sets`/`lists`/`derived` are EMPTY — measures are + customer-grain and cohorts store partner pids; neither means anything over user rows.""" + import aios_grid + from core import grid_events + + defn = _defn_or_refuse(session, table_key) + fields_base = [dict(f) for f in (defn.get("fields") or [])] + field_keys = {f["key"] for f in fields_base} + rows_src = [] + for rid, row in (defn.get("rows") or {}).items(): + if not str(rid).isdigit(): + continue + r = {k: v for k, v in (row or {}).items() if k in field_keys} + r["pid"] = int(rid) + rows_src.append(r) + rows_src.sort(key=lambda r: r["pid"]) + pids = frozenset(r["pid"] for r in rows_src) + + ops = _ops(session, table_key) + ctx = grid_events.EventCtx( + uname=session.uname, allowed_pids=pids, fields=[], hidden_keys=frozenset(), + admin=session.admin, fallback_ws=None, seen_ids={}, + scope_key=table_key, table=ops) + ws = grid_events.table_workspace(ctx, allowed_pids=pids, + consume_corrections=consume_corrections) + workspace, fields, views, _lists = aios_grid.workspace_wire( + ws, session.uname, set(pids), defs={}, scope_key=table_key, + storage_key=storage_key, fields_base=fields_base, with_cohorts=False) + + return {"rows_src": rows_src, "pids": pids, "ws": ws, "workspace": workspace, + "fields": fields, "views": views, "lists": [], "derived": {}, + "measures": [], "measure_sets": {}, "today": time.strftime("%Y-%m-%d"), + "defn": defn} + + +@router.get("/tables") +def list_tables(session: Session = Depends(require_session)): + """This session's user tables — the list the '+ New database' surface renders.""" + ut = _ut() + out = [] + for key, t in sorted(ut.all_tables(st=session.runtime).items(), + key=lambda kv: (kv[1].get("label") or "").lower()): + if not ut.may_open(key, session.uname, session.admin, st=session.runtime): + continue + out.append({"key": key, "label": t.get("label") or key, + "source": t.get("source") or "Blank", + "createdBy": t.get("createdBy") or "", + "created": t.get("created") or "", + "fields": [dict(f) for f in (t.get("fields") or [])], + "rowCount": len(t.get("rows") or {})}) + return {"tables": out} + + +@router.post("/tables", status_code=201) +def create_table(body: dict = Body(default=None), + session: Session = Depends(require_session)): + ut = _ut() + body = body or {} + label = str(body.get("label") or "").strip() + if not label: + raise err(400, "bad_label", "give the database a name") + if not session.runtime.available(): + raise err(503, "store_unavailable", + "the tenant store is unavailable — nothing was created") + source = body.get("source") + try: + key = ut.create(label, session.uname, fields=body.get("fields"), + source=source, st=session.runtime) + except Exception: + raise err(503, "store_unavailable", + "the tenant store refused the write — nothing was created") + if not key: + raise err(400, "refused", + f"could not create it — the name may be empty or this tenant already has " + f"{ut.MAX_TABLES} databases") + return {"key": key} + + +@router.delete("/tables/{table_key}") +def delete_table(table_key: str, session: Session = Depends(require_session)): + """Creator or admin only — the same actors `may_open` admits, and deletion is the one + operation the client must confirm explicitly (the server cannot tell a click from a plan).""" + _defn_or_refuse(session, table_key) + try: + _ut().delete(table_key, st=session.runtime) + except Exception: + raise err(503, "store_unavailable", "the delete did not land — try again") + # The workspace bucket (views/custom fields/overlays) is left in place: a delete that also + # destroyed per-user state would make an accidental delete unrecoverable, and the bucket is + # invisible without its definition. Booked, not hidden. + return {"ok": True} + + +@router.get("/tables/{table_key}/rows") +def table_rows(table_key: str, session: Session = Depends(require_session)): + """The `/customers`-shaped envelope for one user table: `{fields, rows, today, pulled_at, + identity}` — so the client's generic topic fetch consumes it with zero new parsing. + + ⚠ THE MERGE ORDER IS THE CONTRACT. `rows_from_pool` sources an overlay-typed field's cell + from the OVERLAY stratum only (that is what makes a custom column render standalone) — a + user table's base values live in its DEFINITION rows, so they are layered UNDER the user's + overlay edits here: base first, overlay wins. Without this every base cell reads empty + (found by this route's own gate check, not by luck).""" + import aios_grid + + g = ut_assembly(session, table_key) + merged = {str(r["pid"]): {k: v for k, v in r.items() if k != "pid"} + for r in g["rows_src"]} + for pid, cells in (g["ws"].get("overlays") or {}).items(): + if isinstance(cells, dict): + merged.setdefault(str(pid), {}).update(cells) + rows = aios_grid.rows_from_pool( + g["rows_src"], g["fields"], merged, derived=g["derived"]) + return {"fields": g["fields"], "rows": rows, "today": g["today"], + "pulled_at": time.strftime("%Y-%m-%d %H:%M"), + "identity": {"pid": "pid"}, + "scope": {"table": table_key, "rowCount": len(rows)}} + + +@router.post("/tables/{table_key}/rows", status_code=201) +def add_row(table_key: str, body: dict = Body(default=None), + session: Session = Depends(require_session)): + _defn_or_refuse(session, table_key) + ut = _ut() + values = (body or {}).get("values") or {} + if not isinstance(values, dict): + raise err(400, "bad_values", "values must be an object of {fieldKey: value}") + try: + rid = ut.add_row(table_key, values, session.uname, st=session.runtime) + except Exception: + raise err(503, "store_unavailable", "the row was not saved — the store refused") + if rid is None: + raise err(400, "refused", + f"row refused — the table may be at its {ut.MAX_ROWS}-row cap") + return {"rid": rid, "pid": int(rid)} + + +@router.delete("/tables/{table_key}/rows/{rid}") +def delete_row(table_key: str, rid: str, session: Session = Depends(require_session)): + _defn_or_refuse(session, table_key) + try: + ok = _ut().delete_row(table_key, rid, st=session.runtime) + except Exception: + raise err(503, "store_unavailable", "the delete did not land — try again") + if not ok: + raise err(400, "refused", "rows can only be deleted from user-created databases") + return {"ok": True} + + +@router.patch("/tables/{table_key}/rows/{pid}") +def patch_row(table_key: str, pid: int, body: dict = Body(default=None), + session: Session = Depends(require_session)): + """Cell edits — the products PATCH on the user-table ctx. Routed through + `core.grid_events.handle_one` so truncation and permission rules stay ONE implementation; + the accepted values are read BACK from the bucket, never echoed from the request.""" + from core import grid_events + + updates = dict(body or {}) + if not updates: + raise err(400, "empty_patch", "no fields to update") + g = ut_assembly(session, table_key, consume_corrections=False) + if pid not in g["pids"]: + raise err(403, "out_of_scope", "that row is not in this database") + ctx = grid_events.EventCtx( + uname=session.uname, allowed_pids=g["pids"], fields=g["fields"], + admin=session.admin, fallback_ws=None, seen_ids={}, hidden_keys=frozenset(), + scope_key=table_key, table=_ops(session, table_key)) + try: + grid_events.handle_one( + {"id": f"patch:{table_key}:{pid}:{time.time_ns()}", "type": "overlay_patch", + "pid": pid, "updates": updates}, ctx) + except grid_events.StoreUnavailable: + raise err(503, "store_unavailable", + "the tenant store is unavailable — your change was not saved") + stored = (grid_events.table_workspace(ctx, allowed_pids=None) + .get("overlays") or {}).get(str(pid)) or {} + accepted = {k: stored.get(k) for k in updates if k in stored} + refused = sorted(k for k in updates + if k not in accepted or stored.get(k) != str(updates[k])) + out = {"pid": pid, "updates": accepted} + if refused: + out["refused"] = refused + return out diff --git a/requirements.txt b/requirements.txt index 5476ec3cb2f98d94f6ad6a25518072c8827da90b..1b8d51736867b9934c55e65f30cee1a71a34f2b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,3 +10,7 @@ huggingface_hub>=0.20 duckdb>=1.0 pyyaml>=6.0 streamlit==1.58.0 +pillow>=10.0 +beautifulsoup4>=4.12 +lxml>=5.0 +cryptography>=42.0 diff --git a/royalimports_os/aios_grid.py b/royalimports_os/aios_grid.py index 2e9de5d48feabee016d7349689953dd88b3d3d71..06bb1a9c6454a726e506f79c8a171eb421423ec9 100644 --- a/royalimports_os/aios_grid.py +++ b/royalimports_os/aios_grid.py @@ -102,7 +102,8 @@ def _round(v): #: `max`, SVG stars client-side — never emoji) · `created_time` (READ-ONLY, renders the row's #: `_created`) · `formula` (READ-ONLY, client-computed from the row's other cells). CUSTOM_FIELD_TYPES = {"text", "select", "multiselect", "user", "int", "currency", "pct", "date", - "checkbox", "phone", "email", "url", "rating", "created_time", "formula"} + "checkbox", "phone", "email", "url", "rating", "created_time", "formula", + "automation"} #: User-created types whose CELLS are read-only: their values are computed (formula — client #: side, any error degrades to BLANK) or system-owned (created_time = the row's `_created`). #: Emitted with the cohort column's read-only mechanism — `source: 'odoo'` + `derived` — so @@ -253,6 +254,40 @@ def _quotes_balanced(s): return s.count('"') % 2 == 0 +#: Wave-18 C5-AUTOFIELD. `kind` is a whitelist because an unknown kind would be a column that +#: silently never runs; `source` names where the run's subject comes from. +AUTOMATION_KINDS = {"instagram_profile"} +AUTOMATION_SOURCES = {"record_url_field", "self"} +MAX_AUTOMATION_SETTINGS = 12 + + +def _clean_automation(raw, valid_keys=None): + """Validate an `automation` config bag. Returns the clean dict, or None when there is + nothing valid to store (the column then renders as unconfigured — never invented).""" + if not isinstance(raw, dict): + return None + kind = str(raw.get('kind') or '').strip() + if kind not in AUTOMATION_KINDS: + return None + source = str(raw.get('source') or 'record_url_field').strip() + if source not in AUTOMATION_SOURCES: + source = 'record_url_field' + out = {'kind': kind, 'source': source} + url_field = str(raw.get('urlField') or '').strip()[:80] + # fail closed on a ref that does not exist, exactly as _clean_formula does at WRITE time + if url_field and (valid_keys is None or url_field in valid_keys): + out['urlField'] = url_field + settings = {} + for k, v in list((raw.get('settings') or {}).items())[:MAX_AUTOMATION_SETTINGS]: + if isinstance(v, bool) or isinstance(v, (int, float)): + settings[str(k)[:40]] = v + elif isinstance(v, str): + settings[str(k)[:40]] = v[:200] + if settings: + out['settings'] = settings + return out + + def _clean_formula(raw, valid_keys=None): """STRUCTURAL passthrough for a formula field's expression (wave-5 item 9). @@ -576,6 +611,8 @@ def fields_from_workspace(workspace=None, cohorts=False, scope_key=None, fields_ # every member, groups count it under each, the toolbar count stays distinct. **({"multi": True} if ftype == "multiselect" else {}), **({"max": _clean_rating_max(field.get("max"))} if ftype == "rating" else {}), + **({"automation": _clean_automation(field.get("automation"))} + if ftype == "automation" and _clean_automation(field.get("automation")) else {}), **_field_extras(field, ftype), }) if cohorts: @@ -756,7 +793,7 @@ def _clean_rhs(raw, valid_keys): #: rename is therefore a stored-value MIGRATION, not a constant rename: accept 'dashboard' on #: READ forever, only ever WRITE 'chart'. DISPLAY_MODES = {'grid', 'list', 'calendar', 'kanban', 'map', 'dashboard', 'chart', - 'timeseries'} + 'timeseries', 'catalog'} #: C-DISP (wave 2026-08-02): the time-series view's bucket vocabulary and caps, plus the #: calendar-summary metric cap. types.ts mirrors these as TS_BUCKETS / TS_MAX_LAST_N / @@ -768,6 +805,22 @@ TS_MAX_FIELDS = 12 MAX_CALENDAR_METRICS = 4 _ISO_DAY = re.compile(r'^\d{4}-\d{2}-\d{2}$') +#: C6-CATALOG (wave 18) — the catalog view's vocabulary and caps. types.ts mirrors every name +#: below, and `cleanDisplay` applies the same drops in the SAME ORDER, so an accepted save reads +#: back identically on both engines. The code budget is the order-sensitive one — see +#: `_clean_catalogs`. +MAX_CATALOGS = 12 +MAX_CATALOG_PAGES = 40 +MAX_CATALOG_CODES = 500 # cumulative across ONE catalog's pages, spent in PAGE ORDER +CATALOG_PAPERS = {'letter', 'a4', 'tabloid'} +CATALOG_ORIENTATIONS = {'portrait', 'landscape'} +CATALOG_QUALITIES = {'web', 'print'} +CATALOG_PAGE_KINDS = {'cover', 'intro', 'section', 'gallery'} +CATALOG_COLS = (2, 3, 4) +CATALOG_ID_MAX, CATALOG_NAME_MAX = 40, 80 +CATALOG_TITLE_MAX, CATALOG_BODY_MAX, CATALOG_CODE_MAX = 120, 2000, 60 +_HEX6 = re.compile(r'^#[0-9A-Fa-f]{6}$') + #: Wave 14 C-ACC ([[loopable-wave14-split]]; rulings R2/R3). Mirrored by types.ts #: TS_DELTA_KINDS / TS_MAX_CUSTOM_ROWS / TS_MAX_STYLES — the C-DISP byte-identical law. TS_DELTA_KINDS = ('abs', 'pct', 'yoy', 'ytd') @@ -908,6 +961,140 @@ def _clean_chart(raw, valid_keys): return out +def _clean_catalog_page(raw, budget): + """C6-CATALOG — one page of a catalog. Returns `(page | None, codes_spent)`. + + `budget` is what is LEFT of the catalog's 500-code allowance. Codes are deduped WITHIN a + page and not across the catalog: a product legitimately appears on a gallery page and again + in its section listing, and de-duplicating globally would silently delete the second + appearance. The budget is spent in page order, so a catalog that runs out loses the TAIL of + its last pages — never a random scatter, and never a page (a page with no products is a + heading the user can still see and fix). + """ + if not isinstance(raw, dict): + return None, 0 + page_id = str(raw.get('id') or '')[:CATALOG_ID_MAX] + kind = raw.get('kind') + if not page_id or kind not in CATALOG_PAGE_KINDS: + return None, 0 + out = {'id': page_id, 'kind': kind} + for key, cap in (('title', CATALOG_TITLE_MAX), ('body', CATALOG_BODY_MAX), + ('imageCode', CATALOG_CODE_MAX)): + v = raw.get(key) + if isinstance(v, str) and v: + out[key] = v[:cap] + products = raw.get('products') + if isinstance(products, list) and budget > 0: + clean_p, seen_p = [], set() + for c in products: + if not isinstance(c, str) or not c: + continue + c = c[:CATALOG_CODE_MAX] + if c in seen_p: + continue + seen_p.add(c) + clean_p.append(c) + if len(clean_p) >= budget: + break + if clean_p: + out['products'] = clean_p + layout = raw.get('layout') + if isinstance(layout, dict): + clean_l = {} + cols = layout.get('cols') + if isinstance(cols, int) and not isinstance(cols, bool) and cols in CATALOG_COLS: + clean_l['cols'] = cols + # The kanbanClamp/tsSparkline asymmetry, one per direction: pack and colour SHOW by + # default (the 2027 catalogue shows both), price does NOT (it shows no prices at all). + # So only the opt-OUT is storable for the first two and only the opt-IN for the third — + # a second spelling of a default is how a round trip starts churning. + if layout.get('showPack') is False: + clean_l['showPack'] = False + if layout.get('showColor') is False: + clean_l['showColor'] = False + if layout.get('showPrice') is True: + clean_l['showPrice'] = True + if clean_l: + out['layout'] = clean_l + return out, len(out.get('products') or ()) + + +def _clean_catalogs(raw, valid_keys): + """C6-CATALOG (wave 18) — `display.catalogs`, fail-closed. Returns a list or None. + + A catalog is a PRINT artifact, so the two structural keys that decide how it paginates + (`paper`, `orientation`) are NORMALISED WITH A DEFAULT rather than dropped: a page box with + no size is not a smaller catalog, it is an unrenderable one. Everything else follows the + house rules — unknown keys dropped, per-entry drops never cost the neighbours, empty + sub-objects omitted entirely (`brand`, `fields`, `layout`, `products`) so an absent key and + an empty one are not two spellings of the same nothing. + + `fields` binds the listing lines to real columns (the 2027 listing prints description / SKU / + pack / colour, and `product_data` carries no pack or colour of its own — the user binds + custom fields). Refs are checked against `valid_keys` HERE and not on the client, the same + split `dateField`/`stackField` already run. + """ + if not isinstance(raw, list): + return None + out = [] + for c in raw: + if len(out) >= MAX_CATALOGS: + break + if not isinstance(c, dict): + continue + cat_id = str(c.get('id') or '')[:CATALOG_ID_MAX] + name = c.get('name') + # An EMPTY name is legal (the user cleared the box and will type again) — an ABSENT one + # is a malformed record. The `tsRows` label rule, same reasoning. + if not cat_id or not isinstance(name, str): + continue + cat = {'id': cat_id, 'name': name[:CATALOG_NAME_MAX]} + cat['paper'] = c['paper'] if c.get('paper') in CATALOG_PAPERS else 'letter' + cat['orientation'] = (c['orientation'] + if c.get('orientation') in CATALOG_ORIENTATIONS else 'portrait') + if c.get('quality') in CATALOG_QUALITIES: + cat['quality'] = c['quality'] + brand = c.get('brand') + if isinstance(brand, dict): + clean_b = {} + for k in ('primary', 'accent'): + v = brand.get(k) + if isinstance(v, str) and _HEX6.match(v): + clean_b[k] = v + company = brand.get('company') + if isinstance(company, str) and company: + clean_b['company'] = company[:CATALOG_NAME_MAX] + # An asset CODE (resolved through C2-ASSET), never a URL: an arbitrary host inside + # print CSS is exactly the tokens-not-values rule this contract carries. + logo = brand.get('logo') + if isinstance(logo, str) and logo: + clean_b['logo'] = logo[:CATALOG_CODE_MAX] + if clean_b: + cat['brand'] = clean_b + binds = c.get('fields') + if isinstance(binds, dict): + clean_bind = {k: binds[k] for k in ('name', 'pack', 'color', 'price') + if binds.get(k) in valid_keys} + if clean_bind: + cat['fields'] = clean_bind + pages, budget = [], MAX_CATALOG_CODES + raw_pages = c.get('pages') + if isinstance(raw_pages, list): + for p in raw_pages: + if len(pages) >= MAX_CATALOG_PAGES: + break + page, spent = _clean_catalog_page(p, budget) + if page is None: + continue + budget -= spent + pages.append(page) + # ALWAYS emitted, even empty: a catalog with no pages yet is the state every catalog + # starts in, and dropping the key would make "new" and "corrupt" the same wire value. + cat['pages'] = pages + out.append(cat) + return out or None + + def _clean_display(raw, valid_keys): """Structural passthrough for a view's `config.display` (wave-6 item 10), fail-closed. @@ -1066,6 +1253,10 @@ def _clean_display(raw, valid_keys): uniq.append(c) if uniq: out['charts'] = uniq + # ── C6-CATALOG (wave 18) ───────────────────────────────────────────────────────────── + catalogs = _clean_catalogs(raw.get('catalogs'), valid_keys) + if catalogs: + out['catalogs'] = catalogs return out diff --git a/royalimports_os/core/assets.py b/royalimports_os/core/assets.py new file mode 100644 index 0000000000000000000000000000000000000000..da2edd121a1b3884478765261d904e017bb722eb --- /dev/null +++ b/royalimports_os/core/assets.py @@ -0,0 +1,73 @@ +"""core/assets.py — the product-image ASSET SOURCE (wave 18, C2-ASSET). + +WHY THIS FILE EXISTS AT ALL, given the route is three functions long: the API process is +HOST-AGNOSTIC by contract (`ops/verify_portability.py` checks B1/B2 — the HuggingFace SDK may +appear ONLY in its declared homes, all of which live under `royalimports_os/`, so the FastAPI +service can be lifted to Hetzner/EC2 without dragging a hub client with it). The first version +of `routes_assets.py` imported `huggingface_hub` directly and the gate caught it. The fetch is +a STORE-shaped concern anyway, so it belongs beside `core/store.py`. + +Two sources, checked by the caller in order: + * a local master directory (`AIOS_ASSET_DIR`) — dev, and the fastest path on the owner's box; + * the private HF dataset `AIOS_ASSET_REPO` (default `royal-imports/product-assets`), laid out + by `ingest_product_assets.py`: + assets/products/orig/ masters, archived verbatim (owner ruling R9) + assets/products/web/.png ~800px derivatives (what the app displays) + manifest.json {"codes": {"": {"ext": ".png"}}, ...} + +Every failure returns None/{} rather than raising: a missing image is "no picture for that SKU", +never a broken catalog page. +""" +import os +import time +from pathlib import Path + +DEFAULT_REPO = 'royal-imports/product-assets' +_MANIFEST_TTL = 300 +#: (fetched_at, {"CODE": {"ext": ".png"}}) — one manifest read per process per TTL. +_MANIFEST = {'at': 0.0, 'codes': None} + + +def repo_id(): + return os.environ.get('AIOS_ASSET_REPO', '').strip() or DEFAULT_REPO + + +def _token(): + return os.environ.get('HF_TOKEN') or None + + +def manifest(): + """{CODE: {'ext': '.png'}} for the configured asset repo, or {} when unreachable.""" + now = time.time() + if _MANIFEST['codes'] is not None and now - _MANIFEST['at'] < _MANIFEST_TTL: + return _MANIFEST['codes'] + try: + import json + + from huggingface_hub import hf_hub_download + p = hf_hub_download(repo_id(), 'manifest.json', repo_type='dataset', token=_token()) + codes = (json.loads(Path(p).read_text(encoding='utf-8')) or {}).get('codes') or {} + except Exception: + codes = {} + _MANIFEST.update(at=now, codes=codes) + return codes + + +def fetch(code, quality='web'): + """A local Path to one asset, or None. The hub cache dedupes across requests, so a container + downloads each file at most once.""" + meta = manifest().get(code) + if not meta: + return None + rel = (f'assets/products/web/{code}.png' if quality == 'web' + else f"assets/products/orig/{code}{meta.get('ext', '.png')}") + try: + from huggingface_hub import hf_hub_download + return Path(hf_hub_download(repo_id(), rel, repo_type='dataset', token=_token())) + except Exception: + return None + + +def reset_cache(): + """Drop the memoized manifest — for gates and for a post-ingest refresh.""" + _MANIFEST.update(at=0.0, codes=None) diff --git a/royalimports_os/core/grid_events.py b/royalimports_os/core/grid_events.py index d0f335918b0fe590bfe089dab24b45009644e3ba..5f3e25a1f2e45e5004621641296c2d1b003c6397 100644 --- a/royalimports_os/core/grid_events.py +++ b/royalimports_os/core/grid_events.py @@ -807,6 +807,13 @@ def handle_one(event, ctx): if formula is None: return False field['formula'] = formula + if ftype == 'automation': + # C5-AUTOFIELD (wave 18): persist the validated config bag. No `return False` + # when absent — an unconfigured automation column is a legitimate intermediate + # state (create the column, then configure it in the gear). + auto = _ag2._clean_automation(raw.get('automation'), valid_keys) + if auto: + field['automation'] = auto fmt = _ag2._clean_format(raw.get('format'), ftype) if fmt: field['format'] = fmt @@ -1273,6 +1280,13 @@ def handle_one(event, ctx): admin or (field_by_key.get(key) or {}).get('createdBy') == uname): refused = True continue + # C5-AUTOFIELD (wave 18): an automation cell is MACHINE-WRITTEN. The client marks + # the type read-only (READONLY_CELL_TYPES) but that is courtesy — this is the wall. + # Without it the UI hides the editor while the API still takes a PATCH, which is + # exactly the shape a "read-only" type must not have. + if (field_by_key.get(key) or {}).get('type') == 'automation': + refused = True + continue clean = str(value)[:10000] if isinstance(value, str) and clean != value: # Truncated: the stored truth is shorter than the client's copy. (An diff --git a/royalimports_os/core/keychain.py b/royalimports_os/core/keychain.py new file mode 100644 index 0000000000000000000000000000000000000000..1f6eef4894ec27db25aef35f3aa33db93a9f0134 --- /dev/null +++ b/royalimports_os/core/keychain.py @@ -0,0 +1,182 @@ +"""core/keychain.py — per-tenant CREDENTIAL STORE (wave 18, contract C7 / ruling R3). + +An admin stores a data source's secrets (Royal's Odoo API key today; any tenant's sources +tomorrow) encrypted at rest in the TENANT's store bucket. The runtime posture is R3's +"live with env fallback": the connector layer asks `odoo_creds(rt)` FIRST and falls back to +the process environment (tenant #0's `.env` / Space secrets), so Royal keeps working with an +empty keychain and a new tenant needs no code to bring keys. The FULL cutover (env retired) +is staged for a later wave — R3, verbatim. + +CRYPTO: Fernet (AES128-CBC + HMAC, the `cryptography` package) under ONE platform key, +`AIOS_KEYCHAIN_KEY` (a `Fernet.generate_key()` value; a Space secret, never in the store). +No key ⇒ the keychain is LOCKED: metadata still lists (labels are not secrets), but nothing +decrypts and writes are refused — fail closed, never a plaintext fallback. + +SHAPE (bucket `keychain`, per-tenant via the runtime handle): + + {entries: {id: {id, label, type, enc, preview, created, createdBy}}} + +`enc` = Fernet token over the JSON fields dict. `preview` = a masked hint ("····1234") +computed ONCE at write from the entry's most secret-looking field — the ONLY part of a +secret that ever leaves this module through a route. `read_fields` exists for the CONNECTOR +LAYER; no route returns its output. +""" +import datetime as _dt +import json +import os +import secrets as _secrets + +KEY = 'keychain' +ENTRY_TYPES = {'odoo', 'generic'} +#: which stored field feeds the masked preview, per type (first present wins) +_PREVIEW_FIELDS = ('api_key', 'value', 'password', 'token') +MAX_ENTRIES = 40 +MAX_FIELD_LEN = 500 + + +class KeychainLocked(Exception): + """Raised when AIOS_KEYCHAIN_KEY is absent/wrong — callers answer 503, never {}.""" + + +def _fernet(): + key = (os.environ.get('AIOS_KEYCHAIN_KEY') or '').strip() + if not key: + raise KeychainLocked('AIOS_KEYCHAIN_KEY is not configured') + try: + from cryptography.fernet import Fernet + return Fernet(key.encode('ascii')) + except Exception as e: + raise KeychainLocked(f'keychain key unusable: {type(e).__name__}') + + +def unlocked(): + try: + _fernet() + return True + except KeychainLocked: + return False + + +def _bucket(rt): + return rt.get(KEY) or {} + + +def list_entries(rt): + """Metadata ONLY — never a decrypted field, never `enc` itself.""" + out = [] + for eid, e in sorted((_bucket(rt).get('entries') or {}).items()): + if not isinstance(e, dict): + continue + out.append({'id': eid, 'label': e.get('label') or eid, + 'type': e.get('type') or 'generic', + 'preview': e.get('preview') or '', + 'created': e.get('created') or '', + 'createdBy': e.get('createdBy') or ''}) + return out + + +def add_entry(rt, label, etype, fields, username): + """Encrypt + store. Returns the metadata row, or raises ValueError on shape problems and + KeychainLocked when there is no key (a secret must never be stored in the clear).""" + label = ' '.join(str(label or '').split())[:80] + etype = str(etype or '').strip().lower() + if not label: + raise ValueError('give the key a label') + if etype not in ENTRY_TYPES: + raise ValueError(f"type must be one of {', '.join(sorted(ENTRY_TYPES))}") + if not isinstance(fields, dict) or not fields: + raise ValueError('fields must be a non-empty object') + clean = {} + for k, v in list(fields.items())[:12]: + k = str(k).strip()[:40] + if k and isinstance(v, (str, int, float, bool)): + clean[k] = str(v)[:MAX_FIELD_LEN] + if not clean: + raise ValueError('no usable fields') + token = _fernet().encrypt(json.dumps(clean, ensure_ascii=False).encode('utf-8')) + secretish = next((clean[k] for k in _PREVIEW_FIELDS if clean.get(k)), '') + preview = ('····' + secretish[-4:]) if len(secretish) >= 4 else ('····' if secretish else '') + eid = f'k_{_secrets.token_hex(6)}' + row = {'id': eid, 'label': label, 'type': etype, 'enc': token.decode('ascii'), + 'preview': preview, + 'created': _dt.datetime.now().strftime('%Y-%m-%dT%H:%M:%S'), + 'createdBy': str(username or '')} + + def _up(cur): + entries = cur.setdefault('entries', {}) + if len(entries) >= MAX_ENTRIES: + raise ValueError(f'this keychain is at its {MAX_ENTRIES}-entry cap') + entries[eid] = row + return cur + + rt.update(KEY, _up, flush='sync') + return {'id': eid, 'label': label, 'type': etype, 'preview': preview, + 'created': row['created'], 'createdBy': row['createdBy']} + + +def delete_entry(rt, entry_id): + def _drop(cur): + (cur.get('entries') or {}).pop(str(entry_id), None) + return cur + rt.update(KEY, _drop, flush='sync') + return True + + +def read_fields(rt, entry_id): + """Decrypt ONE entry's fields — for the CONNECTOR LAYER only; no route returns this. + None when the entry does not exist; KeychainLocked when the key is absent/wrong (a wrong + key must be loud — silently empty creds would read as 'not configured').""" + e = (_bucket(rt).get('entries') or {}).get(str(entry_id)) + if not isinstance(e, dict) or not e.get('enc'): + return None + try: + raw = _fernet().decrypt(str(e['enc']).encode('ascii')) + except KeychainLocked: + raise + except Exception: + raise KeychainLocked('this entry does not decrypt under the configured key') + try: + data = json.loads(raw.decode('utf-8')) + return data if isinstance(data, dict) else None + except Exception: + return None + + +def odoo_creds(rt): + """R3's resolver seam: the FIRST odoo-type entry's fields, else None (the caller falls + back to the environment). Deterministic order = insertion-id sort, so 'first' is stable.""" + for row in list_entries(rt): + if row['type'] == 'odoo': + return read_fields(rt, row['id']) + return None + + +def test_entry(rt, entry_id, timeout=8): + """A cheap, READ-ONLY liveness probe. odoo: xmlrpc `common.version()` (no auth, no data); + generic: shape-only. Always answers {ok, message} — an exception here is a result, not a + crash.""" + try: + e = (_bucket(rt).get('entries') or {}).get(str(entry_id)) + if not isinstance(e, dict): + return {'ok': False, 'message': 'no such entry'} + fields = read_fields(rt, entry_id) or {} + if e.get('type') != 'odoo': + return {'ok': bool(fields), 'message': f'{len(fields)} field(s) stored'} + url = str(fields.get('url') or '').rstrip('/') + if not url.startswith(('http://', 'https://')): + return {'ok': False, 'message': 'url must start with http(s)://'} + import socket + import xmlrpc.client + old = socket.getdefaulttimeout() + socket.setdefaulttimeout(timeout) + try: + common = xmlrpc.client.ServerProxy(f'{url}/xmlrpc/2/common', allow_none=True) + ver = common.version() + finally: + socket.setdefaulttimeout(old) + sv = (ver or {}).get('server_version') if isinstance(ver, dict) else None + return {'ok': True, 'message': f'Odoo answered (server {sv or "unknown"})'} + except KeychainLocked as e: + return {'ok': False, 'message': str(e)} + except Exception as e: + return {'ok': False, 'message': f'{type(e).__name__}: {str(e)[:120]}'} diff --git a/royalimports_os/core/registry.py b/royalimports_os/core/registry.py index db431a8d5c327a4d682da240f827831d1904b506..5a291b417c3b517e80bb6d0087972ff711df89a0 100644 --- a/royalimports_os/core/registry.py +++ b/royalimports_os/core/registry.py @@ -177,6 +177,12 @@ REGISTRY = [ 'proof). No nav, no page. Wave 17 R8 ("I don\'t even know what it does — delete ' 'them") made that literal: `validate_only` takes it out of the account menu too, ' 'which is the last place it was still visible. The proof survives; the door does not.'}, + {'key': 'automation', 'label': 'Automation', 'brand': False, 'hq': True, 'validate': False, + 'nav': True, + 'note': 'Wave 18 (C-AUTONAV): the Automation surface — scheduled jobs that create and ' + 'refresh user databases (website scrape-to-DB, the Instagram field). React-only ' + 'surface (no PAGE_FUNCS entry, the no-new-Streamlit rule); admins hold it via ' + '"all", other users need the explicit grant — fail-closed default.'}, {'key': 'settings', 'label': 'Settings', 'brand': False, 'hq': True, 'validate': False, 'nav': False, # sidebar sentinel (account group) — owner IA 2026-07-12 'note': 'User scope settings: the Business Unit toggle (strict isolation) and the Data basis ' diff --git a/royalimports_os/core/store.py b/royalimports_os/core/store.py index 95a564b571f507d6655487ebecc1f4bf90421426..889e1d262afe8ef72cae9b69f2c9e2891c7d8c74 100644 --- a/royalimports_os/core/store.py +++ b/royalimports_os/core/store.py @@ -1,307 +1,369 @@ -"""Tiny JSON persistence on a PRIVATE Hugging Face Dataset repo — the platform's ONLY writable store -(Odoo stays strictly read-only). Holds the user registry, customer notes and per-user tags. - -Auth uses HF_TOKEN (a Space secret / .env value with write access to the royal-imports org). The -repo is created private on first write. Reads use a short in-process cache that writes refresh, so -within a running instance reads are consistent with writes; a fresh instance re-fetches the latest. -""" -import io -import os -import json -import threading -import time as _time -from pathlib import Path - -try: - from dotenv import load_dotenv - load_dotenv(Path(__file__).resolve().parents[1] / '.env') -except Exception: - pass - -from huggingface_hub import HfApi, hf_hub_download -from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError - -REPO = os.environ.get('OS_DATA_REPO', 'royal-imports/cfo-os-data') -_LOCK = threading.RLock() -_CACHE = {} -# --- async flush state (wave-7 W3, 2026-07-28) -------------------------------------------- -# One typed character in a Notes cell used to cost THREE synchronous network calls inside the -# component round-trip (strict re-download + create_repo + full re-upload = one hub commit per -# edit — measured seconds each, and a commit-budget hazard). update(..., flush='async') now -# applies the mutation to the in-process cache synchronously (read-your-writes: every reader -# already consults _CACHE first) and a background worker coalesces uploads. The restart-wipe -# protection is UNCHANGED where it matters: the FIRST update of a key in a fresh process still -# strict-reads (a transient read error aborts the write, never merges into {}); after that the -# cache we last wrote IS the latest known state, so re-downloading it per keystroke bought -# nothing but latency. Known, accepted: with a second concurrent writer (local QA against the -# shared store) the stale window widens from ~one round-trip to ~the flush gap. -_OWNED = {} # name -> True once _CACHE[name] reflects our own last accepted write -_DIRTY = {} # name -> cache is ahead of the hub -_FLUSHERS = {} # name -> live worker thread -_REPO_OK = [False] # create_repo(exist_ok=True) confirmed once per process -_FLUSH_DELAY = 2.0 # coalesce a burst of edits into one commit -_FLUSH_MIN_GAP = 20.0 # floor between commits of one key (the 256-commits/hr budget) -_LAST_FLUSH = {} # name -> monotonic time of the last completed upload - - -def _token(): - return os.environ.get('HF_TOKEN') or None - - -def available(): - """True when a token is configured — callers degrade gracefully (read-only UI) without one.""" - return bool(_token()) - - -def _download(name): - """Parse {name}.json into a dict. Returns {} ONLY when the file is genuinely absent. Any - other failure (network, auth, rate-limit, corrupt/partial JSON) RAISES — a transient read - error must never be mistaken for an empty store, or a caller could overwrite real data with - an empty dict (this is what wiped the user registry on restart).""" - try: - path = hf_hub_download(REPO, f'{name}.json', repo_type='dataset', token=_token(), - force_download=True) - with open(path, encoding='utf-8') as f: - return json.load(f) - except (EntryNotFoundError, RepositoryNotFoundError, FileNotFoundError): - return {} - - -def get(name, fresh=False): - """Load {name}.json as a dict. LENIENT (for display reads): on a transient fetch error, hand - back the last known-good cached value if we have one, else {}. Callers that MUTATE the store - must go through update()/_read_strict, which RAISE on such errors so they never clobber real - data with a phantom-empty read.""" - with _LOCK: - if not fresh and name in _CACHE: - return json.loads(json.dumps(_CACHE[name])) # hand back a copy - try: - data = _download(name) - except Exception as e: - try: # lazy import — core stays layer-clean - import harness.telemetry as _tel # noqa: PLC0415 - _tel.error(f'store:get:{name}', e, - fallback='cached' if name in _CACHE else 'empty') - except Exception: - pass - if name in _CACHE: - return json.loads(json.dumps(_CACHE[name])) - return {} - _CACHE[name] = data - return json.loads(json.dumps(data)) - - -def _read_strict(name): - """Like get(fresh=True) but RAISES on any transient read error ({} only for a genuinely - absent file). Read-modify-write callers use this so a failed read ABORTS the write instead - of merging changes into an empty dict and overwriting the store.""" - with _LOCK: - data = _download(name) - _CACHE[name] = data - return json.loads(json.dumps(data)) - - -def exists(name): - """True if {name}.json is confirmed present, False if confirmed absent, and True on ANY - uncertainty — so a caller that would seed or overwrite the store never clobbers a registry - we merely failed to reach.""" - try: - files = HfApi(token=_token()).list_repo_files(REPO, repo_type='dataset') - return f'{name}.json' in files - except RepositoryNotFoundError: - return False - except Exception: - return True - - -def _upload(name, data): - """The raw hub write. create_repo is confirmed ONCE per process — it was a full extra API - round-trip on every put(), pure latency after the first call ever succeeded.""" - api = HfApi(token=_token()) - if not _REPO_OK[0]: - api.create_repo(REPO, repo_type='dataset', private=True, exist_ok=True) - _REPO_OK[0] = True - buf = io.BytesIO(json.dumps(data, ensure_ascii=False, indent=2).encode('utf-8')) - api.upload_file(path_or_fileobj=buf, path_in_repo=f'{name}.json', repo_id=REPO, - repo_type='dataset', commit_message=f'update {name}') - - -def upload_bytes(path_in_repo, data, message=None): - """Persist RAW BYTES at an arbitrary path in the tenant dataset (wave-8 C5, documents). - - The rest of this module is JSON-per-key; a customer's attachment is neither JSON nor - per-key, so it gets its own path rather than being base64'd into somebody's blob. That - matters for a reason beyond tidiness: the workspace blob is READ ON EVERY PAGE RENDER, and - a few megabytes of base64 inside it would be paid on every keystroke by every user of that - table, not just by whoever opened the document. - - Bytes are never cached in-process: they are large, cold, and fetched one at a time on an - explicit user action. - """ - if not available(): - raise RuntimeError('No HF_TOKEN configured — persistence is unavailable.') - with _LOCK: - api = HfApi(token=_token()) - if not _REPO_OK[0]: - api.create_repo(REPO, repo_type='dataset', private=True, exist_ok=True) - _REPO_OK[0] = True - api.upload_file(path_or_fileobj=io.BytesIO(data), path_in_repo=path_in_repo, - repo_id=REPO, repo_type='dataset', - commit_message=message or f'add {path_in_repo}') - - -def download_bytes(path_in_repo): - """Raw bytes back, or None when absent/unreachable. - - None rather than an exception: a missing attachment must degrade to "that file is gone", - never to a broken page — the same contract every other read here follows. - """ - if not available(): - return None - try: - local = hf_hub_download(REPO, path_in_repo, repo_type='dataset', token=_token()) - return Path(local).read_bytes() - except (EntryNotFoundError, RepositoryNotFoundError): - return None - except Exception: - return None - - -def delete_path(path_in_repo): - """Remove a stored file. Absent is SUCCESS — deleting what is already gone is the goal.""" - if not available(): - return False - try: - HfApi(token=_token()).delete_file(path_in_repo=path_in_repo, repo_id=REPO, - repo_type='dataset', - commit_message=f'delete {path_in_repo}') - return True - except (EntryNotFoundError, RepositoryNotFoundError): - return True - except Exception: - return False - - -def put(name, data): - """Persist {name}.json (creates the private repo on first write). Updates the in-process cache.""" - if not available(): - raise RuntimeError('No HF_TOKEN configured — persistence is unavailable.') - with _LOCK: - _upload(name, data) - _CACHE[name] = json.loads(json.dumps(data)) - _OWNED[name] = True - _LAST_FLUSH[name] = _time.monotonic() - return _CACHE[name] - - -def _flush_worker(name): - """Coalescing uploader for one key. Runs while dirty; retries with backoff on failure — - the cache stays the truth and the dirty mark survives, so nothing is ever lost silently.""" - backoff = 2.0 - while True: - _time.sleep(_FLUSH_DELAY) - with _LOCK: - gap = _time.monotonic() - _LAST_FLUSH.get(name, 0.0) - if gap < _FLUSH_MIN_GAP: - wait = _FLUSH_MIN_GAP - gap - elif not _DIRTY.get(name): - _FLUSHERS.pop(name, None) - return - else: - _DIRTY[name] = False - snapshot = json.loads(json.dumps(_CACHE.get(name, {}))) - wait = None - if wait is not None: - _time.sleep(wait) - continue - try: - _upload(name, snapshot) - with _LOCK: - _LAST_FLUSH[name] = _time.monotonic() - backoff = 2.0 - except Exception as e: - with _LOCK: - _DIRTY[name] = True # keep it queued; cache is still the truth - try: - import harness.telemetry as _tel # noqa: PLC0415 - _tel.error(f'store:flush:{name}', e) - except Exception: - pass - _time.sleep(backoff) - backoff = min(backoff * 2, 60.0) - - -def _schedule_flush(name): - """Mark dirty + ensure exactly one live worker for the key. Caller holds _LOCK.""" - _DIRTY[name] = True - t = _FLUSHERS.get(name) - if t is not None and t.is_alive(): - return - t = threading.Thread(target=_flush_worker, args=(name,), daemon=True, - name=f'store-flush-{name}') - _FLUSHERS[name] = t - t.start() - - -def flush(name=None, timeout=30.0): - """Block until pending async writes for `name` (or ALL keys) reach the hub — QA gates and - shutdown hooks use this; the app itself never needs to.""" - deadline = _time.monotonic() + timeout - names = [name] if name else None - while _time.monotonic() < deadline: - with _LOCK: - pending = {k for k, v in _DIRTY.items() if v} | { - k for k, t in _FLUSHERS.items() if t.is_alive()} - if names is not None: - pending &= set(names) - if not pending: - return True - _time.sleep(0.2) - return False - - -def _flush_now_at_exit(): - """Process-exit safety net: push any dirty keys synchronously, bypassing the coalescing - gap — a Space restart must not eat the last seconds of the async window.""" - with _LOCK: - dirty = [k for k, v in _DIRTY.items() if v] - snaps = {k: json.loads(json.dumps(_CACHE.get(k, {}))) for k in dirty} - for k in dirty: - _DIRTY[k] = False - for k, d in snaps.items(): - try: - _upload(k, d) - except Exception: - pass # exiting anyway — nothing left to reschedule - - -import atexit # noqa: E402 (registered after the helpers it needs) -atexit.register(_flush_now_at_exit) - - -def update(name, fn, flush='sync'): - """Read-modify-write. STRICT first read (raises on a transient error rather than starting - from an empty dict — a network blip during 'add user' can never wipe the accounts), apply - fn(data)->data, persist. - - flush='sync' (default) = exactly the historical behavior: fresh strict read + blocking - upload. flush='async' (the table-workspace hot path, wave-7 W3) = the mutation applies to - the in-process cache and returns immediately; a coalescing worker commits to the hub. The - strict read still guards the FIRST async update of a key per process; after we own the - cache, it IS the latest known state and re-downloading it per edit was pure latency.""" - with _LOCK: - if flush == 'async' and _OWNED.get(name) and name in _CACHE: - data = json.loads(json.dumps(_CACHE[name])) - else: - data = _read_strict(name) - result = fn(data) - data = result if result is not None else data - if flush == 'async': - if not available(): - raise RuntimeError('No HF_TOKEN configured — persistence is unavailable.') - _CACHE[name] = json.loads(json.dumps(data)) - _OWNED[name] = True - _schedule_flush(name) - return data - put(name, data) - return data +"""Tiny JSON persistence on a PRIVATE Hugging Face Dataset repo — the platform's ONLY writable store +(Odoo stays strictly read-only). Holds the user registry, customer notes and per-user tags. + +Auth uses HF_TOKEN (a Space secret / .env value with write access to the royal-imports org). The +repo is created private on first write. Reads use a short in-process cache that writes refresh, so +within a running instance reads are consistent with writes; a fresh instance re-fetches the latest. + +WAVE 18 (C1-TENANT, R2): the store is now a CLASS, one instance per repo. The module-level +functions below delegate to the default instance (`OS_DATA_REPO`, tenant #0) — every existing +`import core.store as store` caller is byte-for-byte unaffected, which the gate battery proves. +`for_repo(repo_id)` hands back the bound instance for a tenant that owns its OWN dataset repo +(nurilab, gtmlab, …); `harness.runtime.TenantRuntime` binds it from the tenant record. Each +instance carries its own cache / dirty-marks / flush workers / commit-gap clock, so one tenant's +write burst can never starve another's flush window. +""" +import io +import os +import json +import threading +import time as _time +from pathlib import Path + +try: + from dotenv import load_dotenv + load_dotenv(Path(__file__).resolve().parents[1] / '.env') +except Exception: + pass + +from huggingface_hub import HfApi, hf_hub_download +from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError + +REPO = os.environ.get('OS_DATA_REPO', 'royal-imports/cfo-os-data') +_FLUSH_DELAY = 2.0 # coalesce a burst of edits into one commit +_FLUSH_MIN_GAP = 20.0 # floor between commits of one key (the 256-commits/hr budget) + + +def _token(): + return os.environ.get('HF_TOKEN') or None + + +class Store: + """One repo's persistence: JSON-per-key + raw byte paths, with the wave-7 async flush. + + Every method body is the pre-wave-18 module function, verbatim except globals→fields. + The behaviour contracts that matter are stated on each method and are UNCHANGED: + strict-read-guards-the-write, exists()-is-True-on-uncertainty, lenient display reads. + """ + + def __init__(self, repo): + self.repo = str(repo) + self._lock = threading.RLock() + self._cache = {} + # --- async flush state (wave-7 W3, 2026-07-28) ------------------------------------ + # One typed character in a Notes cell used to cost THREE synchronous network calls + # inside the component round-trip. update(..., flush='async') applies the mutation to + # the in-process cache synchronously (read-your-writes: every reader consults the + # cache first) and a background worker coalesces uploads. The restart-wipe protection + # is UNCHANGED where it matters: the FIRST update of a key in a fresh process still + # strict-reads. Known, accepted: with a second concurrent writer the stale window + # widens from ~one round-trip to ~the flush gap. + self._owned = {} # name -> True once cache reflects our own last accepted write + self._dirty = {} # name -> cache is ahead of the hub + self._flushers = {} # name -> live worker thread + self._repo_ok = False # create_repo(exist_ok=True) confirmed once per instance + self._last_flush = {} # name -> monotonic time of the last completed upload + + def available(self): + """True when a token is configured — callers degrade gracefully without one.""" + return bool(_token()) + + def _download(self, name): + """Parse {name}.json into a dict. Returns {} ONLY when the file is genuinely absent. + Any other failure (network, auth, rate-limit, corrupt JSON) RAISES — a transient read + error must never be mistaken for an empty store, or a caller could overwrite real data + with an empty dict (this is what wiped the user registry on restart).""" + try: + path = hf_hub_download(self.repo, f'{name}.json', repo_type='dataset', + token=_token(), force_download=True) + with open(path, encoding='utf-8') as f: + return json.load(f) + except (EntryNotFoundError, RepositoryNotFoundError, FileNotFoundError): + return {} + except ValueError as e: + # Wave 18 (R2, found by SESSION D): current huggingface_hub wraps a missing REPO in + # ValueError("Force download failed…") with the 404 as __cause__ — so a brand-new + # tenant repo's very first strict read raised here and aborted its very first write. + # A genuinely-absent repo is the same fact as a genuinely-absent file: {}. + cause = getattr(e, '__cause__', None) + if isinstance(cause, (EntryNotFoundError, RepositoryNotFoundError)): + return {} + raise + + def get(self, name, fresh=False): + """Load {name}.json as a dict. LENIENT (for display reads): on a transient fetch error, + hand back the last known-good cached value if we have one, else {}. Mutating callers go + through update()/_read_strict, which RAISE instead.""" + with self._lock: + if not fresh and name in self._cache: + return json.loads(json.dumps(self._cache[name])) # hand back a copy + try: + data = self._download(name) + except Exception as e: + try: # lazy import — core stays layer-clean + import harness.telemetry as _tel # noqa: PLC0415 + _tel.error(f'store:get:{name}', e, + fallback='cached' if name in self._cache else 'empty') + except Exception: + pass + if name in self._cache: + return json.loads(json.dumps(self._cache[name])) + return {} + self._cache[name] = data + return json.loads(json.dumps(data)) + + def _read_strict(self, name): + """Like get(fresh=True) but RAISES on any transient read error ({} only for a genuinely + absent file), so a failed read ABORTS a read-modify-write instead of merging into {}.""" + with self._lock: + data = self._download(name) + self._cache[name] = data + return json.loads(json.dumps(data)) + + def exists(self, name): + """True if {name}.json is confirmed present, False if confirmed absent, and True on ANY + uncertainty — a seeder must never clobber a registry we merely failed to reach.""" + try: + files = HfApi(token=_token()).list_repo_files(self.repo, repo_type='dataset') + return f'{name}.json' in files + except RepositoryNotFoundError: + return False + except Exception: + return True + + def _upload(self, name, data): + """The raw hub write. create_repo is confirmed ONCE per instance — it was a full extra + API round-trip on every put(), pure latency after the first success.""" + api = HfApi(token=_token()) + if not self._repo_ok: + api.create_repo(self.repo, repo_type='dataset', private=True, exist_ok=True) + self._repo_ok = True + buf = io.BytesIO(json.dumps(data, ensure_ascii=False, indent=2).encode('utf-8')) + api.upload_file(path_or_fileobj=buf, path_in_repo=f'{name}.json', repo_id=self.repo, + repo_type='dataset', commit_message=f'update {name}') + + def upload_bytes(self, path_in_repo, data, message=None): + """Persist RAW BYTES at an arbitrary path in the tenant dataset (wave-8 C5, documents). + Bytes are never cached in-process: large, cold, fetched on explicit user action.""" + if not self.available(): + raise RuntimeError('No HF_TOKEN configured — persistence is unavailable.') + with self._lock: + api = HfApi(token=_token()) + if not self._repo_ok: + api.create_repo(self.repo, repo_type='dataset', private=True, exist_ok=True) + self._repo_ok = True + api.upload_file(path_or_fileobj=io.BytesIO(data), path_in_repo=path_in_repo, + repo_id=self.repo, repo_type='dataset', + commit_message=message or f'add {path_in_repo}') + + def download_bytes(self, path_in_repo): + """Raw bytes back, or None when absent/unreachable — a missing attachment degrades to + "that file is gone", never to a broken page.""" + if not self.available(): + return None + try: + local = hf_hub_download(self.repo, path_in_repo, repo_type='dataset', + token=_token()) + return Path(local).read_bytes() + except (EntryNotFoundError, RepositoryNotFoundError): + return None + except Exception: + return None + + def delete_path(self, path_in_repo): + """Remove a stored file. Absent is SUCCESS — deleting what is already gone is the goal.""" + if not self.available(): + return False + try: + HfApi(token=_token()).delete_file(path_in_repo=path_in_repo, repo_id=self.repo, + repo_type='dataset', + commit_message=f'delete {path_in_repo}') + return True + except (EntryNotFoundError, RepositoryNotFoundError): + return True + except Exception: + return False + + def put(self, name, data): + """Persist {name}.json (creates the private repo on first write). Updates the cache.""" + if not self.available(): + raise RuntimeError('No HF_TOKEN configured — persistence is unavailable.') + with self._lock: + self._upload(name, data) + self._cache[name] = json.loads(json.dumps(data)) + self._owned[name] = True + self._last_flush[name] = _time.monotonic() + return self._cache[name] + + def _flush_worker(self, name): + """Coalescing uploader for one key. Runs while dirty; retries with backoff on failure — + the cache stays the truth and the dirty mark survives, so nothing is lost silently.""" + backoff = 2.0 + while True: + _time.sleep(_FLUSH_DELAY) + with self._lock: + gap = _time.monotonic() - self._last_flush.get(name, 0.0) + if gap < _FLUSH_MIN_GAP: + wait = _FLUSH_MIN_GAP - gap + elif not self._dirty.get(name): + self._flushers.pop(name, None) + return + else: + self._dirty[name] = False + snapshot = json.loads(json.dumps(self._cache.get(name, {}))) + wait = None + if wait is not None: + _time.sleep(wait) + continue + try: + self._upload(name, snapshot) + with self._lock: + self._last_flush[name] = _time.monotonic() + backoff = 2.0 + except Exception as e: + with self._lock: + self._dirty[name] = True # keep it queued; cache is still the truth + try: + import harness.telemetry as _tel # noqa: PLC0415 + _tel.error(f'store:flush:{name}', e) + except Exception: + pass + _time.sleep(backoff) + backoff = min(backoff * 2, 60.0) + + def _schedule_flush(self, name): + """Mark dirty + ensure exactly one live worker for the key. Caller holds the lock.""" + self._dirty[name] = True + t = self._flushers.get(name) + if t is not None and t.is_alive(): + return + t = threading.Thread(target=self._flush_worker, args=(name,), daemon=True, + name=f'store-flush-{self.repo}:{name}') + self._flushers[name] = t + t.start() + + def flush(self, name=None, timeout=30.0): + """Block until pending async writes for `name` (or ALL keys) reach the hub — QA gates + and shutdown hooks use this; the app itself never needs to.""" + deadline = _time.monotonic() + timeout + names = [name] if name else None + while _time.monotonic() < deadline: + with self._lock: + pending = {k for k, v in self._dirty.items() if v} | { + k for k, t in self._flushers.items() if t.is_alive()} + if names is not None: + pending &= set(names) + if not pending: + return True + _time.sleep(0.2) + return False + + def _flush_now_at_exit(self): + """Process-exit safety net: push any dirty keys synchronously, bypassing the coalescing + gap — a Space restart must not eat the last seconds of the async window.""" + with self._lock: + dirty = [k for k, v in self._dirty.items() if v] + snaps = {k: json.loads(json.dumps(self._cache.get(k, {}))) for k in dirty} + for k in dirty: + self._dirty[k] = False + for k, d in snaps.items(): + try: + self._upload(k, d) + except Exception: + pass # exiting anyway — nothing left to reschedule + + def update(self, name, fn, flush='sync'): + """Read-modify-write. STRICT first read (raises on a transient error rather than + starting from an empty dict), apply fn(data)->data, persist. + + flush='sync' (default) = fresh strict read + blocking upload. flush='async' (the + table-workspace hot path, wave-7 W3) = the mutation applies to the in-process cache and + returns immediately; a coalescing worker commits. The strict read still guards the + FIRST async update of a key per process.""" + with self._lock: + if flush == 'async' and self._owned.get(name) and name in self._cache: + data = json.loads(json.dumps(self._cache[name])) + else: + data = self._read_strict(name) + result = fn(data) + data = result if result is not None else data + if flush == 'async': + if not self.available(): + raise RuntimeError('No HF_TOKEN configured — persistence is unavailable.') + self._cache[name] = json.loads(json.dumps(data)) + self._owned[name] = True + self._schedule_flush(name) + return data + self.put(name, data) + return data + + +# ------------------------------------------------------------------- instances + module API +_INSTANCES = {} +_INSTANCES_LOCK = threading.RLock() + + +def for_repo(repo_id): + """The Store bound to `repo_id` — one instance per repo per process (each with its own + cache and flush state). The default instance IS `for_repo(REPO)`.""" + rid = str(repo_id or '').strip() or REPO + with _INSTANCES_LOCK: + inst = _INSTANCES.get(rid) + if inst is None: + inst = Store(rid) + _INSTANCES[rid] = inst + return inst + + +_DEFAULT = for_repo(REPO) + + +def available(): + return _DEFAULT.available() + + +def get(name, fresh=False): + return _DEFAULT.get(name, fresh=fresh) + + +def _read_strict(name): + return _DEFAULT._read_strict(name) + + +def exists(name): + return _DEFAULT.exists(name) + + +def upload_bytes(path_in_repo, data, message=None): + return _DEFAULT.upload_bytes(path_in_repo, data, message=message) + + +def download_bytes(path_in_repo): + return _DEFAULT.download_bytes(path_in_repo) + + +def delete_path(path_in_repo): + return _DEFAULT.delete_path(path_in_repo) + + +def put(name, data): + return _DEFAULT.put(name, data) + + +def flush(name=None, timeout=30.0): + return _DEFAULT.flush(name=name, timeout=timeout) + + +def update(name, fn, flush='sync'): + return _DEFAULT.update(name, fn, flush=flush) + + +def _flush_all_at_exit(): + with _INSTANCES_LOCK: + instances = list(_INSTANCES.values()) + for inst in instances: + inst._flush_now_at_exit() + + +import atexit # noqa: E402 (registered after the class it needs) +atexit.register(_flush_all_at_exit) diff --git a/royalimports_os/core/table_store.py b/royalimports_os/core/table_store.py index d8400b03e493755608b232734dcfb9d6cc21c699..99c5467f4ddf8af7a01a66082c4f9860b6db826d 100644 --- a/royalimports_os/core/table_store.py +++ b/royalimports_os/core/table_store.py @@ -100,16 +100,24 @@ def _unique_name(wanted, existing, *, fallback='Untitled', max_len=120): class TableStore: - """The six store operations for one table object's workspace, closed over its store key.""" + """The six store operations for one table object's workspace, closed over its store key. - def __init__(self, table_key): + `st` (wave 18, C3-UT) is the STORE HANDLE — anything exposing `get(name)` / + `update(name, fn, flush=)`. Default = `core.store` (tenant #0, every existing caller, + zero behaviour change). The API passes the session's `TenantRuntime`, whose accessors + apply the tenant prefix / repo binding — which is what makes a user table created by a + Nurilab admin land in Nurilab's store instead of Royal's. + """ + + def __init__(self, table_key, st=None): self.table_key = table_key + self._st = st if st is not None else store # ---------------------------------------------------------------- read def workspace(self, username, consume_corrections=True): """One user's durable workspace: always the full three-strata shape.""" try: - data = store.get(self.table_key) or {} + data = self._st.get(self.table_key) or {} ws = data.get(username, {}) or {} # A collision acknowledgement is protocol state, not part of a field definition. # Consume it with the first fresh workspace payload after the correcting write, @@ -128,7 +136,7 @@ class TableStore: current_ws.pop('fieldCorrections', None) return current - data = store.update(self.table_key, _take, flush='async') + data = self._st.update(self.table_key, _take, flush='async') ws = (data or {}).get(username, {}) or {} except Exception: ws = {} @@ -189,7 +197,7 @@ class TableStore: # the historical synchronous hub commit cost seconds per edit. The mutation applies to # the in-process cache (read-your-writes for every subsequent render); the hub write # coalesces in the background. Registry/auth writes elsewhere stay flush='sync'. - return store.update(self.table_key, _up, flush='async') + return self._st.update(self.table_key, _up, flush='async') def save_active_view(self, username, view_id): """Remember which view this user last opened (owner item 3, 2026-07-31). @@ -254,7 +262,7 @@ class TableStore: personal view by forgetting to filter. """ try: - bucket = ((store.get(self.table_key) or {}).get(SHARED_KEY) or {}).get('views') or {} + bucket = ((self._st.get(self.table_key) or {}).get(SHARED_KEY) or {}).get('views') or {} except Exception: return {} return {vid: dict(v) for vid, v in bucket.items() @@ -265,7 +273,7 @@ class TableStore: caller must know a view exists and who owns it before it can decide whether the actor may touch it. Never hand the result to a renderer without checking `_may_see`.""" try: - return ((store.get(self.table_key) or {}).get(SHARED_KEY) or {} + return ((self._st.get(self.table_key) or {}).get(SHARED_KEY) or {} ).get('views', {}).get(str(view_id)) except Exception: return None @@ -319,7 +327,7 @@ class TableStore: (data.get(SHARED_KEY, {}).get('views') or {}).pop(view_id, None) return data - store.update(self.table_key, _up, flush='async') + self._st.update(self.table_key, _up, flush='async') return dict(accepted) def delete_view(self, username, view_id): @@ -335,7 +343,7 @@ class TableStore: (data.get(SHARED_KEY, {}).get('views') or {}).pop(vid, None) return data - store.update(self.table_key, _up, flush='async') + self._st.update(self.table_key, _up, flush='async') def save_field(self, username, field, reserved_names=(), correction_id=None): """Persist a column note or a user-created (custom_/measure_) field definition.""" @@ -467,5 +475,5 @@ class TableStore: self._update(username, _patch) -def make(table_key): - return TableStore(table_key) +def make(table_key, st=None): + return TableStore(table_key, st=st) diff --git a/royalimports_os/core/user_tables.py b/royalimports_os/core/user_tables.py index 499c6b48863be013518092d5d93827325ce80331..ea38028b99c84f617b2f7d6ce1dbd7df4d9a187e 100644 --- a/royalimports_os/core/user_tables.py +++ b/royalimports_os/core/user_tables.py @@ -20,9 +20,16 @@ SHAPE (one store key, `user_tables`): which is the same overlay shape `TableStore` already uses, so the grid's write path needs no new storage concept. -⚠ ROW WRITES ARE ONLY EVER LEGAL HERE. An Odoo-sourced table is READ-ONLY at the source and -`_cl_handle_one`'s row_add / row_delete refuse unless `is_user_table(key)` — a user must not be -able to invent a customer in Odoo by typing into a grid. +⚠ ROW WRITES ARE ONLY EVER LEGAL HERE. An Odoo-sourced table is READ-ONLY at the source and the +row endpoints refuse unless `is_user_table(key)` — a user must not be able to invent a customer +in Odoo by typing into a grid. (Wave 18 note: the events seam has NO row event types; row +add/delete are REST endpoints on `aios-web/api/routes_tables.py`, and this predicate is their +wall.) + +WAVE 18 (C3-UT): every function takes an optional `st` STORE HANDLE — anything exposing +`get(name)` / `update(name, fn, flush=)` / `exists(name)`. Default = `core.store` (tenant #0, +the Streamlit host, unchanged). The API passes the session's `TenantRuntime`, whose accessors +apply the tenant prefix / repo binding, so a Nurilab table lands in Nurilab's store. """ import datetime as _dt import re @@ -33,36 +40,79 @@ STORE_KEY = 'user_tables' MAX_TABLES = 40 MAX_LABEL = 60 MAX_ROWS = 5000 +MAX_FIELDS = 60 #: the badge the nav paints for a table with no connector behind it BLANK_SOURCE = 'Blank' +#: automation-created tables carry their maker instead (wave 18 C4-AUTO) +AUTOMATION_SOURCE = 'Automation' #: every user table's key is prefixed, so it can never collide with a registry module key KEY_PREFIX = 'ut_' +#: The field types a user table may declare. ⚠ Kept a SUBSET of +#: `aios_grid.CUSTOM_FIELD_TYPES` (gated in verify_api's W18-UT section) — minus the two +#: machine-written kinds (`formula` computes client-side over a workspace stratum; a base +#: column of that type would have no author). Local literal rather than an aios_grid import so +#: this module stays dependency-light for the API's boot path. +UT_FIELD_TYPES = {'text', 'select', 'multiselect', 'user', 'int', 'currency', 'pct', 'date', + 'checkbox', 'phone', 'email', 'url', 'rating'} + + +def _st(st): + return st if st is not None else store + def _slug(label): s = re.sub(r'[^a-z0-9]+', '_', str(label or '').strip().lower()).strip('_') return (s or 'table')[:40] -def all_tables(): +def clean_fields(raw): + """Validate a caller-supplied field list into the stored shape — refuse junk, never store + it. Returns a list of `{key,label,type,source}` dicts (source is always 'overlay': every + base column of a user table is user-editable by construction), or None when nothing + survives. Unknown types are DROPPED, not coerced — a column silently retyped is a lie.""" + out, seen = [], set() + for f in (raw or [])[:MAX_FIELDS]: + if not isinstance(f, dict): + continue + label = ' '.join(str(f.get('label') or f.get('key') or '').split())[:80] + key = re.sub(r'[^a-z0-9_]+', '_', str(f.get('key') or _slug(label)).strip().lower()) + key = key.strip('_')[:60] + ftype = str(f.get('type') or 'text').strip().lower() + if not key or key in seen or ftype not in UT_FIELD_TYPES or not label: + continue + seen.add(key) + entry = {'key': key, 'label': label, 'type': ftype, 'source': 'overlay'} + if ftype in ('select', 'multiselect'): + opts = [' '.join(str(o).split())[:60] for o in (f.get('options') or []) + if str(o).strip()][:50] + if opts: + entry['options'] = opts + if f.get('default') is True: + entry['default'] = True + out.append(entry) + return out or None + + +def all_tables(st=None): """{key: definition} — every user-created table in this tenant.""" try: - return dict(store.get(STORE_KEY) or {}) + return dict(_st(st).get(STORE_KEY) or {}) except Exception: return {} -def get(table_key): - return all_tables().get(str(table_key)) +def get(table_key, st=None): + return all_tables(st).get(str(table_key)) -def is_user_table(table_key): +def is_user_table(table_key, st=None): """THE permission predicate for row writes. Cheap and total: a key that is not in this store is not a user table, so it cannot accept invented rows.""" - return str(table_key or '').startswith(KEY_PREFIX) and get(table_key) is not None + return str(table_key or '').startswith(KEY_PREFIX) and get(table_key, st) is not None -def create(label, username, fields=None): +def create(label, username, fields=None, source=None, st=None): """Create a blank table. Returns its key, or None if refused. Refuses rather than raises on the ordinary conditions (no name, duplicate, cap reached) — @@ -71,7 +121,7 @@ def create(label, username, fields=None): label = str(label or '').strip()[:MAX_LABEL] if not label: return None - existing = all_tables() + existing = all_tables(st) if len(existing) >= MAX_TABLES: return None key = KEY_PREFIX + _slug(label) @@ -88,11 +138,11 @@ def create(label, username, fields=None): defn = { 'key': key, 'label': label, - 'source': BLANK_SOURCE, + 'source': (source if source in (BLANK_SOURCE, AUTOMATION_SOURCE) else BLANK_SOURCE), 'createdBy': username, 'created': _dt.datetime.now().strftime('%Y-%m-%dT%H:%M:%S'), - 'fields': list(fields or [{'key': 'name', 'label': 'Name', 'type': 'text', - 'source': 'overlay', 'default': True}]), + 'fields': clean_fields(fields) or [{'key': 'name', 'label': 'Name', 'type': 'text', + 'source': 'overlay', 'default': True}], 'rows': {}, } @@ -100,28 +150,45 @@ def create(label, username, fields=None): cur[key] = defn return cur - store.update(STORE_KEY, _add, flush='sync') # a creation is not a hot path; commit it + _st(st).update(STORE_KEY, _add, flush='sync') # a creation is not a hot path; commit it return key -def delete(table_key): +def delete(table_key, st=None): def _drop(cur): cur.pop(str(table_key), None) return cur - store.update(STORE_KEY, _drop, flush='sync') + _st(st).update(STORE_KEY, _drop, flush='sync') + + +def set_fields(table_key, fields, st=None): + """Replace a table's base-field contract (wave 18 — the automation engine grows tables it + creates). Cleaned with the same validator as `create`; refuses to leave a table fieldless.""" + clean = clean_fields(fields) + if not clean or not is_user_table(table_key, st): + return False + + def _set(cur): + t = cur.get(str(table_key)) + if t is not None: + t['fields'] = clean + return cur + + _st(st).update(STORE_KEY, _set, flush='sync') + return True -def add_row(table_key, values=None, username=None): +def add_row(table_key, values=None, username=None, st=None): """Append one row. Returns the new row id, or None if refused.""" - if not is_user_table(table_key): + if not is_user_table(table_key, st): return None # ⚠ never on a connector-backed table - defn = get(table_key) or {} + defn = get(table_key, st) or {} rows = defn.get('rows') or {} if len(rows) >= MAX_ROWS: return None rid = str(max((int(r) for r in rows if str(r).isdigit()), default=0) + 1) valid = {f['key'] for f in (defn.get('fields') or [])} - clean = {k: v for k, v in (values or {}).items() if k in valid} + clean = {k: str(v) for k, v in (values or {}).items() if k in valid} def _add(cur): t = cur.get(str(table_key)) @@ -129,12 +196,57 @@ def add_row(table_key, values=None, username=None): t.setdefault('rows', {})[rid] = clean return cur - store.update(STORE_KEY, _add, flush='async') + _st(st).update(STORE_KEY, _add, flush='async') return rid -def delete_row(table_key, row_id): - if not is_user_table(table_key): +def upsert_rows(table_key, rows_by_key, key_field, username=None, st=None): + """Bulk UPSERT for the automation engine (wave 18 C4-AUTO): match on `key_field`'s value, + update matched rows, insert the rest. Returns `{'updated': n, 'inserted': n, 'orphans': n}` + where orphans = existing rows whose key value did not appear this run — COUNTED, never + deleted (the contract's no-silent-delete rule). Refuses on a non-user table.""" + if not is_user_table(table_key, st): + return None + defn = get(table_key, st) or {} + valid = {f['key'] for f in (defn.get('fields') or [])} + if key_field not in valid: + return None + incoming = {} + for kv, vals in (rows_by_key or {}).items(): + kv = str(kv).strip() + if kv: + incoming[kv] = {k: str(v) for k, v in (vals or {}).items() if k in valid} + counts = {'updated': 0, 'inserted': 0, 'orphans': 0} + + def _apply(cur): + t = cur.get(str(table_key)) + if t is None: + return cur + rows = t.setdefault('rows', {}) + by_val = {} + for rid, row in rows.items(): + v = str((row or {}).get(key_field) or '').strip() + if v and v not in by_val: + by_val[v] = rid + next_id = max((int(r) for r in rows if str(r).isdigit()), default=0) + for kv, vals in incoming.items(): + rid = by_val.get(kv) + if rid is not None: + rows[rid].update(vals) + counts['updated'] += 1 + elif len(rows) < MAX_ROWS: + next_id += 1 + rows[str(next_id)] = vals + counts['inserted'] += 1 + counts['orphans'] = sum(1 for v in by_val if v not in incoming) + return cur + + _st(st).update(STORE_KEY, _apply, flush='sync') + return counts + + +def delete_row(table_key, row_id, st=None): + if not is_user_table(table_key, st): return False def _drop(cur): @@ -143,11 +255,11 @@ def delete_row(table_key, row_id): (t.get('rows') or {}).pop(str(row_id), None) return cur - store.update(STORE_KEY, _drop, flush='async') + _st(st).update(STORE_KEY, _drop, flush='async') return True -def may_open(table_key, viewer, is_admin=False): +def may_open(table_key, viewer, is_admin=False, st=None): """FAIL-CLOSED visibility: the creator, or an admin. Nothing else. A user table cannot be gated by `allowed_modules` — a module grant written last month cannot @@ -157,21 +269,22 @@ def may_open(table_key, viewer, is_admin=False): Sharing a user table with named colleagues is a follow-on, and it should reuse the shared- VIEW vocabulary rather than inventing a second one. """ - t = get(table_key) + t = get(table_key, st) if not t: return False return bool(is_admin) or t.get('createdBy') == viewer -def nav_entries(viewer=None, is_admin=False): +def nav_entries(viewer=None, is_admin=False, st=None): """Registry-SHAPED dicts so the nav can render user tables beside real modules with no special-casing: the same keys the flat nav reads (`key`, `label`, `source`). Filtered by `may_open`, so the nav cannot offer a row the dispatcher would refuse. """ out = [] - for key, t in sorted(all_tables().items(), key=lambda kv: (kv[1].get('label') or '').lower()): - if viewer is not None and not may_open(key, viewer, is_admin): + for key, t in sorted(all_tables(st).items(), + key=lambda kv: (kv[1].get('label') or '').lower()): + if viewer is not None and not may_open(key, viewer, is_admin, st=st): continue out.append({'key': key, 'label': t.get('label') or key, 'source': t.get('source') or BLANK_SOURCE, diff --git a/royalimports_os/core/users.py b/royalimports_os/core/users.py index f92eb4c724ef4179abd89c8e676ce3a533c5a421..00ba00f8bf24cd628bc1b707e1de231eba923b3c 100644 --- a/royalimports_os/core/users.py +++ b/royalimports_os/core/users.py @@ -27,11 +27,15 @@ def _hash(pw, salt): def _record(pw, name, role, bus, active=True, modules='all', agent=None, email=None, - perms=None): + perms=None, tenant='royal-imports'): salt = secrets.token_hex(16) rec = {'salt': salt, 'hash': _hash(pw, salt), 'name': name, 'role': role, 'bus': bus, 'active': active, 'modules': modules, - 'agent': agent or None, 'email': email or None} + 'agent': agent or None, 'email': email or None, + # Wave 18 (C1-TENANT, R1): the account's COMPANY. Absent == 'royal-imports' on every + # pre-wave record — no migration. Login binds the session to THIS value; the posted + # tenant field can hint but never override it. + 'tenant': str(tenant or 'royal-imports').strip().lower()} if perms is not None: # Wave 15 C-PERM. A record written WITH perms is migrated by construction — the marker # and the block are set together, here, so no writer can create one without the other. @@ -78,6 +82,9 @@ def _public(username, u): 'role': u.get('role', 'user'), 'bus': u.get('bus', 'all'), 'modules': u.get('modules', 'all'), 'agent': u.get('agent'), 'email': u.get('email'), + # Wave 18 (C1-TENANT): the session's tenant binding travels on the projection or it + # does not travel — the same rule the perms block states below. + 'tenant': str(u.get('tenant') or 'royal-imports').strip().lower(), # Wave 14 C-AVATAR: the profile photo is public-safe by definition (it is served # to every grid session via the workspace map); without it here the API session's # user record silently drops it and /me can never show your own photo. @@ -143,6 +150,14 @@ def verify(username, pw): except Exception: reg = {} u = reg.get(username) + if u is None and '@' in username: + # Wave 18 (R1): the login box takes a username OR an email — admin@nurilab.id signs in + # without knowing the slug an admin chose. First case-insensitive email match wins; + # ambiguity is an admin data problem, not a login feature. + for k, r in reg.items(): + if isinstance(r, dict) and str(r.get('email') or '').strip().lower() == username: + username, u = k, r + break if u and u.get('active', True) and hmac.compare_digest(_hash(pw, u['salt']), u['hash']): return _public(username, u) # emergency master: admin + APP_PASSWORD always works (covers first run / store outage) @@ -165,7 +180,7 @@ def verify(username, pw): def create_user(username, pw, name, role='user', bus='all', modules='all', - agent=None, email=None): + agent=None, email=None, tenant=None): """Create — or, from app.py's dialog, OVERWRITE — an account. ⛔ X3: OVERWRITING AN ACCOUNT MUST NOT RESURRECT ITS OLD SESSIONS. `_record()` builds a fresh @@ -185,7 +200,10 @@ def create_user(username, pw, name, role='user', bus='all', modules='all', def _add(reg): prior = reg.get(username) or {} rec = _record(pw, name or username, role, bus, modules=modules, - agent=agent, email=email) + agent=agent, email=email, + # An overwrite that names no tenant KEEPS the account's company — a + # rename must never quietly move a user between tenants. + tenant=(tenant or prior.get('tenant') or 'royal-imports')) if prior: rec['epoch'] = int(prior.get('epoch') or 0) + 1 reg[username] = rec @@ -273,22 +291,29 @@ def allowed_bus_labels(user): return (['All'] + labels) if len(labels) > 1 else labels -def assignable_people(): +def assignable_people(tenant=None): """Display names for `user`-typed overlay columns — the tenant's ACTIVE accounts. Moved from app.py (2026-07-31) so both hosts serve the same choices. Resolved on every call rather than persisted with the column: a snapshot would keep offering people who have left and never offer people who joined. Deactivated accounts are excluded; a value already stored on a row is untouched — history should still say who owned something. + + Wave 18 (C1-TENANT): pass `tenant` to scope the choices to ONE company — the user registry + is a global control-plane bucket, and a Nurilab picker offering Royal's staff is a + cross-tenant name leak. None = unscoped (the Streamlit host, tenant #0's process). """ try: reg = registry() or {} except Exception: return [] + want = str(tenant or '').strip().lower() out = [] for username, u in reg.items(): if not isinstance(u, dict) or u.get('active') is False: continue + if want and str(u.get('tenant') or 'royal-imports').strip().lower() != want: + continue out.append(str(u.get('name') or username)) return sorted(set(out)) @@ -311,20 +336,24 @@ def set_avatar(username, data_url): store.update('users', _set) -def avatar_map(): +def avatar_map(tenant=None): """{display name -> avatar data URL} for ACTIVE accounts with a photo — the companion of `assignable_people()`, keyed by the SAME vocabulary: a `user` cell stores the display name, so the display name is the only join a renderer has. Two active accounts sharing a display name share one option; the first WITH a photo wins the key rather than a coin - flip deciding whether the option has a face.""" + flip deciding whether the option has a face. `tenant` scopes it exactly as + `assignable_people(tenant)` does, and for the same leak.""" try: reg = registry() or {} except Exception: return {} + want = str(tenant or '').strip().lower() out = {} for username, u in sorted(reg.items()): if not isinstance(u, dict) or u.get('active') is False: continue + if want and str(u.get('tenant') or 'royal-imports').strip().lower() != want: + continue av = u.get('avatar') nm = str(u.get('name') or username) if av and nm not in out: diff --git a/royalimports_os/harness/runtime.py b/royalimports_os/harness/runtime.py index e5325ec1b9108a00af2e33b91638f82978e992bb..d46cfce4cc78ba054e571864a6f0571687905816 100644 --- a/royalimports_os/harness/runtime.py +++ b/royalimports_os/harness/runtime.py @@ -96,24 +96,34 @@ class TenantRuntime: return _ds.path_for(self.key) # ---------------------------------------------------------------- the store handle + #: Wave 18 (C1-TENANT, R2): a tenant that OWNS its dataset repo carries its bound Store + #: instance here (namespace stays EMPTY — a whole repo needs no prefix). None = the shared + #: default repo through the MODULE functions, which is what keeps the gates' fake-store + #: installation effective (the fake patches module attributes, and royal-imports + the + #: prefix tenants resolve through exactly those). + store_handle: object = None + + def _store(self): + return self.store_handle if self.store_handle is not None else store + def store_key(self, name): """Namespace a product-data key for this tenant. The ONE place the prefix is applied.""" return f"{self.store_namespace}{name}" if self.store_namespace else str(name) def get(self, name, fresh=False): - return store.get(self.store_key(name), fresh=fresh) + return self._store().get(self.store_key(name), fresh=fresh) def put(self, name, data): - return store.put(self.store_key(name), data) + return self._store().put(self.store_key(name), data) def update(self, name, fn, flush="sync"): - return store.update(self.store_key(name), fn, flush=flush) + return self._store().update(self.store_key(name), fn, flush=flush) def exists(self, name): - return store.exists(self.store_key(name)) + return self._store().exists(self.store_key(name)) def available(self): - return store.available() + return self._store().available() def assert_datastore_matches(self): """RAISE if the process-wide DuckDB file is not this tenant's. @@ -140,7 +150,39 @@ def register(key, builder): def known_tenants(): - return sorted(_BUILDERS) + keys = set(_BUILDERS) + try: + keys |= set(_tenant_records()) + except Exception: + pass + return sorted(keys) + + +#: Wave 18 (C1-TENANT) — the CONTROL-PLANE bucket: tenants provisioned at runtime rather than +#: compiled in. Lives in the DEFAULT store (tenant #0's repo) deliberately: it answers "which +#: tenants exist", which is a platform fact, not any one tenant's data. +TENANTS_KEY = "tenants" + + +def _tenant_records(): + """{slug: record} from the control-plane bucket. {} on any failure — an unreachable bucket + must degrade to "only the compiled-in tenants exist", never to an exception at login.""" + try: + recs = store.get(TENANTS_KEY) or {} + return {str(k).strip().lower(): v for k, v in recs.items() if isinstance(v, dict)} + except Exception: + return {} + + +def _builder_from_record(key, rec): + """A Tenant for a bucket-provisioned client: no sources yet (connectors arrive via the + Keychain flow), config carries the platform fields the request path reads.""" + def _build(): + from harness.base import Tenant + return Tenant(key=key, name=str(rec.get("name") or key), + config={"modules": rec.get("modules", []), + "store_repo": rec.get("store_repo") or None}) + return _build def get_runtime(tenant_key): @@ -159,8 +201,14 @@ def get_runtime(tenant_key): _CACHE.move_to_end(key) # LRU: touch on read return rt builder = _BUILDERS.get(key) - if builder is None: + # Wave 18 (C1-TENANT): a slug the compiled registry does not know may be a PROVISIONED + # tenant — consult the control-plane bucket before failing closed. A suspended record is + # the same KeyError as an unknown one: "which tenants exist" is not this caller's question. + if builder is None: + rec = _tenant_records().get(key) + if not rec or rec.get("status", "active") != "active": raise KeyError(key) + builder = _builder_from_record(key, rec) # Built OUTSIDE the lock: a builder may do real work (a connector handshake), and holding the # registry lock through it would serialise every other tenant's requests behind it. tenant = builder() @@ -169,8 +217,14 @@ def get_runtime(tenant_key): if existing is not None: # another thread won the race — keep ONE runtime _CACHE.move_to_end(key) return existing - rt = TenantRuntime(key=key, tenant=tenant, - store_namespace="" if key == "royal-imports" else f"t/{key}/") + # R2: a tenant with its OWN repo gets a bound Store instance and an EMPTY prefix (the + # repo boundary is the namespace); everyone else keeps the t// prefix in the + # shared repo. Tenant #0 keeps both defaults — empty prefix, shared repo. + repo = (getattr(tenant, "config", {}) or {}).get("store_repo") + rt = TenantRuntime( + key=key, tenant=tenant, + store_namespace=("" if (key == "royal-imports" or repo) else f"t/{key}/"), + store_handle=(store.for_repo(repo) if repo else None)) _CACHE[key] = rt while len(_CACHE) > _MAX_RUNTIMES: _CACHE.popitem(last=False) # evict least recently used diff --git a/web/dist-embed/index.html b/web/dist-embed/index.html index c7f386e60483434c5fbd6ef6c4fd9c4d6194658c..ef4adb4a65497ddd57219b3ae7ab26e1b289345b 100644 --- a/web/dist-embed/index.html +++ b/web/dist-embed/index.html @@ -9,9 +9,9 @@ `),a=r.stack.split(` `),o=i.length-1,s=a.length-1;1<=o&&0<=s&&i[o]!==a[s];)s--;for(;1<=o&&0<=s;o--,s--)if(i[o]!==a[s]){if(o!==1||s!==1)do if(o--,s--,0>s||i[o]!==a[s]){var c=` `+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(``)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{oe=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?ae(e):``}function ce(e){switch(e.tag){case 5:return ae(e.type);case 16:return ae(`Lazy`);case 13:return ae(`Suspense`);case 19:return ae(`SuspenseList`);case 0:case 2:case 15:return e=se(e.type,!1),e;case 11:return e=se(e.type.render,!1),e;case 1:return e=se(e.type,!0),e;default:return``}}function le(e){if(e==null)return null;if(typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case E:return`Fragment`;case T:return`Portal`;case O:return`Profiler`;case D:return`StrictMode`;case M:return`Suspense`;case ee:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case A:return(e.displayName||`Context`)+`.Consumer`;case k:return(e._context.displayName||`Context`)+`.Provider`;case j:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case N:return t=e.displayName||null,t===null?le(e.type)||`Memo`:t;case te:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}function ue(e){var t=e.type;switch(e.tag){case 24:return`Cache`;case 9:return(t.displayName||`Context`)+`.Consumer`;case 10:return(t._context.displayName||`Context`)+`.Provider`;case 18:return`DehydratedFragment`;case 11:return e=t.render,e=e.displayName||e.name||``,t.displayName||(e===``?`ForwardRef`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return le(t);case 8:return t===D?`StrictMode`:`Mode`;case 22:return`Offscreen`;case 12:return`Profiler`;case 21:return`Scope`;case 13:return`Suspense`;case 19:return`SuspenseList`;case 25:return`TracingMarker`;case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t==`function`)return t.displayName||t.name||null;if(typeof t==`string`)return t}return null}function de(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function fe(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function pe(e){var t=fe(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function me(e){e._valueTracker||=pe(e)}function he(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=fe(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function ge(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function _e(e,t){var n=t.checked;return F({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ve(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=de(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function ye(e,t){t=t.checked,t!=null&&S(e,`checked`,t,!1)}function be(e,t){ye(e,t);var n=de(t.value),r=t.type;if(n!=null)r===`number`?(n===0&&e.value===``||e.value!=n)&&(e.value=``+n):e.value!==``+n&&(e.value=``+n);else if(r===`submit`||r===`reset`){e.removeAttribute(`value`);return}t.hasOwnProperty(`value`)?Se(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&Se(e,t.type,de(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function xe(e,t,n){if(t.hasOwnProperty(`value`)||t.hasOwnProperty(`defaultValue`)){var r=t.type;if(!(r!==`submit`&&r!==`reset`||t.value!==void 0&&t.value!==null))return;t=``+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==``&&(e.name=``),e.defaultChecked=!!e._wrapperState.initialChecked,n!==``&&(e.name=n)}function Se(e,t,n){(t!==`number`||ge(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var Ce=Array.isArray;function we(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ne(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Fe=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(Pe).forEach(function(e){Fe.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Pe[t]=Pe[e]})});function Ie(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||Pe.hasOwnProperty(e)&&Pe[e]?(``+t).trim():t+`px`}function Le(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=Ie(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Re=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ze(e,t){if(t){if(Re[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(r(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(r(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(r(62))}}function Be(e,t){if(e.indexOf(`-`)===-1)return typeof t.is==`string`;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Ve=null;function He(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ue=null,We=null,Ge=null;function Ke(e){if(e=Ui(e)){if(typeof Ue!=`function`)throw Error(r(280));var t=e.stateNode;t&&(t=Gi(t),Ue(e.stateNode,e.type,t))}}function qe(e){We?Ge?Ge.push(e):Ge=[e]:We=e}function Je(){if(We){var e=We,t=Ge;if(Ge=We=null,Ke(e),t)for(e=0;e>>=0,e===0?32:31-(At(e)/jt|0)|0}var Nt=64,Pt=4194304;function Ft(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function It(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=Ft(a))):r=Ft(s)}else o=n&~i,o===0?a!==0&&(r=Ft(a)):r=Ft(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Ht(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-kt(t),e[t]=n}function Ut(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=nr),ar=` `,or=!1;function sr(e,t){switch(e){case`keyup`:return er.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function cr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var lr=!1;function ur(e,t){switch(e){case`compositionend`:return cr(t);case`keypress`:return t.which===32?(or=!0,ar):null;case`textInput`:return e=t.data,e===ar&&or?null:e;default:return null}}function dr(e,t){if(lr)return e===`compositionend`||!tr&&sr(e,t)?(e=Tn(),wn=Cn=Sn=null,lr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Nr(n)}}function Fr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Fr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ir(){for(var e=window,t=ge();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=ge(e.document)}return t}function Lr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}function Rr(e){var t=Ir(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Fr(n.ownerDocument.documentElement,n)){if(r!==null&&Lr(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),`selectionStart`in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=Pr(n,a);var o=Pr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus==`function`&&n.focus(),n=0;n=document.documentMode,Br=null,Vr=null,Hr=null,Ur=!1;function Wr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ur||Br==null||Br!==ge(r)||(r=Br,`selectionStart`in r&&Lr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Hr&&Mr(Hr,r)||(Hr=r,r=gi(Vr,`onSelect`),0qi||(e.current=Ki[qi],Ki[qi]=null,qi--)}function Xi(e,t){qi++,Ki[qi]=e.current,e.current=t}var Zi={},Qi=Ji(Zi),$i=Ji(!1),ea=Zi;function ta(e,t){var n=e.type.contextTypes;if(!n)return Zi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function na(e){return e=e.childContextTypes,e!=null}function ra(){Yi($i),Yi(Qi)}function ia(e,t,n){if(Qi.current!==Zi)throw Error(r(168));Xi(Qi,t),Xi($i,n)}function aa(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,ue(e)||`Unknown`,a));return F({},n,i)}function oa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Zi,ea=Qi.current,Xi(Qi,e),Xi($i,$i.current),!0}function sa(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=aa(e,t,ea),i.__reactInternalMemoizedMergedChildContext=e,Yi($i),Yi(Qi),Xi(Qi,e)):Yi($i),Xi($i,n)}var ca=null,la=!1,ua=!1;function da(e){ca===null?ca=[e]:ca.push(e)}function eee(e){la=!0,da(e)}function fa(){if(!ua&&ca!==null){ua=!0;var e=0,t=Gt;try{var n=ca;for(Gt=1;e>=o,i-=o,ba=1<<32-kt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),Oa&&Sa(r,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Oa&&Sa(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Oa&&Sa(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Oa&&Sa(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===te&&Ha(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Ba(e,l,i),r.return=e,e=r;break a}n(e,l);break}else t(e,l);l=l.sibling}i.type===E?(r=cu(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=su(i.type,i.key,i.props,null,e.mode,o),o.ref=Ba(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}else{n(e,r);break}else t(e,r);r=r.sibling}r=du(i,e.mode,o),r.return=e,e=r}return s(e);case te:return l=i._init,_(e,r,l(i._payload),o)}if(Ce(i))return h(e,r,i,o);if(re(i))return g(e,r,i,o);Va(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=uu(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Wa=Ua(!0),Ga=Ua(!1),Ka=Ji(null),qa=null,Ja=null,Ya=null;function Xa(){Ya=Ja=qa=null}function Za(e){var t=Ka.current;Yi(Ka),e._currentValue=t}function Qa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function $a(e,t){qa=e,Ya=Ja=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Hs=!0),e.firstContext=null)}function eo(e){var t=e._currentValue;if(Ya!==e)if(e={context:e,memoizedValue:t,next:null},Ja===null){if(qa===null)throw Error(r(308));Ja=e,qa.dependencies={lanes:0,firstContext:e}}else Ja=Ja.next=e;return t}var to=null;function no(e){to===null?to=[e]:to.push(e)}function ro(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,no(t)):(n.next=i.next,i.next=n),t.interleaved=n,io(e,r)}function io(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ao=!1;function oo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function so(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function co(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function lo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Zc&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,io(e,n)}return i=r.interleaved,i===null?(t.next=t,no(r)):(t.next=i.next,i.next=t),r.interleaved=t,io(e,n)}function uo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Wt(e,n)}}function fo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function po(e,t,n,r){var i=e.updateQueue;ao=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=F({},d,f);break a;case 2:ao=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);al|=o,e.lanes=o,e.memoizedState=d}}function mo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ko.transition;ko.transition={};try{e(!1),t()}finally{Gt=n,ko.transition=r}}function hs(){return Ho().memoizedState}function gs(e,t,n){var r=wl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},vs(e))ys(t,n);else if(n=ro(e,t,n,r),n!==null){var i=Cl();Tl(n,e,r,i),bs(n,t,r)}}function _s(e,t,n){var r=wl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(vs(e))ys(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,jr(s,o)){var c=t.interleaved;c===null?(i.next=i,no(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=ro(e,t,i,r),n!==null&&(i=Cl(),Tl(n,e,r,i),bs(n,t,r))}}function vs(e){var t=e.alternate;return e===jo||t!==null&&t===jo}function ys(e,t){Fo=Po=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function bs(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Wt(e,n)}}var xs={readContext:eo,useCallback:Lo,useContext:Lo,useEffect:Lo,useImperativeHandle:Lo,useInsertionEffect:Lo,useLayoutEffect:Lo,useMemo:Lo,useReducer:Lo,useRef:Lo,useState:Lo,useDebugValue:Lo,useDeferredValue:Lo,useTransition:Lo,useMutableSource:Lo,useSyncExternalStore:Lo,useId:Lo,unstable_isNewReconciler:!1},Ss={readContext:eo,useCallback:function(e,t){return Vo().memoizedState=[e,t===void 0?null:t],e},useContext:eo,useEffect:is,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),ns(4194308,4,cs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ns(4194308,4,e,t)},useInsertionEffect:function(e,t){return ns(4,2,e,t)},useMemo:function(e,t){var n=Vo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Vo();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=gs.bind(null,jo,e),[r.memoizedState,e]},useRef:function(e){var t=Vo();return e={current:e},t.memoizedState=e},useState:$o,useDebugValue:us,useDeferredValue:function(e){return Vo().memoizedState=e},useTransition:function(){var e=$o(!1),t=e[0];return e=ms.bind(null,e[1]),Vo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=jo,a=Vo();if(Oa){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Qc===null)throw Error(r(349));Ao&30||Jo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,is(Xo.bind(null,i,o,e),[e]),i.flags|=2048,es(9,Yo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=Vo(),t=Qc.identifierPrefix;if(Oa){var n=xa,r=ba;n=(r&~(1<<32-kt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=Io++,0qi||(e.current=Ki[qi],Ki[qi]=null,qi--)}function Xi(e,t){qi++,Ki[qi]=e.current,e.current=t}var Zi={},Qi=Ji(Zi),$i=Ji(!1),ea=Zi;function ta(e,t){var n=e.type.contextTypes;if(!n)return Zi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function na(e){return e=e.childContextTypes,e!=null}function ra(){Yi($i),Yi(Qi)}function ia(e,t,n){if(Qi.current!==Zi)throw Error(r(168));Xi(Qi,t),Xi($i,n)}function aa(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,ue(e)||`Unknown`,a));return F({},n,i)}function oa(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Zi,ea=Qi.current,Xi(Qi,e),Xi($i,$i.current),!0}function sa(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=aa(e,t,ea),i.__reactInternalMemoizedMergedChildContext=e,Yi($i),Yi(Qi),Xi(Qi,e)):Yi($i),Xi($i,n)}var ca=null,la=!1,ua=!1;function da(e){ca===null?ca=[e]:ca.push(e)}function eee(e){la=!0,da(e)}function fa(){if(!ua&&ca!==null){ua=!0;var e=0,t=Gt;try{var n=ca;for(Gt=1;e>=o,i-=o,ba=1<<32-kt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),Oa&&Sa(r,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Oa&&Sa(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Oa&&Sa(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Oa&&Sa(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===te&&Ha(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Ba(e,l,i),r.return=e,e=r;break a}n(e,l);break}else t(e,l);l=l.sibling}i.type===E?(r=cu(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=su(i.type,i.key,i.props,null,e.mode,o),o.ref=Ba(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}else{n(e,r);break}else t(e,r);r=r.sibling}r=du(i,e.mode,o),r.return=e,e=r}return s(e);case te:return l=i._init,_(e,r,l(i._payload),o)}if(Ce(i))return h(e,r,i,o);if(re(i))return g(e,r,i,o);Va(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=uu(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Wa=Ua(!0),Ga=Ua(!1),Ka=Ji(null),qa=null,Ja=null,Ya=null;function Xa(){Ya=Ja=qa=null}function Za(e){var t=Ka.current;Yi(Ka),e._currentValue=t}function Qa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function $a(e,t){qa=e,Ya=Ja=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Us=!0),e.firstContext=null)}function eo(e){var t=e._currentValue;if(Ya!==e)if(e={context:e,memoizedValue:t,next:null},Ja===null){if(qa===null)throw Error(r(308));Ja=e,qa.dependencies={lanes:0,firstContext:e}}else Ja=Ja.next=e;return t}var to=null;function no(e){to===null?to=[e]:to.push(e)}function ro(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,no(t)):(n.next=i.next,i.next=n),t.interleaved=n,io(e,r)}function io(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ao=!1;function oo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function so(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function co(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function lo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Zc&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,io(e,n)}return i=r.interleaved,i===null?(t.next=t,no(r)):(t.next=i.next,i.next=t),r.interleaved=t,io(e,n)}function uo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Wt(e,n)}}function fo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function po(e,t,n,r){var i=e.updateQueue;ao=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=F({},d,f);break a;case 2:ao=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);al|=o,e.lanes=o,e.memoizedState=d}}function mo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ko.transition;ko.transition={};try{e(!1),t()}finally{Gt=n,ko.transition=r}}function gs(){return Uo().memoizedState}function _s(e,t,n){var r=wl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ys(e))bs(t,n);else if(n=ro(e,t,n,r),n!==null){var i=Cl();Tl(n,e,r,i),xs(n,t,r)}}function vs(e,t,n){var r=wl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ys(e))bs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,jr(s,o)){var c=t.interleaved;c===null?(i.next=i,no(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=ro(e,t,i,r),n!==null&&(i=Cl(),Tl(n,e,r,i),xs(n,t,r))}}function ys(e){var t=e.alternate;return e===jo||t!==null&&t===jo}function bs(e,t){Fo=Po=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function xs(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Wt(e,n)}}var Ss={readContext:eo,useCallback:Ro,useContext:Ro,useEffect:Ro,useImperativeHandle:Ro,useInsertionEffect:Ro,useLayoutEffect:Ro,useMemo:Ro,useReducer:Ro,useRef:Ro,useState:Ro,useDebugValue:Ro,useDeferredValue:Ro,useTransition:Ro,useMutableSource:Ro,useSyncExternalStore:Ro,useId:Ro,unstable_isNewReconciler:!1},Cs={readContext:eo,useCallback:function(e,t){return Ho().memoizedState=[e,t===void 0?null:t],e},useContext:eo,useEffect:as,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),rs(4194308,4,ls.bind(null,t,e),n)},useLayoutEffect:function(e,t){return rs(4194308,4,e,t)},useInsertionEffect:function(e,t){return rs(4,2,e,t)},useMemo:function(e,t){var n=Ho();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ho();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=_s.bind(null,jo,e),[r.memoizedState,e]},useRef:function(e){var t=Ho();return e={current:e},t.memoizedState=e},useState:es,useDebugValue:ds,useDeferredValue:function(e){return Ho().memoizedState=e},useTransition:function(){var e=es(!1),t=e[0];return e=hs.bind(null,e[1]),Ho().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=jo,a=Ho();if(Oa){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Qc===null)throw Error(r(349));Ao&30||Yo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,as(Zo.bind(null,i,o,e),[e]),i.flags|=2048,ts(9,Xo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=Ho(),t=Qc.identifierPrefix;if(Oa){var n=xa,r=ba;n=(r&~(1<<32-kt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=Io++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Ii]=t,e[Li]=i,dc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Be(n,i),n){case`dialog`:li(`cancel`,e),li(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:li(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;odl&&(t.flags|=128,i=!0,mc(s,!1),t.lanes=4194304)}else{if(!i)if(e=To(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),mc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!Oa)return hc(t),null}else 2*yt()-s.renderingStartTime>dl&&n!==1073741824&&(t.flags|=128,i=!0,mc(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(hc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=yt(),t.sibling=null,n=wo.current,Xi(wo,i?n&1|2:n&1),t);case 22:case 23:return Fl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?tl&1073741824&&(hc(t),t.subtreeFlags&6&&(t.flags|=8192)):hc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function _c(e,t){switch(Ta(t),t.tag){case 1:return na(t.type)&&ra(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xo(),Yi($i),Yi(Qi),Do(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Co(t),null;case 13:if(Yi(wo),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));La()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Yi(wo),null;case 4:return xo(),null;case 10:return Za(t.type._context),null;case 22:case 23:return Fl(),null;case 24:return null;default:return null}}var vc=!1,yc=!1,bc=typeof WeakSet==`function`?WeakSet:Set,xc=null;function Sc(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){Yl(e,t,n)}else n.current=null}function Cc(e,t,n){try{n()}catch(n){Yl(e,t,n)}}var wc=!1;function Tc(e,t){if(wi=hn,e=Ir(),Lr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ti={focusedElem:e,selectionRange:n},hn=!1,xc=t;xc!==null;)if(t=xc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,xc=e;else for(;xc!==null;){t=xc;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:Ts(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){Yl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,xc=e;break}xc=t.return}return h=wc,wc=!1,h}function Ec(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&Cc(t,n,a)}i=i.next}while(i!==r)}}function Dc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Oc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function kc(e){var t=e.alternate;t!==null&&(e.alternate=null,kc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ii],delete t[Li],delete t[zi],delete t[Bi],delete t[Vi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ac(e){return e.tag===5||e.tag===3||e.tag===4}function jc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Ac(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Mc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ci));else if(r!==4&&(e=e.child,e!==null))for(Mc(e,t,n),e=e.sibling;e!==null;)Mc(e,t,n),e=e.sibling}function Nc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Nc(e,t,n),e=e.sibling;e!==null;)Nc(e,t,n),e=e.sibling}var Pc=null,Fc=!1;function Ic(e,t,n){for(n=n.child;n!==null;)Lc(e,t,n),n=n.sibling}function Lc(e,t,n){if(Dt&&typeof Dt.onCommitFiberUnmount==`function`)try{Dt.onCommitFiberUnmount(Et,n)}catch{}switch(n.tag){case 5:yc||Sc(n,t);case 6:var r=Pc,i=Fc;Pc=null,Ic(e,t,n),Pc=r,Fc=i,Pc!==null&&(Fc?(e=Pc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pc.removeChild(n.stateNode));break;case 18:Pc!==null&&(Fc?(e=Pc,n=n.stateNode,e.nodeType===8?Mi(e.parentNode,n):e.nodeType===1&&Mi(e,n),z(e)):Mi(Pc,n.stateNode));break;case 4:r=Pc,i=Fc,Pc=n.stateNode.containerInfo,Fc=!0,Ic(e,t,n),Pc=r,Fc=i;break;case 0:case 11:case 14:case 15:if(!yc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&Cc(n,t,o),i=i.next}while(i!==r)}Ic(e,t,n);break;case 1:if(!yc&&(Sc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Yl(n,t,e)}Ic(e,t,n);break;case 21:Ic(e,t,n);break;case 22:n.mode&1?(yc=(r=yc)||n.memoizedState!==null,Ic(e,t,n),yc=r):Ic(e,t,n);break;default:Ic(e,t,n)}}function Rc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new bc),t.forEach(function(t){var r=$l.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function zc(e,t){var n=t.deletions;if(n!==null)for(var i=0;ia&&(a=s),i&=~o}if(i=a,i=yt()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*qc(i/1960))-i,10e?16:e,_l===null)var i=!1;else{if(e=_l,_l=null,vl=0,Zc&6)throw Error(r(331));var a=Zc;for(Zc|=4,xc=e.current;xc!==null;){var o=xc,s=o.child;if(xc.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lyt()-ul?Il(e,0):sl|=n),El(e,t)}function Zl(e,t){t===0&&(e.mode&1?(t=Pt,Pt<<=1,!(Pt&130023424)&&(Pt=4194304)):t=1);var n=Cl();e=io(e,t),e!==null&&(Ht(e,t,n),El(e,n))}function Ql(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Zl(e,n)}function $l(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Zl(e,n)}var eu=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||$i.current)Hs=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Hs=!1,nee(e,t,n);Hs=!!(e.flags&131072)}else Hs=!1,Oa&&t.flags&1048576&&Ca(t,ga,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;lc(e,t),e=t.pendingProps;var a=ta(t,Qi.current);$a(t,n),a=zo(null,t,i,e,a,n);var o=Bo();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,na(i)?(o=!0,oa(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,oo(t),a.updater=Ds,t.stateNode=a,a._reactInternals=t,js(t,i,e,n),t=Zs(null,t,i,!0,o,n)):(t.tag=0,Oa&&o&&wa(t),Us(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(lc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=au(i),e=Ts(i,e),a){case 0:t=Ys(null,t,i,e,n);break a;case 1:t=Xs(null,t,i,e,n);break a;case 11:t=Ws(null,t,i,e,n);break a;case 14:t=Gs(null,t,i,Ts(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Ts(i,a),Ys(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Ts(i,a),Xs(e,t,i,a,n);case 3:a:{if(Qs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,so(e,t),po(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ms(Error(r(423)),t),t=$s(e,t,i,n,a);break a}else if(i!==a){a=Ms(Error(r(424)),t),t=$s(e,t,i,n,a);break a}else for(Da=Ni(t.stateNode.containerInfo.firstChild),Ea=t,Oa=!0,ka=null,n=Ga(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(La(),i===a){t=uc(e,t,n);break a}Us(e,t,i,n)}t=t.child}return t;case 5:return So(t),e===null&&Na(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,Ei(i,a)?s=null:o!==null&&Ei(i,o)&&(t.flags|=32),Js(e,t),Us(e,t,s,n),t.child;case 6:return e===null&&Na(t),null;case 13:return nc(e,t,n);case 4:return bo(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Wa(t,null,i,n):Us(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Ts(i,a),Ws(e,t,i,a,n);case 7:return Us(e,t,t.pendingProps,n),t.child;case 8:return Us(e,t,t.pendingProps.children,n),t.child;case 12:return Us(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Xi(Ka,i._currentValue),i._currentValue=s,o!==null)if(jr(o.value,s)){if(o.children===a.children&&!$i.current){t=uc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=co(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Qa(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Qa(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Us(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,$a(t,n),a=eo(a),i=i(a),t.flags|=1,Us(e,t,i,n),t.child;case 14:return i=t.type,a=Ts(i,t.pendingProps),a=Ts(i.type,a),Gs(e,t,i,a,n);case 15:return Ks(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Ts(i,a),lc(e,t),t.tag=1,na(i)?(e=!0,oa(t)):e=!1,$a(t,n),ks(t,i,a),js(t,i,a,n),Zs(null,t,i,!0,e,n);case 19:return cc(e,t,n);case 22:return qs(e,t,n)}throw Error(r(156,t.tag))};function tu(e,t){return ht(e,t)}function nu(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ru(e,t,n,r){return new nu(e,t,n,r)}function iu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function au(e){if(typeof e==`function`)return+!!iu(e);if(e!=null){if(e=e.$$typeof,e===j)return 11;if(e===N)return 14}return 2}function ou(e,t){var n=e.alternate;return n===null?(n=ru(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function su(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)iu(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return cu(n.children,a,o,t);case D:s=8,a|=8;break;case O:return e=ru(12,n,t,a|2),e.elementType=O,e.lanes=o,e;case M:return e=ru(13,n,t,a),e.elementType=M,e.lanes=o,e;case ee:return e=ru(19,n,t,a),e.elementType=ee,e.lanes=o,e;case ne:return lu(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case k:s=10;break a;case A:s=9;break a;case j:s=11;break a;case N:s=14;break a;case te:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=ru(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function cu(e,t,n,r){return e=ru(7,e,r,t),e.lanes=n,e}function lu(e,t,n,r){return e=ru(22,e,r,t),e.elementType=ne,e.lanes=n,e.stateNode={isHidden:!1},e}function uu(e,t,n){return e=ru(6,e,null,t),e.lanes=n,e}function du(e,t,n){return t=ru(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function fu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Vt(0),this.expirationTimes=Vt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function pu(e,t,n,r,i,a,o,s,c){return e=new fu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=ru(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},oo(a),e}function mu(e,t,n){var r=3{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=s((e=>{var t=g();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),v=u(f(),1),y=_();function b(e=`This should not happen`){throw Error(e)}function x(e,t=`Assertion failed`){if(!e)return b(t)}function S(e,t){return b(t??`Hell froze over`)}function C(e,t){try{return e()}catch{return t}}function w(e,t){let n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&w(e[r],t[r]););return r===-1}if(!n||typeof e==`object`){for(n in r=0,e)if(T.call(e,n)&&++r&&!T.call(t,n)||!(n in t)||!w(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var T,E=o((()=>{T=Object.prototype.hasOwnProperty})),D=s(((e,t)=>{var n=Object.prototype.hasOwnProperty;function r(e,t){return e!=null&&n.call(e,t)}t.exports=r})),O=s(((e,t)=>{t.exports=Array.isArray})),k=s(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),A=s(((e,t)=>{var n=k(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),j=s(((e,t)=>{t.exports=A().Symbol})),M=s(((e,t)=>{var n=j(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),ee=s(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),N=s(((e,t)=>{var n=j(),r=M(),i=ee(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),te=s(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),ne=s(((e,t)=>{var n=N(),r=te(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),P=s(((e,t)=>{var n=O(),r=ne(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),re=s(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),F=s(((e,t)=>{var n=N(),r=re(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),ie=s(((e,t)=>{t.exports=A()[`__core-js_shared__`]})),ae=s(((e,t)=>{var n=ie(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),oe=s(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),se=s(((e,t)=>{var n=F(),r=ae(),i=re(),a=oe(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),ce=s(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),le=s(((e,t)=>{var n=se(),r=ce();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),ue=s(((e,t)=>{t.exports=le()(Object,`create`)})),de=s(((e,t)=>{var n=ue();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),fe=s(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}t.exports=n})),pe=s(((e,t)=>{var n=ue(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),me=s(((e,t)=>{var n=ue(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),he=s(((e,t)=>{var n=ue(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=+!this.has(e),i[e]=n&&t===void 0?r:t,this}t.exports=i})),ge=s(((e,t)=>{var n=de(),r=fe(),i=pe(),a=me(),o=he();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{function n(){this.__data__=[],this.size=0}t.exports=n})),ve=s(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),ye=s(((e,t)=>{var n=ve();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),be=s(((e,t)=>{var n=ye(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),xe=s(((e,t)=>{var n=ye();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),Se=s(((e,t)=>{var n=ye();function r(e){return n(this.__data__,e)>-1}t.exports=r})),Ce=s(((e,t)=>{var n=ye();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),we=s(((e,t)=>{var n=_e(),r=be(),i=xe(),a=Se(),o=Ce();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{t.exports=le()(A(),`Map`)})),Ee=s(((e,t)=>{var n=ge(),r=we(),i=Te();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),De=s(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),Oe=s(((e,t)=>{var n=De();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),ke=s(((e,t)=>{var n=Oe();function r(e){var t=n(this,e).delete(e);return this.size-=+!!t,t}t.exports=r})),Ae=s(((e,t)=>{var n=Oe();function r(e){return n(this,e).get(e)}t.exports=r})),je=s(((e,t)=>{var n=Oe();function r(e){return n(this,e).has(e)}t.exports=r})),Me=s(((e,t)=>{var n=Oe();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),Ne=s(((e,t)=>{var n=Ee(),r=ke(),i=Ae(),a=je(),o=Me();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{var n=Ne(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),Fe=s(((e,t)=>{var n=Pe(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),Ie=s(((e,t)=>{var n=Fe(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),Le=s(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n{var n=j(),r=Le(),i=O(),a=ne(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),ze=s(((e,t)=>{var n=Re();function r(e){return e==null?``:n(e)}t.exports=r})),Be=s(((e,t)=>{var n=O(),r=P(),i=Ie(),a=ze();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),Ve=s(((e,t)=>{var n=N(),r=te(),i=`[object Arguments]`;function a(e){return r(e)&&n(e)==i}t.exports=a})),He=s(((e,t)=>{var n=Ve(),r=te(),i=Object.prototype,a=i.hasOwnProperty,o=i.propertyIsEnumerable;t.exports=n(function(){return arguments}())?n:function(e){return r(e)&&a.call(e,`callee`)&&!o.call(e,`callee`)}})),Ue=s(((e,t)=>{var n=/^(?:0|[1-9]\d*)$/;function r(e,t){var r=typeof e;return t??=9007199254740991,!!t&&(r==`number`||r!=`symbol`&&n.test(e))&&e>-1&&e%1==0&&e{function n(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=9007199254740991}t.exports=n})),Ge=s(((e,t)=>{var n=ne(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),Ke=s(((e,t)=>{var n=Be(),r=He(),i=O(),a=Ue(),o=We(),s=Ge();function c(e,t,c){t=n(t,e);for(var l=-1,u=t.length,d=!1;++l{var n=D(),r=Ke();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i}));function Je(e){return`width`in e&&typeof e.width==`number`}async function Ye(e){return typeof e==`object`?e:await e()}function Xe(e){return!(e.kind===I.Loading||e.kind===I.Bubble||e.kind===I.RowID||e.kind===I.Protected||e.kind===I.Drilldown)}function Ze(e){return e.kind===at.Marker||e.kind===at.NewRow}function Qe(e){if(!Xe(e)||e.kind===I.Image)return!1;if(e.kind===I.Text||e.kind===I.Number||e.kind===I.Markdown||e.kind===I.Uri||e.kind===I.Custom||e.kind===I.Boolean)return e.readonly!==!0;S(e,`A cell was passed with an invalid kind`)}function $e(e){return(0,nt.default)(e,`editor`)}function et(e){return!(e.readonly??!1)}function tt(e){if(e.length===0)return[];let t=[...e],n=[];t.sort(function(e,t){return e[0]-t[0]}),n.push([...t[0]]);for(let e of t.slice(1)){let t=n[n.length-1];t[1]{E(),nt=u(qe(),1),(function(e){e.Uri=`uri`,e.Text=`text`,e.Image=`image`,e.RowID=`row-id`,e.Number=`number`,e.Bubble=`bubble`,e.Boolean=`boolean`,e.Loading=`loading`,e.Markdown=`markdown`,e.Drilldown=`drilldown`,e.Protected=`protected`,e.Custom=`custom`})(I||={}),(function(e){e.HeaderRowID=`headerRowID`,e.HeaderCode=`headerCode`,e.HeaderNumber=`headerNumber`,e.HeaderString=`headerString`,e.HeaderBoolean=`headerBoolean`,e.HeaderAudioUri=`headerAudioUri`,e.HeaderVideoUri=`headerVideoUri`,e.HeaderEmoji=`headerEmoji`,e.HeaderImage=`headerImage`,e.HeaderUri=`headerUri`,e.HeaderPhone=`headerPhone`,e.HeaderMarkdown=`headerMarkdown`,e.HeaderDate=`headerDate`,e.HeaderTime=`headerTime`,e.HeaderEmail=`headerEmail`,e.HeaderReference=`headerReference`,e.HeaderIfThenElse=`headerIfThenElse`,e.HeaderSingleValue=`headerSingleValue`,e.HeaderLookup=`headerLookup`,e.HeaderTextTemplate=`headerTextTemplate`,e.HeaderMath=`headerMath`,e.HeaderRollup=`headerRollup`,e.HeaderJoinStrings=`headerJoinStrings`,e.HeaderSplitString=`headerSplitString`,e.HeaderGeoDistance=`headerGeoDistance`,e.HeaderArray=`headerArray`,e.RowOwnerOverlay=`rowOwnerOverlay`,e.ProtectedColumnOverlay=`protectedColumnOverlay`})(rt||={}),(function(e){e.Triangle=`triangle`,e.Dots=`dots`})(it||={}),(function(e){e.NewRow=`new-row`,e.Marker=`marker`})(at||={}),st=class e{items;constructor(e){this.items=e}static empty=()=>ot??=new e([]);static fromSingleSelection=t=>e.empty().add(t);offset(t){if(t===0)return this;let n=this.items.map(e=>[e[0]+t,e[1]+t]);return new e(n)}add(t){let n=typeof t==`number`?[t,t+1]:t,r=tt([...this.items,n]);return new e(r)}remove(t){let n=[...this.items],r=typeof t==`number`?t:t[0],i=typeof t==`number`?t+1:t[1];for(let[e,t]of n.entries()){let[a,o]=t;if(a<=i&&r<=o){let t=[];a=n&&e{})),dt,ft,pt=o((()=>{ut(),dt=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,ft=lt(function(e){return dt.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91})})),mt,ht=o((()=>{mt=function(){let e=Array.prototype.slice.call(arguments).filter(Boolean),t={},n=[];e.forEach(e=>{(e?e.split(` `):[]).forEach(e=>{if(e.startsWith(`atm_`)){let[,n]=e.split(`_`);t[n]=e}else n.push(e)})});let r=[];for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.push(t[e]);return r.push(...n),r.join(` `)}}));function gt(e,t,n){let r=bt(t,n);if(!e){let e=typeof ft==`function`?{default:ft}:ft;Object.keys(r).forEach(t=>{e.default(t)||delete r[t]})}return r}function _t(e){return t=>{let n=(n,r)=>{let{as:i=e,class:a=``}=n,o=gt(t.propsAsIs===void 0?!(typeof i==`string`&&i.indexOf(`-`)===-1&&!vt(i[0])):t.propsAsIs,n,[`as`,`class`]);o.ref=r,o.className=t.atomic?mt(t.class,o.className||a):mt(o.className||a,t.class);let{vars:s}=t;if(s){let e={};for(let r in s){let i=s[r],a=i[0],o=i[1]||``,c=typeof a==`function`?a(n):a;t.name,e[`--${r}`]=`${c}${o}`}let r=o.style||{},i=Object.keys(r);i.length>0&&i.forEach(t=>{e[t]=r[t]}),o.style=e}return e.__linaria&&e!==i?(o.as=i,v.createElement(e,o)):v.createElement(i,o)},r=v.forwardRef?v.forwardRef(n):e=>{let t=bt(e,[`innerRef`]);return n(t,e.innerRef)};return r.displayName=t.name,r.__linaria={className:t.class||``,extends:e},r}}var vt,yt,bt,xt,St=o((()=>{pt(),ht(),vt=e=>e.toUpperCase()===e,yt=e=>t=>e.indexOf(t)===-1,bt=(e,t)=>{let n={};return Object.keys(e).filter(yt(t)).forEach(t=>{n[t]=e[t]}),n},xt=_t}));St();var Ct=xt(`div`)({name:`ImageOverlayEditorStyle`,class:`gdg-i2iowwq`,propsAsIs:!1}),wt=s(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Tt=s(((e,t)=>{var n=wt();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Et=s(((e,t)=>{t.exports=Tt()()})),Dt=s((e=>{(function(t,n){if(typeof define==`function`&&define.amd)define([`exports`,`react`,`prop-types`],n);else if(e!==void 0)n(e,f(),Et());else{var r={exports:{}};n(r.exports,t.react,t.propTypes),t.reactSwipe=r.exports}})(e,function(e,t,n){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var r=a(t),i=a(n);function a(e){return e&&e.__esModule?e:{default:e}}var o=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function c(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}var l=function(){function e(e,t){for(var n=0;n0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return f?e:e.capture}function h(e){if(`touches`in e){var t=e.touches[0];return{x:t.pageX,y:t.pageY}}return{x:e.screenX,y:e.screenY}}var g=function(e){d(t,e);function t(){var e;c(this,t);var n=[...arguments],r=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(n)));return r._handleSwipeStart=r._handleSwipeStart.bind(r),r._handleSwipeMove=r._handleSwipeMove.bind(r),r._handleSwipeEnd=r._handleSwipeEnd.bind(r),r._onMouseDown=r._onMouseDown.bind(r),r._onMouseMove=r._onMouseMove.bind(r),r._onMouseUp=r._onMouseUp.bind(r),r._setSwiperRef=r._setSwiperRef.bind(r),r}return l(t,[{key:`componentDidMount`,value:function(){this.swiper&&this.swiper.addEventListener(`touchmove`,this._handleSwipeMove,m({capture:!0,passive:!1}))}},{key:`componentWillUnmount`,value:function(){this.swiper&&this.swiper.removeEventListener(`touchmove`,this._handleSwipeMove,m({capture:!0,passive:!1}))}},{key:`_onMouseDown`,value:function(e){this.props.allowMouseEvents&&(this.mouseDown=!0,document.addEventListener(`mouseup`,this._onMouseUp),document.addEventListener(`mousemove`,this._onMouseMove),this._handleSwipeStart(e))}},{key:`_onMouseMove`,value:function(e){this.mouseDown&&this._handleSwipeMove(e)}},{key:`_onMouseUp`,value:function(e){this.mouseDown=!1,document.removeEventListener(`mouseup`,this._onMouseUp),document.removeEventListener(`mousemove`,this._onMouseMove),this._handleSwipeEnd(e)}},{key:`_handleSwipeStart`,value:function(e){var t=h(e),n=t.x,r=t.y;this.moveStart={x:n,y:r},this.props.onSwipeStart(e)}},{key:`_handleSwipeMove`,value:function(e){if(this.moveStart){var t=h(e),n=t.x,r=t.y,i=n-this.moveStart.x,a=r-this.moveStart.y;this.moving=!0,this.props.onSwipeMove({x:i,y:a},e)&&e.cancelable&&e.preventDefault(),this.movePosition={deltaX:i,deltaY:a}}}},{key:`_handleSwipeEnd`,value:function(e){this.props.onSwipeEnd(e);var t=this.props.tolerance;this.moving&&this.movePosition&&(this.movePosition.deltaX<-t?this.props.onSwipeLeft(1,e):this.movePosition.deltaX>t&&this.props.onSwipeRight(1,e),this.movePosition.deltaY<-t?this.props.onSwipeUp(1,e):this.movePosition.deltaY>t&&this.props.onSwipeDown(1,e)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:`_setSwiperRef`,value:function(e){this.swiper=e,this.props.innerRef(e)}},{key:`render`,value:function(){var e=this.props;e.tagName;var t=e.className,n=e.style,i=e.children;e.allowMouseEvents,e.onSwipeUp,e.onSwipeDown,e.onSwipeLeft,e.onSwipeRight,e.onSwipeStart,e.onSwipeMove,e.onSwipeEnd,e.innerRef,e.tolerance;var a=s(e,[`tagName`,`className`,`style`,`children`,`allowMouseEvents`,`onSwipeUp`,`onSwipeDown`,`onSwipeLeft`,`onSwipeRight`,`onSwipeStart`,`onSwipeMove`,`onSwipeEnd`,`innerRef`,`tolerance`]);return r.default.createElement(this.props.tagName,o({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:t,style:n},a),i)}}]),t}(t.Component);g.displayName=`ReactSwipe`,g.propTypes={tagName:i.default.string,className:i.default.string,style:i.default.object,children:i.default.node,allowMouseEvents:i.default.bool,onSwipeUp:i.default.func,onSwipeDown:i.default.func,onSwipeLeft:i.default.func,onSwipeRight:i.default.func,onSwipeStart:i.default.func,onSwipeMove:i.default.func,onSwipeEnd:i.default.func,innerRef:i.default.func,tolerance:i.default.number.isRequired},g.defaultProps={tagName:`div`,allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},e.default=g})})),Ot=s((e=>{(function(t,n){if(typeof define==`function`&&define.amd)define([`exports`,`./react-swipe`],n);else if(e!==void 0)n(e,Dt());else{var r={exports:{}};n(r.exports,t.reactSwipe),t.index=r.exports}})(e,function(e,t){Object.defineProperty(e,"__esModule",{value:!0});var n=r(t);function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default})})),kt=s(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(kt());function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e.default={ROOT:function(e){return(0,t.default)(r({"carousel-root":!0},e||``,!!e))},CAROUSEL:function(e){return(0,t.default)({carousel:!0,"carousel-slider":e})},WRAPPER:function(e,n){return(0,t.default)({"thumbs-wrapper":!e,"slider-wrapper":e,"axis-horizontal":n===`horizontal`,"axis-vertical":n!==`horizontal`})},SLIDER:function(e,n){return(0,t.default)({thumbs:!e,slider:e,animated:!n})},ITEM:function(e,n,r){return(0,t.default)({thumb:!e,slide:e,selected:n,previous:r})},ARROW_PREV:function(e){return(0,t.default)({"control-arrow control-prev":!0,"control-disabled":e})},ARROW_NEXT:function(e){return(0,t.default)({"control-arrow control-next":!0,"control-disabled":e})},DOT:function(e){return(0,t.default)({dot:!0,selected:e})}}})),jt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.outerWidth=void 0,e.outerWidth=function(e){var t=e.offsetWidth,n=getComputedStyle(e);return t+=parseInt(n.marginLeft)+parseInt(n.marginRight),t}})),Mt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(e,t,n){var r=e===0?e:e+t;return`translate3d`+(`(`+(n===`horizontal`?[r,0,0]:[0,r,0]).join(`,`)+`)`)}})),Nt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(){return window}})),Pt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=l(f()),n=s(At()),r=jt(),i=s(Mt()),a=s(Ot()),o=s(Nt());function s(e){return e&&e.__esModule?e:{default:e}}function c(){if(typeof WeakMap!=`function`)return null;var e=new WeakMap;return c=function(){return e},e}function l(e){if(e&&e.__esModule)return e;if(e===null||u(e)!==`object`&&typeof e!=`function`)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=r?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(){return d=Object.assign||function(e){for(var t=1;t`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function S(e){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},S(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=function(e){return e.hasOwnProperty(`key`)},T=function(e){g(c,e);var s=v(c);function c(e){var n;return p(this,c),n=s.call(this,e),C(b(n),`itemsWrapperRef`,void 0),C(b(n),`itemsListRef`,void 0),C(b(n),`thumbsRef`,void 0),C(b(n),`setItemsWrapperRef`,function(e){n.itemsWrapperRef=e}),C(b(n),`setItemsListRef`,function(e){n.itemsListRef=e}),C(b(n),`setThumbsRef`,function(e,t){n.thumbsRef||=[],n.thumbsRef[t]=e}),C(b(n),`updateSizes`,function(){if(!(!n.props.children||!n.itemsWrapperRef||!n.thumbsRef)){var e=t.Children.count(n.props.children),i=n.itemsWrapperRef.clientWidth,a=n.props.thumbWidth?n.props.thumbWidth:(0,r.outerWidth)(n.thumbsRef[0]),o=Math.floor(i/a),s=o0&&(r=0),s===c&&r<0&&(r=0);var l=s+100/(n.itemsWrapperRef.clientWidth/r);return n.itemsListRef&&[`WebkitTransform`,`MozTransform`,`MsTransform`,`OTransform`,`transform`,`msTransform`].forEach(function(e){n.itemsListRef.style[e]=(0,i.default)(l,`%`,n.props.axis)}),!0}),C(b(n),`slideRight`,function(e){n.moveTo(n.state.firstItem-(typeof e==`number`?e:1))}),C(b(n),`slideLeft`,function(e){n.moveTo(n.state.firstItem+(typeof e==`number`?e:1))}),C(b(n),`moveTo`,function(e){e=e<0?0:e,e=e>=n.state.lastPosition?n.state.lastPosition:e,n.setState({firstItem:e})}),n.state={selectedItem:e.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},n}return h(c,[{key:`componentDidMount`,value:function(){this.setupThumbs()}},{key:`componentDidUpdate`,value:function(e){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==e.children&&this.updateSizes()}},{key:`componentWillUnmount`,value:function(){this.destroyThumbs()}},{key:`setupThumbs`,value:function(){(0,o.default)().addEventListener(`resize`,this.updateSizes),(0,o.default)().addEventListener(`DOMContentLoaded`,this.updateSizes),this.updateSizes()}},{key:`destroyThumbs`,value:function(){(0,o.default)().removeEventListener(`resize`,this.updateSizes),(0,o.default)().removeEventListener(`DOMContentLoaded`,this.updateSizes)}},{key:`getFirstItem`,value:function(e){var t=e;return e>=this.state.lastPosition&&(t=this.state.lastPosition),e1,o=this.state.showArrows&&this.state.firstItem>0,s=this.state.showArrows&&this.state.firstItem{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(){return document}})),It=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setPosition=e.getPosition=e.isKeyboardEvent=e.defaultStatusFormatter=e.noop=void 0;var t=f(),n=r(Mt());function r(e){return e&&e.__esModule?e:{default:e}}e.noop=function(){},e.defaultStatusFormatter=function(e,t){return`${e} of ${t}`},e.isKeyboardEvent=function(e){return e?e.hasOwnProperty(`key`):!1},e.getPosition=function(e,n){if(n.infiniteLoop&&++e,e===0)return 0;var r=t.Children.count(n.children);if(n.centerMode&&n.axis===`horizontal`){var i=-e*n.centerSlidePercentage,a=r-1;return e&&(e!==a||n.infiniteLoop)?i+=(100-n.centerSlidePercentage)/2:e===a&&(i+=100-n.centerSlidePercentage),i}return-e*100},e.setPosition=function(e,t){var r={};return[`WebkitTransform`,`MozTransform`,`MsTransform`,`OTransform`,`transform`,`msTransform`].forEach(function(i){r[i]=(0,n.default)(e,`%`,t)}),r}})),Lt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.fadeAnimationHandler=e.slideStopSwipingHandler=e.slideSwipeAnimationHandler=e.slideAnimationHandler=void 0;var t=f(),n=i(Mt()),r=It();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function o(e){for(var t=1;tl))return c<0?e.centerMode&&e.centerSlidePercentage&&e.axis===`horizontal`?a.itemListStyle=(0,r.setPosition)(-(l+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):a.itemListStyle=(0,r.setPosition)(-(l+2)*100,e.axis):c>l&&(a.itemListStyle=(0,r.setPosition)(0,e.axis)),a;var u=(0,r.getPosition)(s,e),d=(0,n.default)(u,`%`,e.axis),f=e.transitionTime+`ms`;return a.itemListStyle={WebkitTransform:d,msTransform:d,OTransform:d,transform:d},i.swiping||(a.itemListStyle=o(o({},a.itemListStyle),{},{WebkitTransitionDuration:f,MozTransitionDuration:f,OTransitionDuration:f,transitionDuration:f,msTransitionDuration:f})),a},e.slideSwipeAnimationHandler=function(e,n,i,a){var o={},s=n.axis===`horizontal`,c=t.Children.count(n.children),l=0,u=(0,r.getPosition)(i.selectedItem,n),d=n.infiniteLoop?(0,r.getPosition)(c-1,n)-100:(0,r.getPosition)(c-1,n),f=s?e.x:e.y,p=f;u===l&&f>0&&(p=0),u===d&&f<0&&(p=0);var m=u+100/(i.itemSize/p),h=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&h&&(i.selectedItem===0&&m>-100?m-=c*100:i.selectedItem===c-1&&m<-c*100&&(m+=c*100)),(!n.preventMovementUntilSwipeScrollTolerance||h||i.swipeMovementStarted)&&(i.swipeMovementStarted||a({swipeMovementStarted:!0}),o.itemListStyle=(0,r.setPosition)(m,n.axis)),h&&!i.cancelClick&&a({cancelClick:!0}),o},e.slideStopSwipingHandler=function(e,t){var n=(0,r.getPosition)(t.selectedItem,e);return{itemListStyle:(0,r.setPosition)(n,e.axis)}},e.fadeAnimationHandler=function(e,t){var n=e.transitionTime+`ms`,r=`ease-in-out`,i={position:`absolute`,display:`block`,zIndex:-2,minHeight:`100%`,opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:r,msTransitionTimingFunction:r,MozTransitionTimingFunction:r,WebkitTransitionTimingFunction:r,OTransitionTimingFunction:r};return t.swiping||(i=o(o({},i),{},{WebkitTransitionDuration:n,MozTransitionDuration:n,OTransitionDuration:n,transitionDuration:n,msTransitionDuration:n})),{slideStyle:i,selectedStyle:o(o({},i),{},{opacity:1,position:`relative`}),prevStyle:o({},i)}}})),Rt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=d(f()),n=l(Ot()),r=l(At()),i=l(Pt()),a=l(Ft()),o=l(Nt()),s=It(),c=Lt();function l(e){return e&&e.__esModule?e:{default:e}}function u(){if(typeof WeakMap!=`function`)return null;var e=new WeakMap;return u=function(){return e},e}function d(e){if(e&&e.__esModule)return e;if(e===null||p(e)!==`object`&&typeof e!=`function`)return{default:e};var t=u();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=r?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(){return m=Object.assign||function(e){for(var t=1;t`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function D(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O=function(e){b(u,e);var l=S(u);function u(e){var n;_(this,u),n=l.call(this,e),D(w(n),`thumbsRef`,void 0),D(w(n),`carouselWrapperRef`,void 0),D(w(n),`listRef`,void 0),D(w(n),`itemsRef`,void 0),D(w(n),`timer`,void 0),D(w(n),`animationHandler`,void 0),D(w(n),`setThumbsRef`,function(e){n.thumbsRef=e}),D(w(n),`setCarouselWrapperRef`,function(e){n.carouselWrapperRef=e}),D(w(n),`setListRef`,function(e){n.listRef=e}),D(w(n),`setItemsRef`,function(e,t){n.itemsRef||=[],n.itemsRef[t]=e}),D(w(n),`autoPlay`,function(){t.Children.count(n.props.children)<=1||(n.clearAutoPlay(),n.props.autoPlay&&(n.timer=setTimeout(function(){n.increment()},n.props.interval)))}),D(w(n),`clearAutoPlay`,function(){n.timer&&clearTimeout(n.timer)}),D(w(n),`resetAutoPlay`,function(){n.clearAutoPlay(),n.autoPlay()}),D(w(n),`stopOnHover`,function(){n.setState({isMouseEntered:!0},n.clearAutoPlay)}),D(w(n),`startOnLeave`,function(){n.setState({isMouseEntered:!1},n.autoPlay)}),D(w(n),`isFocusWithinTheCarousel`,function(){return n.carouselWrapperRef?!!((0,a.default)().activeElement===n.carouselWrapperRef||n.carouselWrapperRef.contains((0,a.default)().activeElement)):!1}),D(w(n),`navigateWithKeyboard`,function(e){if(n.isFocusWithinTheCarousel()){var t=n.props.axis===`horizontal`,r={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},i=t?r.ArrowRight:r.ArrowDown,a=t?r.ArrowLeft:r.ArrowUp;i===e.keyCode?n.increment():a===e.keyCode&&n.decrement()}}),D(w(n),`updateSizes`,function(){if(!(!n.state.initialized||!n.itemsRef||n.itemsRef.length===0)){var e=n.props.axis===`horizontal`,t=n.itemsRef[0];if(t){var r=e?t.clientWidth:t.clientHeight;n.setState({itemSize:r}),n.thumbsRef&&n.thumbsRef.updateSizes()}}}),D(w(n),`setMountState`,function(){n.setState({hasMount:!0}),n.updateSizes()}),D(w(n),`handleClickItem`,function(e,r){if(t.Children.count(n.props.children)!==0){if(n.state.cancelClick){n.setState({cancelClick:!1});return}n.props.onClickItem(e,r),e!==n.state.selectedItem&&n.setState({selectedItem:e})}}),D(w(n),`handleOnChange`,function(e,r){t.Children.count(n.props.children)<=1||n.props.onChange(e,r)}),D(w(n),`handleClickThumb`,function(e,t){n.props.onClickThumb(e,t),n.moveTo(e)}),D(w(n),`onSwipeStart`,function(e){n.setState({swiping:!0}),n.props.onSwipeStart(e)}),D(w(n),`onSwipeEnd`,function(e){n.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),n.props.onSwipeEnd(e),n.clearAutoPlay(),n.state.autoPlay&&n.autoPlay()}),D(w(n),`onSwipeMove`,function(e,t){n.props.onSwipeMove(t);var r=n.props.swipeAnimationHandler(e,n.props,n.state,n.setState.bind(w(n)));return n.setState(g({},r)),!!Object.keys(r).length}),D(w(n),`decrement`,function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;n.moveTo(n.state.selectedItem-(typeof e==`number`?e:1))}),D(w(n),`increment`,function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;n.moveTo(n.state.selectedItem+(typeof e==`number`?e:1))}),D(w(n),`moveTo`,function(e){if(typeof e==`number`){var r=t.Children.count(n.props.children)-1;e<0&&(e=n.props.infiniteLoop?r:0),e>r&&(e=n.props.infiniteLoop?0:r),n.selectItem({selectedItem:e}),n.state.autoPlay&&n.state.isMouseEntered===!1&&n.resetAutoPlay()}}),D(w(n),`onClickNext`,function(){n.increment(1)}),D(w(n),`onClickPrev`,function(){n.decrement(1)}),D(w(n),`onSwipeForward`,function(){n.increment(1),n.props.emulateTouch&&n.setState({cancelClick:!0})}),D(w(n),`onSwipeBackwards`,function(){n.decrement(1),n.props.emulateTouch&&n.setState({cancelClick:!0})}),D(w(n),`changeItem`,function(e){return function(t){(!(0,s.isKeyboardEvent)(t)||t.key===`Enter`)&&n.moveTo(e)}}),D(w(n),`selectItem`,function(e){n.setState(g({previousItem:n.state.selectedItem},e),function(){n.setState(n.animationHandler(n.props,n.state))}),n.handleOnChange(e.selectedItem,t.Children.toArray(n.props.children)[e.selectedItem])}),D(w(n),`getInitialImage`,function(){var e=n.props.selectedItem,t=n.itemsRef&&n.itemsRef[e];return(t&&t.getElementsByTagName(`img`)||[])[0]}),D(w(n),`getVariableItemHeight`,function(e){var t=n.itemsRef&&n.itemsRef[e];if(n.state.hasMount&&t&&t.children.length){var r=t.children[0].getElementsByTagName(`img`)||[];if(r.length>0){var i=r[0];i.complete||i.addEventListener(`load`,function e(){n.forceUpdate(),i.removeEventListener(`load`,e)})}var a=(r[0]||t.children[0]).clientHeight;return a>0?a:null}return null});var r={initialized:!1,previousItem:e.selectedItem,selectedItem:e.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:e.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return n.animationHandler=typeof e.animationHandler==`function`&&e.animationHandler||e.animationHandler===`fade`&&c.fadeAnimationHandler||c.slideAnimationHandler,n.state=g(g({},r),n.animationHandler(e,r)),n}return y(u,[{key:`componentDidMount`,value:function(){this.props.children&&this.setupCarousel()}},{key:`componentDidUpdate`,value:function(e,t){!e.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!e.autoFocus&&this.props.autoFocus&&this.forceFocus(),t.swiping&&!this.state.swiping&&this.setState(g({},this.props.stopSwipingHandler(this.props,this.state))),(e.selectedItem!==this.props.selectedItem||e.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),e.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:`componentWillUnmount`,value:function(){this.destroyCarousel()}},{key:`setupCarousel`,value:function(){var e=this;this.bindEvents(),this.state.autoPlay&&t.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var t=e.getInitialImage();t&&!t.complete?t.addEventListener(`load`,e.setMountState):e.setMountState()})}},{key:`destroyCarousel`,value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:`setupAutoPlay`,value:function(){this.autoPlay();var e=this.carouselWrapperRef;this.props.stopOnHover&&e&&(e.addEventListener(`mouseenter`,this.stopOnHover),e.addEventListener(`mouseleave`,this.startOnLeave))}},{key:`destroyAutoPlay`,value:function(){this.clearAutoPlay();var e=this.carouselWrapperRef;this.props.stopOnHover&&e&&(e.removeEventListener(`mouseenter`,this.stopOnHover),e.removeEventListener(`mouseleave`,this.startOnLeave))}},{key:`bindEvents`,value:function(){(0,o.default)().addEventListener(`resize`,this.updateSizes),(0,o.default)().addEventListener(`DOMContentLoaded`,this.updateSizes),this.props.useKeyboardArrows&&(0,a.default)().addEventListener(`keydown`,this.navigateWithKeyboard)}},{key:`unbindEvents`,value:function(){(0,o.default)().removeEventListener(`resize`,this.updateSizes),(0,o.default)().removeEventListener(`DOMContentLoaded`,this.updateSizes);var e=this.getInitialImage();e&&e.removeEventListener(`load`,this.setMountState),this.props.useKeyboardArrows&&(0,a.default)().removeEventListener(`keydown`,this.navigateWithKeyboard)}},{key:`forceFocus`,value:function(){var e;(e=this.carouselWrapperRef)==null||e.focus()}},{key:`renderItems`,value:function(e){var n=this;return this.props.children?t.Children.map(this.props.children,function(i,a){var o=a===n.state.selectedItem,s=a===n.state.previousItem,c=o&&n.state.selectedStyle||s&&n.state.prevStyle||n.state.slideStyle||{};n.props.centerMode&&n.props.axis===`horizontal`&&(c=g(g({},c),{},{minWidth:n.props.centerSlidePercentage+`%`})),n.state.swiping&&n.state.swipeMovementStarted&&(c=g(g({},c),{},{pointerEvents:`none`}));var l={ref:function(e){return n.setItemsRef(e,a)},key:`itemKey`+a+(e?`clone`:``),className:r.default.ITEM(!0,a===n.state.selectedItem,a===n.state.previousItem),onClick:n.handleClickItem.bind(n,a,i),style:c};return t.default.createElement(`li`,l,n.props.renderItem(i,{isSelected:a===n.state.selectedItem,isPrevious:a===n.state.previousItem}))}):[]}},{key:`renderControls`,value:function(){var e=this,n=this.props,r=n.showIndicators,i=n.labels,a=n.renderIndicator,o=n.children;return r?t.default.createElement(`ul`,{className:`control-dots`},t.Children.map(o,function(t,n){return a&&a(e.changeItem(n),n===e.state.selectedItem,n,i.item)})):null}},{key:`renderStatus`,value:function(){return this.props.showStatus?t.default.createElement(`p`,{className:`carousel-status`},this.props.statusFormatter(this.state.selectedItem+1,t.Children.count(this.props.children))):null}},{key:`renderThumbs`,value:function(){return!this.props.showThumbs||!this.props.children||t.Children.count(this.props.children)===0?null:t.default.createElement(i.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:`render`,value:function(){var e=this;if(!this.props.children||t.Children.count(this.props.children)===0)return null;var i=this.props.swipeable&&t.Children.count(this.props.children)>1,a=this.props.axis===`horizontal`,o=this.props.showArrows&&t.Children.count(this.props.children)>1,s=o&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,c=o&&(this.state.selectedItem{})),Bt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Carousel",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"CarouselProps",{enumerable:!0,get:function(){return n.CarouselProps}}),Object.defineProperty(e,"Thumbs",{enumerable:!0,get:function(){return r.default}});var t=i(Rt()),n=zt(),r=i(Pt());function i(e){return e&&e.__esModule?e:{default:e}}})),Vt=s(((e,t)=>{var n=A();t.exports=function(){return n.Date.now()}})),Ht=s(((e,t)=>{var n=/\s/;function r(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}t.exports=r})),Ut=s(((e,t)=>{var n=Ht(),r=/^\s+/;function i(e){return e&&e.slice(0,n(e)+1).replace(r,``)}t.exports=i})),Wt=s(((e,t)=>{var n=Ut(),r=re(),i=ne(),a=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;function u(e){if(typeof e==`number`)return e;if(i(e))return a;if(r(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=r(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=n(e);var u=s.test(e);return u||c.test(e)?l(e.slice(2),u?2:8):o.test(e)?a:+e}t.exports=u})),Gt=s(((e,t)=>{var n=re(),r=Vt(),i=Wt(),a=`Expected a function`,o=Math.max,s=Math.min;function c(e,t,c){var l,u,d,f,p,m,h=0,g=!1,_=!1,v=!0;if(typeof e!=`function`)throw TypeError(a);t=i(t)||0,n(c)&&(g=!!c.leading,_=`maxWait`in c,d=_?o(i(c.maxWait)||0,t):d,v=`trailing`in c?!!c.trailing:v);function y(t){var n=l,r=u;return l=u=void 0,h=t,f=e.apply(r,n),f}function b(e){return h=e,p=setTimeout(C,t),g?y(e):f}function x(e){var n=e-m,r=e-h,i=t-n;return _?s(i,d-r):i}function S(e){var n=e-m,r=e-h;return m===void 0||n>=t||n<0||_&&r>=d}function C(){var e=r();if(S(e))return w(e);p=setTimeout(C,x(e))}function w(e){return p=void 0,v&&l?y(e):(l=u=void 0,f)}function T(){p!==void 0&&clearTimeout(p),h=0,l=m=u=p=void 0}function E(){return p===void 0?f:w(r())}function D(){var e=r(),n=S(e);if(l=arguments,u=this,m=e,n){if(p===void 0)return b(m);if(_)return clearTimeout(p),p=setTimeout(C,t),y(m)}return p===void 0&&(p=setTimeout(C,t)),f}return D.cancel=T,D.flush=E,D}t.exports=c})),L=u(f(),1),Kt=u(Gt(),1);E();function qt(e,t,n,r,i=!1){let a=L.useRef();a.current=t,L.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;let t=n,o=e=>{a.current?.call(t,e)};return t.addEventListener(e,o,{passive:r,capture:i}),()=>{t.removeEventListener(e,o,{capture:i})}},[e,n,r,i])}function Jt(e,t){return e===void 0?void 0:t}var Yt=Math.PI;function Xt(e){return e*Yt/180}var Zt=(e,t,n)=>({x1:e-n/2,y1:t-n/2,x2:e+n/2,y2:t+n/2}),Qt=(e,t,n,r,i)=>{switch(e){case`left`:return Math.floor(t)+r+i/2;case`center`:return Math.floor(t+n/2);case`right`:return Math.floor(t+n)-r-i/2}},$t=(e,t,n)=>Math.min(e,t-n*2),en=(e,t,n)=>n.x1<=e&&e<=n.x2&&n.y1<=t&&t<=n.y2,tn=e=>{let t=e.fgColor??`currentColor`;return L.createElement(`svg`,{viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},L.createElement(`path`,{d:`M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929`,stroke:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,vectorEffect:`non-scaling-stroke`}),L.createElement(`path`,{d:`M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z`,stroke:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,vectorEffect:`non-scaling-stroke`}))},nn=e=>{let t=e.fgColor??`currentColor`;return L.createElement(`svg`,{viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},L.createElement(`path`,{d:`M19 6L10.3802 17L5.34071 11.8758`,vectorEffect:`non-scaling-stroke`,stroke:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}))};function rn(e,t,n){let[r,i]=L.useState(e),a=L.useRef(!0);L.useEffect(()=>()=>{a.current=!1},[]);let o=L.useRef((0,Kt.default)(e=>{a.current&&i(e)},n));return L.useLayoutEffect(()=>{a.current&&o.current(()=>e())},t),r}var an=RegExp(`^[^A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿]*[֑-߿יִ-﷽ﹰ-ﻼ]`);function R(e){return an.test(e)?`rtl`:`not-rtl`}var on=void 0;function sn(){if(typeof document>`u`)return 0;if(on!==void 0)return on;let e=document.createElement(`p`);e.style.width=`100%`,e.style.height=`200px`;let t=document.createElement(`div`);t.id=`testScrollbar`,t.style.position=`absolute`,t.style.top=`0px`,t.style.left=`0px`,t.style.visibility=`hidden`,t.style.width=`200px`,t.style.height=`150px`,t.style.overflow=`hidden`,t.append(e),document.body.append(t);let n=e.offsetWidth;t.style.overflow=`scroll`;let r=e.offsetWidth;return n===r&&(r=t.clientWidth),t.remove(),on=n-r,on}var cn=Symbol();function ln(e){let t=L.useRef([cn,e]);t.current[1]!==e&&(t.current[0]=e),t.current[1]=e;let[n,r]=L.useState(e),[,i]=L.useState(),a=L.useCallback(e=>{let n=t.current[0];n!==cn&&(e=typeof e==`function`?e(n):e,e===n)||(n!==cn&&i({}),r(t=>typeof e==`function`?e(n===cn?t:n):e),t.current[0]=cn)},[]),o=L.useCallback(()=>{t.current[0]=cn,i({})},[]);return[t.current[0]===cn?n:t.current[0],a,o]}function un(e){if(e.length===0)return``;let t=0,n=0;for(let r of e){if(n+=r.length,n>1e4)break;t++}return e.slice(0,t).join(`, `)}function dn(e){let t=L.useRef(e);return w(e,t.current)||(t.current=e),t.current}var fn=Bt(),pn=e=>{let{urls:t,canWrite:n,onEditClick:r,renderImage:i}=e,a=t.filter(e=>e!==``);if(a.length===0)return null;let o=a.length>1;return L.createElement(Ct,{"data-testid":`GDG-default-image-overlay-editor`},L.createElement(fn.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},a.map(e=>{let t=i?.(e)??L.createElement(`img`,{draggable:!1,src:e});return L.createElement(`div`,{className:`gdg-centering-container`,key:e},t)})),n&&r&&L.createElement(`button`,{className:`gdg-edit-icon`,onClick:r},L.createElement(tn,null)))};function z(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:``,highlight:null,hooks:null,langPrefix:`language-`,mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}var mn=z();function hn(e){mn=e}var gn=/[&<>"']/,_n=new RegExp(gn.source,`g`),vn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,yn=new RegExp(vn.source,`g`),bn={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},xn=e=>bn[e];function Sn(e,t){if(t){if(gn.test(e))return e.replace(_n,xn)}else if(vn.test(e))return e.replace(yn,xn);return e}var Cn=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function wn(e){return e.replace(Cn,(e,t)=>(t=t.toLowerCase(),t===`colon`?`:`:t.charAt(0)===`#`?t.charAt(1)===`x`?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):``))}var Tn=/(^|[^\[])\^/g;function En(e,t){e=typeof e==`string`?e:e.source,t||=``;let n={replace:(t,r)=>(r=r.source||r,r=r.replace(Tn,`$1`),e=e.replace(t,r),n),getRegex:()=>new RegExp(e,t)};return n}var Dn=/[^\w:]/g,On=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function kn(e,t,n){if(e){let e;try{e=decodeURIComponent(wn(n)).replace(Dn,``).toLowerCase()}catch{return null}if(e.indexOf(`javascript:`)===0||e.indexOf(`vbscript:`)===0||e.indexOf(`data:`)===0)return null}t&&!On.test(n)&&(n=Pn(t,n));try{n=encodeURI(n).replace(/%25/g,`%`)}catch{return null}return n}var An={},jn=/^[^:]+:\/*[^/]*$/,Mn=/^([^:]+:)[\s\S]*$/,Nn=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Pn(e,t){An[` `+e]||(jn.test(e)?An[` `+e]=e+`/`:An[` `+e]=Ln(e,`/`,!0)),e=An[` `+e];let n=e.indexOf(`:`)===-1;return t.substring(0,2)===`//`?n?t:e.replace(Mn,`$1`)+t:t.charAt(0)===`/`?n?t:e.replace(Nn,`$1`)+t:e+t}var Fn={exec:function(){}};function In(e,t){let n=e.replace(/\|/g,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(/ \|/),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Vn(e,t,n,r){let i=t.href,a=t.title?Sn(t.title):null,o=e[1].replace(/\\([\[\]])/g,`$1`);if(e[0].charAt(0)!==`!`){r.state.inLink=!0;let e={type:`link`,raw:n,href:i,title:a,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,e}return{type:`image`,raw:n,href:i,title:a,text:Sn(o)}}function Hn(e,t){let n=e.match(/^(\s+)(?:```)/);if(n===null)return t;let r=n[1];return t.split(` +`+e.stack}return{value:e,source:t,stack:i,digest:null}}function Ps(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Fs(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var Is=typeof WeakMap==`function`?WeakMap:Map;function Ls(e,t,n){n=co(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){pl||(pl=!0,ml=r),Fs(e,t)},n}function Rs(e,t,n){n=co(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Fs(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){Fs(e,t),typeof r!=`function`&&(hl===null?hl=new Set([this]):hl.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function zs(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Is;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=Xl.bind(null,e,t,n),t.then(e,e))}function Bs(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null||t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Vs(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=co(-1,1),t.tag=2,lo(n,t,1))),n.lanes|=1),e)}var Hs=C.ReactCurrentOwner,Us=!1;function Ws(e,t,n,r){t.child=e===null?Ga(t,null,n,r):Wa(t,e.child,n,r)}function Gs(e,t,n,r,i){n=n.render;var a=t.ref;return $a(t,i),r=Bo(e,t,n,r,a,i),n=Vo(),e!==null&&!Us?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,uc(e,t,i)):(Oa&&n&&wa(t),t.flags|=1,Ws(e,t,r,i),t.child)}function Ks(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!iu(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,qs(e,t,a,r,i)):(e=su(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Mr:n,n(o,r)&&e.ref===t.ref)return uc(e,t,i)}return t.flags|=1,e=ou(a,r),e.ref=t.ref,e.return=t,t.child=e}function qs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Mr(a,r)&&e.ref===t.ref)if(Us=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Us=!0);else return t.lanes=e.lanes,uc(e,t,i)}return Xs(e,t,n,r,i)}function Js(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`)if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Xi(nl,tl),tl|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Xi(nl,tl),tl|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,Xi(nl,tl),tl|=r}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),Xi(nl,tl),tl|=r;return Ws(e,t,i,n),t.child}function Ys(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Xs(e,t,n,r,i){var a=na(n)?ea:Qi.current;return a=ta(t,a),$a(t,i),n=Bo(e,t,n,r,a,i),r=Vo(),e!==null&&!Us?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,uc(e,t,i)):(Oa&&r&&wa(t),t.flags|=1,Ws(e,t,n,i),t.child)}function Zs(e,t,n,r,i){if(na(n)){var a=!0;oa(t)}else a=!1;if($a(t,i),t.stateNode===null)lc(e,t),As(t,n,r),Ms(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=eo(l):(l=na(n)?ea:Qi.current,l=ta(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&js(t,o,r,l),ao=!1;var f=t.memoizedState;o.state=f,po(t,r,o,i),c=t.memoizedState,s!==r||f!==c||$i.current||ao?(typeof u==`function`&&(Ds(t,n,u,r),c=t.memoizedState),(s=ao||ks(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,so(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:Es(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=eo(c):(c=na(n)?ea:Qi.current,c=ta(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&js(t,o,r,c),ao=!1,f=t.memoizedState,o.state=f,po(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||$i.current||ao?(typeof p==`function`&&(Ds(t,n,p,r),m=t.memoizedState),(l=ao||ks(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return Qs(e,t,n,r,a,i)}function Qs(e,t,n,r,i,a){Ys(e,t);var o=(t.flags&128)!=0;if(!r&&!o)return i&&sa(t,n,!1),uc(e,t,a);r=t.stateNode,Hs.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=Wa(t,e.child,null,a),t.child=Wa(t,null,s,a)):Ws(e,t,s,a),t.memoizedState=r.state,i&&sa(t,n,!0),t.child}function $s(e){var t=e.stateNode;t.pendingContext?ia(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ia(e,t.context,!1),bo(e,t.containerInfo)}function ec(e,t,n,r,i){return La(),Ra(i),t.flags|=256,Ws(e,t,n,r),t.child}var tc={dehydrated:null,treeContext:null,retryLane:0};function nc(e){return{baseLanes:e,cachePool:null,transitions:null}}function rc(e,t,n){var r=t.pendingProps,i=wo.current,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(i&2)!=0),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Xi(wo,i&1),e===null)return Na(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data===`$!`?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=lu(o,r,0,null),e=cu(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=nc(n),t.memoizedState=tc,e):ic(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return tee(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=ou(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=cu(a,o,n,null),a.flags|=2):a=ou(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?nc(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=tc,r}return a=e.child,e=a.sibling,r=ou(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function ic(e,t){return t=lu({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function ac(e,t,n,r){return r!==null&&Ra(r),Wa(t,e.child,null,n),e=ic(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function tee(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=Ps(Error(r(422))),ac(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=lu({mode:`visible`,children:i.children},a,0,null),o=cu(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&Wa(t,e.child,null,s),t.child.memoizedState=nc(s),t.memoizedState=tc,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return ac(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=Ps(o,i,void 0),ac(e,t,s,i)}if(c=(s&e.childLanes)!==0,Us||c){if(i=Qc,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,io(e,a),Tl(i,e,a,-1))}return zl(),i=Ps(Error(r(421))),ac(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=Ql.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,Da=Ni(a.nextSibling),Ea=t,Oa=!0,ka=null,e!==null&&(_a[va++]=ba,_a[va++]=xa,_a[va++]=ya,ba=e.id,xa=e.overflow,ya=t),t=ic(t,i.children),t.flags|=4096,t)}function oc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Qa(e.return,t,n)}function sc(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function cc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(Ws(e,t,r.children,n),r=wo.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&oc(e,n,t);else if(e.tag===19)oc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Xi(wo,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&To(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),sc(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&To(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}sc(t,!0,n,null,a);break;case`together`:sc(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function lc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function uc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),al|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=ou(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ou(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function nee(e,t,n){switch(t.tag){case 3:$s(t),La();break;case 5:So(t);break;case 1:na(t.type)&&oa(t);break;case 4:bo(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Xi(Ka,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Xi(wo,wo.current&1),e=uc(e,t,n),e===null?null:e.sibling):rc(e,t,n):(Xi(wo,wo.current&1),t.flags|=128,null);Xi(wo,wo.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return cc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Xi(wo,wo.current),r)break;return null;case 22:case 23:return t.lanes=0,Js(e,t,n)}return uc(e,t,n)}var dc=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},fc=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,yo(go.current);var o=null;switch(n){case`input`:i=_e(e,i),r=_e(e,r),o=[];break;case`select`:i=F({},i,{value:void 0}),r=F({},r,{value:void 0}),o=[];break;case`textarea`:i=Te(e,i),r=Te(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=Ci)}ze(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null));for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null))if(u===`style`)if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l;else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&li(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},pc=function(e,t,n,r){n!==r&&(t.flags|=4)};function mc(e,t){if(!Oa)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function hc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function gc(e,t,n){var i=t.pendingProps;switch(Ta(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return hc(t),null;case 1:return na(t.type)&&ra(),hc(t),null;case 3:return i=t.stateNode,xo(),Yi($i),Yi(Qi),Do(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Fa(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ka!==null&&(kl(ka),ka=null))),hc(t),null;case 5:Co(t);var o=yo(vo.current);if(n=t.type,e!==null&&t.stateNode!=null)fc(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return hc(t),null}if(e=yo(go.current),Fa(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[Ii]=t,i[Li]=s,e=(t.mode&1)!=0,n){case`dialog`:li(`cancel`,i),li(`close`,i);break;case`iframe`:case`object`:case`embed`:li(`load`,i);break;case`video`:case`audio`:for(o=0;o<\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Ii]=t,e[Li]=i,dc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Be(n,i),n){case`dialog`:li(`cancel`,e),li(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:li(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;odl&&(t.flags|=128,i=!0,mc(s,!1),t.lanes=4194304)}else{if(!i)if(e=To(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),mc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!Oa)return hc(t),null}else 2*yt()-s.renderingStartTime>dl&&n!==1073741824&&(t.flags|=128,i=!0,mc(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(hc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=yt(),t.sibling=null,n=wo.current,Xi(wo,i?n&1|2:n&1),t);case 22:case 23:return Fl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?tl&1073741824&&(hc(t),t.subtreeFlags&6&&(t.flags|=8192)):hc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function _c(e,t){switch(Ta(t),t.tag){case 1:return na(t.type)&&ra(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xo(),Yi($i),Yi(Qi),Do(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Co(t),null;case 13:if(Yi(wo),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));La()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Yi(wo),null;case 4:return xo(),null;case 10:return Za(t.type._context),null;case 22:case 23:return Fl(),null;case 24:return null;default:return null}}var vc=!1,yc=!1,bc=typeof WeakSet==`function`?WeakSet:Set,xc=null;function Sc(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){Yl(e,t,n)}else n.current=null}function Cc(e,t,n){try{n()}catch(n){Yl(e,t,n)}}var wc=!1;function Tc(e,t){if(wi=hn,e=Ir(),Lr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ti={focusedElem:e,selectionRange:n},hn=!1,xc=t;xc!==null;)if(t=xc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,xc=e;else for(;xc!==null;){t=xc;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:Es(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){Yl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,xc=e;break}xc=t.return}return h=wc,wc=!1,h}function Ec(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&Cc(t,n,a)}i=i.next}while(i!==r)}}function Dc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Oc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function kc(e){var t=e.alternate;t!==null&&(e.alternate=null,kc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ii],delete t[Li],delete t[zi],delete t[Bi],delete t[Vi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ac(e){return e.tag===5||e.tag===3||e.tag===4}function jc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Ac(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Mc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ci));else if(r!==4&&(e=e.child,e!==null))for(Mc(e,t,n),e=e.sibling;e!==null;)Mc(e,t,n),e=e.sibling}function Nc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Nc(e,t,n),e=e.sibling;e!==null;)Nc(e,t,n),e=e.sibling}var Pc=null,Fc=!1;function Ic(e,t,n){for(n=n.child;n!==null;)Lc(e,t,n),n=n.sibling}function Lc(e,t,n){if(Dt&&typeof Dt.onCommitFiberUnmount==`function`)try{Dt.onCommitFiberUnmount(Et,n)}catch{}switch(n.tag){case 5:yc||Sc(n,t);case 6:var r=Pc,i=Fc;Pc=null,Ic(e,t,n),Pc=r,Fc=i,Pc!==null&&(Fc?(e=Pc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pc.removeChild(n.stateNode));break;case 18:Pc!==null&&(Fc?(e=Pc,n=n.stateNode,e.nodeType===8?Mi(e.parentNode,n):e.nodeType===1&&Mi(e,n),z(e)):Mi(Pc,n.stateNode));break;case 4:r=Pc,i=Fc,Pc=n.stateNode.containerInfo,Fc=!0,Ic(e,t,n),Pc=r,Fc=i;break;case 0:case 11:case 14:case 15:if(!yc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&Cc(n,t,o),i=i.next}while(i!==r)}Ic(e,t,n);break;case 1:if(!yc&&(Sc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Yl(n,t,e)}Ic(e,t,n);break;case 21:Ic(e,t,n);break;case 22:n.mode&1?(yc=(r=yc)||n.memoizedState!==null,Ic(e,t,n),yc=r):Ic(e,t,n);break;default:Ic(e,t,n)}}function Rc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new bc),t.forEach(function(t){var r=$l.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function zc(e,t){var n=t.deletions;if(n!==null)for(var i=0;ia&&(a=s),i&=~o}if(i=a,i=yt()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*qc(i/1960))-i,10e?16:e,_l===null)var i=!1;else{if(e=_l,_l=null,vl=0,Zc&6)throw Error(r(331));var a=Zc;for(Zc|=4,xc=e.current;xc!==null;){var o=xc,s=o.child;if(xc.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lyt()-ul?Il(e,0):sl|=n),El(e,t)}function Zl(e,t){t===0&&(e.mode&1?(t=Pt,Pt<<=1,!(Pt&130023424)&&(Pt=4194304)):t=1);var n=Cl();e=io(e,t),e!==null&&(Ht(e,t,n),El(e,n))}function Ql(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Zl(e,n)}function $l(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Zl(e,n)}var eu=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||$i.current)Us=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Us=!1,nee(e,t,n);Us=!!(e.flags&131072)}else Us=!1,Oa&&t.flags&1048576&&Ca(t,ga,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;lc(e,t),e=t.pendingProps;var a=ta(t,Qi.current);$a(t,n),a=Bo(null,t,i,e,a,n);var o=Vo();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,na(i)?(o=!0,oa(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,oo(t),a.updater=Os,t.stateNode=a,a._reactInternals=t,Ms(t,i,e,n),t=Qs(null,t,i,!0,o,n)):(t.tag=0,Oa&&o&&wa(t),Ws(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(lc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=au(i),e=Es(i,e),a){case 0:t=Xs(null,t,i,e,n);break a;case 1:t=Zs(null,t,i,e,n);break a;case 11:t=Gs(null,t,i,e,n);break a;case 14:t=Ks(null,t,i,Es(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),Xs(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),Zs(e,t,i,a,n);case 3:a:{if($s(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,so(e,t),po(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ns(Error(r(423)),t),t=ec(e,t,i,n,a);break a}else if(i!==a){a=Ns(Error(r(424)),t),t=ec(e,t,i,n,a);break a}else for(Da=Ni(t.stateNode.containerInfo.firstChild),Ea=t,Oa=!0,ka=null,n=Ga(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(La(),i===a){t=uc(e,t,n);break a}Ws(e,t,i,n)}t=t.child}return t;case 5:return So(t),e===null&&Na(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,Ei(i,a)?s=null:o!==null&&Ei(i,o)&&(t.flags|=32),Ys(e,t),Ws(e,t,s,n),t.child;case 6:return e===null&&Na(t),null;case 13:return rc(e,t,n);case 4:return bo(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Wa(t,null,i,n):Ws(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),Gs(e,t,i,a,n);case 7:return Ws(e,t,t.pendingProps,n),t.child;case 8:return Ws(e,t,t.pendingProps.children,n),t.child;case 12:return Ws(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Xi(Ka,i._currentValue),i._currentValue=s,o!==null)if(jr(o.value,s)){if(o.children===a.children&&!$i.current){t=uc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=co(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Qa(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Qa(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Ws(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,$a(t,n),a=eo(a),i=i(a),t.flags|=1,Ws(e,t,i,n),t.child;case 14:return i=t.type,a=Es(i,t.pendingProps),a=Es(i.type,a),Ks(e,t,i,a,n);case 15:return qs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:Es(i,a),lc(e,t),t.tag=1,na(i)?(e=!0,oa(t)):e=!1,$a(t,n),As(t,i,a),Ms(t,i,a,n),Qs(null,t,i,!0,e,n);case 19:return cc(e,t,n);case 22:return Js(e,t,n)}throw Error(r(156,t.tag))};function tu(e,t){return ht(e,t)}function nu(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ru(e,t,n,r){return new nu(e,t,n,r)}function iu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function au(e){if(typeof e==`function`)return+!!iu(e);if(e!=null){if(e=e.$$typeof,e===j)return 11;if(e===N)return 14}return 2}function ou(e,t){var n=e.alternate;return n===null?(n=ru(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function su(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)iu(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return cu(n.children,a,o,t);case D:s=8,a|=8;break;case O:return e=ru(12,n,t,a|2),e.elementType=O,e.lanes=o,e;case M:return e=ru(13,n,t,a),e.elementType=M,e.lanes=o,e;case ee:return e=ru(19,n,t,a),e.elementType=ee,e.lanes=o,e;case ne:return lu(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case k:s=10;break a;case A:s=9;break a;case j:s=11;break a;case N:s=14;break a;case te:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=ru(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function cu(e,t,n,r){return e=ru(7,e,r,t),e.lanes=n,e}function lu(e,t,n,r){return e=ru(22,e,r,t),e.elementType=ne,e.lanes=n,e.stateNode={isHidden:!1},e}function uu(e,t,n){return e=ru(6,e,null,t),e.lanes=n,e}function du(e,t,n){return t=ru(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function fu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Vt(0),this.expirationTimes=Vt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function pu(e,t,n,r,i,a,o,s,c){return e=new fu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=ru(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},oo(a),e}function mu(e,t,n){var r=3{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=s((e=>{var t=g();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),v=u(f(),1),y=_();function b(e=`This should not happen`){throw Error(e)}function x(e,t=`Assertion failed`){if(!e)return b(t)}function S(e,t){return b(t??`Hell froze over`)}function C(e,t){try{return e()}catch{return t}}function w(e,t){let n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&w(e[r],t[r]););return r===-1}if(!n||typeof e==`object`){for(n in r=0,e)if(T.call(e,n)&&++r&&!T.call(t,n)||!(n in t)||!w(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var T,E=o((()=>{T=Object.prototype.hasOwnProperty})),D=s(((e,t)=>{var n=Object.prototype.hasOwnProperty;function r(e,t){return e!=null&&n.call(e,t)}t.exports=r})),O=s(((e,t)=>{t.exports=Array.isArray})),k=s(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),A=s(((e,t)=>{var n=k(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),j=s(((e,t)=>{t.exports=A().Symbol})),M=s(((e,t)=>{var n=j(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),ee=s(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),N=s(((e,t)=>{var n=j(),r=M(),i=ee(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),te=s(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),ne=s(((e,t)=>{var n=N(),r=te(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),P=s(((e,t)=>{var n=O(),r=ne(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),re=s(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),F=s(((e,t)=>{var n=N(),r=re(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),ie=s(((e,t)=>{t.exports=A()[`__core-js_shared__`]})),ae=s(((e,t)=>{var n=ie(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),oe=s(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),se=s(((e,t)=>{var n=F(),r=ae(),i=re(),a=oe(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),ce=s(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),le=s(((e,t)=>{var n=se(),r=ce();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),ue=s(((e,t)=>{t.exports=le()(Object,`create`)})),de=s(((e,t)=>{var n=ue();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),fe=s(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}t.exports=n})),pe=s(((e,t)=>{var n=ue(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),me=s(((e,t)=>{var n=ue(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),he=s(((e,t)=>{var n=ue(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=+!this.has(e),i[e]=n&&t===void 0?r:t,this}t.exports=i})),ge=s(((e,t)=>{var n=de(),r=fe(),i=pe(),a=me(),o=he();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{function n(){this.__data__=[],this.size=0}t.exports=n})),ve=s(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),ye=s(((e,t)=>{var n=ve();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),be=s(((e,t)=>{var n=ye(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),xe=s(((e,t)=>{var n=ye();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),Se=s(((e,t)=>{var n=ye();function r(e){return n(this.__data__,e)>-1}t.exports=r})),Ce=s(((e,t)=>{var n=ye();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),we=s(((e,t)=>{var n=_e(),r=be(),i=xe(),a=Se(),o=Ce();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{t.exports=le()(A(),`Map`)})),Ee=s(((e,t)=>{var n=ge(),r=we(),i=Te();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),De=s(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),Oe=s(((e,t)=>{var n=De();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),ke=s(((e,t)=>{var n=Oe();function r(e){var t=n(this,e).delete(e);return this.size-=+!!t,t}t.exports=r})),Ae=s(((e,t)=>{var n=Oe();function r(e){return n(this,e).get(e)}t.exports=r})),je=s(((e,t)=>{var n=Oe();function r(e){return n(this,e).has(e)}t.exports=r})),Me=s(((e,t)=>{var n=Oe();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),Ne=s(((e,t)=>{var n=Ee(),r=ke(),i=Ae(),a=je(),o=Me();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{var n=Ne(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),Fe=s(((e,t)=>{var n=Pe(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),Ie=s(((e,t)=>{var n=Fe(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),Le=s(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n{var n=j(),r=Le(),i=O(),a=ne(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),ze=s(((e,t)=>{var n=Re();function r(e){return e==null?``:n(e)}t.exports=r})),Be=s(((e,t)=>{var n=O(),r=P(),i=Ie(),a=ze();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),Ve=s(((e,t)=>{var n=N(),r=te(),i=`[object Arguments]`;function a(e){return r(e)&&n(e)==i}t.exports=a})),He=s(((e,t)=>{var n=Ve(),r=te(),i=Object.prototype,a=i.hasOwnProperty,o=i.propertyIsEnumerable;t.exports=n(function(){return arguments}())?n:function(e){return r(e)&&a.call(e,`callee`)&&!o.call(e,`callee`)}})),Ue=s(((e,t)=>{var n=/^(?:0|[1-9]\d*)$/;function r(e,t){var r=typeof e;return t??=9007199254740991,!!t&&(r==`number`||r!=`symbol`&&n.test(e))&&e>-1&&e%1==0&&e{function n(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=9007199254740991}t.exports=n})),Ge=s(((e,t)=>{var n=ne(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),Ke=s(((e,t)=>{var n=Be(),r=He(),i=O(),a=Ue(),o=We(),s=Ge();function c(e,t,c){t=n(t,e);for(var l=-1,u=t.length,d=!1;++l{var n=D(),r=Ke();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i}));function Je(e){return`width`in e&&typeof e.width==`number`}async function Ye(e){return typeof e==`object`?e:await e()}function Xe(e){return!(e.kind===I.Loading||e.kind===I.Bubble||e.kind===I.RowID||e.kind===I.Protected||e.kind===I.Drilldown)}function Ze(e){return e.kind===at.Marker||e.kind===at.NewRow}function Qe(e){if(!Xe(e)||e.kind===I.Image)return!1;if(e.kind===I.Text||e.kind===I.Number||e.kind===I.Markdown||e.kind===I.Uri||e.kind===I.Custom||e.kind===I.Boolean)return e.readonly!==!0;S(e,`A cell was passed with an invalid kind`)}function $e(e){return(0,nt.default)(e,`editor`)}function et(e){return!(e.readonly??!1)}function tt(e){if(e.length===0)return[];let t=[...e],n=[];t.sort(function(e,t){return e[0]-t[0]}),n.push([...t[0]]);for(let e of t.slice(1)){let t=n[n.length-1];t[1]{E(),nt=u(qe(),1),(function(e){e.Uri=`uri`,e.Text=`text`,e.Image=`image`,e.RowID=`row-id`,e.Number=`number`,e.Bubble=`bubble`,e.Boolean=`boolean`,e.Loading=`loading`,e.Markdown=`markdown`,e.Drilldown=`drilldown`,e.Protected=`protected`,e.Custom=`custom`})(I||={}),(function(e){e.HeaderRowID=`headerRowID`,e.HeaderCode=`headerCode`,e.HeaderNumber=`headerNumber`,e.HeaderString=`headerString`,e.HeaderBoolean=`headerBoolean`,e.HeaderAudioUri=`headerAudioUri`,e.HeaderVideoUri=`headerVideoUri`,e.HeaderEmoji=`headerEmoji`,e.HeaderImage=`headerImage`,e.HeaderUri=`headerUri`,e.HeaderPhone=`headerPhone`,e.HeaderMarkdown=`headerMarkdown`,e.HeaderDate=`headerDate`,e.HeaderTime=`headerTime`,e.HeaderEmail=`headerEmail`,e.HeaderReference=`headerReference`,e.HeaderIfThenElse=`headerIfThenElse`,e.HeaderSingleValue=`headerSingleValue`,e.HeaderLookup=`headerLookup`,e.HeaderTextTemplate=`headerTextTemplate`,e.HeaderMath=`headerMath`,e.HeaderRollup=`headerRollup`,e.HeaderJoinStrings=`headerJoinStrings`,e.HeaderSplitString=`headerSplitString`,e.HeaderGeoDistance=`headerGeoDistance`,e.HeaderArray=`headerArray`,e.RowOwnerOverlay=`rowOwnerOverlay`,e.ProtectedColumnOverlay=`protectedColumnOverlay`})(rt||={}),(function(e){e.Triangle=`triangle`,e.Dots=`dots`})(it||={}),(function(e){e.NewRow=`new-row`,e.Marker=`marker`})(at||={}),st=class e{items;constructor(e){this.items=e}static empty=()=>ot??=new e([]);static fromSingleSelection=t=>e.empty().add(t);offset(t){if(t===0)return this;let n=this.items.map(e=>[e[0]+t,e[1]+t]);return new e(n)}add(t){let n=typeof t==`number`?[t,t+1]:t,r=tt([...this.items,n]);return new e(r)}remove(t){let n=[...this.items],r=typeof t==`number`?t:t[0],i=typeof t==`number`?t+1:t[1];for(let[e,t]of n.entries()){let[a,o]=t;if(a<=i&&r<=o){let t=[];a=n&&e{})),dt,ft,pt=o((()=>{ut(),dt=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,ft=lt(function(e){return dt.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91})})),mt,ht=o((()=>{mt=function(){let e=Array.prototype.slice.call(arguments).filter(Boolean),t={},n=[];e.forEach(e=>{(e?e.split(` `):[]).forEach(e=>{if(e.startsWith(`atm_`)){let[,n]=e.split(`_`);t[n]=e}else n.push(e)})});let r=[];for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.push(t[e]);return r.push(...n),r.join(` `)}}));function gt(e,t,n){let r=bt(t,n);if(!e){let e=typeof ft==`function`?{default:ft}:ft;Object.keys(r).forEach(t=>{e.default(t)||delete r[t]})}return r}function _t(e){return t=>{let n=(n,r)=>{let{as:i=e,class:a=``}=n,o=gt(t.propsAsIs===void 0?!(typeof i==`string`&&i.indexOf(`-`)===-1&&!vt(i[0])):t.propsAsIs,n,[`as`,`class`]);o.ref=r,o.className=t.atomic?mt(t.class,o.className||a):mt(o.className||a,t.class);let{vars:s}=t;if(s){let e={};for(let r in s){let i=s[r],a=i[0],o=i[1]||``,c=typeof a==`function`?a(n):a;t.name,e[`--${r}`]=`${c}${o}`}let r=o.style||{},i=Object.keys(r);i.length>0&&i.forEach(t=>{e[t]=r[t]}),o.style=e}return e.__linaria&&e!==i?(o.as=i,v.createElement(e,o)):v.createElement(i,o)},r=v.forwardRef?v.forwardRef(n):e=>{let t=bt(e,[`innerRef`]);return n(t,e.innerRef)};return r.displayName=t.name,r.__linaria={className:t.class||``,extends:e},r}}var vt,yt,bt,xt,St=o((()=>{pt(),ht(),vt=e=>e.toUpperCase()===e,yt=e=>t=>e.indexOf(t)===-1,bt=(e,t)=>{let n={};return Object.keys(e).filter(yt(t)).forEach(t=>{n[t]=e[t]}),n},xt=_t}));St();var Ct=xt(`div`)({name:`ImageOverlayEditorStyle`,class:`gdg-i2iowwq`,propsAsIs:!1}),wt=s(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Tt=s(((e,t)=>{var n=wt();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Et=s(((e,t)=>{t.exports=Tt()()})),Dt=s((e=>{(function(t,n){if(typeof define==`function`&&define.amd)define([`exports`,`react`,`prop-types`],n);else if(e!==void 0)n(e,f(),Et());else{var r={exports:{}};n(r.exports,t.react,t.propTypes),t.reactSwipe=r.exports}})(e,function(e,t,n){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var r=a(t),i=a(n);function a(e){return e&&e.__esModule?e:{default:e}}var o=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function c(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}var l=function(){function e(e,t){for(var n=0;n0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return f?e:e.capture}function h(e){if(`touches`in e){var t=e.touches[0];return{x:t.pageX,y:t.pageY}}return{x:e.screenX,y:e.screenY}}var g=function(e){d(t,e);function t(){var e;c(this,t);var n=[...arguments],r=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(n)));return r._handleSwipeStart=r._handleSwipeStart.bind(r),r._handleSwipeMove=r._handleSwipeMove.bind(r),r._handleSwipeEnd=r._handleSwipeEnd.bind(r),r._onMouseDown=r._onMouseDown.bind(r),r._onMouseMove=r._onMouseMove.bind(r),r._onMouseUp=r._onMouseUp.bind(r),r._setSwiperRef=r._setSwiperRef.bind(r),r}return l(t,[{key:`componentDidMount`,value:function(){this.swiper&&this.swiper.addEventListener(`touchmove`,this._handleSwipeMove,m({capture:!0,passive:!1}))}},{key:`componentWillUnmount`,value:function(){this.swiper&&this.swiper.removeEventListener(`touchmove`,this._handleSwipeMove,m({capture:!0,passive:!1}))}},{key:`_onMouseDown`,value:function(e){this.props.allowMouseEvents&&(this.mouseDown=!0,document.addEventListener(`mouseup`,this._onMouseUp),document.addEventListener(`mousemove`,this._onMouseMove),this._handleSwipeStart(e))}},{key:`_onMouseMove`,value:function(e){this.mouseDown&&this._handleSwipeMove(e)}},{key:`_onMouseUp`,value:function(e){this.mouseDown=!1,document.removeEventListener(`mouseup`,this._onMouseUp),document.removeEventListener(`mousemove`,this._onMouseMove),this._handleSwipeEnd(e)}},{key:`_handleSwipeStart`,value:function(e){var t=h(e),n=t.x,r=t.y;this.moveStart={x:n,y:r},this.props.onSwipeStart(e)}},{key:`_handleSwipeMove`,value:function(e){if(this.moveStart){var t=h(e),n=t.x,r=t.y,i=n-this.moveStart.x,a=r-this.moveStart.y;this.moving=!0,this.props.onSwipeMove({x:i,y:a},e)&&e.cancelable&&e.preventDefault(),this.movePosition={deltaX:i,deltaY:a}}}},{key:`_handleSwipeEnd`,value:function(e){this.props.onSwipeEnd(e);var t=this.props.tolerance;this.moving&&this.movePosition&&(this.movePosition.deltaX<-t?this.props.onSwipeLeft(1,e):this.movePosition.deltaX>t&&this.props.onSwipeRight(1,e),this.movePosition.deltaY<-t?this.props.onSwipeUp(1,e):this.movePosition.deltaY>t&&this.props.onSwipeDown(1,e)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:`_setSwiperRef`,value:function(e){this.swiper=e,this.props.innerRef(e)}},{key:`render`,value:function(){var e=this.props;e.tagName;var t=e.className,n=e.style,i=e.children;e.allowMouseEvents,e.onSwipeUp,e.onSwipeDown,e.onSwipeLeft,e.onSwipeRight,e.onSwipeStart,e.onSwipeMove,e.onSwipeEnd,e.innerRef,e.tolerance;var a=s(e,[`tagName`,`className`,`style`,`children`,`allowMouseEvents`,`onSwipeUp`,`onSwipeDown`,`onSwipeLeft`,`onSwipeRight`,`onSwipeStart`,`onSwipeMove`,`onSwipeEnd`,`innerRef`,`tolerance`]);return r.default.createElement(this.props.tagName,o({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:t,style:n},a),i)}}]),t}(t.Component);g.displayName=`ReactSwipe`,g.propTypes={tagName:i.default.string,className:i.default.string,style:i.default.object,children:i.default.node,allowMouseEvents:i.default.bool,onSwipeUp:i.default.func,onSwipeDown:i.default.func,onSwipeLeft:i.default.func,onSwipeRight:i.default.func,onSwipeStart:i.default.func,onSwipeMove:i.default.func,onSwipeEnd:i.default.func,innerRef:i.default.func,tolerance:i.default.number.isRequired},g.defaultProps={tagName:`div`,allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},e.default=g})})),Ot=s((e=>{(function(t,n){if(typeof define==`function`&&define.amd)define([`exports`,`./react-swipe`],n);else if(e!==void 0)n(e,Dt());else{var r={exports:{}};n(r.exports,t.reactSwipe),t.index=r.exports}})(e,function(e,t){Object.defineProperty(e,"__esModule",{value:!0});var n=r(t);function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default})})),kt=s(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(kt());function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e.default={ROOT:function(e){return(0,t.default)(r({"carousel-root":!0},e||``,!!e))},CAROUSEL:function(e){return(0,t.default)({carousel:!0,"carousel-slider":e})},WRAPPER:function(e,n){return(0,t.default)({"thumbs-wrapper":!e,"slider-wrapper":e,"axis-horizontal":n===`horizontal`,"axis-vertical":n!==`horizontal`})},SLIDER:function(e,n){return(0,t.default)({thumbs:!e,slider:e,animated:!n})},ITEM:function(e,n,r){return(0,t.default)({thumb:!e,slide:e,selected:n,previous:r})},ARROW_PREV:function(e){return(0,t.default)({"control-arrow control-prev":!0,"control-disabled":e})},ARROW_NEXT:function(e){return(0,t.default)({"control-arrow control-next":!0,"control-disabled":e})},DOT:function(e){return(0,t.default)({dot:!0,selected:e})}}})),jt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.outerWidth=void 0,e.outerWidth=function(e){var t=e.offsetWidth,n=getComputedStyle(e);return t+=parseInt(n.marginLeft)+parseInt(n.marginRight),t}})),Mt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(e,t,n){var r=e===0?e:e+t;return`translate3d`+(`(`+(n===`horizontal`?[r,0,0]:[0,r,0]).join(`,`)+`)`)}})),Nt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(){return window}})),Pt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=l(f()),n=s(At()),r=jt(),i=s(Mt()),a=s(Ot()),o=s(Nt());function s(e){return e&&e.__esModule?e:{default:e}}function c(){if(typeof WeakMap!=`function`)return null;var e=new WeakMap;return c=function(){return e},e}function l(e){if(e&&e.__esModule)return e;if(e===null||u(e)!==`object`&&typeof e!=`function`)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=r?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(){return d=Object.assign||function(e){for(var t=1;t`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function S(e){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},S(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=function(e){return e.hasOwnProperty(`key`)},T=function(e){g(c,e);var s=v(c);function c(e){var n;return p(this,c),n=s.call(this,e),C(b(n),`itemsWrapperRef`,void 0),C(b(n),`itemsListRef`,void 0),C(b(n),`thumbsRef`,void 0),C(b(n),`setItemsWrapperRef`,function(e){n.itemsWrapperRef=e}),C(b(n),`setItemsListRef`,function(e){n.itemsListRef=e}),C(b(n),`setThumbsRef`,function(e,t){n.thumbsRef||=[],n.thumbsRef[t]=e}),C(b(n),`updateSizes`,function(){if(!(!n.props.children||!n.itemsWrapperRef||!n.thumbsRef)){var e=t.Children.count(n.props.children),i=n.itemsWrapperRef.clientWidth,a=n.props.thumbWidth?n.props.thumbWidth:(0,r.outerWidth)(n.thumbsRef[0]),o=Math.floor(i/a),s=o0&&(r=0),s===c&&r<0&&(r=0);var l=s+100/(n.itemsWrapperRef.clientWidth/r);return n.itemsListRef&&[`WebkitTransform`,`MozTransform`,`MsTransform`,`OTransform`,`transform`,`msTransform`].forEach(function(e){n.itemsListRef.style[e]=(0,i.default)(l,`%`,n.props.axis)}),!0}),C(b(n),`slideRight`,function(e){n.moveTo(n.state.firstItem-(typeof e==`number`?e:1))}),C(b(n),`slideLeft`,function(e){n.moveTo(n.state.firstItem+(typeof e==`number`?e:1))}),C(b(n),`moveTo`,function(e){e=e<0?0:e,e=e>=n.state.lastPosition?n.state.lastPosition:e,n.setState({firstItem:e})}),n.state={selectedItem:e.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},n}return h(c,[{key:`componentDidMount`,value:function(){this.setupThumbs()}},{key:`componentDidUpdate`,value:function(e){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==e.children&&this.updateSizes()}},{key:`componentWillUnmount`,value:function(){this.destroyThumbs()}},{key:`setupThumbs`,value:function(){(0,o.default)().addEventListener(`resize`,this.updateSizes),(0,o.default)().addEventListener(`DOMContentLoaded`,this.updateSizes),this.updateSizes()}},{key:`destroyThumbs`,value:function(){(0,o.default)().removeEventListener(`resize`,this.updateSizes),(0,o.default)().removeEventListener(`DOMContentLoaded`,this.updateSizes)}},{key:`getFirstItem`,value:function(e){var t=e;return e>=this.state.lastPosition&&(t=this.state.lastPosition),e1,o=this.state.showArrows&&this.state.firstItem>0,s=this.state.showArrows&&this.state.firstItem{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(){return document}})),It=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setPosition=e.getPosition=e.isKeyboardEvent=e.defaultStatusFormatter=e.noop=void 0;var t=f(),n=r(Mt());function r(e){return e&&e.__esModule?e:{default:e}}e.noop=function(){},e.defaultStatusFormatter=function(e,t){return`${e} of ${t}`},e.isKeyboardEvent=function(e){return e?e.hasOwnProperty(`key`):!1},e.getPosition=function(e,n){if(n.infiniteLoop&&++e,e===0)return 0;var r=t.Children.count(n.children);if(n.centerMode&&n.axis===`horizontal`){var i=-e*n.centerSlidePercentage,a=r-1;return e&&(e!==a||n.infiniteLoop)?i+=(100-n.centerSlidePercentage)/2:e===a&&(i+=100-n.centerSlidePercentage),i}return-e*100},e.setPosition=function(e,t){var r={};return[`WebkitTransform`,`MozTransform`,`MsTransform`,`OTransform`,`transform`,`msTransform`].forEach(function(i){r[i]=(0,n.default)(e,`%`,t)}),r}})),Lt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.fadeAnimationHandler=e.slideStopSwipingHandler=e.slideSwipeAnimationHandler=e.slideAnimationHandler=void 0;var t=f(),n=i(Mt()),r=It();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function o(e){for(var t=1;tl))return c<0?e.centerMode&&e.centerSlidePercentage&&e.axis===`horizontal`?a.itemListStyle=(0,r.setPosition)(-(l+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):a.itemListStyle=(0,r.setPosition)(-(l+2)*100,e.axis):c>l&&(a.itemListStyle=(0,r.setPosition)(0,e.axis)),a;var u=(0,r.getPosition)(s,e),d=(0,n.default)(u,`%`,e.axis),f=e.transitionTime+`ms`;return a.itemListStyle={WebkitTransform:d,msTransform:d,OTransform:d,transform:d},i.swiping||(a.itemListStyle=o(o({},a.itemListStyle),{},{WebkitTransitionDuration:f,MozTransitionDuration:f,OTransitionDuration:f,transitionDuration:f,msTransitionDuration:f})),a},e.slideSwipeAnimationHandler=function(e,n,i,a){var o={},s=n.axis===`horizontal`,c=t.Children.count(n.children),l=0,u=(0,r.getPosition)(i.selectedItem,n),d=n.infiniteLoop?(0,r.getPosition)(c-1,n)-100:(0,r.getPosition)(c-1,n),f=s?e.x:e.y,p=f;u===l&&f>0&&(p=0),u===d&&f<0&&(p=0);var m=u+100/(i.itemSize/p),h=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&h&&(i.selectedItem===0&&m>-100?m-=c*100:i.selectedItem===c-1&&m<-c*100&&(m+=c*100)),(!n.preventMovementUntilSwipeScrollTolerance||h||i.swipeMovementStarted)&&(i.swipeMovementStarted||a({swipeMovementStarted:!0}),o.itemListStyle=(0,r.setPosition)(m,n.axis)),h&&!i.cancelClick&&a({cancelClick:!0}),o},e.slideStopSwipingHandler=function(e,t){var n=(0,r.getPosition)(t.selectedItem,e);return{itemListStyle:(0,r.setPosition)(n,e.axis)}},e.fadeAnimationHandler=function(e,t){var n=e.transitionTime+`ms`,r=`ease-in-out`,i={position:`absolute`,display:`block`,zIndex:-2,minHeight:`100%`,opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:r,msTransitionTimingFunction:r,MozTransitionTimingFunction:r,WebkitTransitionTimingFunction:r,OTransitionTimingFunction:r};return t.swiping||(i=o(o({},i),{},{WebkitTransitionDuration:n,MozTransitionDuration:n,OTransitionDuration:n,transitionDuration:n,msTransitionDuration:n})),{slideStyle:i,selectedStyle:o(o({},i),{},{opacity:1,position:`relative`}),prevStyle:o({},i)}}})),Rt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=d(f()),n=l(Ot()),r=l(At()),i=l(Pt()),a=l(Ft()),o=l(Nt()),s=It(),c=Lt();function l(e){return e&&e.__esModule?e:{default:e}}function u(){if(typeof WeakMap!=`function`)return null;var e=new WeakMap;return u=function(){return e},e}function d(e){if(e&&e.__esModule)return e;if(e===null||p(e)!==`object`&&typeof e!=`function`)return{default:e};var t=u();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=r?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(){return m=Object.assign||function(e){for(var t=1;t`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function D(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O=function(e){b(u,e);var l=S(u);function u(e){var n;_(this,u),n=l.call(this,e),D(w(n),`thumbsRef`,void 0),D(w(n),`carouselWrapperRef`,void 0),D(w(n),`listRef`,void 0),D(w(n),`itemsRef`,void 0),D(w(n),`timer`,void 0),D(w(n),`animationHandler`,void 0),D(w(n),`setThumbsRef`,function(e){n.thumbsRef=e}),D(w(n),`setCarouselWrapperRef`,function(e){n.carouselWrapperRef=e}),D(w(n),`setListRef`,function(e){n.listRef=e}),D(w(n),`setItemsRef`,function(e,t){n.itemsRef||=[],n.itemsRef[t]=e}),D(w(n),`autoPlay`,function(){t.Children.count(n.props.children)<=1||(n.clearAutoPlay(),n.props.autoPlay&&(n.timer=setTimeout(function(){n.increment()},n.props.interval)))}),D(w(n),`clearAutoPlay`,function(){n.timer&&clearTimeout(n.timer)}),D(w(n),`resetAutoPlay`,function(){n.clearAutoPlay(),n.autoPlay()}),D(w(n),`stopOnHover`,function(){n.setState({isMouseEntered:!0},n.clearAutoPlay)}),D(w(n),`startOnLeave`,function(){n.setState({isMouseEntered:!1},n.autoPlay)}),D(w(n),`isFocusWithinTheCarousel`,function(){return n.carouselWrapperRef?!!((0,a.default)().activeElement===n.carouselWrapperRef||n.carouselWrapperRef.contains((0,a.default)().activeElement)):!1}),D(w(n),`navigateWithKeyboard`,function(e){if(n.isFocusWithinTheCarousel()){var t=n.props.axis===`horizontal`,r={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},i=t?r.ArrowRight:r.ArrowDown,a=t?r.ArrowLeft:r.ArrowUp;i===e.keyCode?n.increment():a===e.keyCode&&n.decrement()}}),D(w(n),`updateSizes`,function(){if(!(!n.state.initialized||!n.itemsRef||n.itemsRef.length===0)){var e=n.props.axis===`horizontal`,t=n.itemsRef[0];if(t){var r=e?t.clientWidth:t.clientHeight;n.setState({itemSize:r}),n.thumbsRef&&n.thumbsRef.updateSizes()}}}),D(w(n),`setMountState`,function(){n.setState({hasMount:!0}),n.updateSizes()}),D(w(n),`handleClickItem`,function(e,r){if(t.Children.count(n.props.children)!==0){if(n.state.cancelClick){n.setState({cancelClick:!1});return}n.props.onClickItem(e,r),e!==n.state.selectedItem&&n.setState({selectedItem:e})}}),D(w(n),`handleOnChange`,function(e,r){t.Children.count(n.props.children)<=1||n.props.onChange(e,r)}),D(w(n),`handleClickThumb`,function(e,t){n.props.onClickThumb(e,t),n.moveTo(e)}),D(w(n),`onSwipeStart`,function(e){n.setState({swiping:!0}),n.props.onSwipeStart(e)}),D(w(n),`onSwipeEnd`,function(e){n.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),n.props.onSwipeEnd(e),n.clearAutoPlay(),n.state.autoPlay&&n.autoPlay()}),D(w(n),`onSwipeMove`,function(e,t){n.props.onSwipeMove(t);var r=n.props.swipeAnimationHandler(e,n.props,n.state,n.setState.bind(w(n)));return n.setState(g({},r)),!!Object.keys(r).length}),D(w(n),`decrement`,function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;n.moveTo(n.state.selectedItem-(typeof e==`number`?e:1))}),D(w(n),`increment`,function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;n.moveTo(n.state.selectedItem+(typeof e==`number`?e:1))}),D(w(n),`moveTo`,function(e){if(typeof e==`number`){var r=t.Children.count(n.props.children)-1;e<0&&(e=n.props.infiniteLoop?r:0),e>r&&(e=n.props.infiniteLoop?0:r),n.selectItem({selectedItem:e}),n.state.autoPlay&&n.state.isMouseEntered===!1&&n.resetAutoPlay()}}),D(w(n),`onClickNext`,function(){n.increment(1)}),D(w(n),`onClickPrev`,function(){n.decrement(1)}),D(w(n),`onSwipeForward`,function(){n.increment(1),n.props.emulateTouch&&n.setState({cancelClick:!0})}),D(w(n),`onSwipeBackwards`,function(){n.decrement(1),n.props.emulateTouch&&n.setState({cancelClick:!0})}),D(w(n),`changeItem`,function(e){return function(t){(!(0,s.isKeyboardEvent)(t)||t.key===`Enter`)&&n.moveTo(e)}}),D(w(n),`selectItem`,function(e){n.setState(g({previousItem:n.state.selectedItem},e),function(){n.setState(n.animationHandler(n.props,n.state))}),n.handleOnChange(e.selectedItem,t.Children.toArray(n.props.children)[e.selectedItem])}),D(w(n),`getInitialImage`,function(){var e=n.props.selectedItem,t=n.itemsRef&&n.itemsRef[e];return(t&&t.getElementsByTagName(`img`)||[])[0]}),D(w(n),`getVariableItemHeight`,function(e){var t=n.itemsRef&&n.itemsRef[e];if(n.state.hasMount&&t&&t.children.length){var r=t.children[0].getElementsByTagName(`img`)||[];if(r.length>0){var i=r[0];i.complete||i.addEventListener(`load`,function e(){n.forceUpdate(),i.removeEventListener(`load`,e)})}var a=(r[0]||t.children[0]).clientHeight;return a>0?a:null}return null});var r={initialized:!1,previousItem:e.selectedItem,selectedItem:e.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:e.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return n.animationHandler=typeof e.animationHandler==`function`&&e.animationHandler||e.animationHandler===`fade`&&c.fadeAnimationHandler||c.slideAnimationHandler,n.state=g(g({},r),n.animationHandler(e,r)),n}return y(u,[{key:`componentDidMount`,value:function(){this.props.children&&this.setupCarousel()}},{key:`componentDidUpdate`,value:function(e,t){!e.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!e.autoFocus&&this.props.autoFocus&&this.forceFocus(),t.swiping&&!this.state.swiping&&this.setState(g({},this.props.stopSwipingHandler(this.props,this.state))),(e.selectedItem!==this.props.selectedItem||e.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),e.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:`componentWillUnmount`,value:function(){this.destroyCarousel()}},{key:`setupCarousel`,value:function(){var e=this;this.bindEvents(),this.state.autoPlay&&t.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var t=e.getInitialImage();t&&!t.complete?t.addEventListener(`load`,e.setMountState):e.setMountState()})}},{key:`destroyCarousel`,value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:`setupAutoPlay`,value:function(){this.autoPlay();var e=this.carouselWrapperRef;this.props.stopOnHover&&e&&(e.addEventListener(`mouseenter`,this.stopOnHover),e.addEventListener(`mouseleave`,this.startOnLeave))}},{key:`destroyAutoPlay`,value:function(){this.clearAutoPlay();var e=this.carouselWrapperRef;this.props.stopOnHover&&e&&(e.removeEventListener(`mouseenter`,this.stopOnHover),e.removeEventListener(`mouseleave`,this.startOnLeave))}},{key:`bindEvents`,value:function(){(0,o.default)().addEventListener(`resize`,this.updateSizes),(0,o.default)().addEventListener(`DOMContentLoaded`,this.updateSizes),this.props.useKeyboardArrows&&(0,a.default)().addEventListener(`keydown`,this.navigateWithKeyboard)}},{key:`unbindEvents`,value:function(){(0,o.default)().removeEventListener(`resize`,this.updateSizes),(0,o.default)().removeEventListener(`DOMContentLoaded`,this.updateSizes);var e=this.getInitialImage();e&&e.removeEventListener(`load`,this.setMountState),this.props.useKeyboardArrows&&(0,a.default)().removeEventListener(`keydown`,this.navigateWithKeyboard)}},{key:`forceFocus`,value:function(){var e;(e=this.carouselWrapperRef)==null||e.focus()}},{key:`renderItems`,value:function(e){var n=this;return this.props.children?t.Children.map(this.props.children,function(i,a){var o=a===n.state.selectedItem,s=a===n.state.previousItem,c=o&&n.state.selectedStyle||s&&n.state.prevStyle||n.state.slideStyle||{};n.props.centerMode&&n.props.axis===`horizontal`&&(c=g(g({},c),{},{minWidth:n.props.centerSlidePercentage+`%`})),n.state.swiping&&n.state.swipeMovementStarted&&(c=g(g({},c),{},{pointerEvents:`none`}));var l={ref:function(e){return n.setItemsRef(e,a)},key:`itemKey`+a+(e?`clone`:``),className:r.default.ITEM(!0,a===n.state.selectedItem,a===n.state.previousItem),onClick:n.handleClickItem.bind(n,a,i),style:c};return t.default.createElement(`li`,l,n.props.renderItem(i,{isSelected:a===n.state.selectedItem,isPrevious:a===n.state.previousItem}))}):[]}},{key:`renderControls`,value:function(){var e=this,n=this.props,r=n.showIndicators,i=n.labels,a=n.renderIndicator,o=n.children;return r?t.default.createElement(`ul`,{className:`control-dots`},t.Children.map(o,function(t,n){return a&&a(e.changeItem(n),n===e.state.selectedItem,n,i.item)})):null}},{key:`renderStatus`,value:function(){return this.props.showStatus?t.default.createElement(`p`,{className:`carousel-status`},this.props.statusFormatter(this.state.selectedItem+1,t.Children.count(this.props.children))):null}},{key:`renderThumbs`,value:function(){return!this.props.showThumbs||!this.props.children||t.Children.count(this.props.children)===0?null:t.default.createElement(i.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:`render`,value:function(){var e=this;if(!this.props.children||t.Children.count(this.props.children)===0)return null;var i=this.props.swipeable&&t.Children.count(this.props.children)>1,a=this.props.axis===`horizontal`,o=this.props.showArrows&&t.Children.count(this.props.children)>1,s=o&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,c=o&&(this.state.selectedItem{})),Bt=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Carousel",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"CarouselProps",{enumerable:!0,get:function(){return n.CarouselProps}}),Object.defineProperty(e,"Thumbs",{enumerable:!0,get:function(){return r.default}});var t=i(Rt()),n=zt(),r=i(Pt());function i(e){return e&&e.__esModule?e:{default:e}}})),Vt=s(((e,t)=>{var n=A();t.exports=function(){return n.Date.now()}})),Ht=s(((e,t)=>{var n=/\s/;function r(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}t.exports=r})),Ut=s(((e,t)=>{var n=Ht(),r=/^\s+/;function i(e){return e&&e.slice(0,n(e)+1).replace(r,``)}t.exports=i})),Wt=s(((e,t)=>{var n=Ut(),r=re(),i=ne(),a=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;function u(e){if(typeof e==`number`)return e;if(i(e))return a;if(r(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=r(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=n(e);var u=s.test(e);return u||c.test(e)?l(e.slice(2),u?2:8):o.test(e)?a:+e}t.exports=u})),Gt=s(((e,t)=>{var n=re(),r=Vt(),i=Wt(),a=`Expected a function`,o=Math.max,s=Math.min;function c(e,t,c){var l,u,d,f,p,m,h=0,g=!1,_=!1,v=!0;if(typeof e!=`function`)throw TypeError(a);t=i(t)||0,n(c)&&(g=!!c.leading,_=`maxWait`in c,d=_?o(i(c.maxWait)||0,t):d,v=`trailing`in c?!!c.trailing:v);function y(t){var n=l,r=u;return l=u=void 0,h=t,f=e.apply(r,n),f}function b(e){return h=e,p=setTimeout(C,t),g?y(e):f}function x(e){var n=e-m,r=e-h,i=t-n;return _?s(i,d-r):i}function S(e){var n=e-m,r=e-h;return m===void 0||n>=t||n<0||_&&r>=d}function C(){var e=r();if(S(e))return w(e);p=setTimeout(C,x(e))}function w(e){return p=void 0,v&&l?y(e):(l=u=void 0,f)}function T(){p!==void 0&&clearTimeout(p),h=0,l=m=u=p=void 0}function E(){return p===void 0?f:w(r())}function D(){var e=r(),n=S(e);if(l=arguments,u=this,m=e,n){if(p===void 0)return b(m);if(_)return clearTimeout(p),p=setTimeout(C,t),y(m)}return p===void 0&&(p=setTimeout(C,t)),f}return D.cancel=T,D.flush=E,D}t.exports=c})),L=u(f(),1),Kt=u(Gt(),1);E();function qt(e,t,n,r,i=!1){let a=L.useRef();a.current=t,L.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;let t=n,o=e=>{a.current?.call(t,e)};return t.addEventListener(e,o,{passive:r,capture:i}),()=>{t.removeEventListener(e,o,{capture:i})}},[e,n,r,i])}function Jt(e,t){return e===void 0?void 0:t}var Yt=Math.PI;function Xt(e){return e*Yt/180}var Zt=(e,t,n)=>({x1:e-n/2,y1:t-n/2,x2:e+n/2,y2:t+n/2}),Qt=(e,t,n,r,i)=>{switch(e){case`left`:return Math.floor(t)+r+i/2;case`center`:return Math.floor(t+n/2);case`right`:return Math.floor(t+n)-r-i/2}},$t=(e,t,n)=>Math.min(e,t-n*2),en=(e,t,n)=>n.x1<=e&&e<=n.x2&&n.y1<=t&&t<=n.y2,tn=e=>{let t=e.fgColor??`currentColor`;return L.createElement(`svg`,{viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},L.createElement(`path`,{d:`M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929`,stroke:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,vectorEffect:`non-scaling-stroke`}),L.createElement(`path`,{d:`M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z`,stroke:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,vectorEffect:`non-scaling-stroke`}))},nn=e=>{let t=e.fgColor??`currentColor`;return L.createElement(`svg`,{viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},L.createElement(`path`,{d:`M19 6L10.3802 17L5.34071 11.8758`,vectorEffect:`non-scaling-stroke`,stroke:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}))};function rn(e,t,n){let[r,i]=L.useState(e),a=L.useRef(!0);L.useEffect(()=>()=>{a.current=!1},[]);let o=L.useRef((0,Kt.default)(e=>{a.current&&i(e)},n));return L.useLayoutEffect(()=>{a.current&&o.current(()=>e())},t),r}var an=RegExp(`^[^A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿]*[֑-߿יִ-﷽ﹰ-ﻼ]`);function R(e){return an.test(e)?`rtl`:`not-rtl`}var on=void 0;function sn(){if(typeof document>`u`)return 0;if(on!==void 0)return on;let e=document.createElement(`p`);e.style.width=`100%`,e.style.height=`200px`;let t=document.createElement(`div`);t.id=`testScrollbar`,t.style.position=`absolute`,t.style.top=`0px`,t.style.left=`0px`,t.style.visibility=`hidden`,t.style.width=`200px`,t.style.height=`150px`,t.style.overflow=`hidden`,t.append(e),document.body.append(t);let n=e.offsetWidth;t.style.overflow=`scroll`;let r=e.offsetWidth;return n===r&&(r=t.clientWidth),t.remove(),on=n-r,on}var cn=Symbol();function ln(e){let t=L.useRef([cn,e]);t.current[1]!==e&&(t.current[0]=e),t.current[1]=e;let[n,r]=L.useState(e),[,i]=L.useState(),a=L.useCallback(e=>{let n=t.current[0];n!==cn&&(e=typeof e==`function`?e(n):e,e===n)||(n!==cn&&i({}),r(t=>typeof e==`function`?e(n===cn?t:n):e),t.current[0]=cn)},[]),o=L.useCallback(()=>{t.current[0]=cn,i({})},[]);return[t.current[0]===cn?n:t.current[0],a,o]}function un(e){if(e.length===0)return``;let t=0,n=0;for(let r of e){if(n+=r.length,n>1e4)break;t++}return e.slice(0,t).join(`, `)}function dn(e){let t=L.useRef(e);return w(e,t.current)||(t.current=e),t.current}var fn=Bt(),pn=e=>{let{urls:t,canWrite:n,onEditClick:r,renderImage:i}=e,a=t.filter(e=>e!==``);if(a.length===0)return null;let o=a.length>1;return L.createElement(Ct,{"data-testid":`GDG-default-image-overlay-editor`},L.createElement(fn.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},a.map(e=>{let t=i?.(e)??L.createElement(`img`,{draggable:!1,src:e});return L.createElement(`div`,{className:`gdg-centering-container`,key:e},t)})),n&&r&&L.createElement(`button`,{className:`gdg-edit-icon`,onClick:r},L.createElement(tn,null)))};function z(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:``,highlight:null,hooks:null,langPrefix:`language-`,mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}var mn=z();function hn(e){mn=e}var gn=/[&<>"']/,_n=new RegExp(gn.source,`g`),vn=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,yn=new RegExp(vn.source,`g`),bn={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},xn=e=>bn[e];function Sn(e,t){if(t){if(gn.test(e))return e.replace(_n,xn)}else if(vn.test(e))return e.replace(yn,xn);return e}var Cn=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function wn(e){return e.replace(Cn,(e,t)=>(t=t.toLowerCase(),t===`colon`?`:`:t.charAt(0)===`#`?t.charAt(1)===`x`?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):``))}var Tn=/(^|[^\[])\^/g;function En(e,t){e=typeof e==`string`?e:e.source,t||=``;let n={replace:(t,r)=>(r=r.source||r,r=r.replace(Tn,`$1`),e=e.replace(t,r),n),getRegex:()=>new RegExp(e,t)};return n}var Dn=/[^\w:]/g,On=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function kn(e,t,n){if(e){let e;try{e=decodeURIComponent(wn(n)).replace(Dn,``).toLowerCase()}catch{return null}if(e.indexOf(`javascript:`)===0||e.indexOf(`vbscript:`)===0||e.indexOf(`data:`)===0)return null}t&&!On.test(n)&&(n=Pn(t,n));try{n=encodeURI(n).replace(/%25/g,`%`)}catch{return null}return n}var An={},jn=/^[^:]+:\/*[^/]*$/,Mn=/^([^:]+:)[\s\S]*$/,Nn=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Pn(e,t){An[` `+e]||(jn.test(e)?An[` `+e]=e+`/`:An[` `+e]=Ln(e,`/`,!0)),e=An[` `+e];let n=e.indexOf(`:`)===-1;return t.substring(0,2)===`//`?n?t:e.replace(Mn,`$1`)+t:t.charAt(0)===`/`?n?t:e.replace(Nn,`$1`)+t:e+t}var Fn={exec:function(){}};function In(e,t){let n=e.replace(/\|/g,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(/ \|/),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Vn(e,t,n,r){let i=t.href,a=t.title?Sn(t.title):null,o=e[1].replace(/\\([\[\]])/g,`$1`);if(e[0].charAt(0)!==`!`){r.state.inLink=!0;let e={type:`link`,raw:n,href:i,title:a,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,e}return{type:`image`,raw:n,href:i,title:a,text:Sn(o)}}function Hn(e,t){let n=e.match(/^(\s+)(?:```)/);if(n===null)return t;let r=n[1];return t.split(` `).map(e=>{let t=e.match(/^\s+/);if(t===null)return e;let[n]=t;return n.length>=r.length?e.slice(r.length):e}).join(` `)}var Un=class{constructor(e){this.options=e||mn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(/^ {1,4}/gm,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:Ln(e,` `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Hn(e,t[3]||``);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){let t=Ln(e,`#`);(this.options.pedantic||!t||/ $/.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:t[0]}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=t[0].replace(/^ *>[ \t]?/gm,``),n=this.lexer.state.top;this.lexer.state.top=!0;let r=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:`blockquote`,raw:t[0],tokens:r,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n,r,i,a,o,s,c,l,u,d,f,p,m=t[1].trim(),h=m.length>1,g={type:`list`,raw:``,ordered:h,start:h?+m.slice(0,-1):``,loose:!1,items:[]};m=h?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=h?m:`[*+-]`);let _=RegExp(`^( {0,3}${m})((?:[\t ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,!(!(t=_.exec(e))||this.rules.block.hr.test(e)));){if(n=t[0],e=e.substring(n.length),l=t[2].split(` @@ -165,16 +165,16 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`

An error -`}};function eee(e,t){return e===`normal`?[t.bgIconHeader,t.fgIconHeader]:e===`selected`?[`white`,t.accentColor]:[t.accentColor,t.bgHeader]}var fa=class{onSettled;spriteMap=new Map;headerIcons;inFlight=0;constructor(e,t){this.onSettled=t,this.headerIcons=e??{}}drawSprite(e,t,n,r,i,a,o,s=1){let[c,l]=eee(t,o),u=a*Math.ceil(window.devicePixelRatio),d=`${c}_${l}_${u}_${e}`,f=this.spriteMap.get(d);if(f===void 0){let t=this.headerIcons[e];if(t===void 0)return;f=document.createElement(`canvas`);let n=f.getContext(`2d`);if(n===null)return;let r=new Image;r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t({fgColor:l,bgColor:c}))}`,this.spriteMap.set(d,f);let i=r.decode();if(i===void 0)return;this.inFlight++,i.then(()=>{n.drawImage(r,0,0,u,u)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else s<1&&(n.globalAlpha=s),n.drawImage(f,0,0,u,u,r,i,a,a),s<1&&(n.globalAlpha=1)}};function pa(e){if(e.length===0)return;let t;for(let n of e)t=Math.min(t??n.y,n.y)}function ma(e,t,n,r,i,a,o,s,c){s??=t;let l=t,u=e,d=r-a,f=!1;for(;ls&&c(l,u,e,!1,o&&u===r-1)===!0){f=!0;break}l+=e,u++}if(!f){l=n;for(let e=0;e!e.sticky)?.sourceIndex??0;if(c>d){let e=Math.max(s,d),l=t,f=r;for(let t=a.sourceIndex-1;t>=e;t--)l-=o[t].width,f+=o[t].width;for(let e=a.sourceIndex+1;e<=c;e++)f+=o[e].width;u={x:l,y:n,width:f,height:i}}if(d>s){let e=Math.min(c,d-1),u=t,f=r;for(let e=a.sourceIndex-1;e>=s;e--)u-=o[e].width,f+=o[e].width;for(let t=a.sourceIndex+1;t<=e;t++)f+=o[t].width;l={x:u,y:n,width:f,height:i}}return[l,u]}function va(e,t,n,r){if(r===`any`)return xa(e,{x:t,y:n,width:1,height:1});if(r===`vertical`&&(t=e.x),r===`horizontal`&&(n=e.y),Mr([t,n],e))return;let i=t-e.x,a=e.x+e.width-t,o=n-e.y+1,s=e.y+e.height-n,c=Math.min(r===`vertical`?2**53-1:i,r===`vertical`?2**53-1:a,r===`horizontal`?2**53-1:o,r===`horizontal`?2**53-1:s);return c===s?{x:e.x,y:e.y+e.height,width:e.width,height:n-e.y-e.height+1}:c===o?{x:e.x,y:n,width:e.width,height:e.y-n}:c===a?{x:e.x+e.width,y:e.y,width:t-e.x-e.width+1,height:e.height}:{x:t,y:e.y,width:e.x-t,height:e.height}}function ya(e,t,n,r,i,a,o,s){return e<=i+o&&i<=e+n&&t<=a+s&&a<=t+r}function ba(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function xa(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-r}}function Sa(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}function Ca(e,t,n,r){if(e.x>t||e.y>n||e.x<0&&e.y<0&&e.x+e.width>t&&e.y+e.height>n)return;if(e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n)return e;let i=t+4,a=n+4,o=-4-e.x,s=e.x+e.width-i,c=-4-e.y,l=e.y+e.height-a,u=o>0?e.x+Math.floor(o/r)*r:e.x,d=s>0?e.x+e.width-Math.floor(s/r)*r:e.x+e.width,f=c>0?e.y+Math.floor(c/r)*r:e.y,p=l>0?e.y+e.height-Math.floor(l/r)*r:e.y+e.height;return{x:u,y:f,width:d-u,height:p-f}}function wa(e,t,n,r,i){let[a,o,s,c]=t,[l,u,d,f]=i,{x:p,y:m,width:h,height:g}=e,_=[];if(h<=0||g<=0)return _;let v=p+h,y=m+g,b=ps,C=m+g>c,w=p>=a&&pa&&v<=s||ps,T=m>=o&&mo&&y<=c||mc;if(w&&T){let e=Math.max(p,a),t=Math.max(m,o),n=Math.min(v,s),r=Math.min(y,c);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:l,y:u,width:d-l+1,height:f-u+1}})}if(b&&x){let e=p,t=m,n=Math.min(v,a),r=Math.min(y,o);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:0,y:0,width:l+1,height:u+1}})}if(x&&w){let e=Math.max(p,a),t=m,n=Math.min(v,s),r=Math.min(y,o);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:l,y:0,width:d-l+1,height:u+1}})}if(x&&S){let e=Math.max(p,s),t=m,r=v,i=Math.min(y,o);_.push({rect:{x:e,y:t,width:r-e,height:i-t},clip:{x:d,y:0,width:n-d+1,height:u+1}})}if(b&&T){let e=p,t=Math.max(m,o),n=Math.min(v,a),r=Math.min(y,c);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:0,y:u,width:l+1,height:f-u+1}})}if(S&&T){let e=Math.max(p,s),t=Math.max(m,o),r=v,i=Math.min(y,c);_.push({rect:{x:e,y:t,width:r-e,height:i-t},clip:{x:d,y:u,width:n-d+1,height:f-u+1}})}if(b&&C){let e=p,t=Math.max(m,c),n=Math.min(v,a),i=y;_.push({rect:{x:e,y:t,width:n-e,height:i-t},clip:{x:0,y:f,width:l+1,height:r-f+1}})}if(C&&w){let e=Math.max(p,a),t=Math.max(m,c),n=Math.min(v,s),i=y;_.push({rect:{x:e,y:t,width:n-e,height:i-t},clip:{x:l,y:f,width:d-l+1,height:r-f+1}})}if(S&&C){let e=Math.max(p,s),t=Math.max(m,c),i=v,a=y;_.push({rect:{x:e,y:t,width:i-e,height:a-t},clip:{x:d,y:f,width:n-d+1,height:r-f+1}})}return _}ct(),Ti(),vr();var Ta={kind:I.Loading,allowOverlay:!1};function Ea(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N){let te=y?.size??2**53-1,ne=performance.now(),P=k.baseFontFull;e.font=P;let re={ctx:e},F=[0,0],ie=g>0?zr(c,g,l):0,ae,oe,se=pa(v);return ha(t,s,a,o,i,(t,a,o,s,ce)=>{let le=Math.max(0,s-a),ue=a+le,de=i+1,fe=t.width-le,pe=r-i-1;if(v.length>0){let e=!1;for(let t=0;t{e.save(),e.beginPath(),e.rect(ue,de,fe,pe),e.clip()},he=b.columns.hasIndex(t.sourceIndex),ge=d(t.group??``).overrideTheme,_e=t.themeOverride===void 0&&ge===void 0?k:xi(k,ge,t.themeOverride),ve=_e.baseFontFull;ve!==P&&(P=ve,e.font=ve),me();let ye;return ma(ce,o,r,c,l,g,_,se,(i,o,l,d,g)=>{if(o<0||(F[0]=t.sourceIndex,F[1]=o,y!==void 0&&!y.has(F)))return;if(v.length>0){let e=!1;for(let n=0;nce.span!==void 0&&e>=ce.span[0]&&e<=ce.span[1]);xe&&!m&&h?Se=0:xe&&h&&(Se=Math.max(Se,1)),Ce&&Se++,xe||(_&&Se++,he&&!g&&Se++);let we=ce.kind===I.Protected?be.bgCellMedium:be.bgCell,Te;if((d||we!==k.bgCell)&&(Te=mr(we,Te)),Se>0||se){se&&(Te=mr(be.bgHeader,Te));for(let e=0;eN&&!fe){let n=be.baseFontFull;n!==P&&(e.font=n,P=n),ye=Ma(e,ce,t.sourceIndex,o,De,Oe,le,i,ue,l,Se>0,be,Te??be.bgCell,C,w,ke?.hoverAmount??0,E,O,ne,D,ye,A,j,M,ee)}return Ee&&e.restore(),ce.style===`faded`&&(e.globalAlpha=1),te--,de&&(e.restore(),ye?.deprep?.(re),ye=void 0,me(),P=ve,e.font=ve),te<=0}),e.restore(),te<=0}),ae}var Da=[0,0],Oa={x:0,y:0,width:0,height:0},ka=[void 0,()=>void 0],Aa=!1;function ja(){Aa=!0}function Ma(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w){let T,E;g!==void 0&&g[0][0]===n&&g[0][1]===r&&(T=g[1][0],E=g[1][1]);let D;Da[0]=n,Da[1]=r,Oa.x=o,Oa.y=s,Oa.width=c,Oa.height=l,ka[0]=S.getValue(Da),ka[1]=e=>S.setValue(Da,e),Aa=!1;let O={ctx:e,theme:d,col:n,row:r,cell:t,rect:Oa,highlighted:u,cellFillColor:f,hoverAmount:h,frameTime:v,hoverX:T,drawState:ka,hoverY:E,imageLoader:p,spriteManager:m,hyperWrapping:_,overrideCursor:T===void 0?void 0:w,requestAnimationFrame:ja},k=ei(O,t.lastUpdated,v,b,i,a),A=C(t);if(A!==void 0){b?.renderer!==A&&(b?.deprep?.(O),b=void 0);let e=A.drawPrep?.(O,b);y!==void 0&&!Ze(O.cell)?y(O,()=>A.draw(O,t)):A.draw(O,t),D=e===void 0?void 0:{deprep:e?.deprep,fillStyle:e?.fillStyle,font:e?.font,renderer:A}}return(k||Aa)&&x?.(Da),D}E(),ct();function Na(e,t,n,r,i,a,o,s,c=-20,l=-20,u=32,d=`center`,f=`square`){let p=Math.floor(i+o/2),m=f===`circle`?1e4:t.roundingRadius??4,h=$t(u,o,t.cellVerticalPadding),g=h/2,_=Qt(d,r,a,t.cellHorizontalPadding,h),v=Zt(_,p,h),y=en(r+c,i+l,v);switch(n){case!0:e.beginPath(),si(e,_-h/2,p-h/2,h,h,m),f===`circle`&&(g*=.8,h*=.8),e.fillStyle=s?t.accentColor:t.textMedium,e.fill(),e.beginPath(),e.moveTo(_-g+h/4.23,p-g+h/1.97),e.lineTo(_-g+h/2.42,p-g+h/1.44),e.lineTo(_-g+h/1.29,p-g+h/3.25),e.strokeStyle=t.bgCell,e.lineJoin=`round`,e.lineCap=`round`,e.lineWidth=1.9,e.stroke();break;case null:case!1:e.beginPath(),si(e,_-h/2+.5,p-h/2+.5,h-1,h-1,m),e.lineWidth=1,e.strokeStyle=y?t.textDark:t.textMedium,e.stroke();break;case void 0:e.beginPath(),si(e,_-h/2,p-h/2,h,h,m),e.fillStyle=y?t.textMedium:t.textLight,e.fill(),f===`circle`&&(g*=.8,h*=.8),e.beginPath(),e.moveTo(_-h/3,p),e.lineTo(_+h/3,p),e.strokeStyle=t.bgCell,e.lineCap=`round`,e.lineWidth=1.9,e.stroke();break;default:S(n)}}Ti(),vr(),ct();function Pa(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=o+s;if(y<=0)return;e.fillStyle=d.bgHeader,e.fillRect(0,0,i,y);let[b,x]=r?.[0]??[];e.font=d.headerFontFull,ha(t,0,a,0,y,(t,r,i,a)=>{if(g!==void 0&&!g.has([t.sourceIndex,-1]))return;let m=Math.max(0,a-r);e.save(),e.beginPath(),e.rect(r+m,s,t.width-m,o),e.clip();let y=h(t.group??``).overrideTheme,S=t.themeOverride===void 0&&y===void 0?d:xi(d,y,t.themeOverride);S.bgHeader!==d.bgHeader&&(e.fillStyle=S.bgHeader,e.fill()),S!==d&&(e.font=S.baseFontFull);let C=u.columns.hasIndex(t.sourceIndex),w=c!==void 0||l,T=!w&&x===-1&&b===t.sourceIndex,E=w?0:p.find(e=>e.item[0]===t.sourceIndex&&e.item[1]===-1)?.hoverAmount??0,D=u?.current!==void 0&&u.current.cell[0]===t.sourceIndex,O=C?S.accentColor:D?S.bgHeaderHasFocus:S.bgHeader,k=n?s:0,A=t.sourceIndex===0?0:1;C?(e.fillStyle=O,e.fillRect(r+A,k,t.width-A,o)):(D||E>0)&&(e.beginPath(),e.rect(r+A,k,t.width-A,o),D&&(e.fillStyle=S.bgHeaderHasFocus,e.fill()),E>0&&(e.globalAlpha=E,e.fillStyle=S.bgHeaderHovered,e.fill(),e.globalAlpha=1)),Ba(e,r,k,t.width,o,t,C,S,T,D,E,f,_,v),e.restore()}),n&&Fa(e,t,i,a,s,r,d,f,p,m,h,g)}function Fa(e,t,n,r,i,a,o,s,c,l,u,d){let[f,p]=a?.[0]??[],m=0;ga(t,n,r,i,(t,n,r,c,h,g)=>{if(d!==void 0&&!d.hasItemInRectangle({x:t[0],y:-2,width:t[1]-t[0]+1,height:1}))return;e.save(),e.beginPath(),e.rect(r,c,h,g),e.clip();let _=u(n),v=_?.overrideTheme===void 0?o:xi(o,_.overrideTheme),y=p===-2&&f!==void 0&&f>=t[0]&&f<=t[1],b=y?v.bgHeaderHovered:v.bgHeader;if(b!==o.bgHeader&&(e.fillStyle=b,e.fill()),e.fillStyle=v.textGroupHeader??v.textHeader,_!==void 0){let t=r;if(_.icon!==void 0&&(s.drawSprite(_.icon,`normal`,e,t+8,(i-20)/2,20,v),t+=26),e.fillText(_.name,t+8,i/2+Xr(e,o.headerFontFull)),_.actions!==void 0&&y){let t=Ra({x:r,y:c,width:h,height:g},_.actions);e.beginPath();let n=t[0].x-10,o=r+h-n;e.rect(n,0,o,i);let l=e.createLinearGradient(n,0,n+o,0),u=fr(b,0);l.addColorStop(0,u),l.addColorStop(10/o,b),l.addColorStop(1,b),e.fillStyle=l,e.fill(),e.globalAlpha=.6;let[d,f]=a?.[1]??[-1,-1];for(let n=0;n<_.actions.length;n++){let i=_.actions[n],a=t[n],o=ba(a,d+r,f);o&&(e.globalAlpha=1),s.drawSprite(i.icon,`normal`,e,a.x+a.width/2-10,a.y+a.height/2-10,20,v),o&&(e.globalAlpha=.6)}e.globalAlpha=1}}r!==0&&l(t[0])&&(e.beginPath(),e.moveTo(r+.5,0),e.lineTo(r+.5,i),e.strokeStyle=o.borderColor,e.lineWidth=1,e.stroke()),e.restore(),m=r+h}),e.beginPath(),e.moveTo(m+.5,0),e.lineTo(m+.5,i),e.moveTo(0,i+.5),e.lineTo(n,i+.5),e.strokeStyle=o.borderColor,e.lineWidth=1,e.stroke()}var Ia=30;function La(e,t,n,r,i){return i?{x:e,y:t,width:Ia,height:Math.min(Ia,r)}:{x:e+n-Ia,y:Math.max(t,t+r/2-Ia/2),width:Ia,height:Math.min(Ia,r)}}function Ra(e,t){let n=[],r=e.x+e.width-26*t.length,i=e.y+e.height/2-13;for(let e=0;e35){let n=f?35:r-35,i=f?35*.7:r-35*.7,a=n/r,o=i/r,s=e.createLinearGradient(t,0,t+r,0),c=fr(h,0);s.addColorStop(+!!f,h),s.addColorStop(a,h),s.addColorStop(o,c),s.addColorStop(+!f,c),e.fillStyle=s}else e.fillStyle=h;if(f&&(e.textAlign=`right`),e.fillText(a.title,v,n+i/2+Xr(e,s.headerFontFull)),f&&(e.textAlign=`left`),g&&a.hasMenu===!0)if(a.menuIcon===void 0||a.menuIcon===it.Triangle){e.beginPath();let t=p.x+p.width/2-5.5,n=p.y+p.height/2-3;li(e,[{x:t,y:n},{x:t+11,y:n},{x:t+5.5,y:n+6}],1),e.fillStyle=h,e.fill()}else if(a.menuIcon===it.Dots)e.beginPath(),ci(e,p.x+p.width/2,p.y+p.height/2),e.fillStyle=h,e.fill();else{let t=p.x+(p.width-s.headerIconSize)/2,n=p.y+(p.height-s.headerIconSize)/2;u.drawSprite(a.menuIcon,`normal`,e,t,n,s.headerIconSize,s)}}function Ba(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=R(a.title)===`rtl`,h=La(t,n,r,i,m);f===void 0?za(e,t,n,r,i,a,o,s,c,u,d,p,m,h):f({ctx:e,theme:s,rect:{x:t,y:n,width:r,height:i},column:a,columnIndex:a.sourceIndex,isSelected:o,hoverAmount:u,isHovered:c,hasSelectedCell:l,spriteManager:d,menuBounds:h},()=>za(e,t,n,r,i,a,o,s,c,u,d,p,m,h))}var Va=s(((e,t)=>{var n=le();t.exports=function(){try{var e=n(Object,`defineProperty`);return e({},``,{}),e}catch{}}()})),Ha=s(((e,t)=>{var n=Va();function r(e,t,r){t==`__proto__`&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}t.exports=r})),Ua=s(((e,t)=>{function n(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i{function n(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}t.exports=n})),Ga=s(((e,t)=>{t.exports=Wa()()})),Ka=s(((e,t)=>{function n(e,t){for(var n=-1,r=Array(e);++n{function n(){return!1}t.exports=n})),Ja=s(((e,t)=>{var n=A(),r=qa(),i=typeof e==`object`&&e&&!e.nodeType&&e,a=i&&typeof t==`object`&&t&&!t.nodeType&&t,o=a&&a.exports===i?n.Buffer:void 0;t.exports=(o?o.isBuffer:void 0)||r})),Ya=s(((e,t)=>{var n=N(),r=We(),i=te(),a=`[object Arguments]`,o=`[object Array]`,s=`[object Boolean]`,c=`[object Date]`,l=`[object Error]`,u=`[object Function]`,d=`[object Map]`,f=`[object Number]`,p=`[object Object]`,m=`[object RegExp]`,h=`[object Set]`,g=`[object String]`,_=`[object WeakMap]`,v=`[object ArrayBuffer]`,y=`[object DataView]`,b=`[object Float32Array]`,x=`[object Float64Array]`,S=`[object Int8Array]`,C=`[object Int16Array]`,w=`[object Int32Array]`,T=`[object Uint8Array]`,E=`[object Uint8ClampedArray]`,D=`[object Uint16Array]`,O=`[object Uint32Array]`,k={};k[b]=k[x]=k[S]=k[C]=k[w]=k[T]=k[E]=k[D]=k[O]=!0,k[a]=k[o]=k[v]=k[s]=k[y]=k[c]=k[l]=k[u]=k[d]=k[f]=k[p]=k[m]=k[h]=k[g]=k[_]=!1;function A(e){return i(e)&&r(e.length)&&!!k[n(e)]}t.exports=A})),Xa=s(((e,t)=>{function n(e){return function(t){return e(t)}}t.exports=n})),Za=s(((e,t)=>{var n=k(),r=typeof e==`object`&&e&&!e.nodeType&&e,i=r&&typeof t==`object`&&t&&!t.nodeType&&t,a=i&&i.exports===r&&n.process;t.exports=function(){try{return i&&i.require&&i.require(`util`).types||a&&a.binding&&a.binding(`util`)}catch{}}()})),Qa=s(((e,t)=>{var n=Ya(),r=Xa(),i=Za(),a=i&&i.isTypedArray;t.exports=a?r(a):n})),$a=s(((e,t)=>{var n=Ka(),r=He(),i=O(),a=Ja(),o=Ue(),s=Qa(),c=Object.prototype.hasOwnProperty;function l(e,t){var l=i(e),u=!l&&r(e),d=!l&&!u&&a(e),f=!l&&!u&&!d&&s(e),p=l||u||d||f,m=p?n(e.length,String):[],h=m.length;for(var g in e)(t||c.call(e,g))&&!(p&&(g==`length`||d&&(g==`offset`||g==`parent`)||f&&(g==`buffer`||g==`byteLength`||g==`byteOffset`)||o(g,h)))&&m.push(g);return m}t.exports=l})),eo=s(((e,t)=>{var n=Object.prototype;function r(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||n)}t.exports=r})),to=s(((e,t)=>{function n(e,t){return function(n){return e(t(n))}}t.exports=n})),no=s(((e,t)=>{t.exports=to()(Object.keys,Object)})),ro=s(((e,t)=>{var n=eo(),r=no(),i=Object.prototype.hasOwnProperty;function a(e){if(!n(e))return r(e);var t=[];for(var a in Object(e))i.call(e,a)&&a!=`constructor`&&t.push(a);return t}t.exports=a})),io=s(((e,t)=>{var n=$a(),r=ro(),i=$i();function a(e){return i(e)?n(e):r(e)}t.exports=a})),ao=s(((e,t)=>{var n=Ga(),r=io();function i(e,t){return e&&n(e,t,r)}t.exports=i})),oo=s(((e,t)=>{var n=$i();function r(e,t){return function(r,i){if(r==null)return r;if(!n(r))return e(r,i);for(var a=r.length,o=t?a:-1,s=Object(r);(t?o--:++o{var n=ao();t.exports=oo()(n)})),co=s(((e,t)=>{var n=so();function r(e,t,r,i){return n(e,function(e,n,a){t(i,e,r(e),a)}),i}t.exports=r})),lo=s(((e,t)=>{var n=we();function r(){this.__data__=new n,this.size=0}t.exports=r})),uo=s(((e,t)=>{function n(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}t.exports=n})),fo=s(((e,t)=>{function n(e){return this.__data__.get(e)}t.exports=n})),po=s(((e,t)=>{function n(e){return this.__data__.has(e)}t.exports=n})),mo=s(((e,t)=>{var n=we(),r=Te(),i=Ne(),a=200;function o(e,t){var o=this.__data__;if(o instanceof n){var s=o.__data__;if(!r||s.length{var n=we(),r=lo(),i=uo(),a=fo(),o=po(),s=mo();function c(e){var t=this.__data__=new n(e);this.size=t.size}c.prototype.clear=r,c.prototype.delete=i,c.prototype.get=a,c.prototype.has=o,c.prototype.set=s,t.exports=c})),go=s(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length;++n{var n=Pi(),r=go(),i=Vi(),a=1,o=2;function s(e,t,s,c,l,u){var d=s&a,f=e.length,p=t.length;if(f!=p&&!(d&&p>f))return!1;var m=u.get(e),h=u.get(t);if(m&&h)return m==t&&h==e;var g=-1,_=!0,v=s&o?new n:void 0;for(u.set(e,t),u.set(t,e);++g{t.exports=A().Uint8Array})),yo=s(((e,t)=>{function n(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}t.exports=n})),bo=s(((e,t)=>{var n=j(),r=vo(),i=ve(),a=_o(),o=yo(),s=Wi(),c=1,l=2,u=`[object Boolean]`,d=`[object Date]`,f=`[object Error]`,p=`[object Map]`,m=`[object Number]`,h=`[object RegExp]`,g=`[object Set]`,_=`[object String]`,v=`[object Symbol]`,y=`[object ArrayBuffer]`,b=`[object DataView]`,x=n?n.prototype:void 0,S=x?x.valueOf:void 0;function C(e,t,n,x,C,w,T){switch(n){case b:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case y:return!(e.byteLength!=t.byteLength||!w(new r(e),new r(t)));case u:case d:case m:return i(+e,+t);case f:return e.name==t.name&&e.message==t.message;case h:case _:return e==t+``;case p:var E=o;case g:var D=x&c;if(E||=s,e.size!=t.size&&!D)return!1;var O=T.get(e);if(O)return O==t;x|=l,T.set(e,t);var k=a(E(e),E(t),x,C,w,T);return T.delete(e),k;case v:if(S)return S.call(e)==S.call(t)}return!1}t.exports=C})),xo=s(((e,t)=>{var n=Ji(),r=O();function i(e,t,i){var a=t(e);return r(e)?a:n(a,i(e))}t.exports=i})),So=s(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n{function n(){return[]}t.exports=n})),wo=s(((e,t)=>{var n=So(),r=Co(),i=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols;t.exports=a?function(e){return e==null?[]:(e=Object(e),n(a(e),function(t){return i.call(e,t)}))}:r})),To=s(((e,t)=>{var n=xo(),r=wo(),i=io();function a(e){return n(e,i,r)}t.exports=a})),Eo=s(((e,t)=>{var n=To(),r=1,i=Object.prototype.hasOwnProperty;function a(e,t,a,o,s,c){var l=a&r,u=n(e),d=u.length;if(d!=n(t).length&&!l)return!1;for(var f=d;f--;){var p=u[f];if(!(l?p in t:i.call(t,p)))return!1}var m=c.get(e),h=c.get(t);if(m&&h)return m==t&&h==e;var g=!0;c.set(e,t),c.set(t,e);for(var _=l;++f{t.exports=le()(A(),`DataView`)})),Oo=s(((e,t)=>{t.exports=le()(A(),`Promise`)})),ko=s(((e,t)=>{t.exports=le()(A(),`WeakMap`)})),Ao=s(((e,t)=>{var n=Do(),r=Te(),i=Oo(),a=Hi(),o=ko(),s=N(),c=oe(),l=`[object Map]`,u=`[object Object]`,d=`[object Promise]`,f=`[object Set]`,p=`[object WeakMap]`,m=`[object DataView]`,h=c(n),g=c(r),_=c(i),v=c(a),y=c(o),b=s;(n&&b(new n(new ArrayBuffer(1)))!=m||r&&b(new r)!=l||i&&b(i.resolve())!=d||a&&b(new a)!=f||o&&b(new o)!=p)&&(b=function(e){var t=s(e),n=t==u?e.constructor:void 0,r=n?c(n):``;if(r)switch(r){case h:return m;case g:return l;case _:return d;case v:return f;case y:return p}return t}),t.exports=b})),jo=s(((e,t)=>{var n=ho(),r=_o(),i=bo(),a=Eo(),o=Ao(),s=O(),c=Ja(),l=Qa(),u=1,d=`[object Arguments]`,f=`[object Array]`,p=`[object Object]`,m=Object.prototype.hasOwnProperty;function h(e,t,h,g,_,v){var y=s(e),b=s(t),x=y?f:o(e),S=b?f:o(t);x=x==d?p:x,S=S==d?p:S;var C=x==p,w=S==p,T=x==S;if(T&&c(e)){if(!c(t))return!1;y=!0,C=!1}if(T&&!C)return v||=new n,y||l(e)?r(e,t,h,g,_,v):i(e,t,x,h,g,_,v);if(!(h&u)){var E=C&&m.call(e,`__wrapped__`),D=w&&m.call(t,`__wrapped__`);if(E||D){var O=E?e.value():e,k=D?t.value():t;return v||=new n,_(O,k,h,g,v)}}return T?(v||=new n,a(e,t,h,g,_,v)):!1}t.exports=h})),Mo=s(((e,t)=>{var n=jo(),r=te();function i(e,t,a,o,s){return e===t?!0:e==null||t==null||!r(e)&&!r(t)?e!==e&&t!==t:n(e,t,a,o,i,s)}t.exports=i})),No=s(((e,t)=>{var n=ho(),r=Mo(),i=1,a=2;function o(e,t,o,s){var c=o.length,l=c,u=!s;if(e==null)return!l;for(e=Object(e);c--;){var d=o[c];if(u&&d[2]?d[1]!==e[d[0]]:!(d[0]in e))return!1}for(;++c{var n=re();function r(e){return e===e&&!n(e)}t.exports=r})),Fo=s(((e,t)=>{var n=Po(),r=io();function i(e){for(var t=r(e),i=t.length;i--;){var a=t[i],o=e[a];t[i]=[a,o,n(o)]}return t}t.exports=i})),Io=s(((e,t)=>{function n(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}t.exports=n})),tee=s(((e,t)=>{var n=No(),r=Fo(),i=Io();function a(e){var t=r(e);return t.length==1&&t[0][2]?i(t[0][0],t[0][1]):function(r){return r===e||n(r,e,t)}}t.exports=a})),Lo=s(((e,t)=>{var n=Be(),r=Ge();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i{var n=Lo();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),zo=s(((e,t)=>{function n(e,t){return e!=null&&t in Object(e)}t.exports=n})),Bo=s(((e,t)=>{var n=zo(),r=Ke();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i})),Vo=s(((e,t)=>{var n=Mo(),r=Ro(),i=Bo(),a=P(),o=Po(),s=Io(),c=Ge(),l=1,u=2;function d(e,t){return a(e)&&o(t)?s(c(e),t):function(a){var o=r(a,e);return o===void 0&&o===t?i(a,e):n(t,o,l|u)}}t.exports=d})),Ho=s(((e,t)=>{function n(e){return e}t.exports=n})),Uo=s(((e,t)=>{function n(e){return function(t){return t?.[e]}}t.exports=n})),Wo=s(((e,t)=>{var n=Lo();function r(e){return function(t){return n(t,e)}}t.exports=r})),Go=s(((e,t)=>{var n=Uo(),r=Wo(),i=P(),a=Ge();function o(e){return i(e)?n(a(e)):r(e)}t.exports=o})),Ko=s(((e,t)=>{var n=tee(),r=Vo(),i=Ho(),a=O(),o=Go();function s(e){return typeof e==`function`?e:e==null?i:typeof e==`object`?a(e)?r(e[0],e[1]):n(e):o(e)}t.exports=s})),qo=s(((e,t)=>{var n=Ua(),r=co(),i=Ko(),a=O();function o(e,t){return function(o,s){var c=a(o)?n:r,l=t?t():{};return c(o,e,i(s,2),l)}}t.exports=o})),Jo=u(s(((e,t)=>{var n=Ha(),r=qo(),i=Object.prototype.hasOwnProperty;t.exports=r(function(e,t,r){i.call(e,r)?e[r].push(t):n(e,r,[t])})}))(),1);Ti(),vr();function Yo(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){if(_!==void 0||t[t.length-1]!==n[t.length-1])return;let y=pa(g);ha(t,c,o,s,a,(n,o,s,c,_)=>{if(n!==t[t.length-1])return;o+=n.width;let b=Math.max(o,c);b>r||(e.save(),e.beginPath(),e.rect(b,a+1,1e4,i-a-1),e.clip(),ma(_,s,i,l,u,m,h,y,(t,n,r,i)=>{if(!i&&g.length>0&&!g.some(e=>ya(o,t,1e4,r,e.x,e.y,e.width,e.height)))return;let a=f.hasIndex(n),s=p.hasIndex(n);e.beginPath();let c=d?.(n),l=c===void 0?v:xi(v,c);l.bgCell!==v.bgCell&&(e.fillStyle=l.bgCell,e.fillRect(o,t,1e4,r)),s&&(e.fillStyle=l.bgHeader,e.fillRect(o,t,1e4,r)),a&&(e.fillStyle=l.accentLight,e.fillRect(o,t,1e4,r))}),e.restore())})}function Xo(e,t,n,r,i,a,o,s,c){let l=!1;for(let e of t)if(!e.sticky){l=o(e.sourceIndex);break}let u=c.horizontalBorderColor??c.borderColor,d=c.borderColor,f=l?Rr(t):0,p;if(f!==0&&(p=pr(d,c.bgCell),e.beginPath(),e.moveTo(f+.5,0),e.lineTo(f+.5,r),e.strokeStyle=p,e.stroke()),i>0){let t=d===u&&p!==void 0?p:pr(u,c.bgCell),o=zr(a,i,s);e.beginPath(),e.moveTo(0,r-o+.5),e.lineTo(n,r-o+.5),e.strokeStyle=t,e.stroke()}}var Zo=(e,t,n)=>{let r=0,i=t,a=0,o=n;if(e!==void 0&&e.length>0){r=2**53-1,a=2**53-1,i=-(2**53-1),o=-(2**53-1);for(let t of e)r=Math.min(r,t.x-1),i=Math.max(i,t.x+t.width+1),a=Math.min(a,t.y-1),o=Math.max(o,t.y+t.height+1)}return{minX:r,maxX:i,minY:a,maxY:o}};function Qo(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h=m.bgCell,{minX:g,maxX:_,minY:v,maxY:y}=Zo(s,a,o),b=[],x=o-zr(p,f,l),S=c,C=n,w=0;for(;S+i=v&&e<=y-1){let n=u?.(C)?.bgCell;n!==void 0&&n!==h&&C>=p-f&&b.push({x:g,y:e,w:_-g,h:t,color:n})}S+=t,C0)for(let e=0;e=g&&i<=_&&d(e+1)&&b.push({x:i,y:w,w:n.width,h:E,color:a}),T+=n.width}if(b.length===0)return;let D;e.beginPath();for(let t=b.length-1;t>=0;t--){let n=b[t];D===void 0?D=n.color:n.color!==D&&(e.fillStyle=D,e.fill(),e.beginPath(),D=n.color),e.rect(n.x,n.y,n.w,n.h)}D!==void 0&&(e.fillStyle=D,e.fill()),e.beginPath()}function $o(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=!1){if(c!==void 0){e.beginPath(),e.save(),e.rect(0,0,a,o);for(let t of c)e.rect(t.x+1,t.y+1,t.width-1,t.height-1);e.clip(`evenodd`)}let v=g.horizontalBorderColor??g.borderColor,y=g.borderColor,{minX:b,maxX:x,minY:S,maxY:C}=Zo(s,a,o),w=[];e.beginPath();let T=.5;for(let e=0;e=b&&i<=x&&p(e+1)&&w.push({x1:i,y1:Math.max(l,S),x2:i,y2:Math.min(o,C),color:y})}let E=o+.5;for(let e=h-m;e=S&&n<=C-1){let e=f?.(t);w.push({x1:b,y1:n,x2:x,y2:n,color:e?.horizontalBorderColor??e?.borderColor??v})}e+=d(t),t++}}let D=(0,Jo.default)(w,e=>e.color);for(let t of Object.keys(D)){e.strokeStyle=t;for(let n of D[t])e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke(),e.beginPath()}c!==void 0&&e.restore()}E();function es(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=[];e.imageSmoothingEnabled=!1;let b=Math.min(i.cellYOffset,o),x=Math.max(i.cellYOffset,o),S=0;if(typeof _==`number`)S+=(x-b)*_;else for(let e=b;ei.cellYOffset&&(S=-S),S+=c-i.translateY;let C=Math.min(i.cellXOffset,a),w=Math.max(i.cellXOffset,a),T=0;for(let e=C;ei.cellXOffset&&(T=-T),T+=s-i.translateX;let E=Rr(g);if(T!==0&&S!==0)return{regions:[]};let D=l>0?zr(f,l,_):0,O=u-E-Math.abs(T),k=d-p-D-Math.abs(S)-1;if(O>150&&k>150){let i={sx:0,sy:0,sw:u*m,sh:d*m,dx:0,dy:0,dw:u*m,dh:d*m};if(S>0?(i.sy=(p+1)*m,i.sh=k*m,i.dy=(S+p+1)*m,i.dh=k*m,y.push({x:0,y:p,width:u,height:S+1})):S<0&&(i.sy=(-S+p+1)*m,i.sh=k*m,i.dy=(p+1)*m,i.dh=k*m,y.push({x:0,y:d+S-D,width:u,height:-S+D})),T>0?(i.sx=E*m,i.sw=O*m,i.dx=(T+E)*m,i.dw=O*m,y.push({x:E-1,y:0,width:T+2,height:d})):T<0&&(i.sx=(E-T)*m,i.sw=O*m,i.dx=E*m,i.dw=O*m,y.push({x:u+T,y:0,width:-T,height:d})),e.setTransform(1,0,0,1,0,0),v){if(E>0&&T!==0&&S===0&&(r===void 0||n?.[1]!==!1)){let n=E*m,r=d*m;e.drawImage(t,0,0,n,r,0,0,n,r)}if(D>0&&T===0&&S!==0&&(r===void 0||n?.[0]!==!1)){let n=(d-D)*m,r=u*m,i=D*m;e.drawImage(t,0,n,r,i,0,n,r,i)}}e.drawImage(t,i.sx,i.sy,i.sw,i.sh,i.dx,i.dy,i.dw,i.dh),e.scale(m,m)}return e.imageSmoothingEnabled=!0,{regions:y}}function ts(e,t,n,r,i,a,o,s,c,l){let u=[];return t!==e.cellXOffset||n!==e.cellYOffset||r!==e.translateX||i!==e.translateY||ha(c,n,r,i,s,(e,t,n,r)=>{if(e.sourceIndex===l){let e=Math.max(t,r)+1;return u.push({x:e,y:0,width:a-e,height:o}),!0}}),u}function ns(e,t){if(t===void 0||e.width!==t.width||e.height!==t.height||e.theme!==t.theme||e.headerHeight!==t.headerHeight||e.rowHeight!==t.rowHeight||e.rows!==t.rows||e.freezeColumns!==t.freezeColumns||e.getRowThemeOverride!==t.getRowThemeOverride||e.isFocused!==t.isFocused||e.isResizing!==t.isResizing||e.verticalBorder!==t.verticalBorder||e.getCellContent!==t.getCellContent||e.highlightRegions!==t.highlightRegions||e.selection!==t.selection||e.dragAndDropState!==t.dragAndDropState||e.prelightCells!==t.prelightCells||e.touchMode!==t.touchMode||e.maxScaleFactor!==t.maxScaleFactor)return!1;if(e.mappedColumns!==t.mappedColumns){if(e.mappedColumns.length>100||e.mappedColumns.length!==t.mappedColumns.length)return!1;let n;for(let r=0;re.style!==`no-outline`);if(g===void 0||g.length===0)return;let _=Rr(s),v=zr(p,f,d),y=[c,0,s.length,p-f],b=[_,0,t,n-v],x=g.map(e=>{let m=e.range,h=e.style??`dashed`;return wa(m,y,t,n,b).map(m=>{let g=m.rect,_=ui(g.x,g.y,t,n,u,l+u,r,i,a,o,p,c,f,s,d),v=g.width===1&&g.height===1?_:ui(g.x+g.width-1,g.y+g.height-1,t,n,u,l+u,r,i,a,o,p,c,f,s,d);return g.x+g.width>=s.length&&--v.width,g.y+g.height>=p&&--v.height,{color:e.color,style:h,clip:m.clip,rect:Ca({x:_.x,y:_.y,width:v.x+v.width-_.x,height:v.y+v.height-_.y},t,n,8)}})}),S=()=>{e.lineWidth=1;let r=!1;for(let i of x)for(let a of i)if(a?.rect!==void 0&&ya(0,0,t,n,a.rect.x,a.rect.y,a.rect.width,a.rect.height)){let t=r,n=!Sa(a.clip,a.rect);n&&(e.save(),e.rect(a.clip.x,a.clip.y,a.clip.width,a.clip.height),e.clip()),a.style===`dashed`&&!r?(e.setLineDash([5,3]),r=!0):(a.style===`solid`||a.style===`solid-outline`)&&r&&(e.setLineDash([]),r=!1),e.strokeStyle=a.style===`solid-outline`?mr(mr(a.color,h.borderColor),h.bgCell):fr(a.color,1),e.strokeRect(a.rect.x+.5,a.rect.y+.5,a.rect.width-1,a.rect.height-1),n&&(e.restore(),r=t)}r&&e.setLineDash([])};return S(),S}function is(e,t,n,r,i){e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.lineWidth=2,e.strokeStyle=i,e.stroke(),e.globalAlpha=1}function as(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){if(u.current===void 0)return;let _=u.current.range,v=u.current.cell,y=[_.x+_.width-1,_.y+_.height-1];if(v[1]>=g&&y[1]>=g||!o.some(e=>e.sourceIndex===v[0]||e.sourceIndex===y[0]))return;let[b,x]=u.current.cell,S=f(u.current.cell),C=S.span??[b,b],w=x>=g-p,T=p>0&&!w?zr(g,p,d)-1:0,E=y[1],D;if(ha(o,r,i,a,l,(r,i,a,o,l)=>{if(r.sticky&&b>r.sourceIndex)return;let u=r.sourceIndexC[1],_=r.sourceIndex===y[0];if(!(!_&&(u||f)))return ma(l,a,n,g,d,p,m,void 0,(a,l,u)=>{if(l!==x&&l!==E)return;let d=i,f=r.width;if(S.span!==void 0){let e=_a(S.span,i,a,r.width,u,r,s),t=r.sticky?e[0]:e[1];t!==void 0&&(d=t.x,f=t.width)}return l===E&&_&&h&&(D=()=>{o>d&&!r.sticky&&(e.beginPath(),e.rect(o,0,t-o,n),e.clip()),e.beginPath(),e.rect(d+f-4,a+u-4,4,4),e.fillStyle=r.themeOverride?.accentColor??c.accentColor,e.fill()}),D!==void 0}),D!==void 0}),D===void 0)return;let O=()=>{e.save(),e.beginPath(),e.rect(0,l,t,n-l-T),e.clip(),D?.(),e.restore()};return O(),O}vr(),E();function os(e,t,n,r,i,a,o,s,c){c===void 0||c.size===0||(e.beginPath(),ga(t,n,a,r,(t,n,r,i,a,o)=>{c.hasItemInRectangle({x:t[0],y:-2,width:t[1]-t[0]+1,height:1})&&e.rect(r,i,a,o)}),ha(t,s,a,o,i,(t,n,a,o)=>{let s=Math.max(0,o-n),l=n+s+1,u=t.width-s-1;c.has([t.sourceIndex,-1])&&e.rect(l,r,u,i-r)}),e.clip())}function ss(e,t,n,r,i,a,o,s,c,l){let u=0;return ha(e,a,r,i,n,(e,n,r,i,a)=>(ma(a,r,t,o,s,c,l,void 0,(e,t,n,r)=>{r||(u=Math.max(t,u))}),!0)),u}function cs(e,t){let{canvasCtx:n,headerCanvasCtx:r,width:i,height:a,cellXOffset:o,cellYOffset:s,translateX:c,translateY:l,mappedColumns:u,enableGroups:d,freezeColumns:f,dragAndDropState:p,theme:m,drawFocus:h,headerHeight:g,groupHeaderHeight:_,disabledRows:v,rowHeight:y,verticalBorder:b,overrideCursor:S,isResizing:C,selection:w,fillHandle:T,freezeTrailingRows:E,rows:D,getCellContent:O,getGroupDetails:k,getRowThemeOverride:A,isFocused:j,drawHeaderCallback:M,prelightCells:ee,drawCellCallback:N,highlightRegions:te,resizeCol:ne,imageLoader:P,lastBlitData:re,hoverValues:F,hyperWrapping:ie,hoverInfo:ae,spriteManager:oe,maxScaleFactor:se,hasAppendRow:ce,touchMode:le,enqueue:ue,renderStateProvider:de,getCellRenderer:fe,renderStrategy:pe,bufferACtx:me,bufferBCtx:he,damage:ge,minimumCellWidth:_e}=e;if(i===0||a===0)return;let ve=pe===`double-buffer`,ye=Math.min(se,Math.ceil(window.devicePixelRatio??1)),be=pe!==`direct`&&ns(e,t),xe=n.canvas;(xe.width!==i*ye||xe.height!==a*ye)&&(xe.width=i*ye,xe.height=a*ye,xe.style.width=i+`px`,xe.style.height=a+`px`);let Se=r.canvas,Ce=d?_+g:g,we=Ce+1;(Se.width!==i*ye||Se.height!==we*ye)&&(Se.width=i*ye,Se.height=we*ye,Se.style.width=i+`px`,Se.style.height=we+`px`);let Te=me.canvas,Ee=he.canvas;ve&&(Te.width!==i*ye||Te.height!==a*ye)&&(Te.width=i*ye,Te.height=a*ye,re.current!==void 0&&(re.current.aBufferScroll=void 0)),ve&&(Ee.width!==i*ye||Ee.height!==a*ye)&&(Ee.width=i*ye,Ee.height=a*ye,re.current!==void 0&&(re.current.bBufferScroll=void 0));let De=re.current;if(be===!0&&o===De?.cellXOffset&&s===De?.cellYOffset&&c===De?.translateX&&l===De?.translateY)return;let Oe=null;ve&&(Oe=n);let ke=r,Ae;Ae=ve?ge===void 0?De?.lastBuffer===`b`?me:he:De?.lastBuffer===`b`?he:me:n;let je=Ae.canvas,Me=ve?je===Te?Ee:Te:xe,Ne=typeof y==`number`?()=>y:y;ke.save(),Ae.save(),ke.beginPath(),Ae.beginPath(),ke.textBaseline=`middle`,Ae.textBaseline=`middle`,ye!==1&&(ke.scale(ye,ye),Ae.scale(ye,ye));let Pe=Br(u,o,i,p,c),Fe=[],Ie=h&&w.current?.cell[1]===s&&l===0,Le=!1;if(te!==void 0){for(let e of te)if(e.style!==`no-outline`&&e.range.y===s&&l===0){Le=!0;break}}let Re=()=>{Pa(ke,Pe,d,ae,i,c,g,_,p,C,w,m,oe,F,b,k,ge,M,le),$o(ke,Pe,s,c,l,i,a,void 0,void 0,_,Ce,Ne,A,b,E,D,m,!0),ke.beginPath(),ke.moveTo(0,we-.5),ke.lineTo(i,we-.5),ke.strokeStyle=mr(m.headerBottomBorderColor??m.horizontalBorderColor??m.borderColor,m.bgHeader),ke.stroke(),Le&&rs(ke,i,a,o,s,c,l,u,f,g,_,y,E,D,te,m),Ie&&as(ke,i,a,s,c,l,Pe,u,m,Ce,w,Ne,O,E,ce,T,D)};if(ge!==void 0){let e=Pe[Pe.length-1].sourceIndex+1,t=ge.hasItemInRegion([{x:o,y:-2,width:e,height:2},{x:o,y:s,width:e,height:300},{x:0,y:s,width:f,height:300},{x:0,y:-2,width:f,height:2},{x:o,y:D-E,width:e,height:E,when:E>0}]),n=e=>{Ea(e,Pe,u,a,Ce,c,l,s,D,Ne,O,k,A,v,j,h,E,ce,Fe,ge,w,ee,te,P,oe,F,ae,N,ie,m,ue,de,fe,S,_e);let t=w.current;T&&h&&t!==void 0&&ge.has(Pr(t.range))&&as(e,i,a,s,c,l,Pe,u,m,Ce,w,Ne,O,E,ce,T,D)};t&&(n(Ae),Oe!==null&&(Oe.save(),Oe.scale(ye,ye),Oe.textBaseline=`middle`,n(Oe),Oe.restore()),ge.hasHeader()&&(os(ke,Pe,i,_,Ce,c,l,s,ge),Re())),Ae.restore(),ke.restore();return}if((be!==!0||o!==De?.cellXOffset||c!==De?.translateX||Ie!==De?.mustDrawFocusOnHeader||Le!==De?.mustDrawHighlightRingsOnHeader)&&Re(),be===!0){x(Me!==void 0&&De!==void 0);let{regions:e}=es(Ae,Me,Me===Te?De.aBufferScroll:De.bBufferScroll,Me===Te?De.bBufferScroll:De.aBufferScroll,De,o,s,c,l,E,i,a,D,Ce,ye,u,Pe,y,ve);Fe=e}else be!==!1&&(x(De!==void 0),Fe=ts(De,o,s,c,l,i,a,Ce,Pe,be));Xo(Ae,Pe,i,a,E,D,b,Ne,m);let ze=rs(Ae,i,a,o,s,c,l,u,f,g,_,y,E,D,te,m),Be=h?as(Ae,i,a,s,c,l,Pe,u,m,Ce,w,Ne,O,E,ce,T,D):void 0;if(Ae.fillStyle=m.bgCell,Fe.length>0){Ae.beginPath();for(let e of Fe)Ae.rect(e.x,e.y,e.width,e.height);Ae.clip(),Ae.fill(),Ae.beginPath()}else Ae.fillRect(0,0,i,a);let Ve=Ea(Ae,Pe,u,a,Ce,c,l,s,D,Ne,O,k,A,v,j,h,E,ce,Fe,ge,w,ee,te,P,oe,F,ae,N,ie,m,ue,de,fe,S,_e);Yo(Ae,Pe,u,i,a,Ce,c,l,s,D,Ne,A,w.rows,v,E,ce,Fe,ge,m),Qo(Ae,Pe,s,c,l,i,a,Fe,Ce,Ne,A,b,E,D,m),$o(Ae,Pe,s,c,l,i,a,Fe,Ve,_,Ce,Ne,A,b,E,D,m),ze?.(),Be?.(),C&&ha(Pe,0,c,0,Ce,(e,t)=>e.sourceIndex===ne?(is(ke,t+e.width,0,Ce+1,mr(m.resizeIndicatorColor??m.accentLight,m.bgHeader)),is(Ae,t+e.width,Ce,a,mr(m.resizeIndicatorColor??m.accentLight,m.bgCell)),!0):!1),Oe!==null&&(Oe.fillStyle=m.bgCell,Oe.fillRect(0,0,i,a),Oe.drawImage(Ae.canvas,0,0));let He=ss(Pe,a,Ce,c,l,s,D,Ne,E,ce);P?.setWindow({x:o,y:s,width:Pe.length,height:He-s},f,Array.from({length:E},(e,t)=>D-1-t));let Ue=De!==void 0&&(o!==De.cellXOffset||c!==De.translateX),We=De!==void 0&&(s!==De.cellYOffset||l!==De.translateY);re.current={cellXOffset:o,cellYOffset:s,translateX:c,translateY:l,mustDrawFocusOnHeader:Ie,mustDrawHighlightRingsOnHeader:Le,lastBuffer:ve?je===Te?`a`:`b`:void 0,aBufferScroll:je===Te?[Ue,We]:De?.aBufferScroll,bBufferScroll:je===Ee?[Ue,We]:De?.bBufferScroll},Ae.restore(),ke.restore()}var ls=u(ji(),1),us=80;function ds(e){let t=e-1;return t*t*t+1}var fs=class{callback;constructor(e){this.callback=e}currentHoveredItem=void 0;leavingItems=[];lastAnimationTime;addToLeavingItems=e=>{this.leavingItems.some(t=>Nr(t.item,e.item))||this.leavingItems.push(e)};removeFromLeavingItems=e=>{let t=this.leavingItems.find(t=>Nr(t.item,e));return this.leavingItems=this.leavingItems.filter(e=>e!==t),t?.hoverAmount??0};cleanUpLeavingElements=()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)};shouldStep=()=>{let e=this.leavingItems.length>0,t=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||t};getAnimatingItems=()=>this.currentHoveredItem===void 0?this.leavingItems.map(e=>({...e,hoverAmount:ds(e.hoverAmount)})):[...this.leavingItems,this.currentHoveredItem];step=e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{let t=(e-this.lastAnimationTime)/us;for(let e of this.leavingItems)e.hoverAmount=(0,ls.default)(e.hoverAmount-t,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=(0,ls.default)(this.currentHoveredItem.hoverAmount+t,0,1));let n=this.getAnimatingItems();this.callback(n),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0};setHovered=e=>{if(!Nr(this.currentHoveredItem?.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){let t=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:t}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}}},ps=class{fn;val;constructor(e){this.fn=e}get value(){return this.val??=this.fn()}};function ms(e){return new ps(e)}var hs=ms(()=>window.navigator.userAgent.includes(`Firefox`)),gs=ms(()=>window.navigator.userAgent.includes(`Mac OS`)&&window.navigator.userAgent.includes(`Safari`)&&!window.navigator.userAgent.includes(`Chrome`)),_s=ms(()=>window.navigator.platform.toLowerCase().startsWith(`mac`));function vs(e){let t=L.useRef([]),n=L.useRef(0),r=L.useRef(e);r.current=e;let i=L.useCallback(()=>{let e=()=>window.requestAnimationFrame(i),i=()=>{let e=t.current.map(hi);t.current=[],r.current(new vi(e)),t.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?e:i)},[]);return L.useCallback(e=>{t.current.length===0&&i();let n=fi(e[0],e[1]);t.current.includes(n)||t.current.push(n)},[i])}var ys=`header`,bs=`group-header`,xs=`out-of-bounds`,Ss;(function(e){e[e.Start=-2]=`Start`,e[e.StartPadding=-1]=`StartPadding`,e[e.Center=0]=`Center`,e[e.EndPadding=1]=`EndPadding`,e[e.End=2]=`End`})(Ss||={});function Cs(e,t){return e===t?!0:e?.kind===`out-of-bounds`?e?.kind===t?.kind&&e?.location[0]===t?.location[0]&&e?.location[1]===t?.location[1]&&e?.region[0]===t?.region[0]&&e?.region[1]===t?.region[1]:e?.kind===t?.kind&&e?.location[0]===t?.location[0]&&e?.location[1]===t?.location[1]}ct();var ws=u(ra(),1);E();var Ts=6,Es=(e,t)=>e.kind===I.Custom?e.copyData:(t?.(e))?.getAccessibilityString(e)??``,Ds=L.memo(L.forwardRef((e,t)=>{let{width:n,height:r,accessibilityHeight:i,columns:a,cellXOffset:o,cellYOffset:s,headerHeight:c,fillHandle:l=!1,groupHeaderHeight:u,rowHeight:d,rows:f,getCellContent:p,getRowThemeOverride:m,onHeaderMenuClick:h,enableGroups:g,isFilling:_,onCanvasFocused:v,onCanvasBlur:y,isFocused:b,selection:S,freezeColumns:C,onContextMenu:w,freezeTrailingRows:T,fixedShadowX:E=!0,fixedShadowY:D=!0,drawFocusRing:O,onMouseDown:k,onMouseUp:A,onMouseMoveRaw:j,onMouseMove:M,onItemHovered:ee,dragAndDropState:N,firstColAccessible:te,onKeyDown:ne,onKeyUp:P,highlightRegions:re,canvasRef:F,onDragStart:ie,onDragEnd:ae,eventTargetRef:oe,isResizing:se,resizeColumn:ce,isDragging:le,isDraggable:ue=!1,allowResize:de,disabledRows:fe,hasAppendRow:pe,getGroupDetails:me,theme:he,prelightCells:ge,headerIcons:_e,verticalBorder:ve,drawCell:ye,drawHeader:be,onCellFocused:xe,onDragOverCell:Se,onDrop:Ce,onDragLeave:we,imageWindowLoader:Te,smoothScrollX:Ee=!1,smoothScrollY:De=!1,experimental:Oe,getCellRenderer:ke}=e,Ae=e.translateX??0,je=e.translateY??0,Me=Math.max(C,Math.min(a.length-1,o)),Ne=L.useRef(null),Pe=Te,Fe=L.useRef(),[Ie,Le]=L.useState(!1),Re=L.useRef([]),ze=L.useRef(),[Be,Ve]=L.useState(),[He,Ue]=L.useState(),We=L.useRef(null),[Ge,Ke]=L.useState(),[qe,Je]=L.useState(!1),Ye=L.useRef(qe);Ye.current=qe;let Xe=L.useMemo(()=>new fa(_e,()=>{vt.current=void 0,St.current()}),[_e]),$e=g?u+c:c,tt=L.useRef(-1),nt=(Oe?.enableFirefoxRescaling??!1)&&hs.value,rt=(Oe?.enableSafariRescaling??!1)&&gs.value;L.useLayoutEffect(()=>{window.devicePixelRatio===1||!nt&&!rt||(tt.current!==-1&&Le(!0),window.clearTimeout(tt.current),tt.current=window.setTimeout(()=>{Le(!1),tt.current=-1},200))},[s,Me,Ae,je,nt,rt]);let it=Or(a,C),ot=E?Rr(it,N):0,ct=L.useCallback((e,t,i)=>{let a=e.getBoundingClientRect();if(t>=it.length||i>=f)return;let o=a.width/n,c=ui(t,i,n,r,u,$e,Me,s,Ae,je,f,C,T,it,d);return o!==1&&(c.x*=o,c.y*=o,c.width*=o,c.height*=o),c.x+=a.x,c.y+=a.y,c},[n,r,u,$e,Me,s,Ae,je,f,C,T,it,d]),lt=L.useCallback((e,t,i,a)=>{let o=e.getBoundingClientRect(),p=o.width/n,m=(t-o.left)/p,h=(i-o.top)/p,_=Br(it,Me,n,void 0,Ae),v=0,y=0;a instanceof MouseEvent&&(v=a.button,y=a.buttons);let b=Vr(m,_,Ae),C=Hr(h,r,g,c,u,f,d,s,je,T),w=a?.shiftKey===!0,E=a?.ctrlKey===!0,D=a?.metaKey===!0,O=a!==void 0&&!(a instanceof MouseEvent)||a?.pointerType===`touch`,k=[m<0?-1:+(nn||h>r){let i=m>n?1:m<0?-1:0,a=h>r?1:h<0?-1:0,o=i*2,s=a*2;i===0&&(o=b===-1?Ss.EndPadding:Ss.Center),a===0&&(s=C===void 0?Ss.EndPadding:Ss.Center);let c=!1;if(b===-1&&C===-1){let n=ct(e,it.length-1,-1);x(n!==void 0),c=tn&&mr&&h=0?(r=!0,n=ct(e,a,C),x(n!==void 0),A={kind:g&&C===-2?bs:ys,location:[a,C],bounds:n,group:it[a].group??``,isEdge:r,shiftKey:w,ctrlKey:E,metaKey:D,isTouch:O,localEventX:t-n.x,localEventY:i-n.y,button:v,buttons:y,scrollEdge:k}):A={kind:g&&C===-2?bs:ys,group:it[b].group??``,location:[b,C],bounds:n,isEdge:r,shiftKey:w,ctrlKey:E,metaKey:D,isTouch:O,localEventX:t-n.x,localEventY:i-n.y,button:v,buttons:y,scrollEdge:k}}else{let n=ct(e,b,C);x(n!==void 0);let r=n!==void 0&&n.x+n.width-t<5,a=!1;if(l&&S.current!==void 0){let n=Pr(S.current.range),r=ct(e,n[0],n[1]);if(r!==void 0){let e=r.x+r.width-2,n=r.y+r.height-2;a=Math.abs(e-t){}),ft=L.useRef(Be);ft.current=Be;let[pt,mt]=L.useMemo(()=>{let e=document.createElement(`canvas`),t=document.createElement(`canvas`);return e.style.display=`none`,e.style.opacity=`0`,e.style.position=`fixed`,t.style.display=`none`,t.style.opacity=`0`,t.style.position=`fixed`,[e.getContext(`2d`,{alpha:!1}),t.getContext(`2d`,{alpha:!1})]},[]);L.useLayoutEffect(()=>{if(!(pt===null||mt===null))return document.documentElement.append(pt.canvas),document.documentElement.append(mt.canvas),()=>{pt.canvas.remove(),mt.canvas.remove()}},[pt,mt]);let ht=L.useMemo(()=>new _i,[]),gt=nt&&Ie?1:rt&&Ie?2:5,_t=Oe?.disableMinimumCellWidth===!0?1:10,vt=L.useRef(),yt=L.useRef(null),bt=L.useRef(null),xt=L.useCallback(()=>{let e=Ne.current,t=We.current;if(e===null||t===null||(yt.current===null&&(yt.current=e.getContext(`2d`,{alpha:!1}),e.width=0,e.height=0),bt.current===null&&(bt.current=t.getContext(`2d`,{alpha:!1}),t.width=0,t.height=0),yt.current===null||bt.current===null||pt===null||mt===null))return;let i=!1,a=e=>{i=!0,Ke(e)},o=vt.current,h={headerCanvasCtx:bt.current,canvasCtx:yt.current,bufferACtx:pt,bufferBCtx:mt,width:n,height:r,cellXOffset:Me,cellYOffset:s,translateX:Math.round(Ae),translateY:Math.round(je),mappedColumns:it,enableGroups:g,freezeColumns:C,dragAndDropState:N,theme:he,headerHeight:c,groupHeaderHeight:u,disabledRows:fe??st.empty(),rowHeight:d,verticalBorder:ve,isResizing:se,resizeCol:ce,isFocused:b,selection:S,fillHandle:l,drawCellCallback:ye,hasAppendRow:pe,overrideCursor:a,maxScaleFactor:gt,freezeTrailingRows:T,rows:f,drawFocus:O,getCellContent:p,getGroupDetails:me??(e=>({name:e})),getRowThemeOverride:m,drawHeaderCallback:be,prelightCells:ge,highlightRegions:re,imageLoader:Pe,lastBlitData:ze,damage:Fe.current,hoverValues:Re.current,hoverInfo:ft.current,spriteManager:Xe,scrolling:Ie,hyperWrapping:Oe?.hyperWrapping??!1,touchMode:qe,enqueue:dt.current,renderStateProvider:ht,renderStrategy:Oe?.renderStrategy??(gs.value?`double-buffer`:`single-buffer`),getCellRenderer:ke,minimumCellWidth:_t};h.damage===void 0?(vt.current=h,cs(h,o)):cs(h,void 0),!i&&(h.damage===void 0||h.damage.has(ft?.current?.[0]))&&Ke(void 0)},[pt,mt,n,r,Me,s,Ae,je,it,g,C,N,he,c,u,fe,d,ve,se,pe,ce,b,S,l,T,f,O,gt,p,me,m,ye,be,ge,re,Pe,Xe,Ie,Oe?.hyperWrapping,Oe?.renderStrategy,qe,ht,ke,_t]),St=L.useRef(xt);L.useLayoutEffect(()=>{xt(),St.current=xt},[xt]),L.useLayoutEffect(()=>{(async()=>{document?.fonts?.ready!==void 0&&(await document.fonts.ready,vt.current=void 0,St.current())})()},[]);let Ct=L.useCallback(e=>{Fe.current=e,St.current(),Fe.current=void 0},[]);dt.current=vs(Ct);let wt=L.useCallback(e=>{Ct(new vi(e.map(e=>e.cell)))},[Ct]);Pe.setCallback(Ct);let[Tt,Et]=L.useState(!1),[Dt,Ot]=ut??[],kt=Dt!==void 0&&Ot===-1,At=Dt!==void 0&&Ot===-2,jt=!1,Mt=!1,Nt=Ge;if(Nt===void 0&&Dt!==void 0&&Ot!==void 0&&Ot>-1&&Ot({contain:`strict`,display:`block`,cursor:Pt}),[Pt]),It=L.useRef(`default`),Lt=oe?.current;Lt!=null&&It.current!==Ft.cursor&&(Lt.style.cursor=It.current=Ft.cursor);let Rt=L.useCallback((e,t,n,r)=>{if(me===void 0)return;let i=me(e);if(i.actions!==void 0){let e=Ra(t,i.actions);for(let[a,o]of e.entries())if(ba(o,n+t.x,r+o.y))return i.actions[a]}},[me]),zt=L.useCallback((e,t,n,r)=>{let i=a[t];if(!le&&!se&&i.hasMenu===!0&&!(He??!1)){let a=ct(e,t,-1);x(a!==void 0);let o=La(a.x,a.y,a.width,a.height,R(i.title)===`rtl`);if(n>o.x&&no.y&&r{let t=Ne.current,n=oe?.current;if(t===null||e.target!==t&&e.target!==n)return;Ht.current=!0;let r,i;if(e instanceof MouseEvent?(r=e.clientX,i=e.clientY):(r=e.touches[0].clientX,i=e.touches[0].clientY),e.target===n&&n!==null){let e=n.getBoundingClientRect();if(r>e.right||i>e.bottom)return}let a=lt(t,r,i,e);Vt.current=a.location,a.isTouch&&(Bt.current=Date.now()),Ye.current!==a.isTouch&&Je(a.isTouch),!(a.kind===`header`&&zt(t,a.location[0],r,i)!==void 0)&&(a.kind===`group-header`&&Rt(a.group,a.bounds,a.localEventX,a.localEventY)!==void 0||(k?.(a),!a.isTouch&&ue!==!0&&ue!==a.kind&&a.button<3&&a.button!==1&&e.preventDefault()))},[oe,ue,lt,Rt,zt,k]);qt(`touchstart`,Ut,window,!1),qt(`mousedown`,Ut,window,!1);let Wt=L.useRef(0),Gt=L.useCallback(e=>{let t=Wt.current;Wt.current=Date.now();let n=Ne.current;if(Ht.current=!1,A===void 0||n===null)return;let r=oe?.current,i=e.target!==n&&e.target!==r,a,o,s=!0;if(e instanceof MouseEvent){if(a=e.clientX,o=e.clientY,s=e.button<3,e.pointerType===`touch`)return}else a=e.changedTouches[0].clientX,o=e.changedTouches[0].clientY;let c=lt(n,a,o,e);c.isTouch&&Bt.current!==0&&Date.now()-Bt.current>500&&(c={...c,isLongTouch:!0}),t!==0&&Date.now()-t<(c.isTouch?1e3:500)&&(c={...c,isDoubleClick:!0}),Ye.current!==c.isTouch&&Je(c.isTouch),!i&&e.cancelable&&s&&e.preventDefault();let[l]=c.location,u=zt(n,l,a,o);if(c.kind===`header`&&u!==void 0){(c.button!==0||Vt.current?.[0]!==l||Vt.current?.[1]!==-1)&&A(c,!0);return}else if(c.kind===`group-header`){let e=Rt(c.group,c.bounds,c.localEventX,c.localEventY);if(e!==void 0){c.button===0&&e.onClick(c);return}}A(c,i)},[A,oe,lt,zt,Rt]);qt(`mouseup`,Gt,window,!1),qt(`touchend`,Gt,window,!1),qt(`click`,L.useCallback(e=>{let t=Ne.current;if(t===null)return;let n=oe?.current,r=e.target!==t&&e.target!==n,i,a,o=!0;e instanceof MouseEvent?(i=e.clientX,a=e.clientY,o=e.button<3):(i=e.changedTouches[0].clientX,a=e.changedTouches[0].clientY);let s=lt(t,i,a,e);Ye.current!==s.isTouch&&Je(s.isTouch),!r&&e.cancelable&&o&&e.preventDefault();let[c]=s.location,l=zt(t,c,i,a);if(s.kind===`header`&&l!==void 0)s.button===0&&Vt.current?.[0]===c&&Vt.current?.[1]===-1&&h?.(c,l);else if(s.kind===`group-header`){let e=Rt(s.group,s.bounds,s.localEventX,s.localEventY);e!==void 0&&s.button===0&&e.onClick(s)}},[oe,lt,zt,h,Rt]),window,!1),qt(`contextmenu`,L.useCallback(e=>{let t=Ne.current,n=oe?.current;if(t===null||e.target!==t&&e.target!==n||w===void 0)return;let r=lt(t,e.clientX,e.clientY,e);w(r,()=>{e.cancelable&&e.preventDefault()})},[oe,lt,w]),oe?.current??null,!1);let Kt=L.useCallback(e=>{Fe.current=new vi(e.map(e=>e.item)),Re.current=e,St.current(),Fe.current=void 0},[]),Jt=L.useMemo(()=>new fs(Kt),[Kt]),Yt=L.useRef(Jt);Yt.current=Jt,L.useLayoutEffect(()=>{let e=Yt.current;if(ut===void 0||ut[1]<0){e.setHovered(ut);return}let t=p(ut,!0),n=ke(t),r=n===void 0&&t.kind===I.Custom||n?.needsHover!==void 0&&(typeof n.needsHover==`boolean`?n.needsHover:n.needsHover(t));e.setHovered(r?ut:void 0)},[p,ke,ut]);let Xt=L.useRef();qt(`mousemove`,L.useCallback(e=>{let t=Ne.current;if(t===null)return;let n=oe?.current,r=e.target!==t&&e.target!==n,i=lt(t,e.clientX,e.clientY,e);if(i.kind!==`out-of-bounds`&&r&&!Ht.current&&!i.isTouch)return;let a=(e,t)=>{Ve(n=>n===e||n?.[0][0]===e?.[0][0]&&n?.[0][1]===e?.[0][1]&&(n?.[1][0]===e?.[1][0]&&n?.[1][1]===e?.[1][1]||!t)?n:e)};if(!Cs(i,Xt.current))Ke(void 0),ee?.(i),a(i.kind===`out-of-bounds`?void 0:[i.location,[i.localEventX,i.localEventY]],!0),Xt.current=i;else if(i.kind===`cell`||i.kind===`header`||i.kind===`group-header`){let e=!1,t=!0;if(i.kind===`cell`){let n=p(i.location);t=ke(n)?.needsHoverPosition??n.kind===I.Custom,e=t}else i.kind===`group-header`&&(e=!0);let n=[i.location,[i.localEventX,i.localEventY]];a(n,t),ft.current=n,e&&Ct(new vi([i.location]))}let o=i.location[0]>=+!te;Ue(i.kind===`header`&&i.isEdge&&o&&de===!0),Et(i.kind===`cell`&&i.isFillHandle),j?.(e),M(i)},[oe,lt,te,de,j,M,ee,p,ke,Ct]),window,!0);let Zt=L.useCallback(e=>{let t=Ne.current;if(t===null)return;let n,r;S.current!==void 0&&(n=ct(t,S.current.cell[0],S.current.cell[1]),r=S.current.cell),ne?.({bounds:n,stopPropagation:()=>e.stopPropagation(),preventDefault:()=>e.preventDefault(),cancel:()=>void 0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,key:e.key,keyCode:e.keyCode,rawEvent:e,location:r})},[ne,S,ct]),Qt=L.useCallback(e=>{let t=Ne.current;if(t===null)return;let n,r;S.current!==void 0&&(n=ct(t,S.current.cell[0],S.current.cell[1]),r=S.current.cell),P?.({bounds:n,stopPropagation:()=>e.stopPropagation(),preventDefault:()=>e.preventDefault(),cancel:()=>void 0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,key:e.key,keyCode:e.keyCode,rawEvent:e,location:r})},[P,S,ct]),$t=L.useCallback(e=>{Ne.current=e,F!==void 0&&(F.current=e)},[F]);qt(`dragstart`,L.useCallback(e=>{let t=Ne.current;if(t===null||ue===!1||se){e.preventDefault();return}let n,r,i=lt(t,e.clientX,e.clientY);if(ue!==!0&&i.kind!==ue){e.preventDefault();return}let a=(e,t)=>{n=e,r=t},o,s,c,l=(e,t,n)=>{o=e,s=t,c=n},u=!1;if(ie?.({...i,setData:a,setDragImage:l,preventDefault:()=>u=!0,defaultPrevented:()=>u}),!u&&n!==void 0&&r!==void 0&&e.dataTransfer!==null)if(e.dataTransfer.setData(n,r),e.dataTransfer.effectAllowed=`copyLink`,o!==void 0&&s!==void 0&&c!==void 0)e.dataTransfer.setDragImage(o,s,c);else{let[n,r]=i.location;if(r!==void 0){let i=document.createElement(`canvas`),a=ct(t,n,r);x(a!==void 0);let o=Math.ceil(window.devicePixelRatio??1);i.width=a.width*o,i.height=a.height*o;let s=i.getContext(`2d`);s!==null&&(s.scale(o,o),s.textBaseline=`middle`,r===-1?(s.font=he.headerFontFull,s.fillStyle=he.bgHeader,s.fillRect(0,0,i.width,i.height),Ba(s,0,0,a.width,a.height,it[n],!1,he,!1,!1,0,Xe,be,!1)):(s.font=he.baseFontFull,s.fillStyle=he.bgCell,s.fillRect(0,0,i.width,i.height),Ma(s,p([n,r]),0,r,!1,!1,0,0,a.width,a.height,!1,he,he.bgCell,Pe,Xe,1,void 0,!1,0,void 0,void 0,void 0,ht,ke,()=>void 0))),i.style.left=`-100%`,i.style.position=`absolute`,i.style.width=`${a.width}px`,i.style.height=`${a.height}px`,document.body.append(i),e.dataTransfer.setDragImage(i,a.width/2,a.height/2),window.setTimeout(()=>{i.remove()},0)}}else e.preventDefault()},[ue,se,lt,ie,ct,he,it,Xe,be,p,Pe,ht,ke]),oe?.current??null,!1,!1);let en=L.useRef();qt(`dragover`,L.useCallback(e=>{let t=Ne.current;if(Ce!==void 0&&e.preventDefault(),t===null||Se===void 0)return;let[n,r]=lt(t,e.clientX,e.clientY).location,i=n-+!te,[a,o]=en.current??[];(a!==i||o!==r)&&(en.current=[i,r],Se([i,r],e.dataTransfer))},[te,lt,Se,Ce]),oe?.current??null,!1,!1),qt(`dragend`,L.useCallback(()=>{en.current=void 0,ae?.()},[ae]),oe?.current??null,!1,!1),qt(`drop`,L.useCallback(e=>{let t=Ne.current;if(t===null||Ce===void 0)return;e.preventDefault();let[n,r]=lt(t,e.clientX,e.clientY).location,i=n-+!te;Ce([i,r],e.dataTransfer)},[te,lt,Ce]),oe?.current??null,!1,!1),qt(`dragleave`,L.useCallback(()=>{we?.()},[we]),oe?.current??null,!1,!1);let tn=L.useRef(S);tn.current=S;let nn=L.useRef(null),an=L.useCallback(e=>{Ne.current===null||!Ne.current.contains(document.activeElement)||(e===null&&tn.current.current!==void 0?F?.current?.focus({preventScroll:!0}):e!==null&&e.focus({preventScroll:!0}),nn.current=e)},[F]);L.useImperativeHandle(t,()=>({focus:()=>{let e=nn.current;e===null||!document.contains(e)?F?.current?.focus({preventScroll:!0}):e.focus({preventScroll:!0})},getBounds:(e,t)=>{if(!(F===void 0||F.current===null))return ct(F.current,e??0,t??-1)},damage:wt}),[F,wt,ct]);let on=L.useRef(),cn=rn(()=>{if(n<50||Oe?.disableAccessibilityTree===!0)return null;let e=Br(it,Me,n,N,Ae),t=te?0:-1;!te&&e[0]?.sourceIndex===0&&(e=e.slice(1));let[r,a]=S.current?.cell??[],o=S.current?.range,c=e.map(e=>e.sourceIndex),l=(0,ws.default)(s,Math.min(f,s+i));return r!==void 0&&a!==void 0&&!(c.includes(r)&&l.includes(a))&&an(null),L.createElement(`table`,{key:`access-tree`,role:`grid`,"aria-rowcount":f+1,"aria-multiselectable":`true`,"aria-colcount":it.length+t},L.createElement(`thead`,{role:`rowgroup`},L.createElement(`tr`,{role:`row`,"aria-rowindex":1},e.map(e=>L.createElement(`th`,{role:`columnheader`,"aria-selected":S.columns.hasIndex(e.sourceIndex),"aria-colindex":e.sourceIndex+1+t,tabIndex:-1,onFocus:t=>{if(t.target!==nn.current)return xe?.([e.sourceIndex,-1])},key:e.sourceIndex},e.title)))),L.createElement(`tbody`,{role:`rowgroup`},l.map(n=>L.createElement(`tr`,{role:`row`,"aria-selected":S.rows.hasIndex(n),key:n,"aria-rowindex":n+2},e.map(e=>{let i=e.sourceIndex,s=fi(i,n),c=r===i&&a===n,l=o!==void 0&&i>=o.x&&i=o.y&&n{let e=F?.current;if(e!=null)return ne?.({bounds:ct(e,i,n),cancel:()=>void 0,preventDefault:()=>void 0,stopPropagation:()=>void 0,ctrlKey:!1,key:`Enter`,keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:d})},onFocusCapture:e=>{if(!(e.target===nn.current||on.current?.[0]===i&&on.current?.[1]===n))return on.current=d,xe?.(d)},ref:c?an:void 0,tabIndex:-1},Es(f,ke))})))))},[n,it,Me,N,Ae,f,s,i,S,an,p,F,ne,ct,xe],200),ln=C===0||!E?0:Me>C?1:(0,ls.default)(-Ae/100,0,1),un=-s*32+je,dn=D?(0,ls.default)(-un/100,0,1):0,fn=L.useMemo(()=>{if(!ln&&!dn)return null;let e={position:`absolute`,top:0,left:ot,width:n-ot,height:r,opacity:ln,pointerEvents:`none`,transition:Ee?void 0:`opacity 0.2s`,boxShadow:`inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)`},t={position:`absolute`,top:$e,left:0,width:n,height:r,opacity:dn,pointerEvents:`none`,transition:De?void 0:`opacity 0.2s`,boxShadow:`inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)`};return L.createElement(L.Fragment,null,ln>0&&L.createElement(`div`,{id:`shadow-x`,style:e}),dn>0&&L.createElement(`div`,{id:`shadow-y`,style:t}))},[ln,dn,ot,n,Ee,$e,r,De]),pn=L.useMemo(()=>({position:`absolute`,top:0,left:0}),[]);return L.createElement(L.Fragment,null,L.createElement(`canvas`,{"data-testid":`data-grid-canvas`,tabIndex:0,onKeyDown:Zt,onKeyUp:Qt,onFocus:v,onBlur:y,ref:$t,style:Ft},cn),L.createElement(`canvas`,{ref:We,style:pn}),fn)}));function Os(e,t,n,r){return(0,ls.default)(Math.round(t-(e.growOffset??0)),Math.ceil(n),Math.floor(r))}var ks=e=>{let[t,n]=L.useState(),[r,i]=L.useState(),[a,o]=L.useState(),[s,c]=L.useState(),[l,u]=L.useState(!1),[d,f]=L.useState(),[p,m]=L.useState(),[h,g]=L.useState(),[_,v]=L.useState(!1),[y,b]=L.useState(),{onHeaderMenuClick:x,getCellContent:S,onColumnMoved:C,onColumnResize:w,onColumnResizeStart:T,onColumnResizeEnd:E,gridRef:D,maxColumnWidth:O,minColumnWidth:k,onRowMoved:A,lockColumns:j,onColumnProposeMove:M,onMouseDown:ee,onMouseUp:N,onItemHovered:te,onDragStart:ne,canvasRef:P}=e,re=(w??E??T)!==void 0,{columns:F,selection:ie}=e,ae=ie.columns,oe=L.useCallback(e=>{let[t,n]=e.location;a!==void 0&&s!==t&&t>=j?(u(!0),c(t)):p!==void 0&&n!==void 0?(v(!0),g(Math.max(0,n))):r===void 0&&!l&&!_&&te?.(e)},[a,p,s,te,j,r,l,_]),se=C!==void 0,ce=L.useCallback(e=>{if(e.button===0){let[t,r]=e.location;if(e.kind===`out-of-bounds`&&e.isEdge&&re){let e=D?.current?.getBounds(F.length-1,-1);e!==void 0&&(n(e.x),i(F.length-1))}else if(e.kind===`header`&&t>=j){let r=P?.current;if(e.isEdge&&re&&r){n(e.bounds.x),i(t);let a=r.getBoundingClientRect().width/r.offsetWidth,o=e.bounds.width/a;T?.(F[t],o,t,o+(F[t].growOffset??0))}else e.kind===`header`&&se&&(f(e.bounds.x),o(t))}else e.kind===`cell`&&j>0&&t===0&&r!==void 0&&A!==void 0&&(b(e.bounds.y),m(r))}ee?.(e)},[ee,re,j,A,D,F,se,T,P]),le=L.useCallback((e,t)=>{l||_||x?.(e,t)},[l,_,x]),ue=L.useRef(-1),de=L.useCallback(()=>{ue.current=-1,m(void 0),g(void 0),b(void 0),v(!1),o(void 0),c(void 0),f(void 0),u(!1),i(void 0),n(void 0)},[]),fe=L.useCallback((e,t)=>{if(e.button===0){if(r!==void 0){if(ae?.hasIndex(r)===!0)for(let e of ae){if(e===r)continue;let t=F[e],n=Os(t,ue.current,k,O);w?.(t,n,e,n+(t.growOffset??0))}let e=Os(F[r],ue.current,k,O);if(E?.(F[r],e,r,e+(F[r].growOffset??0)),ae.hasIndex(r))for(let e of ae){if(e===r)continue;let t=F[e],n=Os(t,ue.current,k,O);E?.(t,n,e,n+(t.growOffset??0))}}de(),a!==void 0&&s!==void 0&&C?.(a,s),p!==void 0&&h!==void 0&&A?.(p,h)}N?.(e,t)},[N,r,a,s,p,h,ae,E,F,k,O,w,C,A,de]),pe=L.useMemo(()=>{if(!(a===void 0||s===void 0)&&a!==s&&M?.(a,s)!==!1)return{src:a,dest:s}},[a,s,M]),me=L.useCallback(e=>{let n=P?.current;if(a!==void 0&&d!==void 0)Math.abs(e.clientX-d)>20&&u(!0);else if(p!==void 0&&y!==void 0)Math.abs(e.clientY-y)>20&&v(!0);else if(r!==void 0&&t!==void 0&&n){let i=n.getBoundingClientRect().width/n.offsetWidth,a=(e.clientX-t)/i,o=F[r],s=Os(o,a,k,O);if(w?.(o,s,r,s+(o.growOffset??0)),ue.current=a,ae?.first()===r)for(let e of ae){if(e===r)continue;let t=F[e],n=Os(t,ue.current,k,O);w?.(t,n,e,n+(t.growOffset??0))}}},[a,d,p,y,r,t,F,k,O,w,ae,P]),he=L.useCallback((e,t)=>{if(p===void 0||h===void 0)return S(e,t);let[n,r]=e;return r===h?r=p:(r>h&&--r,r>=p&&(r+=1)),S([n,r],t)},[p,h,S]),ge=L.useCallback(e=>{ne?.(e),e.defaultPrevented()||de()},[de,ne]);return L.createElement(Ds,{accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,enableGroups:e.enableGroups,eventTargetRef:e.eventTargetRef,experimental:e.experimental,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,headerIcons:e.headerIcons,height:e.height,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,resizeColumn:r,isDraggable:e.isDraggable,isFilling:e.isFilling,isFocused:e.isFocused,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDrop:e.onDrop,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,verticalBorder:e.verticalBorder,width:e.width,getCellContent:he,isResizing:r!==void 0,onHeaderMenuClick:le,isDragging:l,onItemHovered:oe,onDragStart:ge,onMouseDown:ce,allowResize:re,onMouseUp:fe,dragAndDropState:pe,onMouseMoveRaw:me,ref:D})};function As(e){let t=(0,L.useRef)(null),[n,r]=(0,L.useState)({width:e?.[0],height:e?.[1]});return(0,L.useLayoutEffect)(()=>{let e=new window.ResizeObserver(e=>{for(let t of e){let{width:e,height:n}=t&&t.contentRect||{};r(t=>t.width===e&&t.height===n?t:{width:e,height:n})}});return t.current&&e.observe(t.current,void 0),()=>{e.disconnect()}},[t.current]),{ref:t,...n}}var js=(e,t,n)=>{let r=(0,L.useRef)(null),i=(0,L.useRef)(null),a=(0,L.useRef)(null),o=(0,L.useRef)(0),s=(0,L.useRef)(t);s.current=t;let c=n.current;(0,L.useEffect)(()=>{let t=()=>{if(i.current===!1&&c!==null){let e=[c.scrollLeft,c.scrollTop];if(a.current?.[0]===e[0]&&a.current?.[1]===e[1])if(o.current>10){a.current=null,i.current=null;return}else o.current++;else o.current=0,s.current(e[0],e[1]),a.current=e;r.current=window.setTimeout(t,1e3/120)}},n=()=>{i.current=!0,a.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},l=e=>{e.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(t,1e3/120))};if(e&&c!==null){let e=c;return e.addEventListener(`touchstart`,n),e.addEventListener(`touchend`,l),()=>{e.removeEventListener(`touchstart`,n),e.removeEventListener(`touchend`,l),r.current!==null&&window.clearTimeout(r.current)}}},[e,c])};St();var Ms=xt(`div`)({name:`ScrollRegionStyle`,class:`gdg-s1dgczr6`,propsAsIs:!1,vars:{"s1dgczr6-0":[e=>e.isSafari?`scroll`:`auto`]}});function Ns(e){let[t,n]=L.useState(!1),r=typeof window>`u`?null:window,i=L.useRef(0);return qt(`touchstart`,L.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),qt(`touchend`,L.useCallback(t=>{t.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),e))},[e]),r,!0,!1),t}var Ps=e=>{let{children:t,clientHeight:n,scrollHeight:r,scrollWidth:i,update:a,draggable:o,className:s,preventDiagonalScrolling:c=!1,paddingBottom:l=0,paddingRight:u=0,rightElement:d,rightElementProps:f,kineticScrollPerfHack:p=!1,scrollRef:m,initialSize:h}=e,g=[],_=f?.sticky??!1,v=f?.fill??!1,y=L.useRef(0),b=L.useRef(0),x=L.useRef(null),S=typeof window>`u`?1:window.devicePixelRatio,C=L.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),w=L.useRef(null),T=Ns(200),[E,D]=L.useState(!0),O=L.useRef(0);L.useLayoutEffect(()=>{if(!E||T||C.current.lockDirection===void 0)return;let e=x.current;if(e===null)return;let[t,n]=C.current.lockDirection;t===void 0?n!==void 0&&(e.scrollTop=n):e.scrollLeft=t,C.current.lockDirection=void 0},[T,E]);let k=L.useCallback((e,t)=>{let n=x.current;if(n===null)return;t??=n.scrollTop,e??=n.scrollLeft;let i=C.current.scrollTop,o=C.current.scrollLeft,s=e-o,d=t-i;T&&s!==0&&d!==0&&(Math.abs(s)>3||Math.abs(d)>3)&&c&&C.current.lockDirection===void 0&&(C.current.lockDirection=Math.abs(s)0&&(Math.abs(g)>2e3||h===0||h===_)&&r>n.scrollHeight+5){let e=h/_,t=(r-m)*e;y.current=t-h}f!==void 0&&(window.clearTimeout(O.current),D(!1),O.current=window.setTimeout(()=>D(!0),200)),a({x:e,y:h+y.current,width:p-u,height:m-l,paddingRight:w.current?.clientWidth??0})},[l,u,r,a,c,T]);js(p&&gs.value,k,x);let A=L.useRef(k);A.current=k;let j=L.useRef(),M=L.useRef(!1);L.useLayoutEffect(()=>{M.current?k():M.current=!0},[k,l,u]);let ee=L.useCallback(e=>{x.current=e,m!==void 0&&(m.current=e)},[m]),N=0,te=0;for(g.push(L.createElement(`div`,{key:N++,style:{width:i,height:0}}));teA.current(),0),j.current={width:P,height:re}),(P??0)===0||(re??0)===0?L.createElement(`div`,{ref:ne}):L.createElement(`div`,{ref:ne},L.createElement(Ms,{isSafari:gs.value},L.createElement(`div`,{className:`dvn-underlay`},t),L.createElement(`div`,{ref:ee,style:j.current,draggable:o,onDragStart:e=>{o||(e.stopPropagation(),e.preventDefault())},className:`dvn-scroller `+(s??``),onScroll:()=>k()},L.createElement(`div`,{className:`dvn-scroll-inner`+(d===void 0?` dvn-hidden`:``)},L.createElement(`div`,{className:`dvn-stack`},g),d!==void 0&&L.createElement(L.Fragment,null,!v&&L.createElement(`div`,{className:`dvn-spacer`}),L.createElement(`div`,{ref:w,style:{height:re,maxHeight:n-Math.ceil(S%1),position:`sticky`,top:0,paddingLeft:1,marginBottom:-40,marginRight:u,flexGrow:v?1:void 0,right:_?u??0:void 0,pointerEvents:`auto`}},d))))))},Fs=e=>{let{columns:t,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:a,enableGroups:o,freezeColumns:s,experimental:c,nonGrowWidth:l,clientSize:u,className:d,onVisibleRegionChanged:f,scrollRef:p,preventDiagonalScrolling:m,rightElement:h,rightElementProps:g,overscrollX:_,overscrollY:v,initialSize:y,smoothScrollX:b=!1,smoothScrollY:x=!1,isDraggable:S}=e,{paddingRight:C,paddingBottom:w}=c??{},[T,E]=u,D=L.useRef(),O=L.useRef(),k=L.useRef(),A=L.useRef(),j=l+Math.max(0,_??0),M=o?i+a:i;if(typeof r==`number`)M+=n*r;else for(let e=0;e{if(ee.current===void 0)return;let e={...ee.current},i=0,a=e.x<0?-e.x:0,o=0,c=0;e.x=e.x<0?0:e.x;let l=0;for(let e=0;e=t+n.width)i+=n.width,c++,o++;else if(e.x>t)i+=n.width,b?a+=t-e.x:c++,o++;else if(e.x+e.width>t)i+=n.width,o++;else break}let u=0,d=0,p=0;if(typeof r==`number`)x?(d=Math.floor(e.y/r),u=d*r-e.y):d=Math.ceil(e.y/r),p=Math.ceil(e.height/r)+d,u<0&&p++;else{let t=0;for(let i=0;i=t+n)t+=n,d++,p++;else if(e.y>a)t+=n,x?u+=a-e.y:d++,p++;else if(e.y+e.height>n/2+t)t+=n,p++;else break}}let m={x:c,y:d,width:o-c,height:p-d},h=D.current;(h===void 0||h.y!==m.y||h.x!==m.x||h.height!==m.height||h.width!==m.width||O.current!==a||k.current!==u||e.width!==A.current?.[0]||e.height!==A.current?.[1])&&(f?.({x:c,y:d,width:o-c,height:p-d},e.width,e.height,e.paddingRight??0,a,u),D.current=m,O.current=a,k.current=u,A.current=[e.width,e.height])},[t,r,n,f,s,b,x]),te=L.useCallback(e=>{ee.current=e,N()},[N]);return L.useEffect(()=>{N()},[N]),L.createElement(Ps,{scrollRef:p,className:d,kineticScrollPerfHack:c?.kineticScrollPerfHack,preventDiagonalScrolling:m,draggable:S===!0||typeof S==`string`,scrollWidth:j+(C??0),scrollHeight:M+(w??0),clientHeight:E,rightElement:h,paddingBottom:w,paddingRight:C,rightElementProps:g,update:te,initialSize:y},L.createElement(ks,{eventTargetRef:p,width:T,height:E,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,onColumnProposeMove:e.onColumnProposeMove,verticalBorder:e.verticalBorder,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY}))};St();var Is=xt(`div`)({name:`SearchWrapper`,class:`gdg-seveqep`,propsAsIs:!1});ct(),E();var Ls=L.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},L.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`48`,d:`M112 244l144-144 144 144M256 120v292`})),Rs=L.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},L.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`48`,d:`M112 268l144 144 144-144M256 392V100`})),zs=L.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},L.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`32`,d:`M368 368L144 144M368 144L144 368`})),Bs=10,Vs=e=>{let{canvasRef:t,cellYOffset:n,rows:r,columns:i,searchInputRef:a,searchValue:o,searchResults:s,onSearchValueChange:c,getCellsForSelection:l,onSearchResultsChanged:u,showSearch:d=!1,onSearchClose:f}=e,[p]=L.useState(()=>`search-box-`+Math.round(Math.random()*1e3)),[m,h]=L.useState(``),g=o??m,_=L.useCallback(e=>{h(e),c?.(e)},[c]),[v,y]=L.useState(),b=L.useRef(v);b.current=v,L.useEffect(()=>{s!==void 0&&(s.length>0?y(e=>({rowsSearched:r,results:s.length,selectedIndex:e?.selectedIndex??-1})):y(void 0))},[r,s]);let S=L.useRef();S.current===void 0&&(S.current=new AbortController);let C=L.useRef(),[w,T]=L.useState([]),E=s??w,D=L.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.current=void 0,S.current.abort())},[]),O=L.useRef(n);O.current=n;let k=L.useCallback(e=>{let t=new RegExp(e.replace(/([$()*+.?[\\\]^{|}-])/g,`\\$1`),`i`),n=O.current,a=Math.min(10,r),o=0;y(void 0),T([]);let s=[],c=async()=>{if(l===void 0)return;let e=performance.now(),d=r-o,f=l({x:0,y:n,width:i.length,height:Math.min(a,d,r-n)},S.current.signal);typeof f==`function`&&(f=await f());let p=!1;for(let[e,r]of f.entries())for(let[i,a]of r.entries()){let r;switch(a.kind){case I.Text:case I.Number:r=a.displayData;break;case I.Uri:case I.Markdown:r=a.data;break;case I.Boolean:r=typeof a.data==`boolean`?a.data.toString():void 0;break;case I.Image:case I.Bubble:r=a.data.join(`🐳`);break;case I.Custom:r=a.copyData;break}r!==void 0&&t.test(r)&&(s.push([i,e+n]),p=!0)}let m=performance.now();p&&T([...s]),o+=f.length,x(o<=r);let h=b.current?.selectedIndex??-1;y({results:s.length,rowsSearched:o,selectedIndex:h}),u?.(s,h),n+a>=r?n=0:n+=a;let g=m-e,_=Bs/Math.max(g,1);a=Math.ceil(a*_),o{f?.(),y(void 0),T([]),u?.([],-1),D(),t?.current?.focus()},[D,t,f,u]),j=L.useCallback(e=>{_(e.target.value),s===void 0&&(e.target.value===``?(y(void 0),T([]),D()):k(e.target.value))},[k,D,_,s]);L.useEffect(()=>{d&&a.current!==null&&(_(``),a.current.focus({preventScroll:!0}))},[d,a,_]);let M=L.useCallback(e=>{if(e?.stopPropagation?.(),v===void 0)return;let t=(v.selectedIndex+1)%v.results;y({...v,selectedIndex:t}),u?.(E,t)},[v,u,E]),ee=L.useCallback(e=>{if(e?.stopPropagation?.(),v===void 0)return;let t=(v.selectedIndex-1)%v.results;t<0&&(t+=v.results),y({...v,selectedIndex:t}),u?.(E,t)},[u,E,v]),N=L.useCallback(e=>{(e.ctrlKey||e.metaKey)&&e.nativeEvent.code===`KeyF`||e.key===`Escape`?(A(),e.stopPropagation(),e.preventDefault()):e.key===`Enter`&&(e.shiftKey?ee():M())},[A,M,ee]);L.useEffect(()=>()=>{D()},[D]);let[te,ne]=L.useState(!1);L.useEffect(()=>{if(d)ne(!0);else{let e=setTimeout(()=>ne(!1),150);return()=>clearTimeout(e)}},[d]);let P=L.useMemo(()=>{if(!d&&!te)return null;let e;v!==void 0&&(e=v.results>=1e3?`over 1000`:`${v.results} result${v.results===1?``:`s`}`,v.selectedIndex>=0&&(e=`${v.selectedIndex+1} of ${e}`));let t=e=>{e.stopPropagation()},n={width:`${Math.floor((v?.rowsSearched??0)/r*100)}%`};return L.createElement(Is,{className:d?``:`out`,onMouseDown:t,onMouseMove:t,onMouseUp:t,onClick:t},L.createElement(`div`,{className:`gdg-search-bar-inner`},L.createElement(`input`,{id:p,"aria-hidden":!d,"data-testid":`search-input`,ref:a,onChange:j,value:g,tabIndex:d?void 0:-1,onKeyDownCapture:N}),L.createElement(`button`,{"aria-label":`Previous Result`,"aria-hidden":!d,tabIndex:d?void 0:-1,onClick:ee,disabled:(v?.results??0)===0},Ls),L.createElement(`button`,{"aria-label":`Next Result`,"aria-hidden":!d,tabIndex:d?void 0:-1,onClick:M,disabled:(v?.results??0)===0},Rs),f!==void 0&&L.createElement(`button`,{"aria-label":`Close Search`,"aria-hidden":!d,"data-testid":`search-close-button`,tabIndex:d?void 0:-1,onClick:A},zs)),v===void 0?L.createElement(`div`,{className:`gdg-search-status`},L.createElement(`label`,{htmlFor:p},`Type to search`)):L.createElement(L.Fragment,null,L.createElement(`div`,{className:`gdg-search-status`},L.createElement(`div`,{"data-testid":`search-result-area`},e)),L.createElement(`div`,{className:`gdg-search-progress`,style:n})))},[d,te,v,r,p,a,j,g,N,ee,M,f,A]);return L.createElement(L.Fragment,null,L.createElement(Fs,{prelightCells:E,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,className:e.className,clientSize:e.clientSize,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,nonGrowWidth:e.nonGrowWidth,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,initialSize:e.initialSize,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onMouseMove:e.onMouseMove,onVisibleRegionChanged:e.onVisibleRegionChanged,overscrollX:e.overscrollX,overscrollY:e.overscrollY,preventDiagonalScrolling:e.preventDiagonalScrolling,rightElement:e.rightElement,rightElementProps:e.rightElementProps,rowHeight:e.rowHeight,rows:e.rows,scrollRef:e.scrollRef,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,verticalBorder:e.verticalBorder,onColumnProposeMove:e.onColumnProposeMove,drawFocusRing:e.drawFocusRing,drawCell:e.drawCell,drawHeader:e.drawHeader,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY}),P)},Hs,Us,Ws=o((()=>{Hs=u(f(),1),Us=class extends Hs.PureComponent{wrapperRef=Hs.createRef();componentDidMount(){document.addEventListener(`touchend`,this.clickOutside,!0),document.addEventListener(`mousedown`,this.clickOutside,!0),document.addEventListener(`contextmenu`,this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener(`touchend`,this.clickOutside,!0),document.removeEventListener(`mousedown`,this.clickOutside,!0),document.removeEventListener(`contextmenu`,this.clickOutside,!0)}clickOutside=e=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(e))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(e.target)){let t=e.target;for(;t!==null;){if(t.classList.contains(`click-outside-ignore`))return;t=t.parentElement}this.props.onClickOutside()}};render(){let{onClickOutside:e,isOutsideClick:t,...n}=this.props;return Hs.createElement(`div`,{...n,ref:this.wrapperRef},this.props.children)}}}));St(),Ws();var Gs=xt(`input`)({name:`RenameInput`,class:`gdg-r17m35ur`,propsAsIs:!1,vars:{"r17m35ur-0":[e=>Math.max(16,e.targetHeight-10),`px`]}}),Ks=e=>{let{bounds:t,group:n,onClose:r,canvasBounds:i,onFinish:a}=e,[o,s]=L.useState(n);return L.createElement(Us,{style:{position:`absolute`,left:t.x-i.left+1,top:t.y-i.top,width:t.width-2,height:t.height},className:`gdg-c1tqibwd`,onClickOutside:r},L.createElement(Gs,{targetHeight:t.height,"data-testid":`group-rename-input`,value:o,onBlur:r,onFocus:e=>e.target.setSelectionRange(0,o.length),onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?a(o):e.key===`Escape`&&r()},autoFocus:!0}))};function qs(e,t){return e===void 0?!1:e.length>1&&e.startsWith(`_`)?Number.parseInt(e.slice(1))===t.keyCode:e.length===1&&e>=`a`&&e<=`z`?e.toUpperCase().codePointAt(0)===t.keyCode:e===t.key}function Js(e,t,n){let r=Ys(e,t);return r&&(n.didMatch=!0),r}function Ys(e,t){if(e.length===0)return!1;if(e.includes(`|`)){let n=e.split(`|`);for(let e of n)if(Ys(e,t))return!0;return!1}let n=!1,r=!1,i=!1,a=!1,o=e.split(`+`);if(!qs(o.pop(),t))return!1;if(o[0]===`any`)return!0;for(let e of o)switch(e){case`ctrl`:n=!0;break;case`shift`:r=!0;break;case`alt`:i=!0;break;case`meta`:a=!0;break;case`primary`:_s.value?a=!0:n=!0;break}return t.altKey===i&&t.ctrlKey===n&&t.shiftKey===r&&t.metaKey===a}ct();function Xs(e,t,n,r,i,a){return[L.useCallback((o,s,c,l)=>{(a===`cell`||a===`multi-cell`)&&o!==void 0&&(o={...o,range:{x:o.cell[0],y:o.cell[1],width:1,height:1}});let u=n===`mixed`&&(c||l===`drag`),d=r===`mixed`&&u,f=i===`mixed`&&u,p={current:o===void 0?void 0:{...o,rangeStack:l===`drag`?e.current?.rangeStack??[]:[]},columns:d?e.columns:st.empty(),rows:f?e.rows:st.empty()};c&&(a===`multi-rect`||a===`multi-cell`)&&p.current!==void 0&&e.current!==void 0&&(p={...p,current:{...p.current,rangeStack:[...e.current.rangeStack,e.current.range]}}),t(p,s)},[r,e,n,a,i,t]),L.useCallback((a,o,s)=>{a??=e.rows,o!==void 0&&(a=a.add(o));let c;if(i===`exclusive`&&a.length>0)c={current:void 0,columns:st.empty(),rows:a};else{let t=s&&n===`mixed`,i=s&&r===`mixed`;c={current:t?e.current:void 0,columns:i?e.columns:st.empty(),rows:a}}t(c,!1)},[r,e,n,i,t]),L.useCallback((a,o,s)=>{a??=e.columns,o!==void 0&&(a=a.add(o));let c;if(r===`exclusive`&&a.length>0)c={current:void 0,rows:st.empty(),columns:a};else{let t=s&&n===`mixed`,r=s&&i===`mixed`;c={current:t?e.current:void 0,rows:r?e.rows:st.empty(),columns:a}}t(c,!1)},[r,e,n,i,t])]}ct();function Zs(e,t,n,r,i){let a=L.useCallback(n=>{if(e===!0){let e=[];for(let r=n.y;r=i?a.push({kind:I.Loading,allowOverlay:!1}):a.push(t([e,r]));e.push(a)}return e}return e?.(n,r.signal)??[]},[r.signal,t,e,i]),o=e===void 0?void 0:a,s=L.useCallback(e=>{if(o===void 0)return[];let t={...e,x:e.x-n};if(t.x<0){t.x=0,t.width--;let e=o(t,r.signal);return typeof e==`function`?async()=>(await e()).map(e=>[{kind:I.Loading,allowOverlay:!1},...e]):e.map(e=>[{kind:I.Loading,allowOverlay:!1},...e])}return o(t,r.signal)},[r.signal,o,n]);return[e===void 0?void 0:s,o]}E(),ct();function Qs(e){if(e.copyData!==void 0)return{formatted:e.copyData,rawValue:e.copyData,format:`string`};switch(e.kind){case I.Boolean:return{formatted:e.data===!0?`TRUE`:e.data===!1?`FALSE`:e.data===void 0?`INDETERMINATE`:``,rawValue:e.data,format:`boolean`};case I.Custom:return{formatted:e.copyData,rawValue:e.copyData,format:`string`};case I.Image:case I.Bubble:return{formatted:e.data,rawValue:e.data,format:`string-array`};case I.Drilldown:return{formatted:e.data.map(e=>e.text),rawValue:e.data.map(e=>e.text),format:`string-array`};case I.Text:return{formatted:e.displayData??e.data,rawValue:e.data,format:`string`};case I.Uri:return{formatted:e.displayData??e.data,rawValue:e.data,format:`url`};case I.Markdown:case I.RowID:return{formatted:e.data,rawValue:e.data,format:`string`};case I.Number:return{formatted:e.displayData,rawValue:e.data,format:`number`};case I.Loading:return{formatted:`#LOADING`,rawValue:``,format:`string`};case I.Protected:return{formatted:`************`,rawValue:``,format:`string`};default:S(e)}}function $s(e,t){return e.map((e,n)=>{let r=t[n];return e.map(e=>e.span!==void 0&&e.span[0]!==r?{formatted:``,rawValue:``,format:`string`}:Qs(e))})}function ec(e,t){return(t?/[\t\n",]/:/[\t\n"]/).test(e)&&(e=`"${e.replace(/"/g,`""`)}"`),e}function tc(e){let t=[];for(let n of e){let e=[];for(let t of n)t.format===`url`?e.push(t.rawValue?.toString()??``):t.format===`string-array`?e.push(t.formatted.map(e=>ec(e,!0)).join(`,`)):e.push(ec(t.formatted,!1));t.push(e.join(` `))}return t.join(` -`)}function nc(e){return e.replace(/\t/g,` `).replace(/ {2,}/g,e=>` `.repeat(e.length))}function rc(e){return`"`+e.replace(/&/g,`&`).replace(/"/g,`"`).replace(//g,`>`)+`"`}function ic(e){return e.replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`)}function ac(e){let t=[];t.push(``,``);for(let n of e){t.push(``);for(let e of n){let n=`gdg-format="${e.format}"`;e.format===`url`?t.push(``):e.format===`string-array`?t.push(``):t.push(``)}t.push(``)}return t.push(`
${nc(e.formatted)}
    ${e.formatted.map((t,n)=>`
  1. `+nc(t)+`
  2. `).join(``)}
${nc(e.formatted)}
`),t.join(``)}function oc(e,t){let n=$s(e,t);return{textPlain:tc(n),textHtml:ac(n)}}function sc(e){let t=document.createElement(`html`);t.innerHTML=e.replace(/ /g,` `);let n=t.querySelector(`table`);if(n===null)return;let r=[n],i=[],a;for(;r.length>0;){let e=r.pop();if(e===void 0)break;if(e instanceof HTMLTableElement||e.nodeName===`TBODY`)r.push(...[...e.children].reverse());else if(e instanceof HTMLTableRowElement)a!==void 0&&i.push(a),a=[],r.push(...[...e.children].reverse());else if(e instanceof HTMLTableCellElement){let t=e.cloneNode(!0),n=t.children.length===1&&t.children[0].nodeName===`P`?t.children[0]:null,r=n?.children.length===1&&n.children[0].nodeName===`FONT`,i=t.querySelectorAll(`br`);for(let e of i)e.replaceWith(` -`);let o=t.getAttribute(`gdg-raw-value`),s=t.getAttribute(`gdg-format`)??`string`;if(t.querySelector(`a`)!==null)a?.push({rawValue:t.querySelector(`a`)?.getAttribute(`href`)??``,formatted:t.textContent??``,format:s});else if(t.querySelector(`ol`)!==null){let e=t.querySelectorAll(`li`);a?.push({rawValue:[...e].map(e=>e.getAttribute(`gdg-raw-value`)??``),formatted:[...e].map(e=>e.textContent??``),format:`string-array`})}else if(o!==null)a?.push({rawValue:ic(o),formatted:t.textContent??``,format:s});else{let e=t.textContent??``;r&&(e=e.replace(/\n(?!\n)/g,``)),a?.push({rawValue:e??``,formatted:e??``,format:s})}}}return a!==void 0&&i.push(a),i}function cc(e,t,n,r,i){let a=e;if(r===`allowPartial`||e.current===void 0||t===void 0)return e;let o=!1;do{if(e?.current===void 0)break;let r=e.current?.range,s=[];if(r.width>2){let e=t({x:r.x,y:r.y,width:1,height:r.height},i.signal);if(typeof e==`function`)return a;s.push(...e);let n=t({x:r.x+r.width-1,y:r.y,width:1,height:r.height},i.signal);if(typeof n==`function`)return a;s.push(...n)}else{let e=t({x:r.x,y:r.y,width:r.width,height:r.height},i.signal);if(typeof e==`function`)return a;s.push(...e)}let c=r.x-n,l=r.x+r.width-1-n;for(let e of s)for(let t of e)t.span!==void 0&&(c=Math.min(t.span[0],c),l=Math.max(t.span[1],l));c===r.x-n&&l===r.x+r.width-1-n?o=!0:e={current:{cell:e.current.cell??[0,0],range:{x:c+n,y:r.y,width:l-c+1,height:r.height},rangeStack:e.current.rangeStack},columns:e.columns,rows:e.rows}}while(!o);return e}function lc(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&(e=e.slice(1,-1).replace(/""/g,`"`)),e}function uc(e){let t;(function(e){e[e.None=0]=`None`,e[e.inString=1]=`inString`,e[e.inStringPostQuote=2]=`inStringPostQuote`})(t||={});let n=[],r=[],i=0,a=t.None;e=e.replace(/\r\n/g,` +`}};function eee(e,t){return e===`normal`?[t.bgIconHeader,t.fgIconHeader]:e===`selected`?[`white`,t.accentColor]:[t.accentColor,t.bgHeader]}var fa=class{onSettled;spriteMap=new Map;headerIcons;inFlight=0;constructor(e,t){this.onSettled=t,this.headerIcons=e??{}}drawSprite(e,t,n,r,i,a,o,s=1){let[c,l]=eee(t,o),u=a*Math.ceil(window.devicePixelRatio),d=`${c}_${l}_${u}_${e}`,f=this.spriteMap.get(d);if(f===void 0){let t=this.headerIcons[e];if(t===void 0)return;f=document.createElement(`canvas`);let n=f.getContext(`2d`);if(n===null)return;let r=new Image;r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t({fgColor:l,bgColor:c}))}`,this.spriteMap.set(d,f);let i=r.decode();if(i===void 0)return;this.inFlight++,i.then(()=>{n.drawImage(r,0,0,u,u)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else s<1&&(n.globalAlpha=s),n.drawImage(f,0,0,u,u,r,i,a,a),s<1&&(n.globalAlpha=1)}};function pa(e){if(e.length===0)return;let t;for(let n of e)t=Math.min(t??n.y,n.y)}function ma(e,t,n,r,i,a,o,s,c){s??=t;let l=t,u=e,d=r-a,f=!1;for(;ls&&c(l,u,e,!1,o&&u===r-1)===!0){f=!0;break}l+=e,u++}if(!f){l=n;for(let e=0;e!e.sticky)?.sourceIndex??0;if(c>d){let e=Math.max(s,d),l=t,f=r;for(let t=a.sourceIndex-1;t>=e;t--)l-=o[t].width,f+=o[t].width;for(let e=a.sourceIndex+1;e<=c;e++)f+=o[e].width;u={x:l,y:n,width:f,height:i}}if(d>s){let e=Math.min(c,d-1),u=t,f=r;for(let e=a.sourceIndex-1;e>=s;e--)u-=o[e].width,f+=o[e].width;for(let t=a.sourceIndex+1;t<=e;t++)f+=o[t].width;l={x:u,y:n,width:f,height:i}}return[l,u]}function va(e,t,n,r){if(r===`any`)return xa(e,{x:t,y:n,width:1,height:1});if(r===`vertical`&&(t=e.x),r===`horizontal`&&(n=e.y),Mr([t,n],e))return;let i=t-e.x,a=e.x+e.width-t,o=n-e.y+1,s=e.y+e.height-n,c=Math.min(r===`vertical`?2**53-1:i,r===`vertical`?2**53-1:a,r===`horizontal`?2**53-1:o,r===`horizontal`?2**53-1:s);return c===s?{x:e.x,y:e.y+e.height,width:e.width,height:n-e.y-e.height+1}:c===o?{x:e.x,y:n,width:e.width,height:e.y-n}:c===a?{x:e.x+e.width,y:e.y,width:t-e.x-e.width+1,height:e.height}:{x:t,y:e.y,width:e.x-t,height:e.height}}function ya(e,t,n,r,i,a,o,s){return e<=i+o&&i<=e+n&&t<=a+s&&a<=t+r}function ba(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function xa(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-r}}function Sa(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}function Ca(e,t,n,r){if(e.x>t||e.y>n||e.x<0&&e.y<0&&e.x+e.width>t&&e.y+e.height>n)return;if(e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n)return e;let i=t+4,a=n+4,o=-4-e.x,s=e.x+e.width-i,c=-4-e.y,l=e.y+e.height-a,u=o>0?e.x+Math.floor(o/r)*r:e.x,d=s>0?e.x+e.width-Math.floor(s/r)*r:e.x+e.width,f=c>0?e.y+Math.floor(c/r)*r:e.y,p=l>0?e.y+e.height-Math.floor(l/r)*r:e.y+e.height;return{x:u,y:f,width:d-u,height:p-f}}function wa(e,t,n,r,i){let[a,o,s,c]=t,[l,u,d,f]=i,{x:p,y:m,width:h,height:g}=e,_=[];if(h<=0||g<=0)return _;let v=p+h,y=m+g,b=ps,C=m+g>c,w=p>=a&&pa&&v<=s||ps,T=m>=o&&mo&&y<=c||mc;if(w&&T){let e=Math.max(p,a),t=Math.max(m,o),n=Math.min(v,s),r=Math.min(y,c);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:l,y:u,width:d-l+1,height:f-u+1}})}if(b&&x){let e=p,t=m,n=Math.min(v,a),r=Math.min(y,o);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:0,y:0,width:l+1,height:u+1}})}if(x&&w){let e=Math.max(p,a),t=m,n=Math.min(v,s),r=Math.min(y,o);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:l,y:0,width:d-l+1,height:u+1}})}if(x&&S){let e=Math.max(p,s),t=m,r=v,i=Math.min(y,o);_.push({rect:{x:e,y:t,width:r-e,height:i-t},clip:{x:d,y:0,width:n-d+1,height:u+1}})}if(b&&T){let e=p,t=Math.max(m,o),n=Math.min(v,a),r=Math.min(y,c);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:0,y:u,width:l+1,height:f-u+1}})}if(S&&T){let e=Math.max(p,s),t=Math.max(m,o),r=v,i=Math.min(y,c);_.push({rect:{x:e,y:t,width:r-e,height:i-t},clip:{x:d,y:u,width:n-d+1,height:f-u+1}})}if(b&&C){let e=p,t=Math.max(m,c),n=Math.min(v,a),i=y;_.push({rect:{x:e,y:t,width:n-e,height:i-t},clip:{x:0,y:f,width:l+1,height:r-f+1}})}if(C&&w){let e=Math.max(p,a),t=Math.max(m,c),n=Math.min(v,s),i=y;_.push({rect:{x:e,y:t,width:n-e,height:i-t},clip:{x:l,y:f,width:d-l+1,height:r-f+1}})}if(S&&C){let e=Math.max(p,s),t=Math.max(m,c),i=v,a=y;_.push({rect:{x:e,y:t,width:i-e,height:a-t},clip:{x:d,y:f,width:n-d+1,height:r-f+1}})}return _}ct(),Ti(),vr();var Ta={kind:I.Loading,allowOverlay:!1};function Ea(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,ee,N){let te=y?.size??2**53-1,ne=performance.now(),P=k.baseFontFull;e.font=P;let re={ctx:e},F=[0,0],ie=g>0?zr(c,g,l):0,ae,oe,se=pa(v);return ha(t,s,a,o,i,(t,a,o,s,ce)=>{let le=Math.max(0,s-a),ue=a+le,de=i+1,fe=t.width-le,pe=r-i-1;if(v.length>0){let e=!1;for(let t=0;t{e.save(),e.beginPath(),e.rect(ue,de,fe,pe),e.clip()},he=b.columns.hasIndex(t.sourceIndex),ge=d(t.group??``).overrideTheme,_e=t.themeOverride===void 0&&ge===void 0?k:xi(k,ge,t.themeOverride),ve=_e.baseFontFull;ve!==P&&(P=ve,e.font=ve),me();let ye;return ma(ce,o,r,c,l,g,_,se,(i,o,l,d,g)=>{if(o<0||(F[0]=t.sourceIndex,F[1]=o,y!==void 0&&!y.has(F)))return;if(v.length>0){let e=!1;for(let n=0;nce.span!==void 0&&e>=ce.span[0]&&e<=ce.span[1]);xe&&!m&&h?Se=0:xe&&h&&(Se=Math.max(Se,1)),Ce&&Se++,xe||(_&&Se++,he&&!g&&Se++);let we=ce.kind===I.Protected?be.bgCellMedium:be.bgCell,Te;if((d||we!==k.bgCell)&&(Te=mr(we,Te)),Se>0||se){se&&(Te=mr(be.bgHeader,Te));for(let e=0;eN&&!fe){let n=be.baseFontFull;n!==P&&(e.font=n,P=n),ye=Ma(e,ce,t.sourceIndex,o,De,Oe,le,i,ue,l,Se>0,be,Te??be.bgCell,C,w,ke?.hoverAmount??0,E,O,ne,D,ye,A,j,M,ee)}return Ee&&e.restore(),ce.style===`faded`&&(e.globalAlpha=1),te--,de&&(e.restore(),ye?.deprep?.(re),ye=void 0,me(),P=ve,e.font=ve),te<=0}),e.restore(),te<=0}),ae}var Da=[0,0],Oa={x:0,y:0,width:0,height:0},ka=[void 0,()=>void 0],Aa=!1;function ja(){Aa=!0}function Ma(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w){let T,E;g!==void 0&&g[0][0]===n&&g[0][1]===r&&(T=g[1][0],E=g[1][1]);let D;Da[0]=n,Da[1]=r,Oa.x=o,Oa.y=s,Oa.width=c,Oa.height=l,ka[0]=S.getValue(Da),ka[1]=e=>S.setValue(Da,e),Aa=!1;let O={ctx:e,theme:d,col:n,row:r,cell:t,rect:Oa,highlighted:u,cellFillColor:f,hoverAmount:h,frameTime:v,hoverX:T,drawState:ka,hoverY:E,imageLoader:p,spriteManager:m,hyperWrapping:_,overrideCursor:T===void 0?void 0:w,requestAnimationFrame:ja},k=ei(O,t.lastUpdated,v,b,i,a),A=C(t);if(A!==void 0){b?.renderer!==A&&(b?.deprep?.(O),b=void 0);let e=A.drawPrep?.(O,b);y!==void 0&&!Ze(O.cell)?y(O,()=>A.draw(O,t)):A.draw(O,t),D=e===void 0?void 0:{deprep:e?.deprep,fillStyle:e?.fillStyle,font:e?.font,renderer:A}}return(k||Aa)&&x?.(Da),D}E(),ct();function Na(e,t,n,r,i,a,o,s,c=-20,l=-20,u=32,d=`center`,f=`square`){let p=Math.floor(i+o/2),m=f===`circle`?1e4:t.roundingRadius??4,h=$t(u,o,t.cellVerticalPadding),g=h/2,_=Qt(d,r,a,t.cellHorizontalPadding,h),v=Zt(_,p,h),y=en(r+c,i+l,v);switch(n){case!0:e.beginPath(),si(e,_-h/2,p-h/2,h,h,m),f===`circle`&&(g*=.8,h*=.8),e.fillStyle=s?t.accentColor:t.textMedium,e.fill(),e.beginPath(),e.moveTo(_-g+h/4.23,p-g+h/1.97),e.lineTo(_-g+h/2.42,p-g+h/1.44),e.lineTo(_-g+h/1.29,p-g+h/3.25),e.strokeStyle=t.bgCell,e.lineJoin=`round`,e.lineCap=`round`,e.lineWidth=1.9,e.stroke();break;case null:case!1:e.beginPath(),si(e,_-h/2+.5,p-h/2+.5,h-1,h-1,m),e.lineWidth=1,e.strokeStyle=y?t.textDark:t.textMedium,e.stroke();break;case void 0:e.beginPath(),si(e,_-h/2,p-h/2,h,h,m),e.fillStyle=y?t.textMedium:t.textLight,e.fill(),f===`circle`&&(g*=.8,h*=.8),e.beginPath(),e.moveTo(_-h/3,p),e.lineTo(_+h/3,p),e.strokeStyle=t.bgCell,e.lineCap=`round`,e.lineWidth=1.9,e.stroke();break;default:S(n)}}Ti(),vr(),ct();function Pa(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=o+s;if(y<=0)return;e.fillStyle=d.bgHeader,e.fillRect(0,0,i,y);let[b,x]=r?.[0]??[];e.font=d.headerFontFull,ha(t,0,a,0,y,(t,r,i,a)=>{if(g!==void 0&&!g.has([t.sourceIndex,-1]))return;let m=Math.max(0,a-r);e.save(),e.beginPath(),e.rect(r+m,s,t.width-m,o),e.clip();let y=h(t.group??``).overrideTheme,S=t.themeOverride===void 0&&y===void 0?d:xi(d,y,t.themeOverride);S.bgHeader!==d.bgHeader&&(e.fillStyle=S.bgHeader,e.fill()),S!==d&&(e.font=S.baseFontFull);let C=u.columns.hasIndex(t.sourceIndex),w=c!==void 0||l,T=!w&&x===-1&&b===t.sourceIndex,E=w?0:p.find(e=>e.item[0]===t.sourceIndex&&e.item[1]===-1)?.hoverAmount??0,D=u?.current!==void 0&&u.current.cell[0]===t.sourceIndex,O=C?S.accentColor:D?S.bgHeaderHasFocus:S.bgHeader,k=n?s:0,A=t.sourceIndex===0?0:1;C?(e.fillStyle=O,e.fillRect(r+A,k,t.width-A,o)):(D||E>0)&&(e.beginPath(),e.rect(r+A,k,t.width-A,o),D&&(e.fillStyle=S.bgHeaderHasFocus,e.fill()),E>0&&(e.globalAlpha=E,e.fillStyle=S.bgHeaderHovered,e.fill(),e.globalAlpha=1)),Ba(e,r,k,t.width,o,t,C,S,T,D,E,f,_,v),e.restore()}),n&&Fa(e,t,i,a,s,r,d,f,p,m,h,g)}function Fa(e,t,n,r,i,a,o,s,c,l,u,d){let[f,p]=a?.[0]??[],m=0;ga(t,n,r,i,(t,n,r,c,h,g)=>{if(d!==void 0&&!d.hasItemInRectangle({x:t[0],y:-2,width:t[1]-t[0]+1,height:1}))return;e.save(),e.beginPath(),e.rect(r,c,h,g),e.clip();let _=u(n),v=_?.overrideTheme===void 0?o:xi(o,_.overrideTheme),y=p===-2&&f!==void 0&&f>=t[0]&&f<=t[1],b=y?v.bgHeaderHovered:v.bgHeader;if(b!==o.bgHeader&&(e.fillStyle=b,e.fill()),e.fillStyle=v.textGroupHeader??v.textHeader,_!==void 0){let t=r;if(_.icon!==void 0&&(s.drawSprite(_.icon,`normal`,e,t+8,(i-20)/2,20,v),t+=26),e.fillText(_.name,t+8,i/2+Xr(e,o.headerFontFull)),_.actions!==void 0&&y){let t=Ra({x:r,y:c,width:h,height:g},_.actions);e.beginPath();let n=t[0].x-10,o=r+h-n;e.rect(n,0,o,i);let l=e.createLinearGradient(n,0,n+o,0),u=fr(b,0);l.addColorStop(0,u),l.addColorStop(10/o,b),l.addColorStop(1,b),e.fillStyle=l,e.fill(),e.globalAlpha=.6;let[d,f]=a?.[1]??[-1,-1];for(let n=0;n<_.actions.length;n++){let i=_.actions[n],a=t[n],o=ba(a,d+r,f);o&&(e.globalAlpha=1),s.drawSprite(i.icon,`normal`,e,a.x+a.width/2-10,a.y+a.height/2-10,20,v),o&&(e.globalAlpha=.6)}e.globalAlpha=1}}r!==0&&l(t[0])&&(e.beginPath(),e.moveTo(r+.5,0),e.lineTo(r+.5,i),e.strokeStyle=o.borderColor,e.lineWidth=1,e.stroke()),e.restore(),m=r+h}),e.beginPath(),e.moveTo(m+.5,0),e.lineTo(m+.5,i),e.moveTo(0,i+.5),e.lineTo(n,i+.5),e.strokeStyle=o.borderColor,e.lineWidth=1,e.stroke()}var Ia=30;function La(e,t,n,r,i){return i?{x:e,y:t,width:Ia,height:Math.min(Ia,r)}:{x:e+n-Ia,y:Math.max(t,t+r/2-Ia/2),width:Ia,height:Math.min(Ia,r)}}function Ra(e,t){let n=[],r=e.x+e.width-26*t.length,i=e.y+e.height/2-13;for(let e=0;e35){let n=f?35:r-35,i=f?35*.7:r-35*.7,a=n/r,o=i/r,s=e.createLinearGradient(t,0,t+r,0),c=fr(h,0);s.addColorStop(+!!f,h),s.addColorStop(a,h),s.addColorStop(o,c),s.addColorStop(+!f,c),e.fillStyle=s}else e.fillStyle=h;if(f&&(e.textAlign=`right`),e.fillText(a.title,v,n+i/2+Xr(e,s.headerFontFull)),f&&(e.textAlign=`left`),g&&a.hasMenu===!0)if(a.menuIcon===void 0||a.menuIcon===it.Triangle){e.beginPath();let t=p.x+p.width/2-5.5,n=p.y+p.height/2-3;li(e,[{x:t,y:n},{x:t+11,y:n},{x:t+5.5,y:n+6}],1),e.fillStyle=h,e.fill()}else if(a.menuIcon===it.Dots)e.beginPath(),ci(e,p.x+p.width/2,p.y+p.height/2),e.fillStyle=h,e.fill();else{let t=p.x+(p.width-s.headerIconSize)/2,n=p.y+(p.height-s.headerIconSize)/2;u.drawSprite(a.menuIcon,`normal`,e,t,n,s.headerIconSize,s)}}function Ba(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=R(a.title)===`rtl`,h=La(t,n,r,i,m);f===void 0?za(e,t,n,r,i,a,o,s,c,u,d,p,m,h):f({ctx:e,theme:s,rect:{x:t,y:n,width:r,height:i},column:a,columnIndex:a.sourceIndex,isSelected:o,hoverAmount:u,isHovered:c,hasSelectedCell:l,spriteManager:d,menuBounds:h},()=>za(e,t,n,r,i,a,o,s,c,u,d,p,m,h))}var Va=s(((e,t)=>{var n=le();t.exports=function(){try{var e=n(Object,`defineProperty`);return e({},``,{}),e}catch{}}()})),Ha=s(((e,t)=>{var n=Va();function r(e,t,r){t==`__proto__`&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}t.exports=r})),Ua=s(((e,t)=>{function n(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i{function n(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}t.exports=n})),Ga=s(((e,t)=>{t.exports=Wa()()})),Ka=s(((e,t)=>{function n(e,t){for(var n=-1,r=Array(e);++n{function n(){return!1}t.exports=n})),Ja=s(((e,t)=>{var n=A(),r=qa(),i=typeof e==`object`&&e&&!e.nodeType&&e,a=i&&typeof t==`object`&&t&&!t.nodeType&&t,o=a&&a.exports===i?n.Buffer:void 0;t.exports=(o?o.isBuffer:void 0)||r})),Ya=s(((e,t)=>{var n=N(),r=We(),i=te(),a=`[object Arguments]`,o=`[object Array]`,s=`[object Boolean]`,c=`[object Date]`,l=`[object Error]`,u=`[object Function]`,d=`[object Map]`,f=`[object Number]`,p=`[object Object]`,m=`[object RegExp]`,h=`[object Set]`,g=`[object String]`,_=`[object WeakMap]`,v=`[object ArrayBuffer]`,y=`[object DataView]`,b=`[object Float32Array]`,x=`[object Float64Array]`,S=`[object Int8Array]`,C=`[object Int16Array]`,w=`[object Int32Array]`,T=`[object Uint8Array]`,E=`[object Uint8ClampedArray]`,D=`[object Uint16Array]`,O=`[object Uint32Array]`,k={};k[b]=k[x]=k[S]=k[C]=k[w]=k[T]=k[E]=k[D]=k[O]=!0,k[a]=k[o]=k[v]=k[s]=k[y]=k[c]=k[l]=k[u]=k[d]=k[f]=k[p]=k[m]=k[h]=k[g]=k[_]=!1;function A(e){return i(e)&&r(e.length)&&!!k[n(e)]}t.exports=A})),Xa=s(((e,t)=>{function n(e){return function(t){return e(t)}}t.exports=n})),Za=s(((e,t)=>{var n=k(),r=typeof e==`object`&&e&&!e.nodeType&&e,i=r&&typeof t==`object`&&t&&!t.nodeType&&t,a=i&&i.exports===r&&n.process;t.exports=function(){try{return i&&i.require&&i.require(`util`).types||a&&a.binding&&a.binding(`util`)}catch{}}()})),Qa=s(((e,t)=>{var n=Ya(),r=Xa(),i=Za(),a=i&&i.isTypedArray;t.exports=a?r(a):n})),$a=s(((e,t)=>{var n=Ka(),r=He(),i=O(),a=Ja(),o=Ue(),s=Qa(),c=Object.prototype.hasOwnProperty;function l(e,t){var l=i(e),u=!l&&r(e),d=!l&&!u&&a(e),f=!l&&!u&&!d&&s(e),p=l||u||d||f,m=p?n(e.length,String):[],h=m.length;for(var g in e)(t||c.call(e,g))&&!(p&&(g==`length`||d&&(g==`offset`||g==`parent`)||f&&(g==`buffer`||g==`byteLength`||g==`byteOffset`)||o(g,h)))&&m.push(g);return m}t.exports=l})),eo=s(((e,t)=>{var n=Object.prototype;function r(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||n)}t.exports=r})),to=s(((e,t)=>{function n(e,t){return function(n){return e(t(n))}}t.exports=n})),no=s(((e,t)=>{t.exports=to()(Object.keys,Object)})),ro=s(((e,t)=>{var n=eo(),r=no(),i=Object.prototype.hasOwnProperty;function a(e){if(!n(e))return r(e);var t=[];for(var a in Object(e))i.call(e,a)&&a!=`constructor`&&t.push(a);return t}t.exports=a})),io=s(((e,t)=>{var n=$a(),r=ro(),i=$i();function a(e){return i(e)?n(e):r(e)}t.exports=a})),ao=s(((e,t)=>{var n=Ga(),r=io();function i(e,t){return e&&n(e,t,r)}t.exports=i})),oo=s(((e,t)=>{var n=$i();function r(e,t){return function(r,i){if(r==null)return r;if(!n(r))return e(r,i);for(var a=r.length,o=t?a:-1,s=Object(r);(t?o--:++o{var n=ao();t.exports=oo()(n)})),co=s(((e,t)=>{var n=so();function r(e,t,r,i){return n(e,function(e,n,a){t(i,e,r(e),a)}),i}t.exports=r})),lo=s(((e,t)=>{var n=we();function r(){this.__data__=new n,this.size=0}t.exports=r})),uo=s(((e,t)=>{function n(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}t.exports=n})),fo=s(((e,t)=>{function n(e){return this.__data__.get(e)}t.exports=n})),po=s(((e,t)=>{function n(e){return this.__data__.has(e)}t.exports=n})),mo=s(((e,t)=>{var n=we(),r=Te(),i=Ne(),a=200;function o(e,t){var o=this.__data__;if(o instanceof n){var s=o.__data__;if(!r||s.length{var n=we(),r=lo(),i=uo(),a=fo(),o=po(),s=mo();function c(e){var t=this.__data__=new n(e);this.size=t.size}c.prototype.clear=r,c.prototype.delete=i,c.prototype.get=a,c.prototype.has=o,c.prototype.set=s,t.exports=c})),go=s(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length;++n{var n=Pi(),r=go(),i=Vi(),a=1,o=2;function s(e,t,s,c,l,u){var d=s&a,f=e.length,p=t.length;if(f!=p&&!(d&&p>f))return!1;var m=u.get(e),h=u.get(t);if(m&&h)return m==t&&h==e;var g=-1,_=!0,v=s&o?new n:void 0;for(u.set(e,t),u.set(t,e);++g{t.exports=A().Uint8Array})),yo=s(((e,t)=>{function n(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}t.exports=n})),bo=s(((e,t)=>{var n=j(),r=vo(),i=ve(),a=_o(),o=yo(),s=Wi(),c=1,l=2,u=`[object Boolean]`,d=`[object Date]`,f=`[object Error]`,p=`[object Map]`,m=`[object Number]`,h=`[object RegExp]`,g=`[object Set]`,_=`[object String]`,v=`[object Symbol]`,y=`[object ArrayBuffer]`,b=`[object DataView]`,x=n?n.prototype:void 0,S=x?x.valueOf:void 0;function C(e,t,n,x,C,w,T){switch(n){case b:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case y:return!(e.byteLength!=t.byteLength||!w(new r(e),new r(t)));case u:case d:case m:return i(+e,+t);case f:return e.name==t.name&&e.message==t.message;case h:case _:return e==t+``;case p:var E=o;case g:var D=x&c;if(E||=s,e.size!=t.size&&!D)return!1;var O=T.get(e);if(O)return O==t;x|=l,T.set(e,t);var k=a(E(e),E(t),x,C,w,T);return T.delete(e),k;case v:if(S)return S.call(e)==S.call(t)}return!1}t.exports=C})),xo=s(((e,t)=>{var n=Ji(),r=O();function i(e,t,i){var a=t(e);return r(e)?a:n(a,i(e))}t.exports=i})),So=s(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n{function n(){return[]}t.exports=n})),wo=s(((e,t)=>{var n=So(),r=Co(),i=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols;t.exports=a?function(e){return e==null?[]:(e=Object(e),n(a(e),function(t){return i.call(e,t)}))}:r})),To=s(((e,t)=>{var n=xo(),r=wo(),i=io();function a(e){return n(e,i,r)}t.exports=a})),Eo=s(((e,t)=>{var n=To(),r=1,i=Object.prototype.hasOwnProperty;function a(e,t,a,o,s,c){var l=a&r,u=n(e),d=u.length;if(d!=n(t).length&&!l)return!1;for(var f=d;f--;){var p=u[f];if(!(l?p in t:i.call(t,p)))return!1}var m=c.get(e),h=c.get(t);if(m&&h)return m==t&&h==e;var g=!0;c.set(e,t),c.set(t,e);for(var _=l;++f{t.exports=le()(A(),`DataView`)})),Oo=s(((e,t)=>{t.exports=le()(A(),`Promise`)})),ko=s(((e,t)=>{t.exports=le()(A(),`WeakMap`)})),Ao=s(((e,t)=>{var n=Do(),r=Te(),i=Oo(),a=Hi(),o=ko(),s=N(),c=oe(),l=`[object Map]`,u=`[object Object]`,d=`[object Promise]`,f=`[object Set]`,p=`[object WeakMap]`,m=`[object DataView]`,h=c(n),g=c(r),_=c(i),v=c(a),y=c(o),b=s;(n&&b(new n(new ArrayBuffer(1)))!=m||r&&b(new r)!=l||i&&b(i.resolve())!=d||a&&b(new a)!=f||o&&b(new o)!=p)&&(b=function(e){var t=s(e),n=t==u?e.constructor:void 0,r=n?c(n):``;if(r)switch(r){case h:return m;case g:return l;case _:return d;case v:return f;case y:return p}return t}),t.exports=b})),jo=s(((e,t)=>{var n=ho(),r=_o(),i=bo(),a=Eo(),o=Ao(),s=O(),c=Ja(),l=Qa(),u=1,d=`[object Arguments]`,f=`[object Array]`,p=`[object Object]`,m=Object.prototype.hasOwnProperty;function h(e,t,h,g,_,v){var y=s(e),b=s(t),x=y?f:o(e),S=b?f:o(t);x=x==d?p:x,S=S==d?p:S;var C=x==p,w=S==p,T=x==S;if(T&&c(e)){if(!c(t))return!1;y=!0,C=!1}if(T&&!C)return v||=new n,y||l(e)?r(e,t,h,g,_,v):i(e,t,x,h,g,_,v);if(!(h&u)){var E=C&&m.call(e,`__wrapped__`),D=w&&m.call(t,`__wrapped__`);if(E||D){var O=E?e.value():e,k=D?t.value():t;return v||=new n,_(O,k,h,g,v)}}return T?(v||=new n,a(e,t,h,g,_,v)):!1}t.exports=h})),Mo=s(((e,t)=>{var n=jo(),r=te();function i(e,t,a,o,s){return e===t?!0:e==null||t==null||!r(e)&&!r(t)?e!==e&&t!==t:n(e,t,a,o,i,s)}t.exports=i})),No=s(((e,t)=>{var n=ho(),r=Mo(),i=1,a=2;function o(e,t,o,s){var c=o.length,l=c,u=!s;if(e==null)return!l;for(e=Object(e);c--;){var d=o[c];if(u&&d[2]?d[1]!==e[d[0]]:!(d[0]in e))return!1}for(;++c{var n=re();function r(e){return e===e&&!n(e)}t.exports=r})),Fo=s(((e,t)=>{var n=Po(),r=io();function i(e){for(var t=r(e),i=t.length;i--;){var a=t[i],o=e[a];t[i]=[a,o,n(o)]}return t}t.exports=i})),Io=s(((e,t)=>{function n(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}t.exports=n})),Lo=s(((e,t)=>{var n=No(),r=Fo(),i=Io();function a(e){var t=r(e);return t.length==1&&t[0][2]?i(t[0][0],t[0][1]):function(r){return r===e||n(r,e,t)}}t.exports=a})),Ro=s(((e,t)=>{var n=Be(),r=Ge();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i{var n=Ro();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),Bo=s(((e,t)=>{function n(e,t){return e!=null&&t in Object(e)}t.exports=n})),Vo=s(((e,t)=>{var n=Bo(),r=Ke();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i})),Ho=s(((e,t)=>{var n=Mo(),r=zo(),i=Vo(),a=P(),o=Po(),s=Io(),c=Ge(),l=1,u=2;function d(e,t){return a(e)&&o(t)?s(c(e),t):function(a){var o=r(a,e);return o===void 0&&o===t?i(a,e):n(t,o,l|u)}}t.exports=d})),Uo=s(((e,t)=>{function n(e){return e}t.exports=n})),Wo=s(((e,t)=>{function n(e){return function(t){return t?.[e]}}t.exports=n})),Go=s(((e,t)=>{var n=Ro();function r(e){return function(t){return n(t,e)}}t.exports=r})),Ko=s(((e,t)=>{var n=Wo(),r=Go(),i=P(),a=Ge();function o(e){return i(e)?n(a(e)):r(e)}t.exports=o})),qo=s(((e,t)=>{var n=Lo(),r=Ho(),i=Uo(),a=O(),o=Ko();function s(e){return typeof e==`function`?e:e==null?i:typeof e==`object`?a(e)?r(e[0],e[1]):n(e):o(e)}t.exports=s})),Jo=s(((e,t)=>{var n=Ua(),r=co(),i=qo(),a=O();function o(e,t){return function(o,s){var c=a(o)?n:r,l=t?t():{};return c(o,e,i(s,2),l)}}t.exports=o})),Yo=u(s(((e,t)=>{var n=Ha(),r=Jo(),i=Object.prototype.hasOwnProperty;t.exports=r(function(e,t,r){i.call(e,r)?e[r].push(t):n(e,r,[t])})}))(),1);Ti(),vr();function Xo(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){if(_!==void 0||t[t.length-1]!==n[t.length-1])return;let y=pa(g);ha(t,c,o,s,a,(n,o,s,c,_)=>{if(n!==t[t.length-1])return;o+=n.width;let b=Math.max(o,c);b>r||(e.save(),e.beginPath(),e.rect(b,a+1,1e4,i-a-1),e.clip(),ma(_,s,i,l,u,m,h,y,(t,n,r,i)=>{if(!i&&g.length>0&&!g.some(e=>ya(o,t,1e4,r,e.x,e.y,e.width,e.height)))return;let a=f.hasIndex(n),s=p.hasIndex(n);e.beginPath();let c=d?.(n),l=c===void 0?v:xi(v,c);l.bgCell!==v.bgCell&&(e.fillStyle=l.bgCell,e.fillRect(o,t,1e4,r)),s&&(e.fillStyle=l.bgHeader,e.fillRect(o,t,1e4,r)),a&&(e.fillStyle=l.accentLight,e.fillRect(o,t,1e4,r))}),e.restore())})}function Zo(e,t,n,r,i,a,o,s,c){let l=!1;for(let e of t)if(!e.sticky){l=o(e.sourceIndex);break}let u=c.horizontalBorderColor??c.borderColor,d=c.borderColor,f=l?Rr(t):0,p;if(f!==0&&(p=pr(d,c.bgCell),e.beginPath(),e.moveTo(f+.5,0),e.lineTo(f+.5,r),e.strokeStyle=p,e.stroke()),i>0){let t=d===u&&p!==void 0?p:pr(u,c.bgCell),o=zr(a,i,s);e.beginPath(),e.moveTo(0,r-o+.5),e.lineTo(n,r-o+.5),e.strokeStyle=t,e.stroke()}}var Qo=(e,t,n)=>{let r=0,i=t,a=0,o=n;if(e!==void 0&&e.length>0){r=2**53-1,a=2**53-1,i=-(2**53-1),o=-(2**53-1);for(let t of e)r=Math.min(r,t.x-1),i=Math.max(i,t.x+t.width+1),a=Math.min(a,t.y-1),o=Math.max(o,t.y+t.height+1)}return{minX:r,maxX:i,minY:a,maxY:o}};function $o(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h=m.bgCell,{minX:g,maxX:_,minY:v,maxY:y}=Qo(s,a,o),b=[],x=o-zr(p,f,l),S=c,C=n,w=0;for(;S+i=v&&e<=y-1){let n=u?.(C)?.bgCell;n!==void 0&&n!==h&&C>=p-f&&b.push({x:g,y:e,w:_-g,h:t,color:n})}S+=t,C0)for(let e=0;e=g&&i<=_&&d(e+1)&&b.push({x:i,y:w,w:n.width,h:E,color:a}),T+=n.width}if(b.length===0)return;let D;e.beginPath();for(let t=b.length-1;t>=0;t--){let n=b[t];D===void 0?D=n.color:n.color!==D&&(e.fillStyle=D,e.fill(),e.beginPath(),D=n.color),e.rect(n.x,n.y,n.w,n.h)}D!==void 0&&(e.fillStyle=D,e.fill()),e.beginPath()}function es(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=!1){if(c!==void 0){e.beginPath(),e.save(),e.rect(0,0,a,o);for(let t of c)e.rect(t.x+1,t.y+1,t.width-1,t.height-1);e.clip(`evenodd`)}let v=g.horizontalBorderColor??g.borderColor,y=g.borderColor,{minX:b,maxX:x,minY:S,maxY:C}=Qo(s,a,o),w=[];e.beginPath();let T=.5;for(let e=0;e=b&&i<=x&&p(e+1)&&w.push({x1:i,y1:Math.max(l,S),x2:i,y2:Math.min(o,C),color:y})}let E=o+.5;for(let e=h-m;e=S&&n<=C-1){let e=f?.(t);w.push({x1:b,y1:n,x2:x,y2:n,color:e?.horizontalBorderColor??e?.borderColor??v})}e+=d(t),t++}}let D=(0,Yo.default)(w,e=>e.color);for(let t of Object.keys(D)){e.strokeStyle=t;for(let n of D[t])e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke(),e.beginPath()}c!==void 0&&e.restore()}E();function ts(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=[];e.imageSmoothingEnabled=!1;let b=Math.min(i.cellYOffset,o),x=Math.max(i.cellYOffset,o),S=0;if(typeof _==`number`)S+=(x-b)*_;else for(let e=b;ei.cellYOffset&&(S=-S),S+=c-i.translateY;let C=Math.min(i.cellXOffset,a),w=Math.max(i.cellXOffset,a),T=0;for(let e=C;ei.cellXOffset&&(T=-T),T+=s-i.translateX;let E=Rr(g);if(T!==0&&S!==0)return{regions:[]};let D=l>0?zr(f,l,_):0,O=u-E-Math.abs(T),k=d-p-D-Math.abs(S)-1;if(O>150&&k>150){let i={sx:0,sy:0,sw:u*m,sh:d*m,dx:0,dy:0,dw:u*m,dh:d*m};if(S>0?(i.sy=(p+1)*m,i.sh=k*m,i.dy=(S+p+1)*m,i.dh=k*m,y.push({x:0,y:p,width:u,height:S+1})):S<0&&(i.sy=(-S+p+1)*m,i.sh=k*m,i.dy=(p+1)*m,i.dh=k*m,y.push({x:0,y:d+S-D,width:u,height:-S+D})),T>0?(i.sx=E*m,i.sw=O*m,i.dx=(T+E)*m,i.dw=O*m,y.push({x:E-1,y:0,width:T+2,height:d})):T<0&&(i.sx=(E-T)*m,i.sw=O*m,i.dx=E*m,i.dw=O*m,y.push({x:u+T,y:0,width:-T,height:d})),e.setTransform(1,0,0,1,0,0),v){if(E>0&&T!==0&&S===0&&(r===void 0||n?.[1]!==!1)){let n=E*m,r=d*m;e.drawImage(t,0,0,n,r,0,0,n,r)}if(D>0&&T===0&&S!==0&&(r===void 0||n?.[0]!==!1)){let n=(d-D)*m,r=u*m,i=D*m;e.drawImage(t,0,n,r,i,0,n,r,i)}}e.drawImage(t,i.sx,i.sy,i.sw,i.sh,i.dx,i.dy,i.dw,i.dh),e.scale(m,m)}return e.imageSmoothingEnabled=!0,{regions:y}}function ns(e,t,n,r,i,a,o,s,c,l){let u=[];return t!==e.cellXOffset||n!==e.cellYOffset||r!==e.translateX||i!==e.translateY||ha(c,n,r,i,s,(e,t,n,r)=>{if(e.sourceIndex===l){let e=Math.max(t,r)+1;return u.push({x:e,y:0,width:a-e,height:o}),!0}}),u}function rs(e,t){if(t===void 0||e.width!==t.width||e.height!==t.height||e.theme!==t.theme||e.headerHeight!==t.headerHeight||e.rowHeight!==t.rowHeight||e.rows!==t.rows||e.freezeColumns!==t.freezeColumns||e.getRowThemeOverride!==t.getRowThemeOverride||e.isFocused!==t.isFocused||e.isResizing!==t.isResizing||e.verticalBorder!==t.verticalBorder||e.getCellContent!==t.getCellContent||e.highlightRegions!==t.highlightRegions||e.selection!==t.selection||e.dragAndDropState!==t.dragAndDropState||e.prelightCells!==t.prelightCells||e.touchMode!==t.touchMode||e.maxScaleFactor!==t.maxScaleFactor)return!1;if(e.mappedColumns!==t.mappedColumns){if(e.mappedColumns.length>100||e.mappedColumns.length!==t.mappedColumns.length)return!1;let n;for(let r=0;re.style!==`no-outline`);if(g===void 0||g.length===0)return;let _=Rr(s),v=zr(p,f,d),y=[c,0,s.length,p-f],b=[_,0,t,n-v],x=g.map(e=>{let m=e.range,h=e.style??`dashed`;return wa(m,y,t,n,b).map(m=>{let g=m.rect,_=ui(g.x,g.y,t,n,u,l+u,r,i,a,o,p,c,f,s,d),v=g.width===1&&g.height===1?_:ui(g.x+g.width-1,g.y+g.height-1,t,n,u,l+u,r,i,a,o,p,c,f,s,d);return g.x+g.width>=s.length&&--v.width,g.y+g.height>=p&&--v.height,{color:e.color,style:h,clip:m.clip,rect:Ca({x:_.x,y:_.y,width:v.x+v.width-_.x,height:v.y+v.height-_.y},t,n,8)}})}),S=()=>{e.lineWidth=1;let r=!1;for(let i of x)for(let a of i)if(a?.rect!==void 0&&ya(0,0,t,n,a.rect.x,a.rect.y,a.rect.width,a.rect.height)){let t=r,n=!Sa(a.clip,a.rect);n&&(e.save(),e.rect(a.clip.x,a.clip.y,a.clip.width,a.clip.height),e.clip()),a.style===`dashed`&&!r?(e.setLineDash([5,3]),r=!0):(a.style===`solid`||a.style===`solid-outline`)&&r&&(e.setLineDash([]),r=!1),e.strokeStyle=a.style===`solid-outline`?mr(mr(a.color,h.borderColor),h.bgCell):fr(a.color,1),e.strokeRect(a.rect.x+.5,a.rect.y+.5,a.rect.width-1,a.rect.height-1),n&&(e.restore(),r=t)}r&&e.setLineDash([])};return S(),S}function as(e,t,n,r,i){e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.lineWidth=2,e.strokeStyle=i,e.stroke(),e.globalAlpha=1}function os(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){if(u.current===void 0)return;let _=u.current.range,v=u.current.cell,y=[_.x+_.width-1,_.y+_.height-1];if(v[1]>=g&&y[1]>=g||!o.some(e=>e.sourceIndex===v[0]||e.sourceIndex===y[0]))return;let[b,x]=u.current.cell,S=f(u.current.cell),C=S.span??[b,b],w=x>=g-p,T=p>0&&!w?zr(g,p,d)-1:0,E=y[1],D;if(ha(o,r,i,a,l,(r,i,a,o,l)=>{if(r.sticky&&b>r.sourceIndex)return;let u=r.sourceIndexC[1],_=r.sourceIndex===y[0];if(!(!_&&(u||f)))return ma(l,a,n,g,d,p,m,void 0,(a,l,u)=>{if(l!==x&&l!==E)return;let d=i,f=r.width;if(S.span!==void 0){let e=_a(S.span,i,a,r.width,u,r,s),t=r.sticky?e[0]:e[1];t!==void 0&&(d=t.x,f=t.width)}return l===E&&_&&h&&(D=()=>{o>d&&!r.sticky&&(e.beginPath(),e.rect(o,0,t-o,n),e.clip()),e.beginPath(),e.rect(d+f-4,a+u-4,4,4),e.fillStyle=r.themeOverride?.accentColor??c.accentColor,e.fill()}),D!==void 0}),D!==void 0}),D===void 0)return;let O=()=>{e.save(),e.beginPath(),e.rect(0,l,t,n-l-T),e.clip(),D?.(),e.restore()};return O(),O}vr(),E();function ss(e,t,n,r,i,a,o,s,c){c===void 0||c.size===0||(e.beginPath(),ga(t,n,a,r,(t,n,r,i,a,o)=>{c.hasItemInRectangle({x:t[0],y:-2,width:t[1]-t[0]+1,height:1})&&e.rect(r,i,a,o)}),ha(t,s,a,o,i,(t,n,a,o)=>{let s=Math.max(0,o-n),l=n+s+1,u=t.width-s-1;c.has([t.sourceIndex,-1])&&e.rect(l,r,u,i-r)}),e.clip())}function cs(e,t,n,r,i,a,o,s,c,l){let u=0;return ha(e,a,r,i,n,(e,n,r,i,a)=>(ma(a,r,t,o,s,c,l,void 0,(e,t,n,r)=>{r||(u=Math.max(t,u))}),!0)),u}function ls(e,t){let{canvasCtx:n,headerCanvasCtx:r,width:i,height:a,cellXOffset:o,cellYOffset:s,translateX:c,translateY:l,mappedColumns:u,enableGroups:d,freezeColumns:f,dragAndDropState:p,theme:m,drawFocus:h,headerHeight:g,groupHeaderHeight:_,disabledRows:v,rowHeight:y,verticalBorder:b,overrideCursor:S,isResizing:C,selection:w,fillHandle:T,freezeTrailingRows:E,rows:D,getCellContent:O,getGroupDetails:k,getRowThemeOverride:A,isFocused:j,drawHeaderCallback:M,prelightCells:ee,drawCellCallback:N,highlightRegions:te,resizeCol:ne,imageLoader:P,lastBlitData:re,hoverValues:F,hyperWrapping:ie,hoverInfo:ae,spriteManager:oe,maxScaleFactor:se,hasAppendRow:ce,touchMode:le,enqueue:ue,renderStateProvider:de,getCellRenderer:fe,renderStrategy:pe,bufferACtx:me,bufferBCtx:he,damage:ge,minimumCellWidth:_e}=e;if(i===0||a===0)return;let ve=pe===`double-buffer`,ye=Math.min(se,Math.ceil(window.devicePixelRatio??1)),be=pe!==`direct`&&rs(e,t),xe=n.canvas;(xe.width!==i*ye||xe.height!==a*ye)&&(xe.width=i*ye,xe.height=a*ye,xe.style.width=i+`px`,xe.style.height=a+`px`);let Se=r.canvas,Ce=d?_+g:g,we=Ce+1;(Se.width!==i*ye||Se.height!==we*ye)&&(Se.width=i*ye,Se.height=we*ye,Se.style.width=i+`px`,Se.style.height=we+`px`);let Te=me.canvas,Ee=he.canvas;ve&&(Te.width!==i*ye||Te.height!==a*ye)&&(Te.width=i*ye,Te.height=a*ye,re.current!==void 0&&(re.current.aBufferScroll=void 0)),ve&&(Ee.width!==i*ye||Ee.height!==a*ye)&&(Ee.width=i*ye,Ee.height=a*ye,re.current!==void 0&&(re.current.bBufferScroll=void 0));let De=re.current;if(be===!0&&o===De?.cellXOffset&&s===De?.cellYOffset&&c===De?.translateX&&l===De?.translateY)return;let Oe=null;ve&&(Oe=n);let ke=r,Ae;Ae=ve?ge===void 0?De?.lastBuffer===`b`?me:he:De?.lastBuffer===`b`?he:me:n;let je=Ae.canvas,Me=ve?je===Te?Ee:Te:xe,Ne=typeof y==`number`?()=>y:y;ke.save(),Ae.save(),ke.beginPath(),Ae.beginPath(),ke.textBaseline=`middle`,Ae.textBaseline=`middle`,ye!==1&&(ke.scale(ye,ye),Ae.scale(ye,ye));let Pe=Br(u,o,i,p,c),Fe=[],Ie=h&&w.current?.cell[1]===s&&l===0,Le=!1;if(te!==void 0){for(let e of te)if(e.style!==`no-outline`&&e.range.y===s&&l===0){Le=!0;break}}let Re=()=>{Pa(ke,Pe,d,ae,i,c,g,_,p,C,w,m,oe,F,b,k,ge,M,le),es(ke,Pe,s,c,l,i,a,void 0,void 0,_,Ce,Ne,A,b,E,D,m,!0),ke.beginPath(),ke.moveTo(0,we-.5),ke.lineTo(i,we-.5),ke.strokeStyle=mr(m.headerBottomBorderColor??m.horizontalBorderColor??m.borderColor,m.bgHeader),ke.stroke(),Le&&is(ke,i,a,o,s,c,l,u,f,g,_,y,E,D,te,m),Ie&&os(ke,i,a,s,c,l,Pe,u,m,Ce,w,Ne,O,E,ce,T,D)};if(ge!==void 0){let e=Pe[Pe.length-1].sourceIndex+1,t=ge.hasItemInRegion([{x:o,y:-2,width:e,height:2},{x:o,y:s,width:e,height:300},{x:0,y:s,width:f,height:300},{x:0,y:-2,width:f,height:2},{x:o,y:D-E,width:e,height:E,when:E>0}]),n=e=>{Ea(e,Pe,u,a,Ce,c,l,s,D,Ne,O,k,A,v,j,h,E,ce,Fe,ge,w,ee,te,P,oe,F,ae,N,ie,m,ue,de,fe,S,_e);let t=w.current;T&&h&&t!==void 0&&ge.has(Pr(t.range))&&os(e,i,a,s,c,l,Pe,u,m,Ce,w,Ne,O,E,ce,T,D)};t&&(n(Ae),Oe!==null&&(Oe.save(),Oe.scale(ye,ye),Oe.textBaseline=`middle`,n(Oe),Oe.restore()),ge.hasHeader()&&(ss(ke,Pe,i,_,Ce,c,l,s,ge),Re())),Ae.restore(),ke.restore();return}if((be!==!0||o!==De?.cellXOffset||c!==De?.translateX||Ie!==De?.mustDrawFocusOnHeader||Le!==De?.mustDrawHighlightRingsOnHeader)&&Re(),be===!0){x(Me!==void 0&&De!==void 0);let{regions:e}=ts(Ae,Me,Me===Te?De.aBufferScroll:De.bBufferScroll,Me===Te?De.bBufferScroll:De.aBufferScroll,De,o,s,c,l,E,i,a,D,Ce,ye,u,Pe,y,ve);Fe=e}else be!==!1&&(x(De!==void 0),Fe=ns(De,o,s,c,l,i,a,Ce,Pe,be));Zo(Ae,Pe,i,a,E,D,b,Ne,m);let ze=is(Ae,i,a,o,s,c,l,u,f,g,_,y,E,D,te,m),Be=h?os(Ae,i,a,s,c,l,Pe,u,m,Ce,w,Ne,O,E,ce,T,D):void 0;if(Ae.fillStyle=m.bgCell,Fe.length>0){Ae.beginPath();for(let e of Fe)Ae.rect(e.x,e.y,e.width,e.height);Ae.clip(),Ae.fill(),Ae.beginPath()}else Ae.fillRect(0,0,i,a);let Ve=Ea(Ae,Pe,u,a,Ce,c,l,s,D,Ne,O,k,A,v,j,h,E,ce,Fe,ge,w,ee,te,P,oe,F,ae,N,ie,m,ue,de,fe,S,_e);Xo(Ae,Pe,u,i,a,Ce,c,l,s,D,Ne,A,w.rows,v,E,ce,Fe,ge,m),$o(Ae,Pe,s,c,l,i,a,Fe,Ce,Ne,A,b,E,D,m),es(Ae,Pe,s,c,l,i,a,Fe,Ve,_,Ce,Ne,A,b,E,D,m),ze?.(),Be?.(),C&&ha(Pe,0,c,0,Ce,(e,t)=>e.sourceIndex===ne?(as(ke,t+e.width,0,Ce+1,mr(m.resizeIndicatorColor??m.accentLight,m.bgHeader)),as(Ae,t+e.width,Ce,a,mr(m.resizeIndicatorColor??m.accentLight,m.bgCell)),!0):!1),Oe!==null&&(Oe.fillStyle=m.bgCell,Oe.fillRect(0,0,i,a),Oe.drawImage(Ae.canvas,0,0));let He=cs(Pe,a,Ce,c,l,s,D,Ne,E,ce);P?.setWindow({x:o,y:s,width:Pe.length,height:He-s},f,Array.from({length:E},(e,t)=>D-1-t));let Ue=De!==void 0&&(o!==De.cellXOffset||c!==De.translateX),We=De!==void 0&&(s!==De.cellYOffset||l!==De.translateY);re.current={cellXOffset:o,cellYOffset:s,translateX:c,translateY:l,mustDrawFocusOnHeader:Ie,mustDrawHighlightRingsOnHeader:Le,lastBuffer:ve?je===Te?`a`:`b`:void 0,aBufferScroll:je===Te?[Ue,We]:De?.aBufferScroll,bBufferScroll:je===Ee?[Ue,We]:De?.bBufferScroll},Ae.restore(),ke.restore()}var us=u(ji(),1),ds=80;function fs(e){let t=e-1;return t*t*t+1}var ps=class{callback;constructor(e){this.callback=e}currentHoveredItem=void 0;leavingItems=[];lastAnimationTime;addToLeavingItems=e=>{this.leavingItems.some(t=>Nr(t.item,e.item))||this.leavingItems.push(e)};removeFromLeavingItems=e=>{let t=this.leavingItems.find(t=>Nr(t.item,e));return this.leavingItems=this.leavingItems.filter(e=>e!==t),t?.hoverAmount??0};cleanUpLeavingElements=()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)};shouldStep=()=>{let e=this.leavingItems.length>0,t=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||t};getAnimatingItems=()=>this.currentHoveredItem===void 0?this.leavingItems.map(e=>({...e,hoverAmount:fs(e.hoverAmount)})):[...this.leavingItems,this.currentHoveredItem];step=e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{let t=(e-this.lastAnimationTime)/ds;for(let e of this.leavingItems)e.hoverAmount=(0,us.default)(e.hoverAmount-t,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=(0,us.default)(this.currentHoveredItem.hoverAmount+t,0,1));let n=this.getAnimatingItems();this.callback(n),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0};setHovered=e=>{if(!Nr(this.currentHoveredItem?.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){let t=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:t}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}}},ms=class{fn;val;constructor(e){this.fn=e}get value(){return this.val??=this.fn()}};function hs(e){return new ms(e)}var gs=hs(()=>window.navigator.userAgent.includes(`Firefox`)),_s=hs(()=>window.navigator.userAgent.includes(`Mac OS`)&&window.navigator.userAgent.includes(`Safari`)&&!window.navigator.userAgent.includes(`Chrome`)),vs=hs(()=>window.navigator.platform.toLowerCase().startsWith(`mac`));function ys(e){let t=L.useRef([]),n=L.useRef(0),r=L.useRef(e);r.current=e;let i=L.useCallback(()=>{let e=()=>window.requestAnimationFrame(i),i=()=>{let e=t.current.map(hi);t.current=[],r.current(new vi(e)),t.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?e:i)},[]);return L.useCallback(e=>{t.current.length===0&&i();let n=fi(e[0],e[1]);t.current.includes(n)||t.current.push(n)},[i])}var bs=`header`,xs=`group-header`,Ss=`out-of-bounds`,Cs;(function(e){e[e.Start=-2]=`Start`,e[e.StartPadding=-1]=`StartPadding`,e[e.Center=0]=`Center`,e[e.EndPadding=1]=`EndPadding`,e[e.End=2]=`End`})(Cs||={});function ws(e,t){return e===t?!0:e?.kind===`out-of-bounds`?e?.kind===t?.kind&&e?.location[0]===t?.location[0]&&e?.location[1]===t?.location[1]&&e?.region[0]===t?.region[0]&&e?.region[1]===t?.region[1]:e?.kind===t?.kind&&e?.location[0]===t?.location[0]&&e?.location[1]===t?.location[1]}ct();var Ts=u(ra(),1);E();var Es=6,Ds=(e,t)=>e.kind===I.Custom?e.copyData:(t?.(e))?.getAccessibilityString(e)??``,Os=L.memo(L.forwardRef((e,t)=>{let{width:n,height:r,accessibilityHeight:i,columns:a,cellXOffset:o,cellYOffset:s,headerHeight:c,fillHandle:l=!1,groupHeaderHeight:u,rowHeight:d,rows:f,getCellContent:p,getRowThemeOverride:m,onHeaderMenuClick:h,enableGroups:g,isFilling:_,onCanvasFocused:v,onCanvasBlur:y,isFocused:b,selection:S,freezeColumns:C,onContextMenu:w,freezeTrailingRows:T,fixedShadowX:E=!0,fixedShadowY:D=!0,drawFocusRing:O,onMouseDown:k,onMouseUp:A,onMouseMoveRaw:j,onMouseMove:M,onItemHovered:ee,dragAndDropState:N,firstColAccessible:te,onKeyDown:ne,onKeyUp:P,highlightRegions:re,canvasRef:F,onDragStart:ie,onDragEnd:ae,eventTargetRef:oe,isResizing:se,resizeColumn:ce,isDragging:le,isDraggable:ue=!1,allowResize:de,disabledRows:fe,hasAppendRow:pe,getGroupDetails:me,theme:he,prelightCells:ge,headerIcons:_e,verticalBorder:ve,drawCell:ye,drawHeader:be,onCellFocused:xe,onDragOverCell:Se,onDrop:Ce,onDragLeave:we,imageWindowLoader:Te,smoothScrollX:Ee=!1,smoothScrollY:De=!1,experimental:Oe,getCellRenderer:ke}=e,Ae=e.translateX??0,je=e.translateY??0,Me=Math.max(C,Math.min(a.length-1,o)),Ne=L.useRef(null),Pe=Te,Fe=L.useRef(),[Ie,Le]=L.useState(!1),Re=L.useRef([]),ze=L.useRef(),[Be,Ve]=L.useState(),[He,Ue]=L.useState(),We=L.useRef(null),[Ge,Ke]=L.useState(),[qe,Je]=L.useState(!1),Ye=L.useRef(qe);Ye.current=qe;let Xe=L.useMemo(()=>new fa(_e,()=>{vt.current=void 0,St.current()}),[_e]),$e=g?u+c:c,tt=L.useRef(-1),nt=(Oe?.enableFirefoxRescaling??!1)&&gs.value,rt=(Oe?.enableSafariRescaling??!1)&&_s.value;L.useLayoutEffect(()=>{window.devicePixelRatio===1||!nt&&!rt||(tt.current!==-1&&Le(!0),window.clearTimeout(tt.current),tt.current=window.setTimeout(()=>{Le(!1),tt.current=-1},200))},[s,Me,Ae,je,nt,rt]);let it=Or(a,C),ot=E?Rr(it,N):0,ct=L.useCallback((e,t,i)=>{let a=e.getBoundingClientRect();if(t>=it.length||i>=f)return;let o=a.width/n,c=ui(t,i,n,r,u,$e,Me,s,Ae,je,f,C,T,it,d);return o!==1&&(c.x*=o,c.y*=o,c.width*=o,c.height*=o),c.x+=a.x,c.y+=a.y,c},[n,r,u,$e,Me,s,Ae,je,f,C,T,it,d]),lt=L.useCallback((e,t,i,a)=>{let o=e.getBoundingClientRect(),p=o.width/n,m=(t-o.left)/p,h=(i-o.top)/p,_=Br(it,Me,n,void 0,Ae),v=0,y=0;a instanceof MouseEvent&&(v=a.button,y=a.buttons);let b=Vr(m,_,Ae),C=Hr(h,r,g,c,u,f,d,s,je,T),w=a?.shiftKey===!0,E=a?.ctrlKey===!0,D=a?.metaKey===!0,O=a!==void 0&&!(a instanceof MouseEvent)||a?.pointerType===`touch`,k=[m<0?-1:+(nn||h>r){let i=m>n?1:m<0?-1:0,a=h>r?1:h<0?-1:0,o=i*2,s=a*2;i===0&&(o=b===-1?Cs.EndPadding:Cs.Center),a===0&&(s=C===void 0?Cs.EndPadding:Cs.Center);let c=!1;if(b===-1&&C===-1){let n=ct(e,it.length-1,-1);x(n!==void 0),c=tn&&mr&&h=0?(r=!0,n=ct(e,a,C),x(n!==void 0),A={kind:g&&C===-2?xs:bs,location:[a,C],bounds:n,group:it[a].group??``,isEdge:r,shiftKey:w,ctrlKey:E,metaKey:D,isTouch:O,localEventX:t-n.x,localEventY:i-n.y,button:v,buttons:y,scrollEdge:k}):A={kind:g&&C===-2?xs:bs,group:it[b].group??``,location:[b,C],bounds:n,isEdge:r,shiftKey:w,ctrlKey:E,metaKey:D,isTouch:O,localEventX:t-n.x,localEventY:i-n.y,button:v,buttons:y,scrollEdge:k}}else{let n=ct(e,b,C);x(n!==void 0);let r=n!==void 0&&n.x+n.width-t<5,a=!1;if(l&&S.current!==void 0){let n=Pr(S.current.range),r=ct(e,n[0],n[1]);if(r!==void 0){let e=r.x+r.width-2,n=r.y+r.height-2;a=Math.abs(e-t){}),ft=L.useRef(Be);ft.current=Be;let[pt,mt]=L.useMemo(()=>{let e=document.createElement(`canvas`),t=document.createElement(`canvas`);return e.style.display=`none`,e.style.opacity=`0`,e.style.position=`fixed`,t.style.display=`none`,t.style.opacity=`0`,t.style.position=`fixed`,[e.getContext(`2d`,{alpha:!1}),t.getContext(`2d`,{alpha:!1})]},[]);L.useLayoutEffect(()=>{if(!(pt===null||mt===null))return document.documentElement.append(pt.canvas),document.documentElement.append(mt.canvas),()=>{pt.canvas.remove(),mt.canvas.remove()}},[pt,mt]);let ht=L.useMemo(()=>new _i,[]),gt=nt&&Ie?1:rt&&Ie?2:5,_t=Oe?.disableMinimumCellWidth===!0?1:10,vt=L.useRef(),yt=L.useRef(null),bt=L.useRef(null),xt=L.useCallback(()=>{let e=Ne.current,t=We.current;if(e===null||t===null||(yt.current===null&&(yt.current=e.getContext(`2d`,{alpha:!1}),e.width=0,e.height=0),bt.current===null&&(bt.current=t.getContext(`2d`,{alpha:!1}),t.width=0,t.height=0),yt.current===null||bt.current===null||pt===null||mt===null))return;let i=!1,a=e=>{i=!0,Ke(e)},o=vt.current,h={headerCanvasCtx:bt.current,canvasCtx:yt.current,bufferACtx:pt,bufferBCtx:mt,width:n,height:r,cellXOffset:Me,cellYOffset:s,translateX:Math.round(Ae),translateY:Math.round(je),mappedColumns:it,enableGroups:g,freezeColumns:C,dragAndDropState:N,theme:he,headerHeight:c,groupHeaderHeight:u,disabledRows:fe??st.empty(),rowHeight:d,verticalBorder:ve,isResizing:se,resizeCol:ce,isFocused:b,selection:S,fillHandle:l,drawCellCallback:ye,hasAppendRow:pe,overrideCursor:a,maxScaleFactor:gt,freezeTrailingRows:T,rows:f,drawFocus:O,getCellContent:p,getGroupDetails:me??(e=>({name:e})),getRowThemeOverride:m,drawHeaderCallback:be,prelightCells:ge,highlightRegions:re,imageLoader:Pe,lastBlitData:ze,damage:Fe.current,hoverValues:Re.current,hoverInfo:ft.current,spriteManager:Xe,scrolling:Ie,hyperWrapping:Oe?.hyperWrapping??!1,touchMode:qe,enqueue:dt.current,renderStateProvider:ht,renderStrategy:Oe?.renderStrategy??(_s.value?`double-buffer`:`single-buffer`),getCellRenderer:ke,minimumCellWidth:_t};h.damage===void 0?(vt.current=h,ls(h,o)):ls(h,void 0),!i&&(h.damage===void 0||h.damage.has(ft?.current?.[0]))&&Ke(void 0)},[pt,mt,n,r,Me,s,Ae,je,it,g,C,N,he,c,u,fe,d,ve,se,pe,ce,b,S,l,T,f,O,gt,p,me,m,ye,be,ge,re,Pe,Xe,Ie,Oe?.hyperWrapping,Oe?.renderStrategy,qe,ht,ke,_t]),St=L.useRef(xt);L.useLayoutEffect(()=>{xt(),St.current=xt},[xt]),L.useLayoutEffect(()=>{(async()=>{document?.fonts?.ready!==void 0&&(await document.fonts.ready,vt.current=void 0,St.current())})()},[]);let Ct=L.useCallback(e=>{Fe.current=e,St.current(),Fe.current=void 0},[]);dt.current=ys(Ct);let wt=L.useCallback(e=>{Ct(new vi(e.map(e=>e.cell)))},[Ct]);Pe.setCallback(Ct);let[Tt,Et]=L.useState(!1),[Dt,Ot]=ut??[],kt=Dt!==void 0&&Ot===-1,At=Dt!==void 0&&Ot===-2,jt=!1,Mt=!1,Nt=Ge;if(Nt===void 0&&Dt!==void 0&&Ot!==void 0&&Ot>-1&&Ot({contain:`strict`,display:`block`,cursor:Pt}),[Pt]),It=L.useRef(`default`),Lt=oe?.current;Lt!=null&&It.current!==Ft.cursor&&(Lt.style.cursor=It.current=Ft.cursor);let Rt=L.useCallback((e,t,n,r)=>{if(me===void 0)return;let i=me(e);if(i.actions!==void 0){let e=Ra(t,i.actions);for(let[a,o]of e.entries())if(ba(o,n+t.x,r+o.y))return i.actions[a]}},[me]),zt=L.useCallback((e,t,n,r)=>{let i=a[t];if(!le&&!se&&i.hasMenu===!0&&!(He??!1)){let a=ct(e,t,-1);x(a!==void 0);let o=La(a.x,a.y,a.width,a.height,R(i.title)===`rtl`);if(n>o.x&&no.y&&r{let t=Ne.current,n=oe?.current;if(t===null||e.target!==t&&e.target!==n)return;Ht.current=!0;let r,i;if(e instanceof MouseEvent?(r=e.clientX,i=e.clientY):(r=e.touches[0].clientX,i=e.touches[0].clientY),e.target===n&&n!==null){let e=n.getBoundingClientRect();if(r>e.right||i>e.bottom)return}let a=lt(t,r,i,e);Vt.current=a.location,a.isTouch&&(Bt.current=Date.now()),Ye.current!==a.isTouch&&Je(a.isTouch),!(a.kind===`header`&&zt(t,a.location[0],r,i)!==void 0)&&(a.kind===`group-header`&&Rt(a.group,a.bounds,a.localEventX,a.localEventY)!==void 0||(k?.(a),!a.isTouch&&ue!==!0&&ue!==a.kind&&a.button<3&&a.button!==1&&e.preventDefault()))},[oe,ue,lt,Rt,zt,k]);qt(`touchstart`,Ut,window,!1),qt(`mousedown`,Ut,window,!1);let Wt=L.useRef(0),Gt=L.useCallback(e=>{let t=Wt.current;Wt.current=Date.now();let n=Ne.current;if(Ht.current=!1,A===void 0||n===null)return;let r=oe?.current,i=e.target!==n&&e.target!==r,a,o,s=!0;if(e instanceof MouseEvent){if(a=e.clientX,o=e.clientY,s=e.button<3,e.pointerType===`touch`)return}else a=e.changedTouches[0].clientX,o=e.changedTouches[0].clientY;let c=lt(n,a,o,e);c.isTouch&&Bt.current!==0&&Date.now()-Bt.current>500&&(c={...c,isLongTouch:!0}),t!==0&&Date.now()-t<(c.isTouch?1e3:500)&&(c={...c,isDoubleClick:!0}),Ye.current!==c.isTouch&&Je(c.isTouch),!i&&e.cancelable&&s&&e.preventDefault();let[l]=c.location,u=zt(n,l,a,o);if(c.kind===`header`&&u!==void 0){(c.button!==0||Vt.current?.[0]!==l||Vt.current?.[1]!==-1)&&A(c,!0);return}else if(c.kind===`group-header`){let e=Rt(c.group,c.bounds,c.localEventX,c.localEventY);if(e!==void 0){c.button===0&&e.onClick(c);return}}A(c,i)},[A,oe,lt,zt,Rt]);qt(`mouseup`,Gt,window,!1),qt(`touchend`,Gt,window,!1),qt(`click`,L.useCallback(e=>{let t=Ne.current;if(t===null)return;let n=oe?.current,r=e.target!==t&&e.target!==n,i,a,o=!0;e instanceof MouseEvent?(i=e.clientX,a=e.clientY,o=e.button<3):(i=e.changedTouches[0].clientX,a=e.changedTouches[0].clientY);let s=lt(t,i,a,e);Ye.current!==s.isTouch&&Je(s.isTouch),!r&&e.cancelable&&o&&e.preventDefault();let[c]=s.location,l=zt(t,c,i,a);if(s.kind===`header`&&l!==void 0)s.button===0&&Vt.current?.[0]===c&&Vt.current?.[1]===-1&&h?.(c,l);else if(s.kind===`group-header`){let e=Rt(s.group,s.bounds,s.localEventX,s.localEventY);e!==void 0&&s.button===0&&e.onClick(s)}},[oe,lt,zt,h,Rt]),window,!1),qt(`contextmenu`,L.useCallback(e=>{let t=Ne.current,n=oe?.current;if(t===null||e.target!==t&&e.target!==n||w===void 0)return;let r=lt(t,e.clientX,e.clientY,e);w(r,()=>{e.cancelable&&e.preventDefault()})},[oe,lt,w]),oe?.current??null,!1);let Kt=L.useCallback(e=>{Fe.current=new vi(e.map(e=>e.item)),Re.current=e,St.current(),Fe.current=void 0},[]),Jt=L.useMemo(()=>new ps(Kt),[Kt]),Yt=L.useRef(Jt);Yt.current=Jt,L.useLayoutEffect(()=>{let e=Yt.current;if(ut===void 0||ut[1]<0){e.setHovered(ut);return}let t=p(ut,!0),n=ke(t),r=n===void 0&&t.kind===I.Custom||n?.needsHover!==void 0&&(typeof n.needsHover==`boolean`?n.needsHover:n.needsHover(t));e.setHovered(r?ut:void 0)},[p,ke,ut]);let Xt=L.useRef();qt(`mousemove`,L.useCallback(e=>{let t=Ne.current;if(t===null)return;let n=oe?.current,r=e.target!==t&&e.target!==n,i=lt(t,e.clientX,e.clientY,e);if(i.kind!==`out-of-bounds`&&r&&!Ht.current&&!i.isTouch)return;let a=(e,t)=>{Ve(n=>n===e||n?.[0][0]===e?.[0][0]&&n?.[0][1]===e?.[0][1]&&(n?.[1][0]===e?.[1][0]&&n?.[1][1]===e?.[1][1]||!t)?n:e)};if(!ws(i,Xt.current))Ke(void 0),ee?.(i),a(i.kind===`out-of-bounds`?void 0:[i.location,[i.localEventX,i.localEventY]],!0),Xt.current=i;else if(i.kind===`cell`||i.kind===`header`||i.kind===`group-header`){let e=!1,t=!0;if(i.kind===`cell`){let n=p(i.location);t=ke(n)?.needsHoverPosition??n.kind===I.Custom,e=t}else i.kind===`group-header`&&(e=!0);let n=[i.location,[i.localEventX,i.localEventY]];a(n,t),ft.current=n,e&&Ct(new vi([i.location]))}let o=i.location[0]>=+!te;Ue(i.kind===`header`&&i.isEdge&&o&&de===!0),Et(i.kind===`cell`&&i.isFillHandle),j?.(e),M(i)},[oe,lt,te,de,j,M,ee,p,ke,Ct]),window,!0);let Zt=L.useCallback(e=>{let t=Ne.current;if(t===null)return;let n,r;S.current!==void 0&&(n=ct(t,S.current.cell[0],S.current.cell[1]),r=S.current.cell),ne?.({bounds:n,stopPropagation:()=>e.stopPropagation(),preventDefault:()=>e.preventDefault(),cancel:()=>void 0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,key:e.key,keyCode:e.keyCode,rawEvent:e,location:r})},[ne,S,ct]),Qt=L.useCallback(e=>{let t=Ne.current;if(t===null)return;let n,r;S.current!==void 0&&(n=ct(t,S.current.cell[0],S.current.cell[1]),r=S.current.cell),P?.({bounds:n,stopPropagation:()=>e.stopPropagation(),preventDefault:()=>e.preventDefault(),cancel:()=>void 0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,key:e.key,keyCode:e.keyCode,rawEvent:e,location:r})},[P,S,ct]),$t=L.useCallback(e=>{Ne.current=e,F!==void 0&&(F.current=e)},[F]);qt(`dragstart`,L.useCallback(e=>{let t=Ne.current;if(t===null||ue===!1||se){e.preventDefault();return}let n,r,i=lt(t,e.clientX,e.clientY);if(ue!==!0&&i.kind!==ue){e.preventDefault();return}let a=(e,t)=>{n=e,r=t},o,s,c,l=(e,t,n)=>{o=e,s=t,c=n},u=!1;if(ie?.({...i,setData:a,setDragImage:l,preventDefault:()=>u=!0,defaultPrevented:()=>u}),!u&&n!==void 0&&r!==void 0&&e.dataTransfer!==null)if(e.dataTransfer.setData(n,r),e.dataTransfer.effectAllowed=`copyLink`,o!==void 0&&s!==void 0&&c!==void 0)e.dataTransfer.setDragImage(o,s,c);else{let[n,r]=i.location;if(r!==void 0){let i=document.createElement(`canvas`),a=ct(t,n,r);x(a!==void 0);let o=Math.ceil(window.devicePixelRatio??1);i.width=a.width*o,i.height=a.height*o;let s=i.getContext(`2d`);s!==null&&(s.scale(o,o),s.textBaseline=`middle`,r===-1?(s.font=he.headerFontFull,s.fillStyle=he.bgHeader,s.fillRect(0,0,i.width,i.height),Ba(s,0,0,a.width,a.height,it[n],!1,he,!1,!1,0,Xe,be,!1)):(s.font=he.baseFontFull,s.fillStyle=he.bgCell,s.fillRect(0,0,i.width,i.height),Ma(s,p([n,r]),0,r,!1,!1,0,0,a.width,a.height,!1,he,he.bgCell,Pe,Xe,1,void 0,!1,0,void 0,void 0,void 0,ht,ke,()=>void 0))),i.style.left=`-100%`,i.style.position=`absolute`,i.style.width=`${a.width}px`,i.style.height=`${a.height}px`,document.body.append(i),e.dataTransfer.setDragImage(i,a.width/2,a.height/2),window.setTimeout(()=>{i.remove()},0)}}else e.preventDefault()},[ue,se,lt,ie,ct,he,it,Xe,be,p,Pe,ht,ke]),oe?.current??null,!1,!1);let en=L.useRef();qt(`dragover`,L.useCallback(e=>{let t=Ne.current;if(Ce!==void 0&&e.preventDefault(),t===null||Se===void 0)return;let[n,r]=lt(t,e.clientX,e.clientY).location,i=n-+!te,[a,o]=en.current??[];(a!==i||o!==r)&&(en.current=[i,r],Se([i,r],e.dataTransfer))},[te,lt,Se,Ce]),oe?.current??null,!1,!1),qt(`dragend`,L.useCallback(()=>{en.current=void 0,ae?.()},[ae]),oe?.current??null,!1,!1),qt(`drop`,L.useCallback(e=>{let t=Ne.current;if(t===null||Ce===void 0)return;e.preventDefault();let[n,r]=lt(t,e.clientX,e.clientY).location,i=n-+!te;Ce([i,r],e.dataTransfer)},[te,lt,Ce]),oe?.current??null,!1,!1),qt(`dragleave`,L.useCallback(()=>{we?.()},[we]),oe?.current??null,!1,!1);let tn=L.useRef(S);tn.current=S;let nn=L.useRef(null),an=L.useCallback(e=>{Ne.current===null||!Ne.current.contains(document.activeElement)||(e===null&&tn.current.current!==void 0?F?.current?.focus({preventScroll:!0}):e!==null&&e.focus({preventScroll:!0}),nn.current=e)},[F]);L.useImperativeHandle(t,()=>({focus:()=>{let e=nn.current;e===null||!document.contains(e)?F?.current?.focus({preventScroll:!0}):e.focus({preventScroll:!0})},getBounds:(e,t)=>{if(!(F===void 0||F.current===null))return ct(F.current,e??0,t??-1)},damage:wt}),[F,wt,ct]);let on=L.useRef(),cn=rn(()=>{if(n<50||Oe?.disableAccessibilityTree===!0)return null;let e=Br(it,Me,n,N,Ae),t=te?0:-1;!te&&e[0]?.sourceIndex===0&&(e=e.slice(1));let[r,a]=S.current?.cell??[],o=S.current?.range,c=e.map(e=>e.sourceIndex),l=(0,Ts.default)(s,Math.min(f,s+i));return r!==void 0&&a!==void 0&&!(c.includes(r)&&l.includes(a))&&an(null),L.createElement(`table`,{key:`access-tree`,role:`grid`,"aria-rowcount":f+1,"aria-multiselectable":`true`,"aria-colcount":it.length+t},L.createElement(`thead`,{role:`rowgroup`},L.createElement(`tr`,{role:`row`,"aria-rowindex":1},e.map(e=>L.createElement(`th`,{role:`columnheader`,"aria-selected":S.columns.hasIndex(e.sourceIndex),"aria-colindex":e.sourceIndex+1+t,tabIndex:-1,onFocus:t=>{if(t.target!==nn.current)return xe?.([e.sourceIndex,-1])},key:e.sourceIndex},e.title)))),L.createElement(`tbody`,{role:`rowgroup`},l.map(n=>L.createElement(`tr`,{role:`row`,"aria-selected":S.rows.hasIndex(n),key:n,"aria-rowindex":n+2},e.map(e=>{let i=e.sourceIndex,s=fi(i,n),c=r===i&&a===n,l=o!==void 0&&i>=o.x&&i=o.y&&n{let e=F?.current;if(e!=null)return ne?.({bounds:ct(e,i,n),cancel:()=>void 0,preventDefault:()=>void 0,stopPropagation:()=>void 0,ctrlKey:!1,key:`Enter`,keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:d})},onFocusCapture:e=>{if(!(e.target===nn.current||on.current?.[0]===i&&on.current?.[1]===n))return on.current=d,xe?.(d)},ref:c?an:void 0,tabIndex:-1},Ds(f,ke))})))))},[n,it,Me,N,Ae,f,s,i,S,an,p,F,ne,ct,xe],200),ln=C===0||!E?0:Me>C?1:(0,us.default)(-Ae/100,0,1),un=-s*32+je,dn=D?(0,us.default)(-un/100,0,1):0,fn=L.useMemo(()=>{if(!ln&&!dn)return null;let e={position:`absolute`,top:0,left:ot,width:n-ot,height:r,opacity:ln,pointerEvents:`none`,transition:Ee?void 0:`opacity 0.2s`,boxShadow:`inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)`},t={position:`absolute`,top:$e,left:0,width:n,height:r,opacity:dn,pointerEvents:`none`,transition:De?void 0:`opacity 0.2s`,boxShadow:`inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)`};return L.createElement(L.Fragment,null,ln>0&&L.createElement(`div`,{id:`shadow-x`,style:e}),dn>0&&L.createElement(`div`,{id:`shadow-y`,style:t}))},[ln,dn,ot,n,Ee,$e,r,De]),pn=L.useMemo(()=>({position:`absolute`,top:0,left:0}),[]);return L.createElement(L.Fragment,null,L.createElement(`canvas`,{"data-testid":`data-grid-canvas`,tabIndex:0,onKeyDown:Zt,onKeyUp:Qt,onFocus:v,onBlur:y,ref:$t,style:Ft},cn),L.createElement(`canvas`,{ref:We,style:pn}),fn)}));function ks(e,t,n,r){return(0,us.default)(Math.round(t-(e.growOffset??0)),Math.ceil(n),Math.floor(r))}var As=e=>{let[t,n]=L.useState(),[r,i]=L.useState(),[a,o]=L.useState(),[s,c]=L.useState(),[l,u]=L.useState(!1),[d,f]=L.useState(),[p,m]=L.useState(),[h,g]=L.useState(),[_,v]=L.useState(!1),[y,b]=L.useState(),{onHeaderMenuClick:x,getCellContent:S,onColumnMoved:C,onColumnResize:w,onColumnResizeStart:T,onColumnResizeEnd:E,gridRef:D,maxColumnWidth:O,minColumnWidth:k,onRowMoved:A,lockColumns:j,onColumnProposeMove:M,onMouseDown:ee,onMouseUp:N,onItemHovered:te,onDragStart:ne,canvasRef:P}=e,re=(w??E??T)!==void 0,{columns:F,selection:ie}=e,ae=ie.columns,oe=L.useCallback(e=>{let[t,n]=e.location;a!==void 0&&s!==t&&t>=j?(u(!0),c(t)):p!==void 0&&n!==void 0?(v(!0),g(Math.max(0,n))):r===void 0&&!l&&!_&&te?.(e)},[a,p,s,te,j,r,l,_]),se=C!==void 0,ce=L.useCallback(e=>{if(e.button===0){let[t,r]=e.location;if(e.kind===`out-of-bounds`&&e.isEdge&&re){let e=D?.current?.getBounds(F.length-1,-1);e!==void 0&&(n(e.x),i(F.length-1))}else if(e.kind===`header`&&t>=j){let r=P?.current;if(e.isEdge&&re&&r){n(e.bounds.x),i(t);let a=r.getBoundingClientRect().width/r.offsetWidth,o=e.bounds.width/a;T?.(F[t],o,t,o+(F[t].growOffset??0))}else e.kind===`header`&&se&&(f(e.bounds.x),o(t))}else e.kind===`cell`&&j>0&&t===0&&r!==void 0&&A!==void 0&&(b(e.bounds.y),m(r))}ee?.(e)},[ee,re,j,A,D,F,se,T,P]),le=L.useCallback((e,t)=>{l||_||x?.(e,t)},[l,_,x]),ue=L.useRef(-1),de=L.useCallback(()=>{ue.current=-1,m(void 0),g(void 0),b(void 0),v(!1),o(void 0),c(void 0),f(void 0),u(!1),i(void 0),n(void 0)},[]),fe=L.useCallback((e,t)=>{if(e.button===0){if(r!==void 0){if(ae?.hasIndex(r)===!0)for(let e of ae){if(e===r)continue;let t=F[e],n=ks(t,ue.current,k,O);w?.(t,n,e,n+(t.growOffset??0))}let e=ks(F[r],ue.current,k,O);if(E?.(F[r],e,r,e+(F[r].growOffset??0)),ae.hasIndex(r))for(let e of ae){if(e===r)continue;let t=F[e],n=ks(t,ue.current,k,O);E?.(t,n,e,n+(t.growOffset??0))}}de(),a!==void 0&&s!==void 0&&C?.(a,s),p!==void 0&&h!==void 0&&A?.(p,h)}N?.(e,t)},[N,r,a,s,p,h,ae,E,F,k,O,w,C,A,de]),pe=L.useMemo(()=>{if(!(a===void 0||s===void 0)&&a!==s&&M?.(a,s)!==!1)return{src:a,dest:s}},[a,s,M]),me=L.useCallback(e=>{let n=P?.current;if(a!==void 0&&d!==void 0)Math.abs(e.clientX-d)>20&&u(!0);else if(p!==void 0&&y!==void 0)Math.abs(e.clientY-y)>20&&v(!0);else if(r!==void 0&&t!==void 0&&n){let i=n.getBoundingClientRect().width/n.offsetWidth,a=(e.clientX-t)/i,o=F[r],s=ks(o,a,k,O);if(w?.(o,s,r,s+(o.growOffset??0)),ue.current=a,ae?.first()===r)for(let e of ae){if(e===r)continue;let t=F[e],n=ks(t,ue.current,k,O);w?.(t,n,e,n+(t.growOffset??0))}}},[a,d,p,y,r,t,F,k,O,w,ae,P]),he=L.useCallback((e,t)=>{if(p===void 0||h===void 0)return S(e,t);let[n,r]=e;return r===h?r=p:(r>h&&--r,r>=p&&(r+=1)),S([n,r],t)},[p,h,S]),ge=L.useCallback(e=>{ne?.(e),e.defaultPrevented()||de()},[de,ne]);return L.createElement(Os,{accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,enableGroups:e.enableGroups,eventTargetRef:e.eventTargetRef,experimental:e.experimental,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,headerIcons:e.headerIcons,height:e.height,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,resizeColumn:r,isDraggable:e.isDraggable,isFilling:e.isFilling,isFocused:e.isFocused,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDrop:e.onDrop,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,verticalBorder:e.verticalBorder,width:e.width,getCellContent:he,isResizing:r!==void 0,onHeaderMenuClick:le,isDragging:l,onItemHovered:oe,onDragStart:ge,onMouseDown:ce,allowResize:re,onMouseUp:fe,dragAndDropState:pe,onMouseMoveRaw:me,ref:D})};function js(e){let t=(0,L.useRef)(null),[n,r]=(0,L.useState)({width:e?.[0],height:e?.[1]});return(0,L.useLayoutEffect)(()=>{let e=new window.ResizeObserver(e=>{for(let t of e){let{width:e,height:n}=t&&t.contentRect||{};r(t=>t.width===e&&t.height===n?t:{width:e,height:n})}});return t.current&&e.observe(t.current,void 0),()=>{e.disconnect()}},[t.current]),{ref:t,...n}}var Ms=(e,t,n)=>{let r=(0,L.useRef)(null),i=(0,L.useRef)(null),a=(0,L.useRef)(null),o=(0,L.useRef)(0),s=(0,L.useRef)(t);s.current=t;let c=n.current;(0,L.useEffect)(()=>{let t=()=>{if(i.current===!1&&c!==null){let e=[c.scrollLeft,c.scrollTop];if(a.current?.[0]===e[0]&&a.current?.[1]===e[1])if(o.current>10){a.current=null,i.current=null;return}else o.current++;else o.current=0,s.current(e[0],e[1]),a.current=e;r.current=window.setTimeout(t,1e3/120)}},n=()=>{i.current=!0,a.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},l=e=>{e.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(t,1e3/120))};if(e&&c!==null){let e=c;return e.addEventListener(`touchstart`,n),e.addEventListener(`touchend`,l),()=>{e.removeEventListener(`touchstart`,n),e.removeEventListener(`touchend`,l),r.current!==null&&window.clearTimeout(r.current)}}},[e,c])};St();var Ns=xt(`div`)({name:`ScrollRegionStyle`,class:`gdg-s1dgczr6`,propsAsIs:!1,vars:{"s1dgczr6-0":[e=>e.isSafari?`scroll`:`auto`]}});function Ps(e){let[t,n]=L.useState(!1),r=typeof window>`u`?null:window,i=L.useRef(0);return qt(`touchstart`,L.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),qt(`touchend`,L.useCallback(t=>{t.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),e))},[e]),r,!0,!1),t}var Fs=e=>{let{children:t,clientHeight:n,scrollHeight:r,scrollWidth:i,update:a,draggable:o,className:s,preventDiagonalScrolling:c=!1,paddingBottom:l=0,paddingRight:u=0,rightElement:d,rightElementProps:f,kineticScrollPerfHack:p=!1,scrollRef:m,initialSize:h}=e,g=[],_=f?.sticky??!1,v=f?.fill??!1,y=L.useRef(0),b=L.useRef(0),x=L.useRef(null),S=typeof window>`u`?1:window.devicePixelRatio,C=L.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),w=L.useRef(null),T=Ps(200),[E,D]=L.useState(!0),O=L.useRef(0);L.useLayoutEffect(()=>{if(!E||T||C.current.lockDirection===void 0)return;let e=x.current;if(e===null)return;let[t,n]=C.current.lockDirection;t===void 0?n!==void 0&&(e.scrollTop=n):e.scrollLeft=t,C.current.lockDirection=void 0},[T,E]);let k=L.useCallback((e,t)=>{let n=x.current;if(n===null)return;t??=n.scrollTop,e??=n.scrollLeft;let i=C.current.scrollTop,o=C.current.scrollLeft,s=e-o,d=t-i;T&&s!==0&&d!==0&&(Math.abs(s)>3||Math.abs(d)>3)&&c&&C.current.lockDirection===void 0&&(C.current.lockDirection=Math.abs(s)0&&(Math.abs(g)>2e3||h===0||h===_)&&r>n.scrollHeight+5){let e=h/_,t=(r-m)*e;y.current=t-h}f!==void 0&&(window.clearTimeout(O.current),D(!1),O.current=window.setTimeout(()=>D(!0),200)),a({x:e,y:h+y.current,width:p-u,height:m-l,paddingRight:w.current?.clientWidth??0})},[l,u,r,a,c,T]);Ms(p&&_s.value,k,x);let A=L.useRef(k);A.current=k;let j=L.useRef(),M=L.useRef(!1);L.useLayoutEffect(()=>{M.current?k():M.current=!0},[k,l,u]);let ee=L.useCallback(e=>{x.current=e,m!==void 0&&(m.current=e)},[m]),N=0,te=0;for(g.push(L.createElement(`div`,{key:N++,style:{width:i,height:0}}));teA.current(),0),j.current={width:P,height:re}),(P??0)===0||(re??0)===0?L.createElement(`div`,{ref:ne}):L.createElement(`div`,{ref:ne},L.createElement(Ns,{isSafari:_s.value},L.createElement(`div`,{className:`dvn-underlay`},t),L.createElement(`div`,{ref:ee,style:j.current,draggable:o,onDragStart:e=>{o||(e.stopPropagation(),e.preventDefault())},className:`dvn-scroller `+(s??``),onScroll:()=>k()},L.createElement(`div`,{className:`dvn-scroll-inner`+(d===void 0?` dvn-hidden`:``)},L.createElement(`div`,{className:`dvn-stack`},g),d!==void 0&&L.createElement(L.Fragment,null,!v&&L.createElement(`div`,{className:`dvn-spacer`}),L.createElement(`div`,{ref:w,style:{height:re,maxHeight:n-Math.ceil(S%1),position:`sticky`,top:0,paddingLeft:1,marginBottom:-40,marginRight:u,flexGrow:v?1:void 0,right:_?u??0:void 0,pointerEvents:`auto`}},d))))))},Is=e=>{let{columns:t,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:a,enableGroups:o,freezeColumns:s,experimental:c,nonGrowWidth:l,clientSize:u,className:d,onVisibleRegionChanged:f,scrollRef:p,preventDiagonalScrolling:m,rightElement:h,rightElementProps:g,overscrollX:_,overscrollY:v,initialSize:y,smoothScrollX:b=!1,smoothScrollY:x=!1,isDraggable:S}=e,{paddingRight:C,paddingBottom:w}=c??{},[T,E]=u,D=L.useRef(),O=L.useRef(),k=L.useRef(),A=L.useRef(),j=l+Math.max(0,_??0),M=o?i+a:i;if(typeof r==`number`)M+=n*r;else for(let e=0;e{if(ee.current===void 0)return;let e={...ee.current},i=0,a=e.x<0?-e.x:0,o=0,c=0;e.x=e.x<0?0:e.x;let l=0;for(let e=0;e=t+n.width)i+=n.width,c++,o++;else if(e.x>t)i+=n.width,b?a+=t-e.x:c++,o++;else if(e.x+e.width>t)i+=n.width,o++;else break}let u=0,d=0,p=0;if(typeof r==`number`)x?(d=Math.floor(e.y/r),u=d*r-e.y):d=Math.ceil(e.y/r),p=Math.ceil(e.height/r)+d,u<0&&p++;else{let t=0;for(let i=0;i=t+n)t+=n,d++,p++;else if(e.y>a)t+=n,x?u+=a-e.y:d++,p++;else if(e.y+e.height>n/2+t)t+=n,p++;else break}}let m={x:c,y:d,width:o-c,height:p-d},h=D.current;(h===void 0||h.y!==m.y||h.x!==m.x||h.height!==m.height||h.width!==m.width||O.current!==a||k.current!==u||e.width!==A.current?.[0]||e.height!==A.current?.[1])&&(f?.({x:c,y:d,width:o-c,height:p-d},e.width,e.height,e.paddingRight??0,a,u),D.current=m,O.current=a,k.current=u,A.current=[e.width,e.height])},[t,r,n,f,s,b,x]),te=L.useCallback(e=>{ee.current=e,N()},[N]);return L.useEffect(()=>{N()},[N]),L.createElement(Fs,{scrollRef:p,className:d,kineticScrollPerfHack:c?.kineticScrollPerfHack,preventDiagonalScrolling:m,draggable:S===!0||typeof S==`string`,scrollWidth:j+(C??0),scrollHeight:M+(w??0),clientHeight:E,rightElement:h,paddingBottom:w,paddingRight:C,rightElementProps:g,update:te,initialSize:y},L.createElement(As,{eventTargetRef:p,width:T,height:E,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,onColumnProposeMove:e.onColumnProposeMove,verticalBorder:e.verticalBorder,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY}))};St();var Ls=xt(`div`)({name:`SearchWrapper`,class:`gdg-seveqep`,propsAsIs:!1});ct(),E();var Rs=L.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},L.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`48`,d:`M112 244l144-144 144 144M256 120v292`})),zs=L.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},L.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`48`,d:`M112 268l144 144 144-144M256 392V100`})),Bs=L.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},L.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`32`,d:`M368 368L144 144M368 144L144 368`})),Vs=10,Hs=e=>{let{canvasRef:t,cellYOffset:n,rows:r,columns:i,searchInputRef:a,searchValue:o,searchResults:s,onSearchValueChange:c,getCellsForSelection:l,onSearchResultsChanged:u,showSearch:d=!1,onSearchClose:f}=e,[p]=L.useState(()=>`search-box-`+Math.round(Math.random()*1e3)),[m,h]=L.useState(``),g=o??m,_=L.useCallback(e=>{h(e),c?.(e)},[c]),[v,y]=L.useState(),b=L.useRef(v);b.current=v,L.useEffect(()=>{s!==void 0&&(s.length>0?y(e=>({rowsSearched:r,results:s.length,selectedIndex:e?.selectedIndex??-1})):y(void 0))},[r,s]);let S=L.useRef();S.current===void 0&&(S.current=new AbortController);let C=L.useRef(),[w,T]=L.useState([]),E=s??w,D=L.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.current=void 0,S.current.abort())},[]),O=L.useRef(n);O.current=n;let k=L.useCallback(e=>{let t=new RegExp(e.replace(/([$()*+.?[\\\]^{|}-])/g,`\\$1`),`i`),n=O.current,a=Math.min(10,r),o=0;y(void 0),T([]);let s=[],c=async()=>{if(l===void 0)return;let e=performance.now(),d=r-o,f=l({x:0,y:n,width:i.length,height:Math.min(a,d,r-n)},S.current.signal);typeof f==`function`&&(f=await f());let p=!1;for(let[e,r]of f.entries())for(let[i,a]of r.entries()){let r;switch(a.kind){case I.Text:case I.Number:r=a.displayData;break;case I.Uri:case I.Markdown:r=a.data;break;case I.Boolean:r=typeof a.data==`boolean`?a.data.toString():void 0;break;case I.Image:case I.Bubble:r=a.data.join(`🐳`);break;case I.Custom:r=a.copyData;break}r!==void 0&&t.test(r)&&(s.push([i,e+n]),p=!0)}let m=performance.now();p&&T([...s]),o+=f.length,x(o<=r);let h=b.current?.selectedIndex??-1;y({results:s.length,rowsSearched:o,selectedIndex:h}),u?.(s,h),n+a>=r?n=0:n+=a;let g=m-e,_=Vs/Math.max(g,1);a=Math.ceil(a*_),o{f?.(),y(void 0),T([]),u?.([],-1),D(),t?.current?.focus()},[D,t,f,u]),j=L.useCallback(e=>{_(e.target.value),s===void 0&&(e.target.value===``?(y(void 0),T([]),D()):k(e.target.value))},[k,D,_,s]);L.useEffect(()=>{d&&a.current!==null&&(_(``),a.current.focus({preventScroll:!0}))},[d,a,_]);let M=L.useCallback(e=>{if(e?.stopPropagation?.(),v===void 0)return;let t=(v.selectedIndex+1)%v.results;y({...v,selectedIndex:t}),u?.(E,t)},[v,u,E]),ee=L.useCallback(e=>{if(e?.stopPropagation?.(),v===void 0)return;let t=(v.selectedIndex-1)%v.results;t<0&&(t+=v.results),y({...v,selectedIndex:t}),u?.(E,t)},[u,E,v]),N=L.useCallback(e=>{(e.ctrlKey||e.metaKey)&&e.nativeEvent.code===`KeyF`||e.key===`Escape`?(A(),e.stopPropagation(),e.preventDefault()):e.key===`Enter`&&(e.shiftKey?ee():M())},[A,M,ee]);L.useEffect(()=>()=>{D()},[D]);let[te,ne]=L.useState(!1);L.useEffect(()=>{if(d)ne(!0);else{let e=setTimeout(()=>ne(!1),150);return()=>clearTimeout(e)}},[d]);let P=L.useMemo(()=>{if(!d&&!te)return null;let e;v!==void 0&&(e=v.results>=1e3?`over 1000`:`${v.results} result${v.results===1?``:`s`}`,v.selectedIndex>=0&&(e=`${v.selectedIndex+1} of ${e}`));let t=e=>{e.stopPropagation()},n={width:`${Math.floor((v?.rowsSearched??0)/r*100)}%`};return L.createElement(Ls,{className:d?``:`out`,onMouseDown:t,onMouseMove:t,onMouseUp:t,onClick:t},L.createElement(`div`,{className:`gdg-search-bar-inner`},L.createElement(`input`,{id:p,"aria-hidden":!d,"data-testid":`search-input`,ref:a,onChange:j,value:g,tabIndex:d?void 0:-1,onKeyDownCapture:N}),L.createElement(`button`,{"aria-label":`Previous Result`,"aria-hidden":!d,tabIndex:d?void 0:-1,onClick:ee,disabled:(v?.results??0)===0},Rs),L.createElement(`button`,{"aria-label":`Next Result`,"aria-hidden":!d,tabIndex:d?void 0:-1,onClick:M,disabled:(v?.results??0)===0},zs),f!==void 0&&L.createElement(`button`,{"aria-label":`Close Search`,"aria-hidden":!d,"data-testid":`search-close-button`,tabIndex:d?void 0:-1,onClick:A},Bs)),v===void 0?L.createElement(`div`,{className:`gdg-search-status`},L.createElement(`label`,{htmlFor:p},`Type to search`)):L.createElement(L.Fragment,null,L.createElement(`div`,{className:`gdg-search-status`},L.createElement(`div`,{"data-testid":`search-result-area`},e)),L.createElement(`div`,{className:`gdg-search-progress`,style:n})))},[d,te,v,r,p,a,j,g,N,ee,M,f,A]);return L.createElement(L.Fragment,null,L.createElement(Is,{prelightCells:E,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,className:e.className,clientSize:e.clientSize,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,nonGrowWidth:e.nonGrowWidth,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,initialSize:e.initialSize,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onMouseMove:e.onMouseMove,onVisibleRegionChanged:e.onVisibleRegionChanged,overscrollX:e.overscrollX,overscrollY:e.overscrollY,preventDiagonalScrolling:e.preventDiagonalScrolling,rightElement:e.rightElement,rightElementProps:e.rightElementProps,rowHeight:e.rowHeight,rows:e.rows,scrollRef:e.scrollRef,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,verticalBorder:e.verticalBorder,onColumnProposeMove:e.onColumnProposeMove,drawFocusRing:e.drawFocusRing,drawCell:e.drawCell,drawHeader:e.drawHeader,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY}),P)},Us,Ws,Gs=o((()=>{Us=u(f(),1),Ws=class extends Us.PureComponent{wrapperRef=Us.createRef();componentDidMount(){document.addEventListener(`touchend`,this.clickOutside,!0),document.addEventListener(`mousedown`,this.clickOutside,!0),document.addEventListener(`contextmenu`,this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener(`touchend`,this.clickOutside,!0),document.removeEventListener(`mousedown`,this.clickOutside,!0),document.removeEventListener(`contextmenu`,this.clickOutside,!0)}clickOutside=e=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(e))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(e.target)){let t=e.target;for(;t!==null;){if(t.classList.contains(`click-outside-ignore`))return;t=t.parentElement}this.props.onClickOutside()}};render(){let{onClickOutside:e,isOutsideClick:t,...n}=this.props;return Us.createElement(`div`,{...n,ref:this.wrapperRef},this.props.children)}}}));St(),Gs();var Ks=xt(`input`)({name:`RenameInput`,class:`gdg-r17m35ur`,propsAsIs:!1,vars:{"r17m35ur-0":[e=>Math.max(16,e.targetHeight-10),`px`]}}),qs=e=>{let{bounds:t,group:n,onClose:r,canvasBounds:i,onFinish:a}=e,[o,s]=L.useState(n);return L.createElement(Ws,{style:{position:`absolute`,left:t.x-i.left+1,top:t.y-i.top,width:t.width-2,height:t.height},className:`gdg-c1tqibwd`,onClickOutside:r},L.createElement(Ks,{targetHeight:t.height,"data-testid":`group-rename-input`,value:o,onBlur:r,onFocus:e=>e.target.setSelectionRange(0,o.length),onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?a(o):e.key===`Escape`&&r()},autoFocus:!0}))};function Js(e,t){return e===void 0?!1:e.length>1&&e.startsWith(`_`)?Number.parseInt(e.slice(1))===t.keyCode:e.length===1&&e>=`a`&&e<=`z`?e.toUpperCase().codePointAt(0)===t.keyCode:e===t.key}function Ys(e,t,n){let r=Xs(e,t);return r&&(n.didMatch=!0),r}function Xs(e,t){if(e.length===0)return!1;if(e.includes(`|`)){let n=e.split(`|`);for(let e of n)if(Xs(e,t))return!0;return!1}let n=!1,r=!1,i=!1,a=!1,o=e.split(`+`);if(!Js(o.pop(),t))return!1;if(o[0]===`any`)return!0;for(let e of o)switch(e){case`ctrl`:n=!0;break;case`shift`:r=!0;break;case`alt`:i=!0;break;case`meta`:a=!0;break;case`primary`:vs.value?a=!0:n=!0;break}return t.altKey===i&&t.ctrlKey===n&&t.shiftKey===r&&t.metaKey===a}ct();function Zs(e,t,n,r,i,a){return[L.useCallback((o,s,c,l)=>{(a===`cell`||a===`multi-cell`)&&o!==void 0&&(o={...o,range:{x:o.cell[0],y:o.cell[1],width:1,height:1}});let u=n===`mixed`&&(c||l===`drag`),d=r===`mixed`&&u,f=i===`mixed`&&u,p={current:o===void 0?void 0:{...o,rangeStack:l===`drag`?e.current?.rangeStack??[]:[]},columns:d?e.columns:st.empty(),rows:f?e.rows:st.empty()};c&&(a===`multi-rect`||a===`multi-cell`)&&p.current!==void 0&&e.current!==void 0&&(p={...p,current:{...p.current,rangeStack:[...e.current.rangeStack,e.current.range]}}),t(p,s)},[r,e,n,a,i,t]),L.useCallback((a,o,s)=>{a??=e.rows,o!==void 0&&(a=a.add(o));let c;if(i===`exclusive`&&a.length>0)c={current:void 0,columns:st.empty(),rows:a};else{let t=s&&n===`mixed`,i=s&&r===`mixed`;c={current:t?e.current:void 0,columns:i?e.columns:st.empty(),rows:a}}t(c,!1)},[r,e,n,i,t]),L.useCallback((a,o,s)=>{a??=e.columns,o!==void 0&&(a=a.add(o));let c;if(r===`exclusive`&&a.length>0)c={current:void 0,rows:st.empty(),columns:a};else{let t=s&&n===`mixed`,r=s&&i===`mixed`;c={current:t?e.current:void 0,rows:r?e.rows:st.empty(),columns:a}}t(c,!1)},[r,e,n,i,t])]}ct();function Qs(e,t,n,r,i){let a=L.useCallback(n=>{if(e===!0){let e=[];for(let r=n.y;r=i?a.push({kind:I.Loading,allowOverlay:!1}):a.push(t([e,r]));e.push(a)}return e}return e?.(n,r.signal)??[]},[r.signal,t,e,i]),o=e===void 0?void 0:a,s=L.useCallback(e=>{if(o===void 0)return[];let t={...e,x:e.x-n};if(t.x<0){t.x=0,t.width--;let e=o(t,r.signal);return typeof e==`function`?async()=>(await e()).map(e=>[{kind:I.Loading,allowOverlay:!1},...e]):e.map(e=>[{kind:I.Loading,allowOverlay:!1},...e])}return o(t,r.signal)},[r.signal,o,n]);return[e===void 0?void 0:s,o]}E(),ct();function $s(e){if(e.copyData!==void 0)return{formatted:e.copyData,rawValue:e.copyData,format:`string`};switch(e.kind){case I.Boolean:return{formatted:e.data===!0?`TRUE`:e.data===!1?`FALSE`:e.data===void 0?`INDETERMINATE`:``,rawValue:e.data,format:`boolean`};case I.Custom:return{formatted:e.copyData,rawValue:e.copyData,format:`string`};case I.Image:case I.Bubble:return{formatted:e.data,rawValue:e.data,format:`string-array`};case I.Drilldown:return{formatted:e.data.map(e=>e.text),rawValue:e.data.map(e=>e.text),format:`string-array`};case I.Text:return{formatted:e.displayData??e.data,rawValue:e.data,format:`string`};case I.Uri:return{formatted:e.displayData??e.data,rawValue:e.data,format:`url`};case I.Markdown:case I.RowID:return{formatted:e.data,rawValue:e.data,format:`string`};case I.Number:return{formatted:e.displayData,rawValue:e.data,format:`number`};case I.Loading:return{formatted:`#LOADING`,rawValue:``,format:`string`};case I.Protected:return{formatted:`************`,rawValue:``,format:`string`};default:S(e)}}function ec(e,t){return e.map((e,n)=>{let r=t[n];return e.map(e=>e.span!==void 0&&e.span[0]!==r?{formatted:``,rawValue:``,format:`string`}:$s(e))})}function tc(e,t){return(t?/[\t\n",]/:/[\t\n"]/).test(e)&&(e=`"${e.replace(/"/g,`""`)}"`),e}function nc(e){let t=[];for(let n of e){let e=[];for(let t of n)t.format===`url`?e.push(t.rawValue?.toString()??``):t.format===`string-array`?e.push(t.formatted.map(e=>tc(e,!0)).join(`,`)):e.push(tc(t.formatted,!1));t.push(e.join(` `))}return t.join(` +`)}function rc(e){return e.replace(/\t/g,` `).replace(/ {2,}/g,e=>` `.repeat(e.length))}function ic(e){return`"`+e.replace(/&/g,`&`).replace(/"/g,`"`).replace(//g,`>`)+`"`}function ac(e){return e.replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`)}function tee(e){let t=[];t.push(``,``);for(let n of e){t.push(``);for(let e of n){let n=`gdg-format="${e.format}"`;e.format===`url`?t.push(``):e.format===`string-array`?t.push(``):t.push(``)}t.push(``)}return t.push(`
${rc(e.formatted)}
    ${e.formatted.map((t,n)=>`
  1. `+rc(t)+`
  2. `).join(``)}
${rc(e.formatted)}
`),t.join(``)}function oc(e,t){let n=ec(e,t);return{textPlain:nc(n),textHtml:tee(n)}}function sc(e){let t=document.createElement(`html`);t.innerHTML=e.replace(/ /g,` `);let n=t.querySelector(`table`);if(n===null)return;let r=[n],i=[],a;for(;r.length>0;){let e=r.pop();if(e===void 0)break;if(e instanceof HTMLTableElement||e.nodeName===`TBODY`)r.push(...[...e.children].reverse());else if(e instanceof HTMLTableRowElement)a!==void 0&&i.push(a),a=[],r.push(...[...e.children].reverse());else if(e instanceof HTMLTableCellElement){let t=e.cloneNode(!0),n=t.children.length===1&&t.children[0].nodeName===`P`?t.children[0]:null,r=n?.children.length===1&&n.children[0].nodeName===`FONT`,i=t.querySelectorAll(`br`);for(let e of i)e.replaceWith(` +`);let o=t.getAttribute(`gdg-raw-value`),s=t.getAttribute(`gdg-format`)??`string`;if(t.querySelector(`a`)!==null)a?.push({rawValue:t.querySelector(`a`)?.getAttribute(`href`)??``,formatted:t.textContent??``,format:s});else if(t.querySelector(`ol`)!==null){let e=t.querySelectorAll(`li`);a?.push({rawValue:[...e].map(e=>e.getAttribute(`gdg-raw-value`)??``),formatted:[...e].map(e=>e.textContent??``),format:`string-array`})}else if(o!==null)a?.push({rawValue:ac(o),formatted:t.textContent??``,format:s});else{let e=t.textContent??``;r&&(e=e.replace(/\n(?!\n)/g,``)),a?.push({rawValue:e??``,formatted:e??``,format:s})}}}return a!==void 0&&i.push(a),i}function cc(e,t,n,r,i){let a=e;if(r===`allowPartial`||e.current===void 0||t===void 0)return e;let o=!1;do{if(e?.current===void 0)break;let r=e.current?.range,s=[];if(r.width>2){let e=t({x:r.x,y:r.y,width:1,height:r.height},i.signal);if(typeof e==`function`)return a;s.push(...e);let n=t({x:r.x+r.width-1,y:r.y,width:1,height:r.height},i.signal);if(typeof n==`function`)return a;s.push(...n)}else{let e=t({x:r.x,y:r.y,width:r.width,height:r.height},i.signal);if(typeof e==`function`)return a;s.push(...e)}let c=r.x-n,l=r.x+r.width-1-n;for(let e of s)for(let t of e)t.span!==void 0&&(c=Math.min(t.span[0],c),l=Math.max(t.span[1],l));c===r.x-n&&l===r.x+r.width-1-n?o=!0:e={current:{cell:e.current.cell??[0,0],range:{x:c+n,y:r.y,width:l-c+1,height:r.height},rangeStack:e.current.rangeStack},columns:e.columns,rows:e.rows}}while(!o);return e}function lc(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&(e=e.slice(1,-1).replace(/""/g,`"`)),e}function uc(e){let t;(function(e){e[e.None=0]=`None`,e[e.inString=1]=`inString`,e[e.inStringPostQuote=2]=`inStringPostQuote`})(t||={});let n=[],r=[],i=0,a=t.None;e=e.replace(/\r\n/g,` `);let o=0;for(let s of e){switch(a){case t.None:s===` `||s===` `?(r.push(e.slice(i,o)),i=o+1,s===` `&&(n.push(r),r=[])):s===`"`&&(a=t.inString);break;case t.inString:s===`"`&&(a=t.inStringPostQuote);break;case t.inStringPostQuote:s===`"`?a=t.inString:s===` `||s===` `?(r.push(lc(e.slice(i,o))),i=o+1,s===` -`&&(n.push(r),r=[]),a=t.None):a=t.None;break}o++}return ie.map(e=>({rawValue:e,formatted:e,format:`string`})))}function nee(e,t,n){let r=oc(e,t),i=e=>{window.navigator.clipboard?.writeText(e)},a=(e,t)=>window.navigator.clipboard?.write===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([e],{type:`text/plain`}),"text/html":new Blob([t],{type:`text/html`})})]),!0);window.navigator.clipboard?.write!==void 0||n?.clipboardData!==void 0?((e,t)=>{try{if(n===void 0||n.clipboardData===null)throw Error(`No clipboard data`);n?.clipboardData?.setData(`text/plain`,e),n?.clipboardData?.setData(`text/html`,t)}catch{a(e,t)||i(e)}})(r.textPlain,r.textHtml):i(r.textPlain),n?.preventDefault()}function dc(e){return e!==!0}St();function fc(e){return typeof e==`string`?e:`${e}px`}var pc=xt(`div`)({name:`Wrapper`,class:`gdg-wmyidgi`,propsAsIs:!1,vars:{"wmyidgi-0":[e=>e.innerWidth],"wmyidgi-1":[e=>e.innerHeight]}}),mc=e=>{let{inWidth:t,inHeight:n,children:r,...i}=e;return L.createElement(pc,{innerHeight:fc(n),innerWidth:fc(t),...i},r)},hc=2,gc=1300;function _c(e,t,n){let r=L.useRef(0),[i,a]=e??[0,0];L.useEffect(()=>{if(i===0&&a===0){r.current=0;return}let e=!1,o=0,s=c=>{if(!e){if(o===0)o=c;else{let e=c-o;r.current=Math.min(1,r.current+e/gc);let s=r.current**1.618*e*hc;t.current?.scrollBy(i*s,a*s),o=c,n?.()}window.requestAnimationFrame(s)}};return window.requestAnimationFrame(s),()=>{e=!0}},[t,i,a,n])}Ti();function vc({rowHeight:e,headerHeight:t,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:a,scaleToRem:o,remSize:s}){let[c,l,u,d,f,p]=L.useMemo(()=>{if(!o||s===16)return[e,t,n,r,i,a];let c=s/16,l=e,u=bi();return[typeof l==`number`?l*c:e=>Math.ceil(l(e)*c),Math.ceil(t*c),Math.ceil(n*c),{...r,headerIconSize:(r?.headerIconSize??u.headerIconSize)*c,cellHorizontalPadding:(r?.cellHorizontalPadding??u.cellHorizontalPadding)*c,cellVerticalPadding:(r?.cellVerticalPadding??u.cellVerticalPadding)*c},Math.ceil((i??0)*c),Math.ceil((a??0)*c)]},[n,t,i,a,s,e,o,r]);return{rowHeight:c,headerHeight:l,groupHeaderHeight:u,theme:d,overscrollX:f,overscrollY:p}}var yc={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function bc(e,t){return e===!0?t:e===!1?``:e}function xc(e){let t=_s.value;return{activateCell:bc(e.activateCell,` |Enter|shift+Enter`),clear:bc(e.clear,`any+Escape`),closeOverlay:bc(e.closeOverlay,`any+Escape`),acceptOverlayDown:bc(e.acceptOverlayDown,`Enter`),acceptOverlayUp:bc(e.acceptOverlayUp,`shift+Enter`),acceptOverlayLeft:bc(e.acceptOverlayLeft,`shift+Tab`),acceptOverlayRight:bc(e.acceptOverlayRight,`Tab`),copy:e.copy,cut:e.cut,delete:bc(e.delete,t?`Backspace|Delete`:`Delete`),downFill:bc(e.downFill,`primary+_68`),scrollToSelectedCell:bc(e.scrollToSelectedCell,`primary+Enter`),goDownCell:bc(e.goDownCell,`ArrowDown`),goDownCellRetainSelection:bc(e.goDownCellRetainSelection,`alt+ArrowDown`),goLeftCell:bc(e.goLeftCell,`ArrowLeft|shift+Tab`),goLeftCellRetainSelection:bc(e.goLeftCellRetainSelection,`alt+ArrowLeft`),goRightCell:bc(e.goRightCell,`ArrowRight|Tab`),goRightCellRetainSelection:bc(e.goRightCellRetainSelection,`alt+ArrowRight`),goUpCell:bc(e.goUpCell,`ArrowUp`),goUpCellRetainSelection:bc(e.goUpCellRetainSelection,`alt+ArrowUp`),goToFirstCell:bc(e.goToFirstCell,`primary+Home`),goToFirstColumn:bc(e.goToFirstColumn,`Home|primary+ArrowLeft`),goToFirstRow:bc(e.goToFirstRow,`primary+ArrowUp`),goToLastCell:bc(e.goToLastCell,`primary+End`),goToLastColumn:bc(e.goToLastColumn,`End|primary+ArrowRight`),goToLastRow:bc(e.goToLastRow,`primary+ArrowDown`),goToNextPage:bc(e.goToNextPage,`PageDown`),goToPreviousPage:bc(e.goToPreviousPage,`PageUp`),paste:e.paste,rightFill:bc(e.rightFill,`primary+_82`),search:bc(e.search,`primary+f`),selectAll:bc(e.selectAll,`primary+a`),selectColumn:bc(e.selectColumn,`ctrl+ `),selectGrowDown:bc(e.selectGrowDown,`shift+ArrowDown`),selectGrowLeft:bc(e.selectGrowLeft,`shift+ArrowLeft`),selectGrowRight:bc(e.selectGrowRight,`shift+ArrowRight`),selectGrowUp:bc(e.selectGrowUp,`shift+ArrowUp`),selectRow:bc(e.selectRow,`shift+ `),selectToFirstCell:bc(e.selectToFirstCell,`primary+shift+Home`),selectToFirstColumn:bc(e.selectToFirstColumn,`primary+shift+ArrowLeft`),selectToFirstRow:bc(e.selectToFirstRow,`primary+shift+ArrowUp`),selectToLastCell:bc(e.selectToLastCell,`primary+shift+End`),selectToLastColumn:bc(e.selectToLastColumn,`primary+shift+ArrowRight`),selectToLastRow:bc(e.selectToLastRow,`primary+shift+ArrowDown`)}}function Sc(e){let t=dn(e);return L.useMemo(()=>{if(t===void 0)return xc(yc);let e={...t,goToNextPage:t?.goToNextPage??t?.pageDown??yc.goToNextPage,goToPreviousPage:t?.goToPreviousPage??t?.pageUp??yc.goToPreviousPage,goToFirstCell:t?.goToFirstCell??t?.first??yc.goToFirstCell,goToLastCell:t?.goToLastCell??t?.last??yc.goToLastCell,selectToFirstCell:t?.selectToFirstCell??t?.first??yc.selectToFirstCell,selectToLastCell:t?.selectToLastCell??t?.last??yc.selectToLastCell};return xc({...yc,...e})},[t])}var Cc=g(),wc=`modulepreload`,Tc=function(e,t){return new URL(e,t).href},Ec={},Dc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Tc(t,n),t=s(t),t in Ec)return;Ec[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:wc,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Oc,kc,Ac,jc,Mc,Nc,Pc,Fc=o((()=>{St(),Oc=()=>e=>e.targetX,kc=()=>e=>e.targetY,Ac=()=>e=>e.targetWidth,jc=()=>e=>e.targetHeight,Mc=()=>e=>e.targetY+10,Nc=()=>e=>Math.max(0,(e.targetHeight-28)/2),Pc=xt(`div`)({name:`DataGridOverlayEditorStyle`,class:`gdg-d19meir1`,propsAsIs:!1,vars:{"d19meir1-0":[kc(),`px`],"d19meir1-1":[Oc(),`px`],"d19meir1-2":[Ac(),`px`],"d19meir1-3":[jc(),`px`],"d19meir1-4":[Mc(),`px`],"d19meir1-5":[Nc(),`px`]}})}));function Ic(){let[e,t]=Rc.useState();return[e??void 0,t]}function Lc(){let[e,t]=Ic(),[n,r]=Rc.useState(0),[i,a]=Rc.useState(!0);return Rc.useLayoutEffect(()=>{if(e===void 0||!(`IntersectionObserver`in window))return;let t=new IntersectionObserver(e=>{e.length!==0&&a(e[0].isIntersecting)},{threshold:1});return t.observe(e),()=>t.disconnect()},[e]),Rc.useEffect(()=>{if(i||e===void 0)return;let t,n=()=>{let{right:i}=e.getBoundingClientRect();r(e=>Math.min(e+window.innerWidth-i-10,0)),t=requestAnimationFrame(n)};return t=requestAnimationFrame(n),()=>{t!==void 0&&cancelAnimationFrame(t)}},[e,i]),{ref:t,style:Rc.useMemo(()=>({transform:`translateX(${n}px)`}),[n])}}var Rc,zc=o((()=>{Rc=u(f(),1)})),Bc=c({default:()=>Hc}),Vc,Hc,Uc=o((()=>{Vc=u(f(),1),Ws(),Ti(),ct(),Fc(),zc(),Hc=e=>{let{target:t,content:n,onFinishEditing:r,forceEditMode:i,initialValue:a,imageEditorOverride:o,markdownDivCreateNode:s,highlight:c,className:l,theme:u,id:d,cell:f,bloom:p,validateCell:m,getCellRenderer:h,provideEditor:g,isOutsideClick:_}=e,[v,y]=Vc.useState(i?n:void 0),b=Vc.useRef(v??n);b.current=v??n;let[x,S]=Vc.useState(()=>m===void 0||!(Xe(n)&&m?.(f,n,b.current)===!1)),C=Vc.useCallback((e,t)=>{r(x?e:void 0,t)},[x,r]),w=Vc.useCallback(e=>{if(m!==void 0&&e!==void 0&&Xe(e)){let t=m(f,e,b.current);t===!1?S(!1):(typeof t==`object`&&(e=t),S(!0))}y(e)},[f,m]),T=Vc.useRef(!1),E=Vc.useRef(void 0),D=Vc.useCallback(()=>{C(v,[0,0]),T.current=!0},[v,C]),O=Vc.useCallback((e,t)=>{C(e,t??E.current??[0,0]),T.current=!0},[C]),k=Vc.useCallback(async e=>{let t=!1;e.key===`Escape`?(e.stopPropagation(),e.preventDefault(),E.current=[0,0]):e.key===`Enter`&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),E.current=[0,1],t=!0):e.key===`Tab`&&(e.stopPropagation(),e.preventDefault(),E.current=[e.shiftKey?-1:1,0],t=!0),window.setTimeout(()=>{!T.current&&E.current!==void 0&&(C(t?v:void 0,E.current),T.current=!0)},0)},[C,v]),A=v??n,[j,M]=Vc.useMemo(()=>{if(Ze(n))return[];let e=g?.(n);return e===void 0?[h(n)?.provideEditor?.(n),!1]:[e,!1]},[n,h,g]),{ref:ee,style:N}=Lc(),te=!0,ne,P=!0,re;if(j!==void 0){te=j.disablePadding!==!0,P=j.disableStyling!==!0;let e=$e(j);e&&(re=j.styleOverride);let n=e?j.editor:j;ne=Vc.createElement(n,{isHighlighted:c,onChange:w,value:A,initialValue:a,onFinishedEditing:O,validatedSelection:Xe(A)?A.selectionRange:void 0,forceEditMode:i,target:t,imageEditorOverride:o,markdownDivCreateNode:s,isValid:x,theme:u})}re={...re,...N};let F=document.getElementById(`portal`);if(F===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `

` as the last child of your ``.'),null;let ie=P?`gdg-style`:`gdg-unstyle`;x||(ie+=` gdg-invalid`),te&&(ie+=` gdg-pad`);let ae=p?.[0]??1,oe=p?.[1]??1;return(0,Cc.createPortal)(Vc.createElement(wi.Provider,{value:u},Vc.createElement(Us,{style:yi(u),className:l,onClickOutside:D,isOutsideClick:_},Vc.createElement(Pc,{ref:ee,id:d,className:ie,style:re,as:M===!0?`label`:void 0,targetX:t.x-ae,targetY:t.y-oe,targetWidth:t.width+ae*2,targetHeight:t.height+oe*2},Vc.createElement(`div`,{className:`gdg-clip-region`,onKeyDown:k},ne)))),F)}}));E();var Wc=u(qi(),1),Gc=u(Zi(),1);ct(),Ti(),vr();var Kc=L.lazy(async()=>await Dc(()=>Promise.resolve().then(()=>(Uc(),Bc)),void 0,import.meta.url)),qc=0;function Jc(e){return(0,Wc.default)((0,Gc.default)((0,Gc.default)(e).filter(e=>e.span!==void 0).map(e=>(0,ws.default)((e.span?.[0]??0)+1,(e.span?.[1]??0)+1))))}function Yc(e,t){return e===void 0||t===0||e.columns.length===0&&e.current===void 0?e:{current:e.current===void 0?void 0:{cell:[e.current.cell[0]+t,e.current.cell[1]],range:{...e.current.range,x:e.current.range.x+t},rangeStack:e.current.rangeStack.map(e=>({...e,x:e.x+t}))},rows:e.rows,columns:e.columns.offset(t)}}var Xc={kind:I.Loading,allowOverlay:!1},Zc={columns:st.empty(),rows:st.empty(),current:void 0},Qc=L.forwardRef((e,t)=>{let[n,r]=L.useState(Zc),[i,a]=L.useState(),o=L.useRef(null),s=L.useRef(null),[c,l]=L.useState(),u=L.useRef(null),d=L.useRef(),f=typeof window>`u`?null:window,{imageEditorOverride:p,getRowThemeOverride:m,markdownDivCreateNode:h,width:g,height:_,columns:v,rows:y,getCellContent:b,onCellClicked:w,onCellActivated:T,onFillPattern:E,onFinishedEditing:D,coercePasteValue:O,drawHeader:k,drawCell:A,editorBloom:j,onHeaderClicked:M,onColumnProposeMove:ee,spanRangeBehavior:N=`default`,onGroupHeaderClicked:te,onCellContextMenu:ne,className:P,onHeaderContextMenu:re,getCellsForSelection:F,onGroupHeaderContextMenu:ie,onGroupHeaderRenamed:ae,onCellEdited:oe,onCellsEdited:se,onSearchResultsChanged:ce,searchResults:le,onSearchValueChange:ue,searchValue:de,onKeyDown:fe,onKeyUp:pe,keybindings:me,editOnType:he=!0,onRowAppended:ge,onColumnMoved:_e,validateCell:ve,highlightRegions:ye,rangeSelect:be=`rect`,columnSelect:xe=`multi`,rowSelect:Se=`multi`,rangeSelectionBlending:Ce=`exclusive`,columnSelectionBlending:we=`exclusive`,rowSelectionBlending:Te=`exclusive`,onDelete:Ee,onDragStart:De,onMouseMove:Oe,onPaste:ke,copyHeaders:Ae=!1,freezeColumns:je=0,cellActivationBehavior:Me=`second-click`,rowSelectionMode:Ne=`auto`,onHeaderMenuClick:Pe,getGroupDetails:Fe,onSearchClose:Ie,onItemHovered:Le,onSelectionCleared:Re,showSearch:ze,onVisibleRegionChanged:Be,gridSelection:Ve,onGridSelectionChange:He,minColumnWidth:Ue=50,maxColumnWidth:We=500,maxColumnAutoWidth:Ge,provideEditor:Ke,trailingRowOptions:qe,freezeTrailingRows:Je=0,allowedFillDirections:Ye=`orthogonal`,scrollOffsetX:et,scrollOffsetY:tt,verticalBorder:nt,onDragOverCell:rt,onDrop:it,onColumnResize:ot,onColumnResizeEnd:ct,onColumnResizeStart:lt,customRenderers:ut,fillHandle:dt,drawFocusRing:ft=!0,experimental:pt,fixedShadowX:mt,fixedShadowY:ht,headerIcons:gt,imageWindowLoader:_t,initialSize:vt,isDraggable:yt,onDragLeave:bt,onRowMoved:xt,overscrollX:St,overscrollY:Ct,preventDiagonalScrolling:wt,rightElement:Tt,rightElementProps:Et,trapFocus:Dt=!1,smoothScrollX:Ot,smoothScrollY:kt,scaleToRem:At=!1,rowHeight:jt=34,headerHeight:Mt=36,groupHeaderHeight:Nt=Mt,theme:Pt,isOutsideClick:Ft,renderers:It}=e,Lt=typeof e.rowMarkers==`string`?void 0:e.rowMarkers,Rt=Lt?.kind??e.rowMarkers??`none`,zt=Lt?.width??e.rowMarkerWidth,Bt=Lt?.startIndex??e.rowMarkerStartIndex??1,Vt=Lt?.theme??e.rowMarkerTheme,Ht=Lt?.checkboxStyle??`square`,Ut=Math.max(Ue,20),Wt=Math.max(We,Ut),Gt=Math.max(Ge??Wt,Ut),Yt=L.useMemo(()=>typeof window>`u`?{fontSize:`16px`}:window.getComputedStyle(document.documentElement),[]),{rowHeight:Xt,headerHeight:Zt,groupHeaderHeight:Qt,theme:$t,overscrollX:en,overscrollY:tn}=vc({groupHeaderHeight:Nt,headerHeight:Mt,overscrollX:St,overscrollY:Ct,remSize:L.useMemo(()=>Number.parseFloat(Yt.fontSize),[Yt]),rowHeight:jt,scaleToRem:At,theme:Pt}),nn=Sc(me),rn=zt??(y>1e4?48:y>1e3?44:y>100?36:32),an=Rt!==`none`,R=+!!an,on=ge!==void 0,cn=qe?.sticky===!0,[un,dn]=L.useState(!1),fn=ze??un,pn=L.useCallback(()=>{Ie===void 0?dn(!1):Ie()},[Ie]),z=L.useMemo(()=>Ve===void 0?void 0:Yc(Ve,R),[Ve,R])??n,mn=L.useRef();mn.current===void 0&&(mn.current=new AbortController),L.useEffect(()=>()=>mn?.current.abort(),[]);let[hn,gn]=Zs(F,b,R,mn.current,y),_n=L.useCallback((e,t,n)=>{if(ve===void 0)return!0;let r=[e[0]-R,e[1]];return ve?.(r,t,n)},[R,ve]),vn=L.useRef(Ve),yn=L.useCallback((e,t)=>{t&&(e=cc(e,hn,R,N,mn.current)),He===void 0?r(e):(vn.current=Yc(e,-R),He(vn.current))},[He,hn,R,N]),bn=Jt(ot,L.useCallback((e,t,n,r)=>{ot?.(v[n-R],t,n-R,r)},[ot,R,v])),xn=Jt(ct,L.useCallback((e,t,n,r)=>{ct?.(v[n-R],t,n-R,r)},[ct,R,v])),Sn=Jt(lt,L.useCallback((e,t,n,r)=>{lt?.(v[n-R],t,n-R,r)},[lt,R,v])),Cn=Jt(k,L.useCallback((e,t)=>k?.({...e,columnIndex:e.columnIndex-R},t)??!1,[k,R])),wn=Jt(A,L.useCallback((e,t)=>A?.({...e,col:e.col-R},t)??!1,[A,R])),Tn=L.useCallback(e=>{if(Ee!==void 0){let t=Ee(Yc(e,-R));return typeof t==`boolean`?t:Yc(t,R)}return!0},[Ee,R]),[En,Dn,On]=Xs(z,yn,Ce,we,Te,be),kn=L.useMemo(()=>xi(bi(),$t),[$t]),[An,jn]=L.useState([0,0,0]),Mn=L.useMemo(()=>{if(It===void 0)return{};let e={};for(let t of It)e[t.kind]=t;return e},[It]),Nn=L.useCallback(e=>e.kind===I.Custom?ut?.find(t=>t.isMatch(e)):Mn[e.kind],[ut,Mn]),{sizedColumns:Pn,nonGrowWidth:Fn}=ki(v,y,gn,An[0]-(R===0?0:rn)-An[2],Ut,Gt,kn,Nn,mn.current);Rt!==`none`&&(Fn+=rn);let In=L.useMemo(()=>Pn.some(e=>e.group!==void 0),[Pn]),Ln=In?Zt+Qt:Zt,Rn=z.rows.length,zn=Rt===`none`?void 0:Rn===0?!1:Rn===y||void 0,Bn=L.useMemo(()=>Rt===`none`?Pn:[{title:``,width:rn,icon:void 0,hasMenu:!1,style:`normal`,themeOverride:Vt,rowMarker:Ht,rowMarkerChecked:zn},...Pn],[Rt,Pn,rn,Vt,Ht,zn]),[Vn,Hn]=L.useMemo(()=>[tt!==void 0&&typeof Xt==`number`?Math.floor(tt/Xt):0,tt!==void 0&&typeof Xt==`number`?-(tt%Xt):0],[tt,Xt]),Un=L.useRef({height:1,width:1,x:0,y:0}),Wn=L.useMemo(()=>({x:Un.current.x,y:Vn,width:Un.current.width??1,height:Un.current.height??1,ty:Hn}),[Hn,Vn]),Gn=L.useRef(!1),[Kn,qn,Jn]=ln(Wn);Un.current=Kn;let Yn=(Kn.height??1)>1;L.useLayoutEffect(()=>{if(tt!==void 0&&u.current!==null&&Yn){if(u.current.scrollTop===tt)return;u.current.scrollTop=tt,u.current.scrollTop!==tt&&Jn(),Gn.current=!0}},[tt,Yn,Jn]);let Xn=(Kn.width??1)>1;L.useLayoutEffect(()=>{if(et!==void 0&&u.current!==null&&Xn){if(u.current.scrollLeft===et)return;u.current.scrollLeft=et,u.current.scrollLeft!==et&&Jn(),Gn.current=!0}},[et,Xn,Jn]);let Zn=Kn.x+R,Qn=Kn.y,$n=L.useRef(null),er=L.useCallback(e=>{e===!0?$n.current?.focus():window.requestAnimationFrame(()=>{$n.current?.focus()})},[]),tr=on?y+1:y,nr=L.useCallback(e=>{let t=R===0?e:e.map(e=>({...e,location:[e.location[0]-R,e.location[1]]})),n=se?.(t);if(n!==!0)for(let e of t)oe?.(e.location,e.value);return n},[oe,se,R]),[rr,ir]=L.useState(),ar=z.current!==void 0&&z.current.range.width*z.current.range.height>1?z.current.range:void 0,or=ft?z.current?.cell:void 0,sr=or?.[0],cr=or?.[1],lr=L.useMemo(()=>{if((ye===void 0||ye.length===0)&&(ar??sr??cr??rr)===void 0)return;let e=[];if(ye!==void 0)for(let t of ye){let n=Bn.length-t.range.x-R;n>0&&e.push({color:t.color,range:{...t.range,x:t.range.x+R,width:Math.min(n,t.range.width)},style:t.style})}return rr!==void 0&&e.push({color:fr(kn.accentColor,0),range:rr,style:`dashed`}),ar!==void 0&&e.push({color:fr(kn.accentColor,.5),range:ar,style:`solid-outline`}),sr!==void 0&&cr!==void 0&&e.push({color:kn.accentColor,range:{x:sr,y:cr,width:1,height:1},style:`solid-outline`}),e.length>0?e:void 0},[rr,ar,sr,cr,ye,Bn.length,kn.accentColor,R]),ur=L.useRef(Bn);ur.current=Bn;let dr=L.useCallback(([e,t],n=!1)=>{let r=on&&t===tr-1;if(e===0&&an)return r?Xc:{kind:at.Marker,allowOverlay:!1,checkboxStyle:Ht,checked:z?.rows.hasIndex(t)===!0,markerKind:Rt===`clickable-number`?`number`:Rt,row:Bt+t,drawHandle:xt!==void 0,cursor:Rt===`clickable-number`?`pointer`:void 0};if(r){let t=e===R?qe?.hint??``:``,n=ur.current[e];if(n?.trailingRowOptions?.disabled===!0)return Xc;{let e=n?.trailingRowOptions?.hint??t,r=n?.trailingRowOptions?.addIcon??qe?.addIcon;return{kind:at.NewRow,hint:e,allowOverlay:!1,icon:r}}}else{let r=e-R;if(n||pt?.strict===!0){let e=Un.current,n=e.x>r||r>e.x+e.width||e.y>t||t>e.y+e.height||t>=br.current,i=r===e.extras?.selected?.[0]&&t===e.extras?.selected[1],a=!1;if(e.extras?.freezeRegions!==void 0){for(let n of e.extras.freezeRegions)if(ba(n,r,t)){a=!0;break}}if(n&&!i&&!a)return Xc}let i=b([r,t]);return R!==0&&i.span!==void 0&&(i={...i,span:[i.span[0]+R,i.span[1]+R]}),i}},[on,tr,an,Ht,z?.rows,Rt,Bt,xt,R,qe?.hint,qe?.addIcon,pt?.strict,b]),pr=L.useCallback(e=>{let t=Fe?.(e)??{name:e};return ae!==void 0&&e!==``&&(t={icon:t.icon,name:t.name,overrideTheme:t.overrideTheme,actions:[...t.actions??[],{title:`Rename`,icon:`renameIcon`,onClick:e=>Lr({group:t.name,bounds:e.bounds})}]}),t},[Fe,ae]),mr=L.useCallback(e=>{let[t,n]=e.cell,r=Bn[t],i=r?.group===void 0?void 0:pr(r.group)?.overrideTheme,o=r?.themeOverride,s=m?.(n);a({...e,theme:xi(kn,i,o,s,e.content.themeOverride)})},[m,Bn,pr,kn]),hr=L.useCallback((e,t,n)=>{if(z.current===void 0)return;let[r,i]=z.current.cell,a=dr([r,i]);if(a.kind!==I.Boolean&&a.allowOverlay){let t=a;if(n!==void 0)switch(t.kind){case I.Number:{let e=C(()=>n===`-`?-0:Number.parseFloat(n),0);t={...t,data:Number.isNaN(e)?0:e};break}case I.Text:case I.Markdown:case I.Uri:t={...t,data:n};break}mr({target:e,content:t,initialValue:n,cell:[r,i],highlight:n===void 0,forceEditMode:n!==void 0})}else a.kind===I.Boolean&&t&&a.readonly!==!0&&(nr([{location:z.current.cell,value:{...a,data:dc(a.data)}}]),$n.current?.damage([{cell:z.current.cell}]))},[dr,z,nr,mr]),gr=L.useCallback((e,t)=>{let n=$n.current?.getBounds(e,t);if(n===void 0||u.current===null)return;let r=dr([e,t]);r.allowOverlay&&mr({target:n,content:r,initialValue:void 0,highlight:!0,cell:[e,t],forceEditMode:!0})},[dr,mr]),_r=L.useCallback((e,t,n=`both`,r=0,i=0,a=void 0)=>{if(u.current!==null){let o=$n.current,c=s.current,l=typeof e==`number`?e:e.unit===`cell`?e.amount:void 0,d=typeof t==`number`?t:t.unit===`cell`?t.amount:void 0,f=typeof e!=`number`&&e.unit===`px`?e.amount:void 0,p=typeof t!=`number`&&t.unit===`px`?t.amount:void 0;if(o!==null&&c!==null){let s={x:0,y:0,width:0,height:0},m=0,h=0;if((l!==void 0||d!==void 0)&&(s=o.getBounds((l??0)+R,d??0)??s,s.width===0||s.height===0))return;let g=c.getBoundingClientRect(),_=g.width/c.offsetWidth;if(f!==void 0&&(s={...s,x:f-g.left-u.current.scrollLeft,width:1}),p!==void 0&&(s={...s,y:p+g.top-u.current.scrollTop,height:1}),s!==void 0){let o={x:s.x-r,y:s.y-i,width:s.width+2*r,height:s.height+2*i},c=0;for(let e=0;e0&&(l=zr(tr,d,Xt));let f=c*_+g.left+R*rn*_,p=g.right,v=g.top+Ln*_,y=g.bottom-l*_,b=s.width+r*2;switch(a?.hAlign){case`start`:p=f+b;break;case`end`:f=p-b;break;case`center`:f=Math.floor((f+p)/2)-b/2,p=f+b;break}let x=s.height+i*2;switch(a?.vAlign){case`start`:y=v+x;break;case`end`:v=y-x;break;case`center`:v=Math.floor((v+y)/2)-x/2,y=v+x;break}f>o.x?m=o.x-f:po.y?h=o.y-v:y=tr-d)&&(h=0),(m!==0||h!==0)&&(_!==1&&(m/=_,h/=_),u.current.scrollTo(m+u.current.scrollLeft,h+u.current.scrollTop))}}}},[R,Je,rn,Ln,je,Pn,tr,cn,Xt]),vr=L.useRef(gr),yr=L.useRef(b),br=L.useRef(y);vr.current=gr,yr.current=b,br.current=y;let xr=L.useCallback(async(e,t=!0)=>{if(Bn[e]?.trailingRowOptions?.disabled===!0)return;let n=ge?.(),r,i=!0;n!==void 0&&(r=await n,r===`top`&&(i=!1),typeof r==`number`&&(i=!1));let a=0,o=()=>{if(br.current<=y){a<500&&window.setTimeout(o,a),a=50+a*2;return}let n=typeof r==`number`?r:i?y:0;vi.current(e-R,n),En({cell:[e,n],range:{x:e,y:n,width:1,height:1}},!1,!1,`edit`);let s=yr.current([e-R,n]);s.allowOverlay&&Qe(s)&&s.readonly!==!0&&t&&window.setTimeout(()=>{vr.current(e,n)},0)};o()},[Bn,ge,R,y,En]),Sr=L.useCallback(e=>{let t=Pn[e]?.trailingRowOptions?.targetColumn??qe?.targetColumn;if(typeof t==`number`)return t+ +!!an;if(typeof t==`object`){let e=v.indexOf(t);if(e>=0)return e+ +!!an}},[Pn,v,an,qe?.targetColumn]),Cr=L.useRef(),wr=L.useRef(),Tr=L.useCallback((e,t)=>{let[n,r]=t;return xi(kn,Bn[n]?.themeOverride,m?.(r),e.themeOverride)},[m,Bn,kn]),Er=L.useCallback(e=>{let t=_s.value?e.metaKey:e.ctrlKey,n=t&&Se===`multi`,r=t&&xe===`multi`,[i,o]=e.location,s=z.columns,c=z.rows,[l,u]=z.current?.cell??[];if(e.kind===`cell`){if(wr.current=void 0,Or.current=[i,o],i===0&&an){if(on===!0&&o===y||Rt===`number`||Se===`none`)return;let r=dr(e.location);if(r.kind!==at.Marker)return;if(xt!==void 0){let t=Nn(r);x(t?.kind===at.Marker);let n=t?.onClick?.({...e,cell:r,posX:e.localEventX,posY:e.localEventY,bounds:e.bounds,theme:Tr(r,e.location),preventDefault:()=>void 0});if(n===void 0||n.checked===r.checked)return}a(void 0),er();let i=c.hasIndex(o),s=Cr.current;if(Se===`multi`&&(e.shiftKey||e.isLongTouch===!0)&&s!==void 0&&c.hasIndex(s)){let e=[Math.min(s,o),Math.max(s,o)+1];n||Ne===`multi`?Dn(void 0,e,!0):Dn(st.fromSingleSelection(e),void 0,n)}else n||e.isTouch||Ne===`multi`?i?Dn(c.remove(o),void 0,!0):(Dn(void 0,o,!0),Cr.current=o):i&&c.length===1?Dn(st.empty(),void 0,t):(Dn(st.fromSingleSelection(o),void 0,t),Cr.current=o)}else if(i>=R&&on&&o===y){let e=Sr(i);xr(e??i)}else if(l!==i||u!==o){let n=dr(e.location),r=Nn(n);if(r?.onSelect!==void 0){let t=!1;if(r.onSelect({...e,cell:n,posX:e.localEventX,posY:e.localEventY,bounds:e.bounds,preventDefault:()=>t=!0,theme:Tr(n,e.location)}),t)return}let s=cn&&o===y,c=cn&&z!==void 0&&z.current?.cell[1]===y;if((e.shiftKey||e.isLongTouch===!0)&&l!==void 0&&u!==void 0&&z.current!==void 0&&!c){if(s)return;let e=Math.min(i,l),n=Math.max(i,l),r=Math.min(o,u),a=Math.max(o,u);En({...z.current,range:{x:e,y:r,width:n-e+1,height:a-r+1}},!0,t,`click`),Cr.current=void 0,er()}else En({cell:[i,o],range:{x:i,y:o,width:1,height:1}},!0,t,`click`),Cr.current=void 0,a(void 0),er()}}else if(e.kind===`header`)if(Or.current=[i,o],a(void 0),an&&i===0)Cr.current=void 0,wr.current=void 0,Se===`multi`&&(c.length===y?Dn(st.empty(),void 0,t):Dn(st.fromSingleSelection([0,y]),void 0,t),er());else{let n=wr.current;if(xe===`multi`&&(e.shiftKey||e.isLongTouch===!0)&&n!==void 0&&s.hasIndex(n)){let e=[Math.min(n,i),Math.max(n,i)+1];r?On(void 0,e,t):On(st.fromSingleSelection(e),void 0,t)}else r?(s.hasIndex(i)?On(s.remove(i),void 0,t):On(void 0,i,t),wr.current=i):xe!==`none`&&(On(st.fromSingleSelection(i),void 0,t),wr.current=i);Cr.current=void 0,er()}else e.kind===`group-header`?Or.current=[i,o]:e.kind===`out-of-bounds`&&!e.isMaybeScrollbar&&(yn(Zc,!1),a(void 0),er(),Re?.(),Cr.current=void 0,wr.current=void 0)},[xr,xe,er,Nn,Sr,dr,z,an,cn,Re,xt,R,Rt,Se,Ne,y,En,yn,On,Dn,on,Tr]),Dr=L.useRef(!1),Or=L.useRef(),jr=L.useRef(Kn),Pr=L.useRef(),Fr=L.useCallback(e=>{if(Br.current=!1,jr.current=Un.current,e.button!==0&&e.button!==1){Pr.current=void 0;return}let t=performance.now();Pr.current={button:e.button,time:t,location:e.location},e?.kind===`header`&&(Dr.current=!0);let n=e.kind===`cell`&&e.isFillHandle;!n&&e.kind!==`cell`&&e.isEdge||(l({previousSelection:z,fillHandle:n}),Or.current=void 0,!e.isTouch&&e.button===0&&!n?Er(e):!e.isTouch&&e.button===1&&(Or.current=e.location))},[z,Er]),[Ir,Lr]=L.useState(),Rr=L.useCallback(e=>{if(e.kind!==`group-header`||xe!==`multi`)return;let t=_s.value?e.metaKey:e.ctrlKey,[n]=e.location,r=z.columns;if(n=R&&Ar(i.group,Bn[e].group);e--)a--;for(let e=n+1;e{if(hn!==void 0&&bn!==void 0){let t=Un.current.y,n=Un.current.height,r=hn({x:e,y:t,width:1,height:Math.min(n,y-t)},mn.current.signal);typeof r!=`object`&&(r=await r());let i=Pn[e-R],a=document.createElement(`canvas`).getContext(`2d`,{alpha:!1});if(a!==null){a.font=kn.baseFontFull;let t=Oi(a,kn,i,0,r,Ut,Wt,!1,Nn);bn?.(i,t.width,e,t.width)}}},[Pn,hn,Wt,kn,Ut,bn,R,y,Nn]),[Hr,Ur]=L.useState(),Wr=L.useCallback(async(e,t)=>{let n=e.current?.range;if(n===void 0||hn===void 0||t.current===void 0)return;let r=t.current.range;if(E!==void 0){let e=!1;if(E({fillDestination:{...r,x:r.x-R},patternSource:{...n,x:n.x-R},preventDefault:()=>e=!0}),e)return}let i=hn(n,mn.current.signal);typeof i!=`object`&&(i=await i());let a=i,o=[];for(let e=0;e({cell:e.location})))},[hn,nr,E,R]),Gr=L.useCallback(()=>{if(z.current===void 0||z.current.range.width<=1)return;let e={...z,current:{...z.current,range:{...z.current.range,width:1}}};Wr(e,z)},[Wr,z]),Kr=L.useCallback(()=>{if(z.current===void 0||z.current.range.height<=1)return;let e={...z,current:{...z.current,range:{...z.current.range,height:1}}};Wr(e,z)},[Wr,z]),qr=L.useCallback((e,t)=>{let n=c;if(l(void 0),ir(void 0),Ur(void 0),Dr.current=!1,t)return;if(n?.fillHandle===!0&&z.current!==void 0&&n.previousSelection?.current!==void 0){if(rr===void 0)return;let e={...z,current:{...z.current,range:xa(n.previousSelection.current.range,rr)}};Wr(n.previousSelection,e),yn(e,!0);return}let[r,i]=e.location,[a,o]=Or.current??[],s=()=>{Br.current=!0},u=t=>{let c=t.isTouch||a===r&&o===i;if(c&&w?.([r-R,i],{...t,preventDefault:s}),t.button===1)return!Br.current;if(!Br.current){let a=dr(e.location),o=Nn(a);if(o!==void 0&&o.onClick!==void 0&&c){let n=o.onClick({...t,cell:a,posX:t.localEventX,posY:t.localEventY,bounds:t.bounds,theme:Tr(a,e.location),preventDefault:s});n!==void 0&&!Ze(n)&&Xe(n)&&(nr([{location:t.location,value:n}]),$n.current?.damage([{cell:t.location}]))}if(Br.current||z.current===void 0)return!1;let l=!1;switch(a.activationBehaviorOverride??Me){case`double-click`:case`second-click`:{if(n?.previousSelection?.current?.cell===void 0)break;let[e,a]=z.current.cell,[o,s]=n.previousSelection.current.cell;l=r===e&&r===o&&i===a&&i===s&&(t.isDoubleClick===!0||Me===`second-click`);break}case`single-click`:l=!0;break}if(l)return T?.([r-R,i]),hr(t.bounds,!1),!0}return!1},d=e.location[0]-R;if(e.isTouch){let t=Un.current,n=jr.current;if(t.x!==n.x||t.y!==n.y)return;if(e.isLongTouch===!0){if(e.kind===`cell`&&Nr(z.current?.cell,e.location)){ne?.([d,e.location[1]],{...e,preventDefault:s});return}else if(e.kind===`header`&&z.columns.hasIndex(r)){re?.(d,{...e,preventDefault:s});return}else if(e.kind===`group-header`){if(d<0)return;ie?.(d,{...e,preventDefault:s});return}}e.kind===`cell`?u(e)||Er(e):e.kind===`group-header`?te?.(d,{...e,preventDefault:s}):(e.kind===`header`&&M?.(d,{...e,preventDefault:s}),Er(e));return}if(e.kind===`header`){if(d<0)return;e.isEdge?e.isDoubleClick===!0&&Vr(r):e.button===0&&r===a&&i===o&&M?.(d,{...e,preventDefault:s})}if(e.kind===`group-header`){if(d<0)return;e.button===0&&r===a&&i===o&&(te?.(d,{...e,preventDefault:s}),Br.current||Rr(e))}e.kind===`cell`&&(e.button===0||e.button===1)&&u(e),Or.current=void 0},[c,z,R,rr,Wr,yn,w,dr,Nn,Me,Tr,nr,T,hr,ne,re,ie,Er,te,M,Vr,Rr]),Jr=L.useCallback(e=>{let t={...e,location:[e.location[0]-R,e.location[1]]};Oe?.(t),c!==void 0&&e.buttons===0&&(l(void 0),ir(void 0),Ur(void 0),Dr.current=!1),Ur(t=>Dr.current?[e.scrollEdge[0],0]:e.scrollEdge[0]===t?.[0]&&e.scrollEdge[1]===t[1]?t:c===void 0||(Pr.current?.location[0]??0){Pe?.(e-R,t)},[Pe,R]),Xr=z?.current?.cell,Zr=L.useCallback((e,t,n,r,i,a)=>{Gn.current=!1;let o=Xr;o!==void 0&&(o=[o[0]-R,o[1]]);let s=je===0?void 0:{x:0,y:e.y,width:je,height:e.height},c=[];s!==void 0&&c.push(s),Je>0&&(c.push({x:e.x-R,y:y-Je,width:e.width,height:Je}),je>0&&c.push({x:0,y:y-Je,width:je,height:Je}));let l={x:e.x-R,y:e.y,width:e.width,height:on&&e.y+e.height>=y?e.height-1:e.height,tx:i,ty:a,extras:{selected:o,freezeRegion:s,freezeRegions:c}};Un.current=l,qn(l),jn([t,n,r]),Be?.(l,l.tx,l.ty,l.extras)},[Xr,R,on,y,je,Je,qn,Be]),Qr=Jt(_e,L.useCallback((e,t)=>{_e?.(e-R,t-R),xe!==`none`&&On(st.fromSingleSelection(t),void 0,!0)},[xe,_e,R,On])),$r=L.useRef(!1),ei=L.useCallback(e=>{if(e.location[0]===0&&R>0){e.preventDefault();return}De?.({...e,location:[e.location[0]-R,e.location[1]]}),e.defaultPrevented()||($r.current=!0),l(void 0)},[De,R]),ti=L.useCallback(()=>{$r.current=!1},[]),ni=L.useRef(),ri=L.useCallback(e=>{if(!Cs(e,ni.current)&&(ni.current=e,!(Pr?.current?.button!==void 0&&Pr.current.button>=1))){if(e.buttons!==0&&c!==void 0&&Pr.current?.location[0]===0&&e.location[0]===0&&R===1&&Se===`multi`&&c.previousSelection&&!c.previousSelection.rows.hasIndex(Pr.current.location[1])&&z.rows.hasIndex(Pr.current.location[1])){let t=Math.min(Pr.current.location[1],e.location[1]),n=Math.max(Pr.current.location[1],e.location[1])+1;Dn(st.fromSingleSelection([t,n]),void 0,!1)}if(e.buttons!==0&&c!==void 0&&z.current!==void 0&&!$r.current&&!Dr.current&&(be===`rect`||be===`multi-rect`)){let[t,n]=z.current.cell,[r,i]=e.location;if(i<0&&(i=Un.current.y),c.fillHandle===!0&&c.previousSelection?.current!==void 0){let e=c.previousSelection.current.range;i=Math.min(i,on?y-1:y);let t=va(e,r,i,Ye);ir(t)}else{if(on&&n===y)return;if(on&&i===y)if(e.kind===`out-of-bounds`)i--;else return;r=Math.max(r,R);let a=r-t,o=i-n,s={x:a>=0?t:r,y:o>=0?n:i,width:Math.abs(a)+1,height:Math.abs(o)+1};En({...z.current,range:s},!0,!1,`drag`)}}Le?.({...e,location:[e.location[0]-R,e.location[1]]})}},[Ye,c,R,Se,z,be,Le,Dn,on,y,En]);_c(Hr,u,L.useCallback(()=>{let e=ni.current;if(e===void 0)return;let[t,n]=e.scrollEdge,[r,i]=e.location,a=Un.current;t===-1?r=a.extras?.freezeRegion?.x??a.x:t===1&&(r=a.x+a.width),n===-1?i=Math.max(0,a.y):n===1&&(i=Math.min(y-1,a.y+a.height)),r=(0,ls.default)(r,0,Bn.length-1),i=(0,ls.default)(i,0,y-1),ri({...e,location:[r,i]})},[Bn.length,ri,y]));let ii=L.useCallback(e=>{if(z.current===void 0)return;let[t,n]=e,[r,i]=z.current.cell,a=z.current.range,o=a.x,s=a.x+a.width,c=a.y,l=a.y+a.height;if(n!==0)switch(n){case 2:l=y,c=i,_r(0,l,`vertical`);break;case-2:c=0,l=i+1,_r(0,c,`vertical`);break;case 1:ci+1?(l--,_r(0,l,`vertical`)):(c=Math.max(0,c-1),_r(0,c,`vertical`));break;default:S(n)}if(t!==0)if(t===2)s=Bn.length,o=r,_r(s-1-R,0,`horizontal`);else if(t===-2)o=R,s=r+1,_r(o-R,0,`horizontal`);else{let e=[];if(hn!==void 0){let t=hn({x:o,y:c,width:s-o-R,height:l-c},mn.current.signal);typeof t==`object`&&(e=Jc(t))}if(t===1){let t=!1;if(o0){let n=(0,ws.default)(o+1,r+1).find(t=>!e.includes(t-R));n!==void 0&&(o=n,t=!0)}else o++,t=!0;t&&_r(o,0,`horizontal`)}t||(s=Math.min(Bn.length,s+1),_r(s-1-R,0,`horizontal`))}else if(t===-1){let t=!1;if(s>r+1){if(e.length>0){let n=(0,ws.default)(s-1,r,-1).find(t=>!e.includes(t-R));n!==void 0&&(s=n,t=!0)}else s--,t=!0;t&&_r(s-R,0,`horizontal`)}t||(o=Math.max(R,o-1),_r(o-R,0,`horizontal`))}else S(t)}En({cell:z.current.cell,range:{x:o,y:c,width:s-o,height:l-c}},!0,!1,`keyboard-select`)},[hn,z,Bn.length,R,y,_r,En]),ai=L.useCallback((e,t,n,r)=>{let i=tr-+!n;if(e=(0,ls.default)(e,R,Pn.length-1+R),t=(0,ls.default)(t,0,i),e===Xr?.[0]&&t===Xr?.[1])return!1;if(r&&z.current!==void 0){let n=[...z.current.rangeStack];(z.current.range.width>1||z.current.range.height>1)&&n.push(z.current.range),yn({...z,current:{cell:[e,t],range:{x:e,y:t,width:1,height:1},rangeStack:n}},!0)}else En({cell:[e,t],range:{x:e,y:t,width:1,height:1}},!0,!1,`keyboard-nav`);return d.current!==void 0&&d.current[0]===e&&d.current[1]===t&&(d.current=void 0),_r(e-R,t),!0},[tr,R,Pn.length,Xr,z,_r,yn,En]),oi=L.useCallback((e,t)=>{i?.cell!==void 0&&e!==void 0&&Xe(e)&&(nr([{location:i.cell,value:e}]),window.requestAnimationFrame(()=>{$n.current?.damage([{cell:i.cell}])})),er(!0),a(void 0);let[n,r]=t;if(z.current!==void 0&&(n!==0||r!==0)){let t=z.current.cell[1]===tr-1&&e!==void 0;ai((0,ls.default)(z.current.cell[0]+n,0,Bn.length-1),(0,ls.default)(z.current.cell[1]+r,0,tr-1),t,!1)}D?.(e,t)},[i?.cell,er,z,D,nr,tr,ai,Bn.length]),si=L.useMemo(()=>`gdg-overlay-${qc++}`,[]),ci=L.useCallback(e=>{er();let t=[];for(let n=e.x;n({cell:e.location})))},[er,b,Nn,nr,R]),li=i!==void 0,ui=L.useCallback(e=>{let t=()=>{e.stopPropagation(),e.preventDefault()},n={didMatch:!1},{bounds:r}=e,i=z.columns,s=z.rows,c=nn;if(!li&&Js(c.clear,e,n))yn(Zc,!1),Re?.();else if(!li&&Js(c.selectAll,e,n))yn({columns:st.empty(),rows:st.empty(),current:{cell:z.current?.cell??[R,0],range:{x:R,y:0,width:v.length,height:y},rangeStack:[]}},!1);else if(Js(c.search,e,n))o?.current?.focus({preventScroll:!0}),dn(!0);else if(Js(c.delete,e,n)){let e=Tn?.(z)??!0;if(e!==!1){let t=e===!0?z:e;if(t.current!==void 0){ci(t.current.range);for(let e of t.current.rangeStack)ci(e)}for(let e of t.rows)ci({x:R,y:e,width:v.length,height:1});for(let e of t.columns)ci({x:e,y:0,width:1,height:y})}}if(n.didMatch)return t(),!0;if(z.current===void 0)return!1;let[l,u]=z.current.cell,d=!1,f=!1;Js(c.scrollToSelectedCell,e,n)?vi.current(l-R,u):xe!==`none`&&Js(c.selectColumn,e,n)?i.hasIndex(l)?On(i.remove(l),void 0,!0):xe===`single`?On(st.fromSingleSelection(l),void 0,!0):On(void 0,l,!0):Se!==`none`&&Js(c.selectRow,e,n)?s.hasIndex(u)?Dn(s.remove(u),void 0,!0):Se===`single`?Dn(st.fromSingleSelection(u),void 0,!0):Dn(void 0,u,!0):!li&&r!==void 0&&Js(c.activateCell,e,n)?u===y&&on?window.setTimeout(()=>{let e=Sr(l);xr(e??l)},0):(T?.([l-R,u]),hr(r,!0)):z.current.range.height>1&&Js(c.downFill,e,n)?Kr():z.current.range.width>1&&Js(c.rightFill,e,n)?Gr():Js(c.goToNextPage,e,n)?u+=Math.max(1,Un.current.height-4):Js(c.goToPreviousPage,e,n)?u-=Math.max(1,Un.current.height-4):Js(c.goToFirstCell,e,n)?(a(void 0),u=0,l=0):Js(c.goToLastCell,e,n)?(a(void 0),u=2**53-1,l=2**53-1):Js(c.selectToFirstCell,e,n)?(a(void 0),ii([-2,-2])):Js(c.selectToLastCell,e,n)?(a(void 0),ii([2,2])):li?(Js(c.closeOverlay,e,n)&&a(void 0),Js(c.acceptOverlayDown,e,n)&&(a(void 0),u++),Js(c.acceptOverlayUp,e,n)&&(a(void 0),u--),Js(c.acceptOverlayLeft,e,n)&&(a(void 0),l--),Js(c.acceptOverlayRight,e,n)&&(a(void 0),l++)):(Js(c.goDownCell,e,n)?u+=1:Js(c.goUpCell,e,n)?--u:Js(c.goRightCell,e,n)?l+=1:Js(c.goLeftCell,e,n)?--l:Js(c.goDownCellRetainSelection,e,n)?(u+=1,d=!0):Js(c.goUpCellRetainSelection,e,n)?(--u,d=!0):Js(c.goRightCellRetainSelection,e,n)?(l+=1,d=!0):Js(c.goLeftCellRetainSelection,e,n)?(--l,d=!0):Js(c.goToLastRow,e,n)?u=y-1:Js(c.goToFirstRow,e,n)?u=-(2**53-1):Js(c.goToLastColumn,e,n)?l=2**53-1:Js(c.goToFirstColumn,e,n)?l=-(2**53-1):(be===`rect`||be===`multi-rect`)&&(Js(c.selectGrowDown,e,n)?ii([0,1]):Js(c.selectGrowUp,e,n)?ii([0,-1]):Js(c.selectGrowRight,e,n)?ii([1,0]):Js(c.selectGrowLeft,e,n)?ii([-1,0]):Js(c.selectToLastRow,e,n)?ii([0,2]):Js(c.selectToFirstRow,e,n)?ii([0,-2]):Js(c.selectToLastColumn,e,n)?ii([2,0]):Js(c.selectToFirstColumn,e,n)&&ii([-2,0])),f=n.didMatch);let p=ai(l,u,!1,d),m=n.didMatch;return m&&(p||!f||Dt)&&t(),m},[li,z,nn,xe,Se,be,R,y,ai,yn,Re,v.length,Tn,Dt,ci,On,Dn,on,Sr,xr,T,hr,Kr,Gr,ii]),di=L.useCallback(e=>{let t=!1;if(fe!==void 0&&fe({...e,cancel:()=>{t=!0}}),t||ui(e)||z.current===void 0)return;let[n,r]=z.current.cell,i=Un.current;if(he&&!e.metaKey&&!e.ctrlKey&&z.current!==void 0&&e.key.length===1&&/[ -~]/g.test(e.key)&&e.bounds!==void 0&&Qe(b([n-R,Math.max(0,Math.min(r,y-1))]))){if((!on||r!==y)&&(i.y>r||r>i.y+i.height||i.x>n||n>i.x+i.width))return;hr(e.bounds,!0,e.key),e.stopPropagation(),e.preventDefault()}},[he,fe,ui,z,b,R,y,on,hr]),fi=L.useCallback((e,t)=>{let n=e.location[0]-R;if(e.kind===`header`&&re?.(n,{...e,preventDefault:t}),e.kind===`group-header`){if(n<0)return;ie?.(n,{...e,preventDefault:t})}if(e.kind===`cell`){let[r,i]=e.location;ne?.([n,i],{...e,preventDefault:t}),kr(z,e.location)||ai(r,i,!1,!1)}},[z,ne,ie,re,R,ai]),pi=L.useCallback(async e=>{if(!nn.paste)return;function t(e,t,n,r){let i=typeof n==`object`?n?.join(` +`&&(n.push(r),r=[]),a=t.None):a=t.None;break}o++}return ie.map(e=>({rawValue:e,formatted:e,format:`string`})))}function nee(e,t,n){let r=oc(e,t),i=e=>{window.navigator.clipboard?.writeText(e)},a=(e,t)=>window.navigator.clipboard?.write===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([e],{type:`text/plain`}),"text/html":new Blob([t],{type:`text/html`})})]),!0);window.navigator.clipboard?.write!==void 0||n?.clipboardData!==void 0?((e,t)=>{try{if(n===void 0||n.clipboardData===null)throw Error(`No clipboard data`);n?.clipboardData?.setData(`text/plain`,e),n?.clipboardData?.setData(`text/html`,t)}catch{a(e,t)||i(e)}})(r.textPlain,r.textHtml):i(r.textPlain),n?.preventDefault()}function dc(e){return e!==!0}St();function fc(e){return typeof e==`string`?e:`${e}px`}var pc=xt(`div`)({name:`Wrapper`,class:`gdg-wmyidgi`,propsAsIs:!1,vars:{"wmyidgi-0":[e=>e.innerWidth],"wmyidgi-1":[e=>e.innerHeight]}}),mc=e=>{let{inWidth:t,inHeight:n,children:r,...i}=e;return L.createElement(pc,{innerHeight:fc(n),innerWidth:fc(t),...i},r)},hc=2,gc=1300;function _c(e,t,n){let r=L.useRef(0),[i,a]=e??[0,0];L.useEffect(()=>{if(i===0&&a===0){r.current=0;return}let e=!1,o=0,s=c=>{if(!e){if(o===0)o=c;else{let e=c-o;r.current=Math.min(1,r.current+e/gc);let s=r.current**1.618*e*hc;t.current?.scrollBy(i*s,a*s),o=c,n?.()}window.requestAnimationFrame(s)}};return window.requestAnimationFrame(s),()=>{e=!0}},[t,i,a,n])}Ti();function vc({rowHeight:e,headerHeight:t,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:a,scaleToRem:o,remSize:s}){let[c,l,u,d,f,p]=L.useMemo(()=>{if(!o||s===16)return[e,t,n,r,i,a];let c=s/16,l=e,u=bi();return[typeof l==`number`?l*c:e=>Math.ceil(l(e)*c),Math.ceil(t*c),Math.ceil(n*c),{...r,headerIconSize:(r?.headerIconSize??u.headerIconSize)*c,cellHorizontalPadding:(r?.cellHorizontalPadding??u.cellHorizontalPadding)*c,cellVerticalPadding:(r?.cellVerticalPadding??u.cellVerticalPadding)*c},Math.ceil((i??0)*c),Math.ceil((a??0)*c)]},[n,t,i,a,s,e,o,r]);return{rowHeight:c,headerHeight:l,groupHeaderHeight:u,theme:d,overscrollX:f,overscrollY:p}}var yc={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function bc(e,t){return e===!0?t:e===!1?``:e}function xc(e){let t=vs.value;return{activateCell:bc(e.activateCell,` |Enter|shift+Enter`),clear:bc(e.clear,`any+Escape`),closeOverlay:bc(e.closeOverlay,`any+Escape`),acceptOverlayDown:bc(e.acceptOverlayDown,`Enter`),acceptOverlayUp:bc(e.acceptOverlayUp,`shift+Enter`),acceptOverlayLeft:bc(e.acceptOverlayLeft,`shift+Tab`),acceptOverlayRight:bc(e.acceptOverlayRight,`Tab`),copy:e.copy,cut:e.cut,delete:bc(e.delete,t?`Backspace|Delete`:`Delete`),downFill:bc(e.downFill,`primary+_68`),scrollToSelectedCell:bc(e.scrollToSelectedCell,`primary+Enter`),goDownCell:bc(e.goDownCell,`ArrowDown`),goDownCellRetainSelection:bc(e.goDownCellRetainSelection,`alt+ArrowDown`),goLeftCell:bc(e.goLeftCell,`ArrowLeft|shift+Tab`),goLeftCellRetainSelection:bc(e.goLeftCellRetainSelection,`alt+ArrowLeft`),goRightCell:bc(e.goRightCell,`ArrowRight|Tab`),goRightCellRetainSelection:bc(e.goRightCellRetainSelection,`alt+ArrowRight`),goUpCell:bc(e.goUpCell,`ArrowUp`),goUpCellRetainSelection:bc(e.goUpCellRetainSelection,`alt+ArrowUp`),goToFirstCell:bc(e.goToFirstCell,`primary+Home`),goToFirstColumn:bc(e.goToFirstColumn,`Home|primary+ArrowLeft`),goToFirstRow:bc(e.goToFirstRow,`primary+ArrowUp`),goToLastCell:bc(e.goToLastCell,`primary+End`),goToLastColumn:bc(e.goToLastColumn,`End|primary+ArrowRight`),goToLastRow:bc(e.goToLastRow,`primary+ArrowDown`),goToNextPage:bc(e.goToNextPage,`PageDown`),goToPreviousPage:bc(e.goToPreviousPage,`PageUp`),paste:e.paste,rightFill:bc(e.rightFill,`primary+_82`),search:bc(e.search,`primary+f`),selectAll:bc(e.selectAll,`primary+a`),selectColumn:bc(e.selectColumn,`ctrl+ `),selectGrowDown:bc(e.selectGrowDown,`shift+ArrowDown`),selectGrowLeft:bc(e.selectGrowLeft,`shift+ArrowLeft`),selectGrowRight:bc(e.selectGrowRight,`shift+ArrowRight`),selectGrowUp:bc(e.selectGrowUp,`shift+ArrowUp`),selectRow:bc(e.selectRow,`shift+ `),selectToFirstCell:bc(e.selectToFirstCell,`primary+shift+Home`),selectToFirstColumn:bc(e.selectToFirstColumn,`primary+shift+ArrowLeft`),selectToFirstRow:bc(e.selectToFirstRow,`primary+shift+ArrowUp`),selectToLastCell:bc(e.selectToLastCell,`primary+shift+End`),selectToLastColumn:bc(e.selectToLastColumn,`primary+shift+ArrowRight`),selectToLastRow:bc(e.selectToLastRow,`primary+shift+ArrowDown`)}}function Sc(e){let t=dn(e);return L.useMemo(()=>{if(t===void 0)return xc(yc);let e={...t,goToNextPage:t?.goToNextPage??t?.pageDown??yc.goToNextPage,goToPreviousPage:t?.goToPreviousPage??t?.pageUp??yc.goToPreviousPage,goToFirstCell:t?.goToFirstCell??t?.first??yc.goToFirstCell,goToLastCell:t?.goToLastCell??t?.last??yc.goToLastCell,selectToFirstCell:t?.selectToFirstCell??t?.first??yc.selectToFirstCell,selectToLastCell:t?.selectToLastCell??t?.last??yc.selectToLastCell};return xc({...yc,...e})},[t])}var Cc=g(),wc=`modulepreload`,Tc=function(e,t){return new URL(e,t).href},Ec={},Dc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Tc(t,n),t=s(t),t in Ec)return;Ec[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:wc,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Oc,kc,Ac,jc,Mc,Nc,Pc,Fc=o((()=>{St(),Oc=()=>e=>e.targetX,kc=()=>e=>e.targetY,Ac=()=>e=>e.targetWidth,jc=()=>e=>e.targetHeight,Mc=()=>e=>e.targetY+10,Nc=()=>e=>Math.max(0,(e.targetHeight-28)/2),Pc=xt(`div`)({name:`DataGridOverlayEditorStyle`,class:`gdg-d19meir1`,propsAsIs:!1,vars:{"d19meir1-0":[kc(),`px`],"d19meir1-1":[Oc(),`px`],"d19meir1-2":[Ac(),`px`],"d19meir1-3":[jc(),`px`],"d19meir1-4":[Mc(),`px`],"d19meir1-5":[Nc(),`px`]}})}));function Ic(){let[e,t]=Rc.useState();return[e??void 0,t]}function Lc(){let[e,t]=Ic(),[n,r]=Rc.useState(0),[i,a]=Rc.useState(!0);return Rc.useLayoutEffect(()=>{if(e===void 0||!(`IntersectionObserver`in window))return;let t=new IntersectionObserver(e=>{e.length!==0&&a(e[0].isIntersecting)},{threshold:1});return t.observe(e),()=>t.disconnect()},[e]),Rc.useEffect(()=>{if(i||e===void 0)return;let t,n=()=>{let{right:i}=e.getBoundingClientRect();r(e=>Math.min(e+window.innerWidth-i-10,0)),t=requestAnimationFrame(n)};return t=requestAnimationFrame(n),()=>{t!==void 0&&cancelAnimationFrame(t)}},[e,i]),{ref:t,style:Rc.useMemo(()=>({transform:`translateX(${n}px)`}),[n])}}var Rc,zc=o((()=>{Rc=u(f(),1)})),Bc=c({default:()=>Hc}),Vc,Hc,Uc=o((()=>{Vc=u(f(),1),Gs(),Ti(),ct(),Fc(),zc(),Hc=e=>{let{target:t,content:n,onFinishEditing:r,forceEditMode:i,initialValue:a,imageEditorOverride:o,markdownDivCreateNode:s,highlight:c,className:l,theme:u,id:d,cell:f,bloom:p,validateCell:m,getCellRenderer:h,provideEditor:g,isOutsideClick:_}=e,[v,y]=Vc.useState(i?n:void 0),b=Vc.useRef(v??n);b.current=v??n;let[x,S]=Vc.useState(()=>m===void 0||!(Xe(n)&&m?.(f,n,b.current)===!1)),C=Vc.useCallback((e,t)=>{r(x?e:void 0,t)},[x,r]),w=Vc.useCallback(e=>{if(m!==void 0&&e!==void 0&&Xe(e)){let t=m(f,e,b.current);t===!1?S(!1):(typeof t==`object`&&(e=t),S(!0))}y(e)},[f,m]),T=Vc.useRef(!1),E=Vc.useRef(void 0),D=Vc.useCallback(()=>{C(v,[0,0]),T.current=!0},[v,C]),O=Vc.useCallback((e,t)=>{C(e,t??E.current??[0,0]),T.current=!0},[C]),k=Vc.useCallback(async e=>{let t=!1;e.key===`Escape`?(e.stopPropagation(),e.preventDefault(),E.current=[0,0]):e.key===`Enter`&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),E.current=[0,1],t=!0):e.key===`Tab`&&(e.stopPropagation(),e.preventDefault(),E.current=[e.shiftKey?-1:1,0],t=!0),window.setTimeout(()=>{!T.current&&E.current!==void 0&&(C(t?v:void 0,E.current),T.current=!0)},0)},[C,v]),A=v??n,[j,M]=Vc.useMemo(()=>{if(Ze(n))return[];let e=g?.(n);return e===void 0?[h(n)?.provideEditor?.(n),!1]:[e,!1]},[n,h,g]),{ref:ee,style:N}=Lc(),te=!0,ne,P=!0,re;if(j!==void 0){te=j.disablePadding!==!0,P=j.disableStyling!==!0;let e=$e(j);e&&(re=j.styleOverride);let n=e?j.editor:j;ne=Vc.createElement(n,{isHighlighted:c,onChange:w,value:A,initialValue:a,onFinishedEditing:O,validatedSelection:Xe(A)?A.selectionRange:void 0,forceEditMode:i,target:t,imageEditorOverride:o,markdownDivCreateNode:s,isValid:x,theme:u})}re={...re,...N};let F=document.getElementById(`portal`);if(F===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let ie=P?`gdg-style`:`gdg-unstyle`;x||(ie+=` gdg-invalid`),te&&(ie+=` gdg-pad`);let ae=p?.[0]??1,oe=p?.[1]??1;return(0,Cc.createPortal)(Vc.createElement(wi.Provider,{value:u},Vc.createElement(Ws,{style:yi(u),className:l,onClickOutside:D,isOutsideClick:_},Vc.createElement(Pc,{ref:ee,id:d,className:ie,style:re,as:M===!0?`label`:void 0,targetX:t.x-ae,targetY:t.y-oe,targetWidth:t.width+ae*2,targetHeight:t.height+oe*2},Vc.createElement(`div`,{className:`gdg-clip-region`,onKeyDown:k},ne)))),F)}}));E();var Wc=u(qi(),1),Gc=u(Zi(),1);ct(),Ti(),vr();var Kc=L.lazy(async()=>await Dc(()=>Promise.resolve().then(()=>(Uc(),Bc)),void 0,import.meta.url)),qc=0;function Jc(e){return(0,Wc.default)((0,Gc.default)((0,Gc.default)(e).filter(e=>e.span!==void 0).map(e=>(0,Ts.default)((e.span?.[0]??0)+1,(e.span?.[1]??0)+1))))}function Yc(e,t){return e===void 0||t===0||e.columns.length===0&&e.current===void 0?e:{current:e.current===void 0?void 0:{cell:[e.current.cell[0]+t,e.current.cell[1]],range:{...e.current.range,x:e.current.range.x+t},rangeStack:e.current.rangeStack.map(e=>({...e,x:e.x+t}))},rows:e.rows,columns:e.columns.offset(t)}}var Xc={kind:I.Loading,allowOverlay:!1},Zc={columns:st.empty(),rows:st.empty(),current:void 0},Qc=L.forwardRef((e,t)=>{let[n,r]=L.useState(Zc),[i,a]=L.useState(),o=L.useRef(null),s=L.useRef(null),[c,l]=L.useState(),u=L.useRef(null),d=L.useRef(),f=typeof window>`u`?null:window,{imageEditorOverride:p,getRowThemeOverride:m,markdownDivCreateNode:h,width:g,height:_,columns:v,rows:y,getCellContent:b,onCellClicked:w,onCellActivated:T,onFillPattern:E,onFinishedEditing:D,coercePasteValue:O,drawHeader:k,drawCell:A,editorBloom:j,onHeaderClicked:M,onColumnProposeMove:ee,spanRangeBehavior:N=`default`,onGroupHeaderClicked:te,onCellContextMenu:ne,className:P,onHeaderContextMenu:re,getCellsForSelection:F,onGroupHeaderContextMenu:ie,onGroupHeaderRenamed:ae,onCellEdited:oe,onCellsEdited:se,onSearchResultsChanged:ce,searchResults:le,onSearchValueChange:ue,searchValue:de,onKeyDown:fe,onKeyUp:pe,keybindings:me,editOnType:he=!0,onRowAppended:ge,onColumnMoved:_e,validateCell:ve,highlightRegions:ye,rangeSelect:be=`rect`,columnSelect:xe=`multi`,rowSelect:Se=`multi`,rangeSelectionBlending:Ce=`exclusive`,columnSelectionBlending:we=`exclusive`,rowSelectionBlending:Te=`exclusive`,onDelete:Ee,onDragStart:De,onMouseMove:Oe,onPaste:ke,copyHeaders:Ae=!1,freezeColumns:je=0,cellActivationBehavior:Me=`second-click`,rowSelectionMode:Ne=`auto`,onHeaderMenuClick:Pe,getGroupDetails:Fe,onSearchClose:Ie,onItemHovered:Le,onSelectionCleared:Re,showSearch:ze,onVisibleRegionChanged:Be,gridSelection:Ve,onGridSelectionChange:He,minColumnWidth:Ue=50,maxColumnWidth:We=500,maxColumnAutoWidth:Ge,provideEditor:Ke,trailingRowOptions:qe,freezeTrailingRows:Je=0,allowedFillDirections:Ye=`orthogonal`,scrollOffsetX:et,scrollOffsetY:tt,verticalBorder:nt,onDragOverCell:rt,onDrop:it,onColumnResize:ot,onColumnResizeEnd:ct,onColumnResizeStart:lt,customRenderers:ut,fillHandle:dt,drawFocusRing:ft=!0,experimental:pt,fixedShadowX:mt,fixedShadowY:ht,headerIcons:gt,imageWindowLoader:_t,initialSize:vt,isDraggable:yt,onDragLeave:bt,onRowMoved:xt,overscrollX:St,overscrollY:Ct,preventDiagonalScrolling:wt,rightElement:Tt,rightElementProps:Et,trapFocus:Dt=!1,smoothScrollX:Ot,smoothScrollY:kt,scaleToRem:At=!1,rowHeight:jt=34,headerHeight:Mt=36,groupHeaderHeight:Nt=Mt,theme:Pt,isOutsideClick:Ft,renderers:It}=e,Lt=typeof e.rowMarkers==`string`?void 0:e.rowMarkers,Rt=Lt?.kind??e.rowMarkers??`none`,zt=Lt?.width??e.rowMarkerWidth,Bt=Lt?.startIndex??e.rowMarkerStartIndex??1,Vt=Lt?.theme??e.rowMarkerTheme,Ht=Lt?.checkboxStyle??`square`,Ut=Math.max(Ue,20),Wt=Math.max(We,Ut),Gt=Math.max(Ge??Wt,Ut),Yt=L.useMemo(()=>typeof window>`u`?{fontSize:`16px`}:window.getComputedStyle(document.documentElement),[]),{rowHeight:Xt,headerHeight:Zt,groupHeaderHeight:Qt,theme:$t,overscrollX:en,overscrollY:tn}=vc({groupHeaderHeight:Nt,headerHeight:Mt,overscrollX:St,overscrollY:Ct,remSize:L.useMemo(()=>Number.parseFloat(Yt.fontSize),[Yt]),rowHeight:jt,scaleToRem:At,theme:Pt}),nn=Sc(me),rn=zt??(y>1e4?48:y>1e3?44:y>100?36:32),an=Rt!==`none`,R=+!!an,on=ge!==void 0,cn=qe?.sticky===!0,[un,dn]=L.useState(!1),fn=ze??un,pn=L.useCallback(()=>{Ie===void 0?dn(!1):Ie()},[Ie]),z=L.useMemo(()=>Ve===void 0?void 0:Yc(Ve,R),[Ve,R])??n,mn=L.useRef();mn.current===void 0&&(mn.current=new AbortController),L.useEffect(()=>()=>mn?.current.abort(),[]);let[hn,gn]=Qs(F,b,R,mn.current,y),_n=L.useCallback((e,t,n)=>{if(ve===void 0)return!0;let r=[e[0]-R,e[1]];return ve?.(r,t,n)},[R,ve]),vn=L.useRef(Ve),yn=L.useCallback((e,t)=>{t&&(e=cc(e,hn,R,N,mn.current)),He===void 0?r(e):(vn.current=Yc(e,-R),He(vn.current))},[He,hn,R,N]),bn=Jt(ot,L.useCallback((e,t,n,r)=>{ot?.(v[n-R],t,n-R,r)},[ot,R,v])),xn=Jt(ct,L.useCallback((e,t,n,r)=>{ct?.(v[n-R],t,n-R,r)},[ct,R,v])),Sn=Jt(lt,L.useCallback((e,t,n,r)=>{lt?.(v[n-R],t,n-R,r)},[lt,R,v])),Cn=Jt(k,L.useCallback((e,t)=>k?.({...e,columnIndex:e.columnIndex-R},t)??!1,[k,R])),wn=Jt(A,L.useCallback((e,t)=>A?.({...e,col:e.col-R},t)??!1,[A,R])),Tn=L.useCallback(e=>{if(Ee!==void 0){let t=Ee(Yc(e,-R));return typeof t==`boolean`?t:Yc(t,R)}return!0},[Ee,R]),[En,Dn,On]=Zs(z,yn,Ce,we,Te,be),kn=L.useMemo(()=>xi(bi(),$t),[$t]),[An,jn]=L.useState([0,0,0]),Mn=L.useMemo(()=>{if(It===void 0)return{};let e={};for(let t of It)e[t.kind]=t;return e},[It]),Nn=L.useCallback(e=>e.kind===I.Custom?ut?.find(t=>t.isMatch(e)):Mn[e.kind],[ut,Mn]),{sizedColumns:Pn,nonGrowWidth:Fn}=ki(v,y,gn,An[0]-(R===0?0:rn)-An[2],Ut,Gt,kn,Nn,mn.current);Rt!==`none`&&(Fn+=rn);let In=L.useMemo(()=>Pn.some(e=>e.group!==void 0),[Pn]),Ln=In?Zt+Qt:Zt,Rn=z.rows.length,zn=Rt===`none`?void 0:Rn===0?!1:Rn===y||void 0,Bn=L.useMemo(()=>Rt===`none`?Pn:[{title:``,width:rn,icon:void 0,hasMenu:!1,style:`normal`,themeOverride:Vt,rowMarker:Ht,rowMarkerChecked:zn},...Pn],[Rt,Pn,rn,Vt,Ht,zn]),[Vn,Hn]=L.useMemo(()=>[tt!==void 0&&typeof Xt==`number`?Math.floor(tt/Xt):0,tt!==void 0&&typeof Xt==`number`?-(tt%Xt):0],[tt,Xt]),Un=L.useRef({height:1,width:1,x:0,y:0}),Wn=L.useMemo(()=>({x:Un.current.x,y:Vn,width:Un.current.width??1,height:Un.current.height??1,ty:Hn}),[Hn,Vn]),Gn=L.useRef(!1),[Kn,qn,Jn]=ln(Wn);Un.current=Kn;let Yn=(Kn.height??1)>1;L.useLayoutEffect(()=>{if(tt!==void 0&&u.current!==null&&Yn){if(u.current.scrollTop===tt)return;u.current.scrollTop=tt,u.current.scrollTop!==tt&&Jn(),Gn.current=!0}},[tt,Yn,Jn]);let Xn=(Kn.width??1)>1;L.useLayoutEffect(()=>{if(et!==void 0&&u.current!==null&&Xn){if(u.current.scrollLeft===et)return;u.current.scrollLeft=et,u.current.scrollLeft!==et&&Jn(),Gn.current=!0}},[et,Xn,Jn]);let Zn=Kn.x+R,Qn=Kn.y,$n=L.useRef(null),er=L.useCallback(e=>{e===!0?$n.current?.focus():window.requestAnimationFrame(()=>{$n.current?.focus()})},[]),tr=on?y+1:y,nr=L.useCallback(e=>{let t=R===0?e:e.map(e=>({...e,location:[e.location[0]-R,e.location[1]]})),n=se?.(t);if(n!==!0)for(let e of t)oe?.(e.location,e.value);return n},[oe,se,R]),[rr,ir]=L.useState(),ar=z.current!==void 0&&z.current.range.width*z.current.range.height>1?z.current.range:void 0,or=ft?z.current?.cell:void 0,sr=or?.[0],cr=or?.[1],lr=L.useMemo(()=>{if((ye===void 0||ye.length===0)&&(ar??sr??cr??rr)===void 0)return;let e=[];if(ye!==void 0)for(let t of ye){let n=Bn.length-t.range.x-R;n>0&&e.push({color:t.color,range:{...t.range,x:t.range.x+R,width:Math.min(n,t.range.width)},style:t.style})}return rr!==void 0&&e.push({color:fr(kn.accentColor,0),range:rr,style:`dashed`}),ar!==void 0&&e.push({color:fr(kn.accentColor,.5),range:ar,style:`solid-outline`}),sr!==void 0&&cr!==void 0&&e.push({color:kn.accentColor,range:{x:sr,y:cr,width:1,height:1},style:`solid-outline`}),e.length>0?e:void 0},[rr,ar,sr,cr,ye,Bn.length,kn.accentColor,R]),ur=L.useRef(Bn);ur.current=Bn;let dr=L.useCallback(([e,t],n=!1)=>{let r=on&&t===tr-1;if(e===0&&an)return r?Xc:{kind:at.Marker,allowOverlay:!1,checkboxStyle:Ht,checked:z?.rows.hasIndex(t)===!0,markerKind:Rt===`clickable-number`?`number`:Rt,row:Bt+t,drawHandle:xt!==void 0,cursor:Rt===`clickable-number`?`pointer`:void 0};if(r){let t=e===R?qe?.hint??``:``,n=ur.current[e];if(n?.trailingRowOptions?.disabled===!0)return Xc;{let e=n?.trailingRowOptions?.hint??t,r=n?.trailingRowOptions?.addIcon??qe?.addIcon;return{kind:at.NewRow,hint:e,allowOverlay:!1,icon:r}}}else{let r=e-R;if(n||pt?.strict===!0){let e=Un.current,n=e.x>r||r>e.x+e.width||e.y>t||t>e.y+e.height||t>=br.current,i=r===e.extras?.selected?.[0]&&t===e.extras?.selected[1],a=!1;if(e.extras?.freezeRegions!==void 0){for(let n of e.extras.freezeRegions)if(ba(n,r,t)){a=!0;break}}if(n&&!i&&!a)return Xc}let i=b([r,t]);return R!==0&&i.span!==void 0&&(i={...i,span:[i.span[0]+R,i.span[1]+R]}),i}},[on,tr,an,Ht,z?.rows,Rt,Bt,xt,R,qe?.hint,qe?.addIcon,pt?.strict,b]),pr=L.useCallback(e=>{let t=Fe?.(e)??{name:e};return ae!==void 0&&e!==``&&(t={icon:t.icon,name:t.name,overrideTheme:t.overrideTheme,actions:[...t.actions??[],{title:`Rename`,icon:`renameIcon`,onClick:e=>Lr({group:t.name,bounds:e.bounds})}]}),t},[Fe,ae]),mr=L.useCallback(e=>{let[t,n]=e.cell,r=Bn[t],i=r?.group===void 0?void 0:pr(r.group)?.overrideTheme,o=r?.themeOverride,s=m?.(n);a({...e,theme:xi(kn,i,o,s,e.content.themeOverride)})},[m,Bn,pr,kn]),hr=L.useCallback((e,t,n)=>{if(z.current===void 0)return;let[r,i]=z.current.cell,a=dr([r,i]);if(a.kind!==I.Boolean&&a.allowOverlay){let t=a;if(n!==void 0)switch(t.kind){case I.Number:{let e=C(()=>n===`-`?-0:Number.parseFloat(n),0);t={...t,data:Number.isNaN(e)?0:e};break}case I.Text:case I.Markdown:case I.Uri:t={...t,data:n};break}mr({target:e,content:t,initialValue:n,cell:[r,i],highlight:n===void 0,forceEditMode:n!==void 0})}else a.kind===I.Boolean&&t&&a.readonly!==!0&&(nr([{location:z.current.cell,value:{...a,data:dc(a.data)}}]),$n.current?.damage([{cell:z.current.cell}]))},[dr,z,nr,mr]),gr=L.useCallback((e,t)=>{let n=$n.current?.getBounds(e,t);if(n===void 0||u.current===null)return;let r=dr([e,t]);r.allowOverlay&&mr({target:n,content:r,initialValue:void 0,highlight:!0,cell:[e,t],forceEditMode:!0})},[dr,mr]),_r=L.useCallback((e,t,n=`both`,r=0,i=0,a=void 0)=>{if(u.current!==null){let o=$n.current,c=s.current,l=typeof e==`number`?e:e.unit===`cell`?e.amount:void 0,d=typeof t==`number`?t:t.unit===`cell`?t.amount:void 0,f=typeof e!=`number`&&e.unit===`px`?e.amount:void 0,p=typeof t!=`number`&&t.unit===`px`?t.amount:void 0;if(o!==null&&c!==null){let s={x:0,y:0,width:0,height:0},m=0,h=0;if((l!==void 0||d!==void 0)&&(s=o.getBounds((l??0)+R,d??0)??s,s.width===0||s.height===0))return;let g=c.getBoundingClientRect(),_=g.width/c.offsetWidth;if(f!==void 0&&(s={...s,x:f-g.left-u.current.scrollLeft,width:1}),p!==void 0&&(s={...s,y:p+g.top-u.current.scrollTop,height:1}),s!==void 0){let o={x:s.x-r,y:s.y-i,width:s.width+2*r,height:s.height+2*i},c=0;for(let e=0;e0&&(l=zr(tr,d,Xt));let f=c*_+g.left+R*rn*_,p=g.right,v=g.top+Ln*_,y=g.bottom-l*_,b=s.width+r*2;switch(a?.hAlign){case`start`:p=f+b;break;case`end`:f=p-b;break;case`center`:f=Math.floor((f+p)/2)-b/2,p=f+b;break}let x=s.height+i*2;switch(a?.vAlign){case`start`:y=v+x;break;case`end`:v=y-x;break;case`center`:v=Math.floor((v+y)/2)-x/2,y=v+x;break}f>o.x?m=o.x-f:po.y?h=o.y-v:y=tr-d)&&(h=0),(m!==0||h!==0)&&(_!==1&&(m/=_,h/=_),u.current.scrollTo(m+u.current.scrollLeft,h+u.current.scrollTop))}}}},[R,Je,rn,Ln,je,Pn,tr,cn,Xt]),vr=L.useRef(gr),yr=L.useRef(b),br=L.useRef(y);vr.current=gr,yr.current=b,br.current=y;let xr=L.useCallback(async(e,t=!0)=>{if(Bn[e]?.trailingRowOptions?.disabled===!0)return;let n=ge?.(),r,i=!0;n!==void 0&&(r=await n,r===`top`&&(i=!1),typeof r==`number`&&(i=!1));let a=0,o=()=>{if(br.current<=y){a<500&&window.setTimeout(o,a),a=50+a*2;return}let n=typeof r==`number`?r:i?y:0;vi.current(e-R,n),En({cell:[e,n],range:{x:e,y:n,width:1,height:1}},!1,!1,`edit`);let s=yr.current([e-R,n]);s.allowOverlay&&Qe(s)&&s.readonly!==!0&&t&&window.setTimeout(()=>{vr.current(e,n)},0)};o()},[Bn,ge,R,y,En]),Sr=L.useCallback(e=>{let t=Pn[e]?.trailingRowOptions?.targetColumn??qe?.targetColumn;if(typeof t==`number`)return t+ +!!an;if(typeof t==`object`){let e=v.indexOf(t);if(e>=0)return e+ +!!an}},[Pn,v,an,qe?.targetColumn]),Cr=L.useRef(),wr=L.useRef(),Tr=L.useCallback((e,t)=>{let[n,r]=t;return xi(kn,Bn[n]?.themeOverride,m?.(r),e.themeOverride)},[m,Bn,kn]),Er=L.useCallback(e=>{let t=vs.value?e.metaKey:e.ctrlKey,n=t&&Se===`multi`,r=t&&xe===`multi`,[i,o]=e.location,s=z.columns,c=z.rows,[l,u]=z.current?.cell??[];if(e.kind===`cell`){if(wr.current=void 0,Or.current=[i,o],i===0&&an){if(on===!0&&o===y||Rt===`number`||Se===`none`)return;let r=dr(e.location);if(r.kind!==at.Marker)return;if(xt!==void 0){let t=Nn(r);x(t?.kind===at.Marker);let n=t?.onClick?.({...e,cell:r,posX:e.localEventX,posY:e.localEventY,bounds:e.bounds,theme:Tr(r,e.location),preventDefault:()=>void 0});if(n===void 0||n.checked===r.checked)return}a(void 0),er();let i=c.hasIndex(o),s=Cr.current;if(Se===`multi`&&(e.shiftKey||e.isLongTouch===!0)&&s!==void 0&&c.hasIndex(s)){let e=[Math.min(s,o),Math.max(s,o)+1];n||Ne===`multi`?Dn(void 0,e,!0):Dn(st.fromSingleSelection(e),void 0,n)}else n||e.isTouch||Ne===`multi`?i?Dn(c.remove(o),void 0,!0):(Dn(void 0,o,!0),Cr.current=o):i&&c.length===1?Dn(st.empty(),void 0,t):(Dn(st.fromSingleSelection(o),void 0,t),Cr.current=o)}else if(i>=R&&on&&o===y){let e=Sr(i);xr(e??i)}else if(l!==i||u!==o){let n=dr(e.location),r=Nn(n);if(r?.onSelect!==void 0){let t=!1;if(r.onSelect({...e,cell:n,posX:e.localEventX,posY:e.localEventY,bounds:e.bounds,preventDefault:()=>t=!0,theme:Tr(n,e.location)}),t)return}let s=cn&&o===y,c=cn&&z!==void 0&&z.current?.cell[1]===y;if((e.shiftKey||e.isLongTouch===!0)&&l!==void 0&&u!==void 0&&z.current!==void 0&&!c){if(s)return;let e=Math.min(i,l),n=Math.max(i,l),r=Math.min(o,u),a=Math.max(o,u);En({...z.current,range:{x:e,y:r,width:n-e+1,height:a-r+1}},!0,t,`click`),Cr.current=void 0,er()}else En({cell:[i,o],range:{x:i,y:o,width:1,height:1}},!0,t,`click`),Cr.current=void 0,a(void 0),er()}}else if(e.kind===`header`)if(Or.current=[i,o],a(void 0),an&&i===0)Cr.current=void 0,wr.current=void 0,Se===`multi`&&(c.length===y?Dn(st.empty(),void 0,t):Dn(st.fromSingleSelection([0,y]),void 0,t),er());else{let n=wr.current;if(xe===`multi`&&(e.shiftKey||e.isLongTouch===!0)&&n!==void 0&&s.hasIndex(n)){let e=[Math.min(n,i),Math.max(n,i)+1];r?On(void 0,e,t):On(st.fromSingleSelection(e),void 0,t)}else r?(s.hasIndex(i)?On(s.remove(i),void 0,t):On(void 0,i,t),wr.current=i):xe!==`none`&&(On(st.fromSingleSelection(i),void 0,t),wr.current=i);Cr.current=void 0,er()}else e.kind===`group-header`?Or.current=[i,o]:e.kind===`out-of-bounds`&&!e.isMaybeScrollbar&&(yn(Zc,!1),a(void 0),er(),Re?.(),Cr.current=void 0,wr.current=void 0)},[xr,xe,er,Nn,Sr,dr,z,an,cn,Re,xt,R,Rt,Se,Ne,y,En,yn,On,Dn,on,Tr]),Dr=L.useRef(!1),Or=L.useRef(),jr=L.useRef(Kn),Pr=L.useRef(),Fr=L.useCallback(e=>{if(Br.current=!1,jr.current=Un.current,e.button!==0&&e.button!==1){Pr.current=void 0;return}let t=performance.now();Pr.current={button:e.button,time:t,location:e.location},e?.kind===`header`&&(Dr.current=!0);let n=e.kind===`cell`&&e.isFillHandle;!n&&e.kind!==`cell`&&e.isEdge||(l({previousSelection:z,fillHandle:n}),Or.current=void 0,!e.isTouch&&e.button===0&&!n?Er(e):!e.isTouch&&e.button===1&&(Or.current=e.location))},[z,Er]),[Ir,Lr]=L.useState(),Rr=L.useCallback(e=>{if(e.kind!==`group-header`||xe!==`multi`)return;let t=vs.value?e.metaKey:e.ctrlKey,[n]=e.location,r=z.columns;if(n=R&&Ar(i.group,Bn[e].group);e--)a--;for(let e=n+1;e{if(hn!==void 0&&bn!==void 0){let t=Un.current.y,n=Un.current.height,r=hn({x:e,y:t,width:1,height:Math.min(n,y-t)},mn.current.signal);typeof r!=`object`&&(r=await r());let i=Pn[e-R],a=document.createElement(`canvas`).getContext(`2d`,{alpha:!1});if(a!==null){a.font=kn.baseFontFull;let t=Oi(a,kn,i,0,r,Ut,Wt,!1,Nn);bn?.(i,t.width,e,t.width)}}},[Pn,hn,Wt,kn,Ut,bn,R,y,Nn]),[Hr,Ur]=L.useState(),Wr=L.useCallback(async(e,t)=>{let n=e.current?.range;if(n===void 0||hn===void 0||t.current===void 0)return;let r=t.current.range;if(E!==void 0){let e=!1;if(E({fillDestination:{...r,x:r.x-R},patternSource:{...n,x:n.x-R},preventDefault:()=>e=!0}),e)return}let i=hn(n,mn.current.signal);typeof i!=`object`&&(i=await i());let a=i,o=[];for(let e=0;e({cell:e.location})))},[hn,nr,E,R]),Gr=L.useCallback(()=>{if(z.current===void 0||z.current.range.width<=1)return;let e={...z,current:{...z.current,range:{...z.current.range,width:1}}};Wr(e,z)},[Wr,z]),Kr=L.useCallback(()=>{if(z.current===void 0||z.current.range.height<=1)return;let e={...z,current:{...z.current,range:{...z.current.range,height:1}}};Wr(e,z)},[Wr,z]),qr=L.useCallback((e,t)=>{let n=c;if(l(void 0),ir(void 0),Ur(void 0),Dr.current=!1,t)return;if(n?.fillHandle===!0&&z.current!==void 0&&n.previousSelection?.current!==void 0){if(rr===void 0)return;let e={...z,current:{...z.current,range:xa(n.previousSelection.current.range,rr)}};Wr(n.previousSelection,e),yn(e,!0);return}let[r,i]=e.location,[a,o]=Or.current??[],s=()=>{Br.current=!0},u=t=>{let c=t.isTouch||a===r&&o===i;if(c&&w?.([r-R,i],{...t,preventDefault:s}),t.button===1)return!Br.current;if(!Br.current){let a=dr(e.location),o=Nn(a);if(o!==void 0&&o.onClick!==void 0&&c){let n=o.onClick({...t,cell:a,posX:t.localEventX,posY:t.localEventY,bounds:t.bounds,theme:Tr(a,e.location),preventDefault:s});n!==void 0&&!Ze(n)&&Xe(n)&&(nr([{location:t.location,value:n}]),$n.current?.damage([{cell:t.location}]))}if(Br.current||z.current===void 0)return!1;let l=!1;switch(a.activationBehaviorOverride??Me){case`double-click`:case`second-click`:{if(n?.previousSelection?.current?.cell===void 0)break;let[e,a]=z.current.cell,[o,s]=n.previousSelection.current.cell;l=r===e&&r===o&&i===a&&i===s&&(t.isDoubleClick===!0||Me===`second-click`);break}case`single-click`:l=!0;break}if(l)return T?.([r-R,i]),hr(t.bounds,!1),!0}return!1},d=e.location[0]-R;if(e.isTouch){let t=Un.current,n=jr.current;if(t.x!==n.x||t.y!==n.y)return;if(e.isLongTouch===!0){if(e.kind===`cell`&&Nr(z.current?.cell,e.location)){ne?.([d,e.location[1]],{...e,preventDefault:s});return}else if(e.kind===`header`&&z.columns.hasIndex(r)){re?.(d,{...e,preventDefault:s});return}else if(e.kind===`group-header`){if(d<0)return;ie?.(d,{...e,preventDefault:s});return}}e.kind===`cell`?u(e)||Er(e):e.kind===`group-header`?te?.(d,{...e,preventDefault:s}):(e.kind===`header`&&M?.(d,{...e,preventDefault:s}),Er(e));return}if(e.kind===`header`){if(d<0)return;e.isEdge?e.isDoubleClick===!0&&Vr(r):e.button===0&&r===a&&i===o&&M?.(d,{...e,preventDefault:s})}if(e.kind===`group-header`){if(d<0)return;e.button===0&&r===a&&i===o&&(te?.(d,{...e,preventDefault:s}),Br.current||Rr(e))}e.kind===`cell`&&(e.button===0||e.button===1)&&u(e),Or.current=void 0},[c,z,R,rr,Wr,yn,w,dr,Nn,Me,Tr,nr,T,hr,ne,re,ie,Er,te,M,Vr,Rr]),Jr=L.useCallback(e=>{let t={...e,location:[e.location[0]-R,e.location[1]]};Oe?.(t),c!==void 0&&e.buttons===0&&(l(void 0),ir(void 0),Ur(void 0),Dr.current=!1),Ur(t=>Dr.current?[e.scrollEdge[0],0]:e.scrollEdge[0]===t?.[0]&&e.scrollEdge[1]===t[1]?t:c===void 0||(Pr.current?.location[0]??0){Pe?.(e-R,t)},[Pe,R]),Xr=z?.current?.cell,Zr=L.useCallback((e,t,n,r,i,a)=>{Gn.current=!1;let o=Xr;o!==void 0&&(o=[o[0]-R,o[1]]);let s=je===0?void 0:{x:0,y:e.y,width:je,height:e.height},c=[];s!==void 0&&c.push(s),Je>0&&(c.push({x:e.x-R,y:y-Je,width:e.width,height:Je}),je>0&&c.push({x:0,y:y-Je,width:je,height:Je}));let l={x:e.x-R,y:e.y,width:e.width,height:on&&e.y+e.height>=y?e.height-1:e.height,tx:i,ty:a,extras:{selected:o,freezeRegion:s,freezeRegions:c}};Un.current=l,qn(l),jn([t,n,r]),Be?.(l,l.tx,l.ty,l.extras)},[Xr,R,on,y,je,Je,qn,Be]),Qr=Jt(_e,L.useCallback((e,t)=>{_e?.(e-R,t-R),xe!==`none`&&On(st.fromSingleSelection(t),void 0,!0)},[xe,_e,R,On])),$r=L.useRef(!1),ei=L.useCallback(e=>{if(e.location[0]===0&&R>0){e.preventDefault();return}De?.({...e,location:[e.location[0]-R,e.location[1]]}),e.defaultPrevented()||($r.current=!0),l(void 0)},[De,R]),ti=L.useCallback(()=>{$r.current=!1},[]),ni=L.useRef(),ri=L.useCallback(e=>{if(!ws(e,ni.current)&&(ni.current=e,!(Pr?.current?.button!==void 0&&Pr.current.button>=1))){if(e.buttons!==0&&c!==void 0&&Pr.current?.location[0]===0&&e.location[0]===0&&R===1&&Se===`multi`&&c.previousSelection&&!c.previousSelection.rows.hasIndex(Pr.current.location[1])&&z.rows.hasIndex(Pr.current.location[1])){let t=Math.min(Pr.current.location[1],e.location[1]),n=Math.max(Pr.current.location[1],e.location[1])+1;Dn(st.fromSingleSelection([t,n]),void 0,!1)}if(e.buttons!==0&&c!==void 0&&z.current!==void 0&&!$r.current&&!Dr.current&&(be===`rect`||be===`multi-rect`)){let[t,n]=z.current.cell,[r,i]=e.location;if(i<0&&(i=Un.current.y),c.fillHandle===!0&&c.previousSelection?.current!==void 0){let e=c.previousSelection.current.range;i=Math.min(i,on?y-1:y);let t=va(e,r,i,Ye);ir(t)}else{if(on&&n===y)return;if(on&&i===y)if(e.kind===`out-of-bounds`)i--;else return;r=Math.max(r,R);let a=r-t,o=i-n,s={x:a>=0?t:r,y:o>=0?n:i,width:Math.abs(a)+1,height:Math.abs(o)+1};En({...z.current,range:s},!0,!1,`drag`)}}Le?.({...e,location:[e.location[0]-R,e.location[1]]})}},[Ye,c,R,Se,z,be,Le,Dn,on,y,En]);_c(Hr,u,L.useCallback(()=>{let e=ni.current;if(e===void 0)return;let[t,n]=e.scrollEdge,[r,i]=e.location,a=Un.current;t===-1?r=a.extras?.freezeRegion?.x??a.x:t===1&&(r=a.x+a.width),n===-1?i=Math.max(0,a.y):n===1&&(i=Math.min(y-1,a.y+a.height)),r=(0,us.default)(r,0,Bn.length-1),i=(0,us.default)(i,0,y-1),ri({...e,location:[r,i]})},[Bn.length,ri,y]));let ii=L.useCallback(e=>{if(z.current===void 0)return;let[t,n]=e,[r,i]=z.current.cell,a=z.current.range,o=a.x,s=a.x+a.width,c=a.y,l=a.y+a.height;if(n!==0)switch(n){case 2:l=y,c=i,_r(0,l,`vertical`);break;case-2:c=0,l=i+1,_r(0,c,`vertical`);break;case 1:ci+1?(l--,_r(0,l,`vertical`)):(c=Math.max(0,c-1),_r(0,c,`vertical`));break;default:S(n)}if(t!==0)if(t===2)s=Bn.length,o=r,_r(s-1-R,0,`horizontal`);else if(t===-2)o=R,s=r+1,_r(o-R,0,`horizontal`);else{let e=[];if(hn!==void 0){let t=hn({x:o,y:c,width:s-o-R,height:l-c},mn.current.signal);typeof t==`object`&&(e=Jc(t))}if(t===1){let t=!1;if(o0){let n=(0,Ts.default)(o+1,r+1).find(t=>!e.includes(t-R));n!==void 0&&(o=n,t=!0)}else o++,t=!0;t&&_r(o,0,`horizontal`)}t||(s=Math.min(Bn.length,s+1),_r(s-1-R,0,`horizontal`))}else if(t===-1){let t=!1;if(s>r+1){if(e.length>0){let n=(0,Ts.default)(s-1,r,-1).find(t=>!e.includes(t-R));n!==void 0&&(s=n,t=!0)}else s--,t=!0;t&&_r(s-R,0,`horizontal`)}t||(o=Math.max(R,o-1),_r(o-R,0,`horizontal`))}else S(t)}En({cell:z.current.cell,range:{x:o,y:c,width:s-o,height:l-c}},!0,!1,`keyboard-select`)},[hn,z,Bn.length,R,y,_r,En]),ai=L.useCallback((e,t,n,r)=>{let i=tr-+!n;if(e=(0,us.default)(e,R,Pn.length-1+R),t=(0,us.default)(t,0,i),e===Xr?.[0]&&t===Xr?.[1])return!1;if(r&&z.current!==void 0){let n=[...z.current.rangeStack];(z.current.range.width>1||z.current.range.height>1)&&n.push(z.current.range),yn({...z,current:{cell:[e,t],range:{x:e,y:t,width:1,height:1},rangeStack:n}},!0)}else En({cell:[e,t],range:{x:e,y:t,width:1,height:1}},!0,!1,`keyboard-nav`);return d.current!==void 0&&d.current[0]===e&&d.current[1]===t&&(d.current=void 0),_r(e-R,t),!0},[tr,R,Pn.length,Xr,z,_r,yn,En]),oi=L.useCallback((e,t)=>{i?.cell!==void 0&&e!==void 0&&Xe(e)&&(nr([{location:i.cell,value:e}]),window.requestAnimationFrame(()=>{$n.current?.damage([{cell:i.cell}])})),er(!0),a(void 0);let[n,r]=t;if(z.current!==void 0&&(n!==0||r!==0)){let t=z.current.cell[1]===tr-1&&e!==void 0;ai((0,us.default)(z.current.cell[0]+n,0,Bn.length-1),(0,us.default)(z.current.cell[1]+r,0,tr-1),t,!1)}D?.(e,t)},[i?.cell,er,z,D,nr,tr,ai,Bn.length]),si=L.useMemo(()=>`gdg-overlay-${qc++}`,[]),ci=L.useCallback(e=>{er();let t=[];for(let n=e.x;n({cell:e.location})))},[er,b,Nn,nr,R]),li=i!==void 0,ui=L.useCallback(e=>{let t=()=>{e.stopPropagation(),e.preventDefault()},n={didMatch:!1},{bounds:r}=e,i=z.columns,s=z.rows,c=nn;if(!li&&Ys(c.clear,e,n))yn(Zc,!1),Re?.();else if(!li&&Ys(c.selectAll,e,n))yn({columns:st.empty(),rows:st.empty(),current:{cell:z.current?.cell??[R,0],range:{x:R,y:0,width:v.length,height:y},rangeStack:[]}},!1);else if(Ys(c.search,e,n))o?.current?.focus({preventScroll:!0}),dn(!0);else if(Ys(c.delete,e,n)){let e=Tn?.(z)??!0;if(e!==!1){let t=e===!0?z:e;if(t.current!==void 0){ci(t.current.range);for(let e of t.current.rangeStack)ci(e)}for(let e of t.rows)ci({x:R,y:e,width:v.length,height:1});for(let e of t.columns)ci({x:e,y:0,width:1,height:y})}}if(n.didMatch)return t(),!0;if(z.current===void 0)return!1;let[l,u]=z.current.cell,d=!1,f=!1;Ys(c.scrollToSelectedCell,e,n)?vi.current(l-R,u):xe!==`none`&&Ys(c.selectColumn,e,n)?i.hasIndex(l)?On(i.remove(l),void 0,!0):xe===`single`?On(st.fromSingleSelection(l),void 0,!0):On(void 0,l,!0):Se!==`none`&&Ys(c.selectRow,e,n)?s.hasIndex(u)?Dn(s.remove(u),void 0,!0):Se===`single`?Dn(st.fromSingleSelection(u),void 0,!0):Dn(void 0,u,!0):!li&&r!==void 0&&Ys(c.activateCell,e,n)?u===y&&on?window.setTimeout(()=>{let e=Sr(l);xr(e??l)},0):(T?.([l-R,u]),hr(r,!0)):z.current.range.height>1&&Ys(c.downFill,e,n)?Kr():z.current.range.width>1&&Ys(c.rightFill,e,n)?Gr():Ys(c.goToNextPage,e,n)?u+=Math.max(1,Un.current.height-4):Ys(c.goToPreviousPage,e,n)?u-=Math.max(1,Un.current.height-4):Ys(c.goToFirstCell,e,n)?(a(void 0),u=0,l=0):Ys(c.goToLastCell,e,n)?(a(void 0),u=2**53-1,l=2**53-1):Ys(c.selectToFirstCell,e,n)?(a(void 0),ii([-2,-2])):Ys(c.selectToLastCell,e,n)?(a(void 0),ii([2,2])):li?(Ys(c.closeOverlay,e,n)&&a(void 0),Ys(c.acceptOverlayDown,e,n)&&(a(void 0),u++),Ys(c.acceptOverlayUp,e,n)&&(a(void 0),u--),Ys(c.acceptOverlayLeft,e,n)&&(a(void 0),l--),Ys(c.acceptOverlayRight,e,n)&&(a(void 0),l++)):(Ys(c.goDownCell,e,n)?u+=1:Ys(c.goUpCell,e,n)?--u:Ys(c.goRightCell,e,n)?l+=1:Ys(c.goLeftCell,e,n)?--l:Ys(c.goDownCellRetainSelection,e,n)?(u+=1,d=!0):Ys(c.goUpCellRetainSelection,e,n)?(--u,d=!0):Ys(c.goRightCellRetainSelection,e,n)?(l+=1,d=!0):Ys(c.goLeftCellRetainSelection,e,n)?(--l,d=!0):Ys(c.goToLastRow,e,n)?u=y-1:Ys(c.goToFirstRow,e,n)?u=-(2**53-1):Ys(c.goToLastColumn,e,n)?l=2**53-1:Ys(c.goToFirstColumn,e,n)?l=-(2**53-1):(be===`rect`||be===`multi-rect`)&&(Ys(c.selectGrowDown,e,n)?ii([0,1]):Ys(c.selectGrowUp,e,n)?ii([0,-1]):Ys(c.selectGrowRight,e,n)?ii([1,0]):Ys(c.selectGrowLeft,e,n)?ii([-1,0]):Ys(c.selectToLastRow,e,n)?ii([0,2]):Ys(c.selectToFirstRow,e,n)?ii([0,-2]):Ys(c.selectToLastColumn,e,n)?ii([2,0]):Ys(c.selectToFirstColumn,e,n)&&ii([-2,0])),f=n.didMatch);let p=ai(l,u,!1,d),m=n.didMatch;return m&&(p||!f||Dt)&&t(),m},[li,z,nn,xe,Se,be,R,y,ai,yn,Re,v.length,Tn,Dt,ci,On,Dn,on,Sr,xr,T,hr,Kr,Gr,ii]),di=L.useCallback(e=>{let t=!1;if(fe!==void 0&&fe({...e,cancel:()=>{t=!0}}),t||ui(e)||z.current===void 0)return;let[n,r]=z.current.cell,i=Un.current;if(he&&!e.metaKey&&!e.ctrlKey&&z.current!==void 0&&e.key.length===1&&/[ -~]/g.test(e.key)&&e.bounds!==void 0&&Qe(b([n-R,Math.max(0,Math.min(r,y-1))]))){if((!on||r!==y)&&(i.y>r||r>i.y+i.height||i.x>n||n>i.x+i.width))return;hr(e.bounds,!0,e.key),e.stopPropagation(),e.preventDefault()}},[he,fe,ui,z,b,R,y,on,hr]),fi=L.useCallback((e,t)=>{let n=e.location[0]-R;if(e.kind===`header`&&re?.(n,{...e,preventDefault:t}),e.kind===`group-header`){if(n<0)return;ie?.(n,{...e,preventDefault:t})}if(e.kind===`cell`){let[r,i]=e.location;ne?.([n,i],{...e,preventDefault:t}),kr(z,e.location)||ai(r,i,!1,!1)}},[z,ne,ie,re,R,ai]),pi=L.useCallback(async e=>{if(!nn.paste)return;function t(e,t,n,r){let i=typeof n==`object`?n?.join(` `)??``:n?.toString()??``;if(!Ze(e)&&Qe(e)&&e.readonly!==!0){let a=O?.(i,e);if(a!==void 0&&Xe(a))return{location:t,value:a};let o=Nn(e);if(o===void 0)return;if(o.kind===I.Custom){x(e.kind===I.Custom);let n=o.onPaste?.(i,e.data);return n===void 0?void 0:{location:t,value:{...e,data:n}}}else{let a=o.onPaste?.(i,e,{formatted:r,formattedString:typeof r==`string`?r:r?.join(` -`),rawValue:n});return a===void 0?void 0:(x(a.kind===e.kind),{location:t,value:a})}}}let n=z.columns,r=z.rows,i=u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0,a;if(z.current===void 0?n.length===1?a=[n.first()??0,0]:r.length===1&&(a=[R,r.first()??0]):a=[z.current.range.x,z.current.range.y],i&&a!==void 0){let n,r,i=`text/plain`,o=`text/html`;if(navigator.clipboard.read!==void 0){let e=await navigator.clipboard.read();for(let t of e){if(t.types.includes(o)){let e=sc(await(await t.getType(o)).text());if(e!==void 0){n=e;break}}t.types.includes(i)&&(r=await(await t.getType(i)).text())}}else if(navigator.clipboard.readText!==void 0)r=await navigator.clipboard.readText();else if(e!==void 0&&e?.clipboardData!==null)e.clipboardData.types.includes(o)&&(n=sc(e.clipboardData.getData(o))),n===void 0&&e.clipboardData.types.includes(i)&&(r=e.clipboardData.getData(i));else return;let[s,c]=a,l=[];do{if(ke===void 0){let e=dr(a),i=r??n?.map(e=>e.map(e=>e.rawValue).join(` `)).join(` `)??``,o=t(e,a,i,void 0);o!==void 0&&l.push(o);break}if(n===void 0){if(r===void 0)return;n=uc(r)}if(ke===!1||typeof ke==`function`&&ke?.([a[0]-R,a[1]],n.map(e=>e.map(e=>e.rawValue?.toString()??``)))!==!0)return;for(let[e,r]of n.entries()){if(e+c>=y)break;for(let[n,i]of r.entries()){let r=[n+s,e+c],[a,o]=r;if(a>=Bn.length||o>=tr)continue;let u=t(dr(r),r,i.rawValue,i.formatted);u!==void 0&&l.push(u)}}}while(!1);nr(l),$n.current?.damage(l.map(e=>({cell:e.location})))}},[O,Nn,dr,z,nn.paste,Bn.length,nr,tr,ke,R,y]);qt(`paste`,pi,f,!1,!0);let mi=L.useCallback(async(e,t)=>{if(!nn.copy)return;let n=t===!0||u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0,r=z.columns,i=z.rows,a=(t,n)=>{nee(Ae?[n.map(e=>({kind:I.Text,data:v[e].title,displayData:v[e].title,allowOverlay:!1})),...t]:t,n,e)};if(n&&hn!==void 0){if(z.current!==void 0){let e=hn(z.current.range,mn.current.signal);typeof e!=`object`&&(e=await e()),a(e,(0,ws.default)(z.current.range.x-R,z.current.range.x+z.current.range.width-R))}else if(i!==void 0&&i.length>0){let e=[...i].map(e=>{let t=hn({x:R,y:e,width:v.length,height:1},mn.current.signal);return typeof t==`object`?t[0]:t().then(e=>e[0])});e.some(e=>e instanceof Promise)?a(await Promise.all(e),(0,ws.default)(v.length)):a(e,(0,ws.default)(v.length))}else if(r.length>0){let e=[],t=[];for(let n of r){let r=hn({x:n,y:0,width:1,height:y},mn.current.signal);typeof r!=`object`&&(r=await r()),e.push(r),t.push(n-R)}e.length===1?a(e[0],t):a(e.reduce((e,t)=>e.map((e,n)=>[...e,...t[n]])),t)}}},[v,hn,z,nn.copy,R,y,Ae]);qt(`copy`,mi,f,!1,!1),qt(`cut`,L.useCallback(async e=>{if(nn.cut&&(u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0)&&(await mi(e),z.current!==void 0)){let e={current:{cell:z.current.cell,range:z.current.range,rangeStack:[]},rows:st.empty(),columns:st.empty()},t=Tn?.(e);if(t===!1||(e=t===!0?e:t,e.current===void 0))return;ci(e.current.range)}},[ci,z,nn.cut,mi,Tn]),f,!1,!1);let hi=L.useCallback((e,t)=>{if(ce!==void 0){R!==0&&(e=e.map(e=>[e[0]-R,e[1]])),ce(e,t);return}if(e.length===0||t===-1)return;let[n,r]=e[t];d.current!==void 0&&d.current[0]===n&&d.current[1]===r||(d.current=[n,r],ai(n,r,!1,!1))},[ce,R,ai]),[gi,_i]=Ve?.current?.cell??[],vi=L.useRef(_r);vi.current=_r,L.useLayoutEffect(()=>{!Gn.current&&gi!==void 0&&_i!==void 0&&(gi!==vn.current?.current?.cell[0]||_i!==vn.current?.current?.cell[1])&&vi.current(gi,_i),Gn.current=!1},[gi,_i]);let Si=z.current!==void 0&&(z.current.cell[0]>=Bn.length||z.current.cell[1]>=tr);L.useLayoutEffect(()=>{Si&&yn(Zc,!1)},[Si,yn]);let Ci=L.useMemo(()=>on===!0&&qe?.tint===!0?st.fromSingleSelection(tr-1):st.empty(),[tr,on,qe?.tint]),Ti=L.useCallback(e=>typeof nt==`boolean`?nt:nt?.(e-R)??!0,[R,nt]),Ei=L.useMemo(()=>{if(Ir===void 0||s.current===null)return null;let{bounds:e,group:t}=Ir,n=s.current.getBoundingClientRect();return L.createElement(Ks,{bounds:e,group:t,canvasBounds:n,onClose:()=>Lr(void 0),onFinish:e=>{Lr(void 0),ae?.(t,e)}})},[ae,Ir]),Di=Math.min(Bn.length,je+ +!!an);L.useImperativeHandle(t,()=>({appendRow:(e,t)=>xr(e+R,t),updateCells:e=>(R!==0&&(e=e.map(e=>({cell:[e.cell[0]+R,e.cell[1]]}))),$n.current?.damage(e)),getBounds:(e,t)=>{if(!(s?.current===null||u?.current===null)){if(e===void 0&&t===void 0){let e=s.current.getBoundingClientRect(),t=e.width/u.current.clientWidth;return{x:e.x-u.current.scrollLeft*t,y:e.y-u.current.scrollTop*t,width:u.current.scrollWidth*t,height:u.current.scrollHeight*t}}return $n.current?.getBounds((e??0)+R,t)}},focus:()=>$n.current?.focus(),emit:async e=>{switch(e){case`delete`:di({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!1,key:`Delete`,keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`fill-right`:di({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!0,key:`r`,keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`fill-down`:di({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!0,key:`d`,keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`copy`:await mi(void 0,!0);break;case`paste`:await pi();break}},scrollTo:_r,remeasureColumns:e=>{for(let t of e)Vr(t+R)}}),[xr,Vr,mi,di,pi,R,_r]);let[Ai,ji]=Xr??[],Mi=L.useCallback(e=>{let[t,n]=e;if(n===-1){xe!==`none`&&(On(st.fromSingleSelection(t),void 0,!1),er());return}Ai===t&&ji===n||(En({cell:e,range:{x:t,y:n,width:1,height:1}},!0,!1,`keyboard-nav`),_r(t,n))},[xe,er,_r,Ai,ji,En,On]),[Ni,Pi]=L.useState(!1),Fi=L.useRef((0,Kt.default)(e=>{Pi(e)},5)),Ii=L.useCallback(()=>{Fi.current(!0),z.current===void 0&&z.columns.length===0&&z.rows.length===0&&c===void 0&&En({cell:[R,Qn],range:{x:R,y:Qn,width:1,height:1}},!0,!1,`keyboard-select`)},[Qn,z,c,R,En]),Li=L.useCallback(()=>{Fi.current(!1)},[]),[Ri,zi]=L.useMemo(()=>{let e,t=pt?.scrollbarWidthOverride??sn(),n=y+ +!!on;if(typeof Xt==`number`)e=Ln+n*Xt;else{let t=0,r=Math.min(n,10);for(let e=0;et.width+e,0)+t;return[`${Math.min(1e5,r)}px`,`${Math.min(1e5,e)}px`]},[Bn,pt?.scrollbarWidthOverride,Xt,y,on,Ln]),Bi=L.useMemo(()=>yi(kn),[kn]);return L.createElement(wi.Provider,{value:kn},L.createElement(mc,{style:Bi,className:P,inWidth:g??Ri,inHeight:_??zi},L.createElement(Vs,{fillHandle:dt,drawFocusRing:ft,experimental:pt,fixedShadowX:mt,fixedShadowY:ht,getRowThemeOverride:m,headerIcons:gt,imageWindowLoader:_t,initialSize:vt,isDraggable:yt,onDragLeave:bt,onRowMoved:xt,overscrollX:en,overscrollY:tn,preventDiagonalScrolling:wt,rightElement:Tt,rightElementProps:Et,smoothScrollX:Ot,smoothScrollY:kt,className:P,enableGroups:In,onCanvasFocused:Ii,onCanvasBlur:Li,canvasRef:s,onContextMenu:fi,theme:kn,cellXOffset:Zn,cellYOffset:Qn,accessibilityHeight:Kn.height,onDragEnd:ti,columns:Bn,nonGrowWidth:Fn,drawHeader:Cn,onColumnProposeMove:ee,drawCell:wn,disabledRows:Ci,freezeColumns:Di,lockColumns:R,firstColAccessible:R===0,getCellContent:dr,minColumnWidth:Ut,maxColumnWidth:Wt,searchInputRef:o,showSearch:fn,onSearchClose:pn,highlightRegions:lr,getCellsForSelection:hn,getGroupDetails:pr,headerHeight:Zt,isFocused:Ni,groupHeaderHeight:In?Qt:0,freezeTrailingRows:Je+(on&&qe?.sticky===!0?1:0),hasAppendRow:on,onColumnResize:bn,onColumnResizeEnd:xn,onColumnResizeStart:Sn,onCellFocused:Mi,onColumnMoved:Qr,onDragStart:ei,onHeaderMenuClick:Yr,onItemHovered:ri,isFilling:c?.fillHandle===!0,onMouseMove:Jr,onKeyDown:di,onKeyUp:pe,onMouseDown:Fr,onMouseUp:qr,onDragOverCell:rt,onDrop:it,onSearchResultsChanged:hi,onVisibleRegionChanged:Zr,clientSize:An,rowHeight:Xt,searchResults:le,searchValue:de,onSearchValueChange:ue,rows:tr,scrollRef:u,selection:z,translateX:Kn.tx,translateY:Kn.ty,verticalBorder:Ti,gridRef:$n,getCellRenderer:Nn}),Ei,i!==void 0&&L.createElement(L.Suspense,{fallback:null},L.createElement(Kc,{...i,validateCell:_n,bloom:j,id:si,getCellRenderer:Nn,className:pt?.isSubGrid===!0?`click-outside-ignore`:void 0,provideEditor:Ke,imageEditorOverride:p,onFinishEditing:oi,markdownDivCreateNode:h,isOutsideClick:Ft}))))});ct();var $c=20,el={getAccessibilityString:e=>e.data?.toString()??`false`,kind:I.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:e=>tl(e,e.cell.data,et(e.cell),e.cell.maxSize??$c),onDelete:e=>({...e,data:!1}),onClick:e=>{let{cell:t,posX:n,posY:r,bounds:i,theme:a}=e,{width:o,height:s,x:c,y:l}=i,u=t.maxSize??$c,d=Math.floor(i.y+s/2),f=$t(u,s,a.cellVerticalPadding),p=Zt(Qt(t.contentAlign??`center`,c,o,a.cellHorizontalPadding,f),d,f),m=en(c+n,l+r,p);if(et(t)&&m)return{...t,data:dc(t.data)}},onPaste:(e,t)=>{let n=null;return e.toLowerCase()===`true`?n=!0:e.toLowerCase()===`false`?n=!1:e.toLowerCase()===`indeterminate`&&(n=void 0),n===t.data?void 0:{...t,data:n}}};function tl(e,t,n,r){if(!n&&t===null)return;let{ctx:i,hoverAmount:a,theme:o,rect:s,highlighted:c,hoverX:l,hoverY:u,cell:{contentAlign:d}}=e,{x:f,y:p,width:m,height:h}=s,g=.35,_=n?1-g+g*a:.4;t===null&&(_*=a),_!==0&&(i.globalAlpha=_,Na(i,o,t,f,p,m,h,c,l,u,r,d),i.globalAlpha=1)}St();var nl=xt(`div`)({name:`BubblesOverlayEditorStyle`,class:`gdg-b1ygi5by`,propsAsIs:!1}),rl=e=>{let{bubbles:t}=e;return L.createElement(nl,null,t.map((e,t)=>L.createElement(`div`,{key:t,className:`boe-bubble`},e)),L.createElement(`textarea`,{className:`gdg-input`,autoFocus:!0}))};ct();var il={getAccessibilityString:e=>un(e.data),kind:I.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(e,t,n)=>t.data.reduce((t,n)=>e.measureText(n).width+t+20,0)+2*n.cellHorizontalPadding-4,draw:e=>ol(e,e.cell.data),provideEditor:()=>e=>{let{value:t}=e;return L.createElement(rl,{bubbles:t.data})},onPaste:()=>void 0},al=4;function ol(e,t){let{rect:n,theme:r,ctx:i,highlighted:a}=e,{x:o,y:s,width:c,height:l}=n,u=al,d=o+r.cellHorizontalPadding,f=[];for(let e of t){if(d>o+c)break;let t=Jr(e,i,r.baseFontFull).width;f.push({x:d,width:t}),d+=t+16+u}i.beginPath();for(let e of f)si(i,e.x,s+(l-20)/2,e.width+16,20,r.roundingRadius??20/2);i.fillStyle=a?r.bgBubbleSelected:r.bgBubble,i.fill();for(let[e,n]of f.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(t[e],n.x+8,s+l/2+Xr(i,r))}St();var sl=xt(`div`)({name:`DrilldownOverlayEditorStyle`,class:`gdg-d4zsq0x`,propsAsIs:!1}),cl=e=>{let{drilldowns:t}=e;return L.createElement(sl,null,t.map((e,t)=>L.createElement(`div`,{key:t,className:`doe-bubble`},e.img!==void 0&&L.createElement(`img`,{src:e.img}),L.createElement(`div`,null,e.text))))};ct();var ll={getAccessibilityString:e=>un(e.data.map(e=>e.text)),kind:I.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(e,t,n)=>t.data.reduce((t,n)=>e.measureText(n.text).width+t+20+(n.img===void 0?0:18),0)+2*n.cellHorizontalPadding-4,draw:e=>pl(e,e.cell.data),provideEditor:()=>e=>{let{value:t}=e;return L.createElement(cl,{drilldowns:t.data})},onPaste:()=>void 0},ul=4,dl={};function fl(e,t,n,r){let i=Math.ceil(window.devicePixelRatio),a=n-10,o=n*i,s=r+5,c=r*3,l=(c+10)*i,u=`${e},${t},${i},${n}`;if(dl[u]!==void 0)return{el:dl[u],height:o,width:l,middleWidth:4*i,sideWidth:s*i,padding:5*i,dpr:i};let d=document.createElement(`canvas`),f=d.getContext(`2d`);return f===null?null:(d.width=l,d.height=o,f.scale(i,i),dl[u]=d,f.beginPath(),si(f,5,5,c,a,r),f.shadowColor=`rgba(24, 25, 34, 0.4)`,f.shadowBlur=1,f.fillStyle=e,f.fill(),f.shadowColor=`rgba(24, 25, 34, 0.3)`,f.shadowOffsetY=1,f.shadowBlur=5,f.fillStyle=e,f.fill(),f.shadowOffsetY=0,f.shadowBlur=0,f.shadowBlur=0,f.beginPath(),si(f,5.5,5.5,c,a,r),f.strokeStyle=t,f.lineWidth=1,f.stroke(),{el:d,height:o,width:l,sideWidth:s*i,middleWidth:r*i,padding:5*i,dpr:i})}function pl(e,t){let{rect:n,theme:r,ctx:i,imageLoader:a,col:o,row:s}=e,{x:c,width:l}=n,u=r.baseFontFull,d=ri(i,u),f=Math.min(n.height,Math.max(16,Math.ceil(d*r.lineHeight)*2)),p=Math.floor(n.y+(n.height-f)/2),m=f-10,h=ul,g=c+r.cellHorizontalPadding,_=r.roundingRadius??6,v=fl(r.bgCell,r.drilldownBorder,f,_),y=[];for(let e of t){if(g>c+l)break;let t=Jr(e.text,i,u).width,n=0;e.img!==void 0&&a.loadOrGetImage(e.img,o,s)!==void 0&&(n=m-8+4);let r=t+n+16;y.push({x:g,width:r}),g+=r+h}if(v!==null){let{el:e,height:t,middleWidth:n,sideWidth:r,width:a,dpr:o,padding:s}=v,c=r/o,l=s/o;for(let o of y){let s=Math.floor(o.x),u=Math.floor(o.width),d=u-(c-l)*2;i.imageSmoothingEnabled=!1,i.drawImage(e,0,0,r,t,s-l,p,c,f),d>0&&i.drawImage(e,r,0,n,t,s+(c-l),p,d,f),i.drawImage(e,a-r,0,r,t,s+u-(c-l),p,c,f),i.imageSmoothingEnabled=!0}}i.beginPath();for(let[e,n]of y.entries()){let c=t[e],l=n.x+8;if(c.img!==void 0){let e=a.loadOrGetImage(c.img,o,s);if(e!==void 0){let t=m-8,n=0,a=0,o=e.width,s=e.height;o>s?(n+=(o-s)/2,o=s):s>o&&(a+=(s-o)/2,s=o),i.beginPath(),si(i,l,p+f/2-t/2,t,t,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(e,n,a,o,s,l,p+f/2-t/2,t,t),i.restore(),l+=t+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(c.text,l,p+f/2+Xr(i,r))}}ct();var ml={getAccessibilityString:e=>e.data.join(`, `),kind:I.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:e=>gl(e,e.cell.displayData??e.cell.data,e.cell.rounding??e.theme.roundingRadius??4,e.cell.contentAlign),measure:(e,t)=>t.data.length*50,onDelete:e=>({...e,data:[]}),provideEditor:()=>e=>{let{value:t,onFinishedEditing:n,imageEditorOverride:r}=e,i=r??pn;return L.createElement(i,{urls:t.data,canWrite:t.readonly!==!1,onCancel:n,onChange:e=>{n({...t,data:[e]})}})},onPaste:(e,t)=>{e=e.trim();let n=e.split(`,`).map(e=>{try{return new URL(e),e}catch{return}}).filter(e=>e!==void 0);if(!(n.length===t.data.length&&n.every((e,n)=>e===t.data[n])))return{...t,data:n}}},hl=4;function gl(e,t,n,r){let{rect:i,col:a,row:o,theme:s,ctx:c,imageLoader:l}=e,{x:u,y:d,height:f,width:p}=i,m=f-s.cellVerticalPadding*2,h=[],g=0;for(let e=0;e0&&(c.beginPath(),si(c,_,d+s.cellVerticalPadding,t,m,n),c.save(),c.clip()),c.drawImage(e,_,d+s.cellVerticalPadding,t,m),n>0&&c.restore(),_+=t+hl}}vr(),ct();function _l(e,t){let n=e*49632+t*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}var vl={getAccessibilityString:()=>``,kind:I.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:e=>{let{cell:t,col:n,row:r,ctx:i,rect:a,theme:o}=e;if(t.skeletonWidth===void 0||t.skeletonWidth===0)return;let s=t.skeletonWidth;t.skeletonWidthVariability!==void 0&&t.skeletonWidthVariability>0&&(s+=Math.round(_l(n,r)*t.skeletonWidthVariability));let c=o.cellHorizontalPadding,l=t.skeletonHeight??Math.min(18,a.height-2*o.cellVerticalPadding);si(i,a.x+c,a.y+(a.height-l)/2,s,l,o.roundingRadius??3),i.fillStyle=fr(o.textDark,.1),i.fill()},onPaste:()=>void 0};St();var yl=xt(`div`)({name:`MarkdownOverlayEditorStyle`,class:`gdg-m1pnx84e`,propsAsIs:!1,vars:{"m1pnx84e-0":[e=>e.targetWidth,`px`]}}),bl=e=>{let{value:t,onChange:n,forceEditMode:r,createNode:i,targetRect:a,onFinish:o,validatedSelection:s}=e,c=t.data,l=t.readonly===!0,[u,d]=L.useState(c===``||r),f=L.useCallback(()=>{d(e=>!e)},[]),p=c?`gdg-ml-6`:``;return u?L.createElement(yl,{targetWidth:a.width-20},L.createElement(lr,{autoFocus:!0,highlight:!1,validatedSelection:s,value:c,onKeyDown:e=>{e.key===`Enter`&&e.stopPropagation()},onChange:n}),L.createElement(`div`,{className:`gdg-edit-icon gdg-checkmark-hover ${p}`,onClick:()=>o(t)},L.createElement(nn,null))):L.createElement(yl,{targetWidth:a.width},L.createElement(ir,{contents:c,createNode:i}),!l&&L.createElement(L.Fragment,null,L.createElement(`div`,{className:`spacer`}),L.createElement(`div`,{className:`gdg-edit-icon gdg-edit-hover ${p}`,onClick:f},L.createElement(tn,null))),L.createElement(`textarea`,{className:`gdg-md-edit-textarea gdg-input`,autoFocus:!0}))};ct();var xl={getAccessibilityString:e=>e.data?.toString()??``,kind:I.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:ti,measure:(e,t,n)=>{let r=t.data.split(` +`),rawValue:n});return a===void 0?void 0:(x(a.kind===e.kind),{location:t,value:a})}}}let n=z.columns,r=z.rows,i=u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0,a;if(z.current===void 0?n.length===1?a=[n.first()??0,0]:r.length===1&&(a=[R,r.first()??0]):a=[z.current.range.x,z.current.range.y],i&&a!==void 0){let n,r,i=`text/plain`,o=`text/html`;if(navigator.clipboard.read!==void 0){let e=await navigator.clipboard.read();for(let t of e){if(t.types.includes(o)){let e=sc(await(await t.getType(o)).text());if(e!==void 0){n=e;break}}t.types.includes(i)&&(r=await(await t.getType(i)).text())}}else if(navigator.clipboard.readText!==void 0)r=await navigator.clipboard.readText();else if(e!==void 0&&e?.clipboardData!==null)e.clipboardData.types.includes(o)&&(n=sc(e.clipboardData.getData(o))),n===void 0&&e.clipboardData.types.includes(i)&&(r=e.clipboardData.getData(i));else return;let[s,c]=a,l=[];do{if(ke===void 0){let e=dr(a),i=r??n?.map(e=>e.map(e=>e.rawValue).join(` `)).join(` `)??``,o=t(e,a,i,void 0);o!==void 0&&l.push(o);break}if(n===void 0){if(r===void 0)return;n=uc(r)}if(ke===!1||typeof ke==`function`&&ke?.([a[0]-R,a[1]],n.map(e=>e.map(e=>e.rawValue?.toString()??``)))!==!0)return;for(let[e,r]of n.entries()){if(e+c>=y)break;for(let[n,i]of r.entries()){let r=[n+s,e+c],[a,o]=r;if(a>=Bn.length||o>=tr)continue;let u=t(dr(r),r,i.rawValue,i.formatted);u!==void 0&&l.push(u)}}}while(!1);nr(l),$n.current?.damage(l.map(e=>({cell:e.location})))}},[O,Nn,dr,z,nn.paste,Bn.length,nr,tr,ke,R,y]);qt(`paste`,pi,f,!1,!0);let mi=L.useCallback(async(e,t)=>{if(!nn.copy)return;let n=t===!0||u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0,r=z.columns,i=z.rows,a=(t,n)=>{nee(Ae?[n.map(e=>({kind:I.Text,data:v[e].title,displayData:v[e].title,allowOverlay:!1})),...t]:t,n,e)};if(n&&hn!==void 0){if(z.current!==void 0){let e=hn(z.current.range,mn.current.signal);typeof e!=`object`&&(e=await e()),a(e,(0,Ts.default)(z.current.range.x-R,z.current.range.x+z.current.range.width-R))}else if(i!==void 0&&i.length>0){let e=[...i].map(e=>{let t=hn({x:R,y:e,width:v.length,height:1},mn.current.signal);return typeof t==`object`?t[0]:t().then(e=>e[0])});e.some(e=>e instanceof Promise)?a(await Promise.all(e),(0,Ts.default)(v.length)):a(e,(0,Ts.default)(v.length))}else if(r.length>0){let e=[],t=[];for(let n of r){let r=hn({x:n,y:0,width:1,height:y},mn.current.signal);typeof r!=`object`&&(r=await r()),e.push(r),t.push(n-R)}e.length===1?a(e[0],t):a(e.reduce((e,t)=>e.map((e,n)=>[...e,...t[n]])),t)}}},[v,hn,z,nn.copy,R,y,Ae]);qt(`copy`,mi,f,!1,!1),qt(`cut`,L.useCallback(async e=>{if(nn.cut&&(u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0)&&(await mi(e),z.current!==void 0)){let e={current:{cell:z.current.cell,range:z.current.range,rangeStack:[]},rows:st.empty(),columns:st.empty()},t=Tn?.(e);if(t===!1||(e=t===!0?e:t,e.current===void 0))return;ci(e.current.range)}},[ci,z,nn.cut,mi,Tn]),f,!1,!1);let hi=L.useCallback((e,t)=>{if(ce!==void 0){R!==0&&(e=e.map(e=>[e[0]-R,e[1]])),ce(e,t);return}if(e.length===0||t===-1)return;let[n,r]=e[t];d.current!==void 0&&d.current[0]===n&&d.current[1]===r||(d.current=[n,r],ai(n,r,!1,!1))},[ce,R,ai]),[gi,_i]=Ve?.current?.cell??[],vi=L.useRef(_r);vi.current=_r,L.useLayoutEffect(()=>{!Gn.current&&gi!==void 0&&_i!==void 0&&(gi!==vn.current?.current?.cell[0]||_i!==vn.current?.current?.cell[1])&&vi.current(gi,_i),Gn.current=!1},[gi,_i]);let Si=z.current!==void 0&&(z.current.cell[0]>=Bn.length||z.current.cell[1]>=tr);L.useLayoutEffect(()=>{Si&&yn(Zc,!1)},[Si,yn]);let Ci=L.useMemo(()=>on===!0&&qe?.tint===!0?st.fromSingleSelection(tr-1):st.empty(),[tr,on,qe?.tint]),Ti=L.useCallback(e=>typeof nt==`boolean`?nt:nt?.(e-R)??!0,[R,nt]),Ei=L.useMemo(()=>{if(Ir===void 0||s.current===null)return null;let{bounds:e,group:t}=Ir,n=s.current.getBoundingClientRect();return L.createElement(qs,{bounds:e,group:t,canvasBounds:n,onClose:()=>Lr(void 0),onFinish:e=>{Lr(void 0),ae?.(t,e)}})},[ae,Ir]),Di=Math.min(Bn.length,je+ +!!an);L.useImperativeHandle(t,()=>({appendRow:(e,t)=>xr(e+R,t),updateCells:e=>(R!==0&&(e=e.map(e=>({cell:[e.cell[0]+R,e.cell[1]]}))),$n.current?.damage(e)),getBounds:(e,t)=>{if(!(s?.current===null||u?.current===null)){if(e===void 0&&t===void 0){let e=s.current.getBoundingClientRect(),t=e.width/u.current.clientWidth;return{x:e.x-u.current.scrollLeft*t,y:e.y-u.current.scrollTop*t,width:u.current.scrollWidth*t,height:u.current.scrollHeight*t}}return $n.current?.getBounds((e??0)+R,t)}},focus:()=>$n.current?.focus(),emit:async e=>{switch(e){case`delete`:di({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!1,key:`Delete`,keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`fill-right`:di({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!0,key:`r`,keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`fill-down`:di({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!0,key:`d`,keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`copy`:await mi(void 0,!0);break;case`paste`:await pi();break}},scrollTo:_r,remeasureColumns:e=>{for(let t of e)Vr(t+R)}}),[xr,Vr,mi,di,pi,R,_r]);let[Ai,ji]=Xr??[],Mi=L.useCallback(e=>{let[t,n]=e;if(n===-1){xe!==`none`&&(On(st.fromSingleSelection(t),void 0,!1),er());return}Ai===t&&ji===n||(En({cell:e,range:{x:t,y:n,width:1,height:1}},!0,!1,`keyboard-nav`),_r(t,n))},[xe,er,_r,Ai,ji,En,On]),[Ni,Pi]=L.useState(!1),Fi=L.useRef((0,Kt.default)(e=>{Pi(e)},5)),Ii=L.useCallback(()=>{Fi.current(!0),z.current===void 0&&z.columns.length===0&&z.rows.length===0&&c===void 0&&En({cell:[R,Qn],range:{x:R,y:Qn,width:1,height:1}},!0,!1,`keyboard-select`)},[Qn,z,c,R,En]),Li=L.useCallback(()=>{Fi.current(!1)},[]),[Ri,zi]=L.useMemo(()=>{let e,t=pt?.scrollbarWidthOverride??sn(),n=y+ +!!on;if(typeof Xt==`number`)e=Ln+n*Xt;else{let t=0,r=Math.min(n,10);for(let e=0;et.width+e,0)+t;return[`${Math.min(1e5,r)}px`,`${Math.min(1e5,e)}px`]},[Bn,pt?.scrollbarWidthOverride,Xt,y,on,Ln]),Bi=L.useMemo(()=>yi(kn),[kn]);return L.createElement(wi.Provider,{value:kn},L.createElement(mc,{style:Bi,className:P,inWidth:g??Ri,inHeight:_??zi},L.createElement(Hs,{fillHandle:dt,drawFocusRing:ft,experimental:pt,fixedShadowX:mt,fixedShadowY:ht,getRowThemeOverride:m,headerIcons:gt,imageWindowLoader:_t,initialSize:vt,isDraggable:yt,onDragLeave:bt,onRowMoved:xt,overscrollX:en,overscrollY:tn,preventDiagonalScrolling:wt,rightElement:Tt,rightElementProps:Et,smoothScrollX:Ot,smoothScrollY:kt,className:P,enableGroups:In,onCanvasFocused:Ii,onCanvasBlur:Li,canvasRef:s,onContextMenu:fi,theme:kn,cellXOffset:Zn,cellYOffset:Qn,accessibilityHeight:Kn.height,onDragEnd:ti,columns:Bn,nonGrowWidth:Fn,drawHeader:Cn,onColumnProposeMove:ee,drawCell:wn,disabledRows:Ci,freezeColumns:Di,lockColumns:R,firstColAccessible:R===0,getCellContent:dr,minColumnWidth:Ut,maxColumnWidth:Wt,searchInputRef:o,showSearch:fn,onSearchClose:pn,highlightRegions:lr,getCellsForSelection:hn,getGroupDetails:pr,headerHeight:Zt,isFocused:Ni,groupHeaderHeight:In?Qt:0,freezeTrailingRows:Je+(on&&qe?.sticky===!0?1:0),hasAppendRow:on,onColumnResize:bn,onColumnResizeEnd:xn,onColumnResizeStart:Sn,onCellFocused:Mi,onColumnMoved:Qr,onDragStart:ei,onHeaderMenuClick:Yr,onItemHovered:ri,isFilling:c?.fillHandle===!0,onMouseMove:Jr,onKeyDown:di,onKeyUp:pe,onMouseDown:Fr,onMouseUp:qr,onDragOverCell:rt,onDrop:it,onSearchResultsChanged:hi,onVisibleRegionChanged:Zr,clientSize:An,rowHeight:Xt,searchResults:le,searchValue:de,onSearchValueChange:ue,rows:tr,scrollRef:u,selection:z,translateX:Kn.tx,translateY:Kn.ty,verticalBorder:Ti,gridRef:$n,getCellRenderer:Nn}),Ei,i!==void 0&&L.createElement(L.Suspense,{fallback:null},L.createElement(Kc,{...i,validateCell:_n,bloom:j,id:si,getCellRenderer:Nn,className:pt?.isSubGrid===!0?`click-outside-ignore`:void 0,provideEditor:Ke,imageEditorOverride:p,onFinishEditing:oi,markdownDivCreateNode:h,isOutsideClick:Ft}))))});ct();var $c=20,el={getAccessibilityString:e=>e.data?.toString()??`false`,kind:I.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:e=>tl(e,e.cell.data,et(e.cell),e.cell.maxSize??$c),onDelete:e=>({...e,data:!1}),onClick:e=>{let{cell:t,posX:n,posY:r,bounds:i,theme:a}=e,{width:o,height:s,x:c,y:l}=i,u=t.maxSize??$c,d=Math.floor(i.y+s/2),f=$t(u,s,a.cellVerticalPadding),p=Zt(Qt(t.contentAlign??`center`,c,o,a.cellHorizontalPadding,f),d,f),m=en(c+n,l+r,p);if(et(t)&&m)return{...t,data:dc(t.data)}},onPaste:(e,t)=>{let n=null;return e.toLowerCase()===`true`?n=!0:e.toLowerCase()===`false`?n=!1:e.toLowerCase()===`indeterminate`&&(n=void 0),n===t.data?void 0:{...t,data:n}}};function tl(e,t,n,r){if(!n&&t===null)return;let{ctx:i,hoverAmount:a,theme:o,rect:s,highlighted:c,hoverX:l,hoverY:u,cell:{contentAlign:d}}=e,{x:f,y:p,width:m,height:h}=s,g=.35,_=n?1-g+g*a:.4;t===null&&(_*=a),_!==0&&(i.globalAlpha=_,Na(i,o,t,f,p,m,h,c,l,u,r,d),i.globalAlpha=1)}St();var nl=xt(`div`)({name:`BubblesOverlayEditorStyle`,class:`gdg-b1ygi5by`,propsAsIs:!1}),rl=e=>{let{bubbles:t}=e;return L.createElement(nl,null,t.map((e,t)=>L.createElement(`div`,{key:t,className:`boe-bubble`},e)),L.createElement(`textarea`,{className:`gdg-input`,autoFocus:!0}))};ct();var il={getAccessibilityString:e=>un(e.data),kind:I.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(e,t,n)=>t.data.reduce((t,n)=>e.measureText(n).width+t+20,0)+2*n.cellHorizontalPadding-4,draw:e=>ol(e,e.cell.data),provideEditor:()=>e=>{let{value:t}=e;return L.createElement(rl,{bubbles:t.data})},onPaste:()=>void 0},al=4;function ol(e,t){let{rect:n,theme:r,ctx:i,highlighted:a}=e,{x:o,y:s,width:c,height:l}=n,u=al,d=o+r.cellHorizontalPadding,f=[];for(let e of t){if(d>o+c)break;let t=Jr(e,i,r.baseFontFull).width;f.push({x:d,width:t}),d+=t+16+u}i.beginPath();for(let e of f)si(i,e.x,s+(l-20)/2,e.width+16,20,r.roundingRadius??20/2);i.fillStyle=a?r.bgBubbleSelected:r.bgBubble,i.fill();for(let[e,n]of f.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(t[e],n.x+8,s+l/2+Xr(i,r))}St();var sl=xt(`div`)({name:`DrilldownOverlayEditorStyle`,class:`gdg-d4zsq0x`,propsAsIs:!1}),cl=e=>{let{drilldowns:t}=e;return L.createElement(sl,null,t.map((e,t)=>L.createElement(`div`,{key:t,className:`doe-bubble`},e.img!==void 0&&L.createElement(`img`,{src:e.img}),L.createElement(`div`,null,e.text))))};ct();var ll={getAccessibilityString:e=>un(e.data.map(e=>e.text)),kind:I.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(e,t,n)=>t.data.reduce((t,n)=>e.measureText(n.text).width+t+20+(n.img===void 0?0:18),0)+2*n.cellHorizontalPadding-4,draw:e=>pl(e,e.cell.data),provideEditor:()=>e=>{let{value:t}=e;return L.createElement(cl,{drilldowns:t.data})},onPaste:()=>void 0},ul=4,dl={};function fl(e,t,n,r){let i=Math.ceil(window.devicePixelRatio),a=n-10,o=n*i,s=r+5,c=r*3,l=(c+10)*i,u=`${e},${t},${i},${n}`;if(dl[u]!==void 0)return{el:dl[u],height:o,width:l,middleWidth:4*i,sideWidth:s*i,padding:5*i,dpr:i};let d=document.createElement(`canvas`),f=d.getContext(`2d`);return f===null?null:(d.width=l,d.height=o,f.scale(i,i),dl[u]=d,f.beginPath(),si(f,5,5,c,a,r),f.shadowColor=`rgba(24, 25, 34, 0.4)`,f.shadowBlur=1,f.fillStyle=e,f.fill(),f.shadowColor=`rgba(24, 25, 34, 0.3)`,f.shadowOffsetY=1,f.shadowBlur=5,f.fillStyle=e,f.fill(),f.shadowOffsetY=0,f.shadowBlur=0,f.shadowBlur=0,f.beginPath(),si(f,5.5,5.5,c,a,r),f.strokeStyle=t,f.lineWidth=1,f.stroke(),{el:d,height:o,width:l,sideWidth:s*i,middleWidth:r*i,padding:5*i,dpr:i})}function pl(e,t){let{rect:n,theme:r,ctx:i,imageLoader:a,col:o,row:s}=e,{x:c,width:l}=n,u=r.baseFontFull,d=ri(i,u),f=Math.min(n.height,Math.max(16,Math.ceil(d*r.lineHeight)*2)),p=Math.floor(n.y+(n.height-f)/2),m=f-10,h=ul,g=c+r.cellHorizontalPadding,_=r.roundingRadius??6,v=fl(r.bgCell,r.drilldownBorder,f,_),y=[];for(let e of t){if(g>c+l)break;let t=Jr(e.text,i,u).width,n=0;e.img!==void 0&&a.loadOrGetImage(e.img,o,s)!==void 0&&(n=m-8+4);let r=t+n+16;y.push({x:g,width:r}),g+=r+h}if(v!==null){let{el:e,height:t,middleWidth:n,sideWidth:r,width:a,dpr:o,padding:s}=v,c=r/o,l=s/o;for(let o of y){let s=Math.floor(o.x),u=Math.floor(o.width),d=u-(c-l)*2;i.imageSmoothingEnabled=!1,i.drawImage(e,0,0,r,t,s-l,p,c,f),d>0&&i.drawImage(e,r,0,n,t,s+(c-l),p,d,f),i.drawImage(e,a-r,0,r,t,s+u-(c-l),p,c,f),i.imageSmoothingEnabled=!0}}i.beginPath();for(let[e,n]of y.entries()){let c=t[e],l=n.x+8;if(c.img!==void 0){let e=a.loadOrGetImage(c.img,o,s);if(e!==void 0){let t=m-8,n=0,a=0,o=e.width,s=e.height;o>s?(n+=(o-s)/2,o=s):s>o&&(a+=(s-o)/2,s=o),i.beginPath(),si(i,l,p+f/2-t/2,t,t,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(e,n,a,o,s,l,p+f/2-t/2,t,t),i.restore(),l+=t+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(c.text,l,p+f/2+Xr(i,r))}}ct();var ml={getAccessibilityString:e=>e.data.join(`, `),kind:I.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:e=>gl(e,e.cell.displayData??e.cell.data,e.cell.rounding??e.theme.roundingRadius??4,e.cell.contentAlign),measure:(e,t)=>t.data.length*50,onDelete:e=>({...e,data:[]}),provideEditor:()=>e=>{let{value:t,onFinishedEditing:n,imageEditorOverride:r}=e,i=r??pn;return L.createElement(i,{urls:t.data,canWrite:t.readonly!==!1,onCancel:n,onChange:e=>{n({...t,data:[e]})}})},onPaste:(e,t)=>{e=e.trim();let n=e.split(`,`).map(e=>{try{return new URL(e),e}catch{return}}).filter(e=>e!==void 0);if(!(n.length===t.data.length&&n.every((e,n)=>e===t.data[n])))return{...t,data:n}}},hl=4;function gl(e,t,n,r){let{rect:i,col:a,row:o,theme:s,ctx:c,imageLoader:l}=e,{x:u,y:d,height:f,width:p}=i,m=f-s.cellVerticalPadding*2,h=[],g=0;for(let e=0;e0&&(c.beginPath(),si(c,_,d+s.cellVerticalPadding,t,m,n),c.save(),c.clip()),c.drawImage(e,_,d+s.cellVerticalPadding,t,m),n>0&&c.restore(),_+=t+hl}}vr(),ct();function _l(e,t){let n=e*49632+t*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}var vl={getAccessibilityString:()=>``,kind:I.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:e=>{let{cell:t,col:n,row:r,ctx:i,rect:a,theme:o}=e;if(t.skeletonWidth===void 0||t.skeletonWidth===0)return;let s=t.skeletonWidth;t.skeletonWidthVariability!==void 0&&t.skeletonWidthVariability>0&&(s+=Math.round(_l(n,r)*t.skeletonWidthVariability));let c=o.cellHorizontalPadding,l=t.skeletonHeight??Math.min(18,a.height-2*o.cellVerticalPadding);si(i,a.x+c,a.y+(a.height-l)/2,s,l,o.roundingRadius??3),i.fillStyle=fr(o.textDark,.1),i.fill()},onPaste:()=>void 0};St();var yl=xt(`div`)({name:`MarkdownOverlayEditorStyle`,class:`gdg-m1pnx84e`,propsAsIs:!1,vars:{"m1pnx84e-0":[e=>e.targetWidth,`px`]}}),bl=e=>{let{value:t,onChange:n,forceEditMode:r,createNode:i,targetRect:a,onFinish:o,validatedSelection:s}=e,c=t.data,l=t.readonly===!0,[u,d]=L.useState(c===``||r),f=L.useCallback(()=>{d(e=>!e)},[]),p=c?`gdg-ml-6`:``;return u?L.createElement(yl,{targetWidth:a.width-20},L.createElement(lr,{autoFocus:!0,highlight:!1,validatedSelection:s,value:c,onKeyDown:e=>{e.key===`Enter`&&e.stopPropagation()},onChange:n}),L.createElement(`div`,{className:`gdg-edit-icon gdg-checkmark-hover ${p}`,onClick:()=>o(t)},L.createElement(nn,null))):L.createElement(yl,{targetWidth:a.width},L.createElement(ir,{contents:c,createNode:i}),!l&&L.createElement(L.Fragment,null,L.createElement(`div`,{className:`spacer`}),L.createElement(`div`,{className:`gdg-edit-icon gdg-edit-hover ${p}`,onClick:f},L.createElement(tn,null))),L.createElement(`textarea`,{className:`gdg-md-edit-textarea gdg-input`,autoFocus:!0}))};ct();var xl={getAccessibilityString:e=>e.data?.toString()??``,kind:I.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:ti,measure:(e,t,n)=>{let r=t.data.split(` `)[0];return e.measureText(r).width+2*n.cellHorizontalPadding},draw:e=>oi(e,e.cell.data,e.cell.contentAlign),onDelete:e=>({...e,data:``}),provideEditor:()=>e=>{let{onChange:t,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:a,forceEditMode:o,validatedSelection:s}=e;return L.createElement(bl,{onFinish:i,targetRect:r,value:n,validatedSelection:s,onChange:e=>t({...n,data:e.target.value}),forceEditMode:o,createNode:a})},onPaste:(e,t)=>e===t.data?void 0:{...t,data:e}};ct();var Sl={getAccessibilityString:e=>e.row.toString(),kind:at.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:Cl,measure:()=>44,draw:e=>Tl(e,e.cell.row,e.cell.checked,e.cell.markerKind,e.cell.drawHandle,e.cell.checkboxStyle),onClick:e=>{let{bounds:t,cell:n,posX:r,posY:i}=e,{width:a,height:o}=t,s=n.drawHandle?7+(a-7)/2:a/2,c=o/2;if(Math.abs(r-s)<=10&&Math.abs(i-c)<=10)return{...n,checked:!n.checked}},onPaste:()=>void 0};function Cl(e,t){let{ctx:n,theme:r}=e,i=r.markerFontFull,a=t??{};return a?.font!==i&&(n.font=i,a.font=i),a.deprep=wl,n.textAlign=`center`,a}function wl(e){let{ctx:t}=e;t.textAlign=`start`}function Tl(e,t,n,r,i,a){let{ctx:o,rect:s,hoverAmount:c,theme:l}=e,{x:u,y:d,width:f,height:p}=s,m=n?1:r===`checkbox-visible`?.6+.4*c:c;if(r!==`number`&&m>0){o.globalAlpha=m;let e=7*(n?c:1);if(Na(o,l,n,i?u+e:u,d,i?f-e:f,p,!0,void 0,void 0,18,`center`,a),i){o.globalAlpha=c,o.beginPath();for(let e of[3,6])for(let t of[-5,-1,3])o.rect(u+e,d+p/2+t,2,2);o.fillStyle=l.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r===`number`||r===`both`&&!n){let e=t.toString(),n=l.markerFontFull,i=u+f/2;r===`both`&&c!==0&&(o.globalAlpha=1-c),o.fillStyle=l.textLight,o.font=n,o.fillText(e,i,d+p/2+Xr(o,n)),c!==0&&(o.globalAlpha=1)}}ct();var El={getAccessibilityString:()=>``,kind:at.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:e=>Dl(e,e.cell.hint,e.cell.icon),onPaste:()=>void 0};function Dl(e,t,n){let{ctx:r,rect:i,hoverAmount:a,theme:o,spriteManager:s}=e,{x:c,y:l,width:u,height:d}=i;r.beginPath(),r.globalAlpha=a,r.rect(c+1,l+1,u,d-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();let f=t!==``,p=0;if(n!==void 0){let e=d-8,t=c+8/2,i=l+8/2;s.drawSprite(n,`normal`,r,t,i,e,o,f?1:a),p=e}else{p=24;let e=f?12:a*12,t=f?0:(1-a)*12*.5,n=o.cellHorizontalPadding+4;e>0&&(r.moveTo(c+n+t,l+d/2),r.lineTo(c+n+t+e,l+d/2),r.moveTo(c+n+t+e*.5,l+d/2-e*.5),r.lineTo(c+n+t+e*.5,l+d/2+e*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap=`round`,r.stroke())}r.fillStyle=o.textMedium,r.fillText(t,p+c+o.cellHorizontalPadding+.5,l+d/2+Xr(r,o)),r.beginPath()}var Ol,kl=o((()=>{St(),Ol=xt(`div`)({name:`NumberOverlayEditorStyle`,class:`gdg-n15fjm3e`,propsAsIs:!1})}));function Al(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i=s?i+=Wl(`0`,o-s):i=(i.substring(0,o)||`0`)+`.`+i.substring(o),n+i}function Kl(e,t,n){if([``,`-`].indexOf(e)!==-1)return e;var r=(e.indexOf(`.`)!==-1||n)&&t,i=Vl(e),a=i.beforeDecimal,o=i.afterDecimal,s=i.hasNegation,c=parseFloat(`0.`+(o||`0`)),l=(o.length<=t?`0.`+o:c.toFixed(t)).split(`.`),u=a;a&&Number(l[0])&&(u=a.split(``).reverse().reduce(function(e,t,n){return e.length>n?(Number(e[0])+Number(t)).toString()+e.substring(1,e.length):t+e},l[0]));var d=Ul(l[1]||``,t,n),f=s?`-`:``,p=r?`.`:``;return``+f+u+p+d}function ql(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var n=e.createTextRange();return n.move(`character`,t),n.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}function Jl(e,t,n){return Math.min(Math.max(e,t),n)}function Yl(e){return Math.max(e.selectionStart,e.selectionEnd)}function Xl(){return typeof navigator<`u`&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Zl(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:``}}function Ql(e){var t=e.currentValue,n=e.formattedValue,r=e.currentValueIndex,i=e.formattedValueIndex;return t[r]===n[i]}function $l(e,t,n,r,i,a,o){o===void 0&&(o=Ql);var s=i.findIndex(function(e){return e}),c=e.slice(0,s);!t&&!n.startsWith(c)&&(t=c,n=c+n,r+=c.length);for(var l=n.length,u=e.length,d={},f=Array(l),p=0;p0&&f[g]===-1;)g--;var v=g===-1||f[g]===-1?0:f[g]+1;return v>_?_:r-v<_-r?v:_}function eu(e,t,n,r){var i=e.length;if(t=Jl(t,0,i),r===`left`){for(;t>=0&&!n[t];)t--;t===-1&&(t=n.indexOf(!0))}else{for(;t<=i&&!n[t];)t++;t>i&&(t=n.lastIndexOf(!0))}return t===-1&&(t=i),t}function tu(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),n=0,r=t.length;nC.length-o.length||SD||d>e.length-o.length)&&(E=d),e=e.substring(0,E),e=cu(y?`-`+e:e,i),e=(e.match(lu(m,!0))||[]).join(``);var O=e.indexOf(m);e=e.replace(new RegExp(Ll(m),`g`),function(e,t){return t===O?`.`:``});var k=Vl(e,i),A=k.beforeDecimal,j=k.afterDecimal,M=k.addNegation;return l.end-l.startAn error Prefix can't start with '-' when allowNegative is true. prefix: `+i+` allowNegative: `+a+` - `),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function mu(e){e=pu(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,i=e.onKeyDown;i===void 0&&(i=jl);var a=e.onBlur;a===void 0&&(a=jl);var o=e.thousandSeparator,s=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l=``);var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,p=e.onValueChange,m=Al(e,[`decimalSeparator`,`allowedDecimalSeparators`,`thousandsGroupStyle`,`suffix`,`allowNegative`,`allowLeadingZeros`,`onKeyDown`,`onBlur`,`thousandSeparator`,`decimalScale`,`fixedDecimalScale`,`prefix`,`defaultValue`,`value`,`valueIsNumericString`,`onValueChange`]),h=su(e),g=h.decimalSeparator,_=h.allowedDecimalSeparators,v=function(t){return ou(t,e)},y=function(t,n){return du(t,n,e)},b=Pl(d)?u:d,x=f??uu(b,l,t);Pl(d)?Pl(u)||(x||=typeof u==`number`):x||=typeof d==`number`;var S=function(e){return Il(e)?e:(typeof e==`number`&&(e=Gl(e)),x&&typeof s==`number`?Kl(e,s,!!c):e)},C=nu(S(d),S(u),!!x,v,y,p),w=C[0],T=w.numAsString,E=w.formattedValue,D=C[1];return Object.assign(Object.assign({},m),{value:E,valueIsNumericString:!1,isValidInputCharacter:function(e){return e===g||Nl(e)},isCharacterSame:function(e){var t=e.currentValue,n=e.lastValue,r=e.formattedValue,i=e.currentValueIndex,a=e.formattedValueIndex,o=t[i],u=r[a],f=vu(n,t).to,p=function(e){return y(e).indexOf(`.`)+l.length};return d===0&&c&&s&&t[f.start]===g&&p(t)a?!1:i>=f.start&&i{gu=u(f()),(function(e){e.event=`event`,e.props=`prop`})(_u||={}),vu=Ml(function(e,t){for(var n=0,r=0,i=e.length,a=t.length;e[n]===t[n]&&nn&&i-r>n;)r++;return{from:{start:n,end:i-r},to:{start:n,end:a-r}}}),yu=function(e,t){var n=Math.min(e.selectionStart,t);return{from:{start:n,end:e.selectionEnd},to:{start:n,end:t}}}})),xu=c({default:()=>Tu});function Su(){return Intl.NumberFormat()?.formatToParts(1.1)?.find(e=>e.type===`decimal`)?.value??`.`}function Cu(){return Su()===`.`?`,`:`.`}var wu,Tu,Eu=o((()=>{wu=u(f(),1),kl(),bu(),Tu=e=>{let{value:t,onChange:n,disabled:r,highlight:i,validatedSelection:a,fixedDecimals:o,allowNegative:s,thousandSeparator:c,decimalSeparator:l}=e,u=wu.useRef();return wu.useLayoutEffect(()=>{if(a!==void 0){let e=typeof a==`number`?[a,null]:a;u.current?.setSelectionRange(e[0],e[1])}},[a]),wu.createElement(Ol,null,wu.createElement(hu,{autoFocus:!0,getInputRef:u,className:`gdg-input`,onFocus:e=>e.target.setSelectionRange(i?0:e.target.value.length,e.target.value.length),disabled:r===!0,decimalScale:o,allowNegative:s,thousandSeparator:c??Cu(),decimalSeparator:l??Su(),value:Object.is(t,-0)?`-`:t??``,onValueChange:n}))}}));ct();var Du=L.lazy(async()=>await Dc(()=>Promise.resolve().then(()=>(Eu(),xu)),void 0,import.meta.url)),Ou={getAccessibilityString:e=>e.data?.toString()??``,kind:I.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:ti,draw:e=>oi(e,e.cell.displayData,e.cell.contentAlign),measure:(e,t,n)=>e.measureText(t.displayData).width+n.cellHorizontalPadding*2,onDelete:e=>({...e,data:void 0}),provideEditor:()=>e=>{let{isHighlighted:t,onChange:n,value:r,validatedSelection:i}=e;return L.createElement(L.Suspense,{fallback:null},L.createElement(Du,{highlight:t,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:e=>n({...r,data:Number.isNaN(e.floatValue??0)?0:e.floatValue})}))},onPaste:(e,t,n)=>{let r=typeof n.rawValue==`number`?n.rawValue:Number.parseFloat(typeof n.rawValue==`string`?n.rawValue:e);if(!(Number.isNaN(r)||t.data===r))return{...t,data:r,displayData:n.formattedString??t.displayData}}};ct();var ku={getAccessibilityString:()=>``,measure:()=>108,kind:I.Protected,needsHover:!1,needsHoverPosition:!1,draw:Au,onPaste:()=>void 0};function Au(e){let{ctx:t,theme:n,rect:r}=e,{x:i,y:a,height:o}=r;t.beginPath();let s=2.5,c=i+n.cellHorizontalPadding+s,l=a+o/2,u=Math.cos(Xt(30))*s,d=Math.sin(Xt(30))*s;for(let e=0;e<12;e++)t.moveTo(c,l-s),t.lineTo(c,l+s),t.moveTo(c+u,l-d),t.lineTo(c-u,l+d),t.moveTo(c-u,l-d),t.lineTo(c+u,l+d),c+=8;t.lineWidth=1.1,t.lineCap=`square`,t.strokeStyle=n.textLight,t.stroke()}ct();var ju={getAccessibilityString:e=>e.data?.toString()??``,kind:I.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(e,t)=>ti(e,t,e.theme.textLight),draw:e=>oi(e,e.cell.data,e.cell.contentAlign),measure:(e,t,n)=>e.measureText(t.data).width+n.cellHorizontalPadding*2,provideEditor:()=>e=>{let{isHighlighted:t,onChange:n,value:r,validatedSelection:i}=e;return L.createElement(lr,{highlight:t,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:e=>n({...r,data:e.target.value})})},onPaste:()=>void 0};ct(),vr();var ree={getAccessibilityString:e=>e.data?.toString()??``,kind:I.Text,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,drawPrep:ti,useLabel:!0,draw:e=>{let{cell:t,hoverAmount:n,hyperWrapping:r,ctx:i,rect:a,theme:o,overrideCursor:s}=e,{displayData:c,contentAlign:l,hoverEffect:u,allowWrapping:d}=t;if(u===!0&&n>0){i.textBaseline=`alphabetic`;let e=o.cellHorizontalPadding,t=o.cellVerticalPadding,r=Jr(c,i,o.baseFontFull,`alphabetic`),l=a.height-t,u=Math.min(l,r.actualBoundingBoxAscent*2.5);i.beginPath(),si(i,a.x+e/2,a.y+(a.height-u)/2+1,r.width+e*3,u-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=fr(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline=`middle`,s?.(`text`)}oi(e,c,l,d,r)},measure:(e,t,n)=>{let r=t.displayData.split(` -`,t.allowWrapping===!0?void 0:1),i=0;for(let t of r)i=Math.max(i,e.measureText(t).width);return i+2*n.cellHorizontalPadding},onDelete:e=>({...e,data:``}),provideEditor:e=>({disablePadding:e.allowWrapping===!0,editor:t=>{let{isHighlighted:n,onChange:r,value:i,validatedSelection:a}=t;return L.createElement(lr,{style:e.allowWrapping===!0?{padding:`3px 8.5px`}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:a,onChange:e=>r({...i,data:e.target.value})})}}),onPaste:(e,t,n)=>e===t.data?void 0:{...t,data:e,displayData:n.formattedString??t.displayData}};St();var Mu=xt(`div`)({name:`UriOverlayEditorStyle`,class:`gdg-u1rrojo`,propsAsIs:!1}),iee=e=>{let{uri:t,onChange:n,forceEditMode:r,readonly:i,validatedSelection:a,preview:o}=e,[s,c]=L.useState(!i&&(t===``||r)),l=L.useCallback(()=>{c(!0)},[]);return s?L.createElement(lr,{validatedSelection:a,highlight:!0,autoFocus:!0,value:t,onChange:n}):L.createElement(Mu,null,L.createElement(`a`,{className:`gdg-link-area`,href:t,target:`_blank`,rel:`noopener noreferrer`},o),!i&&L.createElement(`div`,{className:`gdg-edit-icon`,onClick:l},L.createElement(tn,null)),L.createElement(`textarea`,{className:`gdg-input`,autoFocus:!0}))};ct();function aee(e,t,n,r){let i=n.cellHorizontalPadding,a=t.height/2-e.actualBoundingBoxAscent/2,o=e.width,s=e.actualBoundingBoxAscent;return r===`right`?i=t.width-o-n.cellHorizontalPadding:r===`center`&&(i=t.width/2-o/2),{x:i,y:a,width:o,height:s}}var oee=[Sl,El,el,il,ll,ml,vl,xl,Ou,ku,ju,ree,{getAccessibilityString:e=>e.data?.toString()??``,kind:I.Uri,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:ti,draw:e=>{let{cell:t,theme:n,overrideCursor:r,hoverX:i,hoverY:a,rect:o,ctx:s}=e,c=t.displayData??t.data,l=t.hoverEffect===!0;if(r!==void 0&&l&&i!==void 0&&a!==void 0){let{x:l,y:u,width:d,height:f}=aee(Jr(c,s,n.baseFontFull),o,n,t.contentAlign);if(i>=l-4&&i<=l-4+d+8&&a>=u-4&&a<=u-4+f+8){let i=Xr(s,n.baseFontFull);r(`pointer`);let a=u-i;s.beginPath(),s.moveTo(o.x+l,Math.floor(o.y+a+f+5)+.5),s.lineTo(o.x+l+d,Math.floor(o.y+a+f+5)+.5),s.strokeStyle=n.linkColor,s.stroke(),s.save(),s.fillStyle=e.cellFillColor,oi({...e,rect:{...o,x:o.x-1}},c,t.contentAlign),oi({...e,rect:{...o,x:o.x-2}},c,t.contentAlign),oi({...e,rect:{...o,x:o.x+1}},c,t.contentAlign),oi({...e,rect:{...o,x:o.x+2}},c,t.contentAlign),s.restore()}}s.fillStyle=l?n.linkColor:n.textDark,oi(e,c,t.contentAlign)},onClick:e=>{let{cell:t,bounds:n,posX:r,posY:i,theme:a}=e,o=t.displayData??t.data;if(t.hoverEffect!==!0||t.onClickUri===void 0)return;let s=Yr(o,a.baseFontFull);if(s===void 0)return;let c=aee(s,n,a,t.contentAlign);ba({x:c.x-4,y:c.y-4,width:c.width+8,height:c.height+8},r,i)&&t.onClickUri(e)},measure:(e,t,n)=>e.measureText(t.displayData??t.data).width+n.cellHorizontalPadding*2,onDelete:e=>({...e,data:``}),provideEditor:e=>t=>{let{onChange:n,value:r,forceEditMode:i,validatedSelection:a}=t;return L.createElement(iee,{forceEditMode:r.readonly!==!0&&(i||e.hoverEffect===!0&&e.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:a,readonly:r.readonly===!0,onChange:e=>n({...r,data:e.target.value})})},onPaste:(e,t,n)=>e===t.data?void 0:{...t,data:e,displayData:n.formattedString??t.displayData}}],see=u(s(((e,t)=>{var n=Gt(),r=re(),i=`Expected a function`;function a(e,t,a){var o=!0,s=!0;if(typeof e!=`function`)throw TypeError(i);return r(a)&&(o=`leading`in a?!!a.leading:o,s=`trailing`in a?!!a.trailing:s),n(e,t,{leading:o,maxWait:t,trailing:s})}t.exports=a}))(),1),Nu=[],cee=class extends gi{imageLoaded=()=>void 0;loadedLocations=[];cache={};setCallback(e){this.imageLoaded=e}sendLoaded=(0,see.default)(()=>{this.imageLoaded(new vi(this.loadedLocations)),this.loadedLocations=[]},20);clearOutOfWindow=()=>{let e=Object.keys(this.cache);for(let t of e){let e=this.cache[t],n=!1;for(let t=0;t{o||(o=!0,Nu.length<12?Nu.unshift(a):i||(a.src=``))}},c=new Promise(e=>a.addEventListener(`load`,()=>e(null)));requestAnimationFrame(async()=>{try{a.src=e,await c,await a.decode();let t=this.cache[r];if(t!==void 0&&!o){t.img=a;for(let e of t.cells)this.loadedLocations.push(hi(e));i=!0,this.sendLoaded()}}catch{s.cancel()}}),this.cache[r]=s}loadOrGetImage(e,t,n){let r=e,i=this.cache[r];if(i!==void 0){let e=fi(t,n);return i.cells.includes(e)||i.cells.push(e),i.img}else this.loadImage(e,t,n,r)}},lee=L.forwardRef((e,t)=>{let n=L.useMemo(()=>({...da,...e.headerIcons}),[e.headerIcons]),r=L.useMemo(()=>e.imageWindowLoader??new cee,[e.imageWindowLoader]);return L.createElement(Qc,{...e,renderers:oee,headerIcons:n,ref:t,imageWindowLoader:r})}),Pu=[`all_time`,`today`,`yesterday`,`this_week`,`last_week`,`this_month`,`last_month`,`this_quarter`,`last_quarter`,`this_year`,`last_year`,`ytd`,`ytd_last_year`,`ltm`,`past_week`,`past_month`,`past_year`,`last_n_days`,`next_n_days`,`custom`],Fu=new Set([`last_n_days`,`next_n_days`]),Iu={all_time:`all time`,today:`today`,yesterday:`yesterday`,this_week:`this week`,last_week:`last week`,this_month:`this month`,last_month:`last month`,this_quarter:`this quarter`,last_quarter:`last quarter`,this_year:`this year`,last_year:`last year`,ytd:`year to date`,ytd_last_year:`last year to date`,ltm:`the last 12 months`,past_week:`the past week`,past_month:`the past month`,past_year:`the past year`,last_n_days:`the last {n} days`,next_n_days:`the next {n} days`,custom:`a custom range`},Lu=[`today`,`yesterday`,`one_week_ago`,`one_month_ago`,`n_days_ago`,`exact`],uee=new Set([`today`,`yesterday`,`one_week_ago`,`one_month_ago`]),Ru={today:`today`,yesterday:`yesterday`,one_week_ago:`one week ago`,one_month_ago:`one month ago`,n_days_ago:`{n} days ago`,exact:`an exact date`};function zu(e){let t=String(e??``).trim().slice(0,10);if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return null;let n=new Date(`${t}T00:00:00Z`);return Number.isNaN(n.getTime())?null:n}function Bu(e){return e.toISOString().slice(0,10)}function Vu(e,t){return new Date(e.getTime()+t*864e5)}function Hu(e){return[e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate()]}function Uu(e,t,n){return new Date(Date.UTC(e,t-1,n))}function Wu(e){let[t,n]=Hu(e);return Uu(t,n,1)}function Gu(e){let[t,n]=Hu(e);return n===12?Uu(t,12,31):Vu(Uu(t,n+1,1),-1)}function Ku(e){return(e.getUTCDay()+6)%7}function qu(e){let[t,n]=Hu(e);return Uu(t,3*Math.floor((n-1)/3)+1,1)}function dee(e,t){return new Date(Date.UTC(t===12?e+1:e,t===12?0:t,1)-864e5).getUTCDate()}function Ju(e,t){let[n,r,i]=Hu(e),a=n*12+(r-1)+t,o=Math.floor(a/12),s=a-o*12+1;return Uu(o,s,Math.min(i,dee(o,s)))}function Yu(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.kind;if(!Pu.includes(n))return null;let r={kind:n};if(Fu.has(n)){let e=Number(t.n);if(!Number.isInteger(e)||e<1||e>3650)return null;r.n=e}if(n===`custom`){let e=zu(t.from),n=zu(t.to);if(!e&&!n)return null;e&&n&&e>n&&([e,n]=[n,e]),e&&(r.from=Bu(e)),n&&(r.to=Bu(n))}return r}function Xu(e,t){let n=Yu(e);if(!n)return null;let r=zu(t);if(!r)throw Error("resolveWindow() needs an explicit `today`");switch(n.kind){case`all_time`:return[null,null];case`today`:return[Bu(r),Bu(r)];case`yesterday`:{let e=Vu(r,-1);return[Bu(e),Bu(e)]}case`this_week`:{let e=Vu(r,-Ku(r));return[Bu(e),Bu(Vu(e,6))]}case`last_week`:{let e=Vu(r,-Ku(r)-7);return[Bu(e),Bu(Vu(e,6))]}case`this_month`:return[Bu(Wu(r)),Bu(Gu(r))];case`last_month`:{let e=Vu(Wu(r),-1);return[Bu(Wu(e)),Bu(e)]}case`this_quarter`:{let e=qu(r),[t,n]=Hu(e);return[Bu(e),Bu(Gu(Uu(t,n+2,1)))]}case`last_quarter`:{let e=Vu(qu(r),-1);return[Bu(qu(e)),Bu(e)]}case`this_year`:{let[e]=Hu(r);return[Bu(Uu(e,1,1)),Bu(Uu(e,12,31))]}case`last_year`:{let[e]=Hu(r);return[Bu(Uu(e-1,1,1)),Bu(Uu(e-1,12,31))]}case`ytd`:{let[e]=Hu(r);return[Bu(Uu(e,1,1)),Bu(r)]}case`ytd_last_year`:{let[e]=Hu(r);return[Bu(Uu(e-1,1,1)),Bu(Ju(r,-12))]}case`ltm`:return[Bu(Vu(r,-364)),Bu(r)];case`past_week`:return[Bu(Vu(r,-6)),Bu(r)];case`past_month`:return[Bu(Vu(Ju(r,-1),1)),Bu(r)];case`past_year`:return[Bu(Vu(Ju(r,-12),1)),Bu(r)];case`last_n_days`:return[Bu(Vu(r,-(n.n-1))),Bu(r)];case`next_n_days`:return[Bu(r),Bu(Vu(r,n.n-1))];case`custom`:return[n.from??null,n.to??null]}}function Zu(e){let t=Yu(e);return t?Iu[t.kind].replace(`{n}`,String(t.n??``)):`an invalid range`}function Qu(e,t,n){let r=e||`exact`;if(!Lu.includes(r))return null;let i=zu(n);if(!i)throw Error("resolveAnchor() needs an explicit `today`");switch(r){case`today`:return Bu(i);case`yesterday`:return Bu(Vu(i,-1));case`one_week_ago`:return Bu(Vu(i,-7));case`one_month_ago`:return Bu(Ju(i,-1));case`n_days_ago`:{let e=String(t??``).trim();if(!/^[0-9]+$/.test(e))return null;let n=Number(e);return n>3650?null:Bu(Vu(i,-n))}default:{let e=zu(t);return e?Bu(e):null}}}var $u=[`text`,`select`,`multiselect`,`user`,`int`,`currency`,`pct`,`date`,`checkbox`,`phone`,`email`,`url`,`rating`,`created_time`,`formula`],fee=new Set([`formula`,`created_time`]);function ed(e){return e===`select`||e===`user`||e===`multiselect`}function pee(e){let t=new Set,n=[];for(let r of e.split(` -`)){let e=r.trim();if(!e)continue;let i=e.toLowerCase();t.has(i)||(t.add(i),n.push(e))}return n.slice(0,50)}function td(e,t,n=120){let r=Math.max(1,Math.floor(n)),i=e=>e.trim().replace(/\s+/g,` `),a=(i(e)||`Untitled`).slice(0,r).trimEnd(),o=new Set(t.map(e=>i(e).toLocaleLowerCase()));if(!o.has(a.toLocaleLowerCase()))return a;for(let e=2;;e+=1){let t=` ${e}`,n=a.slice(0,Math.max(0,r-t.length)).trimEnd(),i=n?`${n}${t}`:String(e).slice(-r);if(!o.has(i.toLocaleLowerCase()))return i}}function mee(e){return e.filter(e=>e.filterable!==!1)}function nd(e){return Array.isArray(e.options)?e.options:[]}function hee(e){return typeof e.formula==`string`&&e.formula.trim()!==``?e.formula:void 0}function rd(e){let t=typeof e.max==`number`&&Number.isFinite(e.max)?Math.round(e.max):5;return Math.max(2,Math.min(10,t))}var gee=[`grid`,`chart`,`dashboard`,`list`,`calendar`,`kanban`,`map`,`timeseries`],_ee={dashboard:`chart`};function vee(e){return _ee[e]??e}var id=[`week`,`month`,`quarter`,`year`],ad=[`abs`,`pct`,`yoy`,`ytd`],yee=[`note`,`formula`],bee=/^[A-Za-z0-9_ .+\-*/()[\]]*$/;function xee(e){let t=e.bucket===void 0||id.includes(e.bucket),n=e.span,r;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.lastN;if(typeof e==`number`&&Number.isFinite(e)){let t=Math.round(e);t>=1&&t<=120&&(r={lastN:t})}}let i=e.span===void 0?r===void 0:!!r&&r.lastN===n?.lastN;if(t&&i)return e;let a={...e};return t||delete a.bucket,i||(r?a.span=r:delete a.span),a}function od(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(typeof t.mode!=`string`||!gee.includes(t.mode))return;let n={mode:vee(t.mode)};for(let e of[`dateField`,`stackField`,`titleField`,`colorField`,`sizeField`]){let r=t[e];typeof r==`string`&&r!==``&&(n[e]=r)}if(Array.isArray(t.charts)){let e=t.charts.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`).map(xee);e.length&&(n.charts=e.slice(0,12))}if(t.kanbanClamp===!1&&(n.kanbanClamp=!1),(t.calendarMode===`records`||t.calendarMode===`summary`)&&(n.calendarMode=t.calendarMode),Array.isArray(t.calendarMetrics)){let e=[];for(let n of t.calendarMetrics){if(!n||typeof n!=`object`)continue;let t=n;typeof t.id!=`string`||!t.id||typeof t.field!=`string`||!t.field||typeof t.agg!=`string`||!t.agg||e.push({id:t.id,field:t.field,agg:t.agg})}e.length&&(n.calendarMetrics=e.slice(0,4))}if(id.includes(t.tsBucket)&&(n.tsBucket=t.tsBucket),t.tsSpan&&typeof t.tsSpan==`object`&&!Array.isArray(t.tsSpan)){let e=t.tsSpan,r={};if(typeof e.from==`string`&&e.from&&(r.from=e.from),typeof e.to==`string`&&e.to&&(r.to=e.to),typeof e.lastN==`number`&&Number.isFinite(e.lastN)){let t=Math.round(e.lastN);t>=1&&t<=120&&(r.lastN=t)}(r.from||r.to||r.lastN!=null)&&(n.tsSpan=r)}if(Array.isArray(t.tsFields)){let e=t.tsFields.filter(e=>typeof e==`string`&&e!==``);e.length&&(n.tsFields=e.slice(0,12))}if(Array.isArray(t.tsDeltas)){let e=new Set,r=[];for(let n of t.tsDeltas)typeof n!=`string`||!ad.includes(n)||e.has(n)||(e.add(n),r.push(n));r.length&&(n.tsDeltas=r.slice(0,ad.length))}if(t.tsGridlines===!1&&(n.tsGridlines=!1),t.tsSparkline===!0&&(n.tsSparkline=!0),Array.isArray(t.tsRows)){let e=[],r=new Set;for(let n of t.tsRows){if(!n||typeof n!=`object`)continue;let t=n;if(typeof t.id!=`string`||!t.id||t.id.length>40||r.has(t.id)||typeof t.kind!=`string`||!yee.includes(t.kind)||typeof t.label!=`string`||t.label.length>120)continue;r.add(t.id);let i={id:t.id,kind:t.kind,label:t.label};i.kind===`formula`&&typeof t.expr==`string`&&t.expr.length<=200&&bee.test(t.expr)&&(i.expr=t.expr),e.push(i)}e.length&&(n.tsRows=e.slice(0,12))}if(t.tsStyles&&typeof t.tsStyles==`object`&&!Array.isArray(t.tsStyles)){let e={},r=0;for(let[n,i]of Object.entries(t.tsStyles)){if(r>=200)break;if(!n||!i||typeof i!=`object`||Array.isArray(i))continue;let t=i,a={};t.bold===!0&&(a.bold=!0),t.line===!0&&(a.line=!0),!(!a.bold&&!a.line)&&(e[n]=a,r+=1)}r&&(n.tsStyles=e)}if(!(n.mode===`grid`&&!n.dateField&&!n.stackField&&!n.titleField&&!n.colorField&&!n.sizeField&&!n.charts&&n.kanbanClamp===void 0&&!n.calendarMode&&!n.calendarMetrics&&!n.tsBucket&&!n.tsSpan&&!n.tsFields&&!n.tsDeltas&&n.tsGridlines===void 0&&n.tsSparkline===void 0&&!n.tsRows&&!n.tsStyles))return n}function sd(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.round(e);if(!(t<=1))return Math.min(8,t)}function See(e,t){if(e.source!==`overlay`||fee.has(e.type))return!1;let n=e.permissions?.edit??`everyone`;return n===`everyone`?!0:t?t.isAdmin?!0:n===`creator`&&e.createdBy===t.name:!1}function cd(e){return e===`currency`||e===`int`||e===`pct`||e===`rating`||e===`formula`}function ld(e){return e===`date`||e===`created_time`}function ud(e,t){return cd(e)?t===`asc`?`1 → 9`:`9 → 1`:ld(e)?t===`asc`?`Oldest → Newest`:`Newest → Oldest`:t===`asc`?`A → Z`:`Z → A`}function Cee(e,t){return e.type===`status`||e.type===`select`||e.type===`multiselect`||e.type===`checkbox`||e.type===`text`&&e.source!==`overlay`&&e.key!==t}var wee=[`topN`,`bottomN`,`inTopPct`,`inBottomPct`,`aboveAvg`,`belowAvg`,`inQuartile`,`inDecile`];function dd(e){return wee.includes(e)}var Tee=[`contains`,`doesNotContain`,`eq`,`neq`,`isEmpty`,`isNotEmpty`,`gt`,`gte`,`lt`,`lte`,`between`,`within`,`topN`,`bottomN`,`inTopPct`,`inBottomPct`,`aboveAvg`,`belowAvg`,`inQuartile`,`inDecile`],fd=new Set([`isEmpty`,`isNotEmpty`,`aboveAvg`,`belowAvg`]),pd=`__cohort__`;function Eee(e){return!yd(e)&&e.colId===`__cohort__`}var Dee=[`anyOf`,`allOf`,`noneOf`],Oee={eq:`anyOf`,neq:`noneOf`};function md(e){return Dee.includes(e)?e:Oee[e]??`anyOf`}function hd(e){let t=[];for(let n of String(e??``).split(`,`)){let e=n.trim();if(!(e===``||t.includes(e))&&(t.push(e),t.length>=20))break}return t}var kee=[`avg`,`median`,`p10`,`p25`,`p75`,`p90`],Aee={avg:`the average`,median:`the median`,p10:`the bottom 10%`,p25:`the bottom quartile`,p75:`the top quartile`,p90:`the top 10%`};function gd(e){return e&&e.kind!==`stat`?e.colId:void 0}function jee(e){return e?e.kind===`stat`?kee.includes(e.stat):e.colId?e.kind===`measure`?Yu(e.window)!=null:e.kind===`field`:!1:!1}function _d(e){return e.colId===`__cohort__`?hd(e.value).length>0:fd.has(e.op)?!0:e.op===`within`?Yu(e.dateWindow)!=null:e.rhs?jee(e.rhs):e.dateMode&&uee.has(e.dateMode)?!0:e.op===`between`?e.value!==``&&e.value2!=null&&e.value2!==``:e.value!==``}var Mee=[`gte`,`gt`,`lte`,`lt`,`eq`,`neq`],Nee=[`gte`,`gt`,`lte`,`lt`];function vd(e){return!yd(e)&&e.window!=null}function yd(e){return e!=null&&Array.isArray(e.children)}function bd(e){return Array.isArray(e?.nodes)?e.nodes:[]}function xd(e){return e?.conj===`or`?`or`:`and`}var Pee=new Set([`all-customers`]),Fee={key:`customer_data`,scope:`customer`,rowsPath:`customers`,noun:`customer`,nouns:`customers`,measures:!0},Iee={key:`product_data`,scope:`product`,rowsPath:`products`,noun:`product`,nouns:`products`,measures:!1};function Sd(e){return e===`product`?Iee:Fee}function Cd(e){return Pee.has(e.id)}function wd(e){return e.config?.display?.mode??`grid`}function Td(e){return e.kind===`system`||Cd(e)?!1:!!e.locked}function Ed(e,t){return t?t.isAdmin?!0:!!e.createdBy&&e.createdBy===t.name:!1}var Dd=[`personal`,`collaborative`,`users`],Lee={personal:`Personal`,collaborative:`Collaborative`,users:`Specific users`},Ree={personal:`Only you can change this view.`,collaborative:`Anyone who can see this table can change it.`,users:`Only the people you pick can change it.`};function zee(e,t,n){let r=e&&typeof e==`object`&&!Array.isArray(e)?e:{},i=Dd.includes(r.edit)?r.edit:t;if(i!==`users`)return{edit:i};let a=new Set,o=[];for(let e of(Array.isArray(r.users)?r.users:[]).slice(0,50)){let t=String(e??``).trim();!t||a.has(t.toLowerCase())||n&&!n.includes(t)||(a.add(t.toLowerCase()),o.push(t))}return o.length?{edit:`users`,users:o}:{edit:`personal`}}function Bee(e){return e.permissions?.edit??`collaborative`}function Od(e,t){let n=Bee(e);return n===`collaborative`||!e.createdBy?!0:t?t.isAdmin||e.createdBy&&e.createdBy===t.name?!0:n===`users`&&(e.permissions?.users??[]).includes(t.name):!1}var kd=[`folder`,`star`,`flag`,`tag`,`bookmark`,`grid`,`chart`,`map`,`users`,`clock`,`heart`,`bolt`],Ad=[`neutral`,`blue`,`green`,`yellow`,`red`],jd=`folder`,Md=`neutral`;function Vee(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!kd.includes(t.shape))return;let n=t.shape,r=Ad.includes(t.tone)?t.tone:Md;if(!(n===`folder`&&r===`neutral`))return{shape:n,tone:r}}var Nd=5*1024*1024;function Hee(e){return e?.windowed?`server-windowed`:`whole-book`}var Pd=`/api/v1`,Fd=`same-origin`,Id=`aios:unauthorized`,Ld=`aios:data-error`,Rd=`aios:toast`,zd=`aios:derived-cells`,Bd=`aios:workspace-stale`,Vd=`aios:nav-minimize`;function Hd(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}var Uee=`streamlit:componentReady`,Wee=`streamlit:render`,Gee=`streamlit:setComponentValue`,Kee=`streamlit:setFrameHeight`,Ud=`aios:grid-host-render`;function Wd(e,t){window.parent.postMessage({isStreamlitMessage:!0,type:e,...t},`*`)}function Gd(){return typeof window>`u`||window.parent===window?!1:new URLSearchParams(window.location.search).has(`streamlitUrl`)}function qee(){Gd()&&(window.addEventListener(`message`,e=>{let t=e.data;if(!t||t.type!==Wee)return;window.__AIOS_STREAMLIT_ARGS__=t.args??{},window.dispatchEvent(new CustomEvent(Ud));let n=Number(t.args?.height??760);Wd(Kee,{height:Number.isFinite(n)?n:760})}),Wd(Uee,{apiVersion:1}))}function Jee(){return window.__AIOS_STREAMLIT_ARGS__??null}function Yee(e){return window.addEventListener(Ud,e),()=>window.removeEventListener(Ud,e)}var Kd=[],qd=null;function Xee(e){qd=e}function Jd(e){return Gd()?(Kd.push(e),Kd.length>24&&Kd.shift(),Wd(Gee,{value:{events:[...Kd]},dataType:`json`}),!0):qd?qd(e):!1}function Yd(e){return`${e}:${typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}`}var Xd={"Content-Type":`application/json`};async function Zd(e){try{return await e.json()}catch{return null}}function Qd(e){return e===401?($d.clear(),Hd(Id),!0):!1}var Zee=5*6e4,$d=new Map;function ef(){$d.clear()}async function Qee(e){let t=$d.get(e.rowsPath);if(t&&Date.now()-t.ate.pid===t);n&&Object.assign(n,e)}}return r.ok}catch{return!1}}async function nf(e,t=of){try{let n=await fetch(`${Pd}/grid/timeseries?scope=${encodeURIComponent(t)}`,{method:`POST`,credentials:Fd,headers:Xd,body:JSON.stringify(e)});if(Qd(n.status)||!n.ok)return{payload:null,status:n.status};let r=await Zd(n);return!r||!Array.isArray(r.columns)||!Array.isArray(r.rows)?{payload:null,status:n.status}:{payload:r,status:n.status}}catch{return{payload:null,status:0}}}async function ete(e,t=of){try{let n=await fetch(`${Pd}/grid/calendar_metrics?scope=${encodeURIComponent(t)}`,{method:`POST`,credentials:Fd,headers:Xd,body:JSON.stringify(e)});if(Qd(n.status)||!n.ok)return{payload:null,status:n.status};let r=await Zd(n);return!r||!r.values||typeof r.values!=`object`?{payload:null,status:n.status}:{payload:r,status:n.status}}catch{return{payload:null,status:0}}}var rf=[],af=!1,of=`customer`;function tte(e){of=e}async function sf(){if(af||rf.length===0)return;af=!0;let e=rf;rf=[];let t=!1;try{let n=await fetch(`${Pd}/grid/events`,{method:`POST`,credentials:Fd,headers:Xd,body:JSON.stringify({events:e,scopeKey:of})});Qd(n.status)||(n.ok?nte(await Zd(n)):t=!0)}catch{t=!0}finally{af=!1,t?rf=[...e,...rf].slice(-24):rf.length&&sf()}}function nte(e){let t=e,n=t?.toast;typeof n==`string`&&n.trim()!==``&&Hd(Rd,n.trim()),t?.derived&&typeof t.derived==`object`&&!Array.isArray(t.derived)&&Hd(zd,t.derived);let r=Array.isArray(t?.results)?t.results:[];(t?.rerender===!0||r.some(e=>e?.rerender===!0))&&Hd(Bd)}function rte(e){return rf.push(e),rf.length>24&&rf.shift(),sf(),!0}function ite(){Xee(rte)}function cf(e){return JSON.stringify([e.config?.filters??[],e.config?.filterConj===`or`?`or`:`and`])}function ate(e,t,n){let r=cf(e);return r===cf(t)||r===n?null:r}function lf(e,t){for(let n of e??[]){if(yd(n)){lf(n.children,t);continue}let e=n;vd(n)&&e.id&&t.set(e.id,e)}}function ote(e,t,n,r){if(!t||n==null||r-n>12e4)return e;let i=e,a=t.config?t.config.display:void 0;if(t.config&&JSON.stringify(a??null)!==JSON.stringify(e.config?.display??null)){let t={...e.config};a===void 0?delete t.display:t.display=a,i={...e,config:t}}let o=t.config?t.config.cohortLock:void 0;if(t.config&&o!==i.config?.cohortLock){let e={...i.config};o===void 0?delete e.cohortLock:e.cohortLock=o,i={...i,config:e}}let s=t.config?t.config.filters:void 0;if(!Array.isArray(s)||s.length===0)return i;let c=new Map;if(lf(s,c),c.size===0)return i;let l=new Map;lf(e.config?e.config.filters:void 0,l);let u=!1;for(let[e,t]of c){if(!_d(t))continue;let n=l.get(e);if(!n||!_d(n)){u=!0;break}}return u?{...i,config:{...i.config,filters:s,filterConj:t.config.filterConj??e.config.filterConj}}:i}function uf(e,t){let n=e=>{let n={};for(let[r,i]of Object.entries(e??{}))typeof i==`number`&&t-i<=12e4&&(n[r]=i);return n};return{edited:n(e?.edited),deleted:n(e?.deleted)}}function df(e){if(Array.isArray(e))return e.map(df);if(e&&typeof e==`object`){let t={};for(let n of Object.keys(e).sort()){let r=e[n];r!==void 0&&(t[n]=df(r))}return t}return e}function ff(e){let{createdBy:t,permissions:n,editRequestId:r,labelCorrectedFrom:i,labelCorrectionId:a,...o}=e;return JSON.stringify(df(o))}function ste(e,t,n,r,i){let a=e=>typeof e==`number`&&r-e<=12e4,o=new Map(t.map(e=>[e.key,e])),s=[];for(let t of e){let e=o.get(t.key);if(o.delete(t.key),!a(n?.deleted?.[t.key])){if(!e){s.push(t);continue}if(!i){s.push({...e,...t,note:t.note??e.note});continue}if(t.labelCorrectedFrom===e.label&&t.label!==e.label&&typeof t.labelCorrectionId==`string`&&t.labelCorrectionId===e.editRequestId){s.push(t);continue}if(a(n?.edited?.[t.key])&&ff(e)!==ff(t)){s.push({...e,...t.createdBy==null?{}:{createdBy:t.createdBy}});continue}s.push(t.note==null&&e.note!=null?{...t,note:e.note}:t)}}for(let e of o.values())if(e.custom&&!a(n?.deleted?.[e.key])){if(e.source===`overlay`){s.push(e);continue}(!i||a(n?.edited?.[e.key]))&&s.push(e)}return s}function cte(e,t){let n=e.filter(e=>!(e.pid===t.pid&&e.key===t.key));return n.push(t),n.slice(-64)}function lte(e,t,n){let r=[],i={};for(let a of e){if(a==null||typeof a.pid!=`number`||typeof a.key!=`string`||typeof a.at!=`number`)continue;let e=t(a.pid),o=e?e[a.key]:void 0;String(o??``)!==String(a.value??``)&&(n-a.at>12e4||(r.push(a),i[a.pid]={...i[a.pid],[a.key]:a.value}))}return{keep:r,seeds:i}}function pf(){if(typeof window>`u`)return null;let e=window.__AIOS_GRID__;return e&&Array.isArray(e.rows)&&Array.isArray(e.fields)?e:null}function mf(){let e=Jee()?.payload;return e&&Array.isArray(e.rows)&&Array.isArray(e.fields)?e:null}function hf(e,t){let n={...e,workspace:t};Array.isArray(t.measures)&&(n.measures=t.measures),t.measureSets&&typeof t.measureSets==`object`&&(n.measureSets=t.measureSets),t.viewer&&typeof t.viewer.name==`string`&&(n.viewer=t.viewer),Array.isArray(t.userOptions)&&(n.userOptions=t.userOptions);let r=t.derived;return r&&typeof r==`object`&&Object.keys(r).length>0&&(n.rows=e.rows.map(e=>{let t=r[String(e.pid)];return t?{...e,...t}:e})),n}function gf(){return mf()??pf()}var _f=Gd(),ute=pf()!==null;function vf(e){return`aios-grid-cells:${e}`}function yf(e){try{let t=localStorage.getItem(vf(e)),n=t?JSON.parse(t):null;return Array.isArray(n)?n:[]}catch{return[]}}function bf(e,t){try{localStorage.setItem(vf(e),JSON.stringify(t))}catch{}}function xf(e){let t=e?.workspace?.storageKey;if(!e||!t)return{};let n=new Map(e.rows.map(e=>[e.pid,e])),{keep:r,seeds:i}=lte(yf(t),e=>n.get(e),Date.now());return bf(t,r),i}function dte(e=`customer`){tte(e);let t=Sd(e),[n,r]=(0,L.useState)(()=>gf()),[i,a]=(0,L.useState)(()=>_f?xf(gf()):{}),o=(0,L.useRef)(n);o.current=n,(0,L.useEffect)(()=>{if(_f){let e=()=>{let e=mf();if(!e)return;let t=xf(e);Object.keys(t).length&&a(e=>{let n={...e};for(let[e,r]of Object.entries(t))n[Number(e)]={...r,...n[Number(e)]};return n}),r(e)};return e(),Yee(e)}if(pf())return;let n=!1;async function i(){let[i,a]=await Promise.all([Qee(t),tf(e)]);n||!i||r(a?hf(i,a):i)}i();async function o(){let t=await tf(e);n||!t||r(e=>e&&hf(e,t))}let s=e=>{let t=e.detail;!t||typeof t!=`object`||r(e=>{if(!e)return e;let n=!1,r=e.rows.map(e=>{let r=t[String(e.pid)];if(!r||typeof r!=`object`)return e;let i={};for(let[e,t]of Object.entries(r))(t===null||typeof t==`string`||typeof t==`number`)&&(i[e]=t);return Object.keys(i).length===0?e:(n=!0,{...e,...i})});return n?{...e,rows:r}:e})},c=()=>{o()};return typeof window<`u`&&(window.addEventListener(Bd,c),window.addEventListener(zd,s)),()=>{n=!0,typeof window<`u`&&(window.removeEventListener(Bd,c),window.removeEventListener(zd,s))}},[e,t]);let s=(0,L.useCallback)((e,n)=>{let r;if(a(t=>(r=t[e],{...t,[e]:{...t[e],...n}})),_f){let t=o.current?.workspace?.storageKey;if(t){let r=yf(t),i=Date.now();for(let[t,a]of Object.entries(n))r=cte(r,{pid:e,key:t,value:a??null,at:i});bf(t,r)}Jd({id:Yd(`overlay`),type:`overlay_patch`,pid:e,updates:n});return}ute||$ee(t,e,n).then(t=>{t||(console.warn(`customer-grid: overlay PATCH failed for pid ${e}; rolling back`),a(t=>{let n={...t};return r===void 0?delete n[e]:n[e]=r,n}))})},[t]);return{fields:n?.fields??[],rawRows:n?.rows??[],payload:n,loading:n===null,overlayEdits:i,setOverlayEdits:a,patchOverlay:s}}var Sf=`#202433`,Cf=`#6B7280`,wf=`#E6E9EF`,fte=`#FFFFFF`,pte=`#FAFBFC`,mte=`#9DBFF2`,Tf=`#EDF3FD`,hte=`#F5D989`,Ef=`#FBF4E0`,gte=`#F0A8A0`,_te=`#FCEEEC`,vte=`#A5D8B4`,Df=`#EBF6EF`,Of=`#F1EEFB`,yte=`#6B57A8`,bte=`#768FB6`,xte=`#4F6079`,kf=`#7E6428`,Ste=`#A3453C`,Af=`#35754E`,jf={accentColor:bte,accentLight:Tf,textDark:Sf,textMedium:Cf,textLight:`#8B92A0`,textHeader:Sf,bgCell:fte,bgHeader:pte,bgHeaderHovered:`#F1F3F6`,bgHeaderHasFocus:Tf,borderColor:wf,horizontalBorderColor:wf,fgIconHeader:Cf,bgIconHeader:wf,fontFamily:`Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif`,baseFontStyle:`13px`,headerFontStyle:`600 13px`},Cte={growing:{bgBubble:Df,textBubble:Af},new:{bgBubble:Tf,textBubble:xte},declining:{bgBubble:Ef,textBubble:kf},dormant:{bgBubble:wf,textBubble:Sf},lost:{bgBubble:_te,textBubble:Ste},reactivated:{bgBubble:vte,textBubble:Sf}},wte={growing:{bgCell:`rgba(165, 216, 180, 0.40)`},new:{bgCell:`rgba(157, 191, 242, 0.38)`},declining:{bgCell:`rgba(245, 217, 137, 0.42)`},dormant:{bgCell:`rgba(107, 114, 128, 0.13)`},lost:{bgCell:`rgba(240, 168, 160, 0.38)`},reactivated:{bgCell:`rgba(165, 216, 180, 0.72)`}},Tte={growing:{bgCell:`rgba(165, 216, 180, 0.62)`},new:{bgCell:`rgba(157, 191, 242, 0.60)`},declining:{bgCell:`rgba(245, 217, 137, 0.64)`},dormant:{bgCell:`rgba(107, 114, 128, 0.22)`},lost:{bgCell:`rgba(240, 168, 160, 0.60)`},reactivated:{bgCell:`rgba(165, 216, 180, 0.92)`}},Ete={bgCell:`rgba(32, 36, 51, 0.06)`},Dte=Ete,Ote=Ete,Mf=`700 13px`;function Nf(e,t){let n=parseInt(e.slice(1),16);return`rgba(${n>>16&255}, ${n>>8&255}, ${n&255}, ${t})`}var kte={filter:{bgHeader:Df,bgHeaderHovered:Df,bgHeaderHasFocus:Df,bgCell:Nf(Af,.06),headerFontStyle:Mf},sort:{bgHeader:Ef,bgHeaderHovered:Ef,bgHeaderHasFocus:Ef,bgCell:Nf(kf,.06),headerFontStyle:Mf},group:{bgHeader:Of,bgHeaderHovered:Of,bgHeaderHasFocus:Of,bgCell:Nf(yte,.06),headerFontStyle:Mf}},Ate=Cf,Pf=(e,t,n)=>`M${e-n} ${t}a${n} ${n} 0 1 0 ${n*2} 0a${n} ${n} 0 1 0 ${-n*2} 0`,jte=[{d:`M3.2 4.6h9.6v8.2H3.2z`},{d:`M3.2 7.2h9.6`},{d:`M5.8 3v3.2`},{d:`M10.2 3v3.2`}],Ff={text:[{d:`M3 5h10M3 8h10M3 11h6`}],status:[{d:`M4 13V3.5h7.6L10.1 6l1.5 2.5H4`}],currency:[{d:`M8 2.8v10.4`},{d:`M10.6 5.4A2.6 2.6 0 0 0 8.2 4.2H7.4a2 2 0 0 0 0 4h1.2a2 2 0 0 1 0 4H7.8a2.6 2.6 0 0 1-2.4-1.4`}],int:[{d:`M6.2 3L4.8 13M11.2 3l-1.4 10M3.4 6.2h9.2M2.9 9.8h9.2`}],date:jte,pct:[{d:Pf(4.6,4.6,1.6)},{d:Pf(11.4,11.4,1.6)},{d:`M12.2 3.9L3.8 12.3`}],select:[{d:`M3.2 3.8h9.6v8.4H3.2z`},{d:`M6.2 7.2l1.8 1.8 1.8-1.8`}],user:[{d:Pf(8,6,2.4)},{d:`M3.6 13c0-2.4 2-3.8 4.4-3.8s4.4 1.4 4.4 3.8`}],multiselect:[{d:`M3 4.6h2.2v2.2H3zM3 9.2h2.2v2.2H3z`},{d:`M7.2 5.7h6M7.2 10.3h6`}],checkbox:[{d:`M3.4 3.4h9.2v9.2H3.4z`},{d:`M5.8 8.1l1.8 1.9 3.4-3.9`}],phone:[{d:`M5.1 3.2L7 5.1 5.6 7a7.2 7.2 0 0 0 3.4 3.4l1.9-1.4 1.9 1.9-1.5 1.6c-3 .5-8.3-4.8-7.8-7.8z`}],email:[{d:`M3 4.4h10v7.2H3z`},{d:`M3 4.9l5 3.9 5-3.9`}],url:[{d:`M7 5.4L8.4 4a2.6 2.6 0 0 1 3.7 3.7L10.7 9`},{d:`M9 10.6L7.6 12a2.6 2.6 0 0 1-3.7-3.7L5.3 7`},{d:`M6.2 9.8l3.6-3.6`}],rating:[{d:`M8 2.9l1.63 3.3 3.64.53-2.63 2.57.62 3.63L8 11.24 4.74 12.93l.62-3.63L2.73 6.73l3.64-.53z`,fill:!0}],created_time:[{d:Pf(8,8,5.2)},{d:`M8 4.9v3.4l2.3 1.4`}],formula:[{d:`M5.6 12.8V5.4a2 2 0 0 1 3.2-1.6`},{d:`M4.2 7.6h4.6`},{d:`M10.2 8.4l3 3.4M13.2 8.4l-3 3.4`}]},If={grid:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M2.6 6.5h10.8M2.6 9.5h10.8M6.4 3.4v9.2M10 3.4v9.2`}],list:[{d:`M3 4.6h1.4M6.4 4.6h6.6M3 8h1.4M6.4 8h6.6M3 11.4h1.4M6.4 11.4h6.6`}],chart:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M5.4 10.6V7.2M8 10.6V5.4M10.6 10.6V8.6`}],dashboard:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M5.4 10.6V7.2M8 10.6V5.4M10.6 10.6V8.6`}],calendar:jte,kanban:[{d:`M2.8 3.4h3.1v9.2H2.8zM6.5 3.4h3.1v6.2H6.5zM10.2 3.4h3.1v7.6h-3.1z`}],map:[{d:`M8 2.6a3.6 3.6 0 0 1 3.6 3.6c0 2.7-3.6 7.2-3.6 7.2S4.4 8.9 4.4 6.2A3.6 3.6 0 0 1 8 2.6z`},{d:Pf(8,6.1,1.3)}],timeseries:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M2.6 6.6h10.8M6.2 3.4v9.2`},{d:`M7.2 10.8l2-2.4 1.6 1.2 1.8-2.6`}]},Mte={bar:[{d:`M3.2 12.8V7.4M6.4 12.8V4.2M9.6 12.8V8.8M12.8 12.8V5.8`}],line:[{d:`M2.6 11.2l3.2-3.4 2.6 2 4.9-5.2`},{d:Pf(5.8,7.8,.9)},{d:Pf(8.4,9.8,.9)}],area:[{d:`M2.6 12.4V9.2l3.2-3.2 2.6 2 4.9-4.6v9z`},{d:`M2.6 9.2l3.2-3.2 2.6 2 4.9-4.6`}],donut:[{d:Pf(8,8,5)},{d:Pf(8,8,2.1)}],kpi:[{d:`M2.6 3.8h10.8v8.4H2.6z`},{d:`M5.4 9.6V6.4l1.9 3.2V6.4M9.4 6.4v3.2h1.8`}],table:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M2.6 6.2h10.8M7.2 6.2v6.4M2.6 9.4h10.8`}]},Nte={bar:`blue`,line:`green`,area:`green`,donut:`yellow`,kpi:`neutral`,table:`neutral`},Pte={folder:[{d:`M2.4 12.6V4.2a.6.6 0 0 1 .6-.6h3.2l1.5 1.7h5.3a.6.6 0 0 1 .6.6v6.7a.6.6 0 0 1-.6.6H3a.6.6 0 0 1-.6-.6z`}],star:[{d:`M8 2.9l1.63 3.3 3.64.53-2.63 2.57.62 3.63L8 11.24 4.74 12.93l.62-3.63L2.73 6.73l3.64-.53z`}],flag:[{d:`M4.2 13.4V2.9`},{d:`M4.2 3.4h7.6l-1.5 2.6 1.5 2.6H4.2z`}],tag:[{d:`M2.9 8.2V3.5a.6.6 0 0 1 .6-.6h4.7l5 5-5.3 5.3z`},{d:Pf(5.6,5.6,1)}],bookmark:[{d:`M4.4 2.9h7.2v10.4L8 10.7l-3.6 2.6z`}],grid:If.grid,chart:If.dashboard,map:If.map,users:Ff.user,clock:Ff.created_time,heart:[{d:`M8 13.1S2.7 9.8 2.7 6.4a2.9 2.9 0 0 1 5.3-1.6 2.9 2.9 0 0 1 5.3 1.6c0 3.4-5.3 6.7-5.3 6.7z`}],bolt:[{d:`M9.1 2.4L4.2 9.1h3.3l-.6 4.5 4.9-6.7H8.5z`}]},Lf={neutral:{fill:wf,stroke:Cf},blue:{fill:mte,stroke:bte},green:{fill:vte,stroke:Af},yellow:{fill:hte,stroke:kf},red:{fill:gte,stroke:Ste}},Fte={neutral:`Neutral`,blue:`Blue`,green:`Green`,yellow:`Yellow`,red:`Red`},Ite={folder:`Folder`,star:`Star`,flag:`Flag`,tag:`Tag`,bookmark:`Bookmark`,grid:`Table`,chart:`Chart`,map:`Map`,users:`People`,clock:`Clock`,heart:`Heart`,bolt:`Priority`},Rf={grid:`Grid`,chart:`Chart`,dashboard:`Chart`,list:`List`,calendar:`Calendar`,kanban:`Kanban`,map:`Map`,timeseries:`Time series`},Lte=[`grid`,`chart`,`calendar`,`kanban`,`timeseries`,`map`,`list`],Rte={grid:`blue`,list:`blue`,chart:`green`,dashboard:`green`,calendar:`yellow`,kanban:`yellow`,map:`red`,timeseries:`green`},zf={text:`Single line text`,select:`Single select`,multiselect:`Multi select`,user:`Assignee`,int:`Number`,currency:`Currency`,pct:`Percent`,date:`Date`,checkbox:`Checkbox`,phone:`Phone number`,email:`Email`,url:`URL`,rating:`Rating`,created_time:`Created time`,formula:`Formula`,status:`Lifecycle status (Odoo)`};function zte(e,t){return e.fill?``:``}function Bte(e){return({fgColor:t})=>``+e.map(e=>zte(e,t)).join(``)+``}function Vte(e){return`t_${e}`}var Hte={...Object.fromEntries(Object.keys(Ff).map(e=>[Vte(e),Bte(Ff[e])])),aiosInfo:()=>``};function Ute(e,t,n){return e&&t>Math.max(0,n-16)?e:null}function Wte(e,t,n,r=8){let i=Math.min(n,280);return Math.round(Math.max(r,Math.min(e,t-r-i)))}var Gte=`600 13px`;function Kte(e,t,n,r,i){let a=t=>`${e} ${t} (${n})`,o=a(t);if(r==null||r<=0||i(o)<=r)return o;let s=r-i(a(``));return s<=0?o:a(Xte(t,s,i))}function qte(e,t,n,r=4){if(n.length===0)return null;let i=[],a=e.x+e.width-t-r;for(let t of n){let n=a-t;if(n-e.x<68)return null;i.push({x:Math.round(n),y:Math.round(e.y+(e.height-t)/2),size:t}),a=n-6}return i}function Jte(e,t){let n=[];return e&&n.push(16),t&&n.push(6),n}function Yte(e,t,n=30){let r=qte({x:0,y:0,width:e,height:32},n,t===!0?[16]:t===!1?[]:t);return r?Math.max(0,r[r.length-1].x-32-6):null}function Xte(e,t,n){if(t==null||!e||n(e)<=t)return e;let r=n(`…`);if(r>t)return e;let i=0,a=e.length;for(;it.x+t.width||at.y+t.height)?null:{x:i,y:a,size:n}}function Qte(e){let{placement:t,target:n,panel:r,viewport:i}=e,a=i.left+8,o=i.left+i.width-8,s=i.top+8,c=i.top+i.height-8,l=Math.max(1,o-a),u=Math.min(r.width,l),d=r.height,f,p,m,h;if(t===`right-start`){let e=Math.max(0,o-(n.right+6)),t=Math.max(0,n.left-6-a),r=u<=e||e>=t;h=r?`right`:`left`;let i=r?n.right+6:n.left-6-u;f=Math.min(Math.max(i,a),Math.max(a,o-u)),m=Math.max(1,c-s),p=Math.min(Math.max(n.top,s),Math.max(s,c-Math.min(d,m)))}else{let e=Math.max(0,c-(n.bottom+6)),r=Math.max(0,n.top-6-s),i=d<=e||e>=r;h=i?`below`:`above`,m=Math.max(1,i?e:r);let l=t===`bottom-end`?n.right-u:n.left;f=Math.min(Math.max(l,a),o-u),p=i?Math.min(n.bottom+6,c-m):Math.max(s,n.top-6-Math.min(d,m))}return{left:Math.round(f),top:Math.round(p),maxWidth:Math.floor(l),maxHeight:Math.floor(m),side:h}}var $te=150,Bf={base:void 0,bold:void 0};function ene(e,t=!1){let n=t?`bold`:`base`;if(Bf[n]===void 0){let e=document.createElement(`canvas`).getContext(`2d`);e&&(e.font=`${(t?`700 13px`:jf.headerFontStyle)??`600 13px`} ${jf.fontFamily??`Inter, sans-serif`}`),Bf[n]=e}let r=Bf[n];return r?r.measureText(e).width:0}function tne(e){return!!(e.note||e.description)}function nne(e,t){for(let n of e??[]){if(yd(n)){nne(n.children,t);continue}_d(n)&&t.add(n.colId)}}function rne(e){return e?kte[e]:void 0}function ine(e){let t=new Map;e.groupBy&&t.set(e.groupBy,`group`);for(let n of e.sorts??[])t.set(n.colId,`sort`);let n=new Set;nne(e.filters??[],n);for(let e of n)t.set(e,`filter`);return t}function Vf(e){return e.default!==!1||e.source===`overlay`}function Hf(e){let t=e.filter(Vf).map(e=>e.key),n=e.filter(e=>!Vf(e)).map(e=>e.key);return{filters:[],filterConj:`and`,sorts:[],groupBy:null,colorBy:null,rowHeightMode:`short`,order:[...t,...n],visible:t,widths:{},memberPids:[]}}function ane(e,t){let n=new Set(t.map(e=>e.key)),r=e.filter((t,r)=>n.has(t)&&e.indexOf(t)===r);for(let e of t)r.includes(e.key)||r.push(e.key);let i=t.find(e=>e.pinned)?.key??t[0]?.key;return i&&r[0]!==i?[i,...r.filter(e=>e!==i)]:r}function one(e,t,n){let r=new Set(t.map(e=>e.key)),i=new Set(e.filter(e=>r.has(e)));if(i.size===0)for(let e of t)Vf(e)&&i.add(e.key);return n&&i.add(n),i}function sne(e,t,n){let r=(0,L.useMemo)(()=>new Map(e.map(e=>[e.key,e])),[e]),i=(0,L.useMemo)(()=>e.find(e=>e.pinned)?.key??e[0]?.key??``,[e]),a=(0,L.useMemo)(()=>ane(t.order,e),[t.order,e]),o=(0,L.useMemo)(()=>one(t.visible,e,i),[t.visible,e,i]),s=(0,L.useMemo)(()=>ine(t),[t.filters,t.sorts,t.groupBy]),c=(0,L.useMemo)(()=>a.filter(e=>o.has(e)).map(e=>{let n=r.get(e),i=t.widths[e]??$te,a=s.has(e),o=Jte(tne(n),n.source===`overlay`);return{id:e,title:Xte(n.label,Yte(i,o),e=>ene(e,a)),width:i,hasMenu:!0,menuIcon:`dots`,icon:Vte(n.type),themeOverride:rne(s.get(e))}}),[a,o,t.widths,r,s]),l=(0,L.useCallback)((e,r)=>{e.id&&n({...t,widths:{...t.widths,[e.id]:Math.round(r)}})},[t,n]),u=(0,L.useCallback)((e,r)=>{if(e===0||r===0)return;let i=a.filter(e=>o.has(e));if(e<0||e>=i.length||r<0||r>=i.length)return;let s=i.slice(),[c]=s.splice(e,1);s.splice(r,0,c);let l=0,u=a.map(e=>o.has(e)?s[l++]:e);n({...t,order:u})},[t,n,a,o]),d=(0,L.useCallback)((e,t)=>e!==0&&t!==0,[]),f=(0,L.useCallback)((e,r)=>{if(!r&&e===i)return;let a=new Set(o);r?a.add(e):a.delete(e),n({...t,visible:[...a]})},[t,i,n,o]),p=(0,L.useCallback)((e,r,i)=>{let s=a.filter(t=>t!==e);if(i===`end`||!r)s.push(e);else{let t=Math.max(0,s.indexOf(r));s.splice(t+ +(i===`right`),0,e)}let c=new Set(o);c.add(e),n({...t,order:s,visible:[...c]})},[t,n,a,o]);return{visibleCols:c,fieldByKey:r,order:a,visible:o,widths:t.widths,lockedKey:i,onColumnResize:l,onColumnMoved:u,onColumnProposeMove:d,setColumnVisible:f,insertColumn:p}}function cne(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:0}function lne(e,t){let n={};for(let r of t){if(r.agg!==`sum`)continue;let t=0;for(let n of e)t+=cne(n[r.key]);let i=Math.round(t*100)/100;n[r.key]=r.type===`currency`?`$`+i.toLocaleString():i.toLocaleString()}return n}var une={sets:new Map,unanswerable:0};function dne(e){return e===`currency`||e===`int`||e===`pct`||e===`rating`||e===`formula`}function Uf(e){return!yd(e)&&!vd(e)&&dd(e.op)}function fne(e){for(let t of e??[]){if(yd(t)){if(fne(t.children))return!0;continue}if(Uf(t))return!0}return!1}function pne(e){let t=[];for(let n of e??[]){if(yd(n)){let e=pne(n.children);e.length&&t.push({conj:n.conj,children:e});continue}Uf(n)||t.push(n)}return t}function mne(e){let t=[];for(let n of e??[]){if(yd(n)){t.push(...mne(n.children));continue}if(!Uf(n))continue;let e=n;_d(e)&&t.push(e)}return t}function hne(e,t,n){let r=[];for(let n of e){let e=n[t];if(e==null||e===``)continue;let i=typeof e==`number`?e:Number(e);Number.isFinite(i)&&r.push({pid:n.pid,v:i})}return r.sort((e,t)=>e.v===t.v?e.pid-t.pid:n===`asc`?e.v-t.v:t.v-e.v),r}function Wf(e,t,n){let r=Number(e);if(!Number.isFinite(r))return null;let i=Math.trunc(r);return i!==r||in?null:i}function gne(e,t,n){return Math.min(n,Math.floor(e*n/t)+1)}function _ne(e,t){return Math.min(e,Math.max(1,Math.ceil(e*t/100)))}function vne(e,t,n){let r=mne(e);if(!r.length)return une;let i=new Map,a=0,o=new Map,s=(e,n)=>{let r=`${n}:${e}`,i=o.get(r);return i||(i=hne(t,e,n),o.set(r,i)),i},c=e=>{i.set(e,new Set),a+=1};for(let e of r){let r=n.get(e.colId);if(!r||!dne(r.type)){c(e);continue}let o=s(e.colId,`asc`);if(!o.length){i.set(e,new Set),t.length&&(a+=1);continue}let l=o.length,u=null;switch(e.op){case`topN`:{let t=Wf(e.value,1,1e4);u=t==null?null:s(e.colId,`desc`).slice(0,t);break}case`bottomN`:{let t=Wf(e.value,1,1e4);u=t==null?null:o.slice(0,t);break}case`inTopPct`:{let t=Wf(e.value,1,100);u=t==null?null:s(e.colId,`desc`).slice(0,_ne(l,t));break}case`inBottomPct`:{let t=Wf(e.value,1,100);u=t==null?null:o.slice(0,_ne(l,t));break}case`aboveAvg`:case`belowAvg`:{let t=o.reduce((e,t)=>e+t.v,0)/l;u=o.filter(n=>e.op===`aboveAvg`?n.v>t:n.vgne(r,l,t)===n);break}default:u=null}if(u==null){c(e);continue}i.set(e,new Set(u.map(e=>e.pid)))}return{sets:i,unanswerable:a}}function Gf(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:0}function yne(e){return e===`currency`||e===`int`||e===`pct`||e===`rating`||e===`formula`}function bne(e){return e===`date`||e===`created_time`}function xne(e,t,n){for(let r of n){if(r.type!==`text`&&r.type!==`status`)continue;let n=t[r.key];if(n!=null&&String(n).toLowerCase().includes(e))return!0}return!1}function Kf(e){return e==null||e===``}function Sne(e,t,n,r){let i=n.get(e.colId);if(!i)return!0;let a=t[e.colId];if(e.op===`isEmpty`)return Kf(a);if(e.op===`isNotEmpty`)return!Kf(a);if(dd(e.op))return!1;let o=e.rhs!=null,s=o?t[gd(e.rhs)??``]:void 0;if(yne(i.type)){let t=Gf(a);if(o)return qf(e.op,t,Gf(s));if(e.op===`between`){if(e.value===``||e.value2==null||e.value2===``)return!0;let n=Math.min(Gf(e.value),Gf(e.value2)),r=Math.max(Gf(e.value),Gf(e.value2));return t>=n&&t<=r}return e.value===``||qf(e.op,t,Gf(e.value))}if(bne(i.type)){let t=String(a??``).slice(0,10);if(e.op===`within`){if(!r)return!1;let n=Xu(e.dateWindow,r);if(!n||t===``)return!1;let[i,a]=n;return(i==null||t>=i)&&(a==null||t<=a)}if(o)return Jf(e.op,t,String(s??``).slice(0,10));if(e.op===`between`){if(e.value===``||e.value2==null||e.value2===``)return!0;let n=e.value=n&&t<=r}if(!Cne.has(e.op)||!e.dateMode&&e.value===``)return!0;let n=e.dateMode||`exact`;if(n!==`exact`&&!r)return!1;let i=Qu(n,e.value,r||`1970-01-01`);return i!=null&&Jf(e.op,t,i)}let c=String(a??``).toLowerCase();return o?Yf(e.op,c,String(s??``).toLowerCase()):e.value===``||Yf(e.op,c,e.value.toLowerCase())}var Cne=new Set([`eq`,`neq`,`lt`,`lte`,`gt`,`gte`]);function qf(e,t,n){switch(e){case`gt`:return t>n;case`gte`:return t>=n;case`lt`:return tn;case`gte`:return t>=n;default:return!0}}function Yf(e,t,n){switch(e){case`contains`:return t.includes(n);case`doesNotContain`:return!t.includes(n);case`eq`:return t===n;case`neq`:return t!==n;default:return!0}}function Xf(e,t,n,r){if(yd(e)){let i=!1,a=!0,o=!1;for(let s of e.children){let e=Xf(s,t,n,r);e!==null&&(i=!0,a&&=e,o||=e)}return i?e.conj===`or`?o:a:null}if(Eee(e)){if(!_d(e))return null;let n=hd(e.value).map(e=>r?.cohortSets?.[e]);if(n.some(e=>!e))return!1;let i=md(e.op);if(i===`allOf`)return n.every(e=>e.has(t.pid));let a=n.some(e=>e.has(t.pid));return i===`noneOf`?!a:a}if(vd(e)){if(!_d(e))return null;let n=e.id?r?.measureSets?.[e.id]:void 0;return n?n.has(t.pid):!1}if(!n.has(e.colId)||e.rhs&&!n.has(gd(e.rhs)??``)||!_d(e))return null;if(dd(e.op)){let n=r?.rankSets?.get(e);return n?n.has(t.pid):!1}return Tee.includes(e.op)?Sne(e,t,n,r?.today):!1}function Zf(e,t){let n=0;for(let r of e??[]){if(yd(r)){n+=Zf(r.children,t);continue}!vd(r)||!_d(r)||(!r.id||!t?.[r.id])&&(n+=1)}return n}function Qf(e){let t=[];for(let n of e??[]){if(yd(n)){t.push(...Qf(n.children));continue}!vd(n)||!_d(n)||t.push(n.id||`(no-id)`)}return t}function $f(e,t){let n=0;for(let r of e??[]){if(yd(r)){n+=$f(r.children,t);continue}if(_d(r)){if(Eee(r)){hd(r.value).some(e=>!t?.cohortSets?.[e])&&(n+=1);continue}vd(r)||(r.op===`within`?(!t?.today||!Xu(r.dateWindow,t.today))&&(n+=1):r.dateMode&&(!t?.today||Qu(r.dateMode,r.value,t.today)==null)&&(n+=1))}}return n}function ep(e,t,n,r,i){let a=Xf({conj:t,children:e},n,r,i);return a===null||a}function wne(e,t){return(n,r)=>{for(let i of e){let e=t.get(i.colId),a=e?yne(e.type):!1,o=n[i.colId],s=r[i.colId],c=Kf(o),l=Kf(s);if(c!==l)return c?1:-1;if(c&&l)continue;let u=a?Gf(o)-Gf(s):String(o??``).localeCompare(String(s??``));if(u!==0)return i.dir===`asc`?u:-u}return 0}}function Tne(e,t,n,r){let i=[],a=new Map,o=r.some(e=>e.key===t&&(e.multi||e.type===`multiselect`)),s=r.some(e=>e.key===t&&e.type===`checkbox`),c=e=>s?e===`1`?`Checked`:`Unchecked`:e===``?`(empty)`:e;for(let n of e){let e=n[t],r=e==null?``:String(e),s=o?r.split(`,`).map(e=>e.trim()).filter(e=>e!==``):[r];for(let e of s.length?s:[``]){let t=a.get(e);t||(t=[],a.set(e,t),i.push(e)),t.push(n)}}let l=[];for(let e of i){let t=a.get(e),i=n.has(e),o=lne(t,r);if(l.push({kind:`group-header`,groupKey:e,label:c(e),count:t.length,collapsed:i,aggs:o}),!i){for(let e of t)l.push({kind:`data`,record:e});l.push({kind:`group-footer`,groupKey:e,aggs:o})}}return l}function tp(e){let{rawRows:t,fields:n,filters:r,search:i,sorts:a,groupBy:o,collapsed:s,memberPids:c=[],filterConj:l=`and`,serverWindowed:u=!1,measureSets:d,cohortSets:f,today:p,cohortLock:m}=e,h={measureSets:d,cohortSets:f,today:p},g=0,_=e=>{let t=e.map(e=>({kind:`data`,record:e})),n=new Map;return t.forEach((e,t)=>{e.kind===`data`&&n.set(e.record.pid,t)}),{visibleRows:t,pidToIndex:n,unresolvedRank:g}};if(u)return _(t);let v=new Map;for(let e of n)v.set(e.key,e);let y=t;if(m){let e=f?.[m];if(!e)return _([]);y=y.filter(t=>e.has(t.pid))}if(r.length){if(fne(r)){let e=pne(r),t=y,n=vne(r,e.length?t.filter(t=>ep(e,l,t,v,h)):t,v);h.rankSets=n.sets,g=n.unanswerable}else h.rankSets=une.sets;let e=new Set(c);y=y.filter(t=>e.has(t.pid)||ep(r,l,t,v,h))}let b=i.trim().toLowerCase();if(b&&(y=y.filter(e=>xne(b,e,n))),a.length&&(y=[...y].sort(wne(a,v))),!o)return _(y);let x=Tne(y,o,s,n),S=new Map;return x.forEach((e,t)=>{e.kind===`data`&&!S.has(e.record.pid)&&S.set(e.record.pid,t)}),{visibleRows:x,pidToIndex:S,unresolvedRank:g}}function Ene(e,t,n,r,i,a,o,s=[],c=`and`,l=!1,u,d,f,p){return(0,L.useMemo)(()=>tp({rawRows:e,fields:t,filters:n,search:r,sorts:i,groupBy:a,collapsed:o,memberPids:s,filterConj:c,serverWindowed:l,measureSets:u,cohortSets:d,today:f,cohortLock:p}),[e,t,n,c,r,i,a,o,s,l,u,d,f,p])}var np=[{bg:`#EDF3FD`,fg:`#4F6079`},{bg:`#EBF6EF`,fg:`#35754E`},{bg:`#FBF4E0`,fg:`#7E6428`},{bg:`#FCEEEC`,fg:`#A3453C`},{bg:`#F1EEFB`,fg:`#6B57A8`},{bg:`#EEF1F4`,fg:`#4B5563`}];function rp(e){if(!(typeof e!=`string`||!/^#[0-9a-f]{6}$/i.test(e.trim())))return e.trim().toUpperCase()}var ip=`#182230`,ap=[{id:`blue-tint`,hue:`blue`,strength:`tint`,bg:`#EDF3FD`,fg:`#4F6079`,label:`Light blue`},{id:`green-tint`,hue:`green`,strength:`tint`,bg:`#EBF6EF`,fg:`#35754E`,label:`Light green`},{id:`yellow-tint`,hue:`yellow`,strength:`tint`,bg:`#FBF4E0`,fg:`#7E6428`,label:`Light yellow`},{id:`red-tint`,hue:`red`,strength:`tint`,bg:`#FCEEEC`,fg:`#A3453C`,label:`Light red`},{id:`purple-tint`,hue:`purple`,strength:`tint`,bg:`#F1EEFB`,fg:`#6B57A8`,label:`Light purple`},{id:`blue-pastel`,hue:`blue`,strength:`pastel`,bg:`#9DBFF2`,fg:ip,label:`Blue`},{id:`green-pastel`,hue:`green`,strength:`pastel`,bg:`#A5D8B4`,fg:ip,label:`Green`},{id:`yellow-pastel`,hue:`yellow`,strength:`pastel`,bg:`#F5D989`,fg:ip,label:`Yellow`},{id:`red-pastel`,hue:`red`,strength:`pastel`,bg:`#F0A8A0`,fg:ip,label:`Red`},{id:`purple-pastel`,hue:`purple`,strength:`pastel`,bg:`#C3B3EE`,fg:ip,label:`Purple`}];function op(e){let t=rp(e);if(!t)return;let n=cp(t,1),r=cp(t,3),i=cp(t,5),a=ap[0],o=1/0;for(let e of ap){let t=n-cp(e.bg,1),s=r-cp(e.bg,3),c=i-cp(e.bg,5),l=(n+cp(e.bg,1))/2,u=(2+l/256)*t*t+4*s*s+(2+(255-l)/256)*c*c;u>>0;return np[t%np.length]}function One(e,t){let n=e.optionColors;if(!n)return;let r=rp(n[t]);if(r)return r;let i=t.trim().toLowerCase();for(let[e,t]of Object.entries(n))if(e.trim().toLowerCase()===i)return rp(t)}function cp(e,t){return Number.parseInt(e.slice(t,t+2),16)}function lp(e){let t=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(cp(e,1))+.7152*t(cp(e,3))+.0722*t(cp(e,5))}function kne(e){let t=lp(rp(e)??`#FFFFFF`),n=lp(`#182230`),r=lp(`#FFFFFF`);return(t+.05)/(n+.05)>=(r+.05)/(t+.05)?`#182230`:`#FFFFFF`}function up(e,t){if(!t||e.colorCodeOptions===!1)return;let n=One(e,t);return n?Dne(n):sp(t)}function dp(e){return sp(e).bg}function fp(e){let t=e.split(`@`)[0].trim().split(/[\s._]+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function Ane(e){return Math.max(14,Math.min(22,e-6))}function jne(e,t){return{data:{kind:`aios-user`,name:e,photo:t?.[e]},copyData:e}}function pp(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:0}function mp(e){return typeof e==`string`&&e.trim()!==``&&!Number.isFinite(Number(e))}function hp(e){return e==null||typeof e==`string`&&e.trim()===``}function gp(e){return e===`1`||e===1||e===!0}function _p(e,t){if(t?.abbrev&&Math.abs(e)>=1e3){let t=Math.abs(e),[n,r]=t>=1e9?[1e9,`B`]:t>=1e6?[1e6,`M`]:[1e3,`k`];return(e/n).toFixed(1)+r}let n=t&&Number.isInteger(t.decimals)&&t.decimals>=0&&t.decimals<=4?t.decimals:null,r=t?.thousands!==!1;return n==null?r?e.toLocaleString():String(e):r?e.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n}):e.toFixed(n)}function Mne(e){let t=e.includes(` `)?e.replace(` `,`T`):e,n=/T\d{2}:\d{2}/.test(t)&&!/(?:[zZ]|[+-]\d{2}:?\d{2})$/.test(t)?t+`Z`:t,r=new Date(n);return Number.isNaN(r.getTime())?null:r}function vp(e,t){if(t==null||t===``)return``;let n=String(t),r=Mne(n);if(!r)return n;let i=e.format,a=i?.time??e.type===`created_time`,o=i?.tz===`utc`?{timeZone:`UTC`}:void 0;return a?r.toLocaleString(void 0,o):r.toLocaleDateString(void 0,o)}function yp(e,t){switch(e.type){case`currency`:return t==null||t===``?``:`$`+_p(pp(t),e.format);case`formula`:return hp(t)?``:mp(t)?t:_p(pp(t),e.format);case`int`:return t==null||t===``?``:_p(pp(t),e.format);case`pct`:return t==null||t===``?``:pp(t).toFixed(1)+`%`;case`date`:case`created_time`:return vp(e,t);case`checkbox`:return gp(t)?`Checked`:``;case`rating`:{let n=pp(t);return n>=1?`${Math.round(n)} of ${rd(e)}`:``}case`multiselect`:return String(t??``).split(`,`).map(e=>e.trim()).filter(e=>e!==``).join(`, `);default:return String(t??``)}}ct();function Nne(e,t,n,r,i){e.beginPath();for(let i=0;i<10;i+=1){let a=Math.PI/5*i-Math.PI/2,o=i%2==0?r:r*.45,s=t+Math.cos(a)*o,c=n+Math.sin(a)*o;i===0?e.moveTo(s,c):e.lineTo(s,c)}e.closePath(),i?(e.fillStyle=`#A98A3E`,e.fill()):(e.strokeStyle=`rgba(118, 143, 182, 0.55)`,e.lineWidth=1,e.stroke())}var bp=new Map,xp;function Sp(e){xp=e}function Pne(e){let t=bp.get(e);if(t!==void 0)return t;if(typeof Image>`u`)return bp.set(e,null),null;let n=new Image;return bp.set(e,n),n.onload=()=>xp?.(),n.onerror=()=>{bp.set(e,null),xp?.()},n.src=e,n}function Fne(e,t,n,r,i,a,o){let s=a?Pne(a):null;if(s&&s.complete&&s.naturalWidth>0){e.save(),e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.clip();let i=Math.max(r*2/s.naturalWidth,r*2/s.naturalHeight),a=s.naturalWidth*i,o=s.naturalHeight*i;e.drawImage(s,t-a/2,n-o/2,a,o),e.restore();return}let c=sp(i);e.save(),e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fillStyle=c.bg,e.fill(),e.fillStyle=c.fg,e.font=`600 ${Math.round(r*.9)}px ${o}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(fp(i),t,n+.5),e.restore()}var Ine={kind:I.Custom,isMatch:e=>e.data?.kind===`aios-user`,draw:(e,t)=>{let{ctx:n,rect:r,theme:i}=e,{name:a,photo:o}=t.data;if(!a)return!0;let s=Ane(r.height),c=r.x+i.cellHorizontalPadding+s/2,l=r.y+r.height/2;return c+s/2>r.x+r.width-i.cellHorizontalPadding||Fne(n,c,l,s/2,a,o,i.fontFamily),!0}},Lne={kind:I.Custom,isMatch:e=>e.data?.kind===`aios-rating`,draw:(e,t)=>{let{ctx:n,rect:r,theme:i}=e,{value:a,max:o}=t.data,s=r.y+r.height/2,c=r.x+i.cellHorizontalPadding+13/2,l=r.x+r.width-i.cellHorizontalPadding;for(let e=0;el);e+=1)Nne(n,c,s,13/2,ee.trim()).filter(e=>e!==``),r=n.length?up(e,n[0]):void 0;return{kind:I.Bubble,data:n,allowOverlay:!1,themeOverride:r?{bgBubble:r.bg,textBubble:r.fg}:void 0}}default:return{kind:I.Text,data:String(t??``),displayData:String(t??``),...i}}}ct();var Cp={kind:I.Text,data:``,displayData:``,allowOverlay:!1},zne=new Set;function Bne(e,t,n,r,i){let a=e.collapsed?`▶`:`▼`,o=e.count.toLocaleString(),s=`${a} ${e.label} (${o})`,c=i?Kte(a,e.label,o,r,i):s;return{kind:I.Text,data:s,displayData:t===0?c:``,allowOverlay:!1,span:[0,Math.max(0,n-1)],themeOverride:{bgCell:`#eef0f3`,bgCellMedium:`#eef0f3`,textDark:`#33333d`,baseFontStyle:Gte}}}var wp=[`#1b1b22`,`#33333d`,`#4d4d59`,`#33333d`];function Vne(e,t,n){let r=Math.max(22,Math.round((e??120)*.42));return{kind:I.Loading,allowOverlay:!1,skeletonWidth:r,skeletonWidthVariability:Math.min(20,Math.round(r*.35)),skeletonHeight:10,themeOverride:{textDark:wp[(n+t)%wp.length]},copyData:``}}function Hne(e,t){let n=t?e.aggs[t.key]:void 0;return{kind:I.Text,data:n??``,displayData:n??``,contentAlign:`right`,allowOverlay:!1,themeOverride:{bgCell:`#f6f7f9`,bgCellMedium:`#f6f7f9`,textDark:`#4a4a55`,baseFontStyle:`600 12px`}}}function Une(e,t,n,r,i,a,o=0,s=null,c,l=zne,u=0){return(0,L.useCallback)(([o,d])=>{let f=e[d];if(!f)return Cp;let p=t[o],m=p?n.get(p.id):void 0;if(f.kind===`group-header`)return Bne(f,o,t.length,s,c);if(f.kind===`group-footer`)return Hne(f,m);if(!m)return Cp;let h=r[f.record.pid]?.[m.key]??f.record[m.key];return(h==null||h===``)&&l.has(m.key)?Vne(p?.width,d,u):Rne(m,h,i(m),a)},[e,t,n,r,i,a,o,s,c,l,u])}ct();function Wne(e,t,n){let[r,i]=(0,L.useState)(new Set),[a,o]=(0,L.useState)(void 0),s=(0,L.useRef)(null);return(0,L.useEffect)(()=>{o(e=>{if(!e)return e;let n=s.current,r=n==null?void 0:t.get(n);if(r!==void 0)return r===e.cell[1]?e:{cell:[e.cell[0],r],range:{x:e.cell[0],y:r,width:1,height:1},rangeStack:[]}})},[e,t]),{gridSelection:(0,L.useMemo)(()=>{let i=st.empty();for(let e of r){let n=t.get(e);n!==void 0&&(i=i.add(n))}return{current:a&&a.cell[1]{o(t.current);let n=t.current?e[t.current.cell[1]]:void 0;s.current=n&&n.kind===`data`?n.record.pid:null;let r=new Set;for(let n of t.rows){let t=e[n];t&&t.kind===`data`&&r.add(t.record.pid)}i(r)},[e]),selectPids:(0,L.useCallback)((e,t)=>{i(n=>{let r=t===`add`?new Set(n):new Set;for(let t of e)r.add(t);return r})},[]),togglePid:(0,L.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),setActiveCell:(0,L.useCallback)((t,n)=>{let r=e[n];s.current=r&&r.kind===`data`?r.record.pid:null,o({cell:[t,n],range:{x:t,y:n,width:1,height:1},rangeStack:[]})},[e]),clearSelection:(0,L.useCallback)(()=>{i(new Set),o(void 0),s.current=null},[])}}var Tp=[{key:`filters`,label:`Filter conditions`,blurb:`Which records the view shows, and how the conditions combine.`},{key:`sorts`,label:`Sorts`,blurb:`The order records are listed in.`},{key:`groupBy`,label:`Groups`,blurb:`The field records are bucketed by.`},{key:`visible`,label:`Hidden fields`,blurb:`Which columns are shown.`},{key:`order`,label:`Field order`,blurb:`Left-to-right column order.`},{key:`rowHeightMode`,label:`Row height`,blurb:`Short, medium or tall rows.`}],Ep=Tp.map(e=>e.key);function Gne(e){return typeof e==`string`&&Ep.includes(e)}function Dp(e){return JSON.parse(JSON.stringify(e))}function Kne(e,t,n){let r={};if(!e)return r;let i=new Set;for(let e of t)Gne(e)&&i.add(e);if(i.size===0)return r;if(i.has(`filters`)&&(r.filters=Dp(Array.isArray(e.filters)?e.filters:[]),r.filterConj=e.filterConj),i.has(`sorts`)&&(r.sorts=Dp(Array.isArray(e.sorts)?e.sorts:[])),i.has(`groupBy`)&&(r.groupBy=e.groupBy??null),i.has(`visible`)){let t=Dp(Array.isArray(e.visible)?e.visible:[]);r.visible=n&&!t.includes(n)?[n,...t]:t}return i.has(`order`)&&(r.order=Dp(Array.isArray(e.order)?e.order:[])),i.has(`rowHeightMode`)&&e.rowHeightMode&&(r.rowHeightMode=e.rowHeightMode),r}var qne=s((e=>{var t=f(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),Op=s(((e,t)=>{t.exports=qne()})),Jne=g(),B=Op(),kp=(0,L.createContext)(null),Ap=[`[data-overlay-autofocus]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[href]`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function jp({children:e}){let t=(0,L.useRef)([]),n=(0,L.useMemo)(()=>({register:e=>(t.current=[...t.current.filter(t=>t!==e),e],()=>{t.current=t.current.filter(t=>t!==e)}),isTop:e=>t.current.at(-1)===e}),[]);return(0,B.jsx)(kp.Provider,{value:n,children:e})}function Yne(e){if(`getBoundingClientRect`in e){let t=e.getBoundingClientRect();return{left:t.left,top:t.top,right:t.right,bottom:t.bottom,width:t.width,height:t.height}}return e}function Xne(e,t){return e.left===t.left&&e.top===t.top&&e.maxWidth===t.maxWidth&&e.maxHeight===t.maxHeight&&e.visibility===t.visibility}function Mp({panelRef:e,onDismiss:t,dismissOnOutside:n=!0,initialFocus:r=`first`,restoreFocus:i=!0,trapFocus:a=!1,outsideElements:o=[]}){let s=(0,L.useId)(),c=(0,L.useContext)(kp),l=(0,L.useRef)(t),u=(0,L.useRef)(o);l.current=t,u.current=o,(0,L.useEffect)(()=>c?.register(s),[s,c]),(0,L.useEffect)(()=>{let t=t=>{if(!n||c&&!c.isTop(s))return;let r=t.target;!r||e.current?.contains(r)||u.current.some(e=>e?.contains(r))||(document.activeElement instanceof HTMLElement&&e.current?.contains(document.activeElement)&&document.activeElement.blur(),l.current())},r=t=>{if(c&&!c.isTop(s))return;if(t.key===`Escape`){t.preventDefault(),t.stopPropagation(),document.activeElement instanceof HTMLElement&&e.current?.contains(document.activeElement)&&document.activeElement.blur(),l.current();return}if(t.key!==`Tab`||!a)return;let n=Array.from(e.current?.querySelectorAll(Ap)??[]).filter(e=>e.getClientRects().length>0);if(!n.length){t.preventDefault(),e.current?.focus();return}let r=n[0],i=n.at(-1),o=document.activeElement;t.shiftKey&&(o===r||!e.current?.contains(o))?(t.preventDefault(),i.focus()):!t.shiftKey&&o===i&&(t.preventDefault(),r.focus())};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,r,!0)}},[n,s,e,c,a]),(0,L.useLayoutEffect)(()=>{let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=window.requestAnimationFrame(()=>{if(r===`none`)return;let t=r===`first`?Ap:r;(e.current?.querySelector(t))?.focus({preventScroll:!0})});return()=>{window.cancelAnimationFrame(n),i&&t?.isConnected&&t.focus({preventScroll:!0})}},[r,e,i])}function Np({children:e}){return(0,Jne.createPortal)(e,document.body)}function Pp({anchor:e,className:t,children:n,onDismiss:r,placement:i=`bottom-start`,role:a,ariaLabel:o,id:s,initialFocus:c=`first`,restoreFocus:l=!0,dismissOnOutside:u=!0,onKeyDown:d,dataKind:f}){let p=(0,L.useRef)(null),[m,h]=(0,L.useState)({position:`fixed`,left:0,top:0,visibility:`hidden`}),g=`getBoundingClientRect`in e?e:null;Mp({panelRef:p,onDismiss:r,dismissOnOutside:u,initialFocus:c,restoreFocus:l,outsideElements:[g]});let _=(0,L.useCallback)(()=>{let t=p.current;if(!t)return;let n=Yne(e),r=window.visualViewport,a=r?.offsetLeft??0,o=r?.offsetTop??0,s=r?.width??window.innerWidth,c=r?.height??window.innerHeight,l=t.getBoundingClientRect(),u=Qte({placement:i,target:n,panel:{width:Math.max(l.width,t.scrollWidth),height:Math.max(l.height,t.scrollHeight)},viewport:{left:a,top:o,width:s,height:c}}),d={position:`fixed`,left:u.left,top:u.top,maxWidth:u.maxWidth,maxHeight:u.maxHeight,visibility:`visible`};h(e=>Xne(e,d)?e:d)},[e,i]);return(0,L.useLayoutEffect)(()=>{_();let e=window.requestAnimationFrame(_),t=new ResizeObserver(_);return p.current&&t.observe(p.current),g&&t.observe(g),window.addEventListener(`resize`,_),window.addEventListener(`scroll`,_,!0),window.visualViewport?.addEventListener(`resize`,_),window.visualViewport?.addEventListener(`scroll`,_),()=>{window.cancelAnimationFrame(e),t.disconnect(),window.removeEventListener(`resize`,_),window.removeEventListener(`scroll`,_,!0),window.visualViewport?.removeEventListener(`resize`,_),window.visualViewport?.removeEventListener(`scroll`,_)}},[g,_]),(0,B.jsx)(Np,{children:(0,B.jsx)(`div`,{ref:p,id:s,className:t,style:m,role:a,"aria-label":o,"data-overlay-kind":f,onKeyDown:d,children:n})})}function Fp({shapes:e}){return(0,B.jsx)(B.Fragment,{children:e.map((e,t)=>e.fill?(0,B.jsx)(`path`,{d:e.d,fill:`currentColor`},t):(0,B.jsx)(`path`,{d:e.d,fill:`none`,stroke:`currentColor`,strokeWidth:1.35,strokeLinecap:`round`,strokeLinejoin:`round`},t))})}function Ip({type:e,size:t=14,title:n}){return(0,B.jsxs)(`svg`,{className:`cg-type-icon`,width:t,height:t,viewBox:`0 0 16 16`,"aria-hidden":!n||void 0,role:n?`img`:void 0,"aria-label":n,children:[n&&(0,B.jsx)(`title`,{children:n}),(0,B.jsx)(Fp,{shapes:Ff[e===`measure`?`currency`:e]})]})}function Lp({mode:e,size:t=14}){return(0,B.jsx)(`svg`,{className:`cg-mode-icon`,width:t,height:t,viewBox:`0 0 16 16`,"aria-hidden":!0,children:(0,B.jsx)(Fp,{shapes:If[e]})})}function Rp({mode:e,tone:t,size:n=15}){let r=Lf[t];return(0,B.jsx)(`svg`,{className:`cg-mode-icon cg-tone-icon`,width:n,height:n,viewBox:`0 0 16 16`,"aria-hidden":!0,children:If[e].map((e,t)=>e.fill?(0,B.jsx)(`path`,{d:e.d,fill:r.stroke},t):(0,B.jsx)(`path`,{d:e.d,fill:`none`,stroke:r.stroke,strokeWidth:1.35,strokeLinecap:`round`,strokeLinejoin:`round`},t))})}function Zne({kind:e,size:t=15}){let n=Lf[Nte[e]];return(0,B.jsx)(`svg`,{className:`cg-mode-icon cg-tone-icon`,width:t,height:t,viewBox:`0 0 16 16`,"aria-hidden":!0,children:Mte[e].map((t,r)=>(0,B.jsx)(`path`,{d:t.d,fill:r===0&&(e===`area`||e===`donut`||e===`kpi`||e===`table`)?n.fill:`none`,stroke:n.stroke,strokeWidth:1.35,strokeLinecap:`round`,strokeLinejoin:`round`},r))})}var Qne={width:16,height:16,viewBox:`0 0 16 16`,fill:`none`},zp={stroke:`currentColor`,strokeWidth:1.3,strokeLinecap:`round`,strokeLinejoin:`round`},$ne={duplicate:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`rect`,{x:`5.5`,y:`5.5`,width:`8`,height:`8`,rx:`1.5`,...zp}),(0,B.jsx)(`path`,{d:`M10.5 2.5h-7a1 1 0 0 0-1 1v7`,...zp})]}),insertLeft:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`line`,{x1:`3`,y1:`2.5`,x2:`3`,y2:`13.5`,...zp}),(0,B.jsx)(`path`,{d:`M13.5 8H6.5M9.2 5.3 6.5 8l2.7 2.7`,...zp})]}),insertRight:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`line`,{x1:`13`,y1:`2.5`,x2:`13`,y2:`13.5`,...zp}),(0,B.jsx)(`path`,{d:`M2.5 8h7M6.8 5.3 9.5 8l-2.7 2.7`,...zp})]}),addEnd:(0,B.jsx)(`path`,{d:`M8 3v10M3 8h10`,...zp}),rename:(0,B.jsx)(`path`,{d:`m9.8 3.2 3 3L6.2 12.8l-3.6.6.6-3.6 6.6-6.6Z`,...zp}),description:(0,B.jsx)(`path`,{d:`M3 4.5h10M3 8h10M3 11.5h6`,...zp}),permissions:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`rect`,{x:`3.5`,y:`7`,width:`9`,height:`6`,rx:`1`,...zp}),(0,B.jsx)(`path`,{d:`M5.5 7V5.2a2.5 2.5 0 0 1 5 0V7`,...zp})]}),unlock:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`rect`,{x:`3.5`,y:`7`,width:`9`,height:`6`,rx:`1`,...zp}),(0,B.jsx)(`path`,{d:`M5.5 7V5.2a2.5 2.5 0 0 1 5 0`,...zp})]}),format:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M3 5h5.5M12.5 5H13M3 11h1M7 11h6`,...zp}),(0,B.jsx)(`circle`,{cx:`10.5`,cy:`5`,r:`1.6`,...zp}),(0,B.jsx)(`circle`,{cx:`4.9`,cy:`11`,r:`1.6`,...zp})]}),swap:(0,B.jsx)(`path`,{d:`M3.5 6h9M10.2 3.7 12.5 6l-2.3 2.3M12.5 10.5h-9M5.8 8.2 3.5 10.5l2.3 2.3`,...zp}),sortAsc:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M4.5 3v10M4.5 13l-2-2M4.5 13l2-2`,...zp}),(0,B.jsx)(`path`,{d:`M8.5 4.5h2M8.5 8h3.5M8.5 11.5h5`,...zp})]}),sortDesc:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M4.5 3v10M4.5 13l-2-2M4.5 13l2-2`,...zp}),(0,B.jsx)(`path`,{d:`M8.5 4.5h5M8.5 8h3.5M8.5 11.5h2`,...zp})]}),off:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`,...zp}),(0,B.jsx)(`line`,{x1:`4.4`,y1:`11.6`,x2:`11.6`,y2:`4.4`,...zp})]}),filter:(0,B.jsx)(`path`,{d:`M2.5 3.5h11L9.5 8.5v3.8L6.5 14V8.5L2.5 3.5Z`,...zp}),group:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`line`,{x1:`2.5`,y1:`4`,x2:`13.5`,y2:`4`,...zp}),(0,B.jsx)(`line`,{x1:`5.5`,y1:`8`,x2:`13.5`,y2:`8`,...zp}),(0,B.jsx)(`line`,{x1:`5.5`,y1:`12`,x2:`13.5`,y2:`12`,...zp})]}),pin:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M6 2.5h4l-.5 4L12 9v1H4V9l2.5-2.5L6 2.5Z`,...zp}),(0,B.jsx)(`line`,{x1:`8`,y1:`10`,x2:`8`,y2:`13.5`,...zp})]}),unpin:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M6 2.5h4l-.5 4L12 9v1H4V9l2.5-2.5L6 2.5Z`,...zp}),(0,B.jsx)(`line`,{x1:`8`,y1:`10`,x2:`8`,y2:`13.5`,...zp}),(0,B.jsx)(`line`,{x1:`3`,y1:`13`,x2:`13`,y2:`3`,...zp})]}),hide:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M2.5 8s2-3.5 5.5-3.5S13.5 8 13.5 8s-2 3.5-5.5 3.5S2.5 8 2.5 8Z`,...zp}),(0,B.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.5`,...zp}),(0,B.jsx)(`line`,{x1:`3.5`,y1:`12.5`,x2:`12.5`,y2:`3.5`,...zp})]}),trash:(0,B.jsx)(`path`,{d:`M3.5 4.5h9M6.5 4.5V3h3v1.5M5 4.5l.6 8.5h4.8l.6-8.5`,...zp}),download:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M8 2.5v7M5.3 6.8 8 9.5l2.7-2.7`,...zp}),(0,B.jsx)(`path`,{d:`M3 11v1.5a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V11`,...zp})]}),cohortAdd:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M2.5 4h7M2.5 7.5h5M2.5 11h4`,...zp}),(0,B.jsx)(`path`,{d:`M11.5 8.5v5M9 11h5`,...zp})]})};function ere({name:e}){return(0,B.jsx)(`svg`,{...Qne,"aria-hidden":!0,children:$ne[e]})}function Bp({icon:e,text:t}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`cg-mi-ic`,"aria-hidden":!0,children:typeof e==`string`?(0,B.jsx)(ere,{name:e}):e}),(0,B.jsx)(`span`,{className:`cg-mi-text`,children:t})]})}function Vp({size:e=14}){return(0,B.jsxs)(`svg`,{className:`cg-eyeoff-icon`,width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:[(0,B.jsx)(`path`,{d:`M2.5 8s2-3.5 5.5-3.5S13.5 8 13.5 8s-2 3.5-5.5 3.5S2.5 8 2.5 8Z`,stroke:`currentColor`,strokeWidth:1.4,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,B.jsx)(`path`,{d:`M9.6 8a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0Z`,stroke:`currentColor`,strokeWidth:1.4,strokeLinejoin:`round`}),(0,B.jsx)(`path`,{d:`M3.3 12.7 12.7 3.3`,stroke:`currentColor`,strokeWidth:1.4,strokeLinecap:`round`})]})}function Hp({size:e=11}){return(0,B.jsxs)(`svg`,{className:`cg-lock-mark`,width:e,height:e,viewBox:`0 0 16 16`,"aria-hidden":!0,children:[(0,B.jsx)(`path`,{d:`M4.2 7.2h7.6v5.6H4.2z`,fill:`none`,stroke:`currentColor`,strokeWidth:1.35,strokeLinejoin:`round`}),(0,B.jsx)(`path`,{d:`M5.9 7.2V5.5a2.1 2.1 0 0 1 4.2 0v1.7`,fill:`none`,stroke:`currentColor`,strokeWidth:1.35,strokeLinecap:`round`})]})}function Up({icon:e,size:t=14}){let n=e?.shape??`folder`,r=Lf[e?.tone??`neutral`];return(0,B.jsx)(`svg`,{className:`cg-folder-mark`,width:t,height:t,viewBox:`0 0 16 16`,"aria-hidden":!0,children:Pte[n].map((e,t)=>(0,B.jsx)(`path`,{d:e.d,fill:`none`,stroke:r.stroke,strokeWidth:1.35,strokeLinecap:`round`,strokeLinejoin:`round`},t))})}function Wp({item:e}){return e.icon?(0,B.jsx)(B.Fragment,{children:e.icon}):e.type?(0,B.jsx)(Ip,{type:e.type,title:e.type===`measure`?`Metric`:zf[e.type]}):(0,B.jsx)(`span`,{className:`cg-fsel-nomark`,"aria-hidden":!0})}function tre(){return(0,B.jsx)(`svg`,{className:`cg-fsel-caret`,width:`10`,height:`10`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M4 6l4 4 4-4`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`})})}function nre(){return(0,B.jsx)(`svg`,{className:`cg-type-check`,width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`m3.5 8.5 3 3 6-6.5`,stroke:`currentColor`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`})})}var Gp=8;function Kp({fields:e,value:t,onChange:n,placeholder:r=`Choose a field…`,allow:i,ariaLabel:a,className:o,disabled:s,title:c,keepOpen:l,overlayAutofocus:u}){let[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(``),h=(0,L.useRef)(null),g=(0,L.useRef)(null),_=(0,L.useMemo)(()=>i?e.filter(e=>e.type!=null&&i.includes(e.type)):e,[e,i]),v=t!=null,y=v?e.find(e=>e.key===t):void 0,b=p.trim().toLowerCase(),x=b?_.filter(e=>e.label.toLowerCase().includes(b)):_,S=()=>{f(!1),m(``)},C=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=Array.from(g.current?.querySelectorAll(`button.cg-type-row`)??[]).filter(e=>!e.disabled);if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);if(e.key===`Home`)return t[0].focus();if(e.key===`End`)return t[t.length-1].focus();let r=e.key===`ArrowDown`?1:-1;t[n<0?r===1?0:t.length-1:(n+r+t.length)%t.length].focus()},w;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{ref:h,type:`button`,disabled:s,className:`cg-select cg-fsel`+(y?``:v&&t!==``?` is-missing`:` is-empty`)+(o?` ${o}`:``),"aria-label":a,"aria-haspopup":`listbox`,"aria-expanded":d,"data-overlay-autofocus":u?!0:void 0,onClick:()=>f(e=>!e),children:[y?(0,B.jsx)(Wp,{item:y}):(0,B.jsx)(`span`,{className:`cg-fsel-nomark`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`cg-fsel-label`,children:y?.label??(v&&t!==``?t:r)}),(0,B.jsx)(tre,{})]}),d&&h.current&&(0,B.jsx)(Pp,{anchor:h.current,className:`cg-pop cg-fsel-pop`,onDismiss:S,role:`dialog`,ariaLabel:a??c??`Choose a field`,initialFocus:_.length>=Gp?`.cg-fsel-search input`:`button.cg-type-row`,dataKind:`field-select`,children:(0,B.jsxs)(`div`,{className:`cg-fsel-body`,onKeyDown:C,children:[c&&(0,B.jsx)(`div`,{className:`cg-pop-title`,children:c}),_.length>=Gp&&(0,B.jsxs)(`div`,{className:`cg-type-search cg-fsel-search`,children:[(0,B.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:[(0,B.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.4`,stroke:`currentColor`,strokeWidth:`1.35`}),(0,B.jsx)(`path`,{d:`m10.4 10.4 3.1 3.1`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`})]}),(0,B.jsx)(`input`,{type:`text`,value:p,placeholder:`Find a field…`,"aria-label":`Find a field`,onChange:e=>m(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`cg-type-list`,role:`listbox`,ref:g,"aria-label":a??c??`Fields`,children:[x.map(e=>{let r=e.group&&e.group!==w?e.group:null;return w=e.group,(0,B.jsxs)(L.Fragment,{children:[r&&(0,B.jsx)(`div`,{className:`cg-fsel-group`,role:`presentation`,children:r}),(0,B.jsxs)(`button`,{type:`button`,role:`option`,disabled:e.disabled,"aria-selected":e.key===t,className:`cg-type-row`+(e.key===t?` is-on`:``),onClick:()=>{n(e.key),l?m(``):S()},children:[(0,B.jsx)(Wp,{item:e}),(0,B.jsxs)(`span`,{className:`cg-type-label`,children:[e.label,e.hint&&(0,B.jsx)(`span`,{className:`cg-fsel-hint`,children:e.hint})]}),e.key===t&&(0,B.jsx)(nre,{})]})]},e.key)}),x.length===0&&(0,B.jsx)(`div`,{className:`cg-pop-note`,children:_.length===0?`No field to choose here.`:`No field matches.`})]})]})})]})}function qp(e,t){let n=e=>e.toLocaleString();if(!t?.windowed)return`${n(e)} ${e===1?`record`:`records`}`;let r=t.matched===1?`record`:`records`,i=t.matched=t.matched?`${n(t.matched)} ${r}${i}`:`showing ${n(t.shown)} of ${n(t.matched)} ${r}${i}`}function Jp(e){if(!e?.partial)return null;let t=typeof e.loaded==`number`&&Number.isFinite(e.loaded)&&e.loaded>=0?Math.floor(e.loaded):0,n=typeof e.total==`number`&&Number.isFinite(e.total)&&e.total>0?Math.floor(e.total).toLocaleString():`…`;return`${t.toLocaleString()} of ${n}`}function rre(e,t){if(!t?.windowed)return qp(e,t);let n=e=>e.toLocaleString();return t.shown>=t.matched?`${n(t.matched)} ${t.matched===1?`record`:`records`}`:`showing ${n(t.shown)} of ${n(t.matched)}`}function Yp({window:e,onWindow:t,kinds:n=Pu}){let r=e.kind;return(0,B.jsxs)(`span`,{className:`cg-cond-window`,children:[(0,B.jsx)(`select`,{className:`cg-select cg-cond-win-kind`,value:r,"aria-label":`Date window`,onChange:n=>{let r=n.target.value;Fu.has(r)?t({kind:r,n:e.n??30}):t(r===`custom`?{kind:r,from:e.from??``,to:e.to??``}:{kind:r})},children:(n.includes(r)?n:[...n,r]).map(e=>(0,B.jsx)(`option`,{value:e,children:Fu.has(e)?Iu[e].replace(`{n}`,`N`):Iu[e]},e))}),Fu.has(r)&&(0,B.jsx)(`input`,{className:`cg-input cg-cond-win-n`,type:`number`,min:1,max:3650,"aria-label":`Number of days`,value:e.n??``,onChange:n=>t({...e,n:n.target.value===``?void 0:Number(n.target.value)})}),r===`custom`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{className:`cg-input cg-cond-win-date`,type:`date`,"aria-label":`Window start`,value:e.from??``,onChange:n=>t({...e,from:n.target.value})}),(0,B.jsx)(`span`,{className:`cg-cond-and`,children:`and`}),(0,B.jsx)(`input`,{className:`cg-input cg-cond-win-date`,type:`date`,"aria-label":`Window end`,value:e.to??``,onChange:n=>t({...e,to:n.target.value})})]})]})}var Xp=cd,Zp=ld;function Qp(e){return e===`checkbox`?[`isNotEmpty`,`isEmpty`]:Xp(e)?[`gte`,`gt`,`lte`,`lt`,`eq`,`neq`,`between`,`isEmpty`,`isNotEmpty`]:Zp(e)?[`eq`,`within`,`lt`,`gt`,`lte`,`gte`,`neq`,`isEmpty`,`isNotEmpty`]:e===`status`||e===`select`||e===`user`?[`eq`,`neq`,`isEmpty`,`isNotEmpty`]:[`contains`,`doesNotContain`,`eq`,`neq`,`isEmpty`,`isNotEmpty`]}var ire={topN:`top N`,bottomN:`bottom N`,inTopPct:`top N%`,inBottomPct:`bottom N%`,aboveAvg:`above average`,belowAvg:`below average`,inQuartile:`in quartile`,inDecile:`in decile`};function are(e){switch(e){case`topN`:case`bottomN`:case`inTopPct`:case`inBottomPct`:case`inDecile`:return`10`;case`inQuartile`:return`4`;default:return``}}function $p(e){for(let t of e??[]){if(yd(t)){if($p(t.children))return!0;continue}if(dd(t.op)&&!vd(t))return!0}return!1}function em(e,t){if(dd(e))return ire[e]??e;if(t===`checkbox`){if(e===`isNotEmpty`)return`is checked`;if(e===`isEmpty`)return`is unchecked`}if(e===`isEmpty`)return`is empty`;if(e===`isNotEmpty`)return`is not empty`;if(Zp(t))switch(e){case`eq`:return`is`;case`neq`:return`is not`;case`within`:return`is within`;case`lt`:return`is before`;case`lte`:return`is on or before`;case`gt`:return`is after`;case`gte`:return`is on or after`;case`between`:return`is between`}if(Xp(t))switch(e){case`gte`:return`≥`;case`gt`:return`>`;case`lte`:return`≤`;case`lt`:return`<`;case`eq`:return`=`;case`neq`:return`≠`;case`between`:return`is between`;default:return e}if(t===`multiselect`)switch(e){case`contains`:return`has`;case`doesNotContain`:return`does not have`;case`eq`:return`is exactly`;case`neq`:return`is not exactly`;default:return e}switch(e){case`contains`:return`contains`;case`doesNotContain`:return`does not contain`;case`eq`:return`is`;case`neq`:return`is not`;default:return e}}function ore(e,t){return t&&!e.includes(t)?[...e,t]:[...e]}function sre(e){return e===`or`?`Any of the following are true…`:`All of the following are true…`}var tm=[...Mee],nm=[...Nee],rm=[...Dee];function cre(e){switch(md(e)){case`allOf`:return`is all of`;case`noneOf`:return`is none of`;default:return`is any of`}}var im=`measure`,am={kind:`ltm`},om={kind:`past_month`},lre=[`last_n_days`,`past_week`,`past_month`,`past_year`,`this_week`,`this_month`,`this_year`,`custom`];function ure(e,t,n,r,i){let a=e.map(e=>({key:e.key,label:e.label,type:e.type})),o=new Set(a.map(e=>e.key));if(!t||o.has(t)||r.has(t)||t===`__cohort__`&&i)return a;let s=n.get(t);return a.push({key:t,label:s?s.label:t,type:s?.type}),a}var sm=0;function cm(){return sm+=1,`r${Date.now().toString(36)}${sm.toString(36)}`}function lm(e){let t=e[0];return t?{colId:t.key,op:Qp(t.type)[0],value:``}:null}function um(e){let t=0;for(let n of e)t+=yd(n)?um(n.children):1;return t}function dre({rule:e,onPatch:t}){let n=e.dateMode??`exact`;return(0,B.jsxs)(`span`,{className:`cg-cond-anchor`,children:[(0,B.jsx)(`select`,{className:`cg-select cg-cond-anchor-mode`,value:n,"aria-label":`Date`,onChange:e=>{let n=e.target.value;t({dateMode:n,value:``})},children:Lu.map(e=>(0,B.jsx)(`option`,{value:e,children:e===`n_days_ago`?Ru[e].replace(`{n}`,`N`):Ru[e]},e))}),n===`n_days_ago`&&(0,B.jsx)(`input`,{className:`cg-input cg-cond-win-n`,type:`number`,min:0,max:3650,"aria-label":`Number of days ago`,value:e.value,onChange:e=>t({value:e.target.value})}),n===`exact`&&(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:`date`,"aria-label":`Date`,value:e.value,onChange:e=>t({value:e.target.value})})]})}function fre({rule:e,options:t,isMeasure:n,onPatch:r}){let i=e.rhs,a=gd(i)??``;return(0,B.jsxs)(`span`,{className:`cg-cond-rhs`,children:[(0,B.jsx)(Kp,{className:`cg-cond-field`,ariaLabel:`Compare with field`,placeholder:`Select a field…`,value:a||void 0,fields:t,onChange:e=>{r({rhs:n?{kind:`measure`,colId:e,window:i?.kind===`measure`&&i.window||am}:{kind:`field`,colId:e}})}}),n&&a!==``&&(0,B.jsx)(Yp,{window:i?.kind===`measure`&&i.window||am,onWindow:e=>r({rhs:{kind:`measure`,colId:a,window:e}})})]})}function pre({rule:e,type:t,statusOptions:n,onValue:r,onValue2:i}){if(e.op===`between`){let n=t===`date`||t===`created_time`?`date`:`number`;return(0,B.jsxs)(`span`,{className:`cg-cond-between`,children:[(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:n,value:e.value,onChange:e=>r(e.target.value)}),(0,B.jsx)(`span`,{className:`cg-cond-and`,children:`and`}),(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:n,value:e.value2??``,onChange:e=>i(e.target.value)})]})}return t===`status`||t===`select`||t===`user`||t===`multiselect`?(0,B.jsxs)(`select`,{className:`cg-select cg-cond-val`,value:e.value,onChange:e=>r(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`Select…`}),n.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]}):(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:t===`date`||t===`created_time`?`date`:Xp(t)?`number`:`text`,placeholder:`Value`,value:e.value,onChange:e=>r(e.target.value)})}function mre({rule:e,onValue:t}){let n=e.op===`inQuartile`?4:e.op===`inDecile`?10:0;if(n)return(0,B.jsx)(`select`,{className:`cg-select cg-cond-val`,value:e.value,"aria-label":e.op===`inQuartile`?`Quartile`:`Decile`,onChange:e=>t(e.target.value),children:Array.from({length:n},(e,t)=>String(t+1)).map(e=>(0,B.jsx)(`option`,{value:e,children:e===`1`?`${e} (lowest)`:e===String(n)?`${e} (highest)`:e},e))});let r=e.op===`inTopPct`||e.op===`inBottomPct`;return(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:`number`,min:1,max:r?100:1e4,step:1,placeholder:`10`,"aria-label":r?`Percent`:`How many`,value:e.value,onChange:e=>t(e.target.value)})}function hre({rule:e,lists:t,onPatch:n}){let r=hd(e.value),i=new Map(t.map(e=>[e.id,e.name])),a=t.filter(e=>!r.includes(e.id)),o=a.length>0&&r.length<20,s=e=>n({value:e.join(`,`)});return(0,B.jsxs)(`span`,{className:`cg-cond-cohorts`,children:[r.map(e=>(0,B.jsxs)(`span`,{className:`cg-chip`+(i.has(e)?``:` cg-chip--gone`),children:[(0,B.jsx)(`span`,{className:`cg-chip-text`,children:i.get(e)??`(deleted list)`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-chip-x`,"aria-label":`Remove ${i.get(e)??e}`,onClick:()=>s(r.filter(t=>t!==e)),children:`×`})]},e)),(0,B.jsxs)(`select`,{className:`cg-select cg-cond-val cg-cond-cohort-add`,value:``,"aria-label":`Cohort`,disabled:!o,onChange:e=>e.target.value&&s([...r,e.target.value]),children:[(0,B.jsx)(`option`,{value:``,children:o?r.length?`Add a cohort…`:`Select a cohort…`:`all added`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})}function gre({index:e,conj:t,onConj:n}){return e===0?(0,B.jsx)(`span`,{className:`cg-cond-prefix`,children:`Where`}):e===1?(0,B.jsxs)(`select`,{className:`cg-select cg-cond-conj`,value:t,"aria-label":`Combine conditions with`,onChange:e=>n(e.target.value),children:[(0,B.jsx)(`option`,{value:`and`,children:`and`}),(0,B.jsx)(`option`,{value:`or`,children:`or`})]}):(0,B.jsx)(`span`,{className:`cg-cond-prefix cg-cond-conj-echo`,children:t})}function dm({nodes:e,conj:t,depth:n,ctx:r,onNodes:i,onConj:a}){let[o,s]=(0,L.useState)(null),c=(t,n)=>i(e.map((e,r)=>r===t?n:e)),l=t=>i(e.filter((e,n)=>n!==t)),u=()=>{let t=lm(r.fields);t&&i([...e,t])},d=()=>{let t=lm(r.fields);t&&i([...e,{conj:`or`,children:[t]}])},f=n<3;return(0,B.jsxs)(B.Fragment,{children:[e.map((e,i)=>(0,B.jsxs)(`div`,{className:`cg-cond-line`,children:[(0,B.jsx)(gre,{index:i,conj:t,onConj:a}),yd(e)?(0,B.jsx)(vre,{group:e,depth:n+1,ctx:r,onGroup:e=>c(i,e),onRemove:()=>l(i)}):(0,B.jsx)(_re,{rule:e,ctx:r,onRule:e=>c(i,e),onRemove:()=>l(i)})]},i)),(0,B.jsxs)(`div`,{className:`cg-builder-add`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`+(o===`condition`?` is-on`:``),onClick:()=>{s(`condition`),u()},children:`+ Add condition`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`+(o===`group`?` is-on`:``),onClick:()=>{s(`group`),d()},disabled:!f,title:f?`Group conditions so they evaluate together`:`Condition groups can nest 3 levels deep`,children:`+ Add condition group`})]})]})}function _re({rule:e,ctx:t,onRule:n,onRemove:r}){let{fields:i,fieldByKey:a,measures:o,measureByKey:s,lists:c,choicesFor:l}=t,u=vd(e),d=e.colId===pd,f=c.length>0,p=u?s.get(e.colId)?.type??`currency`:a.get(e.colId)?.type??`text`,m=t=>n({...e,...t}),h=t=>{if(t===`__cohort__`){n({colId:pd,op:rm[0],value:``});return}if(s.get(t)){n({id:e.id??cm(),colId:t,op:tm[0],value:``,value2:void 0,window:e.window??am});return}n({colId:t,op:Qp(a.get(t)?.type??`text`)[0],value:``,value2:void 0})},g=t=>{if(d)return m({op:t});if(dd(t))return n({...e,op:t,value:are(t),value2:void 0,rhs:void 0,dateWindow:void 0});if(fd.has(t))return n({...e,op:t,value:``,value2:void 0,rhs:void 0});if(t===`within`)return n({...e,op:t,value:``,value2:void 0,rhs:void 0,dateWindow:e.dateWindow??om});if(e.op===`within`)return n({...e,op:t,dateWindow:void 0,value:``});m({op:t})},_=u?o.map(e=>({key:e.key,label:e.label,type:im})):i.filter(t=>t.key!==e.colId&&(Xp(p)?Xp(t.type):t.type===p)).map(e=>({key:e.key,label:e.label,type:e.type})),v=!d&&e.op!==`within`&&!fd.has(e.op)&&!dd(e.op)&&_.length>0&&(u||Xp(p)||Zp(p)),y=e.rhs?.kind===`stat`,b=e.rhs!=null&&!y,x=u?b||y?nm:tm:d?rm:Qp(p),S=d?md(e.op):e.op,C=ore(!u&&!d&&Xp(p)?[...x,...wee]:x,S),w=C.filter(e=>!dd(e)),T=C.filter(e=>dd(e));return(0,B.jsxs)(`span`,{className:`cg-cond-row`+(u?` is-measure`:``)+(d?` is-cohort`:``)+(e.rhs==null?``:` has-rhs`),children:[(0,B.jsx)(Kp,{className:`cg-cond-field`,ariaLabel:`Field`,value:e.colId,onChange:h,fields:[...ure(i,e.colId,a,s,f),...o.map(e=>({key:e.key,label:e.label,type:im})),...f?[{key:pd,label:`Cohort`,type:`multiselect`}]:[]]}),u&&(0,B.jsx)(Yp,{window:e.window??am,onWindow:e=>m({window:e})}),(0,B.jsxs)(`select`,{className:`cg-select cg-cond-op`,value:S,"aria-label":`Condition`,onChange:e=>g(e.target.value),children:[w.map(e=>(0,B.jsx)(`option`,{value:e,children:d?cre(e):em(e,p)},e)),T.length>0&&(0,B.jsx)(`optgroup`,{label:`Ranked`,children:T.map(e=>(0,B.jsx)(`option`,{value:e,children:em(e,p)},e))})]}),v&&(0,B.jsxs)(`select`,{className:`cg-select cg-cond-mode`,value:y?`stat`:b?`field`:`value`,"aria-label":`Compare against`,onChange:t=>{let n=t.target.value;if(n===`stat`)return m({rhs:{kind:`stat`,stat:`median`},value:``,value2:void 0,op:nm.includes(e.op)?e.op:nm[1]});if(n===`field`)return m({rhs:u?{kind:`measure`,colId:``,window:am}:{kind:`field`,colId:``},value:``,value2:void 0});m({rhs:void 0,value:``})},children:[(0,B.jsx)(`option`,{value:`value`,children:`a value`}),(0,B.jsx)(`option`,{value:`field`,children:`another field`}),u&&(0,B.jsx)(`option`,{value:`stat`,children:`a statistic`})]}),fd.has(e.op)?(0,B.jsx)(`span`,{className:`cg-cond-val cg-cond-noval`,"aria-hidden":!0}):y?(0,B.jsx)(`select`,{className:`cg-select cg-cond-val cg-cond-stat`,value:e.rhs?.kind===`stat`?e.rhs.stat:`median`,"aria-label":`Statistic`,onChange:e=>m({rhs:{kind:`stat`,stat:e.target.value}}),children:kee.map(e=>(0,B.jsx)(`option`,{value:e,children:Aee[e]},e))}):b?(0,B.jsx)(fre,{rule:e,options:_,isMeasure:u,onPatch:m}):d?(0,B.jsx)(hre,{rule:e,lists:c,onPatch:m}):dd(e.op)?(0,B.jsx)(mre,{rule:e,onValue:e=>m({value:e})}):e.op===`within`?(0,B.jsx)(Yp,{window:e.dateWindow??om,onWindow:e=>m({dateWindow:e}),kinds:lre}):Zp(p)?(0,B.jsx)(dre,{rule:e,onPatch:m}):(0,B.jsx)(pre,{rule:e,type:p,statusOptions:l(e.colId),onValue:e=>m({value:e}),onValue2:e=>m({value2:e})}),(0,B.jsx)(`button`,{type:`button`,className:`cg-cond-x`,"aria-label":`Remove condition`,onClick:r,children:`×`})]})}function vre({group:e,depth:t,ctx:n,onGroup:r,onRemove:i}){return(0,B.jsxs)(`span`,{className:`cg-cond-group`,"data-depth":t,children:[(0,B.jsxs)(`span`,{className:`cg-cond-group-head`,children:[(0,B.jsx)(`span`,{className:`cg-cond-group-sum`,children:e.children.length?sre(e.conj):`Add a condition to this group…`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-cond-x`,"aria-label":`Remove condition group`,onClick:i,children:`×`})]}),(0,B.jsx)(`span`,{className:`cg-cond-group-body`,children:(0,B.jsx)(dm,{nodes:e.children,conj:e.conj,depth:t,ctx:n,onNodes:t=>r({...e,children:t}),onConj:t=>r({...e,conj:t})})})]})}function fm({fields:e,filters:t,onChange:n,cohorts:r=[],measures:i=[],userOptions:a,statusValues:o,cohortLock:s,footerExtra:c}){let l=bd(t),u=xd(t),d=(0,L.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.key,n);return t},[e]),f=(0,L.useMemo)(()=>mee(e),[e]),p=(0,L.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.key,t);return e},[i]),m=(0,L.useCallback)(e=>{let t=o?.[e];if(t)return t;let n=d.get(e);return n?n.type===`user`?a??[]:nd(n):[]},[o,d,a]),h=(0,L.useMemo)(()=>({fields:f,fieldByKey:d,measures:i,measureByKey:p,lists:r,choicesFor:m}),[f,d,i,p,r,m]);return(0,B.jsxs)(`div`,{className:`cg-pop-body cg-builder`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Filter`}),s&&(0,B.jsx)(`div`,{className:`cg-flt-lockchip`,children:s.name?`Customer list locked to ${s.name}`+(typeof s.count==`number`?` · ${s.count.toLocaleString()} ${s.count===1?`customer`:`customers`}`:``):`Customer list locked to a set you cannot see`}),l.length===0?(0,B.jsx)(`div`,{className:`cg-builder-empty`,children:`No conditions. Add one to narrow the list.`}):(0,B.jsx)(`div`,{className:`cg-builder-caption`,children:`In this view, show records`}),(0,B.jsx)(dm,{nodes:l,conj:u,depth:1,ctx:h,onNodes:e=>n({conj:u,nodes:e}),onConj:e=>n({conj:e,nodes:l})}),$p(l)&&(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`Ranked among the records your other conditions keep — so “top 10” inside a filtered view means the top 10 of that view. Records with no value are not ranked at all. Quartiles and deciles are equal-size slices BY RANK, not by value.`}),(l.length>0||c)&&(0,B.jsxs)(`div`,{className:`cg-pop-footer cg-builder-footer`,children:[l.length>0&&(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>n({conj:u,nodes:[]}),children:`Clear all`}),c]})]})}function pm({fields:e,hidden:t,onToggle:n,onHideAll:r,onShowAll:i,lockedKey:a,onFieldOrder:o,deletableKeys:s,onDeleteField:c}){let[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=l.trim().toLowerCase(),v=_?e.filter(e=>e.label.toLowerCase().includes(_)):e,y=!!o&&_===``,b=(t,n)=>{if(t===n||t===a||n===a)return null;let r=e.map(e=>e.key),i=r.indexOf(t),o=r.indexOf(n);if(i<0||o<0)return null;let s=r.slice();return s.splice(i,1),s.splice(o,0,t),s},x=(t,n)=>{if(!y)return;let r=e.map(e=>e.key),i=r[r.indexOf(t)+n];if(i===void 0)return;let a=b(t,i);a&&o(a)};return(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Hide fields`}),(0,B.jsx)(`input`,{type:`text`,className:`cg-input cg-fields-search`,placeholder:`Find a field…`,"aria-label":`Find a field`,value:l,onChange:e=>u(e.target.value)}),(0,B.jsxs)(`div`,{className:`cg-pop-list`,children:[v.map(e=>{let r=a!==void 0&&e.key===a,i=!t.has(e.key),l=!!c&&!!s?.has(e.key),u=d===e.key;return(0,B.jsxs)(`label`,{className:`cg-check-row`+(i?``:` is-off`)+(r?` is-locked`:``)+(p===e.key?` is-dragging`:``)+(h===e.key&&p!==null&&p!==e.key?` is-drop-target`:``),title:r?`Always visible`:void 0,onDragOver:y&&p&&p!==e.key?t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,h!==e.key&&g(e.key)}:void 0,onDrop:y&&p?t=>{t.preventDefault(),t.stopPropagation();let n=b(p,e.key);m(null),g(null),n&&o(n)}:void 0,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-field-grip`,draggable:y&&!r,"aria-label":r?`${e.label} is always first`:y?`Reorder ${e.label} — drag, or use the arrow keys`:`Reorder ${e.label} (clear the search first)`,title:y&&!r?`Drag to reorder, or use the arrow keys`:r?`This column is always first`:`Clear the search to reorder`,onDragStart:t=>{t.dataTransfer.setData(`text/plain`,e.key),t.dataTransfer.effectAllowed=`move`,m(e.key)},onDragEnd:()=>{m(null),g(null)},onClick:e=>{e.preventDefault(),e.stopPropagation()},onKeyDown:t=>{t.key!==`ArrowUp`&&t.key!==`ArrowDown`||(t.preventDefault(),t.stopPropagation(),x(e.key,t.key===`ArrowUp`?-1:1))},children:(0,B.jsx)(`svg`,{width:`10`,height:`16`,viewBox:`0 0 10 16`,"aria-hidden":!0,focusable:`false`,children:[4,8,12].map(e=>[2.5,7.5].map(t=>(0,B.jsx)(`circle`,{cx:t,cy:e,r:`1.15`,fill:`currentColor`},`${t}-${e}`)))})}),(0,B.jsx)(`input`,{type:`checkbox`,checked:i,disabled:r,onChange:()=>n(e.key)}),(0,B.jsx)(Ip,{type:e.type,title:zf[e.type]}),(0,B.jsx)(`span`,{className:`cg-check-label`,children:e.label}),e.source===`odoo`&&!e.custom&&(0,B.jsx)(`span`,{className:`cg-preset-tag`,children:`Pre-set`}),e.scope===`cohort`&&(0,B.jsx)(`span`,{className:`cg-preset-tag cg-scope-tag`,children:`Cohort-only`}),r&&(0,B.jsx)(`span`,{className:`cg-lock-tag`,children:`Locked`}),l&&(0,B.jsx)(`button`,{type:`button`,className:`cg-check-del`+(u?` is-armed`:``),"aria-label":u?`Permanently delete ${e.label}?`:`Delete ${e.label}`,title:u?void 0:`Removes this field and its values on every row.`,onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!u){f(e.key);return}f(null),c(e.key)},children:u?`Delete permanently?`:(0,B.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M3.5 4.5h9M6.5 4.5V3h3v1.5M5 4.5l.6 8.5h4.8l.6-8.5`,stroke:`currentColor`,strokeWidth:1.3,strokeLinecap:`round`,strokeLinejoin:`round`})})})]},e.key)}),v.length===0&&(0,B.jsx)(`div`,{className:`cg-builder-empty`,children:`No field matches your search.`})]}),(i||r)&&(0,B.jsxs)(`div`,{className:`cg-pop-footer cg-fields-footer`,children:[i&&(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:i,children:`Show all`}),r&&(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:r,children:`Hide all`})]})]})}var yre={stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`};function bre(){return(0,B.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M4 6l4 4 4-4`,...yre})})}function mm({label:e,icon:t,active:n,tone:r,wide:i,measureWide:a,pairWide:o,forceOpenSignal:s,children:c}){let[l,u]=(0,L.useState)(!1),d=(0,L.useRef)(null),f=(0,L.useId)();return(0,L.useEffect)(()=>{s&&s>0&&u(!0)},[s]),(0,B.jsxs)(`div`,{className:`cg-pop-wrap`,children:[(0,B.jsxs)(`button`,{ref:d,type:`button`,className:`cg-tb-btn`+(r?` cg-tb-btn--${r}`:``)+(n||l?` is-active`:``),onClick:()=>u(e=>!e),"aria-expanded":l,"aria-haspopup":`dialog`,"aria-controls":l?f:void 0,title:e,"aria-label":e,children:[t,(0,B.jsx)(`span`,{className:`cg-tb-label`,children:e}),(0,B.jsx)(bre,{})]}),l&&d.current&&(0,B.jsx)(Pp,{anchor:d.current,className:`cg-pop`+(i?` cg-pop--wide`:``)+(a?` cg-pop--measures`:``)+(o?` cg-pop--pair`:``),onDismiss:()=>u(!1),role:`dialog`,ariaLabel:`${e} options`,id:f,dataKind:`toolbar-${e.split(` `)[0].toLowerCase()}`,children:c(()=>u(!1))})]})}var hm={width:14,height:14,viewBox:`0 0 16 16`,fill:`none`},gm={stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`};function xre(){return(0,B.jsxs)(`svg`,{...hm,"aria-hidden":!0,children:[(0,B.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`,...gm}),(0,B.jsx)(`line`,{x1:`6.5`,y1:`3`,x2:`6.5`,y2:`13`,...gm}),(0,B.jsx)(`line`,{x1:`10.5`,y1:`3`,x2:`10.5`,y2:`13`,...gm})]})}function _m(){return(0,B.jsx)(`svg`,{...hm,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M2.5 4h11L9.5 9v3.5L6.5 14V9L2.5 4Z`,...gm})})}function vm(){return(0,B.jsxs)(`svg`,{...hm,"aria-hidden":!0,children:[(0,B.jsx)(`path`,{d:`M5 3v10M5 13l-2-2M5 13l2-2`,...gm}),(0,B.jsx)(`path`,{d:`M11 13V3M11 3l-2 2M11 3l2 2`,...gm})]})}function Sre(){return(0,B.jsx)(`svg`,{...hm,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M8 2s4.5 4.2 4.5 7a4.5 4.5 0 0 1-9 0C3.5 6.2 8 2 8 2Z`,...gm})})}function ym(){return(0,B.jsxs)(`svg`,{...hm,"aria-hidden":!0,children:[(0,B.jsx)(`line`,{x1:`2.5`,y1:`5`,x2:`13.5`,y2:`5`,...gm}),(0,B.jsx)(`line`,{x1:`2.5`,y1:`8`,x2:`13.5`,y2:`8`,...gm}),(0,B.jsx)(`line`,{x1:`2.5`,y1:`11`,x2:`13.5`,y2:`11`,...gm})]})}function bm(){return(0,B.jsxs)(`svg`,{...hm,"aria-hidden":!0,children:[(0,B.jsx)(`line`,{x1:`2.5`,y1:`4`,x2:`13.5`,y2:`4`,...gm}),(0,B.jsx)(`line`,{x1:`5.5`,y1:`8`,x2:`13.5`,y2:`8`,...gm}),(0,B.jsx)(`line`,{x1:`5.5`,y1:`12`,x2:`13.5`,y2:`12`,...gm})]})}function Cre(){return(0,B.jsxs)(`svg`,{...hm,"aria-hidden":!0,children:[(0,B.jsx)(`rect`,{x:`3.5`,y:`7`,width:`9`,height:`6`,rx:`1.2`,...gm}),(0,B.jsx)(`path`,{d:`M5.75 7V5.25a2.25 2.25 0 0 1 4.5 0V7`,...gm})]})}function wre(){return(0,B.jsxs)(`svg`,{...hm,"aria-hidden":!0,children:[(0,B.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4`,...gm}),(0,B.jsx)(`line`,{x1:`10.2`,y1:`10.2`,x2:`13.5`,y2:`13.5`,...gm})]})}var Tre={filters:(0,B.jsx)(_m,{}),sorts:(0,B.jsx)(vm,{}),groupBy:(0,B.jsx)(bm,{}),visible:(0,B.jsx)(Vp,{}),order:(0,B.jsx)(xre,{}),rowHeightMode:(0,B.jsx)(ym,{})};function Ere({views:e,lockedKey:t,onApply:n,onClose:r}){let[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(()=>new Set([`filters`])),c=e.find(e=>e.id===i),l=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,B.jsxs)(`div`,{className:`cg-pop-body cg-copycfg`,children:[(0,B.jsxs)(`div`,{className:`cg-copycfg-head`,children:[(0,B.jsx)(`span`,{children:`Copy configuration from`}),(0,B.jsx)(Kp,{className:`cg-copycfg-source`,ariaLabel:`View to copy from`,placeholder:`Choose a view…`,value:i||void 0,onChange:a,fields:e.map(e=>({key:e.id,label:e.name,icon:(0,B.jsx)(Lp,{mode:wd(e)})}))}),(0,B.jsx)(`span`,{children:`to this view`})]}),(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`Select what to copy. This view keeps everything else.`}),(0,B.jsx)(`div`,{className:`cg-pop-list`,children:Tp.map(e=>(0,B.jsxs)(`label`,{className:`cg-check-row`,title:e.blurb,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:o.has(e.key),onChange:()=>l(e.key)}),(0,B.jsx)(`span`,{className:`cg-mi-ic`,"aria-hidden":!0,children:Tre[e.key]}),(0,B.jsx)(`span`,{className:`cg-check-label`,children:e.label})]},e.key))}),(0,B.jsxs)(`div`,{className:`cg-pop-footer cg-copycfg-bulk`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>s(new Set(Ep)),children:`Select all`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>s(new Set),children:`Clear all`})]}),(0,B.jsxs)(`div`,{className:`cg-form-actions cg-copycfg-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:!c||o.size===0,title:c?o.size===0?`Choose at least one thing to copy`:void 0:`Choose the view to copy from`,onClick:()=>{c&&(n(Kne(c.config,o,t)),r())},children:`Copy configuration`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:r,children:`Cancel`})]})]})}function Dre({views:e,lockedKey:t,onApply:n}){let[r,i]=(0,L.useState)(!1),a=(0,L.useRef)(null);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{ref:a,type:`button`,className:`cg-link-btn cg-copy-link`+(r?` is-on`:``),"aria-expanded":r,onClick:()=>i(e=>!e),children:`Copy from another view`}),r&&a.current&&(0,B.jsx)(Pp,{anchor:a.current,className:`cg-pop cg-copycfg-pop`,placement:`bottom-end`,onDismiss:()=>i(!1),role:`dialog`,ariaLabel:`Copy configuration from another view`,dataKind:`copy-config`,children:(0,B.jsx)(Ere,{views:e,lockedKey:t,onApply:n,onClose:()=>i(!1)})})]})}function Ore({fields:e,fieldByKey:t,sorts:n,onSorts:r}){let i=(e,t)=>r(n.map((n,r)=>r===e?{...n,...t}:n)),a=e=>r(n.filter((t,n)=>n!==e));return(0,B.jsxs)(`div`,{className:`cg-pop-body cg-builder`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Sort`}),n.length===0&&(0,B.jsx)(`div`,{className:`cg-builder-empty`,children:`No sorts. Add one to order the list.`}),n.map((n,r)=>{let o=t.get(n.colId)?.type??`text`;return(0,B.jsxs)(`div`,{className:`cg-cond-line`,children:[(0,B.jsx)(`span`,{className:`cg-cond-prefix`,children:r===0?`Sort by`:`then by`}),(0,B.jsxs)(`span`,{className:`cg-cond-row`,children:[(0,B.jsx)(Kp,{className:`cg-cond-field`,ariaLabel:`Sort field`,value:n.colId,onChange:e=>i(r,{colId:e}),fields:e.map(e=>({key:e.key,label:e.label,type:e.type}))}),(0,B.jsxs)(`select`,{className:`cg-select cg-cond-op`,value:n.dir,"aria-label":`Sort direction`,onChange:e=>i(r,{dir:e.target.value}),children:[(0,B.jsx)(`option`,{value:`asc`,children:ud(o,`asc`)}),(0,B.jsx)(`option`,{value:`desc`,children:ud(o,`desc`)})]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-cond-x`,"aria-label":`Remove sort`,onClick:()=>a(r),children:`×`})]})]},r)}),(0,B.jsxs)(`div`,{className:`cg-pop-footer cg-builder-footer`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>{let t=new Set(n.map(e=>e.colId)),i=e.find(e=>!t.has(e.key))??e[0];i&&r([...n,{colId:i.key,dir:`asc`}])},children:`+ Add another sort`}),n.length>0&&(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>r([]),children:`Clear`})]})]})}var kre=[{mode:`short`,label:`Short`},{mode:`medium`,label:`Medium`},{mode:`tall`,label:`Tall`}];function Are({fields:e,visible:t,nouns:n=`customers`,lockedKey:r,onColumnVisible:i,onColumnsVisible:a,orderedFields:o,onFieldOrder:s,deletableKeys:c,onDeleteField:l,colorOn:u,onToggleColor:d,rowHeightMode:f,onRowHeightMode:p,filters:m,onFilters:h,filterConj:g,onFilterConj:_,sorts:v,onSorts:y,groupBy:b,onGroupBy:x,statusValues:S,measures:C=[],pendingMeasureCount:w=0,unresolvedCount:T=0,lists:E=[],cohortLock:D,copyViews:O,onCopyConfig:k,search:A,onSearch:j,recordCount:M,scopeCounts:ee,pool:N,serverWindowed:te=!1,cohortAction:ne,filterSeed:P=null,modeControl:re}){let F=e.filter(e=>t.has(e.key)).length,ie=(0,L.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.key,n);return t},[e]),ae=(0,L.useMemo)(()=>{let e=new Map;for(let t of C)e.set(t.key,t);return e},[C]),oe=o??e,se=(0,L.useMemo)(()=>new Set(oe.filter(e=>!t.has(e.key)).map(e=>e.key)),[oe,t]),ce=(0,L.useMemo)(()=>({conj:g,nodes:m}),[g,m]),le=e=>{let t=bd(e),n=xd(e);t!==m&&h(t),n!==g&&_(n)},ue=!!D,de=!!k&&(O?.length??0)>0,fe=(0,L.useMemo)(()=>e.filter(e=>Cee(e,r)),[e,r]),pe=(0,L.useRef)(0);(0,L.useEffect)(()=>{if(!P||P.n===pe.current)return;if(pe.current=P.n,P.measure){let e=ae.get(P.measure.key);if(!e)return;h([...m,{id:cm(),colId:e.key,op:tm[0],value:``,window:P.measure.window}]);return}let e=P.key?ie.get(P.key):void 0;!e||e.filterable===!1||h([...m,{colId:e.key,op:Qp(e.type)[0],value:``}])},[P,ie,ae,m,h]);let me=(0,L.useMemo)(()=>um(m),[m]),he=(0,L.useMemo)(()=>{let e=t=>t.some(t=>yd(t)?e(t.children):t.rhs!=null&&t.rhs.kind!==`stat`);return e(m)},[m]),ge=me?`Filter · ${me}`:`Filter`,_e=v.length?`Sort · ${v.length}`:`Sort`,ve=b?`Group: ${ie.get(b)?.label??`?`}`:`Group`;return(0,B.jsxs)(`div`,{className:`cg-toolbar`,children:[re,(0,B.jsx)(mm,{label:`Hide fields`,icon:(0,B.jsx)(Vp,{}),active:F(0,B.jsx)(pm,{fields:oe,hidden:se,onToggle:e=>i(e,!t.has(e)),onShowAll:()=>a(e.map(e=>e.key)),onHideAll:()=>a([r]),lockedKey:r,onFieldOrder:s,deletableKeys:c,onDeleteField:l})}),(0,B.jsx)(mm,{label:ge,icon:(0,B.jsx)(_m,{}),active:me>0,tone:`filter`,wide:!0,measureWide:C.length>0,pairWide:he,forceOpenSignal:P?.n,children:()=>(0,B.jsx)(fm,{fields:e,measures:C,cohorts:E,filters:ce,onChange:le,statusValues:S,cohortLock:D,footerExtra:de?(0,B.jsx)(Dre,{views:O,lockedKey:r,onApply:e=>k(e)}):void 0})}),(0,B.jsx)(mm,{label:_e,icon:(0,B.jsx)(vm,{}),active:v.length>0,tone:`sort`,wide:!0,children:()=>(0,B.jsx)(Ore,{fields:e,fieldByKey:ie,sorts:v,onSorts:y})}),(0,B.jsx)(mm,{label:ve,icon:(0,B.jsx)(bm,{}),active:b!==null,tone:`group`,children:()=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Group by`}),te?(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`Not available on this table. It loads one page at a time, so a group would count only the rows currently fetched.`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-group`,checked:b===null,onChange:()=>x(null)}),(0,B.jsx)(`span`,{children:`No grouping`})]}),fe.map(e=>(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-group`,checked:b===e.key,onChange:()=>x(e.key)}),(0,B.jsx)(Ip,{type:e.type,title:zf[e.type]}),(0,B.jsx)(`span`,{children:e.label})]},e.key))]})]})}),(0,B.jsx)(`span`,{className:`cg-tb-divider`,"aria-hidden":!0}),(0,B.jsx)(mm,{label:`Color`,icon:(0,B.jsx)(Sre,{}),active:u,children:()=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Color`}),(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-color`,checked:!u,onChange:()=>d(!1)}),(0,B.jsx)(`span`,{children:`No color`})]}),(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-color`,checked:u,onChange:()=>d(!0)}),(0,B.jsx)(`span`,{children:`Color by status`})]})]})}),(0,B.jsx)(mm,{label:`Rows`,icon:(0,B.jsx)(ym,{}),active:f!==`short`,children:()=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Row height`}),kre.map(e=>(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-rowh`,checked:f===e.mode,onChange:()=>p(e.mode)}),(0,B.jsx)(`span`,{children:e.label})]},e.mode))]})}),ue&&(0,B.jsxs)(`span`,{className:`cg-tb-lock`,title:(D?.name?`Locked to ${D.name}. `:`Locked to a set of records you cannot see. `)+`Only the records locked into that view are shown. Filters and sort narrow WITHIN the lock; the lock itself is changed from the view menu in the rail.`,children:[(0,B.jsx)(Cre,{}),(0,B.jsx)(`span`,{className:`cg-tb-label`,children:`Locked`})]}),(0,B.jsxs)(`div`,{className:`cg-search`,children:[(0,B.jsx)(`span`,{className:`cg-search-icon`,"aria-hidden":!0,children:(0,B.jsx)(wre,{})}),(0,B.jsx)(`input`,{type:`text`,className:`cg-search-input`,placeholder:`Search ${n}…`,value:A,onChange:e=>j(e.target.value)}),A&&(0,B.jsx)(`button`,{type:`button`,className:`cg-search-clear`,"aria-label":`Clear search`,onClick:()=>j(``),children:`×`})]}),ne,(0,B.jsx)(`span`,{className:`cg-tb-spacer`}),w>0&&(0,B.jsx)(`span`,{className:`cg-count cg-count-pending`,title:`${w} measure condition${w===1?``:`s`} still being calculated over the period you chose. Rows are hidden until the answer arrives rather than shown under a count that would be wrong.`,children:`Calculating…`}),T>0&&(0,B.jsx)(`span`,{className:`cg-count cg-count-pending`,title:`${T} condition${T===1?``:`s`} cannot be evaluated — a date that does not resolve, or a list this view refers to that no longer exists. Rows are hidden rather than shown under a count that would be wrong.`,children:`Filter unresolved`}),Jp(N)==null?(0,B.jsxs)(`span`,{className:`cg-count`,title:qp(M,ee),children:[(0,B.jsx)(`span`,{className:`cg-count-full`,children:qp(M,ee)}),(0,B.jsx)(`span`,{className:`cg-count-compact`,children:rre(M,ee)})]}):(0,B.jsxs)(`span`,{className:`cg-count cg-count-partial`,title:`Loading the rest of your ${n} in the background — you can browse, filter and sort what is already here.`,children:[(0,B.jsx)(`span`,{className:`lp-spin`,role:`status`,"aria-label":`Loading`}),Jp(N)]})]})}function xm({on:e}){return(0,B.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:(0,B.jsx)(`polygon`,{points:`10,1.8 12.5,7.2 18.4,7.7 13.9,11.6 15.3,17.4 10,14.3 4.7,17.4 6.1,11.6 1.6,7.7 7.5,7.2`,fill:e?`#A98A3E`:`none`,stroke:e?`#A98A3E`:`rgba(118,143,182,0.55)`,strokeWidth:`1.2`,strokeLinejoin:`round`})})}function jre({value:e,max:t}){return(0,B.jsx)(`span`,{className:`cg-stars cg-stars--static`,"aria-label":`${e} of ${t}`,children:Array.from({length:t},(t,n)=>(0,B.jsx)(xm,{on:n=0?n.splice(r,1):n.push(t),Fre(n)}function Tm(e,t,n){let r=e.type===`user`?t??[]:nd(e),i=r.map(e=>({value:e,label:e})),a=e.type===`multiselect`?wm(n):[Sm(n).trim()];for(let e of a)e===``||r.includes(e)||i.push({value:e,label:`${e} (no longer a choice)`,stale:!0});return i}function Em(e){let t=Sm(e).trim();if(t===``)return``;let n=Number(t);return Number.isFinite(n)?String(n):``}function Lre(e){let t=e.trim();if(t===``)return``;let n=Number(t);return Number.isFinite(n)?t:null}function Dm(e,t){let n=Math.round(Number(Sm(t)));return Number.isFinite(n)?Math.max(0,Math.min(rd(e),n)):0}function Rre(e,t,n){let r=Dm(e,t),i=Math.max(1,Math.min(rd(e),Math.round(n)));return i===r?``:String(i)}function zre(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length?t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase():`?`}var Bre=new Set([`sum`,`count`]);function Vre(e){return Bre.has(e)}var Om=`month`;function km(e){let t=id.includes(e.bucket??``)?e.bucket:Om,n=e.span??{},r;return r=typeof n.lastN==`number`&&Number.isFinite(n.lastN)?{lastN:Math.max(1,Math.min(120,Math.round(n.lastN)))}:n.from||n.to?{from:n.from,to:n.to}:{lastN:12},{pids:e.pids,bucket:t,span:r,fields:e.fields.slice(0,12)}}function Am(e,t){return e==null||t==null||t===0||!Number.isFinite(e)||!Number.isFinite(t)?null:(e-t)/Math.abs(t)*100}function jm(e){return e.toLocaleString(void 0,{maximumFractionDigits:2})}function Hre(e,t){return e==null?`—`:t?t(e):String(e)}function Mm(e){return e==null?``:jm(e)}function Nm(e,t){return e==null?``:t?Pm(e):`${e>0?`+`:``}${jm(e)}`}function Pm(e){return e==null?`—`:`${e>0?`+`:``}${e.toFixed(1)}%`}function Ure(e){switch(e){case`not_a_measure_field`:return`not a measure — only measure fields have a time dimension`;case`unresolvable`:return`a composite measure has no single aggregate to bucket`;case`window_fixed`:return`its period is a fixed date range, so it cannot slide across buckets`;default:return e}}function Fm(e){if(!e)return{columns:[],rows:[],notes:[],pool:0,empty:!0};let t=e.columns??[],n=(e.rows??[]).map(e=>{let n=e.values??[],r=t.map((e,t)=>({value:n[t]??null,delta:Am(n[t]??null,t>0?n[t-1]??null:null),partial:e.partial===!0})),i=Vre(e.agg)&&typeof e.total==`number`&&Number.isFinite(e.total)?e.total:void 0;return{field:e.field,label:e.label,agg:e.agg,cells:r,total:i,allUnanswered:r.length>0&&r.every(e=>e.value==null),window:e.window}}),r=[],i=e.meta??{pool:0};for(let e of i.dropped??[])r.push(`${e.field} is not shown — ${Ure(e.reason)}.`);for(let e of i.problems??[])r.push(e);let a=t.filter(e=>e.partial).length;a>0&&r.push(a===1?`The last column is a partial period — it is still filling.`:`${a} columns are partial periods — they are still filling.`);let o=n.filter(e=>e.allUnanswered).length;return o>0&&r.push(`${o} of ${n.length} metrics returned no values for this span (shown as "—").`),{columns:t,rows:n,notes:r,pool:i.pool??0,empty:n.length===0}}var Wre=new Set([`currency`,`int`,`pct`]),Gre=/(^|_)days(_|$)/;function Kre(e){return e.agg===`sum`||e.agg===`count`?`sum`:e.agg===`avg`||e.type===`pct`||Gre.test(e.key)?`avg`:`sum`}function Im(e){return e.measure&&typeof e.measure==`object`?`server`:Wre.has(e.type)?`snapshot`:`refused`}function qre(e){return e.formula?`a formula column has no time dimension of its own`:`${e.type} is not a number, so it has nothing to plot over time`}function Jre(e,t,n,r){let i=Kre(e),a=0,o=0;for(let n of t){let t=n?.[e.key];if(t==null||t===``)continue;let r=typeof t==`number`?t:Number(t);Number.isFinite(r)&&(a+=r,o+=1)}let s=o===0?null:i===`avg`?a/o:a,c=n.map(e=>({value:s,delta:null,partial:e.partial===!0}));return{field:e.key,label:e.label,agg:`snapshot`,cells:c,total:void 0,allUnanswered:s==null,window:{kind:`snapshot`,label:r?`Snapshot · the current value as of ${r}, not per period`:`Snapshot · the current value, not per period`}}}function Yre(e,t){return`${e.length===1?e[0]:`${e.length} rows`} ${e.length===1?`has`:`have`} no time dimension, so ${e.length===1?`it is`:`they are`} shown as the current value${t?` as of ${t}`:``} repeated across every period — a flat line here means "not measured over time", not "unchanged". No total and no comparison is offered for ${e.length===1?`it`:`them`}.`}function Xre(e){let t=[],n=0;for(;nt[n],i=e=>{let t=r();return t&&t.k===`op`&&t.v===e?(n+=1,!0):!1};function a(){let e=r();if(!e)return null;if(e.k===`num`)return n+=1,{t:`num`,v:e.v};if(e.k===`ref`)return n+=1,{t:`ref`,name:e.name};if(i(`(`)){let e=c();return!e||!i(`)`)?null:e}return null}function o(){if(i(`-`)){let e=o();return e?{t:`neg`,a:e}:null}return i(`+`)?o():a()}function s(){let e=o();if(!e)return null;for(;;){let t=r();if(!t||t.k!==`op`||t.v!==`*`&&t.v!==`/`)return e;n+=1;let i=o();if(!i)return null;e={t:`bin`,op:t.v,a:e,b:i}}}function c(){let e=s();if(!e)return null;for(;;){let t=r();if(!t||t.k!==`op`||t.v!==`+`&&t.v!==`-`)return e;n+=1;let i=s();if(!i)return null;e={t:`bin`,op:t.v,a:e,b:i}}}let l=c();return l&&n===t.length?l:null}function Qre(e,t){let n,r=e=>{switch(e.t){case`num`:return e.v;case`ref`:{let r=t(e.name);return r===void 0?(n??=`unknown_ref`,null):r}case`neg`:{let t=r(e.a);return t==null?null:-t}case`bin`:{let t=r(e.a),i=r(e.b);if(t==null||i==null)return null;if(e.op===`+`)return t+i;if(e.op===`-`)return t-i;if(e.op===`*`)return t*i;if(i===0)return n??=`div_zero`,null;let a=t/i;return Number.isFinite(a)?a:null}}},i=r(e);return n?{value:null,error:n}:{value:i}}function $re(e,t){switch(t){case`syntax`:return`${e}: that formula could not be read — use + - * / ( ) with numbers and [row] references.`;case`unknown_ref`:return`${e}: a row it refers to is not on this sheet, so it is left blank rather than treated as zero.`;case`cycle`:return`${e}: it refers back to itself, so it has no value.`;case`div_zero`:return`${e}: divided by zero in at least one period — those cells are blank, not zero.`}}var Lm={week:52,month:12,quarter:4,year:1},Rm={abs:`Change`,pct:`Change %`,yoy:`vs last year`,ytd:`YTD growth`};function eie(e){return e!==`abs`}function zm(e,t,n){let r=e.cells.map(e=>e.value),i=Lm[n]??12,a=[];for(let n of t){let t=eie(n),o,s;n===`abs`?s=r.map((e,t)=>t===0||e==null||r[t-1]==null?null:e-r[t-1]):n===`pct`?s=r.map((e,t)=>Am(e,t>0?r[t-1]:null)):n===`yoy`||e.window?.kind===`ytd`?(s=r.map((e,t)=>Am(e,t>=i?r[t-i]:null)),r.length<=i&&(o=`This span is shorter than a year, so there is no earlier period to compare against.`)):(s=r.map(()=>null),o=e.window==null?`Year-to-date growth needs the metric's own period, which this server did not report.`:`Year-to-date growth is only meaningful on a year-to-date metric — this one is "${e.window.label}".`),a.push({kind:n,label:Rm[n],percent:t,values:s,refusal:o})}return a}function tie(e,t){let n=Lm[t]??12,r={value:null,delta:null,partial:!1},i=e.cells.map((t,i)=>i>=n?e.cells[i-n]:r),a=e.cells.length<=n?`This span is shorter than a year, so there is no earlier period to compare against.`:void 0;return{label:`${e.label} (last year)`,cells:a?[]:i,back:n,refusal:a}}function Bm(e,t,n){if(!e)return{};let r=e[t],i=n?e[`${t}:${n}`]:void 0;return!r&&!i?{}:{...r,...i}}function nie(e,t,n){let r=e.filter(e=>e!=null&&Number.isFinite(e));if(r.length<2)return[];let i=Math.min(...r),a=Math.max(...r)-i,o=e.length>1?t/(e.length-1):0,s=[],c=[];return e.forEach((e,t)=>{if(e==null||!Number.isFinite(e)){c.length>1&&s.push({points:c}),c=[];return}let r=a===0?n/2:n-(e-i)/a*n;c.push({x:t*o,y:r})}),c.length>1&&s.push({points:c}),s}function rie(e){return e.points.map(e=>`${Math.round(e.x*10)/10},${Math.round(e.y*10)/10}`).join(` `)}function Vm(e){return e.trim().toLowerCase()}function iie(e,t){let n=[...e.notes],r=t.deltas??[],i=(t.customRows??[]).filter(e=>e&&typeof e.id==`string`),a=new Map,o=new Map;e.rows.forEach((e,t)=>{a.has(e.field)||a.set(e.field,{kind:`metric`,index:t});let n=Vm(e.label);n&&!o.has(n)&&o.set(n,{kind:`metric`,index:t})}),i.forEach((e,t)=>{if(e.kind!==`formula`)return;a.has(e.id)||a.set(e.id,{kind:`formula`,index:t});let n=Vm(e.label);n&&!o.has(n)&&o.set(n,{kind:`formula`,index:t})});let s=i.map(e=>e.kind===`formula`?Zre(e.expr??``):null),c=new Map,l=new Map,u=(t,n)=>{let r=c.get(t);if(r)return r;let i=e.columns.length;if(n.has(t))return l.set(t,`cycle`),Array(i).fill(null);let d=s[t];if(!d){l.set(t,`syntax`);let e=Array(i).fill(null);return c.set(t,e),e}n.add(t);let f=[];for(let r=0;r{let i=a.get(t.trim())??o.get(Vm(t));if(i)return i.kind===`metric`?e.rows[i.index]?.cells[r]?.value??null:u(i.index,n)[r]??null});i.error&&!l.has(t)&&l.set(t,i.error),f.push(i.value)}return n.delete(t),c.set(t,f),f},d=e.rows.map(e=>({id:e.field,kind:`metric`,label:e.label,sublabel:e.window?.label,agg:e.agg,cells:e.cells,total:e.total,deltas:e.agg===`snapshot`?[]:zm(e,r,t.bucket),allUnanswered:e.allUnanswered})),f=e.rows.filter(e=>e.agg===`snapshot`);f.length>0&&n.push(Yre(f.map(e=>e.label),t.today)),i.forEach((i,a)=>{if(i.kind===`note`){d.push({id:i.id,kind:`note`,label:i.label,cells:e.columns.map(e=>({value:null,delta:null,partial:e.partial===!0})),deltas:[],allUnanswered:!1});return}let o=u(a,new Set),s=e.columns.map((e,t)=>({value:o[t]??null,delta:Am(o[t]??null,t>0?o[t-1]??null:null),partial:e.partial===!0})),c=l.get(a);c&&n.push($re(i.label||i.id,c)),d.push({id:i.id,kind:`formula`,label:i.label,expr:i.expr,cells:s,deltas:zm({cells:s,window:void 0},r,t.bucket),allUnanswered:s.length>0&&s.every(e=>e.value==null)})});let p=new Set;for(let e of d)for(let t of e.deltas)t.refusal&&p.add(t.refusal);for(let e of p)n.push(e);return{columns:e.columns,rows:d,notes:n,pool:e.pool,empty:d.length===0}}function Hm(e,t){let n=e.cells.map((e,n)=>({cell:e,col:t[n]})).filter(e=>e.col&&e.cell.value!=null).map(t=>({key:t.col.key,label:t.col.label,value:t.cell.value,n:1,seriesKey:e.field,seriesLabel:e.label}));return{points:n,xOrder:t.map(e=>e.key),seriesOrder:[e.field],omitted:0,omittedValue:0,omittedSeries:0,omittedSeriesValue:0,blanks:e.cells.filter(e=>e.value==null).length,missingY:0,rows:n.length,nonPositive:0,nonPositiveValue:0}}function aie(e,t,n,r){let i=tie(e,n),a=Math.max(1,Math.min(Math.round(r),t.length)),o=t.length-a,s=t.slice(o),c=`${e.field}::prior_year`,l=(e,t,n)=>s.map((t,n)=>({col:t,cell:e[o+n]})).filter(e=>e.cell&&e.cell.value!=null).map(e=>({key:e.col.key,label:e.col.label,value:e.cell.value,n:1,seriesKey:t,seriesLabel:n})),u=l(e.cells,e.field,e.label),d=i.refusal?[]:l(i.cells,c,i.label);return{points:[...u,...d],xOrder:s.map(e=>e.key),seriesOrder:i.refusal?[e.field]:[e.field,c],omitted:0,omittedValue:0,omittedSeries:0,omittedSeriesValue:0,blanks:e.cells.slice(o).filter(e=>e.value==null).length,missingY:0,rows:u.length,nonPositive:0,nonPositiveValue:0}}function Um(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function oie(e){let t=[[`Metric`,...e.columns.map(e=>e.label),`Total`].map(Um).join(`,`)];for(let n of e.rows){t.push([Um(n.sublabel?`${n.label} (${n.sublabel})`:n.label),...n.cells.map(e=>Um(Mm(e.value))),Um(Mm(n.total??null))].join(`,`));for(let e of n.deltas)t.push([Um(`${n.label} — ${e.label}${e.percent?` (%)`:``}`),...e.values.map(t=>Um(Nm(t,e.percent))),``].join(`,`))}if(e.notes.length>0){t.push(``);for(let n of e.notes)t.push(Um(n))}return t.join(`\r + `),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function mu(e){e=pu(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,i=e.onKeyDown;i===void 0&&(i=jl);var a=e.onBlur;a===void 0&&(a=jl);var o=e.thousandSeparator,s=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l=``);var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,p=e.onValueChange,m=Al(e,[`decimalSeparator`,`allowedDecimalSeparators`,`thousandsGroupStyle`,`suffix`,`allowNegative`,`allowLeadingZeros`,`onKeyDown`,`onBlur`,`thousandSeparator`,`decimalScale`,`fixedDecimalScale`,`prefix`,`defaultValue`,`value`,`valueIsNumericString`,`onValueChange`]),h=su(e),g=h.decimalSeparator,_=h.allowedDecimalSeparators,v=function(t){return ou(t,e)},y=function(t,n){return du(t,n,e)},b=Pl(d)?u:d,x=f??uu(b,l,t);Pl(d)?Pl(u)||(x||=typeof u==`number`):x||=typeof d==`number`;var S=function(e){return Il(e)?e:(typeof e==`number`&&(e=Gl(e)),x&&typeof s==`number`?Kl(e,s,!!c):e)},C=nu(S(d),S(u),!!x,v,y,p),w=C[0],T=w.numAsString,E=w.formattedValue,D=C[1];return Object.assign(Object.assign({},m),{value:E,valueIsNumericString:!1,isValidInputCharacter:function(e){return e===g||Nl(e)},isCharacterSame:function(e){var t=e.currentValue,n=e.lastValue,r=e.formattedValue,i=e.currentValueIndex,a=e.formattedValueIndex,o=t[i],u=r[a],f=vu(n,t).to,p=function(e){return y(e).indexOf(`.`)+l.length};return d===0&&c&&s&&t[f.start]===g&&p(t)a?!1:i>=f.start&&i{gu=u(f()),(function(e){e.event=`event`,e.props=`prop`})(_u||={}),vu=Ml(function(e,t){for(var n=0,r=0,i=e.length,a=t.length;e[n]===t[n]&&nn&&i-r>n;)r++;return{from:{start:n,end:i-r},to:{start:n,end:a-r}}}),yu=function(e,t){var n=Math.min(e.selectionStart,t);return{from:{start:n,end:e.selectionEnd},to:{start:n,end:t}}}})),xu=c({default:()=>Tu});function Su(){return Intl.NumberFormat()?.formatToParts(1.1)?.find(e=>e.type===`decimal`)?.value??`.`}function Cu(){return Su()===`.`?`,`:`.`}var wu,Tu,Eu=o((()=>{wu=u(f(),1),kl(),bu(),Tu=e=>{let{value:t,onChange:n,disabled:r,highlight:i,validatedSelection:a,fixedDecimals:o,allowNegative:s,thousandSeparator:c,decimalSeparator:l}=e,u=wu.useRef();return wu.useLayoutEffect(()=>{if(a!==void 0){let e=typeof a==`number`?[a,null]:a;u.current?.setSelectionRange(e[0],e[1])}},[a]),wu.createElement(Ol,null,wu.createElement(hu,{autoFocus:!0,getInputRef:u,className:`gdg-input`,onFocus:e=>e.target.setSelectionRange(i?0:e.target.value.length,e.target.value.length),disabled:r===!0,decimalScale:o,allowNegative:s,thousandSeparator:c??Cu(),decimalSeparator:l??Su(),value:Object.is(t,-0)?`-`:t??``,onValueChange:n}))}}));ct();var Du=L.lazy(async()=>await Dc(()=>Promise.resolve().then(()=>(Eu(),xu)),void 0,import.meta.url)),Ou={getAccessibilityString:e=>e.data?.toString()??``,kind:I.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:ti,draw:e=>oi(e,e.cell.displayData,e.cell.contentAlign),measure:(e,t,n)=>e.measureText(t.displayData).width+n.cellHorizontalPadding*2,onDelete:e=>({...e,data:void 0}),provideEditor:()=>e=>{let{isHighlighted:t,onChange:n,value:r,validatedSelection:i}=e;return L.createElement(L.Suspense,{fallback:null},L.createElement(Du,{highlight:t,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:e=>n({...r,data:Number.isNaN(e.floatValue??0)?0:e.floatValue})}))},onPaste:(e,t,n)=>{let r=typeof n.rawValue==`number`?n.rawValue:Number.parseFloat(typeof n.rawValue==`string`?n.rawValue:e);if(!(Number.isNaN(r)||t.data===r))return{...t,data:r,displayData:n.formattedString??t.displayData}}};ct();var ku={getAccessibilityString:()=>``,measure:()=>108,kind:I.Protected,needsHover:!1,needsHoverPosition:!1,draw:ree,onPaste:()=>void 0};function ree(e){let{ctx:t,theme:n,rect:r}=e,{x:i,y:a,height:o}=r;t.beginPath();let s=2.5,c=i+n.cellHorizontalPadding+s,l=a+o/2,u=Math.cos(Xt(30))*s,d=Math.sin(Xt(30))*s;for(let e=0;e<12;e++)t.moveTo(c,l-s),t.lineTo(c,l+s),t.moveTo(c+u,l-d),t.lineTo(c-u,l+d),t.moveTo(c-u,l-d),t.lineTo(c+u,l+d),c+=8;t.lineWidth=1.1,t.lineCap=`square`,t.strokeStyle=n.textLight,t.stroke()}ct();var Au={getAccessibilityString:e=>e.data?.toString()??``,kind:I.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(e,t)=>ti(e,t,e.theme.textLight),draw:e=>oi(e,e.cell.data,e.cell.contentAlign),measure:(e,t,n)=>e.measureText(t.data).width+n.cellHorizontalPadding*2,provideEditor:()=>e=>{let{isHighlighted:t,onChange:n,value:r,validatedSelection:i}=e;return L.createElement(lr,{highlight:t,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:e=>n({...r,data:e.target.value})})},onPaste:()=>void 0};ct(),vr();var iee={getAccessibilityString:e=>e.data?.toString()??``,kind:I.Text,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,drawPrep:ti,useLabel:!0,draw:e=>{let{cell:t,hoverAmount:n,hyperWrapping:r,ctx:i,rect:a,theme:o,overrideCursor:s}=e,{displayData:c,contentAlign:l,hoverEffect:u,allowWrapping:d}=t;if(u===!0&&n>0){i.textBaseline=`alphabetic`;let e=o.cellHorizontalPadding,t=o.cellVerticalPadding,r=Jr(c,i,o.baseFontFull,`alphabetic`),l=a.height-t,u=Math.min(l,r.actualBoundingBoxAscent*2.5);i.beginPath(),si(i,a.x+e/2,a.y+(a.height-u)/2+1,r.width+e*3,u-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=fr(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline=`middle`,s?.(`text`)}oi(e,c,l,d,r)},measure:(e,t,n)=>{let r=t.displayData.split(` +`,t.allowWrapping===!0?void 0:1),i=0;for(let t of r)i=Math.max(i,e.measureText(t).width);return i+2*n.cellHorizontalPadding},onDelete:e=>({...e,data:``}),provideEditor:e=>({disablePadding:e.allowWrapping===!0,editor:t=>{let{isHighlighted:n,onChange:r,value:i,validatedSelection:a}=t;return L.createElement(lr,{style:e.allowWrapping===!0?{padding:`3px 8.5px`}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:a,onChange:e=>r({...i,data:e.target.value})})}}),onPaste:(e,t,n)=>e===t.data?void 0:{...t,data:e,displayData:n.formattedString??t.displayData}};St();var ju=xt(`div`)({name:`UriOverlayEditorStyle`,class:`gdg-u1rrojo`,propsAsIs:!1}),aee=e=>{let{uri:t,onChange:n,forceEditMode:r,readonly:i,validatedSelection:a,preview:o}=e,[s,c]=L.useState(!i&&(t===``||r)),l=L.useCallback(()=>{c(!0)},[]);return s?L.createElement(lr,{validatedSelection:a,highlight:!0,autoFocus:!0,value:t,onChange:n}):L.createElement(ju,null,L.createElement(`a`,{className:`gdg-link-area`,href:t,target:`_blank`,rel:`noopener noreferrer`},o),!i&&L.createElement(`div`,{className:`gdg-edit-icon`,onClick:l},L.createElement(tn,null)),L.createElement(`textarea`,{className:`gdg-input`,autoFocus:!0}))};ct();function oee(e,t,n,r){let i=n.cellHorizontalPadding,a=t.height/2-e.actualBoundingBoxAscent/2,o=e.width,s=e.actualBoundingBoxAscent;return r===`right`?i=t.width-o-n.cellHorizontalPadding:r===`center`&&(i=t.width/2-o/2),{x:i,y:a,width:o,height:s}}var see=[Sl,El,el,il,ll,ml,vl,xl,Ou,ku,Au,iee,{getAccessibilityString:e=>e.data?.toString()??``,kind:I.Uri,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:ti,draw:e=>{let{cell:t,theme:n,overrideCursor:r,hoverX:i,hoverY:a,rect:o,ctx:s}=e,c=t.displayData??t.data,l=t.hoverEffect===!0;if(r!==void 0&&l&&i!==void 0&&a!==void 0){let{x:l,y:u,width:d,height:f}=oee(Jr(c,s,n.baseFontFull),o,n,t.contentAlign);if(i>=l-4&&i<=l-4+d+8&&a>=u-4&&a<=u-4+f+8){let i=Xr(s,n.baseFontFull);r(`pointer`);let a=u-i;s.beginPath(),s.moveTo(o.x+l,Math.floor(o.y+a+f+5)+.5),s.lineTo(o.x+l+d,Math.floor(o.y+a+f+5)+.5),s.strokeStyle=n.linkColor,s.stroke(),s.save(),s.fillStyle=e.cellFillColor,oi({...e,rect:{...o,x:o.x-1}},c,t.contentAlign),oi({...e,rect:{...o,x:o.x-2}},c,t.contentAlign),oi({...e,rect:{...o,x:o.x+1}},c,t.contentAlign),oi({...e,rect:{...o,x:o.x+2}},c,t.contentAlign),s.restore()}}s.fillStyle=l?n.linkColor:n.textDark,oi(e,c,t.contentAlign)},onClick:e=>{let{cell:t,bounds:n,posX:r,posY:i,theme:a}=e,o=t.displayData??t.data;if(t.hoverEffect!==!0||t.onClickUri===void 0)return;let s=Yr(o,a.baseFontFull);if(s===void 0)return;let c=oee(s,n,a,t.contentAlign);ba({x:c.x-4,y:c.y-4,width:c.width+8,height:c.height+8},r,i)&&t.onClickUri(e)},measure:(e,t,n)=>e.measureText(t.displayData??t.data).width+n.cellHorizontalPadding*2,onDelete:e=>({...e,data:``}),provideEditor:e=>t=>{let{onChange:n,value:r,forceEditMode:i,validatedSelection:a}=t;return L.createElement(aee,{forceEditMode:r.readonly!==!0&&(i||e.hoverEffect===!0&&e.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:a,readonly:r.readonly===!0,onChange:e=>n({...r,data:e.target.value})})},onPaste:(e,t,n)=>e===t.data?void 0:{...t,data:e,displayData:n.formattedString??t.displayData}}],cee=u(s(((e,t)=>{var n=Gt(),r=re(),i=`Expected a function`;function a(e,t,a){var o=!0,s=!0;if(typeof e!=`function`)throw TypeError(i);return r(a)&&(o=`leading`in a?!!a.leading:o,s=`trailing`in a?!!a.trailing:s),n(e,t,{leading:o,maxWait:t,trailing:s})}t.exports=a}))(),1),Mu=[],lee=class extends gi{imageLoaded=()=>void 0;loadedLocations=[];cache={};setCallback(e){this.imageLoaded=e}sendLoaded=(0,cee.default)(()=>{this.imageLoaded(new vi(this.loadedLocations)),this.loadedLocations=[]},20);clearOutOfWindow=()=>{let e=Object.keys(this.cache);for(let t of e){let e=this.cache[t],n=!1;for(let t=0;t{o||(o=!0,Mu.length<12?Mu.unshift(a):i||(a.src=``))}},c=new Promise(e=>a.addEventListener(`load`,()=>e(null)));requestAnimationFrame(async()=>{try{a.src=e,await c,await a.decode();let t=this.cache[r];if(t!==void 0&&!o){t.img=a;for(let e of t.cells)this.loadedLocations.push(hi(e));i=!0,this.sendLoaded()}}catch{s.cancel()}}),this.cache[r]=s}loadOrGetImage(e,t,n){let r=e,i=this.cache[r];if(i!==void 0){let e=fi(t,n);return i.cells.includes(e)||i.cells.push(e),i.img}else this.loadImage(e,t,n,r)}},uee=L.forwardRef((e,t)=>{let n=L.useMemo(()=>({...da,...e.headerIcons}),[e.headerIcons]),r=L.useMemo(()=>e.imageWindowLoader??new lee,[e.imageWindowLoader]);return L.createElement(Qc,{...e,renderers:see,headerIcons:n,ref:t,imageWindowLoader:r})}),Nu=[`all_time`,`today`,`yesterday`,`this_week`,`last_week`,`this_month`,`last_month`,`this_quarter`,`last_quarter`,`this_year`,`last_year`,`ytd`,`ytd_last_year`,`ltm`,`past_week`,`past_month`,`past_year`,`last_n_days`,`next_n_days`,`custom`],Pu=new Set([`last_n_days`,`next_n_days`]),Fu={all_time:`all time`,today:`today`,yesterday:`yesterday`,this_week:`this week`,last_week:`last week`,this_month:`this month`,last_month:`last month`,this_quarter:`this quarter`,last_quarter:`last quarter`,this_year:`this year`,last_year:`last year`,ytd:`year to date`,ytd_last_year:`last year to date`,ltm:`the last 12 months`,past_week:`the past week`,past_month:`the past month`,past_year:`the past year`,last_n_days:`the last {n} days`,next_n_days:`the next {n} days`,custom:`a custom range`},Iu=[`today`,`yesterday`,`one_week_ago`,`one_month_ago`,`n_days_ago`,`exact`],dee=new Set([`today`,`yesterday`,`one_week_ago`,`one_month_ago`]),Lu={today:`today`,yesterday:`yesterday`,one_week_ago:`one week ago`,one_month_ago:`one month ago`,n_days_ago:`{n} days ago`,exact:`an exact date`};function Ru(e){let t=String(e??``).trim().slice(0,10);if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return null;let n=new Date(`${t}T00:00:00Z`);return Number.isNaN(n.getTime())?null:n}function zu(e){return e.toISOString().slice(0,10)}function Bu(e,t){return new Date(e.getTime()+t*864e5)}function Vu(e){return[e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate()]}function Hu(e,t,n){return new Date(Date.UTC(e,t-1,n))}function Uu(e){let[t,n]=Vu(e);return Hu(t,n,1)}function Wu(e){let[t,n]=Vu(e);return n===12?Hu(t,12,31):Bu(Hu(t,n+1,1),-1)}function Gu(e){return(e.getUTCDay()+6)%7}function Ku(e){let[t,n]=Vu(e);return Hu(t,3*Math.floor((n-1)/3)+1,1)}function fee(e,t){return new Date(Date.UTC(t===12?e+1:e,t===12?0:t,1)-864e5).getUTCDate()}function qu(e,t){let[n,r,i]=Vu(e),a=n*12+(r-1)+t,o=Math.floor(a/12),s=a-o*12+1;return Hu(o,s,Math.min(i,fee(o,s)))}function Ju(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.kind;if(!Nu.includes(n))return null;let r={kind:n};if(Pu.has(n)){let e=Number(t.n);if(!Number.isInteger(e)||e<1||e>3650)return null;r.n=e}if(n===`custom`){let e=Ru(t.from),n=Ru(t.to);if(!e&&!n)return null;e&&n&&e>n&&([e,n]=[n,e]),e&&(r.from=zu(e)),n&&(r.to=zu(n))}return r}function Yu(e,t){let n=Ju(e);if(!n)return null;let r=Ru(t);if(!r)throw Error("resolveWindow() needs an explicit `today`");switch(n.kind){case`all_time`:return[null,null];case`today`:return[zu(r),zu(r)];case`yesterday`:{let e=Bu(r,-1);return[zu(e),zu(e)]}case`this_week`:{let e=Bu(r,-Gu(r));return[zu(e),zu(Bu(e,6))]}case`last_week`:{let e=Bu(r,-Gu(r)-7);return[zu(e),zu(Bu(e,6))]}case`this_month`:return[zu(Uu(r)),zu(Wu(r))];case`last_month`:{let e=Bu(Uu(r),-1);return[zu(Uu(e)),zu(e)]}case`this_quarter`:{let e=Ku(r),[t,n]=Vu(e);return[zu(e),zu(Wu(Hu(t,n+2,1)))]}case`last_quarter`:{let e=Bu(Ku(r),-1);return[zu(Ku(e)),zu(e)]}case`this_year`:{let[e]=Vu(r);return[zu(Hu(e,1,1)),zu(Hu(e,12,31))]}case`last_year`:{let[e]=Vu(r);return[zu(Hu(e-1,1,1)),zu(Hu(e-1,12,31))]}case`ytd`:{let[e]=Vu(r);return[zu(Hu(e,1,1)),zu(r)]}case`ytd_last_year`:{let[e]=Vu(r);return[zu(Hu(e-1,1,1)),zu(qu(r,-12))]}case`ltm`:return[zu(Bu(r,-364)),zu(r)];case`past_week`:return[zu(Bu(r,-6)),zu(r)];case`past_month`:return[zu(Bu(qu(r,-1),1)),zu(r)];case`past_year`:return[zu(Bu(qu(r,-12),1)),zu(r)];case`last_n_days`:return[zu(Bu(r,-(n.n-1))),zu(r)];case`next_n_days`:return[zu(r),zu(Bu(r,n.n-1))];case`custom`:return[n.from??null,n.to??null]}}function Xu(e){let t=Ju(e);return t?Fu[t.kind].replace(`{n}`,String(t.n??``)):`an invalid range`}function Zu(e,t,n){let r=e||`exact`;if(!Iu.includes(r))return null;let i=Ru(n);if(!i)throw Error("resolveAnchor() needs an explicit `today`");switch(r){case`today`:return zu(i);case`yesterday`:return zu(Bu(i,-1));case`one_week_ago`:return zu(Bu(i,-7));case`one_month_ago`:return zu(qu(i,-1));case`n_days_ago`:{let e=String(t??``).trim();if(!/^[0-9]+$/.test(e))return null;let n=Number(e);return n>3650?null:zu(Bu(i,-n))}default:{let e=Ru(t);return e?zu(e):null}}}var Qu=[`text`,`select`,`multiselect`,`user`,`int`,`currency`,`pct`,`date`,`checkbox`,`phone`,`email`,`url`,`rating`,`created_time`,`formula`,`automation`],pee=new Set([`formula`,`created_time`,`automation`]);function $u(e){return e===`select`||e===`user`||e===`multiselect`}function mee(e){let t=new Set,n=[];for(let r of e.split(` +`)){let e=r.trim();if(!e)continue;let i=e.toLowerCase();t.has(i)||(t.add(i),n.push(e))}return n.slice(0,50)}function ed(e,t,n=120){let r=Math.max(1,Math.floor(n)),i=e=>e.trim().replace(/\s+/g,` `),a=(i(e)||`Untitled`).slice(0,r).trimEnd(),o=new Set(t.map(e=>i(e).toLocaleLowerCase()));if(!o.has(a.toLocaleLowerCase()))return a;for(let e=2;;e+=1){let t=` ${e}`,n=a.slice(0,Math.max(0,r-t.length)).trimEnd(),i=n?`${n}${t}`:String(e).slice(-r);if(!o.has(i.toLocaleLowerCase()))return i}}function hee(e){return e.filter(e=>e.filterable!==!1)}function td(e){return Array.isArray(e.options)?e.options:[]}function gee(e){return typeof e.formula==`string`&&e.formula.trim()!==``?e.formula:void 0}function nd(e){let t=typeof e.max==`number`&&Number.isFinite(e.max)?Math.round(e.max):5;return Math.max(2,Math.min(10,t))}var _ee=[`grid`,`chart`,`dashboard`,`list`,`calendar`,`kanban`,`map`,`timeseries`,`catalog`],vee={dashboard:`chart`};function yee(e){return vee[e]??e}var rd=[`week`,`month`,`quarter`,`year`],id=[`letter`,`a4`,`tabloid`],ad=[`portrait`,`landscape`],bee=[`web`,`print`],xee=[`cover`,`intro`,`section`,`gallery`],See=[2,3,4],Cee=2e3,wee=/^#[0-9A-Fa-f]{6}$/,od=[`abs`,`pct`,`yoy`,`ytd`],Tee=[`note`,`formula`],Eee=/^[A-Za-z0-9_ .+\-*/()[\]]*$/;function Dee(e){let t=e.bucket===void 0||rd.includes(e.bucket),n=e.span,r;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.lastN;if(typeof e==`number`&&Number.isFinite(e)){let t=Math.round(e);t>=1&&t<=120&&(r={lastN:t})}}let i=e.span===void 0?r===void 0:!!r&&r.lastN===n?.lastN;if(t&&i)return e;let a={...e};return t||delete a.bucket,i||(r?a.span=r:delete a.span),a}function Oee(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e,r=typeof n.id==`string`?n.id.slice(0,40):``;if(!r||typeof n.kind!=`string`||!xee.includes(n.kind))return null;let i={id:r,kind:n.kind};for(let[e,t]of[[`title`,120],[`body`,Cee],[`imageCode`,60]]){let r=n[e];typeof r==`string`&&r&&(i[e]=r.slice(0,t))}if(Array.isArray(n.products)&&t>0){let e=[],r=new Set;for(let i of n.products){if(typeof i!=`string`||!i)continue;let n=i.slice(0,60);if(!r.has(n)&&(r.add(n),e.push(n),e.length>=t))break}e.length&&(i.products=e)}if(n.layout&&typeof n.layout==`object`&&!Array.isArray(n.layout)){let e=n.layout,t={};typeof e.cols==`number`&&Number.isInteger(e.cols)&&See.includes(e.cols)&&(t.cols=e.cols),e.showPack===!1&&(t.showPack=!1),e.showColor===!1&&(t.showColor=!1),e.showPrice===!0&&(t.showPrice=!0),(t.cols!==void 0||t.showPack!==void 0||t.showColor!==void 0||t.showPrice!==void 0)&&(i.layout=t)}return{page:i,spent:i.products?.length??0}}function kee(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(t.length>=12)break;if(!n||typeof n!=`object`||Array.isArray(n))continue;let e=n,r=typeof e.id==`string`?e.id.slice(0,40):``;if(!r||typeof e.name!=`string`)continue;let i={id:r,name:e.name.slice(0,80),paper:id.includes(e.paper)?e.paper:`letter`,orientation:ad.includes(e.orientation)?e.orientation:`portrait`,pages:[]};if(bee.includes(e.quality)&&(i.quality=e.quality),e.brand&&typeof e.brand==`object`&&!Array.isArray(e.brand)){let t=e.brand,n={};for(let e of[`primary`,`accent`])typeof t[e]==`string`&&wee.test(t[e])&&(n[e]=t[e]);typeof t.company==`string`&&t.company&&(n.company=t.company.slice(0,80)),typeof t.logo==`string`&&t.logo&&(n.logo=t.logo.slice(0,60)),Object.keys(n).length&&(i.brand=n)}if(e.fields&&typeof e.fields==`object`&&!Array.isArray(e.fields)){let t=e.fields,n={};for(let e of[`name`,`pack`,`color`,`price`])typeof t[e]==`string`&&t[e]&&(n[e]=t[e]);Object.keys(n).length&&(i.fields=n)}let a=500;if(Array.isArray(e.pages))for(let t of e.pages){if(i.pages.length>=40)break;let e=Oee(t,a);e&&(a-=e.spent,i.pages.push(e.page))}t.push(i)}return t.length?t:void 0}function sd(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(typeof t.mode!=`string`||!_ee.includes(t.mode))return;let n={mode:yee(t.mode)};for(let e of[`dateField`,`stackField`,`titleField`,`colorField`,`sizeField`]){let r=t[e];typeof r==`string`&&r!==``&&(n[e]=r)}if(Array.isArray(t.charts)){let e=t.charts.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`).map(Dee);e.length&&(n.charts=e.slice(0,12))}if(t.kanbanClamp===!1&&(n.kanbanClamp=!1),(t.calendarMode===`records`||t.calendarMode===`summary`)&&(n.calendarMode=t.calendarMode),Array.isArray(t.calendarMetrics)){let e=[];for(let n of t.calendarMetrics){if(!n||typeof n!=`object`)continue;let t=n;typeof t.id!=`string`||!t.id||typeof t.field!=`string`||!t.field||typeof t.agg!=`string`||!t.agg||e.push({id:t.id,field:t.field,agg:t.agg})}e.length&&(n.calendarMetrics=e.slice(0,4))}if(rd.includes(t.tsBucket)&&(n.tsBucket=t.tsBucket),t.tsSpan&&typeof t.tsSpan==`object`&&!Array.isArray(t.tsSpan)){let e=t.tsSpan,r={};if(typeof e.from==`string`&&e.from&&(r.from=e.from),typeof e.to==`string`&&e.to&&(r.to=e.to),typeof e.lastN==`number`&&Number.isFinite(e.lastN)){let t=Math.round(e.lastN);t>=1&&t<=120&&(r.lastN=t)}(r.from||r.to||r.lastN!=null)&&(n.tsSpan=r)}if(Array.isArray(t.tsFields)){let e=t.tsFields.filter(e=>typeof e==`string`&&e!==``);e.length&&(n.tsFields=e.slice(0,12))}if(Array.isArray(t.tsDeltas)){let e=new Set,r=[];for(let n of t.tsDeltas)typeof n!=`string`||!od.includes(n)||e.has(n)||(e.add(n),r.push(n));r.length&&(n.tsDeltas=r.slice(0,od.length))}if(t.tsGridlines===!1&&(n.tsGridlines=!1),t.tsSparkline===!0&&(n.tsSparkline=!0),Array.isArray(t.tsRows)){let e=[],r=new Set;for(let n of t.tsRows){if(!n||typeof n!=`object`)continue;let t=n;if(typeof t.id!=`string`||!t.id||t.id.length>40||r.has(t.id)||typeof t.kind!=`string`||!Tee.includes(t.kind)||typeof t.label!=`string`||t.label.length>120)continue;r.add(t.id);let i={id:t.id,kind:t.kind,label:t.label};i.kind===`formula`&&typeof t.expr==`string`&&t.expr.length<=200&&Eee.test(t.expr)&&(i.expr=t.expr),e.push(i)}e.length&&(n.tsRows=e.slice(0,12))}if(t.tsStyles&&typeof t.tsStyles==`object`&&!Array.isArray(t.tsStyles)){let e={},r=0;for(let[n,i]of Object.entries(t.tsStyles)){if(r>=200)break;if(!n||!i||typeof i!=`object`||Array.isArray(i))continue;let t=i,a={};t.bold===!0&&(a.bold=!0),t.line===!0&&(a.line=!0),!(!a.bold&&!a.line)&&(e[n]=a,r+=1)}r&&(n.tsStyles=e)}let r=kee(t.catalogs);if(r&&(n.catalogs=r),!(n.mode===`grid`&&!n.dateField&&!n.stackField&&!n.titleField&&!n.colorField&&!n.sizeField&&!n.charts&&n.kanbanClamp===void 0&&!n.calendarMode&&!n.calendarMetrics&&!n.tsBucket&&!n.tsSpan&&!n.tsFields&&!n.tsDeltas&&n.tsGridlines===void 0&&n.tsSparkline===void 0&&!n.tsRows&&!n.tsStyles&&!n.catalogs))return n}function Aee(e){if(typeof e!=`number`||!Number.isFinite(e))return;let t=Math.round(e);if(!(t<=1))return Math.min(8,t)}function jee(e,t){if(e.source!==`overlay`||pee.has(e.type))return!1;let n=e.permissions?.edit??`everyone`;return n===`everyone`?!0:t?t.isAdmin?!0:n===`creator`&&e.createdBy===t.name:!1}function cd(e){return e===`currency`||e===`int`||e===`pct`||e===`rating`||e===`formula`}function ld(e){return e===`date`||e===`created_time`}function ud(e,t){return cd(e)?t===`asc`?`1 → 9`:`9 → 1`:ld(e)?t===`asc`?`Oldest → Newest`:`Newest → Oldest`:t===`asc`?`A → Z`:`Z → A`}function Mee(e,t){return e.type===`status`||e.type===`select`||e.type===`multiselect`||e.type===`checkbox`||e.type===`text`&&e.source!==`overlay`&&e.key!==t}var Nee=[`topN`,`bottomN`,`inTopPct`,`inBottomPct`,`aboveAvg`,`belowAvg`,`inQuartile`,`inDecile`];function dd(e){return Nee.includes(e)}var Pee=[`contains`,`doesNotContain`,`eq`,`neq`,`isEmpty`,`isNotEmpty`,`gt`,`gte`,`lt`,`lte`,`between`,`within`,`topN`,`bottomN`,`inTopPct`,`inBottomPct`,`aboveAvg`,`belowAvg`,`inQuartile`,`inDecile`],fd=new Set([`isEmpty`,`isNotEmpty`,`aboveAvg`,`belowAvg`]),pd=`__cohort__`;function md(e){return!Sd(e)&&e.colId===`__cohort__`}var hd=[`anyOf`,`allOf`,`noneOf`],Fee={eq:`anyOf`,neq:`noneOf`};function gd(e){return hd.includes(e)?e:Fee[e]??`anyOf`}function _d(e){let t=[];for(let n of String(e??``).split(`,`)){let e=n.trim();if(!(e===``||t.includes(e))&&(t.push(e),t.length>=20))break}return t}var vd=[`avg`,`median`,`p10`,`p25`,`p75`,`p90`],Iee={avg:`the average`,median:`the median`,p10:`the bottom 10%`,p25:`the bottom quartile`,p75:`the top quartile`,p90:`the top 10%`};function yd(e){return e&&e.kind!==`stat`?e.colId:void 0}function Lee(e){return e?e.kind===`stat`?vd.includes(e.stat):e.colId?e.kind===`measure`?Ju(e.window)!=null:e.kind===`field`:!1:!1}function bd(e){return e.colId===`__cohort__`?_d(e.value).length>0:fd.has(e.op)?!0:e.op===`within`?Ju(e.dateWindow)!=null:e.rhs?Lee(e.rhs):e.dateMode&&dee.has(e.dateMode)?!0:e.op===`between`?e.value!==``&&e.value2!=null&&e.value2!==``:e.value!==``}var Ree=[`gte`,`gt`,`lte`,`lt`,`eq`,`neq`],zee=[`gte`,`gt`,`lte`,`lt`];function xd(e){return!Sd(e)&&e.window!=null}function Sd(e){return e!=null&&Array.isArray(e.children)}function Cd(e){return Array.isArray(e?.nodes)?e.nodes:[]}function wd(e){return e?.conj===`or`?`or`:`and`}var Bee=new Set([`all-customers`]),Vee={key:`customer_data`,scope:`customer`,rowsPath:`customers`,noun:`customer`,nouns:`customers`,measures:!0},Hee={key:`product_data`,scope:`product`,rowsPath:`products`,noun:`product`,nouns:`products`,measures:!1},Td=new Map;function Uee(e){let t=Td.get(e);return t||(t={key:e,scope:e,rowsPath:`tables/${e}/rows`,noun:`record`,nouns:`records`,measures:!1},Td.set(e,t)),t}function Ed(e){return e.startsWith(`ut_`)?Uee(e):e===`product`?Hee:Vee}function Dd(e){return Bee.has(e.id)}function Od(e){return e.config?.display?.mode??`grid`}function kd(e){return e.kind===`system`||Dd(e)?!1:!!e.locked}function Ad(e,t){return t?t.isAdmin?!0:!!e.createdBy&&e.createdBy===t.name:!1}var jd=[`personal`,`collaborative`,`users`],Wee={personal:`Personal`,collaborative:`Collaborative`,users:`Specific users`},Gee={personal:`Only you can change this view.`,collaborative:`Anyone who can see this table can change it.`,users:`Only the people you pick can change it.`};function Kee(e,t,n){let r=e&&typeof e==`object`&&!Array.isArray(e)?e:{},i=jd.includes(r.edit)?r.edit:t;if(i!==`users`)return{edit:i};let a=new Set,o=[];for(let e of(Array.isArray(r.users)?r.users:[]).slice(0,50)){let t=String(e??``).trim();!t||a.has(t.toLowerCase())||n&&!n.includes(t)||(a.add(t.toLowerCase()),o.push(t))}return o.length?{edit:`users`,users:o}:{edit:`personal`}}function qee(e){return e.permissions?.edit??`collaborative`}function Md(e,t){let n=qee(e);return n===`collaborative`||!e.createdBy?!0:t?t.isAdmin||e.createdBy&&e.createdBy===t.name?!0:n===`users`&&(e.permissions?.users??[]).includes(t.name):!1}var Nd=[`folder`,`star`,`flag`,`tag`,`bookmark`,`grid`,`chart`,`map`,`users`,`clock`,`heart`,`bolt`],Pd=[`neutral`,`blue`,`green`,`yellow`,`red`],Fd=`folder`,Id=`neutral`;function Jee(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;if(!Nd.includes(t.shape))return;let n=t.shape,r=Pd.includes(t.tone)?t.tone:Id;if(!(n===`folder`&&r===`neutral`))return{shape:n,tone:r}}var Ld=5*1024*1024;function Yee(e){return e?.windowed?`server-windowed`:`whole-book`}var Rd=`/api/v1`,zd=`same-origin`,Bd=`aios:unauthorized`,Vd=`aios:data-error`,Hd=`aios:toast`,Ud=`aios:derived-cells`,Wd=`aios:workspace-stale`,Gd=`aios:nav-minimize`,Kd=`aios:rows-stale`;function qd(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}var Xee=`streamlit:componentReady`,Zee=`streamlit:render`,Qee=`streamlit:setComponentValue`,$ee=`streamlit:setFrameHeight`,Jd=`aios:grid-host-render`;function Yd(e,t){window.parent.postMessage({isStreamlitMessage:!0,type:e,...t},`*`)}function Xd(){return typeof window>`u`||window.parent===window?!1:new URLSearchParams(window.location.search).has(`streamlitUrl`)}function ete(){Xd()&&(window.addEventListener(`message`,e=>{let t=e.data;if(!t||t.type!==Zee)return;window.__AIOS_STREAMLIT_ARGS__=t.args??{},window.dispatchEvent(new CustomEvent(Jd));let n=Number(t.args?.height??760);Yd($ee,{height:Number.isFinite(n)?n:760})}),Yd(Xee,{apiVersion:1}))}function tte(){return window.__AIOS_STREAMLIT_ARGS__??null}function nte(e){return window.addEventListener(Jd,e),()=>window.removeEventListener(Jd,e)}var Zd=[],Qd=null;function rte(e){Qd=e}function $d(e){return Xd()?(Zd.push(e),Zd.length>24&&Zd.shift(),Yd(Qee,{value:{events:[...Zd]},dataType:`json`}),!0):Qd?Qd(e):!1}function ef(e){return`${e}:${typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`}`}var tf={"Content-Type":`application/json`};async function nf(e){try{return await e.json()}catch{return null}}function rf(e){return e===401?(af.clear(),qd(Bd),!0):!1}var ite=5*6e4,af=new Map;function of(){af.clear()}async function ate(e){let t=af.get(e.rowsPath);if(t&&Date.now()-t.ate.pid===t);n&&Object.assign(n,e)}}return r.ok}catch{return!1}}async function cf(e,t=df){try{let n=await fetch(`${Rd}/grid/timeseries?scope=${encodeURIComponent(t)}`,{method:`POST`,credentials:zd,headers:tf,body:JSON.stringify(e)});if(rf(n.status)||!n.ok)return{payload:null,status:n.status};let r=await nf(n);return!r||!Array.isArray(r.columns)||!Array.isArray(r.rows)?{payload:null,status:n.status}:{payload:r,status:n.status}}catch{return{payload:null,status:0}}}async function ste(e,t=df){try{let n=await fetch(`${Rd}/grid/calendar_metrics?scope=${encodeURIComponent(t)}`,{method:`POST`,credentials:zd,headers:tf,body:JSON.stringify(e)});if(rf(n.status)||!n.ok)return{payload:null,status:n.status};let r=await nf(n);return!r||!r.values||typeof r.values!=`object`?{payload:null,status:n.status}:{payload:r,status:n.status}}catch{return{payload:null,status:0}}}var lf=[],uf=!1,df=`customer`;function cte(e){df=e}async function ff(){if(uf||lf.length===0)return;uf=!0;let e=lf;lf=[];let t=!1;try{let n=await fetch(`${Rd}/grid/events`,{method:`POST`,credentials:zd,headers:tf,body:JSON.stringify({events:e,scopeKey:df})});rf(n.status)||(n.ok?lte(await nf(n)):t=!0)}catch{t=!0}finally{uf=!1,t?lf=[...e,...lf].slice(-24):lf.length&&ff()}}function lte(e){let t=e,n=t?.toast;typeof n==`string`&&n.trim()!==``&&qd(Hd,n.trim()),t?.derived&&typeof t.derived==`object`&&!Array.isArray(t.derived)&&qd(Ud,t.derived);let r=Array.isArray(t?.results)?t.results:[];(t?.rerender===!0||r.some(e=>e?.rerender===!0))&&qd(Wd)}function ute(e){return lf.push(e),lf.length>24&&lf.shift(),ff(),!0}function dte(){rte(ute)}function pf(e){return JSON.stringify([e.config?.filters??[],e.config?.filterConj===`or`?`or`:`and`])}function fte(e,t,n){let r=pf(e);return r===pf(t)||r===n?null:r}function mf(e,t){for(let n of e??[]){if(Sd(n)){mf(n.children,t);continue}let e=n;xd(n)&&e.id&&t.set(e.id,e)}}function pte(e,t,n,r){if(!t||n==null||r-n>12e4)return e;let i=e,a=t.config?t.config.display:void 0;if(t.config&&JSON.stringify(a??null)!==JSON.stringify(e.config?.display??null)){let t={...e.config};a===void 0?delete t.display:t.display=a,i={...e,config:t}}let o=t.config?t.config.cohortLock:void 0;if(t.config&&o!==i.config?.cohortLock){let e={...i.config};o===void 0?delete e.cohortLock:e.cohortLock=o,i={...i,config:e}}let s=t.config?t.config.filters:void 0;if(!Array.isArray(s)||s.length===0)return i;let c=new Map;if(mf(s,c),c.size===0)return i;let l=new Map;mf(e.config?e.config.filters:void 0,l);let u=!1;for(let[e,t]of c){if(!bd(t))continue;let n=l.get(e);if(!n||!bd(n)){u=!0;break}}return u?{...i,config:{...i.config,filters:s,filterConj:t.config.filterConj??e.config.filterConj}}:i}function hf(e,t){let n=e=>{let n={};for(let[r,i]of Object.entries(e??{}))typeof i==`number`&&t-i<=12e4&&(n[r]=i);return n};return{edited:n(e?.edited),deleted:n(e?.deleted)}}function gf(e){if(Array.isArray(e))return e.map(gf);if(e&&typeof e==`object`){let t={};for(let n of Object.keys(e).sort()){let r=e[n];r!==void 0&&(t[n]=gf(r))}return t}return e}function _f(e){let{createdBy:t,permissions:n,editRequestId:r,labelCorrectedFrom:i,labelCorrectionId:a,...o}=e;return JSON.stringify(gf(o))}function mte(e,t,n,r,i){let a=e=>typeof e==`number`&&r-e<=12e4,o=new Map(t.map(e=>[e.key,e])),s=[];for(let t of e){let e=o.get(t.key);if(o.delete(t.key),!a(n?.deleted?.[t.key])){if(!e){s.push(t);continue}if(!i){s.push({...e,...t,note:t.note??e.note});continue}if(t.labelCorrectedFrom===e.label&&t.label!==e.label&&typeof t.labelCorrectionId==`string`&&t.labelCorrectionId===e.editRequestId){s.push(t);continue}if(a(n?.edited?.[t.key])&&_f(e)!==_f(t)){s.push({...e,...t.createdBy==null?{}:{createdBy:t.createdBy}});continue}s.push(t.note==null&&e.note!=null?{...t,note:e.note}:t)}}for(let e of o.values())if(e.custom&&!a(n?.deleted?.[e.key])){if(e.source===`overlay`){s.push(e);continue}(!i||a(n?.edited?.[e.key]))&&s.push(e)}return s}function hte(e,t){let n=e.filter(e=>!(e.pid===t.pid&&e.key===t.key));return n.push(t),n.slice(-64)}function gte(e,t,n){let r=[],i={};for(let a of e){if(a==null||typeof a.pid!=`number`||typeof a.key!=`string`||typeof a.at!=`number`)continue;let e=t(a.pid),o=e?e[a.key]:void 0;String(o??``)!==String(a.value??``)&&(n-a.at>12e4||(r.push(a),i[a.pid]={...i[a.pid],[a.key]:a.value}))}return{keep:r,seeds:i}}function vf(){if(typeof window>`u`)return null;let e=window.__AIOS_GRID__;return e&&Array.isArray(e.rows)&&Array.isArray(e.fields)?e:null}function yf(){let e=tte()?.payload;return e&&Array.isArray(e.rows)&&Array.isArray(e.fields)?e:null}function bf(e,t){let n={...e,workspace:t};Array.isArray(t.measures)&&(n.measures=t.measures),t.measureSets&&typeof t.measureSets==`object`&&(n.measureSets=t.measureSets),t.viewer&&typeof t.viewer.name==`string`&&(n.viewer=t.viewer),Array.isArray(t.userOptions)&&(n.userOptions=t.userOptions);let r=t.derived;return r&&typeof r==`object`&&Object.keys(r).length>0&&(n.rows=e.rows.map(e=>{let t=r[String(e.pid)];return t?{...e,...t}:e})),n}function xf(){return yf()??vf()}var Sf=Xd(),_te=vf()!==null;function vte(e){return`aios-grid-cells:${e}`}function yte(e){try{let t=localStorage.getItem(vte(e)),n=t?JSON.parse(t):null;return Array.isArray(n)?n:[]}catch{return[]}}function bte(e,t){try{localStorage.setItem(vte(e),JSON.stringify(t))}catch{}}function xte(e){let t=e?.workspace?.storageKey;if(!e||!t)return{};let n=new Map(e.rows.map(e=>[e.pid,e])),{keep:r,seeds:i}=gte(yte(t),e=>n.get(e),Date.now());return bte(t,r),i}function Ste(e=`customer`){cte(e);let t=Ed(e),[n,r]=(0,L.useState)(()=>xf()),[i,a]=(0,L.useState)(()=>Sf?xte(xf()):{}),o=(0,L.useRef)(n);o.current=n;let[s,c]=(0,L.useState)(0);(0,L.useEffect)(()=>{if(Sf)return;let e=()=>c(e=>e+1);return window.addEventListener(Kd,e),()=>window.removeEventListener(Kd,e)},[]),(0,L.useEffect)(()=>{if(Sf){let e=()=>{let e=yf();if(!e)return;let t=xte(e);Object.keys(t).length&&a(e=>{let n={...e};for(let[e,r]of Object.entries(t))n[Number(e)]={...r,...n[Number(e)]};return n}),r(e)};return e(),nte(e)}if(vf())return;let n=!1;async function i(){let[i,a]=await Promise.all([ate(t),sf(e)]);n||!i||r(a?bf(i,a):i)}i();async function o(){let t=await sf(e);n||!t||r(e=>e&&bf(e,t))}let s=e=>{let t=e.detail;!t||typeof t!=`object`||r(e=>{if(!e)return e;let n=!1,r=e.rows.map(e=>{let r=t[String(e.pid)];if(!r||typeof r!=`object`)return e;let i={};for(let[e,t]of Object.entries(r))(t===null||typeof t==`string`||typeof t==`number`)&&(i[e]=t);return Object.keys(i).length===0?e:(n=!0,{...e,...i})});return n?{...e,rows:r}:e})},c=()=>{o()};return typeof window<`u`&&(window.addEventListener(Wd,c),window.addEventListener(Ud,s)),()=>{n=!0,typeof window<`u`&&(window.removeEventListener(Wd,c),window.removeEventListener(Ud,s))}},[e,t,s]);let l=(0,L.useCallback)((e,n)=>{let r;if(a(t=>(r=t[e],{...t,[e]:{...t[e],...n}})),Sf){let t=o.current?.workspace?.storageKey;if(t){let r=yte(t),i=Date.now();for(let[t,a]of Object.entries(n))r=hte(r,{pid:e,key:t,value:a??null,at:i});bte(t,r)}$d({id:ef(`overlay`),type:`overlay_patch`,pid:e,updates:n});return}_te||ote(t,e,n).then(t=>{t||(console.warn(`customer-grid: overlay PATCH failed for pid ${e}; rolling back`),a(t=>{let n={...t};return r===void 0?delete n[e]:n[e]=r,n}))})},[t]);return{fields:n?.fields??[],rawRows:n?.rows??[],payload:n,loading:n===null,overlayEdits:i,setOverlayEdits:a,patchOverlay:l}}var Cf=`#202433`,wf=`#6B7280`,Tf=`#E6E9EF`,Cte=`#FFFFFF`,wte=`#FAFBFC`,Tte=`#9DBFF2`,Ef=`#EDF3FD`,Ete=`#F5D989`,Df=`#FBF4E0`,Dte=`#F0A8A0`,Ote=`#FCEEEC`,kte=`#A5D8B4`,Of=`#EBF6EF`,kf=`#F1EEFB`,Ate=`#6B57A8`,jte=`#768FB6`,Mte=`#4F6079`,Af=`#7E6428`,jf=`#A3453C`,Mf=`#35754E`,Nf={accentColor:jte,accentLight:Ef,textDark:Cf,textMedium:wf,textLight:`#8B92A0`,textHeader:Cf,bgCell:Cte,bgHeader:wte,bgHeaderHovered:`#F1F3F6`,bgHeaderHasFocus:Ef,borderColor:Tf,horizontalBorderColor:Tf,fgIconHeader:wf,bgIconHeader:Tf,fontFamily:`Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif`,baseFontStyle:`13px`,headerFontStyle:`600 13px`},Nte={growing:{bgBubble:Of,textBubble:Mf},new:{bgBubble:Ef,textBubble:Mte},declining:{bgBubble:Df,textBubble:Af},dormant:{bgBubble:Tf,textBubble:Cf},lost:{bgBubble:Ote,textBubble:jf},reactivated:{bgBubble:kte,textBubble:Cf}},Pte={growing:{bgCell:`rgba(165, 216, 180, 0.40)`},new:{bgCell:`rgba(157, 191, 242, 0.38)`},declining:{bgCell:`rgba(245, 217, 137, 0.42)`},dormant:{bgCell:`rgba(107, 114, 128, 0.13)`},lost:{bgCell:`rgba(240, 168, 160, 0.38)`},reactivated:{bgCell:`rgba(165, 216, 180, 0.72)`}},Fte={growing:{bgCell:`rgba(165, 216, 180, 0.62)`},new:{bgCell:`rgba(157, 191, 242, 0.60)`},declining:{bgCell:`rgba(245, 217, 137, 0.64)`},dormant:{bgCell:`rgba(107, 114, 128, 0.22)`},lost:{bgCell:`rgba(240, 168, 160, 0.60)`},reactivated:{bgCell:`rgba(165, 216, 180, 0.92)`}},Ite={bgCell:`rgba(32, 36, 51, 0.06)`},Lte=Ite,Rte=Ite,Pf=`700 13px`;function Ff(e,t){let n=parseInt(e.slice(1),16);return`rgba(${n>>16&255}, ${n>>8&255}, ${n&255}, ${t})`}var zte={filter:{bgHeader:Of,bgHeaderHovered:Of,bgHeaderHasFocus:Of,bgCell:Ff(Mf,.06),headerFontStyle:Pf},sort:{bgHeader:Df,bgHeaderHovered:Df,bgHeaderHasFocus:Df,bgCell:Ff(Af,.06),headerFontStyle:Pf},group:{bgHeader:kf,bgHeaderHovered:kf,bgHeaderHasFocus:kf,bgCell:Ff(Ate,.06),headerFontStyle:Pf}},Bte=wf,If=(e,t,n)=>`M${e-n} ${t}a${n} ${n} 0 1 0 ${n*2} 0a${n} ${n} 0 1 0 ${-n*2} 0`,Vte=[{d:`M3.2 4.6h9.6v8.2H3.2z`},{d:`M3.2 7.2h9.6`},{d:`M5.8 3v3.2`},{d:`M10.2 3v3.2`}],Lf={text:[{d:`M3 5h10M3 8h10M3 11h6`}],status:[{d:`M4 13V3.5h7.6L10.1 6l1.5 2.5H4`}],currency:[{d:`M8 2.8v10.4`},{d:`M10.6 5.4A2.6 2.6 0 0 0 8.2 4.2H7.4a2 2 0 0 0 0 4h1.2a2 2 0 0 1 0 4H7.8a2.6 2.6 0 0 1-2.4-1.4`}],int:[{d:`M6.2 3L4.8 13M11.2 3l-1.4 10M3.4 6.2h9.2M2.9 9.8h9.2`}],date:Vte,pct:[{d:If(4.6,4.6,1.6)},{d:If(11.4,11.4,1.6)},{d:`M12.2 3.9L3.8 12.3`}],select:[{d:`M3.2 3.8h9.6v8.4H3.2z`},{d:`M6.2 7.2l1.8 1.8 1.8-1.8`}],user:[{d:If(8,6,2.4)},{d:`M3.6 13c0-2.4 2-3.8 4.4-3.8s4.4 1.4 4.4 3.8`}],multiselect:[{d:`M3 4.6h2.2v2.2H3zM3 9.2h2.2v2.2H3z`},{d:`M7.2 5.7h6M7.2 10.3h6`}],checkbox:[{d:`M3.4 3.4h9.2v9.2H3.4z`},{d:`M5.8 8.1l1.8 1.9 3.4-3.9`}],phone:[{d:`M5.1 3.2L7 5.1 5.6 7a7.2 7.2 0 0 0 3.4 3.4l1.9-1.4 1.9 1.9-1.5 1.6c-3 .5-8.3-4.8-7.8-7.8z`}],email:[{d:`M3 4.4h10v7.2H3z`},{d:`M3 4.9l5 3.9 5-3.9`}],url:[{d:`M7 5.4L8.4 4a2.6 2.6 0 0 1 3.7 3.7L10.7 9`},{d:`M9 10.6L7.6 12a2.6 2.6 0 0 1-3.7-3.7L5.3 7`},{d:`M6.2 9.8l3.6-3.6`}],rating:[{d:`M8 2.9l1.63 3.3 3.64.53-2.63 2.57.62 3.63L8 11.24 4.74 12.93l.62-3.63L2.73 6.73l3.64-.53z`,fill:!0}],created_time:[{d:If(8,8,5.2)},{d:`M8 4.9v3.4l2.3 1.4`}],formula:[{d:`M5.6 12.8V5.4a2 2 0 0 1 3.2-1.6`},{d:`M4.2 7.6h4.6`},{d:`M10.2 8.4l3 3.4M13.2 8.4l-3 3.4`}],automation:[{d:`M10.8 4.1A4.8 4.8 0 1 1 5.3 4.1`},{d:`M4.2 6L5.3 4.1 3.1 4.5`},{d:`M6.9 6.1L9.8 8 6.9 9.9z`,fill:!0}]},Rf={grid:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M2.6 6.5h10.8M2.6 9.5h10.8M6.4 3.4v9.2M10 3.4v9.2`}],list:[{d:`M3 4.6h1.4M6.4 4.6h6.6M3 8h1.4M6.4 8h6.6M3 11.4h1.4M6.4 11.4h6.6`}],chart:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M5.4 10.6V7.2M8 10.6V5.4M10.6 10.6V8.6`}],dashboard:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M5.4 10.6V7.2M8 10.6V5.4M10.6 10.6V8.6`}],calendar:Vte,kanban:[{d:`M2.8 3.4h3.1v9.2H2.8zM6.5 3.4h3.1v6.2H6.5zM10.2 3.4h3.1v7.6h-3.1z`}],map:[{d:`M8 2.6a3.6 3.6 0 0 1 3.6 3.6c0 2.7-3.6 7.2-3.6 7.2S4.4 8.9 4.4 6.2A3.6 3.6 0 0 1 8 2.6z`},{d:If(8,6.1,1.3)}],timeseries:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M2.6 6.6h10.8M6.2 3.4v9.2`},{d:`M7.2 10.8l2-2.4 1.6 1.2 1.8-2.6`}],catalog:[{d:`M2.4 4.2h4.6a1.6 1.6 0 0 1 1 .4l0 8a1.6 1.6 0 0 0-1-.4H2.4z`},{d:`M13.6 4.2H9a1.6 1.6 0 0 0-1 .4l0 8a1.6 1.6 0 0 1 1-.4h4.6z`},{d:`M3.9 6.4h2.3v2.8H3.9z`}]},Hte={bar:[{d:`M3.2 12.8V7.4M6.4 12.8V4.2M9.6 12.8V8.8M12.8 12.8V5.8`}],line:[{d:`M2.6 11.2l3.2-3.4 2.6 2 4.9-5.2`},{d:If(5.8,7.8,.9)},{d:If(8.4,9.8,.9)}],area:[{d:`M2.6 12.4V9.2l3.2-3.2 2.6 2 4.9-4.6v9z`},{d:`M2.6 9.2l3.2-3.2 2.6 2 4.9-4.6`}],donut:[{d:If(8,8,5)},{d:If(8,8,2.1)}],kpi:[{d:`M2.6 3.8h10.8v8.4H2.6z`},{d:`M5.4 9.6V6.4l1.9 3.2V6.4M9.4 6.4v3.2h1.8`}],table:[{d:`M2.6 3.4h10.8v9.2H2.6z`},{d:`M2.6 6.2h10.8M7.2 6.2v6.4M2.6 9.4h10.8`}]},Ute={bar:`blue`,line:`green`,area:`green`,donut:`yellow`,kpi:`neutral`,table:`neutral`},Wte={folder:[{d:`M2.4 12.6V4.2a.6.6 0 0 1 .6-.6h3.2l1.5 1.7h5.3a.6.6 0 0 1 .6.6v6.7a.6.6 0 0 1-.6.6H3a.6.6 0 0 1-.6-.6z`}],star:[{d:`M8 2.9l1.63 3.3 3.64.53-2.63 2.57.62 3.63L8 11.24 4.74 12.93l.62-3.63L2.73 6.73l3.64-.53z`}],flag:[{d:`M4.2 13.4V2.9`},{d:`M4.2 3.4h7.6l-1.5 2.6 1.5 2.6H4.2z`}],tag:[{d:`M2.9 8.2V3.5a.6.6 0 0 1 .6-.6h4.7l5 5-5.3 5.3z`},{d:If(5.6,5.6,1)}],bookmark:[{d:`M4.4 2.9h7.2v10.4L8 10.7l-3.6 2.6z`}],grid:Rf.grid,chart:Rf.dashboard,map:Rf.map,users:Lf.user,clock:Lf.created_time,heart:[{d:`M8 13.1S2.7 9.8 2.7 6.4a2.9 2.9 0 0 1 5.3-1.6 2.9 2.9 0 0 1 5.3 1.6c0 3.4-5.3 6.7-5.3 6.7z`}],bolt:[{d:`M9.1 2.4L4.2 9.1h3.3l-.6 4.5 4.9-6.7H8.5z`}]},zf={neutral:{fill:Tf,stroke:wf},blue:{fill:Tte,stroke:jte},green:{fill:kte,stroke:Mf},yellow:{fill:Ete,stroke:Af},red:{fill:Dte,stroke:jf}},Gte={neutral:`Neutral`,blue:`Blue`,green:`Green`,yellow:`Yellow`,red:`Red`},Kte={folder:`Folder`,star:`Star`,flag:`Flag`,tag:`Tag`,bookmark:`Bookmark`,grid:`Table`,chart:`Chart`,map:`Map`,users:`People`,clock:`Clock`,heart:`Heart`,bolt:`Priority`},Bf={grid:`Grid`,chart:`Chart`,dashboard:`Chart`,list:`List`,calendar:`Calendar`,kanban:`Kanban`,map:`Map`,timeseries:`Time series`,catalog:`Catalog`},qte=[`grid`,`chart`,`calendar`,`kanban`,`timeseries`,`map`,`list`,`catalog`],Jte={grid:`blue`,list:`blue`,chart:`green`,dashboard:`green`,calendar:`yellow`,kanban:`yellow`,map:`red`,timeseries:`green`,catalog:`neutral`},Vf={text:`Single line text`,select:`Single select`,multiselect:`Multi select`,user:`Assignee`,int:`Number`,currency:`Currency`,pct:`Percent`,date:`Date`,checkbox:`Checkbox`,phone:`Phone number`,email:`Email`,url:`URL`,rating:`Rating`,created_time:`Created time`,formula:`Formula`,automation:`Automation`,status:`Lifecycle status (Odoo)`};function Yte(e,t){return e.fill?``:``}function Xte(e){return({fgColor:t})=>``+e.map(e=>Yte(e,t)).join(``)+``}function Zte(e){return`t_${e}`}var Qte={...Object.fromEntries(Object.keys(Lf).map(e=>[Zte(e),Xte(Lf[e])])),aiosInfo:()=>``};function $te(e,t,n){return e&&t>Math.max(0,n-16)?e:null}function ene(e,t,n,r=8){let i=Math.min(n,280);return Math.round(Math.max(r,Math.min(e,t-r-i)))}var tne=`600 13px`;function nne(e,t,n,r,i){let a=t=>`${e} ${t} (${n})`,o=a(t);if(r==null||r<=0||i(o)<=r)return o;let s=r-i(a(``));return s<=0?o:a(one(t,s,i))}function rne(e,t,n,r=4){if(n.length===0)return null;let i=[],a=e.x+e.width-t-r;for(let t of n){let n=a-t;if(n-e.x<68)return null;i.push({x:Math.round(n),y:Math.round(e.y+(e.height-t)/2),size:t}),a=n-6}return i}function ine(e,t){let n=[];return e&&n.push(16),t&&n.push(6),n}function ane(e,t,n=30){let r=rne({x:0,y:0,width:e,height:32},n,t===!0?[16]:t===!1?[]:t);return r?Math.max(0,r[r.length-1].x-32-6):null}function one(e,t,n){if(t==null||!e||n(e)<=t)return e;let r=n(`…`);if(r>t)return e;let i=0,a=e.length;for(;it.x+t.width||at.y+t.height)?null:{x:i,y:a,size:n}}function cne(e){let{placement:t,target:n,panel:r,viewport:i}=e,a=i.left+8,o=i.left+i.width-8,s=i.top+8,c=i.top+i.height-8,l=Math.max(1,o-a),u=Math.min(r.width,l),d=r.height,f,p,m,h;if(t===`right-start`){let e=Math.max(0,o-(n.right+6)),t=Math.max(0,n.left-6-a),r=u<=e||e>=t;h=r?`right`:`left`;let i=r?n.right+6:n.left-6-u;f=Math.min(Math.max(i,a),Math.max(a,o-u)),m=Math.max(1,c-s),p=Math.min(Math.max(n.top,s),Math.max(s,c-Math.min(d,m)))}else{let e=Math.max(0,c-(n.bottom+6)),r=Math.max(0,n.top-6-s),i=d<=e||e>=r;h=i?`below`:`above`,m=Math.max(1,i?e:r);let l=t===`bottom-end`?n.right-u:n.left;f=Math.min(Math.max(l,a),o-u),p=i?Math.min(n.bottom+6,c-m):Math.max(s,n.top-6-Math.min(d,m))}return{left:Math.round(f),top:Math.round(p),maxWidth:Math.floor(l),maxHeight:Math.floor(m),side:h}}var lne=150,Hf={base:void 0,bold:void 0};function une(e,t=!1){let n=t?`bold`:`base`;if(Hf[n]===void 0){let e=document.createElement(`canvas`).getContext(`2d`);e&&(e.font=`${(t?`700 13px`:Nf.headerFontStyle)??`600 13px`} ${Nf.fontFamily??`Inter, sans-serif`}`),Hf[n]=e}let r=Hf[n];return r?r.measureText(e).width:0}function dne(e){return!!(e.note||e.description)}function fne(e,t){for(let n of e??[]){if(Sd(n)){fne(n.children,t);continue}bd(n)&&t.add(n.colId)}}function pne(e){return e?zte[e]:void 0}function mne(e){let t=new Map;e.groupBy&&t.set(e.groupBy,`group`);for(let n of e.sorts??[])t.set(n.colId,`sort`);let n=new Set;fne(e.filters??[],n);for(let e of n)t.set(e,`filter`);return t}function Uf(e){return e.default!==!1||e.source===`overlay`}function Wf(e){let t=e.filter(Uf).map(e=>e.key),n=e.filter(e=>!Uf(e)).map(e=>e.key);return{filters:[],filterConj:`and`,sorts:[],groupBy:null,colorBy:null,rowHeightMode:`short`,order:[...t,...n],visible:t,widths:{},memberPids:[]}}function hne(e,t){let n=new Set(t.map(e=>e.key)),r=e.filter((t,r)=>n.has(t)&&e.indexOf(t)===r);for(let e of t)r.includes(e.key)||r.push(e.key);let i=t.find(e=>e.pinned)?.key??t[0]?.key;return i&&r[0]!==i?[i,...r.filter(e=>e!==i)]:r}function gne(e,t,n){let r=new Set(t.map(e=>e.key)),i=new Set(e.filter(e=>r.has(e)));if(i.size===0)for(let e of t)Uf(e)&&i.add(e.key);return n&&i.add(n),i}function _ne(e,t,n){let r=(0,L.useMemo)(()=>new Map(e.map(e=>[e.key,e])),[e]),i=(0,L.useMemo)(()=>e.find(e=>e.pinned)?.key??e[0]?.key??``,[e]),a=(0,L.useMemo)(()=>hne(t.order,e),[t.order,e]),o=(0,L.useMemo)(()=>gne(t.visible,e,i),[t.visible,e,i]),s=(0,L.useMemo)(()=>mne(t),[t.filters,t.sorts,t.groupBy]),c=(0,L.useMemo)(()=>a.filter(e=>o.has(e)).map(e=>{let n=r.get(e),i=t.widths[e]??lne,a=s.has(e),o=ine(dne(n),n.source===`overlay`);return{id:e,title:one(n.label,ane(i,o),e=>une(e,a)),width:i,hasMenu:!0,menuIcon:`dots`,icon:Zte(n.type),themeOverride:pne(s.get(e))}}),[a,o,t.widths,r,s]),l=(0,L.useCallback)((e,r)=>{e.id&&n({...t,widths:{...t.widths,[e.id]:Math.round(r)}})},[t,n]),u=(0,L.useCallback)((e,r)=>{if(e===0||r===0)return;let i=a.filter(e=>o.has(e));if(e<0||e>=i.length||r<0||r>=i.length)return;let s=i.slice(),[c]=s.splice(e,1);s.splice(r,0,c);let l=0,u=a.map(e=>o.has(e)?s[l++]:e);n({...t,order:u})},[t,n,a,o]),d=(0,L.useCallback)((e,t)=>e!==0&&t!==0,[]),f=(0,L.useCallback)((e,r)=>{if(!r&&e===i)return;let a=new Set(o);r?a.add(e):a.delete(e),n({...t,visible:[...a]})},[t,i,n,o]),p=(0,L.useCallback)((e,r,i)=>{let s=a.filter(t=>t!==e);if(i===`end`||!r)s.push(e);else{let t=Math.max(0,s.indexOf(r));s.splice(t+ +(i===`right`),0,e)}let c=new Set(o);c.add(e),n({...t,order:s,visible:[...c]})},[t,n,a,o]);return{visibleCols:c,fieldByKey:r,order:a,visible:o,widths:t.widths,lockedKey:i,onColumnResize:l,onColumnMoved:u,onColumnProposeMove:d,setColumnVisible:f,insertColumn:p}}function vne(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:0}function yne(e,t){let n={};for(let r of t){if(r.agg!==`sum`)continue;let t=0;for(let n of e)t+=vne(n[r.key]);let i=Math.round(t*100)/100;n[r.key]=r.type===`currency`?`$`+i.toLocaleString():i.toLocaleString()}return n}var Gf={sets:new Map,unanswerable:0};function bne(e){return e===`currency`||e===`int`||e===`pct`||e===`rating`||e===`formula`}function Kf(e){return!Sd(e)&&!xd(e)&&dd(e.op)}function qf(e){for(let t of e??[]){if(Sd(t)){if(qf(t.children))return!0;continue}if(Kf(t))return!0}return!1}function Jf(e){let t=[];for(let n of e??[]){if(Sd(n)){let e=Jf(n.children);e.length&&t.push({conj:n.conj,children:e});continue}Kf(n)||t.push(n)}return t}function Yf(e){let t=[];for(let n of e??[]){if(Sd(n)){t.push(...Yf(n.children));continue}if(!Kf(n))continue;let e=n;bd(e)&&t.push(e)}return t}function xne(e,t,n){let r=[];for(let n of e){let e=n[t];if(e==null||e===``)continue;let i=typeof e==`number`?e:Number(e);Number.isFinite(i)&&r.push({pid:n.pid,v:i})}return r.sort((e,t)=>e.v===t.v?e.pid-t.pid:n===`asc`?e.v-t.v:t.v-e.v),r}function Xf(e,t,n){let r=Number(e);if(!Number.isFinite(r))return null;let i=Math.trunc(r);return i!==r||in?null:i}function Sne(e,t,n){return Math.min(n,Math.floor(e*n/t)+1)}function Zf(e,t){return Math.min(e,Math.max(1,Math.ceil(e*t/100)))}function Cne(e,t,n){let r=Yf(e);if(!r.length)return Gf;let i=new Map,a=0,o=new Map,s=(e,n)=>{let r=`${n}:${e}`,i=o.get(r);return i||(i=xne(t,e,n),o.set(r,i)),i},c=e=>{i.set(e,new Set),a+=1};for(let e of r){let r=n.get(e.colId);if(!r||!bne(r.type)){c(e);continue}let o=s(e.colId,`asc`);if(!o.length){i.set(e,new Set),t.length&&(a+=1);continue}let l=o.length,u=null;switch(e.op){case`topN`:{let t=Xf(e.value,1,1e4);u=t==null?null:s(e.colId,`desc`).slice(0,t);break}case`bottomN`:{let t=Xf(e.value,1,1e4);u=t==null?null:o.slice(0,t);break}case`inTopPct`:{let t=Xf(e.value,1,100);u=t==null?null:s(e.colId,`desc`).slice(0,Zf(l,t));break}case`inBottomPct`:{let t=Xf(e.value,1,100);u=t==null?null:o.slice(0,Zf(l,t));break}case`aboveAvg`:case`belowAvg`:{let t=o.reduce((e,t)=>e+t.v,0)/l;u=o.filter(n=>e.op===`aboveAvg`?n.v>t:n.vSne(r,l,t)===n);break}default:u=null}if(u==null){c(e);continue}i.set(e,new Set(u.map(e=>e.pid)))}return{sets:i,unanswerable:a}}function Qf(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:0}function $f(e){return e===`currency`||e===`int`||e===`pct`||e===`rating`||e===`formula`}function wne(e){return e===`date`||e===`created_time`}function Tne(e,t,n){for(let r of n){if(r.type!==`text`&&r.type!==`status`)continue;let n=t[r.key];if(n!=null&&String(n).toLowerCase().includes(e))return!0}return!1}function ep(e){return e==null||e===``}function Ene(e,t,n,r){let i=n.get(e.colId);if(!i)return!0;let a=t[e.colId];if(e.op===`isEmpty`)return ep(a);if(e.op===`isNotEmpty`)return!ep(a);if(dd(e.op))return!1;let o=e.rhs!=null,s=o?t[yd(e.rhs)??``]:void 0;if($f(i.type)){let t=Qf(a);if(o)return tp(e.op,t,Qf(s));if(e.op===`between`){if(e.value===``||e.value2==null||e.value2===``)return!0;let n=Math.min(Qf(e.value),Qf(e.value2)),r=Math.max(Qf(e.value),Qf(e.value2));return t>=n&&t<=r}return e.value===``||tp(e.op,t,Qf(e.value))}if(wne(i.type)){let t=String(a??``).slice(0,10);if(e.op===`within`){if(!r)return!1;let n=Yu(e.dateWindow,r);if(!n||t===``)return!1;let[i,a]=n;return(i==null||t>=i)&&(a==null||t<=a)}if(o)return np(e.op,t,String(s??``).slice(0,10));if(e.op===`between`){if(e.value===``||e.value2==null||e.value2===``)return!0;let n=e.value=n&&t<=r}if(!Dne.has(e.op)||!e.dateMode&&e.value===``)return!0;let n=e.dateMode||`exact`;if(n!==`exact`&&!r)return!1;let i=Zu(n,e.value,r||`1970-01-01`);return i!=null&&np(e.op,t,i)}let c=String(a??``).toLowerCase();return o?rp(e.op,c,String(s??``).toLowerCase()):e.value===``||rp(e.op,c,e.value.toLowerCase())}var Dne=new Set([`eq`,`neq`,`lt`,`lte`,`gt`,`gte`]);function tp(e,t,n){switch(e){case`gt`:return t>n;case`gte`:return t>=n;case`lt`:return tn;case`gte`:return t>=n;default:return!0}}function rp(e,t,n){switch(e){case`contains`:return t.includes(n);case`doesNotContain`:return!t.includes(n);case`eq`:return t===n;case`neq`:return t!==n;default:return!0}}function ip(e,t,n,r){if(Sd(e)){let i=!1,a=!0,o=!1;for(let s of e.children){let e=ip(s,t,n,r);e!==null&&(i=!0,a&&=e,o||=e)}return i?e.conj===`or`?o:a:null}if(md(e)){if(!bd(e))return null;let n=_d(e.value).map(e=>r?.cohortSets?.[e]);if(n.some(e=>!e))return!1;let i=gd(e.op);if(i===`allOf`)return n.every(e=>e.has(t.pid));let a=n.some(e=>e.has(t.pid));return i===`noneOf`?!a:a}if(xd(e)){if(!bd(e))return null;let n=e.id?r?.measureSets?.[e.id]:void 0;return n?n.has(t.pid):!1}if(!n.has(e.colId)||e.rhs&&!n.has(yd(e.rhs)??``)||!bd(e))return null;if(dd(e.op)){let n=r?.rankSets?.get(e);return n?n.has(t.pid):!1}return Pee.includes(e.op)?Ene(e,t,n,r?.today):!1}function ap(e,t){let n=0;for(let r of e??[]){if(Sd(r)){n+=ap(r.children,t);continue}!xd(r)||!bd(r)||(!r.id||!t?.[r.id])&&(n+=1)}return n}function op(e){let t=[];for(let n of e??[]){if(Sd(n)){t.push(...op(n.children));continue}!xd(n)||!bd(n)||t.push(n.id||`(no-id)`)}return t}function sp(e,t){let n=0;for(let r of e??[]){if(Sd(r)){n+=sp(r.children,t);continue}if(bd(r)){if(md(r)){_d(r.value).some(e=>!t?.cohortSets?.[e])&&(n+=1);continue}xd(r)||(r.op===`within`?(!t?.today||!Yu(r.dateWindow,t.today))&&(n+=1):r.dateMode&&(!t?.today||Zu(r.dateMode,r.value,t.today)==null)&&(n+=1))}}return n}function cp(e,t,n,r,i){let a=ip({conj:t,children:e},n,r,i);return a===null||a}function One(e,t){return(n,r)=>{for(let i of e){let e=t.get(i.colId),a=e?$f(e.type):!1,o=n[i.colId],s=r[i.colId],c=ep(o),l=ep(s);if(c!==l)return c?1:-1;if(c&&l)continue;let u=a?Qf(o)-Qf(s):String(o??``).localeCompare(String(s??``));if(u!==0)return i.dir===`asc`?u:-u}return 0}}function kne(e,t,n,r){let i=[],a=new Map,o=r.some(e=>e.key===t&&(e.multi||e.type===`multiselect`)),s=r.some(e=>e.key===t&&e.type===`checkbox`),c=e=>s?e===`1`?`Checked`:`Unchecked`:e===``?`(empty)`:e;for(let n of e){let e=n[t],r=e==null?``:String(e),s=o?r.split(`,`).map(e=>e.trim()).filter(e=>e!==``):[r];for(let e of s.length?s:[``]){let t=a.get(e);t||(t=[],a.set(e,t),i.push(e)),t.push(n)}}let l=[];for(let e of i){let t=a.get(e),i=n.has(e),o=yne(t,r);if(l.push({kind:`group-header`,groupKey:e,label:c(e),count:t.length,collapsed:i,aggs:o}),!i){for(let e of t)l.push({kind:`data`,record:e});l.push({kind:`group-footer`,groupKey:e,aggs:o})}}return l}function lp(e){let{rawRows:t,fields:n,filters:r,search:i,sorts:a,groupBy:o,collapsed:s,memberPids:c=[],filterConj:l=`and`,serverWindowed:u=!1,measureSets:d,cohortSets:f,today:p,cohortLock:m}=e,h={measureSets:d,cohortSets:f,today:p},g=0,_=e=>{let t=e.map(e=>({kind:`data`,record:e})),n=new Map;return t.forEach((e,t)=>{e.kind===`data`&&n.set(e.record.pid,t)}),{visibleRows:t,pidToIndex:n,unresolvedRank:g}};if(u)return _(t);let v=new Map;for(let e of n)v.set(e.key,e);let y=t;if(m){let e=f?.[m];if(!e)return _([]);y=y.filter(t=>e.has(t.pid))}if(r.length){if(qf(r)){let e=Jf(r),t=y,n=Cne(r,e.length?t.filter(t=>cp(e,l,t,v,h)):t,v);h.rankSets=n.sets,g=n.unanswerable}else h.rankSets=Gf.sets;let e=new Set(c);y=y.filter(t=>e.has(t.pid)||cp(r,l,t,v,h))}let b=i.trim().toLowerCase();if(b&&(y=y.filter(e=>Tne(b,e,n))),a.length&&(y=[...y].sort(One(a,v))),!o)return _(y);let x=kne(y,o,s,n),S=new Map;return x.forEach((e,t)=>{e.kind===`data`&&!S.has(e.record.pid)&&S.set(e.record.pid,t)}),{visibleRows:x,pidToIndex:S,unresolvedRank:g}}function Ane(e,t,n,r,i,a,o,s=[],c=`and`,l=!1,u,d,f,p){return(0,L.useMemo)(()=>lp({rawRows:e,fields:t,filters:n,search:r,sorts:i,groupBy:a,collapsed:o,memberPids:s,filterConj:c,serverWindowed:l,measureSets:u,cohortSets:d,today:f,cohortLock:p}),[e,t,n,c,r,i,a,o,s,l,u,d,f,p])}var up=[{bg:`#EDF3FD`,fg:`#4F6079`},{bg:`#EBF6EF`,fg:`#35754E`},{bg:`#FBF4E0`,fg:`#7E6428`},{bg:`#FCEEEC`,fg:`#A3453C`},{bg:`#F1EEFB`,fg:`#6B57A8`},{bg:`#EEF1F4`,fg:`#4B5563`}];function dp(e){if(!(typeof e!=`string`||!/^#[0-9a-f]{6}$/i.test(e.trim())))return e.trim().toUpperCase()}var fp=`#182230`,pp=[{id:`blue-tint`,hue:`blue`,strength:`tint`,bg:`#EDF3FD`,fg:`#4F6079`,label:`Light blue`},{id:`green-tint`,hue:`green`,strength:`tint`,bg:`#EBF6EF`,fg:`#35754E`,label:`Light green`},{id:`yellow-tint`,hue:`yellow`,strength:`tint`,bg:`#FBF4E0`,fg:`#7E6428`,label:`Light yellow`},{id:`red-tint`,hue:`red`,strength:`tint`,bg:`#FCEEEC`,fg:`#A3453C`,label:`Light red`},{id:`purple-tint`,hue:`purple`,strength:`tint`,bg:`#F1EEFB`,fg:`#6B57A8`,label:`Light purple`},{id:`blue-pastel`,hue:`blue`,strength:`pastel`,bg:`#9DBFF2`,fg:fp,label:`Blue`},{id:`green-pastel`,hue:`green`,strength:`pastel`,bg:`#A5D8B4`,fg:fp,label:`Green`},{id:`yellow-pastel`,hue:`yellow`,strength:`pastel`,bg:`#F5D989`,fg:fp,label:`Yellow`},{id:`red-pastel`,hue:`red`,strength:`pastel`,bg:`#F0A8A0`,fg:fp,label:`Red`},{id:`purple-pastel`,hue:`purple`,strength:`pastel`,bg:`#C3B3EE`,fg:fp,label:`Purple`}];function mp(e){let t=dp(e);if(!t)return;let n=gp(t,1),r=gp(t,3),i=gp(t,5),a=pp[0],o=1/0;for(let e of pp){let t=n-gp(e.bg,1),s=r-gp(e.bg,3),c=i-gp(e.bg,5),l=(n+gp(e.bg,1))/2,u=(2+l/256)*t*t+4*s*s+(2+(255-l)/256)*c*c;u>>0;return up[t%up.length]}function Mne(e,t){let n=e.optionColors;if(!n)return;let r=dp(n[t]);if(r)return r;let i=t.trim().toLowerCase();for(let[e,t]of Object.entries(n))if(e.trim().toLowerCase()===i)return dp(t)}function gp(e,t){return Number.parseInt(e.slice(t,t+2),16)}function _p(e){let t=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(gp(e,1))+.7152*t(gp(e,3))+.0722*t(gp(e,5))}function Nne(e){let t=_p(dp(e)??`#FFFFFF`),n=_p(`#182230`),r=_p(`#FFFFFF`);return(t+.05)/(n+.05)>=(r+.05)/(t+.05)?`#182230`:`#FFFFFF`}function vp(e,t){if(!t||e.colorCodeOptions===!1)return;let n=Mne(e,t);return n?jne(n):hp(t)}function yp(e){return hp(e).bg}function bp(e){let t=e.split(`@`)[0].trim().split(/[\s._]+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function Pne(e){return Math.max(14,Math.min(22,e-6))}function Fne(e,t){return{data:{kind:`aios-user`,name:e,photo:t?.[e]},copyData:e}}function xp(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:0}function Sp(e){return typeof e==`string`&&e.trim()!==``&&!Number.isFinite(Number(e))}function Cp(e){return e==null||typeof e==`string`&&e.trim()===``}function wp(e){return e===`1`||e===1||e===!0}function Tp(e,t){if(t?.abbrev&&Math.abs(e)>=1e3){let t=Math.abs(e),[n,r]=t>=1e9?[1e9,`B`]:t>=1e6?[1e6,`M`]:[1e3,`k`];return(e/n).toFixed(1)+r}let n=t&&Number.isInteger(t.decimals)&&t.decimals>=0&&t.decimals<=4?t.decimals:null,r=t?.thousands!==!1;return n==null?r?e.toLocaleString():String(e):r?e.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n}):e.toFixed(n)}function Ine(e){let t=e.includes(` `)?e.replace(` `,`T`):e,n=/T\d{2}:\d{2}/.test(t)&&!/(?:[zZ]|[+-]\d{2}:?\d{2})$/.test(t)?t+`Z`:t,r=new Date(n);return Number.isNaN(r.getTime())?null:r}function Ep(e,t){if(t==null||t===``)return``;let n=String(t),r=Ine(n);if(!r)return n;let i=e.format,a=i?.time??e.type===`created_time`,o=i?.tz===`utc`?{timeZone:`UTC`}:void 0;return a?r.toLocaleString(void 0,o):r.toLocaleDateString(void 0,o)}var Lne=[`ok`,`partial`,`error`,`blocked`,`queued`];function Dp(e){let t=String(e??``).split(`·`)[0].trim().toLowerCase();return Lne.includes(t)?t:`none`}function Op(e){let t=String(e??``).split(`·`);return t.length>1?t.slice(1).join(`·`).trim():``}function Rne(e){let t=Dp(e);return t===`none`?`Not run yet`:t[0].toUpperCase()+t.slice(1)}function kp(e,t){switch(e.type){case`currency`:return t==null||t===``?``:`$`+Tp(xp(t),e.format);case`formula`:return Cp(t)?``:Sp(t)?t:Tp(xp(t),e.format);case`int`:return t==null||t===``?``:Tp(xp(t),e.format);case`pct`:return t==null||t===``?``:xp(t).toFixed(1)+`%`;case`date`:case`created_time`:return Ep(e,t);case`checkbox`:return wp(t)?`Checked`:``;case`rating`:{let n=xp(t);return n>=1?`${Math.round(n)} of ${nd(e)}`:``}case`automation`:return String(t??``);case`multiselect`:return String(t??``).split(`,`).map(e=>e.trim()).filter(e=>e!==``).join(`, `);default:return String(t??``)}}ct();var zne={ok:{bgCell:Of,textDark:Mf},partial:{bgCell:Df,textDark:Af},blocked:{bgCell:Df,textDark:Af},error:{bgCell:Ote,textDark:jf},queued:{bgCell:Ef,textDark:Mte},none:void 0};function Bne(e,t,n,r,i){e.beginPath();for(let i=0;i<10;i+=1){let a=Math.PI/5*i-Math.PI/2,o=i%2==0?r:r*.45,s=t+Math.cos(a)*o,c=n+Math.sin(a)*o;i===0?e.moveTo(s,c):e.lineTo(s,c)}e.closePath(),i?(e.fillStyle=`#A98A3E`,e.fill()):(e.strokeStyle=`rgba(118, 143, 182, 0.55)`,e.lineWidth=1,e.stroke())}var Ap=new Map,jp;function Mp(e){jp=e}function Vne(e){let t=Ap.get(e);if(t!==void 0)return t;if(typeof Image>`u`)return Ap.set(e,null),null;let n=new Image;return Ap.set(e,n),n.onload=()=>jp?.(),n.onerror=()=>{Ap.set(e,null),jp?.()},n.src=e,n}function Hne(e,t,n,r,i,a,o){let s=a?Vne(a):null;if(s&&s.complete&&s.naturalWidth>0){e.save(),e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.clip();let i=Math.max(r*2/s.naturalWidth,r*2/s.naturalHeight),a=s.naturalWidth*i,o=s.naturalHeight*i;e.drawImage(s,t-a/2,n-o/2,a,o),e.restore();return}let c=hp(i);e.save(),e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fillStyle=c.bg,e.fill(),e.fillStyle=c.fg,e.font=`600 ${Math.round(r*.9)}px ${o}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(bp(i),t,n+.5),e.restore()}var Une={kind:I.Custom,isMatch:e=>e.data?.kind===`aios-user`,draw:(e,t)=>{let{ctx:n,rect:r,theme:i}=e,{name:a,photo:o}=t.data;if(!a)return!0;let s=Pne(r.height),c=r.x+i.cellHorizontalPadding+s/2,l=r.y+r.height/2;return c+s/2>r.x+r.width-i.cellHorizontalPadding||Hne(n,c,l,s/2,a,o,i.fontFamily),!0}},Wne={kind:I.Custom,isMatch:e=>e.data?.kind===`aios-rating`,draw:(e,t)=>{let{ctx:n,rect:r,theme:i}=e,{value:a,max:o}=t.data,s=r.y+r.height/2,c=r.x+i.cellHorizontalPadding+13/2,l=r.x+r.width-i.cellHorizontalPadding;for(let e=0;el);e+=1)Bne(n,c,s,13/2,ee.trim()).filter(e=>e!==``),r=n.length?vp(e,n[0]):void 0;return{kind:I.Bubble,data:n,allowOverlay:!1,themeOverride:r?{bgBubble:r.bg,textBubble:r.fg}:void 0}}default:return{kind:I.Text,data:String(t??``),displayData:String(t??``),...i}}}ct();var Np={kind:I.Text,data:``,displayData:``,allowOverlay:!1},Kne=new Set;function qne(e,t,n,r,i){let a=e.collapsed?`▶`:`▼`,o=e.count.toLocaleString(),s=`${a} ${e.label} (${o})`,c=i?nne(a,e.label,o,r,i):s;return{kind:I.Text,data:s,displayData:t===0?c:``,allowOverlay:!1,span:[0,Math.max(0,n-1)],themeOverride:{bgCell:`#eef0f3`,bgCellMedium:`#eef0f3`,textDark:`#33333d`,baseFontStyle:tne}}}var Pp=[`#1b1b22`,`#33333d`,`#4d4d59`,`#33333d`];function Jne(e,t,n){let r=Math.max(22,Math.round((e??120)*.42));return{kind:I.Loading,allowOverlay:!1,skeletonWidth:r,skeletonWidthVariability:Math.min(20,Math.round(r*.35)),skeletonHeight:10,themeOverride:{textDark:Pp[(n+t)%Pp.length]},copyData:``}}function Yne(e,t){let n=t?e.aggs[t.key]:void 0;return{kind:I.Text,data:n??``,displayData:n??``,contentAlign:`right`,allowOverlay:!1,themeOverride:{bgCell:`#f6f7f9`,bgCellMedium:`#f6f7f9`,textDark:`#4a4a55`,baseFontStyle:`600 12px`}}}function Xne(e,t,n,r,i,a,o=0,s=null,c,l=Kne,u=0){return(0,L.useCallback)(([o,d])=>{let f=e[d];if(!f)return Np;let p=t[o],m=p?n.get(p.id):void 0;if(f.kind===`group-header`)return qne(f,o,t.length,s,c);if(f.kind===`group-footer`)return Yne(f,m);if(!m)return Np;let h=r[f.record.pid]?.[m.key]??f.record[m.key];return(h==null||h===``)&&l.has(m.key)?Jne(p?.width,d,u):Gne(m,h,i(m),a)},[e,t,n,r,i,a,o,s,c,l,u])}ct();function Zne(e,t,n){let[r,i]=(0,L.useState)(new Set),[a,o]=(0,L.useState)(void 0),s=(0,L.useRef)(null);return(0,L.useEffect)(()=>{o(e=>{if(!e)return e;let n=s.current,r=n==null?void 0:t.get(n);if(r!==void 0)return r===e.cell[1]?e:{cell:[e.cell[0],r],range:{x:e.cell[0],y:r,width:1,height:1},rangeStack:[]}})},[e,t]),{gridSelection:(0,L.useMemo)(()=>{let i=st.empty();for(let e of r){let n=t.get(e);n!==void 0&&(i=i.add(n))}return{current:a&&a.cell[1]{o(t.current);let n=t.current?e[t.current.cell[1]]:void 0;s.current=n&&n.kind===`data`?n.record.pid:null;let r=new Set;for(let n of t.rows){let t=e[n];t&&t.kind===`data`&&r.add(t.record.pid)}i(r)},[e]),selectPids:(0,L.useCallback)((e,t)=>{i(n=>{let r=t===`add`?new Set(n):new Set;for(let t of e)r.add(t);return r})},[]),togglePid:(0,L.useCallback)(e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),setActiveCell:(0,L.useCallback)((t,n)=>{let r=e[n];s.current=r&&r.kind===`data`?r.record.pid:null,o({cell:[t,n],range:{x:t,y:n,width:1,height:1},rangeStack:[]})},[e]),clearSelection:(0,L.useCallback)(()=>{i(new Set),o(void 0),s.current=null},[])}}var Fp=[{key:`filters`,label:`Filter conditions`,blurb:`Which records the view shows, and how the conditions combine.`},{key:`sorts`,label:`Sorts`,blurb:`The order records are listed in.`},{key:`groupBy`,label:`Groups`,blurb:`The field records are bucketed by.`},{key:`visible`,label:`Hidden fields`,blurb:`Which columns are shown.`},{key:`order`,label:`Field order`,blurb:`Left-to-right column order.`},{key:`rowHeightMode`,label:`Row height`,blurb:`Short, medium or tall rows.`}],Ip=Fp.map(e=>e.key);function Qne(e){return typeof e==`string`&&Ip.includes(e)}function Lp(e){return JSON.parse(JSON.stringify(e))}function $ne(e,t,n){let r={};if(!e)return r;let i=new Set;for(let e of t)Qne(e)&&i.add(e);if(i.size===0)return r;if(i.has(`filters`)&&(r.filters=Lp(Array.isArray(e.filters)?e.filters:[]),r.filterConj=e.filterConj),i.has(`sorts`)&&(r.sorts=Lp(Array.isArray(e.sorts)?e.sorts:[])),i.has(`groupBy`)&&(r.groupBy=e.groupBy??null),i.has(`visible`)){let t=Lp(Array.isArray(e.visible)?e.visible:[]);r.visible=n&&!t.includes(n)?[n,...t]:t}return i.has(`order`)&&(r.order=Lp(Array.isArray(e.order)?e.order:[])),i.has(`rowHeightMode`)&&e.rowHeightMode&&(r.rowHeightMode=e.rowHeightMode),r}var ere=s((e=>{var t=f(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),Rp=s(((e,t)=>{t.exports=ere()})),zp=g(),B=Rp(),Bp=(0,L.createContext)(null),Vp=[`[data-overlay-autofocus]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[href]`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function Hp({children:e}){let t=(0,L.useRef)([]),n=(0,L.useMemo)(()=>({register:e=>(t.current=[...t.current.filter(t=>t!==e),e],()=>{t.current=t.current.filter(t=>t!==e)}),isTop:e=>t.current.at(-1)===e}),[]);return(0,B.jsx)(Bp.Provider,{value:n,children:e})}function tre(e){if(`getBoundingClientRect`in e){let t=e.getBoundingClientRect();return{left:t.left,top:t.top,right:t.right,bottom:t.bottom,width:t.width,height:t.height}}return e}function nre(e,t){return e.left===t.left&&e.top===t.top&&e.maxWidth===t.maxWidth&&e.maxHeight===t.maxHeight&&e.visibility===t.visibility}function Up({panelRef:e,onDismiss:t,dismissOnOutside:n=!0,initialFocus:r=`first`,restoreFocus:i=!0,trapFocus:a=!1,outsideElements:o=[]}){let s=(0,L.useId)(),c=(0,L.useContext)(Bp),l=(0,L.useRef)(t),u=(0,L.useRef)(o);l.current=t,u.current=o,(0,L.useEffect)(()=>c?.register(s),[s,c]),(0,L.useEffect)(()=>{let t=t=>{if(!n||c&&!c.isTop(s))return;let r=t.target;!r||e.current?.contains(r)||u.current.some(e=>e?.contains(r))||(document.activeElement instanceof HTMLElement&&e.current?.contains(document.activeElement)&&document.activeElement.blur(),l.current())},r=t=>{if(c&&!c.isTop(s))return;if(t.key===`Escape`){t.preventDefault(),t.stopPropagation(),document.activeElement instanceof HTMLElement&&e.current?.contains(document.activeElement)&&document.activeElement.blur(),l.current();return}if(t.key!==`Tab`||!a)return;let n=Array.from(e.current?.querySelectorAll(Vp)??[]).filter(e=>e.getClientRects().length>0);if(!n.length){t.preventDefault(),e.current?.focus();return}let r=n[0],i=n.at(-1),o=document.activeElement;t.shiftKey&&(o===r||!e.current?.contains(o))?(t.preventDefault(),i.focus()):!t.shiftKey&&o===i&&(t.preventDefault(),r.focus())};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,r,!0)}},[n,s,e,c,a]),(0,L.useLayoutEffect)(()=>{let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=window.requestAnimationFrame(()=>{if(r===`none`)return;let t=r===`first`?Vp:r;(e.current?.querySelector(t))?.focus({preventScroll:!0})});return()=>{window.cancelAnimationFrame(n),i&&t?.isConnected&&t.focus({preventScroll:!0})}},[r,e,i])}function Wp({children:e}){return(0,zp.createPortal)(e,document.body)}function Gp({anchor:e,className:t,children:n,onDismiss:r,placement:i=`bottom-start`,role:a,ariaLabel:o,id:s,initialFocus:c=`first`,restoreFocus:l=!0,dismissOnOutside:u=!0,onKeyDown:d,dataKind:f}){let p=(0,L.useRef)(null),[m,h]=(0,L.useState)({position:`fixed`,left:0,top:0,visibility:`hidden`}),g=`getBoundingClientRect`in e?e:null;Up({panelRef:p,onDismiss:r,dismissOnOutside:u,initialFocus:c,restoreFocus:l,outsideElements:[g]});let _=(0,L.useCallback)(()=>{let t=p.current;if(!t)return;let n=tre(e),r=window.visualViewport,a=r?.offsetLeft??0,o=r?.offsetTop??0,s=r?.width??window.innerWidth,c=r?.height??window.innerHeight,l=t.getBoundingClientRect(),u=cne({placement:i,target:n,panel:{width:Math.max(l.width,t.scrollWidth),height:Math.max(l.height,t.scrollHeight)},viewport:{left:a,top:o,width:s,height:c}}),d={position:`fixed`,left:u.left,top:u.top,maxWidth:u.maxWidth,maxHeight:u.maxHeight,visibility:`visible`};h(e=>nre(e,d)?e:d)},[e,i]);return(0,L.useLayoutEffect)(()=>{_();let e=window.requestAnimationFrame(_),t=new ResizeObserver(_);return p.current&&t.observe(p.current),g&&t.observe(g),window.addEventListener(`resize`,_),window.addEventListener(`scroll`,_,!0),window.visualViewport?.addEventListener(`resize`,_),window.visualViewport?.addEventListener(`scroll`,_),()=>{window.cancelAnimationFrame(e),t.disconnect(),window.removeEventListener(`resize`,_),window.removeEventListener(`scroll`,_,!0),window.visualViewport?.removeEventListener(`resize`,_),window.visualViewport?.removeEventListener(`scroll`,_)}},[g,_]),(0,B.jsx)(Wp,{children:(0,B.jsx)(`div`,{ref:p,id:s,className:t,style:m,role:a,"aria-label":o,"data-overlay-kind":f,onKeyDown:d,children:n})})}function Kp({shapes:e}){return(0,B.jsx)(B.Fragment,{children:e.map((e,t)=>e.fill?(0,B.jsx)(`path`,{d:e.d,fill:`currentColor`},t):(0,B.jsx)(`path`,{d:e.d,fill:`none`,stroke:`currentColor`,strokeWidth:1.35,strokeLinecap:`round`,strokeLinejoin:`round`},t))})}function qp({type:e,size:t=14,title:n}){return(0,B.jsxs)(`svg`,{className:`cg-type-icon`,width:t,height:t,viewBox:`0 0 16 16`,"aria-hidden":!n||void 0,role:n?`img`:void 0,"aria-label":n,children:[n&&(0,B.jsx)(`title`,{children:n}),(0,B.jsx)(Kp,{shapes:Lf[e===`measure`?`currency`:e]})]})}function Jp({mode:e,size:t=14}){return(0,B.jsx)(`svg`,{className:`cg-mode-icon`,width:t,height:t,viewBox:`0 0 16 16`,"aria-hidden":!0,children:(0,B.jsx)(Kp,{shapes:Rf[e]})})}function Yp({mode:e,tone:t,size:n=15}){let r=zf[t];return(0,B.jsx)(`svg`,{className:`cg-mode-icon cg-tone-icon`,width:n,height:n,viewBox:`0 0 16 16`,"aria-hidden":!0,children:Rf[e].map((e,t)=>e.fill?(0,B.jsx)(`path`,{d:e.d,fill:r.stroke},t):(0,B.jsx)(`path`,{d:e.d,fill:`none`,stroke:r.stroke,strokeWidth:1.35,strokeLinecap:`round`,strokeLinejoin:`round`},t))})}function rre({kind:e,size:t=15}){let n=zf[Ute[e]];return(0,B.jsx)(`svg`,{className:`cg-mode-icon cg-tone-icon`,width:t,height:t,viewBox:`0 0 16 16`,"aria-hidden":!0,children:Hte[e].map((t,r)=>(0,B.jsx)(`path`,{d:t.d,fill:r===0&&(e===`area`||e===`donut`||e===`kpi`||e===`table`)?n.fill:`none`,stroke:n.stroke,strokeWidth:1.35,strokeLinecap:`round`,strokeLinejoin:`round`},r))})}var ire={width:16,height:16,viewBox:`0 0 16 16`,fill:`none`},Xp={stroke:`currentColor`,strokeWidth:1.3,strokeLinecap:`round`,strokeLinejoin:`round`},are={duplicate:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`rect`,{x:`5.5`,y:`5.5`,width:`8`,height:`8`,rx:`1.5`,...Xp}),(0,B.jsx)(`path`,{d:`M10.5 2.5h-7a1 1 0 0 0-1 1v7`,...Xp})]}),insertLeft:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`line`,{x1:`3`,y1:`2.5`,x2:`3`,y2:`13.5`,...Xp}),(0,B.jsx)(`path`,{d:`M13.5 8H6.5M9.2 5.3 6.5 8l2.7 2.7`,...Xp})]}),insertRight:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`line`,{x1:`13`,y1:`2.5`,x2:`13`,y2:`13.5`,...Xp}),(0,B.jsx)(`path`,{d:`M2.5 8h7M6.8 5.3 9.5 8l-2.7 2.7`,...Xp})]}),addEnd:(0,B.jsx)(`path`,{d:`M8 3v10M3 8h10`,...Xp}),rename:(0,B.jsx)(`path`,{d:`m9.8 3.2 3 3L6.2 12.8l-3.6.6.6-3.6 6.6-6.6Z`,...Xp}),description:(0,B.jsx)(`path`,{d:`M3 4.5h10M3 8h10M3 11.5h6`,...Xp}),permissions:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`rect`,{x:`3.5`,y:`7`,width:`9`,height:`6`,rx:`1`,...Xp}),(0,B.jsx)(`path`,{d:`M5.5 7V5.2a2.5 2.5 0 0 1 5 0V7`,...Xp})]}),unlock:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`rect`,{x:`3.5`,y:`7`,width:`9`,height:`6`,rx:`1`,...Xp}),(0,B.jsx)(`path`,{d:`M5.5 7V5.2a2.5 2.5 0 0 1 5 0`,...Xp})]}),format:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M3 5h5.5M12.5 5H13M3 11h1M7 11h6`,...Xp}),(0,B.jsx)(`circle`,{cx:`10.5`,cy:`5`,r:`1.6`,...Xp}),(0,B.jsx)(`circle`,{cx:`4.9`,cy:`11`,r:`1.6`,...Xp})]}),swap:(0,B.jsx)(`path`,{d:`M3.5 6h9M10.2 3.7 12.5 6l-2.3 2.3M12.5 10.5h-9M5.8 8.2 3.5 10.5l2.3 2.3`,...Xp}),sortAsc:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M4.5 3v10M4.5 13l-2-2M4.5 13l2-2`,...Xp}),(0,B.jsx)(`path`,{d:`M8.5 4.5h2M8.5 8h3.5M8.5 11.5h5`,...Xp})]}),sortDesc:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M4.5 3v10M4.5 13l-2-2M4.5 13l2-2`,...Xp}),(0,B.jsx)(`path`,{d:`M8.5 4.5h5M8.5 8h3.5M8.5 11.5h2`,...Xp})]}),off:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`circle`,{cx:`8`,cy:`8`,r:`5.5`,...Xp}),(0,B.jsx)(`line`,{x1:`4.4`,y1:`11.6`,x2:`11.6`,y2:`4.4`,...Xp})]}),filter:(0,B.jsx)(`path`,{d:`M2.5 3.5h11L9.5 8.5v3.8L6.5 14V8.5L2.5 3.5Z`,...Xp}),group:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`line`,{x1:`2.5`,y1:`4`,x2:`13.5`,y2:`4`,...Xp}),(0,B.jsx)(`line`,{x1:`5.5`,y1:`8`,x2:`13.5`,y2:`8`,...Xp}),(0,B.jsx)(`line`,{x1:`5.5`,y1:`12`,x2:`13.5`,y2:`12`,...Xp})]}),pin:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M6 2.5h4l-.5 4L12 9v1H4V9l2.5-2.5L6 2.5Z`,...Xp}),(0,B.jsx)(`line`,{x1:`8`,y1:`10`,x2:`8`,y2:`13.5`,...Xp})]}),unpin:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M6 2.5h4l-.5 4L12 9v1H4V9l2.5-2.5L6 2.5Z`,...Xp}),(0,B.jsx)(`line`,{x1:`8`,y1:`10`,x2:`8`,y2:`13.5`,...Xp}),(0,B.jsx)(`line`,{x1:`3`,y1:`13`,x2:`13`,y2:`3`,...Xp})]}),hide:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M2.5 8s2-3.5 5.5-3.5S13.5 8 13.5 8s-2 3.5-5.5 3.5S2.5 8 2.5 8Z`,...Xp}),(0,B.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.5`,...Xp}),(0,B.jsx)(`line`,{x1:`3.5`,y1:`12.5`,x2:`12.5`,y2:`3.5`,...Xp})]}),trash:(0,B.jsx)(`path`,{d:`M3.5 4.5h9M6.5 4.5V3h3v1.5M5 4.5l.6 8.5h4.8l.6-8.5`,...Xp}),download:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M8 2.5v7M5.3 6.8 8 9.5l2.7-2.7`,...Xp}),(0,B.jsx)(`path`,{d:`M3 11v1.5a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V11`,...Xp})]}),cohortAdd:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`path`,{d:`M2.5 4h7M2.5 7.5h5M2.5 11h4`,...Xp}),(0,B.jsx)(`path`,{d:`M11.5 8.5v5M9 11h5`,...Xp})]})};function ore({name:e}){return(0,B.jsx)(`svg`,{...ire,"aria-hidden":!0,children:are[e]})}function Zp({icon:e,text:t}){return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`cg-mi-ic`,"aria-hidden":!0,children:typeof e==`string`?(0,B.jsx)(ore,{name:e}):e}),(0,B.jsx)(`span`,{className:`cg-mi-text`,children:t})]})}function Qp({size:e=14}){return(0,B.jsxs)(`svg`,{className:`cg-eyeoff-icon`,width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:[(0,B.jsx)(`path`,{d:`M2.5 8s2-3.5 5.5-3.5S13.5 8 13.5 8s-2 3.5-5.5 3.5S2.5 8 2.5 8Z`,stroke:`currentColor`,strokeWidth:1.4,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,B.jsx)(`path`,{d:`M9.6 8a1.6 1.6 0 1 1-3.2 0 1.6 1.6 0 0 1 3.2 0Z`,stroke:`currentColor`,strokeWidth:1.4,strokeLinejoin:`round`}),(0,B.jsx)(`path`,{d:`M3.3 12.7 12.7 3.3`,stroke:`currentColor`,strokeWidth:1.4,strokeLinecap:`round`})]})}function $p({size:e=11}){return(0,B.jsxs)(`svg`,{className:`cg-lock-mark`,width:e,height:e,viewBox:`0 0 16 16`,"aria-hidden":!0,children:[(0,B.jsx)(`path`,{d:`M4.2 7.2h7.6v5.6H4.2z`,fill:`none`,stroke:`currentColor`,strokeWidth:1.35,strokeLinejoin:`round`}),(0,B.jsx)(`path`,{d:`M5.9 7.2V5.5a2.1 2.1 0 0 1 4.2 0v1.7`,fill:`none`,stroke:`currentColor`,strokeWidth:1.35,strokeLinecap:`round`})]})}function em({icon:e,size:t=14}){let n=e?.shape??`folder`,r=zf[e?.tone??`neutral`];return(0,B.jsx)(`svg`,{className:`cg-folder-mark`,width:t,height:t,viewBox:`0 0 16 16`,"aria-hidden":!0,children:Wte[n].map((e,t)=>(0,B.jsx)(`path`,{d:e.d,fill:`none`,stroke:r.stroke,strokeWidth:1.35,strokeLinecap:`round`,strokeLinejoin:`round`},t))})}function tm({item:e}){return e.icon?(0,B.jsx)(B.Fragment,{children:e.icon}):e.type?(0,B.jsx)(qp,{type:e.type,title:e.type===`measure`?`Metric`:Vf[e.type]}):(0,B.jsx)(`span`,{className:`cg-fsel-nomark`,"aria-hidden":!0})}function sre(){return(0,B.jsx)(`svg`,{className:`cg-fsel-caret`,width:`10`,height:`10`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M4 6l4 4 4-4`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`})})}function cre(){return(0,B.jsx)(`svg`,{className:`cg-type-check`,width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`m3.5 8.5 3 3 6-6.5`,stroke:`currentColor`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`})})}var nm=8;function rm({fields:e,value:t,onChange:n,placeholder:r=`Choose a field…`,allow:i,ariaLabel:a,className:o,disabled:s,title:c,keepOpen:l,overlayAutofocus:u}){let[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(``),h=(0,L.useRef)(null),g=(0,L.useRef)(null),_=(0,L.useMemo)(()=>i?e.filter(e=>e.type!=null&&i.includes(e.type)):e,[e,i]),v=t!=null,y=v?e.find(e=>e.key===t):void 0,b=p.trim().toLowerCase(),x=b?_.filter(e=>e.label.toLowerCase().includes(b)):_,S=()=>{f(!1),m(``)},C=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`&&e.key!==`Home`&&e.key!==`End`)return;let t=Array.from(g.current?.querySelectorAll(`button.cg-type-row`)??[]).filter(e=>!e.disabled);if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);if(e.key===`Home`)return t[0].focus();if(e.key===`End`)return t[t.length-1].focus();let r=e.key===`ArrowDown`?1:-1;t[n<0?r===1?0:t.length-1:(n+r+t.length)%t.length].focus()},w;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{ref:h,type:`button`,disabled:s,className:`cg-select cg-fsel`+(y?``:v&&t!==``?` is-missing`:` is-empty`)+(o?` ${o}`:``),"aria-label":a,"aria-haspopup":`listbox`,"aria-expanded":d,"data-overlay-autofocus":u?!0:void 0,onClick:()=>f(e=>!e),children:[y?(0,B.jsx)(tm,{item:y}):(0,B.jsx)(`span`,{className:`cg-fsel-nomark`,"aria-hidden":!0}),(0,B.jsx)(`span`,{className:`cg-fsel-label`,children:y?.label??(v&&t!==``?t:r)}),(0,B.jsx)(sre,{})]}),d&&h.current&&(0,B.jsx)(Gp,{anchor:h.current,className:`cg-pop cg-fsel-pop`,onDismiss:S,role:`dialog`,ariaLabel:a??c??`Choose a field`,initialFocus:_.length>=nm?`.cg-fsel-search input`:`button.cg-type-row`,dataKind:`field-select`,children:(0,B.jsxs)(`div`,{className:`cg-fsel-body`,onKeyDown:C,children:[c&&(0,B.jsx)(`div`,{className:`cg-pop-title`,children:c}),_.length>=nm&&(0,B.jsxs)(`div`,{className:`cg-type-search cg-fsel-search`,children:[(0,B.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:[(0,B.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.4`,stroke:`currentColor`,strokeWidth:`1.35`}),(0,B.jsx)(`path`,{d:`m10.4 10.4 3.1 3.1`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`})]}),(0,B.jsx)(`input`,{type:`text`,value:p,placeholder:`Find a field…`,"aria-label":`Find a field`,onChange:e=>m(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`cg-type-list`,role:`listbox`,ref:g,"aria-label":a??c??`Fields`,children:[x.map(e=>{let r=e.group&&e.group!==w?e.group:null;return w=e.group,(0,B.jsxs)(L.Fragment,{children:[r&&(0,B.jsx)(`div`,{className:`cg-fsel-group`,role:`presentation`,children:r}),(0,B.jsxs)(`button`,{type:`button`,role:`option`,disabled:e.disabled,"aria-selected":e.key===t,className:`cg-type-row`+(e.key===t?` is-on`:``),onClick:()=>{n(e.key),l?m(``):S()},children:[(0,B.jsx)(tm,{item:e}),(0,B.jsxs)(`span`,{className:`cg-type-label`,children:[e.label,e.hint&&(0,B.jsx)(`span`,{className:`cg-fsel-hint`,children:e.hint})]}),e.key===t&&(0,B.jsx)(cre,{})]})]},e.key)}),x.length===0&&(0,B.jsx)(`div`,{className:`cg-pop-note`,children:_.length===0?`No field to choose here.`:`No field matches.`})]})]})})]})}function im(e,t){let n=e=>e.toLocaleString();if(!t?.windowed)return`${n(e)} ${e===1?`record`:`records`}`;let r=t.matched===1?`record`:`records`,i=t.matched=t.matched?`${n(t.matched)} ${r}${i}`:`showing ${n(t.shown)} of ${n(t.matched)} ${r}${i}`}function am(e){if(!e?.partial)return null;let t=typeof e.loaded==`number`&&Number.isFinite(e.loaded)&&e.loaded>=0?Math.floor(e.loaded):0,n=typeof e.total==`number`&&Number.isFinite(e.total)&&e.total>0?Math.floor(e.total).toLocaleString():`…`;return`${t.toLocaleString()} of ${n}`}function lre(e,t){if(!t?.windowed)return im(e,t);let n=e=>e.toLocaleString();return t.shown>=t.matched?`${n(t.matched)} ${t.matched===1?`record`:`records`}`:`showing ${n(t.shown)} of ${n(t.matched)}`}function om({window:e,onWindow:t,kinds:n=Nu}){let r=e.kind;return(0,B.jsxs)(`span`,{className:`cg-cond-window`,children:[(0,B.jsx)(`select`,{className:`cg-select cg-cond-win-kind`,value:r,"aria-label":`Date window`,onChange:n=>{let r=n.target.value;Pu.has(r)?t({kind:r,n:e.n??30}):t(r===`custom`?{kind:r,from:e.from??``,to:e.to??``}:{kind:r})},children:(n.includes(r)?n:[...n,r]).map(e=>(0,B.jsx)(`option`,{value:e,children:Pu.has(e)?Fu[e].replace(`{n}`,`N`):Fu[e]},e))}),Pu.has(r)&&(0,B.jsx)(`input`,{className:`cg-input cg-cond-win-n`,type:`number`,min:1,max:3650,"aria-label":`Number of days`,value:e.n??``,onChange:n=>t({...e,n:n.target.value===``?void 0:Number(n.target.value)})}),r===`custom`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{className:`cg-input cg-cond-win-date`,type:`date`,"aria-label":`Window start`,value:e.from??``,onChange:n=>t({...e,from:n.target.value})}),(0,B.jsx)(`span`,{className:`cg-cond-and`,children:`and`}),(0,B.jsx)(`input`,{className:`cg-input cg-cond-win-date`,type:`date`,"aria-label":`Window end`,value:e.to??``,onChange:n=>t({...e,to:n.target.value})})]})]})}var sm=cd,cm=ld;function lm(e){return e===`checkbox`?[`isNotEmpty`,`isEmpty`]:sm(e)?[`gte`,`gt`,`lte`,`lt`,`eq`,`neq`,`between`,`isEmpty`,`isNotEmpty`]:cm(e)?[`eq`,`within`,`lt`,`gt`,`lte`,`gte`,`neq`,`isEmpty`,`isNotEmpty`]:e===`status`||e===`select`||e===`user`?[`eq`,`neq`,`isEmpty`,`isNotEmpty`]:[`contains`,`doesNotContain`,`eq`,`neq`,`isEmpty`,`isNotEmpty`]}var ure={topN:`top N`,bottomN:`bottom N`,inTopPct:`top N%`,inBottomPct:`bottom N%`,aboveAvg:`above average`,belowAvg:`below average`,inQuartile:`in quartile`,inDecile:`in decile`};function dre(e){switch(e){case`topN`:case`bottomN`:case`inTopPct`:case`inBottomPct`:case`inDecile`:return`10`;case`inQuartile`:return`4`;default:return``}}function um(e){for(let t of e??[]){if(Sd(t)){if(um(t.children))return!0;continue}if(dd(t.op)&&!xd(t))return!0}return!1}function dm(e,t){if(dd(e))return ure[e]??e;if(t===`checkbox`){if(e===`isNotEmpty`)return`is checked`;if(e===`isEmpty`)return`is unchecked`}if(e===`isEmpty`)return`is empty`;if(e===`isNotEmpty`)return`is not empty`;if(cm(t))switch(e){case`eq`:return`is`;case`neq`:return`is not`;case`within`:return`is within`;case`lt`:return`is before`;case`lte`:return`is on or before`;case`gt`:return`is after`;case`gte`:return`is on or after`;case`between`:return`is between`}if(sm(t))switch(e){case`gte`:return`≥`;case`gt`:return`>`;case`lte`:return`≤`;case`lt`:return`<`;case`eq`:return`=`;case`neq`:return`≠`;case`between`:return`is between`;default:return e}if(t===`multiselect`)switch(e){case`contains`:return`has`;case`doesNotContain`:return`does not have`;case`eq`:return`is exactly`;case`neq`:return`is not exactly`;default:return e}switch(e){case`contains`:return`contains`;case`doesNotContain`:return`does not contain`;case`eq`:return`is`;case`neq`:return`is not`;default:return e}}function fre(e,t){return t&&!e.includes(t)?[...e,t]:[...e]}function pre(e){return e===`or`?`Any of the following are true…`:`All of the following are true…`}var fm=[...Ree],pm=[...zee],mm=[...hd];function mre(e){switch(gd(e)){case`allOf`:return`is all of`;case`noneOf`:return`is none of`;default:return`is any of`}}var hm=`measure`,gm={kind:`ltm`},_m={kind:`past_month`},hre=[`last_n_days`,`past_week`,`past_month`,`past_year`,`this_week`,`this_month`,`this_year`,`custom`];function gre(e,t,n,r,i){let a=e.map(e=>({key:e.key,label:e.label,type:e.type})),o=new Set(a.map(e=>e.key));if(!t||o.has(t)||r.has(t)||t===`__cohort__`&&i)return a;let s=n.get(t);return a.push({key:t,label:s?s.label:t,type:s?.type}),a}var vm=0;function ym(){return vm+=1,`r${Date.now().toString(36)}${vm.toString(36)}`}function bm(e){let t=e[0];return t?{colId:t.key,op:lm(t.type)[0],value:``}:null}function xm(e){let t=0;for(let n of e)t+=Sd(n)?xm(n.children):1;return t}function _re({rule:e,onPatch:t}){let n=e.dateMode??`exact`;return(0,B.jsxs)(`span`,{className:`cg-cond-anchor`,children:[(0,B.jsx)(`select`,{className:`cg-select cg-cond-anchor-mode`,value:n,"aria-label":`Date`,onChange:e=>{let n=e.target.value;t({dateMode:n,value:``})},children:Iu.map(e=>(0,B.jsx)(`option`,{value:e,children:e===`n_days_ago`?Lu[e].replace(`{n}`,`N`):Lu[e]},e))}),n===`n_days_ago`&&(0,B.jsx)(`input`,{className:`cg-input cg-cond-win-n`,type:`number`,min:0,max:3650,"aria-label":`Number of days ago`,value:e.value,onChange:e=>t({value:e.target.value})}),n===`exact`&&(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:`date`,"aria-label":`Date`,value:e.value,onChange:e=>t({value:e.target.value})})]})}function vre({rule:e,options:t,isMeasure:n,onPatch:r}){let i=e.rhs,a=yd(i)??``;return(0,B.jsxs)(`span`,{className:`cg-cond-rhs`,children:[(0,B.jsx)(rm,{className:`cg-cond-field`,ariaLabel:`Compare with field`,placeholder:`Select a field…`,value:a||void 0,fields:t,onChange:e=>{r({rhs:n?{kind:`measure`,colId:e,window:i?.kind===`measure`&&i.window||gm}:{kind:`field`,colId:e}})}}),n&&a!==``&&(0,B.jsx)(om,{window:i?.kind===`measure`&&i.window||gm,onWindow:e=>r({rhs:{kind:`measure`,colId:a,window:e}})})]})}function yre({rule:e,type:t,statusOptions:n,onValue:r,onValue2:i}){if(e.op===`between`){let n=t===`date`||t===`created_time`?`date`:`number`;return(0,B.jsxs)(`span`,{className:`cg-cond-between`,children:[(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:n,value:e.value,onChange:e=>r(e.target.value)}),(0,B.jsx)(`span`,{className:`cg-cond-and`,children:`and`}),(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:n,value:e.value2??``,onChange:e=>i(e.target.value)})]})}return t===`status`||t===`select`||t===`user`||t===`multiselect`?(0,B.jsxs)(`select`,{className:`cg-select cg-cond-val`,value:e.value,onChange:e=>r(e.target.value),children:[(0,B.jsx)(`option`,{value:``,children:`Select…`}),n.map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]}):(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:t===`date`||t===`created_time`?`date`:sm(t)?`number`:`text`,placeholder:`Value`,value:e.value,onChange:e=>r(e.target.value)})}function bre({rule:e,onValue:t}){let n=e.op===`inQuartile`?4:e.op===`inDecile`?10:0;if(n)return(0,B.jsx)(`select`,{className:`cg-select cg-cond-val`,value:e.value,"aria-label":e.op===`inQuartile`?`Quartile`:`Decile`,onChange:e=>t(e.target.value),children:Array.from({length:n},(e,t)=>String(t+1)).map(e=>(0,B.jsx)(`option`,{value:e,children:e===`1`?`${e} (lowest)`:e===String(n)?`${e} (highest)`:e},e))});let r=e.op===`inTopPct`||e.op===`inBottomPct`;return(0,B.jsx)(`input`,{className:`cg-input cg-cond-val`,type:`number`,min:1,max:r?100:1e4,step:1,placeholder:`10`,"aria-label":r?`Percent`:`How many`,value:e.value,onChange:e=>t(e.target.value)})}function xre({rule:e,lists:t,onPatch:n}){let r=_d(e.value),i=new Map(t.map(e=>[e.id,e.name])),a=t.filter(e=>!r.includes(e.id)),o=a.length>0&&r.length<20,s=e=>n({value:e.join(`,`)});return(0,B.jsxs)(`span`,{className:`cg-cond-cohorts`,children:[r.map(e=>(0,B.jsxs)(`span`,{className:`cg-chip`+(i.has(e)?``:` cg-chip--gone`),children:[(0,B.jsx)(`span`,{className:`cg-chip-text`,children:i.get(e)??`(deleted list)`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-chip-x`,"aria-label":`Remove ${i.get(e)??e}`,onClick:()=>s(r.filter(t=>t!==e)),children:`×`})]},e)),(0,B.jsxs)(`select`,{className:`cg-select cg-cond-val cg-cond-cohort-add`,value:``,"aria-label":`Cohort`,disabled:!o,onChange:e=>e.target.value&&s([...r,e.target.value]),children:[(0,B.jsx)(`option`,{value:``,children:o?r.length?`Add a cohort…`:`Select a cohort…`:`all added`}),a.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})}function Sre({index:e,conj:t,onConj:n}){return e===0?(0,B.jsx)(`span`,{className:`cg-cond-prefix`,children:`Where`}):e===1?(0,B.jsxs)(`select`,{className:`cg-select cg-cond-conj`,value:t,"aria-label":`Combine conditions with`,onChange:e=>n(e.target.value),children:[(0,B.jsx)(`option`,{value:`and`,children:`and`}),(0,B.jsx)(`option`,{value:`or`,children:`or`})]}):(0,B.jsx)(`span`,{className:`cg-cond-prefix cg-cond-conj-echo`,children:t})}function Sm({nodes:e,conj:t,depth:n,ctx:r,onNodes:i,onConj:a}){let[o,s]=(0,L.useState)(null),c=(t,n)=>i(e.map((e,r)=>r===t?n:e)),l=t=>i(e.filter((e,n)=>n!==t)),u=()=>{let t=bm(r.fields);t&&i([...e,t])},d=()=>{let t=bm(r.fields);t&&i([...e,{conj:`or`,children:[t]}])},f=n<3;return(0,B.jsxs)(B.Fragment,{children:[e.map((e,i)=>(0,B.jsxs)(`div`,{className:`cg-cond-line`,children:[(0,B.jsx)(Sre,{index:i,conj:t,onConj:a}),Sd(e)?(0,B.jsx)(wre,{group:e,depth:n+1,ctx:r,onGroup:e=>c(i,e),onRemove:()=>l(i)}):(0,B.jsx)(Cre,{rule:e,ctx:r,onRule:e=>c(i,e),onRemove:()=>l(i)})]},i)),(0,B.jsxs)(`div`,{className:`cg-builder-add`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`+(o===`condition`?` is-on`:``),onClick:()=>{s(`condition`),u()},children:`+ Add condition`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`+(o===`group`?` is-on`:``),onClick:()=>{s(`group`),d()},disabled:!f,title:f?`Group conditions so they evaluate together`:`Condition groups can nest 3 levels deep`,children:`+ Add condition group`})]})]})}function Cre({rule:e,ctx:t,onRule:n,onRemove:r}){let{fields:i,fieldByKey:a,measures:o,measureByKey:s,lists:c,choicesFor:l}=t,u=xd(e),d=e.colId===pd,f=c.length>0,p=u?s.get(e.colId)?.type??`currency`:a.get(e.colId)?.type??`text`,m=t=>n({...e,...t}),h=t=>{if(t===`__cohort__`){n({colId:pd,op:mm[0],value:``});return}if(s.get(t)){n({id:e.id??ym(),colId:t,op:fm[0],value:``,value2:void 0,window:e.window??gm});return}n({colId:t,op:lm(a.get(t)?.type??`text`)[0],value:``,value2:void 0})},g=t=>{if(d)return m({op:t});if(dd(t))return n({...e,op:t,value:dre(t),value2:void 0,rhs:void 0,dateWindow:void 0});if(fd.has(t))return n({...e,op:t,value:``,value2:void 0,rhs:void 0});if(t===`within`)return n({...e,op:t,value:``,value2:void 0,rhs:void 0,dateWindow:e.dateWindow??_m});if(e.op===`within`)return n({...e,op:t,dateWindow:void 0,value:``});m({op:t})},_=u?o.map(e=>({key:e.key,label:e.label,type:hm})):i.filter(t=>t.key!==e.colId&&(sm(p)?sm(t.type):t.type===p)).map(e=>({key:e.key,label:e.label,type:e.type})),v=!d&&e.op!==`within`&&!fd.has(e.op)&&!dd(e.op)&&_.length>0&&(u||sm(p)||cm(p)),y=e.rhs?.kind===`stat`,b=e.rhs!=null&&!y,x=u?b||y?pm:fm:d?mm:lm(p),S=d?gd(e.op):e.op,C=fre(!u&&!d&&sm(p)?[...x,...Nee]:x,S),w=C.filter(e=>!dd(e)),T=C.filter(e=>dd(e));return(0,B.jsxs)(`span`,{className:`cg-cond-row`+(u?` is-measure`:``)+(d?` is-cohort`:``)+(e.rhs==null?``:` has-rhs`),children:[(0,B.jsx)(rm,{className:`cg-cond-field`,ariaLabel:`Field`,value:e.colId,onChange:h,fields:[...gre(i,e.colId,a,s,f),...o.map(e=>({key:e.key,label:e.label,type:hm})),...f?[{key:pd,label:`Cohort`,type:`multiselect`}]:[]]}),u&&(0,B.jsx)(om,{window:e.window??gm,onWindow:e=>m({window:e})}),(0,B.jsxs)(`select`,{className:`cg-select cg-cond-op`,value:S,"aria-label":`Condition`,onChange:e=>g(e.target.value),children:[w.map(e=>(0,B.jsx)(`option`,{value:e,children:d?mre(e):dm(e,p)},e)),T.length>0&&(0,B.jsx)(`optgroup`,{label:`Ranked`,children:T.map(e=>(0,B.jsx)(`option`,{value:e,children:dm(e,p)},e))})]}),v&&(0,B.jsxs)(`select`,{className:`cg-select cg-cond-mode`,value:y?`stat`:b?`field`:`value`,"aria-label":`Compare against`,onChange:t=>{let n=t.target.value;if(n===`stat`)return m({rhs:{kind:`stat`,stat:`median`},value:``,value2:void 0,op:pm.includes(e.op)?e.op:pm[1]});if(n===`field`)return m({rhs:u?{kind:`measure`,colId:``,window:gm}:{kind:`field`,colId:``},value:``,value2:void 0});m({rhs:void 0,value:``})},children:[(0,B.jsx)(`option`,{value:`value`,children:`a value`}),(0,B.jsx)(`option`,{value:`field`,children:`another field`}),u&&(0,B.jsx)(`option`,{value:`stat`,children:`a statistic`})]}),fd.has(e.op)?(0,B.jsx)(`span`,{className:`cg-cond-val cg-cond-noval`,"aria-hidden":!0}):y?(0,B.jsx)(`select`,{className:`cg-select cg-cond-val cg-cond-stat`,value:e.rhs?.kind===`stat`?e.rhs.stat:`median`,"aria-label":`Statistic`,onChange:e=>m({rhs:{kind:`stat`,stat:e.target.value}}),children:vd.map(e=>(0,B.jsx)(`option`,{value:e,children:Iee[e]},e))}):b?(0,B.jsx)(vre,{rule:e,options:_,isMeasure:u,onPatch:m}):d?(0,B.jsx)(xre,{rule:e,lists:c,onPatch:m}):dd(e.op)?(0,B.jsx)(bre,{rule:e,onValue:e=>m({value:e})}):e.op===`within`?(0,B.jsx)(om,{window:e.dateWindow??_m,onWindow:e=>m({dateWindow:e}),kinds:hre}):cm(p)?(0,B.jsx)(_re,{rule:e,onPatch:m}):(0,B.jsx)(yre,{rule:e,type:p,statusOptions:l(e.colId),onValue:e=>m({value:e}),onValue2:e=>m({value2:e})}),(0,B.jsx)(`button`,{type:`button`,className:`cg-cond-x`,"aria-label":`Remove condition`,onClick:r,children:`×`})]})}function wre({group:e,depth:t,ctx:n,onGroup:r,onRemove:i}){return(0,B.jsxs)(`span`,{className:`cg-cond-group`,"data-depth":t,children:[(0,B.jsxs)(`span`,{className:`cg-cond-group-head`,children:[(0,B.jsx)(`span`,{className:`cg-cond-group-sum`,children:e.children.length?pre(e.conj):`Add a condition to this group…`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-cond-x`,"aria-label":`Remove condition group`,onClick:i,children:`×`})]}),(0,B.jsx)(`span`,{className:`cg-cond-group-body`,children:(0,B.jsx)(Sm,{nodes:e.children,conj:e.conj,depth:t,ctx:n,onNodes:t=>r({...e,children:t}),onConj:t=>r({...e,conj:t})})})]})}function Cm({fields:e,filters:t,onChange:n,cohorts:r=[],measures:i=[],userOptions:a,statusValues:o,cohortLock:s,footerExtra:c}){let l=Cd(t),u=wd(t),d=(0,L.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.key,n);return t},[e]),f=(0,L.useMemo)(()=>hee(e),[e]),p=(0,L.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.key,t);return e},[i]),m=(0,L.useCallback)(e=>{let t=o?.[e];if(t)return t;let n=d.get(e);return n?n.type===`user`?a??[]:td(n):[]},[o,d,a]),h=(0,L.useMemo)(()=>({fields:f,fieldByKey:d,measures:i,measureByKey:p,lists:r,choicesFor:m}),[f,d,i,p,r,m]);return(0,B.jsxs)(`div`,{className:`cg-pop-body cg-builder`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Filter`}),s&&(0,B.jsx)(`div`,{className:`cg-flt-lockchip`,children:s.name?`Customer list locked to ${s.name}`+(typeof s.count==`number`?` · ${s.count.toLocaleString()} ${s.count===1?`customer`:`customers`}`:``):`Customer list locked to a set you cannot see`}),l.length===0?(0,B.jsx)(`div`,{className:`cg-builder-empty`,children:`No conditions. Add one to narrow the list.`}):(0,B.jsx)(`div`,{className:`cg-builder-caption`,children:`In this view, show records`}),(0,B.jsx)(Sm,{nodes:l,conj:u,depth:1,ctx:h,onNodes:e=>n({conj:u,nodes:e}),onConj:e=>n({conj:e,nodes:l})}),um(l)&&(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`Ranked among the records your other conditions keep — so “top 10” inside a filtered view means the top 10 of that view. Records with no value are not ranked at all. Quartiles and deciles are equal-size slices BY RANK, not by value.`}),(l.length>0||c)&&(0,B.jsxs)(`div`,{className:`cg-pop-footer cg-builder-footer`,children:[l.length>0&&(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>n({conj:u,nodes:[]}),children:`Clear all`}),c]})]})}function wm({fields:e,hidden:t,onToggle:n,onHideAll:r,onShowAll:i,lockedKey:a,onFieldOrder:o,deletableKeys:s,onDeleteField:c}){let[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),_=l.trim().toLowerCase(),v=_?e.filter(e=>e.label.toLowerCase().includes(_)):e,y=!!o&&_===``,b=(t,n)=>{if(t===n||t===a||n===a)return null;let r=e.map(e=>e.key),i=r.indexOf(t),o=r.indexOf(n);if(i<0||o<0)return null;let s=r.slice();return s.splice(i,1),s.splice(o,0,t),s},x=(t,n)=>{if(!y)return;let r=e.map(e=>e.key),i=r[r.indexOf(t)+n];if(i===void 0)return;let a=b(t,i);a&&o(a)};return(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Hide fields`}),(0,B.jsx)(`input`,{type:`text`,className:`cg-input cg-fields-search`,placeholder:`Find a field…`,"aria-label":`Find a field`,value:l,onChange:e=>u(e.target.value)}),(0,B.jsxs)(`div`,{className:`cg-pop-list`,children:[v.map(e=>{let r=a!==void 0&&e.key===a,i=!t.has(e.key),l=!!c&&!!s?.has(e.key),u=d===e.key;return(0,B.jsxs)(`label`,{className:`cg-check-row`+(i?``:` is-off`)+(r?` is-locked`:``)+(p===e.key?` is-dragging`:``)+(h===e.key&&p!==null&&p!==e.key?` is-drop-target`:``),title:r?`Always visible`:void 0,onDragOver:y&&p&&p!==e.key?t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,h!==e.key&&g(e.key)}:void 0,onDrop:y&&p?t=>{t.preventDefault(),t.stopPropagation();let n=b(p,e.key);m(null),g(null),n&&o(n)}:void 0,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-field-grip`,draggable:y&&!r,"aria-label":r?`${e.label} is always first`:y?`Reorder ${e.label} — drag, or use the arrow keys`:`Reorder ${e.label} (clear the search first)`,title:y&&!r?`Drag to reorder, or use the arrow keys`:r?`This column is always first`:`Clear the search to reorder`,onDragStart:t=>{t.dataTransfer.setData(`text/plain`,e.key),t.dataTransfer.effectAllowed=`move`,m(e.key)},onDragEnd:()=>{m(null),g(null)},onClick:e=>{e.preventDefault(),e.stopPropagation()},onKeyDown:t=>{t.key!==`ArrowUp`&&t.key!==`ArrowDown`||(t.preventDefault(),t.stopPropagation(),x(e.key,t.key===`ArrowUp`?-1:1))},children:(0,B.jsx)(`svg`,{width:`10`,height:`16`,viewBox:`0 0 10 16`,"aria-hidden":!0,focusable:`false`,children:[4,8,12].map(e=>[2.5,7.5].map(t=>(0,B.jsx)(`circle`,{cx:t,cy:e,r:`1.15`,fill:`currentColor`},`${t}-${e}`)))})}),(0,B.jsx)(`input`,{type:`checkbox`,checked:i,disabled:r,onChange:()=>n(e.key)}),(0,B.jsx)(qp,{type:e.type,title:Vf[e.type]}),(0,B.jsx)(`span`,{className:`cg-check-label`,children:e.label}),e.source===`odoo`&&!e.custom&&(0,B.jsx)(`span`,{className:`cg-preset-tag`,children:`Pre-set`}),e.scope===`cohort`&&(0,B.jsx)(`span`,{className:`cg-preset-tag cg-scope-tag`,children:`Cohort-only`}),r&&(0,B.jsx)(`span`,{className:`cg-lock-tag`,children:`Locked`}),l&&(0,B.jsx)(`button`,{type:`button`,className:`cg-check-del`+(u?` is-armed`:``),"aria-label":u?`Permanently delete ${e.label}?`:`Delete ${e.label}`,title:u?void 0:`Removes this field and its values on every row.`,onClick:t=>{if(t.preventDefault(),t.stopPropagation(),!u){f(e.key);return}f(null),c(e.key)},children:u?`Delete permanently?`:(0,B.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M3.5 4.5h9M6.5 4.5V3h3v1.5M5 4.5l.6 8.5h4.8l.6-8.5`,stroke:`currentColor`,strokeWidth:1.3,strokeLinecap:`round`,strokeLinejoin:`round`})})})]},e.key)}),v.length===0&&(0,B.jsx)(`div`,{className:`cg-builder-empty`,children:`No field matches your search.`})]}),(i||r)&&(0,B.jsxs)(`div`,{className:`cg-pop-footer cg-fields-footer`,children:[i&&(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:i,children:`Show all`}),r&&(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:r,children:`Hide all`})]})]})}var Tre={stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`};function Ere(){return(0,B.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M4 6l4 4 4-4`,...Tre})})}function Tm({label:e,icon:t,active:n,tone:r,wide:i,measureWide:a,pairWide:o,forceOpenSignal:s,children:c}){let[l,u]=(0,L.useState)(!1),d=(0,L.useRef)(null),f=(0,L.useId)();return(0,L.useEffect)(()=>{s&&s>0&&u(!0)},[s]),(0,B.jsxs)(`div`,{className:`cg-pop-wrap`,children:[(0,B.jsxs)(`button`,{ref:d,type:`button`,className:`cg-tb-btn`+(r?` cg-tb-btn--${r}`:``)+(n||l?` is-active`:``),onClick:()=>u(e=>!e),"aria-expanded":l,"aria-haspopup":`dialog`,"aria-controls":l?f:void 0,title:e,"aria-label":e,children:[t,(0,B.jsx)(`span`,{className:`cg-tb-label`,children:e}),(0,B.jsx)(Ere,{})]}),l&&d.current&&(0,B.jsx)(Gp,{anchor:d.current,className:`cg-pop`+(i?` cg-pop--wide`:``)+(a?` cg-pop--measures`:``)+(o?` cg-pop--pair`:``),onDismiss:()=>u(!1),role:`dialog`,ariaLabel:`${e} options`,id:f,dataKind:`toolbar-${e.split(` `)[0].toLowerCase()}`,children:c(()=>u(!1))})]})}var Em={width:14,height:14,viewBox:`0 0 16 16`,fill:`none`},Dm={stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`};function Dre(){return(0,B.jsxs)(`svg`,{...Em,"aria-hidden":!0,children:[(0,B.jsx)(`rect`,{x:`2`,y:`3`,width:`12`,height:`10`,rx:`1.5`,...Dm}),(0,B.jsx)(`line`,{x1:`6.5`,y1:`3`,x2:`6.5`,y2:`13`,...Dm}),(0,B.jsx)(`line`,{x1:`10.5`,y1:`3`,x2:`10.5`,y2:`13`,...Dm})]})}function Om(){return(0,B.jsx)(`svg`,{...Em,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M2.5 4h11L9.5 9v3.5L6.5 14V9L2.5 4Z`,...Dm})})}function km(){return(0,B.jsxs)(`svg`,{...Em,"aria-hidden":!0,children:[(0,B.jsx)(`path`,{d:`M5 3v10M5 13l-2-2M5 13l2-2`,...Dm}),(0,B.jsx)(`path`,{d:`M11 13V3M11 3l-2 2M11 3l2 2`,...Dm})]})}function Ore(){return(0,B.jsx)(`svg`,{...Em,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M8 2s4.5 4.2 4.5 7a4.5 4.5 0 0 1-9 0C3.5 6.2 8 2 8 2Z`,...Dm})})}function Am(){return(0,B.jsxs)(`svg`,{...Em,"aria-hidden":!0,children:[(0,B.jsx)(`line`,{x1:`2.5`,y1:`5`,x2:`13.5`,y2:`5`,...Dm}),(0,B.jsx)(`line`,{x1:`2.5`,y1:`8`,x2:`13.5`,y2:`8`,...Dm}),(0,B.jsx)(`line`,{x1:`2.5`,y1:`11`,x2:`13.5`,y2:`11`,...Dm})]})}function jm(){return(0,B.jsxs)(`svg`,{...Em,"aria-hidden":!0,children:[(0,B.jsx)(`line`,{x1:`2.5`,y1:`4`,x2:`13.5`,y2:`4`,...Dm}),(0,B.jsx)(`line`,{x1:`5.5`,y1:`8`,x2:`13.5`,y2:`8`,...Dm}),(0,B.jsx)(`line`,{x1:`5.5`,y1:`12`,x2:`13.5`,y2:`12`,...Dm})]})}function kre(){return(0,B.jsxs)(`svg`,{...Em,"aria-hidden":!0,children:[(0,B.jsx)(`rect`,{x:`3.5`,y:`7`,width:`9`,height:`6`,rx:`1.2`,...Dm}),(0,B.jsx)(`path`,{d:`M5.75 7V5.25a2.25 2.25 0 0 1 4.5 0V7`,...Dm})]})}function Are(){return(0,B.jsxs)(`svg`,{...Em,"aria-hidden":!0,children:[(0,B.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4`,...Dm}),(0,B.jsx)(`line`,{x1:`10.2`,y1:`10.2`,x2:`13.5`,y2:`13.5`,...Dm})]})}var jre={filters:(0,B.jsx)(Om,{}),sorts:(0,B.jsx)(km,{}),groupBy:(0,B.jsx)(jm,{}),visible:(0,B.jsx)(Qp,{}),order:(0,B.jsx)(Dre,{}),rowHeightMode:(0,B.jsx)(Am,{})};function Mre({views:e,lockedKey:t,onApply:n,onClose:r}){let[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(()=>new Set([`filters`])),c=e.find(e=>e.id===i),l=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,B.jsxs)(`div`,{className:`cg-pop-body cg-copycfg`,children:[(0,B.jsxs)(`div`,{className:`cg-copycfg-head`,children:[(0,B.jsx)(`span`,{children:`Copy configuration from`}),(0,B.jsx)(rm,{className:`cg-copycfg-source`,ariaLabel:`View to copy from`,placeholder:`Choose a view…`,value:i||void 0,onChange:a,fields:e.map(e=>({key:e.id,label:e.name,icon:(0,B.jsx)(Jp,{mode:Od(e)})}))}),(0,B.jsx)(`span`,{children:`to this view`})]}),(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`Select what to copy. This view keeps everything else.`}),(0,B.jsx)(`div`,{className:`cg-pop-list`,children:Fp.map(e=>(0,B.jsxs)(`label`,{className:`cg-check-row`,title:e.blurb,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:o.has(e.key),onChange:()=>l(e.key)}),(0,B.jsx)(`span`,{className:`cg-mi-ic`,"aria-hidden":!0,children:jre[e.key]}),(0,B.jsx)(`span`,{className:`cg-check-label`,children:e.label})]},e.key))}),(0,B.jsxs)(`div`,{className:`cg-pop-footer cg-copycfg-bulk`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>s(new Set(Ip)),children:`Select all`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>s(new Set),children:`Clear all`})]}),(0,B.jsxs)(`div`,{className:`cg-form-actions cg-copycfg-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:!c||o.size===0,title:c?o.size===0?`Choose at least one thing to copy`:void 0:`Choose the view to copy from`,onClick:()=>{c&&(n($ne(c.config,o,t)),r())},children:`Copy configuration`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:r,children:`Cancel`})]})]})}function Nre({views:e,lockedKey:t,onApply:n}){let[r,i]=(0,L.useState)(!1),a=(0,L.useRef)(null);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{ref:a,type:`button`,className:`cg-link-btn cg-copy-link`+(r?` is-on`:``),"aria-expanded":r,onClick:()=>i(e=>!e),children:`Copy from another view`}),r&&a.current&&(0,B.jsx)(Gp,{anchor:a.current,className:`cg-pop cg-copycfg-pop`,placement:`bottom-end`,onDismiss:()=>i(!1),role:`dialog`,ariaLabel:`Copy configuration from another view`,dataKind:`copy-config`,children:(0,B.jsx)(Mre,{views:e,lockedKey:t,onApply:n,onClose:()=>i(!1)})})]})}function Pre({fields:e,fieldByKey:t,sorts:n,onSorts:r}){let i=(e,t)=>r(n.map((n,r)=>r===e?{...n,...t}:n)),a=e=>r(n.filter((t,n)=>n!==e));return(0,B.jsxs)(`div`,{className:`cg-pop-body cg-builder`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Sort`}),n.length===0&&(0,B.jsx)(`div`,{className:`cg-builder-empty`,children:`No sorts. Add one to order the list.`}),n.map((n,r)=>{let o=t.get(n.colId)?.type??`text`;return(0,B.jsxs)(`div`,{className:`cg-cond-line`,children:[(0,B.jsx)(`span`,{className:`cg-cond-prefix`,children:r===0?`Sort by`:`then by`}),(0,B.jsxs)(`span`,{className:`cg-cond-row`,children:[(0,B.jsx)(rm,{className:`cg-cond-field`,ariaLabel:`Sort field`,value:n.colId,onChange:e=>i(r,{colId:e}),fields:e.map(e=>({key:e.key,label:e.label,type:e.type}))}),(0,B.jsxs)(`select`,{className:`cg-select cg-cond-op`,value:n.dir,"aria-label":`Sort direction`,onChange:e=>i(r,{dir:e.target.value}),children:[(0,B.jsx)(`option`,{value:`asc`,children:ud(o,`asc`)}),(0,B.jsx)(`option`,{value:`desc`,children:ud(o,`desc`)})]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-cond-x`,"aria-label":`Remove sort`,onClick:()=>a(r),children:`×`})]})]},r)}),(0,B.jsxs)(`div`,{className:`cg-pop-footer cg-builder-footer`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>{let t=new Set(n.map(e=>e.colId)),i=e.find(e=>!t.has(e.key))??e[0];i&&r([...n,{colId:i.key,dir:`asc`}])},children:`+ Add another sort`}),n.length>0&&(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>r([]),children:`Clear`})]})]})}var Fre=[{mode:`short`,label:`Short`},{mode:`medium`,label:`Medium`},{mode:`tall`,label:`Tall`}];function Ire({fields:e,visible:t,nouns:n=`customers`,lockedKey:r,onColumnVisible:i,onColumnsVisible:a,orderedFields:o,onFieldOrder:s,deletableKeys:c,onDeleteField:l,colorOn:u,onToggleColor:d,rowHeightMode:f,onRowHeightMode:p,filters:m,onFilters:h,filterConj:g,onFilterConj:_,sorts:v,onSorts:y,groupBy:b,onGroupBy:x,statusValues:S,measures:C=[],pendingMeasureCount:w=0,unresolvedCount:T=0,lists:E=[],cohortLock:D,copyViews:O,onCopyConfig:k,search:A,onSearch:j,recordCount:M,scopeCounts:ee,pool:N,serverWindowed:te=!1,cohortAction:ne,filterSeed:P=null,modeControl:re}){let F=e.filter(e=>t.has(e.key)).length,ie=(0,L.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.key,n);return t},[e]),ae=(0,L.useMemo)(()=>{let e=new Map;for(let t of C)e.set(t.key,t);return e},[C]),oe=o??e,se=(0,L.useMemo)(()=>new Set(oe.filter(e=>!t.has(e.key)).map(e=>e.key)),[oe,t]),ce=(0,L.useMemo)(()=>({conj:g,nodes:m}),[g,m]),le=e=>{let t=Cd(e),n=wd(e);t!==m&&h(t),n!==g&&_(n)},ue=!!D,de=!!k&&(O?.length??0)>0,fe=(0,L.useMemo)(()=>e.filter(e=>Mee(e,r)),[e,r]),pe=(0,L.useRef)(0);(0,L.useEffect)(()=>{if(!P||P.n===pe.current)return;if(pe.current=P.n,P.measure){let e=ae.get(P.measure.key);if(!e)return;h([...m,{id:ym(),colId:e.key,op:fm[0],value:``,window:P.measure.window}]);return}let e=P.key?ie.get(P.key):void 0;!e||e.filterable===!1||h([...m,{colId:e.key,op:lm(e.type)[0],value:``}])},[P,ie,ae,m,h]);let me=(0,L.useMemo)(()=>xm(m),[m]),he=(0,L.useMemo)(()=>{let e=t=>t.some(t=>Sd(t)?e(t.children):t.rhs!=null&&t.rhs.kind!==`stat`);return e(m)},[m]),ge=me?`Filter · ${me}`:`Filter`,_e=v.length?`Sort · ${v.length}`:`Sort`,ve=b?`Group: ${ie.get(b)?.label??`?`}`:`Group`;return(0,B.jsxs)(`div`,{className:`cg-toolbar`,children:[re,(0,B.jsx)(Tm,{label:`Hide fields`,icon:(0,B.jsx)(Qp,{}),active:F(0,B.jsx)(wm,{fields:oe,hidden:se,onToggle:e=>i(e,!t.has(e)),onShowAll:()=>a(e.map(e=>e.key)),onHideAll:()=>a([r]),lockedKey:r,onFieldOrder:s,deletableKeys:c,onDeleteField:l})}),(0,B.jsx)(Tm,{label:ge,icon:(0,B.jsx)(Om,{}),active:me>0,tone:`filter`,wide:!0,measureWide:C.length>0,pairWide:he,forceOpenSignal:P?.n,children:()=>(0,B.jsx)(Cm,{fields:e,measures:C,cohorts:E,filters:ce,onChange:le,statusValues:S,cohortLock:D,footerExtra:de?(0,B.jsx)(Nre,{views:O,lockedKey:r,onApply:e=>k(e)}):void 0})}),(0,B.jsx)(Tm,{label:_e,icon:(0,B.jsx)(km,{}),active:v.length>0,tone:`sort`,wide:!0,children:()=>(0,B.jsx)(Pre,{fields:e,fieldByKey:ie,sorts:v,onSorts:y})}),(0,B.jsx)(Tm,{label:ve,icon:(0,B.jsx)(jm,{}),active:b!==null,tone:`group`,children:()=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Group by`}),te?(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`Not available on this table. It loads one page at a time, so a group would count only the rows currently fetched.`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-group`,checked:b===null,onChange:()=>x(null)}),(0,B.jsx)(`span`,{children:`No grouping`})]}),fe.map(e=>(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-group`,checked:b===e.key,onChange:()=>x(e.key)}),(0,B.jsx)(qp,{type:e.type,title:Vf[e.type]}),(0,B.jsx)(`span`,{children:e.label})]},e.key))]})]})}),(0,B.jsx)(`span`,{className:`cg-tb-divider`,"aria-hidden":!0}),(0,B.jsx)(Tm,{label:`Color`,icon:(0,B.jsx)(Ore,{}),active:u,children:()=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Color`}),(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-color`,checked:!u,onChange:()=>d(!1)}),(0,B.jsx)(`span`,{children:`No color`})]}),(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-color`,checked:u,onChange:()=>d(!0)}),(0,B.jsx)(`span`,{children:`Color by status`})]})]})}),(0,B.jsx)(Tm,{label:`Rows`,icon:(0,B.jsx)(Am,{}),active:f!==`short`,children:()=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Row height`}),Fre.map(e=>(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-rowh`,checked:f===e.mode,onChange:()=>p(e.mode)}),(0,B.jsx)(`span`,{children:e.label})]},e.mode))]})}),ue&&(0,B.jsxs)(`span`,{className:`cg-tb-lock`,title:(D?.name?`Locked to ${D.name}. `:`Locked to a set of records you cannot see. `)+`Only the records locked into that view are shown. Filters and sort narrow WITHIN the lock; the lock itself is changed from the view menu in the rail.`,children:[(0,B.jsx)(kre,{}),(0,B.jsx)(`span`,{className:`cg-tb-label`,children:`Locked`})]}),(0,B.jsxs)(`div`,{className:`cg-search`,children:[(0,B.jsx)(`span`,{className:`cg-search-icon`,"aria-hidden":!0,children:(0,B.jsx)(Are,{})}),(0,B.jsx)(`input`,{type:`text`,className:`cg-search-input`,placeholder:`Search ${n}…`,value:A,onChange:e=>j(e.target.value)}),A&&(0,B.jsx)(`button`,{type:`button`,className:`cg-search-clear`,"aria-label":`Clear search`,onClick:()=>j(``),children:`×`})]}),ne,(0,B.jsx)(`span`,{className:`cg-tb-spacer`}),w>0&&(0,B.jsx)(`span`,{className:`cg-count cg-count-pending`,title:`${w} measure condition${w===1?``:`s`} still being calculated over the period you chose. Rows are hidden until the answer arrives rather than shown under a count that would be wrong.`,children:`Calculating…`}),T>0&&(0,B.jsx)(`span`,{className:`cg-count cg-count-pending`,title:`${T} condition${T===1?``:`s`} cannot be evaluated — a date that does not resolve, or a list this view refers to that no longer exists. Rows are hidden rather than shown under a count that would be wrong.`,children:`Filter unresolved`}),am(N)==null?(0,B.jsxs)(`span`,{className:`cg-count`,title:im(M,ee),children:[(0,B.jsx)(`span`,{className:`cg-count-full`,children:im(M,ee)}),(0,B.jsx)(`span`,{className:`cg-count-compact`,children:lre(M,ee)})]}):(0,B.jsxs)(`span`,{className:`cg-count cg-count-partial`,title:`Loading the rest of your ${n} in the background — you can browse, filter and sort what is already here.`,children:[(0,B.jsx)(`span`,{className:`lp-spin`,role:`status`,"aria-label":`Loading`}),am(N)]})]})}function Mm({on:e}){return(0,B.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 20 20`,"aria-hidden":!0,children:(0,B.jsx)(`polygon`,{points:`10,1.8 12.5,7.2 18.4,7.7 13.9,11.6 15.3,17.4 10,14.3 4.7,17.4 6.1,11.6 1.6,7.7 7.5,7.2`,fill:e?`#A98A3E`:`none`,stroke:e?`#A98A3E`:`rgba(118,143,182,0.55)`,strokeWidth:`1.2`,strokeLinejoin:`round`})})}function Lre({value:e,max:t}){return(0,B.jsx)(`span`,{className:`cg-stars cg-stars--static`,"aria-label":`${e} of ${t}`,children:Array.from({length:t},(t,n)=>(0,B.jsx)(Mm,{on:n=0?n.splice(r,1):n.push(t),Vre(n)}function Im(e,t,n){let r=e.type===`user`?t??[]:td(e),i=r.map(e=>({value:e,label:e})),a=e.type===`multiselect`?Fm(n):[Nm(n).trim()];for(let e of a)e===``||r.includes(e)||i.push({value:e,label:`${e} (no longer a choice)`,stale:!0});return i}function Lm(e){let t=Nm(e).trim();if(t===``)return``;let n=Number(t);return Number.isFinite(n)?String(n):``}function Ure(e){let t=e.trim();if(t===``)return``;let n=Number(t);return Number.isFinite(n)?t:null}function Rm(e,t){let n=Math.round(Number(Nm(t)));return Number.isFinite(n)?Math.max(0,Math.min(nd(e),n)):0}function Wre(e,t,n){let r=Rm(e,t),i=Math.max(1,Math.min(nd(e),Math.round(n)));return i===r?``:String(i)}function Gre(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length?t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase():`?`}var Kre=new Set([`sum`,`count`]);function qre(e){return Kre.has(e)}var zm=`month`;function Bm(e){let t=rd.includes(e.bucket??``)?e.bucket:zm,n=e.span??{},r;return r=typeof n.lastN==`number`&&Number.isFinite(n.lastN)?{lastN:Math.max(1,Math.min(120,Math.round(n.lastN)))}:n.from||n.to?{from:n.from,to:n.to}:{lastN:12},{pids:e.pids,bucket:t,span:r,fields:e.fields.slice(0,12)}}function Vm(e,t){return e==null||t==null||t===0||!Number.isFinite(e)||!Number.isFinite(t)?null:(e-t)/Math.abs(t)*100}function Hm(e){return e.toLocaleString(void 0,{maximumFractionDigits:2})}function Jre(e,t){return e==null?`—`:t?t(e):String(e)}function Um(e){return e==null?``:Hm(e)}function Wm(e,t){return e==null?``:t?Gm(e):`${e>0?`+`:``}${Hm(e)}`}function Gm(e){return e==null?`—`:`${e>0?`+`:``}${e.toFixed(1)}%`}function Yre(e){switch(e){case`not_a_measure_field`:return`not a measure — only measure fields have a time dimension`;case`unresolvable`:return`a composite measure has no single aggregate to bucket`;case`window_fixed`:return`its period is a fixed date range, so it cannot slide across buckets`;default:return e}}function Km(e){if(!e)return{columns:[],rows:[],notes:[],pool:0,empty:!0};let t=e.columns??[],n=(e.rows??[]).map(e=>{let n=e.values??[],r=t.map((e,t)=>({value:n[t]??null,delta:Vm(n[t]??null,t>0?n[t-1]??null:null),partial:e.partial===!0})),i=qre(e.agg)&&typeof e.total==`number`&&Number.isFinite(e.total)?e.total:void 0;return{field:e.field,label:e.label,agg:e.agg,cells:r,total:i,allUnanswered:r.length>0&&r.every(e=>e.value==null),window:e.window}}),r=[],i=e.meta??{pool:0};for(let e of i.dropped??[])r.push(`${e.field} is not shown — ${Yre(e.reason)}.`);for(let e of i.problems??[])r.push(e);let a=t.filter(e=>e.partial).length;a>0&&r.push(a===1?`The last column is a partial period — it is still filling.`:`${a} columns are partial periods — they are still filling.`);let o=n.filter(e=>e.allUnanswered).length;return o>0&&r.push(`${o} of ${n.length} metrics returned no values for this span (shown as "—").`),{columns:t,rows:n,notes:r,pool:i.pool??0,empty:n.length===0}}var Xre=new Set([`currency`,`int`,`pct`]),Zre=/(^|_)days(_|$)/;function Qre(e){return e.agg===`sum`||e.agg===`count`?`sum`:e.agg===`avg`||e.type===`pct`||Zre.test(e.key)?`avg`:`sum`}function qm(e){return e.measure&&typeof e.measure==`object`?`server`:Xre.has(e.type)?`snapshot`:`refused`}function $re(e){return e.formula?`a formula column has no time dimension of its own`:`${e.type} is not a number, so it has nothing to plot over time`}function eie(e,t,n,r){let i=Qre(e),a=0,o=0;for(let n of t){let t=n?.[e.key];if(t==null||t===``)continue;let r=typeof t==`number`?t:Number(t);Number.isFinite(r)&&(a+=r,o+=1)}let s=o===0?null:i===`avg`?a/o:a,c=n.map(e=>({value:s,delta:null,partial:e.partial===!0}));return{field:e.key,label:e.label,agg:`snapshot`,cells:c,total:void 0,allUnanswered:s==null,window:{kind:`snapshot`,label:r?`Snapshot · the current value as of ${r}, not per period`:`Snapshot · the current value, not per period`}}}function tie(e,t){return`${e.length===1?e[0]:`${e.length} rows`} ${e.length===1?`has`:`have`} no time dimension, so ${e.length===1?`it is`:`they are`} shown as the current value${t?` as of ${t}`:``} repeated across every period — a flat line here means "not measured over time", not "unchanged". No total and no comparison is offered for ${e.length===1?`it`:`them`}.`}function nie(e){let t=[],n=0;for(;nt[n],i=e=>{let t=r();return t&&t.k===`op`&&t.v===e?(n+=1,!0):!1};function a(){let e=r();if(!e)return null;if(e.k===`num`)return n+=1,{t:`num`,v:e.v};if(e.k===`ref`)return n+=1,{t:`ref`,name:e.name};if(i(`(`)){let e=c();return!e||!i(`)`)?null:e}return null}function o(){if(i(`-`)){let e=o();return e?{t:`neg`,a:e}:null}return i(`+`)?o():a()}function s(){let e=o();if(!e)return null;for(;;){let t=r();if(!t||t.k!==`op`||t.v!==`*`&&t.v!==`/`)return e;n+=1;let i=o();if(!i)return null;e={t:`bin`,op:t.v,a:e,b:i}}}function c(){let e=s();if(!e)return null;for(;;){let t=r();if(!t||t.k!==`op`||t.v!==`+`&&t.v!==`-`)return e;n+=1;let i=s();if(!i)return null;e={t:`bin`,op:t.v,a:e,b:i}}}let l=c();return l&&n===t.length?l:null}function iie(e,t){let n,r=e=>{switch(e.t){case`num`:return e.v;case`ref`:{let r=t(e.name);return r===void 0?(n??=`unknown_ref`,null):r}case`neg`:{let t=r(e.a);return t==null?null:-t}case`bin`:{let t=r(e.a),i=r(e.b);if(t==null||i==null)return null;if(e.op===`+`)return t+i;if(e.op===`-`)return t-i;if(e.op===`*`)return t*i;if(i===0)return n??=`div_zero`,null;let a=t/i;return Number.isFinite(a)?a:null}}},i=r(e);return n?{value:null,error:n}:{value:i}}function aie(e,t){switch(t){case`syntax`:return`${e}: that formula could not be read — use + - * / ( ) with numbers and [row] references.`;case`unknown_ref`:return`${e}: a row it refers to is not on this sheet, so it is left blank rather than treated as zero.`;case`cycle`:return`${e}: it refers back to itself, so it has no value.`;case`div_zero`:return`${e}: divided by zero in at least one period — those cells are blank, not zero.`}}var Jm={week:52,month:12,quarter:4,year:1},Ym={abs:`Change`,pct:`Change %`,yoy:`vs last year`,ytd:`YTD growth`};function oie(e){return e!==`abs`}function Xm(e,t,n){let r=e.cells.map(e=>e.value),i=Jm[n]??12,a=[];for(let n of t){let t=oie(n),o,s;n===`abs`?s=r.map((e,t)=>t===0||e==null||r[t-1]==null?null:e-r[t-1]):n===`pct`?s=r.map((e,t)=>Vm(e,t>0?r[t-1]:null)):n===`yoy`||e.window?.kind===`ytd`?(s=r.map((e,t)=>Vm(e,t>=i?r[t-i]:null)),r.length<=i&&(o=`This span is shorter than a year, so there is no earlier period to compare against.`)):(s=r.map(()=>null),o=e.window==null?`Year-to-date growth needs the metric's own period, which this server did not report.`:`Year-to-date growth is only meaningful on a year-to-date metric — this one is "${e.window.label}".`),a.push({kind:n,label:Ym[n],percent:t,values:s,refusal:o})}return a}function sie(e,t){let n=Jm[t]??12,r={value:null,delta:null,partial:!1},i=e.cells.map((t,i)=>i>=n?e.cells[i-n]:r),a=e.cells.length<=n?`This span is shorter than a year, so there is no earlier period to compare against.`:void 0;return{label:`${e.label} (last year)`,cells:a?[]:i,back:n,refusal:a}}function Zm(e,t,n){if(!e)return{};let r=e[t],i=n?e[`${t}:${n}`]:void 0;return!r&&!i?{}:{...r,...i}}function cie(e,t,n){let r=e.filter(e=>e!=null&&Number.isFinite(e));if(r.length<2)return[];let i=Math.min(...r),a=Math.max(...r)-i,o=e.length>1?t/(e.length-1):0,s=[],c=[];return e.forEach((e,t)=>{if(e==null||!Number.isFinite(e)){c.length>1&&s.push({points:c}),c=[];return}let r=a===0?n/2:n-(e-i)/a*n;c.push({x:t*o,y:r})}),c.length>1&&s.push({points:c}),s}function lie(e){return e.points.map(e=>`${Math.round(e.x*10)/10},${Math.round(e.y*10)/10}`).join(` `)}function Qm(e){return e.trim().toLowerCase()}function uie(e,t){let n=[...e.notes],r=t.deltas??[],i=(t.customRows??[]).filter(e=>e&&typeof e.id==`string`),a=new Map,o=new Map;e.rows.forEach((e,t)=>{a.has(e.field)||a.set(e.field,{kind:`metric`,index:t});let n=Qm(e.label);n&&!o.has(n)&&o.set(n,{kind:`metric`,index:t})}),i.forEach((e,t)=>{if(e.kind!==`formula`)return;a.has(e.id)||a.set(e.id,{kind:`formula`,index:t});let n=Qm(e.label);n&&!o.has(n)&&o.set(n,{kind:`formula`,index:t})});let s=i.map(e=>e.kind===`formula`?rie(e.expr??``):null),c=new Map,l=new Map,u=(t,n)=>{let r=c.get(t);if(r)return r;let i=e.columns.length;if(n.has(t))return l.set(t,`cycle`),Array(i).fill(null);let d=s[t];if(!d){l.set(t,`syntax`);let e=Array(i).fill(null);return c.set(t,e),e}n.add(t);let f=[];for(let r=0;r{let i=a.get(t.trim())??o.get(Qm(t));if(i)return i.kind===`metric`?e.rows[i.index]?.cells[r]?.value??null:u(i.index,n)[r]??null});i.error&&!l.has(t)&&l.set(t,i.error),f.push(i.value)}return n.delete(t),c.set(t,f),f},d=e.rows.map(e=>({id:e.field,kind:`metric`,label:e.label,sublabel:e.window?.label,agg:e.agg,cells:e.cells,total:e.total,deltas:e.agg===`snapshot`?[]:Xm(e,r,t.bucket),allUnanswered:e.allUnanswered})),f=e.rows.filter(e=>e.agg===`snapshot`);f.length>0&&n.push(tie(f.map(e=>e.label),t.today)),i.forEach((i,a)=>{if(i.kind===`note`){d.push({id:i.id,kind:`note`,label:i.label,cells:e.columns.map(e=>({value:null,delta:null,partial:e.partial===!0})),deltas:[],allUnanswered:!1});return}let o=u(a,new Set),s=e.columns.map((e,t)=>({value:o[t]??null,delta:Vm(o[t]??null,t>0?o[t-1]??null:null),partial:e.partial===!0})),c=l.get(a);c&&n.push(aie(i.label||i.id,c)),d.push({id:i.id,kind:`formula`,label:i.label,expr:i.expr,cells:s,deltas:Xm({cells:s,window:void 0},r,t.bucket),allUnanswered:s.length>0&&s.every(e=>e.value==null)})});let p=new Set;for(let e of d)for(let t of e.deltas)t.refusal&&p.add(t.refusal);for(let e of p)n.push(e);return{columns:e.columns,rows:d,notes:n,pool:e.pool,empty:d.length===0}}function $m(e,t){let n=e.cells.map((e,n)=>({cell:e,col:t[n]})).filter(e=>e.col&&e.cell.value!=null).map(t=>({key:t.col.key,label:t.col.label,value:t.cell.value,n:1,seriesKey:e.field,seriesLabel:e.label}));return{points:n,xOrder:t.map(e=>e.key),seriesOrder:[e.field],omitted:0,omittedValue:0,omittedSeries:0,omittedSeriesValue:0,blanks:e.cells.filter(e=>e.value==null).length,missingY:0,rows:n.length,nonPositive:0,nonPositiveValue:0}}function die(e,t,n,r){let i=sie(e,n),a=Math.max(1,Math.min(Math.round(r),t.length)),o=t.length-a,s=t.slice(o),c=`${e.field}::prior_year`,l=(e,t,n)=>s.map((t,n)=>({col:t,cell:e[o+n]})).filter(e=>e.cell&&e.cell.value!=null).map(e=>({key:e.col.key,label:e.col.label,value:e.cell.value,n:1,seriesKey:t,seriesLabel:n})),u=l(e.cells,e.field,e.label),d=i.refusal?[]:l(i.cells,c,i.label);return{points:[...u,...d],xOrder:s.map(e=>e.key),seriesOrder:i.refusal?[e.field]:[e.field,c],omitted:0,omittedValue:0,omittedSeries:0,omittedSeriesValue:0,blanks:e.cells.slice(o).filter(e=>e.value==null).length,missingY:0,rows:u.length,nonPositive:0,nonPositiveValue:0}}function eh(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function fie(e){let t=[[`Metric`,...e.columns.map(e=>e.label),`Total`].map(eh).join(`,`)];for(let n of e.rows){t.push([eh(n.sublabel?`${n.label} (${n.sublabel})`:n.label),...n.cells.map(e=>eh(Um(e.value))),eh(Um(n.total??null))].join(`,`));for(let e of n.deltas)t.push([eh(`${n.label} — ${e.label}${e.percent?` (%)`:``}`),...e.values.map(t=>eh(Wm(t,e.percent))),``].join(`,`))}if(e.notes.length>0){t.push(``);for(let n of e.notes)t.push(eh(n))}return t.join(`\r `)+`\r -`}function sie(e){let t=(e,t)=>({key:e,label:t,type:`text`,source:`odoo`}),n=[t(`metric`,`Metric`),...e.columns.map(e=>t(`c_${e.key}`,e.partial?`${e.label} (partial)`:e.label)),t(`total`,`Total`)],r=[],i=(t,n,i)=>{let a={pid:r.length+1,metric:t,total:i};e.columns.forEach((e,t)=>{a[`c_${e.key}`]=n[t]??``}),r.push(a)};for(let t of e.rows){i(t.sublabel?`${t.label} (${t.sublabel})`:t.label,t.cells.map(e=>Mm(e.value)),Mm(t.total??null));for(let e of t.deltas)i(`${t.label} — ${e.label}${e.percent?` (%)`:``}`,e.values.map(t=>Nm(t,e.percent)),``)}if(e.notes.length>0){i(``,[],``);for(let t of e.notes)i(t,[],``)}return{fields:n,rows:r}}var cie={brand:[`#1F4E78`,`#C8A24B`,`#6F96B8`,`#E0C979`,`#3E6F98`,`#A17C2D`],categorical:[`#2F6B9A`,`#C28A2C`,`#4C8A68`,`#8A5C9D`,`#C25B56`,`#4B8793`,`#8B704A`,`#6A78A8`,`#A45D7D`,`#708B3D`,`#B66B32`,`#52749C`],sequential:[`#E7F0F7`,`#C5D9E9`,`#9CBCD5`,`#719DBE`,`#477CA3`,`#1F4E78`],diverging:[`#2F6B9A`,`#7EA5C3`,`#D8E4ED`,`#F0E6C6`,`#D5B66A`,`#9B7222`]};function lie(e){switch(e.axis?.y?.format){case`number`:return{format:`,.2~f`};case`currency`:return{format:`$,.0f`};case`percent`:return{labelExpr:`format(datum.value, ',.2~f') + '%'`};case`compact`:return{format:`~s`};default:return{}}}function uie(e,t){let n=new Map(e.xOrder.map((e,t)=>[e,t])),r=new Map(e.seriesOrder.map((e,t)=>[e,t]));return e.points.map(e=>({xKey:e.key,xLabel:e.label,xIndex:n.get(e.key)??0,value:e.value,valueText:t(e.value),n:e.n,seriesKey:e.seriesKey,seriesLabel:e.seriesLabel,seriesIndex:r.get(e.seriesKey)??0}))}function die(){return{font:`Inter, ui-sans-serif, system-ui, sans-serif`,view:{stroke:null},axis:{labelColor:`#536273`,labelFont:`Inter, ui-sans-serif, system-ui, sans-serif`,labelFontSize:10,labelLimit:110,titleColor:`#344355`,titleFont:`Inter, ui-sans-serif, system-ui, sans-serif`,titleFontSize:11,titleFontWeight:500,gridColor:`#E7EBEF`,domainColor:`#C9D1D9`,tickColor:`#C9D1D9`},legend:{labelColor:`#536273`,labelFont:`Inter, ui-sans-serif, system-ui, sans-serif`,labelFontSize:10,titleColor:`#344355`,titleFont:`Inter, ui-sans-serif, system-ui, sans-serif`,titleFontSize:10,symbolType:`circle`,orient:`bottom`,direction:`horizontal`}}}function fie(e,t){return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,data:{values:t},width:`container`,height:`container`,autosize:{type:`fit`,contains:`padding`,resize:!0},padding:4,config:die(),usermeta:{rendererBoundary:`aios-chart-spec-v1`,chartId:e.id}}}function Wm(e){return[{field:`xLabel`,type:`nominal`,title:`Group`},...e?[{field:`seriesLabel`,type:`nominal`,title:`Series`}]:[],{field:`valueText`,type:`nominal`,title:`Value`},{field:`n`,type:`quantitative`,title:`Records`,format:`,`}]}function Gm({spec:e,model:t,xTitle:n,yTitle:r,formatValue:i}){let a=uie(t,i).filter(t=>e.kind!==`donut`||t.value>0),o=[...cie[e.palette??`brand`]],s=t.seriesOrder.length>0,c=s?{field:`seriesLabel`,type:`nominal`,title:null,sort:{field:`seriesIndex`,op:`min`},scale:{range:o},legend:{columns:4}}:{value:o[0]},l={field:`xLabel`,type:`nominal`,title:n??null,sort:{field:`xIndex`,op:`min`,order:`ascending`},axis:{labelAngle:t.xOrder.length>7?-35:0,labelOverlap:`greedy`}},u={field:`value`,type:`quantitative`,title:r??null,axis:lie(e)},d=fie(e,a);if(e.kind===`kpi`)return{...d,mark:{type:`text`,align:`center`,baseline:`middle`,font:`Inter, ui-sans-serif, system-ui, sans-serif`,fontSize:32,fontWeight:600,color:`#172433`},encoding:{text:{field:`valueText`,type:`nominal`},tooltip:[{field:`valueText`,type:`nominal`,title:`Value`},{field:`n`,type:`quantitative`,title:`Records`,format:`,`}]}};if(e.kind===`donut`)return{...d,mark:{type:`arc`,innerRadius:44,outerRadius:76,cornerRadius:2,padAngle:.01},encoding:{theta:{field:`value`,type:`quantitative`,stack:!0},color:{field:`xLabel`,type:`nominal`,title:null,sort:{field:`xIndex`,op:`min`},scale:{range:o},legend:{orient:`right`,direction:`vertical`,labelLimit:110}},order:{field:`xIndex`,type:`quantitative`},tooltip:Wm(!1)}};let f={x:l,y:{...u,stack:(e.kind===`bar`||e.kind===`area`)&&s?e.stacked?`zero`:null:void 0},color:c,tooltip:Wm(s)};return s&&e.kind===`bar`&&!e.stacked&&(f.xOffset={field:`seriesLabel`,type:`nominal`,sort:{field:`seriesIndex`,op:`min`}}),(e.kind===`line`||e.kind===`area`)&&(f.order={field:`xIndex`,type:`quantitative`},s&&(f.detail={field:`seriesKey`,type:`nominal`})),{...d,mark:e.kind===`bar`?{type:`bar`,cornerRadiusTopLeft:2,cornerRadiusTopRight:2}:e.kind===`area`?{type:`area`,opacity:s?.68:.48,line:!0,point:!0}:{type:`line`,strokeWidth:2,point:{filled:!0,size:46}},encoding:f}}function Km(e,t={}){let n=JSON.stringify([1],void 0,t.indent===void 0?2:t.indent).slice(2,-3),r=n===``?1/0:t.maxLength===void 0?80:t.maxLength,{replacer:i}=t;return(function e(t,a,o){t&&typeof t.toJSON==`function`&&(t=t.toJSON());let s=JSON.stringify(t,i);if(s===void 0)return s;let c=r-a.length-o;if(s.length<=c){let e=s.replace(qm,(e,t)=>t||`${e} `);if(e.length<=c)return e}if(i!=null&&(t=JSON.parse(s),i=void 0),typeof t==`object`&&t){let r=a+n,i=[],o=0,s,c;if(Array.isArray(t)){s=`[`,c=`]`;let{length:n}=t;for(;o0)return[s,n+i.join(`,\n${r}`),c].join(`\n${a}`)}return s})(e,``,0)}var qm,pie=o((()=>{qm=/("(?:[^\\"]|\\.)*")|[:,]/g}));function Jm(e,t,n){return Object.assign(e,{fields:t||[],fname:n})}function Ym(e){return e==null?null:e.fname}function Xm(e){return e==null?null:e.fields}var Zm=o((()=>{}));function Qm(e){return e.length===1?$m(e[0]):eh(e)}var $m,eh,th=o((()=>{$m=e=>function(t){return t[e]},eh=e=>{let t=e.length;return function(n){for(let r=0;r{}));function rh(e){let t=[],n=e.length,r=null,i=0,a=``,o,s,c;e+=``;function l(){t.push(a+e.substring(o,s)),a=``,o=s+1}for(o=s=0;so?l():o=s+1:c===`[`?(s>o&&l(),i=o=s+1):c===`]`&&(i||V(`Access path missing open bracket: `+e),i>0&&l(),i=0,o=s+1);return i&&V(`Access path missing closing bracket: `+e),r&&V(`Access path missing closing quote: `+e),s>o&&(s++,l()),t}var ih=o((()=>{nh()}));function ah(e,t,n){let r=rh(e),i=r.length===1?r[0]:e;return Jm((n&&n.get||Qm)(r),[i],t||i)}var oh=o((()=>{Zm(),th(),ih()})),sh,ch,lh,uh,dh,fh,mie=o((()=>{Zm(),oh(),sh=ah(`id`),ch=Jm(e=>e,[],`identity`),lh=Jm(()=>0,[],`zero`),uh=Jm(()=>1,[],`one`),dh=Jm(()=>!0,[],`true`),fh=Jm(()=>!1,[],`false`)})),ph,hie=o((()=>{ph=new Set([...Object.getOwnPropertyNames(Object.prototype).filter(e=>typeof Object.prototype[e]==`function`),`__proto__`])}));function gie(e,t,n){let r=[t,...n];console[e](...r)}function mh(e,t,n=gie){let r=e||0;return{level(e){return arguments.length?(r=+e,this):r},error(...e){return r>=1&&n(t||`error`,`ERROR`,e),this},warn(...e){return r>=2&&n(t||`warn`,`WARN`,e),this},info(...e){return r>=3&&n(t||`log`,`INFO`,e),this},debug(...e){return r>=4&&n(t||`log`,`DEBUG`,e),this}}}var _ie=o((()=>{})),H,hh=o((()=>{H=Array.isArray}));function gh(e){return e===Object(e)}var _h=o((()=>{}));function vh(...e){return e.reduce((e,t)=>{for(let n in t)if(n===`signals`)e.signals=vie(e.signals,t.signals);else{let r=n===`legend`?{layout:1}:n===`style`||null;yh(e,n,t[n],r)}return e},{})}function yh(e,t,n,r){if(!bh(t))return;let i=e,a,o;if(gh(n)&&!H(n)){let e=n;for(a in o=gh(i[t])?i[t]:i[t]={},e)r&&(r===!0||r[a])?yh(o,a,e[a]):bh(a)&&(o[a]=e[a])}else i[t]=n}function vie(e,t){if(e==null)return t;if(t==null)return e;let n={},r=[];function i(e){n[e.name]||(n[e.name]=1,r.push(e))}return t.forEach(i),e.forEach(i),r}var bh,yie=o((()=>{hh(),_h(),bh=e=>e!==`__proto__`&&e!==`constructor`&&e!==`prototype`}));function xh(e){return e[e.length-1]}var Sh=o((()=>{}));function Ch(e){return e==null||e===``?null:+e}var wh=o((()=>{}));function Th(e){return e.length>0}function Eh(e,t,n,r){Th(e)||V(`Domain array must not be empty`);let i=n(e[0]),a=n(xh(e)),o=(a-i)*t;return[r(i-o),r(a-o)]}function Dh(e,t){return Eh(e,t,Vh,Hh)}function Oh(e,t){let n=Math.sign(e[0]);return Eh(e,t,Lh(n),Ih(n))}function kh(e,t,n){return Eh(e,t,Bh(n),Bh(1/n))}function Ah(e,t,n){return Eh(e,t,Rh(n),zh(n))}function jh(e,t,n,r,i){Th(e)||V(`Domain array must not be empty`);let a=r(e[0]),o=r(xh(e)),s=t==null?(a+o)/2:r(t);return[i(s+(a-s)*n),i(s+(o-s)*n)]}function Mh(e,t,n){return jh(e,t,n,Vh,Hh)}function Nh(e,t,n){let r=Math.sign(e[0]);return jh(e,t,n,Lh(r),Ih(r))}function Ph(e,t,n,r){return jh(e,t,n,Bh(r),Bh(1/r))}function Fh(e,t,n,r){return jh(e,t,n,Rh(r),zh(r))}var Ih,Lh,Rh,zh,Bh,Vh,Hh,bie=o((()=>{nh(),Sh(),wh(),Ih=e=>t=>e*Math.exp(t),Lh=e=>t=>Math.log(e*t),Rh=e=>t=>Math.sign(t)*Math.log1p(Math.abs(t/e)),zh=e=>t=>Math.sign(t)*Math.expm1(Math.abs(t))*e,Bh=e=>t=>t<0?-((-t)**+e):t**+e,Vh=e=>Ch(e)??0,Hh=e=>e}));function Uh(e){return 1+~~(new Date(e).getMonth()/3)}function Wh(e){return 1+~~(new Date(e).getUTCMonth()/3)}var xie=o((()=>{}));function Gh(e){return e==null?[]:H(e)?e:[e]}var Kh=o((()=>{hh()}));function qh(e,t,n){let r=e[0],i=e[1],a;return i=n-t?[t,n]:[r=Math.min(Math.max(r,t),n-a),r+a]}var Sie=o((()=>{}));function Jh(e){return typeof e==`function`}var Yh=o((()=>{}));function Xh(e,t,n){let r=n||{},i=Gh(t)||[],a=[],o=[],s={},c=r.comparator||$h;return Gh(e).forEach((e,t)=>{if(e==null)return;a.push(i[t]===Zh?-1:1);let n=Jh(e)?e:ah(e,void 0,r);o.push(n),(Xm(n)||[]).forEach(e=>s[e]=1)}),o.length===0?null:Jm(c(o,a),Object.keys(s))}var Zh,Qh,$h,eg,tg,Cie=o((()=>{Zm(),Kh(),oh(),Yh(),Zh=`descending`,Qh=(e,t)=>{let n=e,r=t;return(nr||r==null)&&n!=null?1:(r=r instanceof Date?+r:r,n=n instanceof Date?+n:n)!==n&&r===r?-1:+(r!==r&&n===n)},$h=(e,t)=>e.length===1?eg(e[0],t[0]):tg(e,t,e.length),eg=(e,t)=>function(n,r){return Qh(e(n),e(r))*t},tg=(e,t,n)=>(t.push(0),function(r,i){let a,o=0,s=-1;for(;o===0&&++se}var wie=o((()=>{Yh()}));function rg(e,t){let n=null;return r=>{n&&clearTimeout(n),n=setTimeout(()=>(t(r),n=null),e)}}var Tie=o((()=>{}));function ig(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}var ag=o((()=>{}));function og(e,t){let n=0,r,i,a,o;if(e&&(r=e.length))if(t==null){for(i=e[n];no&&(o=i))}else{for(i=t(e[n]);no&&(o=i))}return[a,o]}var Eie=o((()=>{}));function Die(e,t){let n=e.length,r=-1,i,a,o,s,c;if(t==null){for(;++r=s){o=c=s;break}if(r===n)return[-1,-1];for(i=a=r;++rs&&(o=s,i=r),c=s){o=c=s;break}if(r===n)return[-1,-1];for(i=a=r;++rs&&(o=s,i=r),c{}));function sg(e,t){return Object.hasOwn(e,t)}var cg=o((()=>{}));function lg(e){let t={},n;function r(e){return sg(t,e)&&t[e]!==ug}let i={size:0,empty:0,object:t,has:r,get(e){return r(e)?t[e]:void 0},set(e,n){return r(e)||(++i.size,t[e]===ug&&--i.empty),t[e]=n,this},delete(e){return r(e)&&(--i.size,++i.empty,t[e]=ug),this},clear(){i.size=i.empty=0,i.object=t={}},test(e){return arguments.length?(n=e,i):n},clean(){let e={},r=0;for(let i in t){let a=t[i];a!==ug&&(!n||!n(a))&&(e[i]=a,++r)}i.size=r,i.empty=0,i.object=t=e}};return e&&Object.keys(e).forEach(t=>{i.set(t,e[t])}),i}var ug,kie=o((()=>{cg(),ug={}}));function Aie(e,t,n,r,i,a){if(!n&&n!==0)return a;let o=+n,s=e[0],c=xh(e),l;if(c===void 0)return a;c{Sh()}));function U(e,t,n){let r=e.prototype=Object.create(t.prototype);return Object.defineProperty(r,"constructor",{value:e,writable:!0,enumerable:!0,configurable:!0}),ig(r,n)}var Mie=o((()=>{ag()}));function dg(e,t,n,r){let i=t[0],a=t[t.length-1],o;return i>a&&(o=i,i=a,a=o),n=n===void 0||n,r=r===void 0||r,(n?i<=e:i{}));function fg(e){return typeof e==`boolean`}var Pie=o((()=>{}));function pg(e){return Object.prototype.toString.call(e)===`[object Date]`}var Fie=o((()=>{}));function Iie(e){return e!=null&&Jh(e[Symbol.iterator])}var Lie=o((()=>{Yh()}));function mg(e){return typeof e==`number`}var Rie=o((()=>{}));function hg(e){return Object.prototype.toString.call(e)===`[object RegExp]`}var zie=o((()=>{}));function gg(e){return typeof e==`string`}var Bie=o((()=>{}));function _g(e,t,n){let r=e?t?Gh(e).map(e=>e.replace(/\\(.)/g,`$1`)):Gh(e):void 0,i=r?.length,a=n&&n.get||Qm,o=e=>a(t?[e]:rh(e)),s;if(!i||!r)s=function(){return``};else if(i===1){let e=o(r[0]);s=function(t){return``+e(t)}}else{let e=r.map(o);s=function(t){let n=``+e[0](t),r=0;for(;++r{Zm(),Kh(),th(),ih()}));function Hie(e,t){let n=e[0],r=xh(e),i=+t;return r===void 0?n:i?i===1?r:n+i*(r-n):n}var Uie=o((()=>{Sh()}));function Wie(e){e=+e||Gie;let t,n,r,i=()=>{t={},n={},r=0},a=(i,a)=>(++r>e&&(n=t,t={},r=1),t[i]=a);return i(),{clear:i,has:e=>sg(t,e)||sg(n,e),get:e=>sg(t,e)?t[e]:sg(n,e)?a(e,n[e]):void 0,set:(e,n)=>sg(t,e)?t[e]=n:a(e,n)}}var Gie,Kie=o((()=>{cg(),Gie=1e4}));function qie(e){return e===Array||typeof e==`function`&&e.prototype&&ArrayBuffer.isView(e.prototype)}function Jie(e,t,n,r){let i=t.length,a=n.length;if(!a)return t;if(!i)return n;let o=t.constructor,s=r||(qie(o)?new o(i+a):Array(i+a)),c=0,l=0,u=0;for(;c0?n[l++]:t[c++];for(;c{}));function vg(e,t){let n=``;for(;--t>=0;)n+=e;return n}var Xie=o((()=>{}));function Zie(e,t,n,r){let i=n||` `,a=e+``,o=t-a.length;return o<=0?a:r===`left`?vg(i,o)+a:r===`center`?vg(i,~~(o/2))+a+vg(i,Math.ceil(o/2)):a+vg(i,o)}var Qie=o((()=>{Xie()}));function yg(e){return e&&xh(e)-e[0]||0}var $ie=o((()=>{Sh()}));function W(e){return H(e)?`[${e.map(e=>e===null?`null`:W(e))}]`:gh(e)||gg(e)?JSON.stringify(e).replaceAll(`\u2028`,`\\u2028`).replaceAll(`\u2029`,`\\u2029`):e}var eae=o((()=>{hh(),_h(),Bie()}));function bg(e){return e==null||e===``?null:!e||e===`false`||e===`0`?!1:!!e}var tae=o((()=>{}));function xg(e,t){return t||=nae,e==null||e===``?null:t(e)}var nae,rae=o((()=>{Fie(),Rie(),nae=e=>mg(e)||pg(e)?e:Date.parse(e)}));function Sg(e){return e==null||e===``?null:e+``}var iae=o((()=>{}));function Cg(e){let t={},n=e.length;for(let r=0;r{}));function oae(e,t,n,r){let i=r??`…`,a=e+``,o=a.length,s=Math.max(0,t-i.length);return o<=t?a:n===`left`?i+a.slice(o-s):n===`center`?a.slice(0,Math.ceil(s/2))+i+a.slice(o-~~(s/2)):a.slice(0,s)+i}var sae=o((()=>{}));function wg(e,t,n){if(e)if(t){let r=e.length;for(let i=0;i{})),Tg=o((()=>{Zm(),mie(),hie(),_ie(),yie(),bie(),xie(),Kh(),Sie(),Cie(),wie(),Tie(),nh(),ag(),Eie(),Oie(),kie(),oh(),jie(),cg(),Mie(),Nie(),hh(),Pie(),Fie(),Yh(),Lie(),Rie(),_h(),zie(),Bie(),Vie(),Uie(),Kie(),Yie(),Qie(),Sh(),Xie(),$ie(),ih(),eae(),tae(),rae(),wh(),iae(),aae(),sae(),cae()}));function lae(e){return Function(`d`,`return {`+e.map(function(e,t){return JSON.stringify(e)+`: d[`+t+`] || ""`}).join(`,`)+`}`)}function uae(e,t){var n=lae(e);return function(r,i){return t(n(r),i,e)}}function dae(e){var t=Object.create(null),n=[];return e.forEach(function(e){for(var r in e)r in t||n.push(t[r]=r)}),n}function Eg(e,t){var n=e+``,r=n.length;return r9999?`+`+Eg(e,6):Eg(e,4)}function pae(e){var t=e.getUTCHours(),n=e.getUTCMinutes(),r=e.getUTCSeconds(),i=e.getUTCMilliseconds();return isNaN(e)?`Invalid Date`:fae(e.getUTCFullYear(),4)+`-`+Eg(e.getUTCMonth()+1,2)+`-`+Eg(e.getUTCDate(),2)+(i?`T`+Eg(t,2)+`:`+Eg(n,2)+`:`+Eg(r,2)+`.`+Eg(i,3)+`Z`:r?`T`+Eg(t,2)+`:`+Eg(n,2)+`:`+Eg(r,2)+`Z`:n||t?`T`+Eg(t,2)+`:`+Eg(n,2)+`Z`:``)}function mae(e){var t=RegExp(`["`+e+` -\r]`),n=e.charCodeAt(0);function r(e,t){var n,r,a=i(e,function(e,i){if(n)return n(e,i-1);r=e,n=t?uae(e,t):lae(e)});return a.columns=r||[],a}function i(e,t){var r=[],i=e.length,a=0,o=0,s,c=i<=0,l=!1;e.charCodeAt(i-1)===Ag&&--i,e.charCodeAt(i-1)===jg&&--i;function u(){if(c)return Og;if(l)return l=!1,Dg;var t,r=a,o;if(e.charCodeAt(r)===kg){for(;a++=i?c=!0:(o=e.charCodeAt(a++))===Ag?l=!0:o===jg&&(l=!0,e.charCodeAt(a)===Ag&&++a),e.slice(r+1,t-1).replace(/""/g,`"`)}for(;a({key:e,label:t,type:`text`,source:`odoo`}),n=[t(`metric`,`Metric`),...e.columns.map(e=>t(`c_${e.key}`,e.partial?`${e.label} (partial)`:e.label)),t(`total`,`Total`)],r=[],i=(t,n,i)=>{let a={pid:r.length+1,metric:t,total:i};e.columns.forEach((e,t)=>{a[`c_${e.key}`]=n[t]??``}),r.push(a)};for(let t of e.rows){i(t.sublabel?`${t.label} (${t.sublabel})`:t.label,t.cells.map(e=>Um(e.value)),Um(t.total??null));for(let e of t.deltas)i(`${t.label} — ${e.label}${e.percent?` (%)`:``}`,e.values.map(t=>Wm(t,e.percent)),``)}if(e.notes.length>0){i(``,[],``);for(let t of e.notes)i(t,[],``)}return{fields:n,rows:r}}var mie={brand:[`#1F4E78`,`#C8A24B`,`#6F96B8`,`#E0C979`,`#3E6F98`,`#A17C2D`],categorical:[`#2F6B9A`,`#C28A2C`,`#4C8A68`,`#8A5C9D`,`#C25B56`,`#4B8793`,`#8B704A`,`#6A78A8`,`#A45D7D`,`#708B3D`,`#B66B32`,`#52749C`],sequential:[`#E7F0F7`,`#C5D9E9`,`#9CBCD5`,`#719DBE`,`#477CA3`,`#1F4E78`],diverging:[`#2F6B9A`,`#7EA5C3`,`#D8E4ED`,`#F0E6C6`,`#D5B66A`,`#9B7222`]};function hie(e){switch(e.axis?.y?.format){case`number`:return{format:`,.2~f`};case`currency`:return{format:`$,.0f`};case`percent`:return{labelExpr:`format(datum.value, ',.2~f') + '%'`};case`compact`:return{format:`~s`};default:return{}}}function gie(e,t){let n=new Map(e.xOrder.map((e,t)=>[e,t])),r=new Map(e.seriesOrder.map((e,t)=>[e,t]));return e.points.map(e=>({xKey:e.key,xLabel:e.label,xIndex:n.get(e.key)??0,value:e.value,valueText:t(e.value),n:e.n,seriesKey:e.seriesKey,seriesLabel:e.seriesLabel,seriesIndex:r.get(e.seriesKey)??0}))}function _ie(){return{font:`Inter, ui-sans-serif, system-ui, sans-serif`,view:{stroke:null},axis:{labelColor:`#536273`,labelFont:`Inter, ui-sans-serif, system-ui, sans-serif`,labelFontSize:10,labelLimit:110,titleColor:`#344355`,titleFont:`Inter, ui-sans-serif, system-ui, sans-serif`,titleFontSize:11,titleFontWeight:500,gridColor:`#E7EBEF`,domainColor:`#C9D1D9`,tickColor:`#C9D1D9`},legend:{labelColor:`#536273`,labelFont:`Inter, ui-sans-serif, system-ui, sans-serif`,labelFontSize:10,titleColor:`#344355`,titleFont:`Inter, ui-sans-serif, system-ui, sans-serif`,titleFontSize:10,symbolType:`circle`,orient:`bottom`,direction:`horizontal`}}}function vie(e,t){return{$schema:`https://vega.github.io/schema/vega-lite/v6.json`,data:{values:t},width:`container`,height:`container`,autosize:{type:`fit`,contains:`padding`,resize:!0},padding:4,config:_ie(),usermeta:{rendererBoundary:`aios-chart-spec-v1`,chartId:e.id}}}function th(e){return[{field:`xLabel`,type:`nominal`,title:`Group`},...e?[{field:`seriesLabel`,type:`nominal`,title:`Series`}]:[],{field:`valueText`,type:`nominal`,title:`Value`},{field:`n`,type:`quantitative`,title:`Records`,format:`,`}]}function nh({spec:e,model:t,xTitle:n,yTitle:r,formatValue:i}){let a=gie(t,i).filter(t=>e.kind!==`donut`||t.value>0),o=[...mie[e.palette??`brand`]],s=t.seriesOrder.length>0,c=s?{field:`seriesLabel`,type:`nominal`,title:null,sort:{field:`seriesIndex`,op:`min`},scale:{range:o},legend:{columns:4}}:{value:o[0]},l={field:`xLabel`,type:`nominal`,title:n??null,sort:{field:`xIndex`,op:`min`,order:`ascending`},axis:{labelAngle:t.xOrder.length>7?-35:0,labelOverlap:`greedy`}},u={field:`value`,type:`quantitative`,title:r??null,axis:hie(e)},d=vie(e,a);if(e.kind===`kpi`)return{...d,mark:{type:`text`,align:`center`,baseline:`middle`,font:`Inter, ui-sans-serif, system-ui, sans-serif`,fontSize:32,fontWeight:600,color:`#172433`},encoding:{text:{field:`valueText`,type:`nominal`},tooltip:[{field:`valueText`,type:`nominal`,title:`Value`},{field:`n`,type:`quantitative`,title:`Records`,format:`,`}]}};if(e.kind===`donut`)return{...d,mark:{type:`arc`,innerRadius:44,outerRadius:76,cornerRadius:2,padAngle:.01},encoding:{theta:{field:`value`,type:`quantitative`,stack:!0},color:{field:`xLabel`,type:`nominal`,title:null,sort:{field:`xIndex`,op:`min`},scale:{range:o},legend:{orient:`right`,direction:`vertical`,labelLimit:110}},order:{field:`xIndex`,type:`quantitative`},tooltip:th(!1)}};let f={x:l,y:{...u,stack:(e.kind===`bar`||e.kind===`area`)&&s?e.stacked?`zero`:null:void 0},color:c,tooltip:th(s)};return s&&e.kind===`bar`&&!e.stacked&&(f.xOffset={field:`seriesLabel`,type:`nominal`,sort:{field:`seriesIndex`,op:`min`}}),(e.kind===`line`||e.kind===`area`)&&(f.order={field:`xIndex`,type:`quantitative`},s&&(f.detail={field:`seriesKey`,type:`nominal`})),{...d,mark:e.kind===`bar`?{type:`bar`,cornerRadiusTopLeft:2,cornerRadiusTopRight:2}:e.kind===`area`?{type:`area`,opacity:s?.68:.48,line:!0,point:!0}:{type:`line`,strokeWidth:2,point:{filled:!0,size:46}},encoding:f}}function rh(e,t={}){let n=JSON.stringify([1],void 0,t.indent===void 0?2:t.indent).slice(2,-3),r=n===``?1/0:t.maxLength===void 0?80:t.maxLength,{replacer:i}=t;return(function e(t,a,o){t&&typeof t.toJSON==`function`&&(t=t.toJSON());let s=JSON.stringify(t,i);if(s===void 0)return s;let c=r-a.length-o;if(s.length<=c){let e=s.replace(ih,(e,t)=>t||`${e} `);if(e.length<=c)return e}if(i!=null&&(t=JSON.parse(s),i=void 0),typeof t==`object`&&t){let r=a+n,i=[],o=0,s,c;if(Array.isArray(t)){s=`[`,c=`]`;let{length:n}=t;for(;o0)return[s,n+i.join(`,\n${r}`),c].join(`\n${a}`)}return s})(e,``,0)}var ih,yie=o((()=>{ih=/("(?:[^\\"]|\\.)*")|[:,]/g}));function ah(e,t,n){return Object.assign(e,{fields:t||[],fname:n})}function oh(e){return e==null?null:e.fname}function sh(e){return e==null?null:e.fields}var ch=o((()=>{}));function lh(e){return e.length===1?uh(e[0]):dh(e)}var uh,dh,fh=o((()=>{uh=e=>function(t){return t[e]},dh=e=>{let t=e.length;return function(n){for(let r=0;r{}));function mh(e){let t=[],n=e.length,r=null,i=0,a=``,o,s,c;e+=``;function l(){t.push(a+e.substring(o,s)),a=``,o=s+1}for(o=s=0;so?l():o=s+1:c===`[`?(s>o&&l(),i=o=s+1):c===`]`&&(i||V(`Access path missing open bracket: `+e),i>0&&l(),i=0,o=s+1);return i&&V(`Access path missing closing bracket: `+e),r&&V(`Access path missing closing quote: `+e),s>o&&(s++,l()),t}var hh=o((()=>{ph()}));function gh(e,t,n){let r=mh(e),i=r.length===1?r[0]:e;return ah((n&&n.get||lh)(r),[i],t||i)}var _h=o((()=>{ch(),fh(),hh()})),vh,yh,bh,xh,Sh,Ch,bie=o((()=>{ch(),_h(),vh=gh(`id`),yh=ah(e=>e,[],`identity`),bh=ah(()=>0,[],`zero`),xh=ah(()=>1,[],`one`),Sh=ah(()=>!0,[],`true`),Ch=ah(()=>!1,[],`false`)})),wh,xie=o((()=>{wh=new Set([...Object.getOwnPropertyNames(Object.prototype).filter(e=>typeof Object.prototype[e]==`function`),`__proto__`])}));function Sie(e,t,n){let r=[t,...n];console[e](...r)}function Th(e,t,n=Sie){let r=e||0;return{level(e){return arguments.length?(r=+e,this):r},error(...e){return r>=1&&n(t||`error`,`ERROR`,e),this},warn(...e){return r>=2&&n(t||`warn`,`WARN`,e),this},info(...e){return r>=3&&n(t||`log`,`INFO`,e),this},debug(...e){return r>=4&&n(t||`log`,`DEBUG`,e),this}}}var Cie=o((()=>{})),H,Eh=o((()=>{H=Array.isArray}));function Dh(e){return e===Object(e)}var Oh=o((()=>{}));function kh(...e){return e.reduce((e,t)=>{for(let n in t)if(n===`signals`)e.signals=wie(e.signals,t.signals);else{let r=n===`legend`?{layout:1}:n===`style`||null;Ah(e,n,t[n],r)}return e},{})}function Ah(e,t,n,r){if(!jh(t))return;let i=e,a,o;if(Dh(n)&&!H(n)){let e=n;for(a in o=Dh(i[t])?i[t]:i[t]={},e)r&&(r===!0||r[a])?Ah(o,a,e[a]):jh(a)&&(o[a]=e[a])}else i[t]=n}function wie(e,t){if(e==null)return t;if(t==null)return e;let n={},r=[];function i(e){n[e.name]||(n[e.name]=1,r.push(e))}return t.forEach(i),e.forEach(i),r}var jh,Tie=o((()=>{Eh(),Oh(),jh=e=>e!==`__proto__`&&e!==`constructor`&&e!==`prototype`}));function Mh(e){return e[e.length-1]}var Nh=o((()=>{}));function Ph(e){return e==null||e===``?null:+e}var Fh=o((()=>{}));function Ih(e){return e.length>0}function Lh(e,t,n,r){Ih(e)||V(`Domain array must not be empty`);let i=n(e[0]),a=n(Mh(e)),o=(a-i)*t;return[r(i-o),r(a-o)]}function Rh(e,t){return Lh(e,t,Qh,$h)}function zh(e,t){let n=Math.sign(e[0]);return Lh(e,t,Jh(n),qh(n))}function Bh(e,t,n){return Lh(e,t,Zh(n),Zh(1/n))}function Vh(e,t,n){return Lh(e,t,Yh(n),Xh(n))}function Hh(e,t,n,r,i){Ih(e)||V(`Domain array must not be empty`);let a=r(e[0]),o=r(Mh(e)),s=t==null?(a+o)/2:r(t);return[i(s+(a-s)*n),i(s+(o-s)*n)]}function Uh(e,t,n){return Hh(e,t,n,Qh,$h)}function Wh(e,t,n){let r=Math.sign(e[0]);return Hh(e,t,n,Jh(r),qh(r))}function Gh(e,t,n,r){return Hh(e,t,n,Zh(r),Zh(1/r))}function Kh(e,t,n,r){return Hh(e,t,n,Yh(r),Xh(r))}var qh,Jh,Yh,Xh,Zh,Qh,$h,Eie=o((()=>{ph(),Nh(),Fh(),qh=e=>t=>e*Math.exp(t),Jh=e=>t=>Math.log(e*t),Yh=e=>t=>Math.sign(t)*Math.log1p(Math.abs(t/e)),Xh=e=>t=>Math.sign(t)*Math.expm1(Math.abs(t))*e,Zh=e=>t=>t<0?-((-t)**+e):t**+e,Qh=e=>Ph(e)??0,$h=e=>e}));function eg(e){return 1+~~(new Date(e).getMonth()/3)}function tg(e){return 1+~~(new Date(e).getUTCMonth()/3)}var Die=o((()=>{}));function ng(e){return e==null?[]:H(e)?e:[e]}var rg=o((()=>{Eh()}));function Oie(e,t,n){let r=e[0],i=e[1],a;return i=n-t?[t,n]:[r=Math.min(Math.max(r,t),n-a),r+a]}var kie=o((()=>{}));function ig(e){return typeof e==`function`}var ag=o((()=>{}));function og(e,t,n){let r=n||{},i=ng(t)||[],a=[],o=[],s={},c=r.comparator||jie;return ng(e).forEach((e,t)=>{if(e==null)return;a.push(i[t]===Aie?-1:1);let n=ig(e)?e:gh(e,void 0,r);o.push(n),(sh(n)||[]).forEach(e=>s[e]=1)}),o.length===0?null:ah(c(o,a),Object.keys(s))}var Aie,sg,jie,Mie,Nie,Pie=o((()=>{ch(),rg(),_h(),ag(),Aie=`descending`,sg=(e,t)=>{let n=e,r=t;return(nr||r==null)&&n!=null?1:(r=r instanceof Date?+r:r,n=n instanceof Date?+n:n)!==n&&r===r?-1:+(r!==r&&n===n)},jie=(e,t)=>e.length===1?Mie(e[0],t[0]):Nie(e,t,e.length),Mie=(e,t)=>function(n,r){return sg(e(n),e(r))*t},Nie=(e,t,n)=>(t.push(0),function(r,i){let a,o=0,s=-1;for(;o===0&&++se}var Fie=o((()=>{ag()}));function lg(e,t){let n=null;return r=>{n&&clearTimeout(n),n=setTimeout(()=>(t(r),n=null),e)}}var Iie=o((()=>{}));function ug(e,...t){for(let n of t)for(let t in n)e[t]=n[t];return e}var Lie=o((()=>{}));function dg(e,t){let n=0,r,i,a,o;if(e&&(r=e.length))if(t==null){for(i=e[n];no&&(o=i))}else{for(i=t(e[n]);no&&(o=i))}return[a,o]}var Rie=o((()=>{}));function zie(e,t){let n=e.length,r=-1,i,a,o,s,c;if(t==null){for(;++r=s){o=c=s;break}if(r===n)return[-1,-1];for(i=a=r;++rs&&(o=s,i=r),c=s){o=c=s;break}if(r===n)return[-1,-1];for(i=a=r;++rs&&(o=s,i=r),c{}));function fg(e,t){return Object.hasOwn(e,t)}var pg=o((()=>{}));function mg(e){let t={},n;function r(e){return fg(t,e)&&t[e]!==hg}let i={size:0,empty:0,object:t,has:r,get(e){return r(e)?t[e]:void 0},set(e,n){return r(e)||(++i.size,t[e]===hg&&--i.empty),t[e]=n,this},delete(e){return r(e)&&(--i.size,++i.empty,t[e]=hg),this},clear(){i.size=i.empty=0,i.object=t={}},test(e){return arguments.length?(n=e,i):n},clean(){let e={},r=0;for(let i in t){let a=t[i];a!==hg&&(!n||!n(a))&&(e[i]=a,++r)}i.size=r,i.empty=0,i.object=t=e}};return e&&Object.keys(e).forEach(t=>{i.set(t,e[t])}),i}var hg,Vie=o((()=>{pg(),hg={}}));function Hie(e,t,n,r,i,a){if(!n&&n!==0)return a;let o=+n,s=e[0],c=Mh(e),l;if(c===void 0)return a;c{Nh()}));function U(e,t,n){let r=e.prototype=Object.create(t.prototype);return Object.defineProperty(r,"constructor",{value:e,writable:!0,enumerable:!0,configurable:!0}),ug(r,n)}var Wie=o((()=>{Lie()}));function gg(e,t,n,r){let i=t[0],a=t[t.length-1],o;return i>a&&(o=i,i=a,a=o),n=n===void 0||n,r=r===void 0||r,(n?i<=e:i{}));function _g(e){return typeof e==`boolean`}var Kie=o((()=>{}));function vg(e){return Object.prototype.toString.call(e)===`[object Date]`}var qie=o((()=>{}));function Jie(e){return e!=null&&ig(e[Symbol.iterator])}var Yie=o((()=>{ag()}));function yg(e){return typeof e==`number`}var Xie=o((()=>{}));function bg(e){return Object.prototype.toString.call(e)===`[object RegExp]`}var Zie=o((()=>{}));function xg(e){return typeof e==`string`}var Qie=o((()=>{}));function Sg(e,t,n){let r=e?t?ng(e).map(e=>e.replace(/\\(.)/g,`$1`)):ng(e):void 0,i=r?.length,a=n&&n.get||lh,o=e=>a(t?[e]:mh(e)),s;if(!i||!r)s=function(){return``};else if(i===1){let e=o(r[0]);s=function(t){return``+e(t)}}else{let e=r.map(o);s=function(t){let n=``+e[0](t),r=0;for(;++r{ch(),rg(),fh(),hh()}));function eae(e,t){let n=e[0],r=Mh(e),i=+t;return r===void 0?n:i?i===1?r:n+i*(r-n):n}var tae=o((()=>{Nh()}));function nae(e){e=+e||rae;let t,n,r,i=()=>{t={},n={},r=0},a=(i,a)=>(++r>e&&(n=t,t={},r=1),t[i]=a);return i(),{clear:i,has:e=>fg(t,e)||fg(n,e),get:e=>fg(t,e)?t[e]:fg(n,e)?a(e,n[e]):void 0,set:(e,n)=>fg(t,e)?t[e]=n:a(e,n)}}var rae,iae=o((()=>{pg(),rae=1e4}));function aae(e){return e===Array||typeof e==`function`&&e.prototype&&ArrayBuffer.isView(e.prototype)}function oae(e,t,n,r){let i=t.length,a=n.length;if(!a)return t;if(!i)return n;let o=t.constructor,s=r||(aae(o)?new o(i+a):Array(i+a)),c=0,l=0,u=0;for(;c0?n[l++]:t[c++];for(;c{}));function Cg(e,t){let n=``;for(;--t>=0;)n+=e;return n}var cae=o((()=>{}));function lae(e,t,n,r){let i=n||` `,a=e+``,o=t-a.length;return o<=0?a:r===`left`?Cg(i,o)+a:r===`center`?Cg(i,~~(o/2))+a+Cg(i,Math.ceil(o/2)):a+Cg(i,o)}var uae=o((()=>{cae()}));function wg(e){return e&&Mh(e)-e[0]||0}var dae=o((()=>{Nh()}));function W(e){return H(e)?`[${e.map(e=>e===null?`null`:W(e))}]`:Dh(e)||xg(e)?JSON.stringify(e).replaceAll(`\u2028`,`\\u2028`).replaceAll(`\u2029`,`\\u2029`):e}var fae=o((()=>{Eh(),Oh(),Qie()}));function Tg(e){return e==null||e===``?null:!e||e===`false`||e===`0`?!1:!!e}var pae=o((()=>{}));function Eg(e,t){return t||=mae,e==null||e===``?null:t(e)}var mae,hae=o((()=>{qie(),Xie(),mae=e=>yg(e)||vg(e)?e:Date.parse(e)}));function Dg(e){return e==null||e===``?null:e+``}var gae=o((()=>{}));function Og(e){let t={},n=e.length;for(let r=0;r{}));function vae(e,t,n,r){let i=r??`…`,a=e+``,o=a.length,s=Math.max(0,t-i.length);return o<=t?a:n===`left`?i+a.slice(o-s):n===`center`?a.slice(0,Math.ceil(s/2))+i+a.slice(o-~~(s/2)):a.slice(0,s)+i}var yae=o((()=>{}));function kg(e,t,n){if(e)if(t){let r=e.length;for(let i=0;i{})),Ag=o((()=>{ch(),bie(),xie(),Cie(),Tie(),Eie(),Die(),rg(),kie(),Pie(),Fie(),Iie(),ph(),Lie(),Rie(),Bie(),Vie(),_h(),Uie(),pg(),Wie(),Gie(),Eh(),Kie(),qie(),ag(),Yie(),Xie(),Oh(),Zie(),Qie(),$ie(),tae(),iae(),sae(),uae(),Nh(),cae(),dae(),hh(),fae(),pae(),hae(),Fh(),gae(),_ae(),yae(),bae()}));function xae(e){return Function(`d`,`return {`+e.map(function(e,t){return JSON.stringify(e)+`: d[`+t+`] || ""`}).join(`,`)+`}`)}function Sae(e,t){var n=xae(e);return function(r,i){return t(n(r),i,e)}}function Cae(e){var t=Object.create(null),n=[];return e.forEach(function(e){for(var r in e)r in t||n.push(t[r]=r)}),n}function jg(e,t){var n=e+``,r=n.length;return r9999?`+`+jg(e,6):jg(e,4)}function Tae(e){var t=e.getUTCHours(),n=e.getUTCMinutes(),r=e.getUTCSeconds(),i=e.getUTCMilliseconds();return isNaN(e)?`Invalid Date`:wae(e.getUTCFullYear(),4)+`-`+jg(e.getUTCMonth()+1,2)+`-`+jg(e.getUTCDate(),2)+(i?`T`+jg(t,2)+`:`+jg(n,2)+`:`+jg(r,2)+`.`+jg(i,3)+`Z`:r?`T`+jg(t,2)+`:`+jg(n,2)+`:`+jg(r,2)+`Z`:n||t?`T`+jg(t,2)+`:`+jg(n,2)+`Z`:``)}function Eae(e){var t=RegExp(`["`+e+` +\r]`),n=e.charCodeAt(0);function r(e,t){var n,r,a=i(e,function(e,i){if(n)return n(e,i-1);r=e,n=t?Sae(e,t):xae(e)});return a.columns=r||[],a}function i(e,t){var r=[],i=e.length,a=0,o=0,s,c=i<=0,l=!1;e.charCodeAt(i-1)===Fg&&--i,e.charCodeAt(i-1)===Ig&&--i;function u(){if(c)return Ng;if(l)return l=!1,Mg;var t,r=a,o;if(e.charCodeAt(r)===Pg){for(;a++=i?c=!0:(o=e.charCodeAt(a++))===Fg?l=!0:o===Ig&&(l=!0,e.charCodeAt(a)===Fg&&++a),e.slice(r+1,t-1).replace(/""/g,`"`)}for(;a{Dg={},Og={},kg=34,Ag=10,jg=13})),gae=o((()=>{hae()}));function _ae(e){return e}var vae=o((()=>{}));function yae(e){if(e==null)return _ae;var t,n,r=e.scale[0],i=e.scale[1],a=e.translate[0],o=e.translate[1];return function(e,s){s||(t=n=0);var c=2,l=e.length,u=Array(l);for(u[0]=(t+=e[0])*r+a,u[1]=(n+=e[1])*i+o;c{vae()}));function xae(e,t){for(var n,r=e.length,i=r-t;i<--r;)n=e[i],e[i++]=e[r],e[r]=n}var Sae=o((()=>{}));function Cae(e,t){return typeof t==`string`&&(t=e.objects[t]),t.type===`GeometryCollection`?{type:`FeatureCollection`,features:t.geometries.map(function(t){return wae(e,t)})}:wae(e,t)}function wae(e,t){var n=t.id,r=t.bbox,i=t.properties==null?{}:t.properties,a=Tae(e,t);return n==null&&r==null?{type:`Feature`,properties:i,geometry:a}:r==null?{type:`Feature`,id:n,properties:i,geometry:a}:{type:`Feature`,id:n,bbox:r,properties:i,geometry:a}}function Tae(e,t){var n=yae(e.transform),r=e.arcs;function i(e,t){t.length&&t.pop();for(var i=r[e<0?~e:e],a=0,o=i.length;a{Sae(),bae()}));function Dae(e,t){var n={},r={},i={},a=[],o=-1;t.forEach(function(n,r){var i=e.arcs[n<0?~n:n],a;i.length<3&&!i[1][0]&&!i[1][1]&&(a=t[++o],t[o]=n,t[r]=a)}),t.forEach(function(e){var t=s(e),n=t[0],a=t[1],o,c;if(o=i[n])if(delete i[o.end],o.push(e),o.end=a,c=r[a]){delete r[c.start];var l=c===o?o:o.concat(c);r[l.start=o.start]=i[l.end=c.end]=l}else r[o.start]=i[o.end]=o;else if(o=r[a])if(delete r[o.start],o.unshift(e),o.start=n,c=i[n]){delete i[c.end];var u=c===o?o:c.concat(o);r[u.start=c.start]=i[u.end=o.end]=u}else r[o.start]=i[o.end]=o;else o=[e],r[o.start=n]=i[o.end=a]=o});function s(t){var n=e.arcs[t<0?~t:t],r=n[0],i;return e.transform?(i=[0,0],n.forEach(function(e){i[0]+=e[0],i[1]+=e[1]})):i=n[n.length-1],t<0?[i,r]:[r,i]}function c(e,t){for(var r in e){var i=e[r];delete t[i.start],delete i.start,delete i.end,i.forEach(function(e){n[e<0?~e:e]=1}),a.push(i)}}return c(i,r),c(r,i),t.forEach(function(e){n[e<0?~e:e]||a.push([e])}),a}var Oae=o((()=>{}));function kae(e){return Tae(e,Aae.apply(this,arguments))}function Aae(e,t,n){var r,i,a;if(arguments.length>1)r=jae(e,t,n);else for(i=0,r=Array(a=e.arcs.length);i{Eae(),Oae()})),Nae=o((()=>{bae(),Eae(),Mae(),Oae(),vae()}));function Mg(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}var Ng=o((()=>{}));function Pae(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}var Fae=o((()=>{}));function Pg(e){let t,n,r;e.length===2?(t=e===Mg||e===Pae?e:Iae,n=e,r=e):(t=Mg,n=(t,n)=>Mg(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i>>1;n(e[t],r)<0?i=t+1:a=t}while(i>>1;n(e[t],r)<=0?i=t+1:a=t}while(in&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function Iae(){return 0}var Lae=o((()=>{Ng(),Fae()}));function Rae(e){return e===null?NaN:+e}function*zae(e,t){if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)(r=t(r,++n,e))!=null&&(r=+r)>=r&&(yield r)}}var Bae=o((()=>{})),Fg,Ig,Lg,Vae=o((()=>{Ng(),Lae(),Bae(),Fg=Pg(Mg),Ig=Fg.right,Lg=Fg.left,Pg(Rae).center}));function Hae(e,t){let n=0,r,i=0,a=0;if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(r=t-i,i+=r/++n,a+=r*(t-i));else{let o=-1;for(let s of e)(s=t(s,++o,e))!=null&&(s=+s)>=s&&(r=s-i,i+=r/++n,a+=r*(s-i))}if(n>1)return a/(n-1)}var Uae=o((()=>{}));function Wae(e,t){let n=Hae(e,t);return n&&Math.sqrt(n)}var Gae=o((()=>{Uae()})),Rg,Kae=o((()=>{Rg=class{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){let t=this._partials,n=0;for(let r=0;r0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,i=r-(a-n),!i););t>0&&(i<0&&e[t-1]<0||i>0&&e[t-1]>0)&&(r=i*2,n=a+r,r==n-a&&(a=n))}return a}}}));function zg({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function qae({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function Jae({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Yae(e){return typeof e==`object`&&e?e.valueOf():e}var Bg,Vg,Hg=o((()=>{Bg=class extends Map{constructor(e,t=Yae){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(zg(this,e))}has(e){return super.has(zg(this,e))}set(e,t){return super.set(qae(this,e),t)}delete(e){return super.delete(Jae(this,e))}},Vg=class extends Set{constructor(e,t=Yae){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let t of e)this.add(t)}has(e){return super.has(zg(this,e))}add(e){return super.add(qae(this,e))}delete(e){return super.delete(Jae(this,e))}}}));function Xae(e,t){return Array.from(t,t=>e[t])}var Zae=o((()=>{}));function Qae(e=Mg){if(e===Mg)return $ae;if(typeof e!=`function`)throw TypeError(`compare is not a function`);return(t,n)=>{let r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function $ae(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et))}var eoe=o((()=>{Ng()}));function Ug(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=toe?10:a>=noe?5:a>=roe?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/lt&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*lt&&--c),c0))return[];if(e===t)return[e];let r=t=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e{toe=Math.sqrt(50),noe=Math.sqrt(10),roe=Math.sqrt(2)}));function qg(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n=i)&&(n=i)}return n}var aoe=o((()=>{}));function Jg(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n>t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}var ooe=o((()=>{}));function soe(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?$ae:Qae(i);r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1),u=Math.max(n,Math.floor(t-o*c/a+l)),d=Math.min(r,Math.floor(t+(a-o)*c/a+l));soe(e,t,u,d,i)}let a=e[t],o=n,s=r;for(Yg(e,n,t),i(e[r],a)>0&&Yg(e,n,r);o0;)--s}i(e[n],a)===0?Yg(e,n,s):(++s,Yg(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}return e}function Yg(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}var coe=o((()=>{eoe()}));function Xg(e,t,n){if(e=Float64Array.from(zae(e,n)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return Jg(e);if(t>=1)return qg(e);var r,i=(r-1)*t,a=Math.floor(i),o=qg(soe(e,a).subarray(0,a+1));return o+(Jg(e.subarray(a+1))-o)*(i-a)}}function loe(e,t,n=Rae){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}var uoe=o((()=>{aoe(),ooe(),coe(),Bae()}));function doe(e,t){let n=0,r=0;if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(++n,r+=t);else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(a=+a)>=a&&(++n,r+=a)}if(n)return r/n}var foe=o((()=>{}));function poe(e,t){return Xg(e,.5,t)}var moe=o((()=>{uoe()}));function*hoe(e){for(let t of e)yield*t}function goe(e){return Array.from(hoe(e))}var _oe=o((()=>{}));function Zg(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r{}));function yoe(e,t){let n=0;if(t===void 0)for(let t of e)(t=+t)&&(n+=t);else{let r=-1;for(let i of e)(i=+t(i,++r,e))&&(n+=i)}return n}var boe=o((()=>{}));function xoe(e,...t){e=new Vg(e),t=t.map(Soe);out:for(let n of e)for(let r of t)if(!r.has(n)){e.delete(n);continue out}return e}function Soe(e){return e instanceof Vg?e:new Vg(e)}var Coe=o((()=>{Hg()}));function woe(...e){let t=new Vg;for(let n of e)for(let e of n)t.add(e);return t}var Toe=o((()=>{Hg()})),Qg=o((()=>{Vae(),Ng(),Lae(),Fae(),Gae(),Kae(),Hg(),eoe(),ioe(),uoe(),aoe(),foe(),moe(),_oe(),ooe(),Zae(),coe(),voe(),boe(),Uae(),Coe(),Toe()}));function Eoe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function $g(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}var e_=o((()=>{}));function t_(e){return e=$g(Math.abs(e)),e?e[1]:NaN}var n_=o((()=>{e_()}));function Doe(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}var Ooe=o((()=>{}));function koe(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var Aoe=o((()=>{}));function r_(e){if(!(t=joe.exec(e)))throw Error(`invalid format: `+e);var t;return new i_({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function i_(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}var joe,Moe=o((()=>{joe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i,r_.prototype=i_.prototype,i_.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type}}));function Noe(e){out:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var Poe=o((()=>{}));function Foe(e,t){var n=$g(e,t);if(!n)return a_=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(a_=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+$g(e,Math.max(0,t+a-1))[0]}var a_,Ioe=o((()=>{e_()}));function Loe(e,t){var n=$g(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var Roe=o((()=>{e_()})),o_,zoe=o((()=>{e_(),Ioe(),Roe(),o_={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:Eoe,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Loe(e*100,t),r:Loe,s:Foe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)}}));function Boe(e){return e}var Voe=o((()=>{}));function Hoe(e){var t=e.grouping===void 0||e.thousands===void 0?Boe:Doe(s_.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?Boe:koe(s_.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=r_(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):o_[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=o_[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=Noe(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&a_!==void 0?c_[8+a_/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++op||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(t_(t)/3)))*3,r=10**-n,i=l((e=r_(e),e.type=`f`,e),{suffix:c_[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var s_,c_,Uoe=o((()=>{n_(),Ooe(),Aoe(),Moe(),Poe(),zoe(),Ioe(),Voe(),s_=Array.prototype.map,c_=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`]}));function Woe(e){return l_=Hoe(e),u_=l_.format,d_=l_.formatPrefix,l_}var l_,u_,d_,Goe=o((()=>{Uoe(),Woe({thousands:`,`,grouping:[3],currency:[`$`,``]})}));function Koe(e){return Math.max(0,-t_(Math.abs(e)))}var qoe=o((()=>{n_()}));function Joe(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(t_(t)/3)))*3-t_(Math.abs(e)))}var Yoe=o((()=>{n_()}));function Xoe(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,t_(t)-t_(e))+1}var Zoe=o((()=>{n_()})),f_=o((()=>{Goe(),Uoe(),Moe(),qoe(),Yoe(),Zoe()}));function p_(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(sp_(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}),n&&(i.count=(t,r)=>(m_.setTime(+t),h_.setTime(+r),e(m_),e(h_),Math.floor(n(m_,h_))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var m_,h_,g_=o((()=>{m_=new Date,h_=new Date})),__,Qoe=o((()=>{g_(),__=p_(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e),__.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?p_(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):__),__.range})),v_,y_,b_,x_,S_,C_,w_,T_=o((()=>{v_=1e3,y_=v_*60,b_=y_*60,x_=b_*24,S_=x_*7,C_=x_*30,w_=x_*365})),E_,$oe=o((()=>{g_(),T_(),E_=p_(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*v_)},(e,t)=>(t-e)/v_,e=>e.getUTCSeconds()),E_.range})),D_,O_,k_=o((()=>{g_(),T_(),D_=p_(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*v_)},(e,t)=>{e.setTime(+e+t*y_)},(e,t)=>(t-e)/y_,e=>e.getMinutes()),D_.range,O_=p_(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*y_)},(e,t)=>(t-e)/y_,e=>e.getUTCMinutes()),O_.range})),A_,j_,M_=o((()=>{g_(),T_(),A_=p_(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*v_-e.getMinutes()*y_)},(e,t)=>{e.setTime(+e+t*b_)},(e,t)=>(t-e)/b_,e=>e.getHours()),A_.range,j_=p_(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*b_)},(e,t)=>(t-e)/b_,e=>e.getUTCHours()),j_.range})),N_,P_,F_,I_=o((()=>{g_(),T_(),N_=p_(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*y_)/x_,e=>e.getDate()-1),N_.range,P_=p_(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/x_,e=>e.getUTCDate()-1),P_.range,F_=p_(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/x_,e=>Math.floor(e/x_)),F_.range}));function L_(e){return p_(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*y_)/S_)}function R_(e){return p_(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/S_)}var z_,B_,V_,H_,U_,W_,G_,K_,q_,J_,Y_,X_,Z_,Q_,$_=o((()=>{g_(),T_(),z_=L_(0),B_=L_(1),V_=L_(2),H_=L_(3),U_=L_(4),W_=L_(5),G_=L_(6),z_.range,B_.range,V_.range,H_.range,U_.range,W_.range,G_.range,K_=R_(0),q_=R_(1),J_=R_(2),Y_=R_(3),X_=R_(4),Z_=R_(5),Q_=R_(6),K_.range,q_.range,J_.range,Y_.range,X_.range,Z_.range,Q_.range})),ev,tv,nv=o((()=>{g_(),ev=p_(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth()),ev.range,tv=p_(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth()),tv.range})),rv,iv,av=o((()=>{g_(),rv=p_(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear()),rv.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:p_(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),rv.range,iv=p_(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear()),iv.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:p_(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),iv.range}));function ov(e,t,n,r,i,a){let o=[[E_,1,v_],[E_,5,5*v_],[E_,15,15*v_],[E_,30,30*v_],[a,1,y_],[a,5,5*y_],[a,15,15*y_],[a,30,30*y_],[i,1,b_],[i,3,3*b_],[i,6,6*b_],[i,12,12*b_],[r,1,x_],[r,2,2*x_],[n,1,S_],[t,1,C_],[t,3,3*C_],[e,1,w_]];function s(e,t,n){let r=te).right(o,i);if(a===o.length)return e.every(Kg(t/w_,n/w_,r));if(a===0)return __.every(Math.max(Kg(t,n,r),1));let[s,c]=o[i/o[a-1][2]{Qg(),T_(),Qoe(),$oe(),k_(),M_(),I_(),$_(),nv(),av(),[sv,cv]=ov(iv,tv,K_,F_,j_,O_),[lv,uv]=ov(rv,ev,z_,N_,A_,D_)})),dv=o((()=>{g_(),Qoe(),$oe(),k_(),M_(),I_(),$_(),nv(),av(),ese()}));function fv(e){let t=Gh(e).slice(),n={};return t.length||V(`Missing time unit.`),t.forEach(e=>{sg(Xv,e)?n[e]=1:V(`Invalid time unit: ${e}.`)}),(n.week||n.day?1:0)+(n.quarter||n.month||n.date?1:0)+ +!!n.dayofyear>1&&V(`Incompatible time units: ${e}`),t.sort((e,t)=>Xv[e]-Xv[t]),t}function pv(e,t){let n=ig({},Zv,t),r=fv(e),i=r.length,a=``,o=0,s,c;for(o=0;oo;--s)if(c=r.slice(o,s).join(`-`),n[c]!=null){a+=n[c],o=s;break}return a.trim()}function mv(e){return Qv.setFullYear(e),Qv.setMonth(0),Qv.setDate(1),Qv.setHours(0,0,0,0),Qv}function hv(e){return _v(new Date(e))}function gv(e){return vv(new Date(e))}function _v(e){return N_.count(mv(e.getFullYear())-1,e)}function vv(e){return z_.count(mv(e.getFullYear())-1,e)}function yv(e){return mv(e).getDay()}function tse(e,t,n,r,i,a,o){if(0<=e&&e<100){let s=new Date(-1,t,n,r,i,a,o);return s.setFullYear(e),s}return new Date(e,t,n,r,i,a,o)}function bv(e){return Sv(new Date(e))}function xv(e){return Cv(new Date(e))}function Sv(e){let t=Date.UTC(e.getUTCFullYear(),0,1);return P_.count(t-1,e)}function Cv(e){let t=Date.UTC(e.getUTCFullYear(),0,1);return K_.count(t-1,e)}function wv(e){return Qv.setTime(Date.UTC(e,0,1)),Qv.getUTCDay()}function nse(e,t,n,r,i,a,o){if(0<=e&&e<100){let e=new Date(Date.UTC(-1,t,n,r,i,a,o));return e.setUTCFullYear(n.y),e}return new Date(Date.UTC(e,t,n,r,i,a,o))}function Tv(e,t,n,r,i){let a=t||1,o=xh(e),s=(e,t,i)=>(i||=e,rse(n[i],r[i],e===o&&a,t)),c=new Date,l=Cg(e),u=l.year?s(zv):ng(2012),d=l.month?s(Vv):l.quarter?s(Bv):lh,f=l.week&&l.day?s(`day`,1,`weekday`):l.week?s(Hv,1):l.day?s(`day`,1):l.date?s(Uv,1):l.dayofyear?s(Wv,1):uh,p=l.hours?s(Gv):lh,m=l.minutes?s(Kv):lh,h=l.seconds?s(qv):lh,g=l.milliseconds?s(Jv):lh;return function(e){c.setTime(+e);let t=u(c);return i(t,d(c),f(c,t),p(c),m(c),h(c),g(c))}}function rse(e,t,n,r){let i=n<=1?e:r?(t,i)=>r+n*Math.floor((e(t,i)-r)/n):(t,r)=>n*Math.floor(e(t,r)/n);return t?(e,n)=>t(i(e,n),n):i}function Ev(e,t,n){return t+e*7-(n+6)%7}function Dv(e,t){return Tv(e,t||1,$v,ey,tse)}function Ov(e,t){return Tv(e,t||1,ty,ny,nse)}function kv(e){return ry[e]}function Av(e){return iy[e]}function jv(e,t,n){return e?e.offset(t,n):void 0}function Mv(e,t,n){return jv(kv(e),t,n)}function Nv(e,t,n){return jv(Av(e),t,n)}function Pv(e,t,n,r){return e?e.range(t,n,r):void 0}function Fv(e,t,n,r){return Pv(kv(e),t,n,r)}function Iv(e,t,n,r){return Pv(Av(e),t,n,r)}function Lv(e){let t=e.extent,n=e.maxbins||40,r=Math.abs(yg(t))/n,i=Pg(e=>e[2]).right(by,r),a,o;return i===by.length?(a=yy,o=Kg(t[0]/dy,t[1]/dy,n)):i?(i=by[r/by[i-1][2]{let n=t(e),r=new Date(n);return Number.isNaN(+r)&&V(`Invalid date: ${n}`),r}),a=Cy.findIndex(e=>!e.aligned(i,r)),o=Cy.findIndex(e=>!e.skippable&&!e.aligned(i,r)),s=o>a+1?o:a,{units:c,step:l}=Cy[s-1];return{units:c,step:l}}var zv,Bv,Vv,Hv,Uv,Wv,Gv,Kv,qv,Jv,Yv,Xv,Zv,Qv,$v,ey,ty,ny,ry,iy,ay,oy,sy,cy,ly,uy,dy,fy,py,my,hy,gy,_y,vy,yy,by,xy,Sy,Cy,wy=o((()=>{Tg(),dv(),Qg(),zv=`year`,Bv=`quarter`,Vv=`month`,Hv=`week`,Uv=`date`,Wv=`dayofyear`,Gv=`hours`,Kv=`minutes`,qv=`seconds`,Jv=`milliseconds`,Yv=[zv,Bv,Vv,Hv,Uv,`day`,Wv,Gv,Kv,qv,Jv],Xv=Yv.reduce((e,t,n)=>(e[t]=1+n,e),{}),Zv={[zv]:`%Y `,[Bv]:`Q%q `,[Vv]:`%b `,[Uv]:`%d `,[Hv]:`W%U `,day:`%a `,[Wv]:`%j `,[Gv]:`%H:00`,[Kv]:`00:%M`,[qv]:`:%S`,[Jv]:`.%L`,[`${zv}-${Vv}`]:`%Y-%m `,[`${zv}-${Vv}-${Uv}`]:`%Y-%m-%d `,[`${Gv}-${Kv}`]:`%H:%M`},Qv=new Date,$v={[zv]:e=>e.getFullYear(),[Bv]:e=>Math.floor(e.getMonth()/3),[Vv]:e=>e.getMonth(),[Uv]:e=>e.getDate(),[Gv]:e=>e.getHours(),[Kv]:e=>e.getMinutes(),[qv]:e=>e.getSeconds(),[Jv]:e=>e.getMilliseconds(),[Wv]:e=>_v(e),[Hv]:e=>vv(e),weekday:(e,t)=>Ev(vv(e),e.getDay(),yv(t)),day:(e,t)=>Ev(1,e.getDay(),yv(t))},ey={[Bv]:e=>3*e,[Hv]:(e,t)=>Ev(e,0,yv(t))},ty={[zv]:e=>e.getUTCFullYear(),[Bv]:e=>Math.floor(e.getUTCMonth()/3),[Vv]:e=>e.getUTCMonth(),[Uv]:e=>e.getUTCDate(),[Gv]:e=>e.getUTCHours(),[Kv]:e=>e.getUTCMinutes(),[qv]:e=>e.getUTCSeconds(),[Jv]:e=>e.getUTCMilliseconds(),[Wv]:e=>Sv(e),[Hv]:e=>Cv(e),day:(e,t)=>Ev(1,e.getUTCDay(),wv(t)),weekday:(e,t)=>Ev(Cv(e),e.getUTCDay(),wv(t))},ny={[Bv]:e=>3*e,[Hv]:(e,t)=>Ev(e,0,wv(t))},ry={[zv]:rv,[Bv]:ev.every(3),[Vv]:ev,[Hv]:z_,[Uv]:N_,day:N_,[Wv]:N_,[Gv]:A_,[Kv]:D_,[qv]:E_,[Jv]:__},iy={[zv]:iv,[Bv]:tv.every(3),[Vv]:tv,[Hv]:K_,[Uv]:P_,day:P_,[Wv]:P_,[Gv]:j_,[Kv]:O_,[qv]:E_,[Jv]:__},ay=1e3,oy=ay*60,sy=oy*60,cy=sy*24,ly=cy*7,uy=cy*30,dy=cy*365,fy=[zv,Vv,Uv,Gv,Kv,qv,Jv],py=fy.slice(0,-1),my=py.slice(0,-1),hy=my.slice(0,-1),gy=hy.slice(0,-1),_y=[zv,Hv],vy=[zv,Vv],yy=[zv],by=[[py,1,ay],[py,5,5*ay],[py,15,15*ay],[py,30,30*ay],[my,1,oy],[my,5,5*oy],[my,15,15*oy],[my,30,30*oy],[hy,1,sy],[hy,3,3*sy],[hy,6,6*sy],[hy,12,12*sy],[gy,1,cy],[_y,1,ly],[vy,1,uy],[vy,3,3*uy],[yy,1,dy]],xy={[zv]:e=>e.getFullYear(),[Vv]:e=>e.getMonth(),[Uv]:e=>e.getDate(),day:e=>e.getDay(),[Gv]:e=>e.getHours(),[Kv]:e=>e.getMinutes(),[qv]:e=>e.getSeconds(),[Jv]:e=>e.getMilliseconds()},Sy={[zv]:e=>e.getUTCFullYear(),[Vv]:e=>e.getUTCMonth(),[Uv]:e=>e.getUTCDate(),day:e=>e.getUTCDay(),[Gv]:e=>e.getUTCHours(),[Kv]:e=>e.getUTCMinutes(),[qv]:e=>e.getUTCSeconds(),[Jv]:e=>e.getUTCMilliseconds()},Cy=[{units:[zv,Vv,Uv,Gv,Kv,qv,Jv],step:1,aligned:()=>!0},{units:[zv,Vv,Uv,Gv,Kv,qv],step:1,aligned:(e,t)=>e.every(e=>t[Jv](e)===0)},{units:[zv,Vv,Uv,Gv,Kv],step:1,aligned:(e,t)=>e.every(e=>t[qv](e)===0)},{units:[zv,Vv,Uv,Gv,Kv],step:5,aligned:(e,t)=>e.every(e=>t[Kv](e)%5==0)},{units:[zv,Vv,Uv,Gv,Kv],step:10,aligned:(e,t)=>e.every(e=>t[Kv](e)%10==0)},{units:[zv,Vv,Uv,Gv],step:1,aligned:(e,t)=>e.every(e=>t[Kv](e)===0)},{units:[zv,Vv,Uv],step:1,aligned:(e,t)=>e.every(e=>t[Gv](e)===0)},{units:[zv,Hv],step:1,skippable:!0,aligned:(e,t)=>new Set(e.map(e=>t.day(e))).size===1},{units:[zv,Vv],step:1,aligned:(e,t)=>e.every(e=>t[Uv](e)===1)},{units:[zv,Vv],step:3,aligned:(e,t)=>e.every(e=>t[Vv](e)%3==0)},{units:[zv],step:1,aligned:(e,t)=>e.every(e=>t[Vv](e)===0)},{units:[zv],step:10,aligned:(e,t)=>e.every(e=>t[zv](e)%10==0)},{aligned:()=>!1}]}));function Ty(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function Ey(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Dy(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function Oy(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,o=e.shortDays,s=e.months,c=e.shortMonths,l=Ay(i),u=jy(i),d=Ay(a),f=jy(a),p=Ay(o),m=jy(o),h=Ay(s),g=jy(s),_=Ay(c),v=jy(c),y={a:ee,A:N,b:te,B:ne,c:null,d:Iy,e:Iy,f:wse,g:Pse,G:Ise,H:xse,I:Sse,j:Cse,L:Ly,m:Tse,M:Ese,p:P,q:re,Q:Uy,s:Wy,S:Dse,u:Ose,U:kse,V:Ase,w:jse,W:Mse,x:null,X:null,y:Nse,Y:Fse,Z:Lse,"%":Hy},b={a:F,A:ie,b:ae,B:oe,c:null,d:zy,e:zy,f:Vse,g:Zse,G:$se,H:Rse,I:zse,j:Bse,L:By,m:Hse,M:Use,p:se,q:ce,Q:Uy,s:Wy,S:Wse,u:Gse,U:Kse,V:qse,w:Jse,W:Yse,x:null,X:null,y:Xse,Y:Qse,Z:ece,"%":Hy},x={a:E,A:D,b:O,B:k,c:A,d:Py,e:Py,f:_se,g:Ny,G:My,H:Fy,I:Fy,j:pse,L:gse,m:fse,M:mse,p:T,q:dse,Q:yse,s:bse,S:hse,u:ose,U:sse,V:cse,w:ase,W:lse,x:j,X:M,y:Ny,Y:My,Z:use,"%":vse};y.x=S(n,y),y.X=S(r,y),y.c=S(t,y),b.x=S(n,b),b.X=S(r,b),b.c=S(t,b);function S(e,t){return function(n){var r=[],i=-1,a=0,o=e.length,s,c,l;for(n instanceof Date||(n=new Date(+n));++i53)return null;`w`in r||(r.w=1),`Z`in r?(a=Ey(Dy(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?q_.ceil(a):q_(a),a=P_.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=Ty(Dy(r.y,0,1)),o=a.getDay(),a=o>4||o===0?B_.ceil(a):B_(a),a=N_.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else(`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?Ey(Dy(r.y,0,1)).getUTCDay():Ty(Dy(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,Ey(r)):Ty(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in Gy?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function A(e,n,r){return w(e,t,n,r)}function j(e,t,r){return w(e,n,t,r)}function M(e,t,n){return w(e,r,t,n)}function ee(e){return o[e.getDay()]}function N(e){return a[e.getDay()]}function te(e){return c[e.getMonth()]}function ne(e){return s[e.getMonth()]}function P(e){return i[+(e.getHours()>=12)]}function re(e){return 1+~~(e.getMonth()/3)}function F(e){return o[e.getUTCDay()]}function ie(e){return a[e.getUTCDay()]}function ae(e){return c[e.getUTCMonth()]}function oe(e){return s[e.getUTCMonth()]}function se(e){return i[+(e.getUTCHours()>=12)]}function ce(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}function ky(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a[e.toLowerCase(),t]))}function ase(e,t,n){var r=Ky.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function ose(e,t,n){var r=Ky.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function sse(e,t,n){var r=Ky.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function cse(e,t,n){var r=Ky.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function lse(e,t,n){var r=Ky.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function My(e,t,n){var r=Ky.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function Ny(e,t,n){var r=Ky.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function use(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function dse(e,t,n){var r=Ky.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function fse(e,t,n){var r=Ky.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function Py(e,t,n){var r=Ky.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function pse(e,t,n){var r=Ky.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function Fy(e,t,n){var r=Ky.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function mse(e,t,n){var r=Ky.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function hse(e,t,n){var r=Ky.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function gse(e,t,n){var r=Ky.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function _se(e,t,n){var r=Ky.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function vse(e,t,n){var r=qy.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function yse(e,t,n){var r=Ky.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function bse(e,t,n){var r=Ky.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function Iy(e,t){return ky(e.getDate(),t,2)}function xse(e,t){return ky(e.getHours(),t,2)}function Sse(e,t){return ky(e.getHours()%12||12,t,2)}function Cse(e,t){return ky(1+N_.count(rv(e),e),t,3)}function Ly(e,t){return ky(e.getMilliseconds(),t,3)}function wse(e,t){return Ly(e,t)+`000`}function Tse(e,t){return ky(e.getMonth()+1,t,2)}function Ese(e,t){return ky(e.getMinutes(),t,2)}function Dse(e,t){return ky(e.getSeconds(),t,2)}function Ose(e){var t=e.getDay();return t===0?7:t}function kse(e,t){return ky(z_.count(rv(e)-1,e),t,2)}function Ry(e){var t=e.getDay();return t>=4||t===0?U_(e):U_.ceil(e)}function Ase(e,t){return e=Ry(e),ky(U_.count(rv(e),e)+(rv(e).getDay()===4),t,2)}function jse(e){return e.getDay()}function Mse(e,t){return ky(B_.count(rv(e)-1,e),t,2)}function Nse(e,t){return ky(e.getFullYear()%100,t,2)}function Pse(e,t){return e=Ry(e),ky(e.getFullYear()%100,t,2)}function Fse(e,t){return ky(e.getFullYear()%1e4,t,4)}function Ise(e,t){var n=e.getDay();return e=n>=4||n===0?U_(e):U_.ceil(e),ky(e.getFullYear()%1e4,t,4)}function Lse(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+ky(t/60|0,`0`,2)+ky(t%60,`0`,2)}function zy(e,t){return ky(e.getUTCDate(),t,2)}function Rse(e,t){return ky(e.getUTCHours(),t,2)}function zse(e,t){return ky(e.getUTCHours()%12||12,t,2)}function Bse(e,t){return ky(1+P_.count(iv(e),e),t,3)}function By(e,t){return ky(e.getUTCMilliseconds(),t,3)}function Vse(e,t){return By(e,t)+`000`}function Hse(e,t){return ky(e.getUTCMonth()+1,t,2)}function Use(e,t){return ky(e.getUTCMinutes(),t,2)}function Wse(e,t){return ky(e.getUTCSeconds(),t,2)}function Gse(e){var t=e.getUTCDay();return t===0?7:t}function Kse(e,t){return ky(K_.count(iv(e)-1,e),t,2)}function Vy(e){var t=e.getUTCDay();return t>=4||t===0?X_(e):X_.ceil(e)}function qse(e,t){return e=Vy(e),ky(X_.count(iv(e),e)+(iv(e).getUTCDay()===4),t,2)}function Jse(e){return e.getUTCDay()}function Yse(e,t){return ky(q_.count(iv(e)-1,e),t,2)}function Xse(e,t){return ky(e.getUTCFullYear()%100,t,2)}function Zse(e,t){return e=Vy(e),ky(e.getUTCFullYear()%100,t,2)}function Qse(e,t){return ky(e.getUTCFullYear()%1e4,t,4)}function $se(e,t){var n=e.getUTCDay();return e=n>=4||n===0?X_(e):X_.ceil(e),ky(e.getUTCFullYear()%1e4,t,4)}function ece(){return`+0000`}function Hy(){return`%`}function Uy(e){return+e}function Wy(e){return Math.floor(e/1e3)}var Gy,Ky,qy,Jy,Yy=o((()=>{dv(),Gy={"-":``,_:` `,0:`0`},Ky=/^\s*\d+/,qy=/^%/,Jy=/[\\^$*+?|[\]().{}]/g}));function tce(e){return Xy=Oy(e),Zy=Xy.format,Qy=Xy.parse,$y=Xy.utcFormat,eb=Xy.utcParse,Xy}var Xy,Zy,Qy,$y,eb,nce=o((()=>{Yy(),tce({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]})})),tb=o((()=>{nce(),Yy()}));function nb(e){let t={};return n=>t[n]||(t[n]=e(n))}function rce(e,t){return n=>{let r=e(n),i=r.indexOf(t);if(i<0)return r;let a=ice(r,i),o=ai;)if(r[a]!==`0`){++a;break}return r.slice(0,a)+o}}function ice(e,t){let n=e.lastIndexOf(`e`),r;if(n>0)return n;for(n=e.length;--n>t;)if(r=e.charCodeAt(n),r>=48&&r<=57)return n+1}function rb(e){let t=nb(e.format),n=e.formatPrefix;return{format:t,formatPrefix:n,formatFloat(e){let n=r_(e||`,`);if(n.precision==null){switch(n.precision=12,n.type){case`%`:n.precision-=2;break;case`e`:--n.precision;break}return rce(t(n),t(`.1f`)(1)[1])}else return t(n)},formatSpan(e,r,i,a){a=r_(a??`,f`);let o=Kg(e,r,i),s=Math.max(Math.abs(e),Math.abs(r)),c;if(a.precision==null)switch(a.type){case`s`:return isNaN(c=Joe(o,s))||(a.precision=c),n(a,s);case``:case`e`:case`g`:case`p`:case`r`:isNaN(c=Xoe(o,s))||(a.precision=c-(a.type===`e`));break;case`f`:case`%`:isNaN(c=Koe(o))||(a.precision=c-(a.type===`%`)*2);break}return t(a)}}}function ib(){return mb=rb({format:u_,formatPrefix:d_})}function ab(e){return rb(Hoe(e))}function ob(e){return arguments.length?mb=ab(e):mb}function sb(e,t,n){n||={},gh(n)||V(`Invalid time multi-format specifier: ${n}`);let r=t(qv),i=t(Kv),a=t(Gv),o=t(Uv),s=t(Hv),c=t(Vv),l=t(Bv),u=t(zv),d=e(n.milliseconds||`.%L`),f=e(n.seconds||`:%S`),p=e(n.minutes||`%I:%M`),m=e(n.hours||`%I %p`),h=e(n.date||n.day||`%a %d`),g=e(n.week||`%b %d`),_=e(n.month||`%B`),v=e(n.quarter||`%B`),y=e(n.year||`%Y`);return e=>(r(e)gg(e)?t(e):sb(t,kv,e),utcFormat:e=>gg(e)?n(e):sb(n,Av,e),timeParse:nb(e.parse),utcParse:nb(e.utcParse)}}function lb(){return hb=cb({format:Zy,parse:Qy,utcFormat:$y,utcParse:eb})}function ub(e){return cb(Oy(e))}function db(e){return arguments.length?hb=ub(e):hb}function fb(e,t){let n=e?ab(e):ob(),r=t?ub(t):db();return gb(n,r)}function pb(e,t){let n=arguments.length;return n&&n!==2&&V(`defaultLocale expects either zero or two arguments.`),n?gb(ob(e),db(t)):gb(ob(),db())}function ace(){return ib(),lb(),pb()}var mb,hb,gb,_b=o((()=>{Qg(),f_(),wy(),Tg(),tb(),ib(),lb(),gb=(e,t)=>ig({},e,t)}));function oce(e){return t=>({options:t||{},sanitize:cce,load:sce,fileAccess:!1,file:lce(e),http:dce})}async function sce(e,t){let n=await this.sanitize(e,t),r=n.href;return n.localFile?this.file(r):this.http(r,t?.http)}async function cce(e,t){t=ig({},this.options,t);let n=this.fileAccess,r={href:null},i,a,o,s=Ob.test(e.replace(kb,``));(e==null||typeof e!=`string`||!s)&&V(`Sanitize failure, invalid URI: `+W(e));let c=Db.test(e);return(o=t.baseURL)&&!c&&(!e.startsWith(`/`)&&!o.endsWith(`/`)&&(e=`/`+e),e=o+e),a=(i=e.startsWith(Ab))||t.mode===`file`||t.mode!==`http`&&!c&&n,i?e=e.slice(7):e.startsWith(`//`)&&(t.defaultProtocol===`file`?(e=e.slice(2),a=!0):e=(t.defaultProtocol||`http`)+`:`+e),Object.defineProperty(r,"localFile",{value:!!a}),r.href=e,t.target&&(r.target=t.target+``),t.rel&&(r.rel=t.rel+``),t.context===`image`&&t.crossOrigin&&(r.crossOrigin=t.crossOrigin+``),r}function lce(e){return e?t=>new Promise((n,r)=>{e.readFile(t,(e,t)=>{e?r(e):n(t)})}):uce}async function uce(){V(`No file system access.`)}async function dce(e,t){let n=ig({},this.options.http,t),r=t&&t.response,i=await fetch(e,n);return i.ok?Jh(i[r])?i[r]():i.text():V(i.status+``+i.statusText)}function vb(e,t){if(!e||!e.length)return`unknown`;let n=e.length,r=Lb.length,i=Lb.map((e,t)=>t+1);for(let a=0,o=0,s,c;ae===0?t:e,0)-1]}function yb(e,t){return t.reduce((t,n)=>(t[n]=vb(e,n),t),{})}function bb(e){let t=function(t,n){let r={delimiter:e};return xb(t,n?ig(n,r):r)};return t.responseType=`text`,t}function xb(e,t){return t.header&&(e=t.header.map(W).join(t.delimiter)+` -`+e),mae(t.delimiter).parse(e+``)}function fce(e){return typeof Buffer==`function`&&Jh(Buffer.isBuffer)?Buffer.isBuffer(e):!1}function Sb(e,t){let n=t&&t.property?ah(t.property):ch;return gh(e)&&!fce(e)?pce(n(e),t):n(JSON.parse(e))}function pce(e,t){return!H(e)&&Iie(e)&&(e=[...e]),t&&t.copy?JSON.parse(JSON.stringify(e)):e}function Cb(e,t){let n,r,i,a;return e=Sb(e,t),t&&t.feature?(n=Cae,i=t.feature):t&&t.mesh?(n=kae,i=t.mesh,a=zb[t.filter]):V(`Missing TopoJSON feature or mesh parameter.`),r=(r=e.objects[i])?n(e,r,a):V(`Invalid TopoJSON object: `+i),r&&r.features||[r]}function wb(e,t){return arguments.length>1?(Bb[e]=t,this):sg(Bb,e)?Bb[e]:null}function Tb(e){let t=wb(e);return t&&t.responseType||`text`}function Eb(e,t,n,r){t||={};let i=wb(t.type||`json`);return i||V(`Unknown data format type: `+t.type),e=i(e,t),t.parse&&mce(e,t.parse,n,r),sg(e,`columns`)&&delete e.columns,e}function mce(e,t,n,r){if(!e.length)return;let i=db();n||=i.timeParse,r||=i.utcParse;let a=e.columns||Object.keys(e[0]),o,s,c,l,u,d;t===`auto`&&(t=yb(e,a)),a=Object.keys(t);let f=a.map(e=>{let i=t[e],a,o;if(i&&(i.startsWith(`date:`)||i.startsWith(`utc:`)))return a=i.split(/:(.+)?/,2),o=a[1],(o[0]===`'`&&o[o.length-1]===`'`||o[0]===`"`&&o[o.length-1]===`"`)&&(o=o.slice(1,-1)),(a[0]===`utc`?r:n)(o);if(!Ib[i])throw Error(`Illegal format pattern: `+e+`:`+i);return Ib[i]});for(c=0,u=e.length,d=a.length;c{Tg(),gae(),Nae(),_b(),Db=/^(data:|([A-Za-z]+:)?\/\/)/,Ob=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,kb=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Ab=`file://`,jb=e=>e!=null&&e===e,Mb=e=>e===`true`||e===`false`||e===!0||e===!1,Nb=e=>!Number.isNaN(Date.parse(e)),Pb=e=>!Number.isNaN(+e)&&!(e instanceof Date),Fb=e=>Pb(e)&&Number.isInteger(+e),Ib={boolean:bg,integer:Ch,number:Ch,date:xg,string:Sg,unknown:ch},Lb=[Mb,Fb,Pb,Nb],Rb=[`boolean`,`integer`,`number`,`date`],xb.responseType=`text`,Sb.responseType=`json`,zb={interior:(e,t)=>e!==t,exterior:(e,t)=>e===t},Cb.responseType=`json`,Bb={dsv:xb,csv:bb(`,`),tsv:bb(` `),json:Sb,topojson:Cb},Vb=oce(null)}));function Ub(e){let t=e||ch,n=[],r={};return n.add=e=>{let i=t(e);return r[i]||(r[i]=1,n.push(e)),n},n.remove=e=>{let i=t(e);if(r[i]){r[i]=0;let t=n.indexOf(e);t>=0&&n.splice(t,1)}return n},n}async function Wb(e,t){try{await t(e)}catch(t){e.error(t)}}function Gb(e){return!!(e&&Kb(e))}function Kb(e){return e[_x]}function qb(e,t){return e[_x]=t,e}function Jb(e){let t=e===Object(e)?e:{data:e};return Kb(t)?t:qb(t,vx++)}function Yb(e){return Xb(e,Jb({}))}function Xb(e,t){for(let n in e)t[n]=e[n];return t}function Zb(e,t){return qb(t,Kb(e))}function Qb(e,t){return e?t?(n,r)=>e(n,r)||Kb(t(n))-Kb(t(r)):(t,n)=>e(t,n)||Kb(t)-Kb(n):null}function $b(e){return e&&e.constructor===ex}function ex(){let e=[],t=[],n=[],r=[],i=[],a=null,o=!1;return{constructor:ex,insert(t){let n=Gh(t),r=n.length;for(let t=0;t{m(e)&&(l[Kb(e)]=-1)});for(d=0,f=e.length;d0&&(_(h,m,p.value),s.modifies(m));for(d=0,f=i.length;d{m(e)&&l[Kb(e)]>0&&_(e,p.field,p.value)}),s.modifies(p.field);if(o)s.mod=t.length||r.length?c.filter(e=>l[Kb(e)]>0):c.slice();else for(g in u)s.mod.push(u[g]);return(a||a==null&&(t.length||r.length))&&s.clean(!0),s}}}function tx(){Object.defineProperty(this,yx,{writable:!0,value:{}})}function nx(e,t,n,r){this.id=++bx,this.value=e,this.stamp=-1,this.rank=-1,this.qrank=-1,this.flags=0,t&&(this._update=t),n&&this.parameters(n,r)}function rx(e){return function(t){let n=this.flags;return arguments.length===0?!!(n&e):(this.flags=t?n|e:n&~e,this)}}function hce(e,t,n,r){let i=1,a;return e instanceof nx?a=e:e&&e.prototype instanceof nx?a=new e:Jh(e)?a=new nx(null,e):(i=0,a=new nx(e,t)),this.rank(a),i&&(r=n,n=t),n&&this.connect(a,a.parameters(n,r)),this.touch(a),a}function gce(e,t){let n=e.rank,r=t.length;for(let i=0;it=e);return n.requests=0,n.done=()=>{--n.requests===0&&(e._pending=null,t(e))},e._pending=n}function Cce(e,t,n,r,i){return(e instanceof nx?Tce:wce)(this,e,t,n,r,i),this}function wce(e,t,n,r,i,a){let o=ig({},a,Ex),s,c;Jh(n)||(n=ng(n)),r===void 0?s=t=>e.touch(n(t)):Jh(r)?(c=new nx(null,r,i,!1),s=t=>{c.evaluate(t);let r=n(t),i=c.value;$b(i)?e.pulse(r,i,a):e.update(r,i,o)}):s=t=>e.update(n(t),r,o),t.apply(s)}function Tce(e,t,n,r,i,a){if(r===void 0)t.targets().add(n);else{let o=a||{},s=new nx(null,Ece(n,r),i,!1);s.modified(o.force),s.rank=t.rank,t.targets().add(s),n&&(s.skip(!0),s.value=n.value,s.targets().add(n),e.connect(n,[s]))}}function Ece(e,t){return t=Jh(t)?t:ng(t),e?function(n,r){let i=t(n,r);return e.skip()||(e.skip(i!==this.value).value=i),i}:t}function Dce(e){e.rank=++this._rank}function Oce(e){let t=[e],n,r,i;for(;t.length;)if(this.rank(n=t.pop()),r=n._targets)for(i=r.length;--i>=0;)t.push(n=r[i]),n===e&&V(`Cycle detected in dataflow graph.`)}function ox(e,t,n){this.dataflow=e,this.stamp=t??-1,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=n||null}function sx(e,t){let n=[];return wg(e,t,e=>n.push(e)),n}function cx(e,t){let n={};return e.visit(t,e=>{n[Kb(e)]=1}),e=>n[Kb(e)]?null:e}function lx(e,t){return e?(n,r)=>e(n,r)&&t(n,r):t}function ux(e,t,n,r){let i=this,a=0;this.dataflow=e,this.stamp=t,this.fields=null,this.encode=r||null,this.pulses=n;for(let e of n)if(e.stamp===t){if(e.fields){let t=i.fields||={};for(let n in e.fields)t[n]=1}e.changed(i.ADD)&&(a|=i.ADD),e.changed(i.REM)&&(a|=i.REM),e.changed(i.MOD)&&(a|=i.MOD)}this.changes=a}async function kce(e,t,n){let r=this,i=[];if(r._pulse)return dx(r);if(r._pending&&await r._pending,t&&await Wb(r,t),!r._touched.length)return r.debug(`Dataflow invoked, but nothing to do.`),r;let a=++r._clock;r._pulse=new ox(r,a,e),r._touched.forEach(e=>r._enqueue(e,!0)),r._touched=Ub(sh);let o=0,s,c,l;try{for(;r._heap.size()>0;){if(s=r._heap.pop(),s.rank!==s.qrank){r._enqueue(s,!0);continue}c=s.run(r._getPulse(s,e)),c.then?c=await c:c.async&&(i.push(c.async),c=Dx),c!==Dx&&s._targets&&s._targets.forEach(e=>r._enqueue(e)),++o}}catch(e){r._heap.clear(),l=e}if(r._input={},r._pulse=null,r.debug(`Pulse ${a}: ${o} operators`),l&&(r._postrun=[],r.error(l)),r._postrun.length){let e=r._postrun.sort((e,t)=>t.priority-e.priority);r._postrun=[];for(let t=0;tr.runAsync(null,()=>{e.forEach(e=>{try{e(r)}catch(e){r.error(e)}})})),r}async function Ace(e,t,n){for(;this._running;)await this._running;let r=()=>this._running=null;return(this._running=this.evaluate(e,t,n)).then(r,r),this._running}function jce(e,t,n){return this._pulse?dx(this):(this.evaluate(e,t,n),this)}function Mce(e,t,n){if(this._pulse||t)this._postrun.push({priority:n||0,callback:e});else try{e(this)}catch(e){this.error(e)}}function dx(e){return e.error(`Dataflow already running. Use runAsync() to chain invocations.`),e}function Nce(e,t){let n=e.stampe.pulse),t):this._input[e.id]||Fce(this._pulse,n&&n.pulse)}function Fce(e,t){return t&&t.stamp===e.stamp?t:(e=e.fork(),t&&t!==Dx&&(e.source=t.source),e)}function Ice(e,t){let n=t||Rx;return this._pulse?this._enqueue(e):this._touched.add(e),n.skip&&e.skip(!0),this}function Lce(e,t,n){let r=n||Rx;return(e.set(t)||r.force)&&this.touch(e,r),this}function Rce(e,t,n){this.touch(e,n||Rx);let r=new ox(this,this._clock+ +!this._pulse),i=e.pulse&&e.pulse.source||[];return r.target=e,this._input[e.id]=t.pulse(r,i),this}function zce(e){let t=[];return{clear:()=>t=[],size:()=>t.length,peek:()=>t[0],push:n=>(t.push(n),fx(t,0,t.length-1,e)),pop:()=>{let n=t.pop(),r;return t.length?(r=t[0],t[0]=n,Bce(t,0,e)):r=n,r}}}function fx(e,t,n,r){let i,a,o=e[n];for(;n>t;){if(a=n-1>>1,i=e[a],r(o,i)<0){e[n]=i,n=a;continue}break}return e[n]=o}function Bce(e,t,n){let r=t,i=e.length,a=e[t],o=(t<<1)+1,s;for(;o=0&&(o=s),e[t]=e[o],t=o,o=(t<<1)+1;return e[t]=a,fx(e,r,t,n)}function px(){this.logger(mh()),this.logLevel(1),this._clock=0,this._rank=0,this._locale=pb();try{this._loader=Vb()}catch{}this._touched=Ub(sh),this._input={},this._pulse=null,this._heap=zce((e,t)=>e.qrank-t.qrank),this._postrun=[]}function mx(e){return function(){return this._log[e].apply(this,arguments)}}function G(e,t){nx.call(this,e,null,t)}function hx(e){let t=gx(e);return t&&t.Definition||null}function gx(e){return e&&=e.toLowerCase(),sg(zx,e)?zx[e]:null}var _x,vx,yx,bx,xx,Sx,Cx,wx,Tx,Ex,Dx,Ox,kx,Ax,jx,Mx,Nx,Px,Fx,Ix,Lx,Rx,zx,Bx=o((()=>{Tg(),Hb(),_b(),_x=Symbol(`vega_id`),vx=1,yx=`_:mod:_`,tx.prototype={set(e,t,n,r){let i=this,a=i[e],o=i[yx];return t!=null&&t>=0?(a[t]!==n||r)&&(a[t]=n,o[t+`:`+e]=-1,o[e]=-1):(a!==n||r)&&(i[e]=n,o[e]=H(n)?1+n.length:-1),i},modified(e,t){let n=this[yx];if(!arguments.length){for(let e in n)if(n[e])return!0;return!1}else if(H(e)){for(let t=0;t=0?t+1{o instanceof nx?(o!==this&&(t&&o.targets().add(this),a.push(o)),i.push({op:o,name:e,index:n})):r.set(e,n,o)};for(o in e)if(s=e[o],o===xx)Gh(s).forEach(e=>{e instanceof nx?e!==this&&(e.targets().add(this),a.push(e)):V(`Pulse parameters must be operator instances.`)}),this.source=s;else if(H(s))for(r.set(o,-1,Array(c=s.length)),l=0;l{let n=Date.now();return n-t>e?(t=n,1):0})},debounce(e){let t=ax();return this.targets().add(ax(null,null,rg(e,e=>{let n=e.dataflow;t.receive(e),n&&n.run&&n.run()}))),t},between(e,t){let n=!1;return e.targets().add(ax(null,null,()=>n=!0)),t.targets().add(ax(null,null,()=>n=!1)),this.filter(()=>n)},detach(){this._filter=dh,this._targets=null}},Ex={skip:!0},Dx={},Ox=1,kx=2,Ax=4,jx=3,Mx=5,Nx=7,Px=8,Fx=16,Ix=32,Lx=64,ox.prototype={StopPropagation:Dx,ADD:Ox,REM:kx,MOD:Ax,ADD_REM:jx,ADD_MOD:Mx,ALL:Nx,REFLOW:Px,SOURCE:Fx,NO_SOURCE:Ix,NO_FIELDS:Lx,fork(e){return new ox(this.dataflow).init(this,e)},clone(){let e=this.fork(Nx);return e.add=e.add.slice(),e.rem=e.rem.slice(),e.mod=e.mod.slice(),e.source&&=e.source.slice(),e.materialize(23)},addAll(){let e=this;return!e.source||e.add===e.rem||!e.rem.length&&e.source.length===e.add.length?e:(e=new ox(this.dataflow).init(this),e.add=e.source,e.rem=[],e)},init(e,t){let n=this;return n.stamp=e.stamp,n.encode=e.encode,e.fields&&!(t&Lx)&&(n.fields=e.fields),t&Ox?(n.addF=e.addF,n.add=e.add):(n.addF=null,n.add=[]),t&kx?(n.remF=e.remF,n.rem=e.rem):(n.remF=null,n.rem=[]),t&Ax?(n.modF=e.modF,n.mod=e.mod):(n.modF=null,n.mod=[]),t&Ix?(n.srcF=null,n.source=null):(n.srcF=e.srcF,n.source=e.source,e.cleans&&(n.cleans=e.cleans)),n},runAfter(e){this.dataflow.runAfter(e)},changed(e){let t=e||Nx;return t&Ox&&this.add.length||t&kx&&this.rem.length||t&Ax&&this.mod.length},reflow(e){if(e)return this.fork(Nx).reflow();let t=this.add.length,n=this.source&&this.source.length;return n&&n!==t&&(this.mod=this.source,t&&this.filter(Ax,cx(this,Ox))),this},clean(e){return arguments.length?(this.cleans=!!e,this):this.cleans},modifies(e){let t=this.fields||={};return H(e)?e.forEach(e=>t[e]=!0):t[e]=!0,this},modified(e,t){let n=this.fields;return(t||this.mod.length)&&n?arguments.length?H(e)?e.some(e=>n[e]):n[e]:!!n:!1},filter(e,t){let n=this;return e&Ox&&(n.addF=lx(n.addF,t)),e&kx&&(n.remF=lx(n.remF,t)),e&Ax&&(n.modF=lx(n.modF,t)),e&Fx&&(n.srcF=lx(n.srcF,t)),n},materialize(e){e||=Nx;let t=this;return e&Ox&&t.addF&&(t.add=sx(t.add,t.addF),t.addF=null),e&kx&&t.remF&&(t.rem=sx(t.rem,t.remF),t.remF=null),e&Ax&&t.modF&&(t.mod=sx(t.mod,t.modF),t.modF=null),e&Fx&&t.srcF&&(t.source=t.source.filter(t.srcF),t.srcF=null),t},visit(e,t){let n=this,r=t;if(e&Fx)return wg(n.source,n.srcF,r),n;e&Ox&&wg(n.add,n.addF,r),e&kx&&wg(n.rem,n.remF,r),e&Ax&&wg(n.mod,n.modF,r);let i=n.source;if(e&Px&&i){let e=n.add.length+n.mod.length;e===i.length||(e?wg(i,cx(n,Mx),r):wg(i,n.srcF,r))}return n}},U(ux,ox,{fork(e){let t=new ox(this.dataflow).init(this,e&this.NO_FIELDS);return e!==void 0&&(e&t.ADD&&this.visit(t.ADD,e=>t.add.push(e)),e&t.REM&&this.visit(t.REM,e=>t.rem.push(e)),e&t.MOD&&this.visit(t.MOD,e=>t.mod.push(e))),t},changed(e){return this.changes&e},modified(e){let t=this,n=t.fields;return n&&t.changes&t.MOD?H(e)?e.some(e=>n[e]):n[e]:0},filter(){V(`MultiPulse does not support filtering.`)},materialize(){V(`MultiPulse does not support materialization.`)},visit(e,t){let n=this,r=n.pulses,i=r.length,a=0;if(e&n.SOURCE)for(;athis.pulse=e):t!==e.StopPropagation&&(this.pulse=t),t},evaluate(e){let t=this.marshall(e.stamp),n=this.transform(t,e);return t.clear(),n},transform(){}}),zx={}}));function*Vx(e,t){if(t==null)for(let t of e)t!=null&&t!==``&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)r=t(r,++n,e),r!=null&&r!==``&&(r=+r)>=r&&(yield r)}}function Hx(e,t,n){let r=Float64Array.from(Vx(e,n));return r.sort(Mg),t.map(e=>loe(r,e))}function Ux(e,t){return Hx(e,[.25,.5,.75],t)}function Wx(e,t){let n=e.length,r=Wae(e,t),i=Ux(e,t),a=(i[2]-i[0])/1.34;return 1.06*(Math.min(r,a)||r||Math.abs(i[0])||1)*n**-.2}function Gx(e){let t=e.maxbins||20,n=e.base||10,r=Math.log(n),i=e.divide||[5,2],a=e.extent[0],o=e.extent[1],s,c,l,u,d,f,p=e.span||o-a||Math.abs(a)||1;if(e.step)s=e.step;else if(e.steps){for(u=p/t,d=0,f=e.steps.length;dt;)s*=n;for(d=0,f=i.length;d=l&&p/u<=t&&(s=u)}u=Math.log(s);let m=n**(-(u>=0?0:~~(-u/r)+1)-1);return(e.nice||e.nice===void 0)&&(u=Math.floor(a/s+m)*s,a=ae);let i=e.length,a=new Float64Array(i),o=0,s=1,c=r(e[0]),l=c,u=c+t,d;for(;s=u){for(l=(c+l)/2;o>1);oi;)e[o--]=e[r]}r=i,i=a}return e}function Uce(e){return function(){return e=(1103515245*e+12345)%2147483647,e/2147483647}}function Wce(e,t){t??(t=e,e=0);let n,r,i,a={min(e){return arguments.length?(n=e||0,i=r-n,a):n},max(e){return arguments.length?(r=e||0,i=r-n,a):r},sample(){return n+Math.floor(i*wS())},pdf(e){return e===Math.floor(e)&&e>=n&&e=r?1:(t-n+1)/i},icdf(e){return e>=0&&e<=1?n-1+Math.floor(e*i):NaN}};return a.min(e).max(t)}function Jx(e,t){e||=0,t??=1;let n=0,r=0,i,a;if(DS===DS)n=DS,DS=NaN;else{do n=wS()*2-1,r=wS()*2-1,i=n*n+r*r;while(i===0||i>1);a=Math.sqrt(-2*Math.log(i)/i),n*=a,DS=r*a}return e+n*t}function Yx(e,t,n){n??=1;let r=(e-(t||0))/n;return Math.exp(-.5*r*r)/(n*TS)}function Xx(e,t,n){t||=0,n??=1;let r=(e-t)/n,i=Math.abs(r),a;if(i>37)a=0;else{let e=Math.exp(-i*i/2),t;i<7.07106781186547?(t=.0352624965998911*i+.700383064443688,t=t*i+6.37396220353165,t=t*i+33.912866078383,t=t*i+112.079291497871,t=t*i+221.213596169931,t=t*i+220.206867912376,a=e*t,t=.0883883476483184*i+1.75566716318264,t=t*i+16.064177579207,t=t*i+86.7807322029461,t=t*i+296.564248779674,t=t*i+637.333633378831,t=t*i+793.826512519948,t=t*i+440.413735824752,a/=t):(t=i+.65,t=i+4/t,t=i+3/t,t=i+2/t,t=i+1/t,a=e/t/2.506628274631)}return r>0?1-a:a}function Zx(e,t,n){return e<0||e>1?NaN:(t||0)+(n??1)*ES*Gce(2*e-1)}function Gce(e){let t=-Math.log((1-e)*(1+e)),n;return t<6.25?(t-=3.125,n=-364441206401782e-35,n=-16850591381820166e-35+n*t,n=128584807152564e-32+n*t,n=11157877678025181e-33+n*t,n=-1333171662854621e-31+n*t,n=20972767875968562e-33+n*t,n=6637638134358324e-30+n*t,n=-4054566272975207e-29+n*t,n=-8151934197605472e-29+n*t,n=26335093153082323e-28+n*t,n=-12975133253453532e-27+n*t,n=-5415412054294628e-26+n*t,n=1.0512122733215323e-9+n*t,n=-4.112633980346984e-9+n*t,n=-2.9070369957882005e-8+n*t,n=4.2347877827932404e-7+n*t,n=-13654692000834679e-22+n*t,n=-13882523362786469e-21+n*t,n=.00018673420803405714+n*t,n=-.000740702534166267+n*t,n=-.006033670871430149+n*t,n=.24015818242558962+n*t,n=1.6536545626831027+n*t):t<16?(t=Math.sqrt(t)-3.25,n=2.2137376921775787e-9,n=9.075656193888539e-8+n*t,n=-2.7517406297064545e-7+n*t,n=1.8239629214389228e-8+n*t,n=15027403968909828e-22+n*t,n=-4013867526981546e-21+n*t,n=29234449089955446e-22+n*t,n=12475304481671779e-21+n*t,n=-47318229009055734e-21+n*t,n=6828485145957318e-20+n*t,n=24031110387097894e-21+n*t,n=-.0003550375203628475+n*t,n=.0009532893797373805+n*t,n=-.0016882755560235047+n*t,n=.002491442096107851+n*t,n=-.003751208507569241+n*t,n=.005370914553590064+n*t,n=1.0052589676941592+n*t,n=3.0838856104922208+n*t):Number.isFinite(t)?(t=Math.sqrt(t)-5,n=-27109920616438573e-27,n=-2555641816996525e-25+n*t,n=1.5076572693500548e-9+n*t,n=-3.789465440126737e-9+n*t,n=7.61570120807834e-9+n*t,n=-1.496002662714924e-8+n*t,n=2.914795345090108e-8+n*t,n=-6.771199775845234e-8+n*t,n=2.2900482228026655e-7+n*t,n=-9.9298272942317e-7+n*t,n=4526062597223154e-21+n*t,n=-1968177810553167e-20+n*t,n=7599527703001776e-20+n*t,n=-.00021503011930044477+n*t,n=-.00013871931833623122+n*t,n=1.0103004648645344+n*t,n=4.849906401408584+n*t):n=1/0,n*e}function Qx(e,t){let n,r,i={mean(e){return arguments.length?(n=e||0,i):n},stdev(e){return arguments.length?(r=e??1,i):r},sample:()=>Jx(n,r),pdf:e=>Yx(e,n,r),cdf:e=>Xx(e,n,r),icdf:e=>Zx(e,n,r)};return i.mean(e).stdev(t)}function $x(e,t){let n=Qx(),r=0,i={data(n){return arguments.length?(e=n,r=n?n.length:0,i.bandwidth(t)):e},bandwidth(n){return arguments.length?(t=n,!t&&e&&(t=Wx(e)),i):t},sample(){return e[~~(wS()*r)]+t*n.sample()},pdf(i){let a=0,o=0;for(;oeS(n,r),pdf:e=>tS(e,n,r),cdf:e=>nS(e,n,r),icdf:e=>rS(e,n,r)};return i.mean(e).stdev(t)}function aS(e,t){let n=0,r;function i(e){let t=[],r=0,i;for(i=0;i=t&&e<=n?1/(n-t):0}function cS(e,t,n){return n??(n=t??1,t=0),en?1:(e-t)/(n-t)}function lS(e,t,n){return n??(n=t??1,t=0),e>=0&&e<=1?t+e*(n-t):NaN}function uS(e,t){let n,r,i={min(e){return arguments.length?(n=e||0,i):n},max(e){return arguments.length?(r=e??1,i):r},sample:()=>oS(n,r),pdf:e=>sS(e,n,r),cdf:e=>cS(e,n,r),icdf:e=>lS(e,n,r)};return t??(t=e??1,e=0),i.min(e).max(t)}function dS(e,t,n){let r=0,i=0;for(let a of e){let e=n(a);t(a)==null||e==null||isNaN(e)||(r+=(e-r)/++i)}return{coef:[r],predict:()=>r,rSquared:0}}function fS(e,t,n,r){let i=r-e*e,a=Math.abs(i)<1e-24?0:(n-e*t)/i;return[t-a*e,a]}function pS(e,t,n,r){e=e.filter(e=>{let r=t(e),i=n(e);return r!=null&&(r=+r)>=r&&i!=null&&(i=+i)>=i}),r&&e.sort((e,n)=>t(e)-t(n));let i=e.length,a=new Float64Array(i),o=new Float64Array(i),s=0,c=0,l=0,u,d,f;for(f of e)a[s]=u=+t(f),o[s]=d=+n(f),++s,c+=(u-c)/s,l+=(d-l)/s;for(s=0;s=a&&o!=null&&(o=+o)>=o&&r(a,o,++i)}function hS(e,t,n,r,i){let a=0,o=0;return mS(e,t,n,(e,t)=>{let n=t-i(e),s=t-r;a+=n*n,o+=s*s}),1-a/o}function gS(e,t,n){let r=0,i=0,a=0,o=0,s=0;mS(e,t,n,(e,t)=>{++s,r+=(e-r)/s,i+=(t-i)/s,a+=(e*t-a)/s,o+=(e*e-o)/s});let c=fS(r,i,a,o),l=e=>c[0]+c[1]*e;return{coef:c,predict:l,rSquared:hS(e,t,n,i,l)}}function _S(e,t,n){let r=0,i=0,a=0,o=0,s=0;mS(e,t,n,(e,t)=>{++s,e=Math.log(e),r+=(e-r)/s,i+=(t-i)/s,a+=(e*t-a)/s,o+=(e*e-o)/s});let c=fS(r,i,a,o),l=e=>c[0]+c[1]*Math.log(e);return{coef:c,predict:l,rSquared:hS(e,t,n,i,l)}}function vS(e,t,n){let[r,i,a,o]=pS(e,t,n),s=0,c=0,l=0,u=0,d=0,f,p,m;mS(e,t,n,(e,t)=>{f=r[d++],p=Math.log(t),m=f*t,s+=(t*p-s)/d,c+=(m-c)/d,l+=(m*p-l)/d,u+=(f*m-u)/d});let[h,g]=fS(c/o,s/o,l/o,u/o),_=e=>Math.exp(h+g*(e-a));return{coef:[Math.exp(h-g*a),g],predict:_,rSquared:hS(e,t,n,o,_)}}function yS(e,t,n){let r=0,i=0,a=0,o=0,s=0,c=0;mS(e,t,n,(e,t)=>{let n=Math.log(e),l=Math.log(t);++c,r+=(n-r)/c,i+=(l-i)/c,a+=(n*l-a)/c,o+=(n*n-o)/c,s+=(t-s)/c});let l=fS(r,i,a,o),u=e=>l[0]*e**+l[1];return l[0]=Math.exp(l[0]),{coef:l,predict:u,rSquared:hS(e,t,n,s,u)}}function bS(e,t,n){let[r,i,a,o]=pS(e,t,n),s=r.length,c=0,l=0,u=0,d=0,f=0,p,m,h,g;for(p=0;p(e-=a,y*e*e+b*e+x+o);return{coef:[x-b*a+y*a*a+o,b-2*y*a,y],predict:S,rSquared:hS(e,t,n,o,S)}}function xS(e,t,n,r){if(r===0)return dS(e,t,n);if(r===1)return gS(e,t,n);if(r===2)return bS(e,t,n);let[i,a,o,s]=pS(e,t,n),c=i.length,l=[],u=[],d=r+1,f,p,m,h,g;for(f=0;f{e-=o;let t=s+_[0]+_[1]*e+_[2]*e*e;for(f=3;f=0;--a)for(s=t[a],c=1,i[a]+=s,o=1;o<=a;++o)c*=(a+1-o)/o,i[a-o]+=s*n**+o*c;return i[0]+=r,i}function qce(e){let t=e.length-1,n=[],r,i,a,o,s;for(r=0;rMath.abs(e[r][o])&&(o=i);for(a=r;a=r;a--)e[a][i]-=e[a][r]*e[r][i]/e[r][r]}for(i=t-1;i>=0;--i){for(s=0,a=i+1;ai[o]-n?r:o,c=0,l=0,p=0,m=0,h=0,g=1/Math.abs(i[s]-n||1);for(let e=r;e<=o;++e){let t=i[e],r=a[e],o=Jce(Math.abs(n-t)*g)*f[e],s=t*o;c+=o,l+=s,p+=r*o,m+=r*s,h+=t*s}let[_,v]=fS(l/c,p/c,m/c,h/c);u[e]=_+v*n,d[e]=Math.abs(a[e]-u[e]),Yce(i,e+1,t)}if(e===OS)break;let n=poe(d);if(Math.abs(n)=1?kS:(r=1-t*t)*r}return Xce(i,u,o,s)}function Jce(e){return(e=1-e*e*e)*e*e}function Yce(e,t,n){let r=e[t],i=n[0],a=n[1]+1;if(!(a>=e.length))for(;t>i&&e[a]-r<=r-e[i];)n[0]=++i,n[1]=a,++a}function Xce(e,t,n,r){let i=e.length,a=[],o=0,s=0,c=[],l;for(;o[t,e(t)],a=t[0],o=t[1],s=o-a,c=s/r,l=[i(a)],u=[];if(n===r){for(let e=1;e0;)u.push(i(a+e/n*s))}let d=l[0],f=u[u.length-1],p=1/s,m=Zce(d[1],u);for(;f;){let e=i((d[0]+f[0])/2);e[0]-d[0]>=c&&Qce(d,e,f,p,m)>AS?u.push(e):(d=f,l.push(f),u.pop()),f=u[u.length-1]}return l}function Zce(e,t){let n=e,r=e,i=t.length;for(let e=0;er&&(r=i)}return 1/(r-n)}function Qce(e,t,n,r,i){let a=Math.atan2(i*(n[1]-e[1]),r*(n[0]-e[0])),o=Math.atan2(i*(t[1]-e[1]),r*(t[0]-e[0]));return Math.abs(a-o)}var wS,TS,ES,DS,OS,kS,AS,jS=o((()=>{Qg(),wS=Math.random,TS=Math.sqrt(2*Math.PI),ES=Math.SQRT2,DS=NaN,OS=2,kS=1e-12,AS=.5*Math.PI/180})),$ce=c({aggregate:()=>RS,bin:()=>zS,collect:()=>VS,compare:()=>HS,countpattern:()=>US,cross:()=>WS,density:()=>KS,dotbin:()=>YS,expression:()=>XS,extent:()=>ZS,facet:()=>$S,field:()=>eC,filter:()=>tC,flatten:()=>nC,fold:()=>rC,formula:()=>iC,generate:()=>aC,impute:()=>oC,joinaggregate:()=>sC,kde:()=>cC,key:()=>lC,load:()=>uC,lookup:()=>fC,multiextent:()=>pC,multivalues:()=>mC,params:()=>hC,pivot:()=>gC,prefacet:()=>_C,project:()=>vC,proxy:()=>yC,quantile:()=>bC,relay:()=>xC,sample:()=>SC,sequence:()=>CC,sieve:()=>wC,subflow:()=>QS,timeunit:()=>TC,tupleindex:()=>EC,values:()=>DC,window:()=>kC});function ele(e){return t=>{let n=e.length,r=1,i=String(e[0](t));for(;rig({name:e,aggregate_param:r,out:n||e},MC,t)}function PS(e,t,n){return NC[e](n,t)}function FS(e,t){return e.idx-t.idx}function nle(e){let t={};e.forEach(e=>t[e.name]=e);let n=e=>{e.req&&e.req.forEach(e=>{t[e]||n(t[e]=NC[e]())})};return e.forEach(n),Object.values(t).sort(FS)}function rle(){this.valid=0,this.missing=0,this._ops.forEach(e=>e.aggregate_param==null?e.init(this):e.init(this,e.aggregate_param))}function ile(e,t){if(e==null||e===``){++this.missing;return}e===e&&(++this.valid,this._ops.forEach(n=>n.add(this,e,t)))}function ale(e,t){if(e==null||e===``){--this.missing;return}e===e&&(--this.valid,this._ops.forEach(n=>n.rem(this,e,t)))}function ole(e){return this._out.forEach(t=>e[t.out]=t.value(this)),e}function IS(e,t){let n=t||ch,r=nle(e),i=e.slice().sort(FS);function a(e){this._ops=r,this._out=i,this.cell=e,this.init()}return a.prototype.init=rle,a.prototype.add=ile,a.prototype.rem=ale,a.prototype.set=ole,a.prototype.get=n,a.fields=e.map(e=>e.out),a}function LS(e){this._key=e?ah(e):Kb,this.reset()}function RS(e){G.call(this,null,e),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}function zS(e){G.call(this,null,e)}function BS(e,t,n){let r=e,i=t||[],a=n||[],o={},s=0;return{add:e=>a.push(e),remove:e=>o[r(e)]=++s,size:()=>i.length,data:(e,t)=>(s&&=(i=i.filter(e=>!o[r(e)]),o={},0),t&&e&&i.sort(e),a.length&&(i=e?Jie(e,i,a.sort(e)):i.concat(a),a=[]),i)}}function VS(e){G.call(this,[],e)}function HS(e){nx.call(this,null,sle,e)}function sle(e){return this.value&&!e.modified()?this.value:Xh(e.fields,e.orders)}function US(e){G.call(this,null,e)}function cle(e,t,n){switch(t){case`upper`:e=e.toUpperCase();break;case`lower`:e=e.toLowerCase();break}return e.match(n)}function WS(e){G.call(this,null,e)}function lle(e,t,n,r){for(var i=[],a={},o=e.length,s=0,c,l;sGS(e,t))):typeof r[n]===zC&&r[n](e[n]);return r}function KS(e){G.call(this,null,e)}function ule(e){return()=>e.materialize(e.SOURCE).source}function qS(e,t){return e?e.map((e,n)=>t[n]||Ym(e)):null}function JS(e,t,n){let r=[],i=e=>e(c),a,o,s,c,l,u;if(t==null)r.push(e.map(n));else for(a={},o=0,s=e.length;ot(n,e),Xm(t),Ym(t))}function ZS(e){G.call(this,[void 0,void 0],e)}function QS(e,t){nx.call(this,e),this.parent=t,this.count=0}function $S(e){G.call(this,{},e),this._keys=lg();let t=this._targets=[];t.active=0,t.forEach=e=>{for(let n=0,r=t.active;nah(e)):ah(e.name,e.as)}function tC(e){G.call(this,lg(),e)}function nC(e){G.call(this,[],e)}function rC(e){G.call(this,[],e)}function iC(e){G.call(this,null,e)}function aC(e){G.call(this,[],e)}function oC(e){G.call(this,[],e)}function ple(e){var t=e.method||GC.value,n;if(GC[t]==null)V(`Unrecognized imputation method: `+t);else if(t===GC.value)return n=e.value===void 0?0:e.value,()=>n;else return GC[t]}function mle(e){let t=e.field;return e=>e?t(e):NaN}function hle(e,t,n,r){var i=e=>e(g),a=[],o=r?r.slice():[],s={},c={},l,u,d,f,p,m,h,g;for(o.forEach((e,t)=>s[e]=t+1),f=0,h=e.length;fi&&(i=o[1]);return[r,i]}function mC(e){nx.call(this,null,yle,e)}function yle(e){return this.value&&!e.modified()?this.value:e.values.reduce((e,t)=>e.concat(t),[])}function hC(e){G.call(this,null,e)}function gC(e){RS.call(this,e)}function ble(e,t){let n=e.field,r=e.value,i=(e.op===`count`?`__count__`:e.op)||`sum`,a=Xm(n).concat(Xm(r)),o=Sle(n,e.limit||0,t);return t.changed()&&e.set(`__pivot__`,null,null,!0),{key:e.key,groupby:e.groupby,ops:o.map(()=>i),fields:o.map(e=>xle(e,n,r,a)),as:o.map(e=>e+``),modified:e.modified.bind(e)}}function xle(e,t,n,r){return Jm(r=>t(r)===e?n(r):NaN,r,e+``)}function Sle(e,t,n){let r={},i=[];return n.visit(n.SOURCE,t=>{let n=e(t);r[n]||(r[n]=1,i.push(n))}),i.sort(Qh),t?i.slice(0,t):i}function _C(e){$S.call(this,e)}function vC(e){G.call(this,null,e)}function Cle(e,t,n,r){for(let i=0,a=n.length;ic[e]=1)}p(e.sort),t.forEach((e,t)=>{let c=n[t],m=r[t],h=i[t]||null,g=Ym(c),_=NS(e,g,a[t]);if(p(c),o.push(_),sg(YC,e))s.push(wle(e,c,m,_));else{if(c==null&&e!==`count`&&V(`Null aggregate field specified.`),e===`count`){u.push(_);return}f=!1;let t=l[g];t||(t=l[g]=[],t.field=c,d.push(t)),t.push(PS(e,h,_))}}),(u.length||d.length)&&(this.cell=Ele(d,u,f)),this.inputs=Object.keys(c)}function Ele(e,t,n){e=e.map(e=>IS(e,e.field));let r={num:0,agg:null,store:!1,count:t};if(!n)for(var i=e.length,a=r.agg=Array(i),o=0;on?n:e}function Ole(e,t,n,r){e.p0=e.i0,e.p1=e.i1;let i=t[0]==null?0:n+t[0],a=t[1]==null?r:n+t[1]+1;e.i0=AC(i,0,r),e.i1=AC(a,0,r),e.index=n}function kle(e,t){let n=e.i0,r=e.i1-1,i=e.compare,a=e.data,o=a.length-1;n>0&&!i(a[n],a[n-1])&&(e.i0=t.left(a,a[n])),r{Tg(),Bx(),jS(),Qg(),wy(),jC=()=>{},MC={init:jC,add:jC,rem:jC,idx:0},NC={values:{init:e=>e.cell.store=!0,value:e=>e.cell.data.values(),idx:-1},count:{value:e=>e.cell.num},__count__:{value:e=>e.missing+e.valid},missing:{value:e=>e.missing},valid:{value:e=>e.valid},sum:{init:e=>e.sum=0,value:e=>e.valid?e.sum:void 0,add:(e,t)=>e.sum+=+t,rem:(e,t)=>e.sum-=t},product:{init:e=>e.product=1,value:e=>e.valid?e.product:void 0,add:(e,t)=>e.product*=t,rem:(e,t)=>e.product/=t},mean:{init:e=>e.mean=0,value:e=>e.valid?e.mean:void 0,add:(e,t)=>(e.mean_d=t-e.mean,e.mean+=e.mean_d/e.valid),rem:(e,t)=>(e.mean_d=t-e.mean,e.mean-=e.valid?e.mean_d/e.valid:e.mean)},average:{value:e=>e.valid?e.mean:void 0,req:[`mean`],idx:1},variance:{init:e=>e.dev=0,value:e=>e.valid>1?Math.max(0,e.dev)/(e.valid-1):void 0,add:(e,t)=>e.dev+=e.mean_d*(t-e.mean),rem:(e,t)=>e.dev-=e.mean_d*(t-e.mean),req:[`mean`],idx:1},variancep:{value:e=>e.valid?Math.max(0,e.dev)/e.valid:void 0,req:[`variance`],idx:2},stdev:{value:e=>e.valid>1?Math.sqrt(Math.max(0,e.dev)/(e.valid-1)):void 0,req:[`variance`],idx:2},stdevp:{value:e=>e.valid?Math.sqrt(Math.max(0,e.dev)/e.valid):void 0,req:[`variance`],idx:2},stderr:{value:e=>e.valid>1?Math.sqrt(Math.max(0,e.dev)/(e.valid*(e.valid-1))):void 0,req:[`variance`],idx:2},distinct:{value:e=>e.cell.data.distinct(e.get),req:[`values`],idx:3},ci0:{value:e=>e.cell.data.ci0(e.get),req:[`values`],idx:3},ci1:{value:e=>e.cell.data.ci1(e.get),req:[`values`],idx:3},median:{value:e=>e.cell.data.q2(e.get),req:[`values`],idx:3},q1:{value:e=>e.cell.data.q1(e.get),req:[`values`],idx:3},q3:{value:e=>e.cell.data.q3(e.get),req:[`values`],idx:3},min:{init:e=>e.min=void 0,value:e=>e.min=Number.isNaN(e.min)?e.cell.data.min(e.get):e.min,add:(e,t)=>{(t{t<=e.min&&(e.min=NaN)},req:[`values`],idx:4},max:{init:e=>e.max=void 0,value:e=>e.max=Number.isNaN(e.max)?e.cell.data.max(e.get):e.max,add:(e,t)=>{(t>e.max||e.max===void 0)&&(e.max=t)},rem:(e,t)=>{t>=e.max&&(e.max=NaN)},req:[`values`],idx:4},argmin:{init:e=>e.argmin=void 0,value:e=>e.argmin||e.cell.data.argmin(e.get),add:(e,t,n)=>{t{t<=e.min&&(e.argmin=void 0)},req:[`min`,`values`],idx:3},argmax:{init:e=>e.argmax=void 0,value:e=>e.argmax||e.cell.data.argmax(e.get),add:(e,t,n)=>{t>e.max&&(e.argmax=n)},rem:(e,t)=>{t>=e.max&&(e.argmax=void 0)},req:[`max`,`values`],idx:3},exponential:{init:(e,t)=>{e.exp=0,e.exp_r=t},value:e=>e.valid?e.exp*(1-e.exp_r)/(1-e.exp_r**e.valid):void 0,add:(e,t)=>e.exp=e.exp_r*e.exp+t,rem:(e,t)=>e.exp=(e.exp-t/e.exp_r**(e.valid-1))/e.exp_r},exponentialb:{value:e=>e.valid?e.exp*(1-e.exp_r):void 0,req:[`exponential`],idx:1}},PC=Object.keys(NC).filter(e=>e!==`__count__`),[...PC,`__count__`].forEach(e=>{NC[e]=tle(e,NC[e])}),FC=LS.prototype,FC.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null},FC.add=function(e){this._add.push(e)},FC.rem=function(e){this._rem.push(e)},FC.values=function(){if(this._get=null,this._rem.length===0)return this._add;let e=this._add,t=this._rem,n=this._key,r=e.length,i=t.length,a=Array(r-i),o={},s,c,l;for(s=0;s=0;)a=e(t[r])+``,sg(n,a)||(n[a]=1,++i);return i},FC.extent=function(e){if(this._get!==e||!this._ext){let t=this.values(),n=Die(t,e);this._ext=[t[n[0]],t[n[1]]],this._get=e}return this._ext},FC.argmin=function(e){return this.extent(e)[0]||{}},FC.argmax=function(e){return this.extent(e)[1]||{}},FC.min=function(e){let t=this.extent(e)[0];return t==null?void 0:e(t)},FC.max=function(e){let t=this.extent(e)[1];return t==null?void 0:e(t)},FC.quartile=function(e){return(this._get!==e||!this._q)&&(this._q=Ux(this.values(),e),this._get=e),this._q},FC.q1=function(e){return this.quartile(e)[0]},FC.q2=function(e){return this.quartile(e)[1]},FC.q3=function(e){return this.quartile(e)[2]},FC.ci=function(e){return(this._get!==e||!this._ci)&&(this._ci=Kx(this.values(),1e3,.05,e),this._get=e),this._ci},FC.ci0=function(e){return this.ci(e)[0]},FC.ci1=function(e){return this.ci(e)[1]},RS.Definition={type:`Aggregate`,metadata:{generates:!0,changes:!0},params:[{name:`groupby`,type:`field`,array:!0},{name:`ops`,type:`enum`,array:!0,values:PC},{name:`aggregate_params`,type:`number`,null:!0,array:!0},{name:`fields`,type:`field`,null:!0,array:!0},{name:`as`,type:`string`,null:!0,array:!0},{name:`drop`,type:`boolean`,default:!0},{name:`cross`,type:`boolean`,default:!1},{name:`key`,type:`field`}]},U(RS,G,{transform(e,t){let n=this,r=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=e.modified();return n.stamp=r.stamp,n.value&&(i||t.modified(n._inputs,!0))?(n._prev=n.value,n.value=i?n.init(e):Object.create(null),t.visit(t.SOURCE,e=>n.add(e))):(n.value=n.value||n.init(e),t.visit(t.REM,e=>n.rem(e)),t.visit(t.ADD,e=>n.add(e))),r.modifies(n._outputs),n._drop=e.drop!==!1,e.cross&&n._dims.length>1&&(n._drop=!1,n.cross()),t.clean()&&n._drop&&r.clean(!0).runAfter(()=>this.clean()),n.changes(r)},cross(){let e=this,t=e.value,n=e._dnames,r=n.map(()=>({})),i=n.length;function a(e){let t,a,o,s;for(t in e)for(o=e[t].tuple,a=0;a{let t=Ym(e);return i(e),n.push(t),t}),this.cellkey=e.key?e.key:MS(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];let a=e.fields||[null],o=e.ops||[`count`],s=e.aggregate_params||[null],c=e.as||[],l=a.length,u={},d,f,p,m,h,g,_;for(l!==o.length&&V(`Unmatched number of fields and aggregate ops.`),_=0;_IS(e,e.field)),Object.create(null)},cellkey:MS(),cell(e,t){let n=this.value[e];return n?n.num===0&&this._drop&&n.stamp{let t=r(e);e[s]=t,e[c]=t==null?null:i+a*(1+(t-i)/a)}:e=>e[s]=r(e)),t.modifies(n?o:s)},_bins(e){if(this.value&&!e.modified())return this.value;let t=e.field,n=Gx(e),r=n.step,i=n.start,a=i+Math.ceil((n.stop-i)/r)*r,o,s;(o=e.anchor)!=null&&(s=o-(i+r*Math.floor((o-i)/r)),i+=s,a+=s);let c=function(e){let n=Ch(t(e));return n==null?null:na?1/0:(n=Math.max(i,Math.min(n,a-r)),i+r*Math.floor(IC+(n-i)/r))};return c.start=i,c.stop=a,c.step=r,this.value=Jm(c,Xm(t),e.name||`bin_`+Ym(t))}}),VS.Definition={type:`Collect`,metadata:{source:!0},params:[{name:`sort`,type:`compare`}]},U(VS,G,{transform(e,t){let n=t.fork(t.ALL),r=BS(Kb,this.value,n.materialize(n.ADD).add),i=e.sort,a=t.changed()||i&&(e.modified(`sort`)||t.modified(i.fields));return n.visit(n.REM,r.remove),this.modified(a),this.value=n.source=r.data(Qb(i),a),t.source&&t.source.root&&(this.value.root=t.source.root),n}}),U(HS,nx),US.Definition={type:`CountPattern`,metadata:{generates:!0,changes:!0},params:[{name:`field`,type:`field`,required:!0},{name:`case`,type:`enum`,values:[`upper`,`lower`,`mixed`],default:`mixed`},{name:`pattern`,type:`string`,default:`[\\w"]+`},{name:`stopwords`,type:`string`,default:``},{name:`as`,type:`string`,array:!0,length:2,default:[`text`,`count`]}]},U(US,G,{transform(e,t){let n=t=>n=>{for(var r=cle(s(n),e.case,a)||[],i,c=0,l=r.length;ci[e]=1+(i[e]||0)),u=n(e=>--i[e]);return r?t.visit(t.SOURCE,l):(t.visit(t.ADD,l),t.visit(t.REM,u)),this._finish(t,c)},_parameterCheck(e,t){let n=!1;return(e.modified(`stopwords`)||!this._stop)&&(this._stop=RegExp(`^`+(e.stopwords||``)+`$`,`i`),n=!0),(e.modified(`pattern`)||!this._match)&&(this._match=new RegExp(e.pattern||`[\\w']+`,`g`),n=!0),(e.modified(`field`)||t.modified(e.field.fields))&&(n=!0),n&&(this._counts={}),n},_finish(e,t){let n=this._counts,r=this._tuples||={},i=t[0],a=t[1],o=e.fork(e.NO_SOURCE|e.NO_FIELDS),s,c,l;for(s in n)c=r[s],l=n[s]||0,!c&&l?(r[s]=c=Jb({}),c[i]=s,c[a]=l,o.add.push(c)):l===0?(c&&o.rem.push(c),n[s]=null,r[s]=null):c[a]!==l&&(c[a]=l,o.mod.push(c));return o.modifies(t)}}),WS.Definition={type:`Cross`,metadata:{generates:!0},params:[{name:`filter`,type:`expr`},{name:`as`,type:`string`,array:!0,length:2,default:[`a`,`b`]}]},U(WS,G,{transform(e,t){let n=t.fork(t.NO_SOURCE),r=e.as||[`a`,`b`],i=r[0],a=r[1],o=!this.value||t.changed(t.ADD_REM)||e.modified(`as`)||e.modified(`filter`),s=this.value;return o?(s&&(n.rem=s),s=t.materialize(t.SOURCE).source,n.add=this.value=lle(s,i,a,e.filter||dh)):n.mod=s,n.source=this.value,n.modifies(r)}}),LC={kde:$x,mixture:aS,normal:Qx,lognormal:iS,uniform:uS},RC=`distributions`,zC=`function`,BC=`field`,VC=[{key:{function:`normal`},params:[{name:`mean`,type:`number`,default:0},{name:`stdev`,type:`number`,default:1}]},{key:{function:`lognormal`},params:[{name:`mean`,type:`number`,default:0},{name:`stdev`,type:`number`,default:1}]},{key:{function:`uniform`},params:[{name:`min`,type:`number`,default:0},{name:`max`,type:`number`,default:1}]},{key:{function:`kde`},params:[{name:`field`,type:`field`,required:!0},{name:`from`,type:`data`},{name:`bandwidth`,type:`number`,default:0}]}],HC={key:{function:`mixture`},params:[{name:`distributions`,type:`param`,array:!0,params:VC},{name:`weights`,type:`number`,array:!0}]},KS.Definition={type:`Density`,metadata:{generates:!0},params:[{name:`extent`,type:`number`,array:!0,length:2},{name:`steps`,type:`number`},{name:`minsteps`,type:`number`,default:25},{name:`maxsteps`,type:`number`,default:200},{name:`method`,type:`string`,default:`pdf`,values:[`pdf`,`cdf`]},{name:`distribution`,type:`param`,params:VC.concat(HC)},{name:`as`,type:`string`,array:!0,default:[`value`,`density`]}]},U(KS,G,{transform(e,t){let n=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){let r=GS(e.distribution,ule(t)),i=e.steps||e.minsteps||25,a=e.steps||e.maxsteps||200,o=e.method||`pdf`;o!==`pdf`&&o!==`cdf`&&V(`Invalid density method: `+o),!e.extent&&!r.data&&V(`Missing density extent parameter.`),o=r[o];let s=e.as||[`value`,`density`],c=e.extent||og(r.data()),l=CS(o,c,i,a).map(e=>{let t={};return t[s[0]]=e[0],t[s[1]]=e[1],Jb(t)});this.value&&(n.rem=this.value),this.value=n.add=n.source=l}return n}}),UC=`bin`,YS.Definition={type:`DotBin`,metadata:{modifies:!0},params:[{name:`field`,type:`field`,required:!0},{name:`groupby`,type:`field`,array:!0},{name:`step`,type:`number`},{name:`smooth`,type:`boolean`,default:!1},{name:`as`,type:`string`,default:UC}]},WC=(e,t)=>yg(og(e,t))/30,U(YS,G,{transform(e,t){if(this.value&&!(e.modified()||t.changed()))return t;let n=t.materialize(t.SOURCE).source,r=JS(t.source,e.groupby,ch),i=e.smooth||!1,a=e.field,o=e.step||WC(n,a),s=Qb((e,t)=>a(e)-a(t)),c=e.as||UC,l=r.length,u=1/0,d=-1/0,f=0,p;for(;fd&&(d=t),e[++p][c]=t}return this.value={start:u,stop:d,step:o},t.reflow(!0).modifies(c)}}),U(XS,nx),ZS.Definition={type:`Extent`,metadata:{},params:[{name:`field`,type:`field`,required:!0}]},U(ZS,G,{transform(e,t){let n=this.value,r=e.field,i=t.changed()||t.modified(r.fields)||e.modified(`field`),a=n[0],o=n[1];if((i||a==null)&&(a=1/0,o=-1/0),t.visit(i?t.SOURCE:t.ADD,e=>{let t=Ch(r(e));t!=null&&(to&&(o=t))}),!Number.isFinite(a)||!Number.isFinite(o)){let e=Ym(r);e&&=` for field "${e}"`,t.dataflow.warn(`Infinite extent${e}: [${a}, ${o}]`),a=o=void 0}this.value=[a,o]}}),U(QS,nx,{connect(e){return this.detachSubflow=e.detachSubflow,this.targets().add(e),e.source=this},add(e){this.count+=1,this.value.add.push(e)},rem(e){--this.count,this.value.rem.push(e)},mod(e){this.value.mod.push(e)},init(e){this.value.init(e,e.NO_SOURCE)},evaluate(){return this.value}}),U($S,G,{activate(e){this._targets[this._targets.active++]=e},subflow(e,t,n,r){let i=this.value,a=sg(i,e)&&i[e],o,s;return a?a.value.stampe&&e.count>0);this.initTargets(e)}},initTargets(e){let t=this._targets,n=t.length,r=e?e.length:0,i=0;for(;ithis.subflow(e,i,t);return this._group=e.group||{},this.initTargets(),t.visit(t.REM,e=>{let t=Kb(e),n=a.get(t);n!==void 0&&(a.delete(t),s(n).rem(e))}),t.visit(t.ADD,e=>{let t=r(e);a.set(Kb(e),t),s(t).add(e)}),o||t.modified(r.fields)?t.visit(t.MOD,e=>{let t=Kb(e),n=a.get(t),i=r(e);n===i?s(i).mod(e):(a.set(t,i),s(n).rem(e),s(i).add(e))}):t.changed(t.MOD)&&t.visit(t.MOD,e=>{s(a.get(Kb(e))).mod(e)}),o&&t.visit(t.REFLOW,e=>{let t=Kb(e),n=a.get(t),i=r(e);n!==i&&(a.set(t,i),s(n).rem(e),s(i).add(e))}),t.clean()?n.runAfter(()=>{this.clean(),a.clean()}):a.empty>n.cleanThreshold&&n.runAfter(a.clean),t}}),U(eC,nx),tC.Definition={type:`Filter`,metadata:{changes:!0},params:[{name:`expr`,type:`expr`,required:!0}]},U(tC,G,{transform(e,t){let n=t.dataflow,r=this.value,i=t.fork(),a=i.add,o=i.rem,s=i.mod,c=e.expr,l=!0;t.visit(t.REM,e=>{let t=Kb(e);r.has(t)?r.delete(t):o.push(e)}),t.visit(t.ADD,t=>{c(t,e)?a.push(t):r.set(Kb(t),1)});function u(t){let n=Kb(t),i=c(t,e),u=r.get(n);i&&u?(r.delete(n),a.push(t)):!i&&!u?(r.set(n,1),o.push(t)):l&&i&&!u&&s.push(t)}return t.visit(t.MOD,u),e.modified()&&(l=!1,t.visit(t.REFLOW,u)),r.empty>n.cleanThreshold&&n.runAfter(r.clean),i}}),nC.Definition={type:`Flatten`,metadata:{generates:!0},params:[{name:`fields`,type:`field`,array:!0,required:!0},{name:`index`,type:`string`},{name:`as`,type:`string`,array:!0}]},U(nC,G,{transform(e,t){let n=t.fork(t.NO_SOURCE),r=e.fields,i=qS(r,e.as||[]),a=e.index||null,o=i.length;return n.rem=this.value,t.visit(t.SOURCE,e=>{let t=r.map(t=>t(e)),s=t.reduce((e,t)=>Math.max(e,t.length),0),c=0,l,u;for(;c{for(let t=0,a;tt[r]=n(t,e))}}),U(aC,G,{transform(e,t){let n=t.fork(t.ALL),r=e.generator,i=this.value,a=e.size-i.length,o,s,c;if(a>0){for(o=[];--a>=0;)o.push(c=Jb(r(e))),i.push(c);n.add=n.add.length?n.materialize(n.ADD).add.concat(o):o}else s=i.slice(0,-a),n.rem=n.rem.length?n.materialize(n.REM).rem.concat(s):s,i=i.slice(-a);return n.source=this.value=i,n}}),GC={value:`value`,median:poe,mean:doe,min:Jg,max:qg},KC=[],oC.Definition={type:`Impute`,metadata:{changes:!0},params:[{name:`field`,type:`field`,required:!0},{name:`key`,type:`field`,required:!0},{name:`keyvals`,array:!0},{name:`groupby`,type:`field`,array:!0},{name:`method`,type:`enum`,default:`value`,values:[`value`,`mean`,`median`,`max`,`min`]},{name:`value`,default:0}]},U(oC,G,{transform(e,t){var n=t.fork(t.ALL),r=ple(e),i=mle(e),a=Ym(e.field),o=Ym(e.key),s=(e.groupby||[]).map(Ym),c=hle(t.source,e.groupby,e.key,e.keyvals),l=[],u=this.value,d=c.domain.length,f,p,m,h,g,_,v,y,b,x;for(g=0,y=c.length;gn.add(e))):(i=n.value=n.value||this.init(e),t.visit(t.REM,e=>n.rem(e)),t.visit(t.ADD,e=>n.add(e))),n.changes(),t.visit(t.SOURCE,e=>{ig(e,i[n.cellkey(e)].tuple)}),t.reflow(r).modifies(this._outputs)},changes(){let e=this._adds,t=this._mods,n,r;for(n=0,r=this._alen;n{let n=$x(t,o)[s],r=e.counts?t.length:1;CS(n,u||og(t),d,f).forEach(e=>{let n={};for(let e=0;e(this._pending=Gh(e.data),e=>e.touch(this)))}:n.request(e.url,e.format).then(e=>dC(this,t,Gh(e.data)))}}),fC.Definition={type:`Lookup`,metadata:{modifies:!0},params:[{name:`index`,type:`index`,params:[{name:`from`,type:`data`,required:!0},{name:`key`,type:`field`,required:!0}]},{name:`values`,type:`field`,array:!0},{name:`fields`,type:`field`,array:!0,required:!0},{name:`as`,type:`string`,array:!0},{name:`default`,default:null}]},U(fC,G,{transform(e,t){let n=e.fields,r=e.index,i=e.values,a=e.default==null?null:e.default,o=e.modified(),s=n.length,c=o?t.SOURCE:t.ADD,l=t,u=e.as,d,f,p;return i?(f=i.length,s>1&&!u&&V(`Multi-field lookup requires explicit "as" parameter.`),u&&u.length!==s*f&&V(`The "as" parameter has too few output field names.`),u||=i.map(Ym),d=function(e){for(var t=0,o=0,c,l;tt.modified(e.fields)),c|=p?t.MOD:0),t.visit(c,d),l.modifies(u)}}),U(pC,nx),U(mC,nx),U(hC,G,{transform(e,t){return this.modified(e.modified()),this.value=e,t.fork(t.NO_SOURCE|t.NO_FIELDS)}}),gC.Definition={type:`Pivot`,metadata:{generates:!0,changes:!0},params:[{name:`groupby`,type:`field`,array:!0},{name:`field`,type:`field`,required:!0},{name:`value`,type:`field`,required:!0},{name:`op`,type:`enum`,values:PC,default:`sum`},{name:`limit`,type:`number`,default:0},{name:`key`,type:`field`}]},U(gC,RS,{_transform:RS.prototype.transform,transform(e,t){return this._transform(ble(e,t),t)}}),U(_C,$S,{transform(e,t){let n=e.subflow,r=e.field,i=e=>this.subflow(Kb(e),n,t,e);return(e.modified(`field`)||r&&t.modified(Xm(r)))&&V(`PreFacet does not support field modification.`),this.initTargets(),r?(t.visit(t.MOD,e=>{let t=i(e);r(e).forEach(e=>t.mod(e))}),t.visit(t.ADD,e=>{let t=i(e);r(e).forEach(e=>t.add(Jb(e)))}),t.visit(t.REM,e=>{let t=i(e);r(e).forEach(e=>t.rem(e))})):(t.visit(t.MOD,e=>i(e).mod(e)),t.visit(t.ADD,e=>i(e).add(e)),t.visit(t.REM,e=>i(e).rem(e))),t.clean()&&t.runAfter(()=>this.clean()),t}}),vC.Definition={type:`Project`,metadata:{generates:!0,changes:!0},params:[{name:`fields`,type:`field`,array:!0},{name:`as`,type:`string`,null:!0,array:!0}]},U(vC,G,{transform(e,t){let n=t.fork(t.NO_SOURCE),r=e.fields,i=qS(e.fields,e.as||[]),a=r?(e,t)=>Cle(e,t,r,i):Xb,o;return this.value?o=this.value:(t=t.addAll(),o=this.value={}),t.visit(t.REM,e=>{let t=Kb(e);n.rem.push(o[t]),o[t]=null}),t.visit(t.ADD,e=>{let t=a(e,Jb({}));o[Kb(e)]=t,n.add.push(t)}),t.visit(t.MOD,e=>{n.mod.push(a(e,o[Kb(e)]))}),n}}),U(yC,G,{transform(e,t){return this.value=e.value,e.modified(`value`)?t.fork(t.NO_SOURCE|t.NO_FIELDS):t.StopPropagation}}),bC.Definition={type:`Quantile`,metadata:{generates:!0,changes:!0},params:[{name:`groupby`,type:`field`,array:!0},{name:`field`,type:`field`,required:!0},{name:`probs`,type:`number`,array:!0},{name:`step`,type:`number`,default:.01},{name:`as`,type:`string`,array:!0,default:[`prob`,`value`]}]},qC=1e-14,U(bC,G,{transform(e,t){let n=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=e.as||[`prob`,`value`];if(this.value&&!e.modified()&&!t.changed())return n.source=this.value,n;let i=t.materialize(t.SOURCE).source,a=JS(i,e.groupby,e.field),o=(e.groupby||[]).map(Ym),s=[],c=e.step||.01,l=e.probs||Zg(c/2,1-qC,c),u=l.length;return a.forEach(e=>{let t=Hx(e,l);for(let n=0;n{let t=Kb(e);n.rem.push(r[t]),r[t]=null}),t.visit(t.ADD,e=>{let t=Yb(e);r[Kb(e)]=t,n.add.push(t)}),t.visit(t.MOD,e=>{let t=r[Kb(e)];for(let r in e)t[r]=e[r],n.modifies(r);n.mod.push(t)})),n}}),SC.Definition={type:`Sample`,metadata:{},params:[{name:`size`,type:`number`,default:1e3}]},U(SC,G,{transform(e,t){let n=t.fork(t.NO_SOURCE),r=e.modified(`size`),i=e.size,a=this.value.reduce((e,t)=>(e[Kb(t)]=1,e),{}),o=this.value,s=this.count,c=0;function l(e){let t,r;o.length=c&&(t=o[r],a[Kb(t)]&&n.rem.push(t),o[r]=e)),++s}if(t.rem.length&&(t.visit(t.REM,e=>{let t=Kb(e);a[t]&&(a[t]=-1,n.rem.push(e)),--s}),o=o.filter(e=>a[Kb(e)]!==-1)),(t.rem.length||r)&&o.length{a[Kb(e)]||l(e)}),c=-1),r&&o.length>i){let e=o.length-i;for(let t=0;t{a[Kb(e)]&&n.mod.push(e)}),t.add.length&&t.visit(t.ADD,l),(t.add.length||c<0)&&(n.add=o.filter(e=>!a[Kb(e)])),this.count=s,this.value=n.source=o,n}}),CC.Definition={type:`Sequence`,metadata:{generates:!0,changes:!0},params:[{name:`start`,type:`number`,required:!0},{name:`stop`,type:`number`,required:!0},{name:`step`,type:`number`,default:1},{name:`as`,type:`string`,default:`data`}]},U(CC,G,{transform(e,t){if(this.value&&!e.modified())return;let n=t.materialize().fork(t.MOD),r=e.as||`data`;return n.rem=this.value?t.rem.concat(this.value):t.rem,this.value=Zg(e.start,e.stop,e.step||1).map(e=>{let t={};return t[r]=e,Jb(t)}),n.add=t.add.concat(this.value),n}}),U(wC,G,{transform(e,t){return this.value=t.source,t.changed()?t.fork(t.NO_SOURCE|t.NO_FIELDS):t.StopPropagation}}),JC=[`unit0`,`unit1`],TC.Definition={type:`TimeUnit`,metadata:{modifies:!0},params:[{name:`field`,type:`field`,required:!0},{name:`interval`,type:`boolean`,default:!0},{name:`units`,type:`enum`,values:Yv,array:!0},{name:`step`,type:`number`,default:1},{name:`maxbins`,type:`number`,default:40},{name:`extent`,type:`date`,array:!0},{name:`inferUnits`,type:`boolean`,default:!1},{name:`timezone`,type:`enum`,default:`local`,values:[`local`,`utc`]},{name:`as`,type:`string`,array:!0,length:2,default:JC}]},U(TC,G,{transform(e,t){let n=e.field,r=e.interval!==!1,i=e.timezone===`utc`,a=this._floor(e,t),o=(i?Av:kv)(a.unit).offset,s=e.as||JC,c=s[0],l=s[1],u=a.step,d=a.start||1/0,f=a.stop||-1/0,p=t.ADD;return(e.modified()||t.changed(t.REM)||t.modified(Xm(n)))&&(t=t.reflow(!0),p=t.SOURCE,d=1/0,f=-1/0),t.visit(p,e=>{let t=n(e),i,s;t==null?(e[c]=null,r&&(e[l]=null)):(e[c]=i=s=a(t),r&&(e[l]=s=o(i,u)),if&&(f=s))}),a.start=d,a.stop=f,t.modifies(r?s:c)},_floor(e,t){let n=e.timezone===`utc`;e.inferUnits&&(e.units||e.step!=null||e.maxbins!=null||e.extent)&&t.dataflow.warn(`TimeUnit inferUnits overrides units, step, maxbins and extent.`);let{units:r,step:i}=e.inferUnits?Rv(t.materialize(t.SOURCE).source,e.field,n):e.units?{units:e.units,step:e.step||1}:Lv({extent:e.extent||og(t.materialize(t.SOURCE).source,e.field),maxbins:e.maxbins}),a=fv(r),o=this.value||{},s=(n?Ov:Dv)(a,i);return s.unit=xh(a),s.units=a,s.step=i,s.start=o.start,s.stop=o.stop,this.value=s}}),U(EC,G,{transform(e,t){let n=t.dataflow,r=e.field,i=this.value,a=e=>i.set(r(e),e),o=!0;return e.modified(`field`)||t.modified(r.fields)?(i.clear(),t.visit(t.SOURCE,a)):t.changed()?(t.visit(t.REM,e=>i.delete(r(e))),t.visit(t.ADD,a)):o=!1,this.modified(o),i.empty>n.cleanThreshold&&n.runAfter(i.clean),t.fork()}}),U(DC,G,{transform(e,t){(!this.value||e.modified(`field`)||e.modified(`sort`)||t.changed()||e.sort&&t.modified(e.sort.fields))&&(this.value=(e.sort?t.source.slice().sort(Qb(e.sort)):t.source).map(e.field))}}),YC={row_number:function(){return{next:e=>e.index+1}},rank:function(){let e;return{init:()=>e=1,next:t=>{let n=t.index,r=t.data;return n&&t.compare(r[n-1],r[n])?e=n+1:e}}},dense_rank:function(){let e;return{init:()=>e=1,next:t=>{let n=t.index,r=t.data;return n&&t.compare(r[n-1],r[n])?++e:e}}},percent_rank:function(){let e=YC.rank(),t=e.next;return{init:e.init,next:e=>(t(e)-1)/(e.data.length-1)}},cume_dist:function(){let e;return{init:()=>e=0,next:t=>{let n=t.data,r=t.compare,i=t.index;if(e0||V(`ntile num must be greater than zero.`);let n=YC.cume_dist(),r=n.next;return{init:n.init,next:e=>Math.ceil(t*r(e))}},lag:function(e,t){return t=+t||1,{next:n=>{let r=n.index-t;return r>=0?e(n.data[r]):null}}},lead:function(e,t){return t=+t||1,{next:n=>{let r=n.index+t,i=n.data;return re(t.data[t.i0])}},last_value:function(e){return{next:t=>e(t.data[t.i1-1])}},nth_value:function(e,t){return t=+t,t>0||V(`nth_value nth must be greater than zero.`),{next:n=>{let r=n.i0+(t-1);return rt=null,next:n=>{let r=e(n.data[n.index]);return r==null?t:t=r}}},next_value:function(e){let t,n;return{init:()=>(t=null,n=-1),next:r=>{let i=r.data;return r.index<=n?t:(n=Tle(e,i,r.index))<0?(n=i.length,t=null):t=e(i[n])}}}},XC=Object.keys(YC),ZC=OC.prototype,ZC.init=function(){this.windows.forEach(e=>e.init()),this.cell&&this.cell.init()},ZC.update=function(e,t){let n=this.cell,r=this.windows,i=e.data,a=r&&r.length,o;if(n){for(o=e.p0;othis.group(i(e)),o=this.state;(!o||n)&&(o=this.state=new OC(e)),n||t.modified(o.inputs)?(this.value={},t.visit(t.SOURCE,e=>a(e).add(e))):(t.visit(t.REM,e=>a(e).remove(e)),t.visit(t.ADD,e=>a(e).add(e)));for(let t=0,n=this._mlen;t{}));function jle(e){return e>1?0:e<-1?cw:Math.acos(e)}function ew(e){return e>=1?lw:e<=-1?-lw:Math.asin(e)}var tw,nw,rw,iw,aw,ow,sw,cw,lw,uw,dw=o((()=>{tw=Math.abs,nw=Math.atan2,rw=Math.cos,iw=Math.max,aw=Math.min,ow=Math.sin,sw=Math.sqrt,cw=Math.PI,lw=cw/2,uw=2*cw}));function fw(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw Error(`invalid digits: ${e}`);if(t>15)return fw;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;t{mw=Math.PI,hw=2*mw,gw=1e-6,_w=hw-gw,vw=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?fw:Mle(e)}moveTo(e,t){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,t){this._append`L${this._x1=+e},${this._y1=+t}`}quadraticCurveTo(e,t,n,r){this._append`Q${+e},${+t},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(e,t,n,r,i,a){this._append`C${+e},${+t},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(e,t,n,r,i){if(e=+e,t=+t,n=+n,r=+r,i=+i,i<0)throw Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(this._x1===null)this._append`M${this._x1=e},${this._y1=t}`;else if(d>gw)if(!(Math.abs(u*s-c*l)>gw)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((mw-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>gw&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>gw||Math.abs(this._y1-l)>gw)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%hw+hw),d>_w?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>gw&&this._append`A${n},${n},0,${+(d>=mw)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}},pw.prototype=vw.prototype})),yw=o((()=>{Nle()}));function bw(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new vw(t)}var xw=o((()=>{yw()}));function Ple(e){return e.innerRadius}function Fle(e){return e.outerRadius}function Ile(e){return e.startAngle}function Lle(e){return e.endAngle}function Rle(e){return e&&e.padAngle}function zle(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function Sw(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/sw(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=v*v+y*y,x=i-a,S=f*h-m*p,C=(y<0?-1:1)*sw(iw(0,x*x*b-S*S)),w=(S*y-v*C)/b,T=(-S*v-y*C)/b,E=(S*y+v*C)/b,D=(-S*v+y*C)/b,O=w-g,k=T-_,A=E-g,j=D-_;return O*O+k*k>A*A+j*j&&(w=E,T=D),{cx:w,cy:T,x01:-u,y01:-d,x11:w*(i/x-1),y11:T*(i/x-1)}}function Ble(){var e=Ple,t=Fle,n=QC(0),r=null,i=Ile,a=Lle,o=Rle,s=null,c=bw(l);function l(){var l,u,d=+e.apply(this,arguments),f=+t.apply(this,arguments),p=i.apply(this,arguments)-lw,m=a.apply(this,arguments)-lw,h=tw(m-p),g=m>p;if(s||=l=c(),f1e-12))s.moveTo(0,0);else if(h>uw-1e-12)s.moveTo(f*rw(p),f*ow(p)),s.arc(0,0,f,p,m,!g),d>1e-12&&(s.moveTo(d*rw(m),d*ow(m)),s.arc(0,0,d,m,p,g));else{var _=p,v=m,y=p,b=m,x=h,S=h,C=o.apply(this,arguments)/2,w=C>1e-12&&(r?+r.apply(this,arguments):sw(d*d+f*f)),T=aw(tw(f-d)/2,+n.apply(this,arguments)),E=T,D=T,O,k;if(w>1e-12){var A=ew(w/d*ow(C)),j=ew(w/f*ow(C));(x-=A*2)>1e-12?(A*=g?1:-1,y+=A,b-=A):(x=0,y=b=(p+m)/2),(S-=j*2)>1e-12?(j*=g?1:-1,_+=j,v-=j):(S=0,_=v=(p+m)/2)}var M=f*rw(_),ee=f*ow(_),N=d*rw(b),te=d*ow(b);if(T>1e-12){var ne=f*rw(v),P=f*ow(v),re=d*rw(y),F=d*ow(y),ie;if(h1e-12?D>1e-12?(O=Sw(re,F,M,ee,f,D,g),k=Sw(ne,P,N,te,f,D,g),s.moveTo(O.cx+O.x01,O.cy+O.y01),D1e-12)||!(x>1e-12)?s.lineTo(N,te):E>1e-12?(O=Sw(N,te,ne,P,d,-E,g),k=Sw(M,ee,re,F,d,-E,g),s.lineTo(O.cx+O.x01,O.cy+O.y01),E{$C(),dw(),xw()}));function Cw(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}var ww=o((()=>{Array.prototype.slice}));function Tw(e){this._context=e}function Ew(e){return new Tw(e)}var Dw=o((()=>{Tw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}}}));function Ow(e){return e[0]}function kw(e){return e[1]}var Aw=o((()=>{}));function jw(e,t){var n=QC(!0),r=null,i=Ew,a=null,o=bw(s);e=typeof e==`function`?e:e===void 0?Ow:QC(e),t=typeof t==`function`?t:t===void 0?kw:QC(t);function s(s){var c,l=(s=Cw(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c{ww(),$C(),Dw(),xw(),Aw()}));function Nw(e,t,n){var r=null,i=QC(!0),a=null,o=Ew,s=null,c=bw(l);e=typeof e==`function`?e:e===void 0?Ow:QC(+e),t=typeof t==`function`?t:QC(t===void 0?0:+t),n=typeof n==`function`?n:n===void 0?kw:QC(+n);function l(l){var u,d,f,p=(l=Cw(l)).length,m,h=!1,g,_=Array(p),v=Array(p);for(a??(s=o(g=c())),u=0;u<=p;++u){if(!(u=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return jw().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:QC(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:QC(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:QC(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:QC(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:QC(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:QC(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:QC(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var Hle=o((()=>{ww(),$C(),Dw(),Mw(),xw(),Aw()})),Pw,Fw=o((()=>{dw(),Pw={draw(e,t){let n=sw(t/cw);e.moveTo(n,0),e.arc(0,0,n,0,uw)}}}));function Ule(e,t){let n=null,r=bw(i);e=typeof e==`function`?e:QC(e||Pw),t=typeof t==`function`?t:QC(t===void 0?64:+t);function i(){let i;if(n||=i=r(),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),i)return n=null,i+``||null}return i.type=function(t){return arguments.length?(e=typeof t==`function`?t:QC(t),i):e},i.size=function(e){return arguments.length?(t=typeof e==`function`?e:QC(+e),i):t},i.context=function(e){return arguments.length?(n=e??null,i):n},i}var Wle=o((()=>{$C(),xw(),Fw()}));function Iw(){}var Lw=o((()=>{}));function Rw(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function zw(e){this._context=e}function Gle(e){return new zw(e)}var Bw=o((()=>{zw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Rw(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Rw(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}}}));function Vw(e){this._context=e}function Kle(e){return new Vw(e)}var qle=o((()=>{Lw(),Bw(),Vw.prototype={areaStart:Iw,areaEnd:Iw,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Rw(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}}}));function Hw(e){this._context=e}function Jle(e){return new Hw(e)}var Yle=o((()=>{Bw(),Hw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Rw(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}}}));function Uw(e,t){this._basis=new zw(e),this._beta=t}var Ww,Xle=o((()=>{Bw(),Uw.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var r=e[0],i=t[0],a=e[n]-r,o=t[n]-i,s=-1,c;++s<=n;)c=s/n,this._basis.point(this._beta*e[s]+(1-this._beta)*(r+c*a),this._beta*t[s]+(1-this._beta)*(i+c*o));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}},Ww=(function e(t){function n(e){return t===1?new zw(e):new Uw(e,t)}return n.beta=function(t){return e(+t)},n})(.85)}));function Gw(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function Kw(e,t){this._context=e,this._k=(1-t)/6}var qw,Jw=o((()=>{Kw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Gw(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:Gw(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},qw=(function e(t){function n(e){return new Kw(e,t)}return n.tension=function(t){return e(+t)},n})(0)}));function Yw(e,t){this._context=e,this._k=(1-t)/6}var Xw,Zw=o((()=>{Lw(),Jw(),Yw.prototype={areaStart:Iw,areaEnd:Iw,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:Gw(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},Xw=(function e(t){function n(e){return new Yw(e,t)}return n.tension=function(t){return e(+t)},n})(0)}));function Qw(e,t){this._context=e,this._k=(1-t)/6}var $w,eT=o((()=>{Jw(),Qw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Gw(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},$w=(function e(t){function n(e){return new Qw(e,t)}return n.tension=function(t){return e(+t)},n})(0)}));function tT(e,t,n){var r=e._x1,i=e._y1,a=e._x2,o=e._y2;if(e._l01_a>1e-12){var s=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,c=3*e._l01_a*(e._l01_a+e._l12_a);r=(r*s-e._x0*e._l12_2a+e._x2*e._l01_2a)/c,i=(i*s-e._y0*e._l12_2a+e._y2*e._l01_2a)/c}if(e._l23_a>1e-12){var l=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,u=3*e._l23_a*(e._l23_a+e._l12_a);a=(a*l+e._x1*e._l23_2a-t*e._l12_2a)/u,o=(o*l+e._y1*e._l23_2a-n*e._l12_2a)/u}e._context.bezierCurveTo(r,i,a,o,e._x2,e._y2)}function nT(e,t){this._context=e,this._alpha=t}var rT,iT=o((()=>{dw(),Jw(),nT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=(n*n+r*r)**+this._alpha)}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:tT(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},rT=(function e(t){function n(e){return t?new nT(e,t):new Kw(e,0)}return n.alpha=function(t){return e(+t)},n})(.5)}));function aT(e,t){this._context=e,this._alpha=t}var oT,Zle=o((()=>{Zw(),Lw(),iT(),aT.prototype={areaStart:Iw,areaEnd:Iw,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=(n*n+r*r)**+this._alpha)}switch(this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:tT(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},oT=(function e(t){function n(e){return t?new aT(e,t):new Yw(e,0)}return n.alpha=function(t){return e(+t)},n})(.5)}));function sT(e,t){this._context=e,this._alpha=t}var cT,Qle=o((()=>{eT(),iT(),sT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=(n*n+r*r)**+this._alpha)}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:tT(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},cT=(function e(t){function n(e){return t?new sT(e,t):new Qw(e,0)}return n.alpha=function(t){return e(+t)},n})(.5)}));function lT(e){this._context=e}function $le(e){return new lT(e)}var eue=o((()=>{Lw(),lT.prototype={areaStart:Iw,areaEnd:Iw,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}}}));function uT(e){return e<0?-1:1}function dT(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(uT(a)+uT(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function fT(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function pT(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function mT(e){this._context=e}function hT(e){this._context=new gT(e)}function gT(e){this._context=e}function tue(e){return new mT(e)}function nue(e){return new hT(e)}var rue=o((()=>{mT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:pT(this,this._t0,fT(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,pT(this,fT(this,n=dT(this,e,t)),n);break;default:pT(this,this._t0,n=dT(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}},(hT.prototype=Object.create(mT.prototype)).point=function(e,t){mT.prototype.point.call(this,t,e)},gT.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}}}));function _T(e){this._context=e}function vT(e){var t,n=e.length-1,r,i=Array(n),a=Array(n),o=Array(n);for(i[0]=0,a[0]=2,o[0]=e[0]+2*e[1],t=1;t=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t{_T.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=vT(e),i=vT(t),a=0,o=1;o{yT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}this._x=e,this._y=t}}})),uue=o((()=>{Vle(),Hle(),Mw(),ww(),$C(),dw(),Dw(),xw(),Wle(),Fw(),qle(),Yle(),Bw(),Xle(),Zw(),eT(),Jw(),Zle(),Qle(),iT(),eue(),rue(),aue(),lue()}));function bT(e,t){if(typeof document<`u`&&document.createElement){let n=document.createElement(`canvas`);if(n&&n.getContext)return n.width=e,n.height=t,n}return null}var xT,ST=o((()=>{xT=()=>typeof Image<`u`?Image:null}));function CT(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function wT(e,t){switch(arguments.length){case 0:break;case 1:typeof e==`function`?this.interpolator(e):this.range(e);break;default:this.domain(e),typeof t==`function`?this.interpolator(t):this.range(t);break}return this}var TT=o((()=>{}));function ET(){var e=new Bg,t=[],n=[],r=DT;function i(i){let a=e.get(i);if(a===void 0){if(r!==DT)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new Bg;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return ET(t,n).unknown(r)},CT.apply(i,arguments),i}var DT,due=o((()=>{Qg(),TT(),DT=Symbol(`implicit`)}));function OT(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function kT(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}var AT=o((()=>{}));function jT(){}function MT(){return this.rgb().formatHex()}function fue(){return this.rgb().formatHex8()}function pue(){return KT(this).formatHsl()}function NT(){return this.rgb().formatRgb()}function PT(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=rE.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?FT(t):n===3?new zT(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?IT(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?IT(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=iE.exec(e))?new zT(t[1],t[2],t[3],1):(t=aE.exec(e))?new zT(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oE.exec(e))?IT(t[1],t[2],t[3],t[4]):(t=sE.exec(e))?IT(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=cE.exec(e))?GT(t[1],t[2]/100,t[3]/100,1):(t=lE.exec(e))?GT(t[1],t[2]/100,t[3]/100,t[4]):uE.hasOwnProperty(e)?FT(uE[e]):e===`transparent`?new zT(NaN,NaN,NaN,0):null}function FT(e){return new zT(e>>16&255,e>>8&255,e&255,1)}function IT(e,t,n,r){return r<=0&&(e=t=n=NaN),new zT(e,t,n,r)}function LT(e){return e instanceof jT||(e=PT(e)),e?(e=e.rgb(),new zT(e.r,e.g,e.b,e.opacity)):new zT}function RT(e,t,n,r){return arguments.length===1?LT(e):new zT(e,t,n,r??1)}function zT(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function BT(){return`#${WT(this.r)}${WT(this.g)}${WT(this.b)}`}function mue(){return`#${WT(this.r)}${WT(this.g)}${WT(this.b)}${WT((isNaN(this.opacity)?1:this.opacity)*255)}`}function VT(){let e=HT(this.opacity);return`${e===1?`rgb(`:`rgba(`}${UT(this.r)}, ${UT(this.g)}, ${UT(this.b)}${e===1?`)`:`, ${e})`}`}function HT(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function UT(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function WT(e){return e=UT(e),(e<16?`0`:``)+e.toString(16)}function GT(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new JT(e,t,n,r)}function KT(e){if(e instanceof JT)return new JT(e.h,e.s,e.l,e.opacity);if(e instanceof jT||(e=PT(e)),!e)return new JT;if(e instanceof JT)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new JT(o,s,c,e.opacity)}function qT(e,t,n,r){return arguments.length===1?KT(e):new JT(e,t,n,r??1)}function JT(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function YT(e){return e=(e||0)%360,e<0?e+360:e}function XT(e){return Math.max(0,Math.min(1,e||0))}function ZT(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var QT,$T,eE,tE,nE,rE,iE,aE,oE,sE,cE,lE,uE,dE=o((()=>{AT(),QT=.7,$T=1/QT,eE=`\\s*([+-]?\\d+)\\s*`,tE=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,nE=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,rE=/^#([0-9a-f]{3,8})$/,iE=RegExp(`^rgb\\(${eE},${eE},${eE}\\)$`),aE=RegExp(`^rgb\\(${nE},${nE},${nE}\\)$`),oE=RegExp(`^rgba\\(${eE},${eE},${eE},${tE}\\)$`),sE=RegExp(`^rgba\\(${nE},${nE},${nE},${tE}\\)$`),cE=RegExp(`^hsl\\(${tE},${nE},${nE}\\)$`),lE=RegExp(`^hsla\\(${tE},${nE},${nE},${tE}\\)$`),uE={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},OT(jT,PT,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:MT,formatHex:MT,formatHex8:fue,formatHsl:pue,formatRgb:NT,toString:NT}),OT(zT,RT,kT(jT,{brighter(e){return e=e==null?$T:$T**+e,new zT(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?QT:QT**+e,new zT(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new zT(UT(this.r),UT(this.g),UT(this.b),HT(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:BT,formatHex:BT,formatHex8:mue,formatRgb:VT,toString:VT})),OT(JT,qT,kT(jT,{brighter(e){return e=e==null?$T:$T**+e,new JT(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?QT:QT**+e,new JT(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new zT(ZT(e>=240?e-240:e+120,i,r),ZT(e,i,r),ZT(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new JT(YT(this.h),XT(this.s),XT(this.l),HT(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=HT(this.opacity);return`${e===1?`hsl(`:`hsla(`}${YT(this.h)}, ${XT(this.s)*100}%, ${XT(this.l)*100}%${e===1?`)`:`, ${e})`}`}}))})),fE,pE,mE=o((()=>{fE=Math.PI/180,pE=180/Math.PI}));function hE(e){if(e instanceof _E)return new _E(e.l,e.a,e.b,e.opacity);if(e instanceof CE)return wE(e);e instanceof zT||(e=LT(e));var t=xE(e.r),n=xE(e.g),r=xE(e.b),i=vE((.2225045*t+.7168786*n+.0606169*r)/DE),a,o;return t===n&&n===r?a=o=i:(a=vE((.4360747*t+.3850649*n+.1430804*r)/EE),o=vE((.0139322*t+.0971045*n+.7141733*r)/OE)),new _E(116*i-16,500*(a-i),200*(i-o),e.opacity)}function gE(e,t,n,r){return arguments.length===1?hE(e):new _E(e,t,n,r??1)}function _E(e,t,n,r){this.l=+e,this.a=+t,this.b=+n,this.opacity=+r}function vE(e){return e>ME?e**(1/3):e/jE+kE}function yE(e){return e>AE?e*e*e:jE*(e-kE)}function bE(e){return 255*(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055)}function xE(e){return(e/=255)<=.04045?e/12.92:((e+.055)/1.055)**2.4}function hue(e){if(e instanceof CE)return new CE(e.h,e.c,e.l,e.opacity);if(e instanceof _E||(e=hE(e)),e.a===0&&e.b===0)return new CE(NaN,0{AT(),dE(),mE(),TE=18,EE=.96422,DE=1,OE=.82521,kE=4/29,AE=6/29,jE=3*AE*AE,ME=AE*AE*AE,OT(_E,gE,kT(jT,{brighter(e){return new _E(this.l+TE*(e??1),this.a,this.b,this.opacity)},darker(e){return new _E(this.l-TE*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,t=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return t=EE*yE(t),e=DE*yE(e),n=OE*yE(n),new zT(bE(3.1338561*t-1.6168667*e-.4906146*n),bE(-.9787684*t+1.9161415*e+.033454*n),bE(.0719453*t-.2289914*e+1.4052427*n),this.opacity)}})),OT(CE,SE,kT(jT,{brighter(e){return new CE(this.h,this.c,this.l+TE*(e??1),this.opacity)},darker(e){return new CE(this.h,this.c,this.l-TE*(e??1),this.opacity)},rgb(){return wE(this).rgb()}}))}));function _ue(e){if(e instanceof PE)return new PE(e.h,e.s,e.l,e.opacity);e instanceof zT||(e=LT(e));var t=e.r/255,n=e.g/255,r=e.b/255,i=(HE*r+BE*t-VE*n)/(HE+BE-VE),a=r-i,o=(zE*(n-i)-LE*a)/RE,s=Math.sqrt(o*o+a*a)/(zE*i*(1-i)),c=s?Math.atan2(o,a)*pE-120:NaN;return new PE(c<0?c+360:c,s,i,e.opacity)}function NE(e,t,n,r){return arguments.length===1?_ue(e):new PE(e,t,n,r??1)}function PE(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}var FE,IE,LE,RE,zE,BE,VE,HE,vue=o((()=>{AT(),dE(),mE(),FE=-.14861,IE=1.78277,LE=-.29227,RE=-.90649,zE=1.97294,BE=zE*RE,VE=zE*IE,HE=IE*LE-RE*FE,OT(PE,NE,kT(jT,{brighter(e){return e=e==null?$T:$T**+e,new PE(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?QT:QT**+e,new PE(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=isNaN(this.h)?0:(this.h+120)*fE,t=+this.l,n=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(e),i=Math.sin(e);return new zT(255*(t+n*(FE*r+IE*i)),255*(t+n*(LE*r+RE*i)),255*(t+zE*r*n),this.opacity)}}))})),UE=o((()=>{dE(),gue(),vue()}));function WE(e,t,n,r,i){var a=e*e,o=a*e;return((1-3*e+3*a-o)*t+(4-6*a+3*o)*n+(1+3*e+3*a-3*o)*r+o*i)/6}function GE(e){var t=e.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),i=e[r],a=e[r+1],o=r>0?e[r-1]:2*i-a,s=r{}));function qE(e){var t=e.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*t),i=e[(r+t-1)%t],a=e[r%t],o=e[(r+1)%t],s=e[(r+2)%t];return WE((n-r/t)*t,i,a,o,s)}}var JE=o((()=>{KE()})),YE,XE=o((()=>{YE=e=>()=>e}));function ZE(e,t){return function(n){return e+n*t}}function yue(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function QE(e,t){var n=t-e;return n?ZE(e,n>180||n<-180?n-360*Math.round(n/360):n):YE(isNaN(e)?t:e)}function bue(e){return(e=+e)==1?$E:function(t,n){return n-t?yue(t,n,e):YE(isNaN(t)?n:t)}}function $E(e,t){var n=t-e;return n?ZE(e,n):YE(isNaN(e)?t:e)}var eD=o((()=>{XE()}));function xue(e){return function(t){var n=t.length,r=Array(n),i=Array(n),a=Array(n),o,s;for(o=0;o{UE(),KE(),JE(),eD(),tD=(function e(t){var n=bue(t);function r(e,t){var r=n((e=RT(e)).r,(t=RT(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=$E(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1),Sue=xue(GE),Cue=xue(qE)}));function nD(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i{}));function Eue(e,t){return(Tue(t)?nD:Due)(e,t)}function Due(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o{lD(),rD()}));function kue(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}var Aue=o((()=>{}));function iD(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var aD=o((()=>{}));function jue(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=cD(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var Mue=o((()=>{lD()}));function Nue(e){return function(){return e}}function Pue(e){return function(t){return e(t)+``}}function Fue(e,t){var n=oD.lastIndex=sD.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=oD.exec(e))&&(i=sD.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:iD(r,i)})),n=sD.lastIndex;return n{aD(),oD=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,sD=new RegExp(oD.source,`g`)}));function cD(e,t){var n=typeof t,r;return t==null||n===`boolean`?YE(t):(n===`number`?iD:n===`string`?(r=PT(t))?(t=r,tD):Fue:t instanceof PT?tD:t instanceof Date?kue:Tue(t)?nD:Array.isArray(t)?Due:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?jue:iD)(e,t)}var lD=o((()=>{UE(),wue(),Oue(),Aue(),aD(),Mue(),Iue(),XE(),rD()}));function Lue(e){var t=e.length;return function(n){return e[Math.max(0,Math.min(t-1,Math.floor(n*t)))]}}var Rue=o((()=>{}));function zue(e,t){var n=QE(+e,+t);return function(e){var t=n(e);return t-360*Math.floor(t/360)}}var Bue=o((()=>{eD()}));function uD(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var Vue=o((()=>{}));function Hue(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r{dD=180/Math.PI,fD={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1}}));function Wue(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?fD:Hue(t.a,t.b,t.c,t.d,t.e,t.f)}function Gue(e){return e==null||(pD||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),pD.setAttribute(`transform`,e),!(e=pD.transform.baseVal.consolidate()))?fD:(e=e.matrix,Hue(e.a,e.b,e.c,e.d,e.e,e.f))}var pD,Kue=o((()=>{Uue()}));function que(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:iD(e,i)},{i:c-2,x:iD(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:iD(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:iD(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:iD(e,n)},{i:s-2,x:iD(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t{aD(),Kue(),Jue=que(Wue,`px, `,`px)`,`deg)`),Yue=que(Gue,`, `,`)`,`)`)}));function Zue(e){return((e=Math.exp(e))+1/e)/2}function Que(e){return((e=Math.exp(e))-1/e)/2}function $ue(e){return((e=Math.exp(2*e))-1)/(e+1)}var ede,tde,nde=o((()=>{ede=1e-12,tde=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p{UE(),eD(),ide=rde(QE),ade=rde($E)}));function sde(e,t){var n=$E((e=gE(e)).l,(t=gE(t)).l),r=$E(e.a,t.a),i=$E(e.b,t.b),a=$E(e.opacity,t.opacity);return function(t){return e.l=n(t),e.a=r(t),e.b=i(t),e.opacity=a(t),e+``}}var cde=o((()=>{UE(),eD()}));function lde(e){return function(t,n){var r=e((t=SE(t)).h,(n=SE(n)).h),i=$E(t.c,n.c),a=$E(t.l,n.l),o=$E(t.opacity,n.opacity);return function(e){return t.h=r(e),t.c=i(e),t.l=a(e),t.opacity=o(e),t+``}}}var ude,dde,fde=o((()=>{UE(),eD(),ude=lde(QE),dde=lde($E)}));function pde(e){return(function t(n){n=+n;function r(t,r){var i=e((t=NE(t)).h,(r=NE(r)).h),a=$E(t.s,r.s),o=$E(t.l,r.l),s=$E(t.opacity,r.opacity);return function(e){return t.h=i(e),t.s=a(e),t.l=o(e**+n),t.opacity=s(e),t+``}}return r.gamma=t,r})(1)}var mde,hde,gde=o((()=>{UE(),eD(),mde=pde(QE),hde=pde($E)}));function mD(e,t){t===void 0&&(t=e,e=cD);for(var n=0,r=t.length-1,i=t[0],a=Array(r<0?0:r);n{lD()}));function vde(e,t){for(var n=Array(t),r=0;r{})),bde=c({interpolate:()=>cD,interpolateArray:()=>Eue,interpolateBasis:()=>GE,interpolateBasisClosed:()=>qE,interpolateCubehelix:()=>mde,interpolateCubehelixLong:()=>hde,interpolateDate:()=>kue,interpolateDiscrete:()=>Lue,interpolateHcl:()=>ude,interpolateHclLong:()=>dde,interpolateHsl:()=>ide,interpolateHslLong:()=>ade,interpolateHue:()=>zue,interpolateLab:()=>sde,interpolateNumber:()=>iD,interpolateNumberArray:()=>nD,interpolateObject:()=>jue,interpolateRgb:()=>tD,interpolateRgbBasis:()=>Sue,interpolateRgbBasisClosed:()=>Cue,interpolateRound:()=>uD,interpolateString:()=>Fue,interpolateTransformCss:()=>Jue,interpolateTransformSvg:()=>Yue,interpolateZoom:()=>tde,piecewise:()=>mD,quantize:()=>vde}),hD=o((()=>{lD(),Oue(),KE(),JE(),Aue(),Rue(),Bue(),aD(),rD(),Mue(),Vue(),Iue(),Xue(),nde(),wue(),ode(),cde(),fde(),gde(),_de(),yde()}));function xde(e){return function(){return e}}var Sde=o((()=>{}));function gD(e){return+e}var _D=o((()=>{}));function vD(e){return e}function yD(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:xde(isNaN(t)?NaN:.5)}function Cde(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function wde(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i2?Tde:wde,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),iD))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,gD),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=uD,u()},d.clamp=function(e){return arguments.length?(o=e?!0:vD,u()):o!==vD},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function Ede(){return xD()(vD,vD)}var SD,CD=o((()=>{Qg(),hD(),Sde(),_D(),SD=[0,1]}));function Dde(e,t,n,r){var i=Kg(e,t,n),a;switch(r=r_(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=Joe(i,o))&&(r.precision=a),d_(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=Xoe(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=Koe(i))&&(r.precision=a-(r.type===`%`)*2);break}return u_(r)}var Ode=o((()=>{Qg(),f_()}));function wD(e){var t=e.domain;return e.ticks=function(e){var n=t();return Wg(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Dde(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s0;){if(l=Gg(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function kde(){var e=Ede();return e.copy=function(){return bD(e,kde())},CT.apply(e,arguments),wD(e)}var TD=o((()=>{Qg(),CD(),TT(),Ode()}));function Ade(e){var t;function n(e){return e==null||isNaN(e=+e)?t:e}return n.invert=n,n.domain=n.range=function(t){return arguments.length?(e=Array.from(t,gD),n):e.slice()},n.unknown=function(e){return arguments.length?(t=e,n):t},n.copy=function(){return Ade(e).unknown(t)},e=arguments.length?Array.from(e,gD):[0,1],wD(n)}var jde=o((()=>{TD(),_D()}));function Mde(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return a{}));function Pde(e){return Math.log(e)}function Fde(e){return Math.exp(e)}function Ide(e){return-Math.log(-e)}function Lde(e){return-Math.exp(-e)}function Rde(e){return isFinite(e)?+(`1e`+e):e<0?0:e}function zde(e){return e===10?Rde:e===Math.E?Math.exp:t=>e**+t}function Bde(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function Vde(e){return(t,n)=>-e(-t,n)}function ED(e){let t=e(Pde,Fde),n=t.domain,r=10,i,a;function o(){return i=Bde(r),a=zde(r),n()[0]<0?(i=Vde(i),a=Vde(a),e(Ide,Lde)):e(Pde,Fde),t}return t.base=function(e){return arguments.length?(r=+e,o()):r},t.domain=function(e){return arguments.length?(n(e),o()):n()},t.ticks=e=>{let t=n(),o=t[0],s=t[t.length-1],c=s0){for(;l<=u;++l)for(d=1;ds)break;m.push(f)}}else for(;l<=u;++l)for(d=r-1;d>=1;--d)if(f=l>0?d/a(-l):d*a(l),!(fs)break;m.push(f)}m.length*2{if(e??=10,n??=r===10?`s`:`,`,typeof n!=`function`&&(!(r%1)&&(n=r_(n)).precision==null&&(n.trim=!0),n=u_(n)),e===1/0)return n;let o=Math.max(1,r*e/t.ticks().length);return e=>{let t=e/a(Math.round(i(e)));return t*rn(Mde(n(),{floor:e=>a(Math.floor(i(e))),ceil:e=>a(Math.ceil(i(e)))})),t}function Hde(){let e=ED(xD()).domain([1,10]);return e.copy=()=>bD(e,Hde()).base(e.base()),CT.apply(e,arguments),e}var DD=o((()=>{Qg(),f_(),Nde(),CD(),TT()}));function Ude(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function Wde(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function OD(e){var t=1,n=e(Ude(t),Wde(t));return n.constant=function(n){return arguments.length?e(Ude(t=+n),Wde(t)):t},wD(n)}function Gde(){var e=OD(xD());return e.copy=function(){return bD(e,Gde()).constant(e.constant())},CT.apply(e,arguments)}var kD=o((()=>{TD(),CD(),TT()}));function Kde(e){return function(t){return t<0?-((-t)**+e):t**+e}}function qde(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function Jde(e){return e<0?-e*e:e*e}function AD(e){var t=e(vD,vD),n=1;function r(){return n===1?e(vD,vD):n===.5?e(qde,Jde):e(Kde(n),Kde(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,r()):n},wD(t)}function jD(){var e=AD(xD());return e.copy=function(){return bD(e,jD()).exponent(e.exponent())},CT.apply(e,arguments),e}function Yde(){return jD.apply(null,arguments).exponent(.5)}var MD=o((()=>{TD(),CD(),TT()}));function Xde(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r0?n[i-1]:e[0],i{Qg(),TT()}));function Qde(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[Ig(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return Qde().domain([e,t]).range(i).unknown(a)},CT.apply(wD(o),arguments)}var $de=o((()=>{Qg(),TD(),TT()}));function efe(){var e=[.5],t=[0,1],n,r=1;function i(i){return i!=null&&i<=i?t[Ig(e,i,0,r)]:n}return i.domain=function(n){return arguments.length?(e=Array.from(n),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(n){return arguments.length?(t=Array.from(n),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(n){var r=t.indexOf(n);return[e[r-1],e[r]]},i.unknown=function(e){return arguments.length?(n=e,i):n},i.copy=function(){return efe().domain(e).range(t).unknown(n)},CT.apply(i,arguments)}var tfe=o((()=>{Qg(),TT()}));function nfe(e){return new Date(e)}function rfe(e){return e instanceof Date?+e:+new Date(+e)}function ND(e,t,n,r,i,a,o,s,c,l){var u=Ede(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e){dv(),tb(),CD(),TT(),Nde()}));function ofe(){return CT.apply(ND(sv,cv,iv,tv,K_,P_,j_,O_,E_,$y).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}var sfe=o((()=>{dv(),tb(),afe(),TT()}));function PD(){var e=0,t=1,n,r,i,a,o=vD,s=!1,c;function l(e){return e==null||isNaN(e=+e)?c:o(i===0?.5:(e=(a(e)-n)*i,s?Math.max(0,Math.min(1,e)):e))}l.domain=function(o){return arguments.length?([e,t]=o,n=a(e=+e),r=a(t=+t),i=n===r?0:1/(r-n),l):[e,t]},l.clamp=function(e){return arguments.length?(s=!!e,l):s},l.interpolator=function(e){return arguments.length?(o=e,l):o};function u(e){return function(t){var n,r;return arguments.length?([n,r]=t,o=e(n,r),l):[o(0),o(1)]}}return l.range=u(cD),l.rangeRound=u(uD),l.unknown=function(e){return arguments.length?(c=e,l):c},function(o){return a=o,n=o(e),r=o(t),i=n===r?0:1/(r-n),l}}function FD(e,t){return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function ID(){var e=wD(PD()(vD));return e.copy=function(){return FD(e,ID())},wT.apply(e,arguments)}function cfe(){var e=ED(PD()).domain([1,10]);return e.copy=function(){return FD(e,cfe()).base(e.base())},wT.apply(e,arguments)}function lfe(){var e=OD(PD());return e.copy=function(){return FD(e,lfe()).constant(e.constant())},wT.apply(e,arguments)}function LD(){var e=AD(PD());return e.copy=function(){return FD(e,LD()).exponent(e.exponent())},wT.apply(e,arguments)}function ufe(){return LD.apply(null,arguments).exponent(.5)}var dfe=o((()=>{hD(),CD(),TT(),TD(),DD(),kD(),MD()}));function RD(){var e=0,t=.5,n=1,r=1,i,a,o,s,c,l=vD,u,d=!1,f;function p(e){return isNaN(e=+e)?f:(e=.5+((e=+u(e))-a)*(r*e{hD(),CD(),TT(),TD(),DD(),dfe(),kD(),MD()})),_fe=o((()=>{Qg(),due(),jde(),TD(),DD(),kD(),MD(),CD(),_D(),Zde(),$de(),tfe(),afe(),sfe(),dfe(),gfe(),Ode()}));function BD(e){for(var t=e.length/6|0,n=Array(t),r=0;r{})),vfe,yfe=o((()=>{VD(),vfe=BD(`1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf`)})),bfe,xfe=o((()=>{VD(),bfe=BD(`7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666`)})),Sfe,Cfe=o((()=>{VD(),Sfe=BD(`1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666`)})),wfe,Tfe=o((()=>{VD(),wfe=BD(`4269d0efb118ff725c6cc5b03ca951ff8ab7a463f297bbf59c6b4e9498a0`)})),Efe,Dfe=o((()=>{VD(),Efe=BD(`a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928`)})),Ofe,kfe=o((()=>{VD(),Ofe=BD(`fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2`)})),Afe,jfe=o((()=>{VD(),Afe=BD(`b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc`)})),Mfe,Nfe=o((()=>{VD(),Mfe=BD(`e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999`)})),Pfe,Ffe=o((()=>{VD(),Pfe=BD(`66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3`)})),Ife,Lfe=o((()=>{VD(),Ife=BD(`8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f`)})),Rfe=o((()=>{yfe(),xfe(),Cfe(),Tfe(),Dfe(),kfe(),jfe(),Nfe(),Ffe(),Lfe(),VD(),hD(),UE()}));function HD(e,t,n){let r=e-t+n*2;return e?r>0?r:1:0}function zfe(e){return function(t){let n=t[0],r=t[1],i;return r=r&&n[c]<=i&&(a<0&&(a=c),o=c);if(!(a<0))return r=e.invertExtent(n[a]),i=e.invertExtent(n[o]),[r[0]===void 0?r[1]:r[0],i[1]===void 0?i[0]:i[1]]}}function UD(){let e=ET().unknown(void 0),t=e.domain,n=e.range,r=[0,1],i,a,o=!1,s=0,c=0,l=.5;delete e.unknown;function u(){let e=t().length,u=r[1]p+i*e);return n(u?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),u()):t()},e.range=function(e){return arguments.length?(r=[+e[0],+e[1]],u()):r.slice()},e.rangeRound=function(e){return r=[+e[0],+e[1]],o=!0,u()},e.bandwidth=function(){return a},e.step=function(){return i},e.round=function(e){return arguments.length?(o=!!e,u()):o},e.padding=function(e){return arguments.length?(c=Math.max(0,Math.min(1,e)),s=c,u()):s},e.paddingInner=function(e){return arguments.length?(s=Math.max(0,Math.min(1,e)),u()):s},e.paddingOuter=function(e){return arguments.length?(c=Math.max(0,Math.min(1,e)),u()):c},e.align=function(e){return arguments.length?(l=Math.max(0,Math.min(1,e)),u()):l},e.invertRange=function(e){if(e[0]==null||e[1]==null)return;let i=r[1]r[1-i])))return u=Math.max(0,Ig(o,c)-1),d=c===l?u:Ig(o,l)-1,c-o[u]>a+1e-10&&++u,i&&(f=u,u=s-d,d=s-f),u>d?void 0:t().slice(u,d+1)},e.invert=function(t){let n=e.invertRange([t,t]);return n&&n[0]},e.copy=function(){return UD().domain(t()).range(r).round(o).paddingInner(s).paddingOuter(c).align(l)},u()}function Vfe(e){let t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,e.copy=function(){return Vfe(t())},e}function Hfe(){return Vfe(UD().paddingInner(1))}function Ufe(e){return xpe.call(e,Ch)}function Wfe(){let e=[],t=[];function n(n){return n==null||n!==n?void 0:t[(Ig(e,n)-1)%t.length]}return n.domain=function(t){return arguments.length?(e=Ufe(t),n):e.slice()},n.range=function(e){return arguments.length?(t=Spe.call(e),n):t.slice()},n.tickFormat=function(t,n){return Dde(e[0],xh(e),t??10,n)},n.copy=function(){return Wfe().domain(n.domain()).range(n.range())},n}function Gfe(e){return e[hO]=!0,e}function Kfe(e){return e&&e[hO]===!0}function qfe(e,t,n){let r=function(){let n=t();return n.invertRange||=n.invert?zfe(n):n.invertExtent?Bfe(n):void 0,n.type=e,Gfe(n)};return r.metadata=Cg(Gh(n)),r}function WD(e,t,n){return arguments.length>1?(mO.set(e,qfe(e,t,n)),this):Jfe(e)?mO.get(e):void 0}function Jfe(e){return mO.has(e)}function GD(e,t){let n=mO.get(e);return n&&n.metadata[t]}function KD(e){return GD(e,lO)}function qD(e){return GD(e,uO)}function JD(e){return GD(e,dO)}function YD(e){return GD(e,`log`)}function Yfe(e){return GD(e,pO)}function Xfe(e){return GD(e,fO)}function Zfe(e){return GD(e,oO)}function Qfe(e,t){let n=t[0],r=xh(t)-n;return function(t){return e(n+t*r)}}function XD(e,t,n){return mD(ZD(t||`rgb`,n),e)}function $fe(e,t){let n=Array(t),r=t+1;for(let i=0;ie[t]?o[t](e[t]()):0),o)}function ZD(e,t){let n=bde[tpe(e)];return t!=null&&n&&n.gamma?n.gamma(t):n}function tpe(e){return`interpolate`+e.toLowerCase().split(`-`).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function npe(e){if(H(e))return e;let t=e.length/6|0,n=Array(t);for(let r=0;r1?(gO[e]=t,this):gO[e]}function $D(e,t,n){let r;if(mg(t)&&(e.bins&&(t=Math.max(t,e.bins.length)),n!=null)){let r=e.domain(),i=Math.min(r[0],xh(r)),a=Math.max(r[0],xh(r));if(t=Math.min(t,Math.floor((a-i)/n||1)+1),!e.bins&&!YD(e.type)&&!Yfe(e.type)&&i1&&Kg(i,a,t)a&&(r=a,a=i,i=r,o=Ope),i=Math.floor(i),a=Math.ceil(a),t=t.map(t=>[t,e(t)]).filter(e=>i<=e[1]&&e[1]<=a).sort(o).map(e=>e[0]),n>0&&t.length>1){let e=[t[0],xh(t)];for(;t.length>n&&t.length>=3;)t=t.filter((e,t)=>!(t%2));t.length<3&&(t=e)}return t}function eO(e,t){return e.bins?ipe(e,e.bins,t):e.ticks?e.ticks(t):e.domain()}function ape(e,t,n,r,i,a){let o=t.type,s=Epe;if(o===`time`||i===`time`)s=e.timeFormat(r);else if(o===`utc`||i===`utc`)s=e.utcFormat(r);else if(YD(o)){let i=e.formatFloat(r);if(a||t.bins)s=i;else{let e=ope(t,n,!1);s=t=>e(t)?i(t):``}}else if(t.tickFormat){let i=t.domain();s=e.formatSpan(i[0],i[i.length-1],n,r)}else r&&(s=e.format(r));return s}function ope(e,t,n){let r=eO(e,t),i=e.base(),a=Math.log(i),o=Math.max(1,i*t/r.length),s=e=>{let t=e/i**+Math.round(Math.log(e)/a);return t*i1?r[1]-r[0]:r[0],o;for(o=1;o(e-r)/a}function ppe(e,t,n,r){let i=r||t.type;return gg(n)&&Yfe(i)&&(n=n.replace(/%a/g,`%A`).replace(/%b/g,`%B`)),!n&&i===`time`?e.timeFormat(`%A, %d %B %Y, %X`):!n&&i===`utc`?e.utcFormat(`%A, %d %B %Y, %X UTC`):dpe(e,t,5,null,n,r,!0)}function mpe(e,t,n){n||={};let r=Math.max(3,n.maxlen||7),i=ppe(e,t,n.format,n.formatType);if(JD(t.type)){let e=spe(t).slice(1).map(i),n=e.length;return`${n} boundar${n===1?`y`:`ies`}: ${e.join(`, `)}`}else if(qD(t.type)){let e=t.domain(),n=e.length,a=n>r?e.slice(0,r-2).map(i).join(`, `)+`, ending with `+e.slice(-1).map(i):e.map(i).join(`, `);return`${n} value${n===1?``:`s`}: ${a}`}else{let e=t.domain();return`values from ${i(e[0])} to ${i(xh(e))}`}}var hpe,tO,nO,rO,gpe,iO,aO,oO,sO,cO,_pe,vpe,ype,bpe,lO,uO,dO,fO,pO,xpe,Spe,mO,hO,Cpe,wpe,Tpe,gO,Epe,Dpe,Ope,_O,vO,kpe,Ape,yO,jpe,Mpe,bO,xO=o((()=>{Tg(),Qg(),_fe(),hD(),Rfe(),wy(),hpe=`identity`,tO=`linear`,nO=`sqrt`,rO=`symlog`,gpe=`time`,iO=`sequential`,aO=`diverging`,oO=`quantile`,sO=`quantize`,cO=`threshold`,_pe=`ordinal`,vpe=`point`,ype=`band`,bpe=`bin-ordinal`,lO=`continuous`,uO=`discrete`,dO=`discretizing`,fO=`interpolating`,pO=`temporal`,xpe=Array.prototype.map,Spe=Array.prototype.slice,mO=new Map,hO=Symbol(`vega_scale`),WD(hpe,Ade),WD(tO,kde,lO),WD(`log`,Hde,[lO,`log`]),WD(`pow`,jD,lO),WD(nO,Yde,lO),WD(rO,Gde,lO),WD(gpe,ife,[lO,pO]),WD(`utc`,ofe,[lO,pO]),WD(iO,ID,[lO,fO]),WD(`${iO}-${tO}`,ID,[lO,fO]),WD(`${iO}-log`,cfe,[lO,fO,`log`]),WD(`${iO}-pow`,LD,[lO,fO]),WD(`${iO}-${nO}`,ufe,[lO,fO]),WD(`${iO}-${rO}`,lfe,[lO,fO]),WD(`${aO}-${tO}`,ffe,[lO,fO]),WD(`${aO}-log`,pfe,[lO,fO,`log`]),WD(`${aO}-pow`,zD,[lO,fO]),WD(`${aO}-${nO}`,hfe,[lO,fO]),WD(`${aO}-${rO}`,mfe,[lO,fO]),WD(oO,Xde,[dO,oO]),WD(sO,Qde,dO),WD(cO,efe,dO),WD(bpe,Wfe,[uO,dO]),WD(_pe,ET,uO),WD(ype,UD,uO),WD(vpe,Hfe,uO),Cpe=[`clamp`,`base`,`constant`,`exponent`],wpe={blues:`cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90`,greens:`d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429`,greys:`e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e`,oranges:`fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303`,purples:`e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c`,reds:`fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13`,blueGreen:`d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429`,bluePurple:`ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71`,greenBlue:`d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1`,orangeRed:`fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403`,purpleBlue:`dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281`,purpleBlueGreen:`dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353`,purpleRed:`dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a`,redPurple:`fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174`,yellowGreen:`e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034`,yellowOrangeBrown:`feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204`,yellowOrangeRed:`fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225`,blueOrange:`134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07`,brownBlueGreen:`704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147`,purpleGreen:`5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29`,purpleOrange:`4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07`,redBlue:`8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85`,redGrey:`8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434`,yellowGreenBlue:`eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185`,redYellowBlue:`a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695`,redYellowGreen:`a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837`,pinkYellowGreen:`8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419`,spectral:`9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2`,viridis:`440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725`,magma:`0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf`,inferno:`0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4`,plasma:`0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921`,cividis:`00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647`,rainbow:`6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa`,sinebow:`ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040`,turbo:`23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00`,browns:`eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632`,tealBlues:`bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985`,teals:`bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667`,warmGreys:`dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e`,goldGreen:`f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36`,goldOrange:`f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26`,goldRed:`f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e`,lightGreyRed:`efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b`,lightGreyTeal:`e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc`,lightMulti:`e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c`,lightOrange:`f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b`,lightTealBlue:`e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988`,darkBlue:`3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff`,darkGold:`3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff`,darkGreen:`3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa`,darkMulti:`3737371f5287197d8c29a86995ce3fffe800ffffff`,darkRed:`3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c`},Tpe={accent:bfe,category10:vfe,category20:`1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5`,category20b:`393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6`,category20c:`3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9`,dark2:Sfe,observable10:wfe,paired:Efe,pastel1:Ofe,pastel2:Afe,set1:Mfe,set2:Pfe,set3:Ife,tableau10:`4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac`,tableau20:`4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5`},gO={},rpe(Tpe,npe),rpe(wpe,e=>XD(npe(e))),Epe=e=>H(e)?e.map(e=>String(e)):String(e),Dpe=(e,t)=>e[1]-t[1],Ope=(e,t)=>t[1]-e[1],_O={[oO]:`quantiles`,[sO]:`thresholds`,[cO]:`domain`},vO={[oO]:`quantiles`,[sO]:`domain`},kpe=e=>_O[e.type]||e.bins,Ape=e=>(t,n,r)=>{let i=yO(r[n+1],yO(r.max,1/0)),a=bO(t,e),o=bO(i,e);return a&&o?a+` – `+o:o?`< `+o:`≥ `+a},yO=(e,t)=>e??t,jpe=e=>(t,n)=>n?e(t):null,Mpe=e=>t=>e(t),bO=(e,t)=>Number.isFinite(e)?t(e):null}));function Npe(){Ik=0}function SO(e){return e&&e.gradient}function Ppe(e,t,n){let r=e.gradient,i=e.id,a=r===`radial`?Lk:``;return i||(i=e.id=`gradient_`+Ik++,r===`radial`?(e.x1=CO(e.x1,.5),e.y1=CO(e.y1,.5),e.r1=CO(e.r1,0),e.x2=CO(e.x2,.5),e.y2=CO(e.y2,.5),e.r2=CO(e.r2,.5),a=Lk):(e.x1=CO(e.x1,0),e.y1=CO(e.y1,0),e.x2=CO(e.x2,1),e.y2=CO(e.y2,0))),t[i]=e,`url(`+(n||``)+`#`+a+i+`)`}function CO(e,t){return e??t}function Fpe(e,t){var n=[],r;return r={gradient:`linear`,x1:e?e[0]:0,y1:e?e[1]:0,x2:t?t[0]:1,y2:t?t[1]:0,stops:n,stop:function(e,t){return n.push({offset:e,color:t}),r}}}function wO(e,t,n){var r=sg(Rk,e)&&Rk[e],i=null;return r&&(i=r.curve||r[t||`vertical`],r.tension&&n!=null&&(i=i[r.tension](n))),i}function TO(e){let t=[];return(e.match(Xhe)||[]).forEach(e=>{let n=e[0],r=n.toLowerCase(),i=Yhe[r],a=Ipe(r,i,e.slice(1).trim()),o=a.length;if(o1&&(h=Math.sqrt(h),n*=h,r*=h);let g=f/n,_=d/n,v=-d/r,y=f/r,b=g*s+_*c,x=v*s+y*c,S=g*e+_*t,C=v*e+y*t,w=1/((S-b)*(S-b)+(C-x)*(C-x))-.25;w<0&&(w=0);let T=Math.sqrt(w);a==i&&(T=-T);let E=.5*(b+S)-T*(C-x),D=.5*(x+C)+T*(S-b),O=Math.atan2(x-D,b-E),k=Math.atan2(C-D,S-E)-O;k<0&&a===1?k+=Vk:k>0&&a===0&&(k-=Vk);let A=Math.ceil(Math.abs(k/(Bk+.001))),j=[];for(let e=0;e+e}function OO(e,t,n){return Math.max(t,Math.min(e,n))}function qpe(){var e=Upe,t=Wpe,n=Gpe,r=Kpe,i=DO(0),a=i,o=i,s=i,c=null;function l(l,u,d){var f,p=u??+e.call(this,l),m=d??+t.call(this,l),h=+n.call(this,l),g=+r.call(this,l),_=Math.min(h,g)/2,v=OO(+i.call(this,l),0,_),y=OO(+a.call(this,l),0,_),b=OO(+o.call(this,l),0,_),x=OO(+s.call(this,l),0,_);if(c||=f=pw(),v<=0&&y<=0&&b<=0&&x<=0)c.rect(p,m,h,g);else{var S=p+h,C=m+g;c.moveTo(p+v,m),c.lineTo(S-y,m),c.bezierCurveTo(S-Xk*y,m,S,m+Xk*y,S,m+y),c.lineTo(S,C-x),c.bezierCurveTo(S,C-Xk*x,S-Xk*x,C,S-x,C),c.lineTo(p+b,C),c.bezierCurveTo(p+Xk*b,C,p,C-Xk*b,p,C-b),c.lineTo(p,m+v),c.bezierCurveTo(p,m+Xk*v,p+Xk*v,m,p+v,m),c.closePath()}if(f)return c=null,f+``||null}return l.x=function(t){return arguments.length?(e=DO(t),l):e},l.y=function(e){return arguments.length?(t=DO(e),l):t},l.width=function(e){return arguments.length?(n=DO(e),l):n},l.height=function(e){return arguments.length?(r=DO(e),l):r},l.cornerRadius=function(e,t,n,r){return arguments.length?(i=DO(e),a=t==null?i:DO(t),s=n==null?i:DO(n),o=r==null?a:DO(r),l):i},l.context=function(e){return arguments.length?(c=e??null,l):c},l}function Jpe(){var e,t,n,r,i=null,a,o,s,c;function l(e,t,n){let r=n/2;if(a){var l=s-t,u=e-o;if(l||u){var d=Math.hypot(l,u),f=(l/=d)*c,p=(u/=d)*c,m=Math.atan2(u,l);i.moveTo(o-f,s-p),i.lineTo(e-l*r,t-u*r),i.arc(e,t,r,m-Math.PI,m),i.lineTo(o+f,s+p),i.arc(o,s,c,m,m+Math.PI)}else i.arc(e,t,r,0,Vk);i.closePath()}else a=1;o=e,s=t,c=r}function u(o){var s,c=o.length,u,d=!1,f;for(i??=f=pw(),s=0;s<=c;++s)!(sege?(u=o*o+s*a,u>=0&&(u=Math.sqrt(u),c=(-o+u)/a,l=(-o-u)/a)):c=.5*s/o,0f)return!1;h>d&&(d=h)}else if(p>0){if(h0?(e.globalAlpha=n,e.fillStyle=ume(e,t,t.fill),!0):!1}function GO(e,t,n){var r=(r=t.strokeWidth)??1;return r<=0?!1:(n*=t.strokeOpacity==null?1:t.strokeOpacity,n>0?(e.globalAlpha=n,e.strokeStyle=ume(e,t,t.stroke),e.lineWidth=r,e.lineCap=t.strokeCap||`butt`,e.lineJoin=t.strokeJoin||`miter`,e.miterLimit=t.strokeMiterLimit==null?4:t.strokeMiterLimit,e.setLineDash&&(e.setLineDash(t.strokeDash||Dge),e.lineDashOffset=t.strokeDashOffset||0),!0):!1)}function dme(e,t){return e.zindex-t.zindex||e.index-t.index}function KO(e){if(!e.zdirty)return e.zitems;var t=e.items,n=[],r,i,a;for(i=0,a=t.length;i=0;)if(r=t(n[i]))return r;if(n===a){for(n=e.items,i=n.length;--i>=0;)if(!n[i].zindex&&(r=t(n[i])))return r}return null}function YO(e){return function(t,n,r){qO(n,n=>{(!r||r.intersects(n.bounds))&&pme(e,t,n,n)})}}function fme(e){return function(t,n,r){n.items.length&&(!r||r.intersects(n.bounds))&&pme(e,t,n.items[0],n.items)}}function pme(e,t,n,r){var i=n.opacity==null?1:n.opacity;i!==0&&(e(t,r)||(HO(t,n),n.fill&&WO(t,n,i)&&t.fill(),n.stroke&&GO(t,n,i)&&t.stroke()))}function XO(e){return e||=dh,function(t,n,r,i,a,o){return r*=t.pixelRatio,i*=t.pixelRatio,JO(n,n=>{let s=n.bounds;if(!(s&&!s.contains(a,o)||!s)&&e(t,n,r,i,a,o))return n})}}function ZO(e,t){return function(n,r,i,a){var o=Array.isArray(r)?r[0]:r,s=t??o.fill,c=o.stroke&&n.isPointInStroke,l,u;return c&&(l=o.strokeWidth,u=o.strokeCap,n.lineWidth=l??1,n.lineCap=u??`butt`),e(n,r)?!1:s&&n.isPointInPath(i,a)||c&&n.isPointInStroke(i,a)}}function QO(e){return XO(ZO(e))}function $O(e,t){return`translate(`+e+`,`+t+`)`}function ek(e){return`rotate(`+e+`)`}function mme(e,t){return`scale(`+e+`,`+t+`)`}function hme(e){return $O(e.x||0,e.y||0)}function gme(e){return $O(e.x||0,e.y||0)+(e.angle?` `+ek(e.angle):``)}function _me(e){return $O(e.x||0,e.y||0)+(e.angle?` `+ek(e.angle):``)+(e.scaleX||e.scaleY?` `+mme(e.scaleX||1,e.scaleY||1):``)}function tk(e,t,n){function r(e,n){e(`transform`,gme(n)),e(`d`,t(null,n))}function i(e,n){return t(RO(e,n.angle),n),LO(e,n,!0).translate(n.x||0,n.y||0)}function a(e,n){var r=n.x||0,i=n.y||0,a=n.angle||0;e.translate(r,i),a&&e.rotate(a*=zk),e.beginPath(),t(e,n),a&&e.rotate(-a),e.translate(-r,-i)}return{type:e,tag:`path`,nested:!1,attr:r,bound:i,draw:YO(a),pick:QO(a),isect:n||zO(a)}}function vme(e,t){for(var n=e[0].orient===`horizontal`?t[1]:t[0],r=e[0].orient===`horizontal`?`y`:`x`,i=e.length,a=1/0,o,s;--i>=0;)e[i].defined!==!1&&(s=Math.abs(e[i][r]-n),s=0;)if(e[r].defined!==!1&&(i=e[r].x-t[0],a=e[r].y-t[1],o=i*i+a*a,o=0;)if(e[n].defined!==!1&&(r=e[n].x-t[0],i=e[n].y-t[1],a=r*r+i*i,r=e[n].size||1,a.5&&t<1.5?.5-Math.abs(t-1):0:e.strokeOffset}function wme(e,t){e(`transform`,hme(t))}function Tme(e,t){let n=Cme(t);e(`d`,jO(null,t,n,n))}function Eme(e,t){e(`class`,`background`),e(`aria-hidden`,!0),Tme(e,t)}function Dme(e,t){e(`class`,`foreground`),e(`aria-hidden`,!0),t.strokeForeground?Tme(e,t):e(`d`,``)}function Ome(e,t,n){e(`clip-path`,t.clip?MO(n,t,t):null)}function kme(e,t){if(!t.clip&&t.items){let n=t.items,r=n.length;for(let t=0;t{let i=t.x||0,a=t.y||0,o=t.strokeForeground,s=t.opacity==null?1:t.opacity;(t.stroke||t.fill)&&s&&(rk(e,t,i,a),HO(e,t),t.fill&&WO(e,t,s)&&e.fill(),t.stroke&&!o&&GO(e,t,s)&&e.stroke()),e.save(),e.translate(i,a),t.clip&&Sme(e,t),n&&n.translate(-i,-a),qO(t,t=>{(t.marktype===`group`||r==null||r.includes(t.marktype))&&this.draw(e,t,n,r)}),n&&n.translate(i,a),e.restore(),o&&t.stroke&&s&&(rk(e,t,i,a),HO(e,t),GO(e,t,s)&&e.stroke())})}function jme(e,t,n,r,i,a){if(t.bounds&&!t.bounds.contains(i,a)||!t.items)return null;let o=n*e.pixelRatio,s=r*e.pixelRatio;return JO(t,c=>{let l,u,d,f=c.bounds;if(f&&!f.contains(i,a))return;u=c.x||0,d=c.y||0;let p=u+(c.width||0),m=d+(c.height||0),h=c.clip;if(h&&(ip||am))return;if(e.save(),e.translate(u,d),u=i-u,d=a-d,h&&AO(c)&&!Mge(e,c,o,s))return e.restore(),null;let g=c.strokeForeground,_=t.interactive!==!1;return _&&g&&c.stroke&&jge(e,c,o,s)?(e.restore(),c):(l=JO(c,e=>Mme(e,u,d)?this.pick(e,n,r,u,d):null),!l&&_&&(c.fill||!g&&c.stroke)&&Age(e,c,o,s)&&(l=c),e.restore(),l||null)})}function Mme(e,t,n){return(e.interactive!==!1||e.marktype===`group`)&&e.bounds&&e.bounds.contains(t,n)}function ik(e,t){var n=e.image;return(!n||e.url&&e.url!==n.url)&&(n={complete:!1,width:0,height:0},t.loadImage(e.url).then(t=>{e.image=t,e.image.url=e.url})),n}function ak(e,t){return e.width==null?!t||!t.width?0:e.aspect!==!1&&e.height?e.height*t.width/t.height:t.width:e.width}function ok(e,t){return e.height==null?!t||!t.height?0:e.aspect!==!1&&e.width?e.width*t.height/t.width:t.height:e.height}function sk(e,t){return e===`center`?t/2:e===`right`?t:0}function ck(e,t){return e===`middle`?t/2:e===`bottom`?t:0}function Nme(e,t,n){let r=ik(t,n),i=ak(t,r),a=ok(t,r),o=(t.x||0)-sk(t.align,i),s=(t.y||0)-ck(t.baseline,a);e(`href`,!r.src&&r.toDataURL?r.toDataURL():r.src||``,bA[`xmlns:xlink`],`xlink:href`),e(`transform`,$O(o,s)),e(`width`,i),e(`height`,a),e(`preserveAspectRatio`,t.aspect===!1?`none`:`xMidYMid`)}function Pme(e,t){let n=t.image,r=ak(t,n),i=ok(t,n),a=(t.x||0)-sk(t.align,r),o=(t.y||0)-ck(t.baseline,i);return e.set(a,o,a+r,o+i)}function Fme(e,t,n){qO(t,t=>{if(n&&!n.intersects(t.bounds))return;let r=ik(t,this),i=ak(t,r),a=ok(t,r);if(i===0||a===0)return;let o=(t.x||0)-sk(t.align,i),s=(t.y||0)-ck(t.baseline,a),c,l,u;t.aspect!==!1&&(c=r.width/r.height,l=t.width/t.height,c===c&&l===l&&c!==l&&(l{if(!(n&&!n.intersects(t.bounds))){var r=t.opacity==null?1:t.opacity;r&&Ume(e,t,r)&&(HO(e,t),e.stroke())}})}function Gme(e,t,n,r){return e.isPointInStroke?Ume(e,t,1)&&e.isPointInStroke(n,r):!1}function Kme(e){SA.width=e&&vA?dk:uk}function uk(e,t){return qme(gk(e,t),fk(e))}function qme(e,t){return~~(.8*e.length*t)}function dk(e,t){return fk(e)<=0||!(t=gk(e,t))?0:Jme(t,vk(e))}function Jme(e,t){let n=`(${t}) ${e}`,r=xA.get(n);return r===void 0&&(vA.font=t,r=vA.measureText(e).width,xA.set(n,r)),r}function fk(e){return e.fontSize==null?11:+e.fontSize||0}function pk(e){return e.lineHeight==null?fk(e)+2:e.lineHeight}function Yme(e){return H(e)?e.length>1?e:e[0]:e}function mk(e){return Yme(e.lineBreak&&e.text&&!H(e.text)?e.text.split(e.lineBreak):e.text)}function hk(e){let t=mk(e);return(H(t)?t.length-1:0)*pk(e)}function gk(e,t){let n=t==null?``:(t+``).trim();return e.limit>0&&n.length?Zme(e,n):n}function Xme(e){if(SA.width===dk){let t=vk(e);return e=>Jme(e,t)}else if(SA.width===uk){let t=fk(e);return e=>qme(e,t)}else return t=>SA.width(e,t)}function Zme(e,t){var n=+e.limit,r=Xme(e);if(r(t)>>1,r(t.slice(c))>n?o=c+1:s=c;return i+t.slice(o)}else{for(;o>>1),r(t.slice(0,c))Math.max(e,SA.width(t,n)),0)):d=SA.width(t,u),i===`center`?c-=d/2:i===`right`&&(c-=d),e.set(c+=o,l+=s,c+d,l+r),t.angle&&!n)e.rotate(t.angle*zk,o,s);else if(n===2)return e.rotatedPoints(t.angle*zk,o,s);return e}function $me(e,t,n){qO(t,t=>{var r=t.opacity==null?1:t.opacity,i,a,o,s,c,l,u;if(!(n&&!n.intersects(t.bounds)||r===0||t.fontSize<=0||t.text==null||t.text.length===0)){if(e.font=vk(t),e.textAlign=t.align||`left`,i=bk(t),a=i.x1,o=i.y1,t.angle&&(e.save(),e.translate(a,o),e.rotate(t.angle*zk),a=o=0),a+=t.dx||0,o+=(t.dy||0)+yk(t),l=mk(t),HO(e,t),H(l))for(c=pk(t),s=0;st;)e.removeChild(n[--r]);return e}function she(e){return`mark-`+e.marktype+(e.role?` role-`+e.role:``)+(e.name?` `+e.name:``)}function Dk(e,t){if(t.getScreenCTM){let n=che(e,t.getScreenCTM());if(n)return n}return lhe(e,t,t.getBoundingClientRect())}function che(e,t){if(!t)return null;let n=t.a*t.d-t.b*t.c;if(!n)return null;let r=e.clientX-t.e,i=e.clientY-t.f;return[(t.d*r-t.c*i)/n,(t.a*i-t.b*r)/n]}function lhe(e,t,n){let r=t.offsetWidth?n.width/t.offsetWidth:1,i=t.offsetHeight?n.height/t.offsetHeight:1;return[(e.clientX-n.left)/r-(t.clientLeft||0),(e.clientY-n.top)/i-(t.clientTop||0)]}function uhe(e,t,n,r){var i=e&&e.mark,a,o;if(i&&(a=wA[i.marktype]).tip){for(o=Dk(t,n),o[0]-=r[0],o[1]-=r[1];e=e.mark.group;)o[0]-=e.x||0,o[1]-=e.y||0;e=a.tip(i.items,o)}return e}function dhe(e,t,n,r){e.element().setAttribute(`title`,r||``)}function fhe(e,t){Zge(t).forEach(t=>phe(e,t))}function phe(e,t){let n=e.canvas();n&&!e._events[t]&&(e._events[t]=1,n.addEventListener(t,e[t]?n=>e[t](n):n=>e.fire(t,n)))}function Ok(e,t,n){t.forEach(t=>e.fire(t,n))}function mhe(e,t,n){return function(r){let i=this._active,a=this.pickEvent(r);a===i?Ok(this,e,r):((!i||!i.exit)&&Ok(this,n,r),this._active=a,Ok(this,t,r),Ok(this,e,r))}}function hhe(e){return function(t){Ok(this,e,t),this._active=null}}function ghe(){return typeof window<`u`&&window.devicePixelRatio||1}function _he(e,t,n,r,i,a){let o=typeof HTMLElement<`u`&&e instanceof HTMLElement&&e.parentNode!=null,s=e.getContext(`2d`),c=o?ghe():i;e.width=t*c,e.height=n*c;for(let e in a)s[e]=a[e];return o&&c!==1&&(e.style.width=t+`px`,e.style.height=n+`px`),s.pixelRatio=c,s.setTransform(c,0,0,c,c*r[0],c*r[1]),e}function vhe(e,t,n){return t.expand(1).round(),e.pixelRatio%1&&t.scale(e.pixelRatio).round().scale(1/e.pixelRatio),t.translate(-(n[0]%1),-(n[1]%1)),e.beginPath(),e.rect(t.x1,t.y1,t.width(),t.height()),e.clip(),t}function yhe(e,t){let n=t.aria===!1;if(e($A,n||void 0),n||t.description==null)for(let t in cj)e(cj[t],void 0);else{let n=t.mark.marktype;e(ej,t.description),e(tj,t.ariaRole||(n===`group`?rj:ij)),e(nj,t.ariaRoleDescription||`${n} mark`)}}function bhe(e){return e.aria===!1?{[$A]:!0}:oj[e.role]?null:sj[e.role]?She(e,sj[e.role]):xhe(e)}function xhe(e){let t=e.marktype,n=t===`group`||t===`text`||e.items.some(e=>e.description!=null&&e.aria!==!1);return aj(n?rj:ij,`${t} mark container`,e.description)}function She(e,t){try{let n=e.items[0],r=t.caption||(()=>``);return aj(t.role||ij,t.desc,e.description||n.description||r(n))}catch{return null}}function Che(e){return Gh(e.text).join(` `)}function whe(e){let t=e.datum,n=e.orient,r=t.title?Ehe(e):null,i=e.context,a=i.scales[t.scale].value,o=i.dataflow.locale(),s=a.type;return`${n===`left`||n===`right`?`Y`:`X`}-axis`+(r?` titled '${r}'`:``)+` for a ${qD(s)?`discrete`:s} scale with ${mpe(o,a,e)}`}function The(e){let t=e.datum,n=t.title?Ehe(e):null,r=`${t.type||``} legend`.trim(),i=t.scales,a=Object.keys(i),o=e.context,s=o.scales[i[a[0]]].value,c=o.dataflow.locale();return Ohe(r)+(n?` titled '${n}'`:``)+` for ${Dhe(a)} with ${mpe(c,s,e)}`}function Ehe(e){try{return Gh(xh(e.items).items[0].text).join(` `)}catch{return null}}function Dhe(e){return e=e.map(e=>e+(e===`fill`||e===`stroke`?` color`:``)),e.length<2?e[0]:e.slice(0,-1).join(`, `)+` and `+xh(e)}function Ohe(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function kk(){let e=``,t=``,n=``,r=[],i=()=>t=n=``,a=a=>{t&&(e+=`${t}>${n}`,i()),r.push(a)},o=(e,n)=>(n!=null&&(t+=` ${e}="${uj(n)}"`),s),s={open(e,...n){a(e),t=`<`+e;for(let e of n)for(let t in e)o(t,e[t]);return s},close(){let a=r.pop();return t?e+=t+(n?`>${n}`:`/>`):e+=``,i(),s},attr:o,text:e=>(n+=lj(e),s),toString:()=>e};return s}function khe(e,t){if(e.open(t.tagName),t.hasAttributes()){let n=t.attributes,r=n.length;for(let t=0;t{i=e.mark(t,n,i,r),++a}),Ek(t,1+a)}function Phe(e,t,n,r,i){let a=e._svg,o;if(!a&&(o=t.ownerDocument,a=Ck(o,r,_j),e._svg=a,e.mark&&(a.__data__=e,a.__values__={fill:`default`},r===`g`))){let t=Ck(o,`path`,_j);a.appendChild(t),t.__data__=e;let n=Ck(o,`g`,_j);a.appendChild(n),n.__data__=e;let r=Ck(o,`path`,_j);a.appendChild(r),r.__data__=e,r.__values__={fill:`default`}}return(a.ownerSVGElement!==i||Fhe(a,n))&&t.insertBefore(a,n?n.nextSibling:t.firstChild),a}function Fhe(e,t){return e.parentNode&&e.parentNode.childNodes.length>1&&e.previousSibling!=t}function Ak(e,t,n){t!==bj[e]&&(n?Ihe(yj,e,t,n):Nk(yj,e,t),bj[e]=t)}function jk(e,t,n){n!==bj[t]&&(n==null?e.style.removeProperty(t):e.style.setProperty(t,n+``),bj[t]=n)}function Mk(e,t){for(let n in t)Nk(e,n,t[n])}function Nk(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function Ihe(e,t,n,r){n==null?e.removeAttributeNS(r,t):e.setAttributeNS(r,t,n)}function Lhe(){let e;return typeof window>`u`?``:(e=window.location).hash?e.href.slice(0,-e.hash.length):e.href}function Rhe(e,t,n,r,i){let a;if(t==null||(r===`bgrect`&&n.interactive===!1&&(e[`pointer-events`]=`none`),r===`bgfore`&&(n.interactive===!1&&(e[`pointer-events`]=`none`),e.display=`none`,t.fill!==null)))return e;r===`image`&&t.smooth===!1&&(a=[`image-rendering: optimizeSpeed;`,`image-rendering: pixelated;`]),r===`text`&&(e[`font-family`]=_k(t),e[`font-size`]=fk(t)+`px`,e[`font-style`]=t.fontStyle,e[`font-variant`]=t.fontVariant,e[`font-weight`]=t.fontWeight);for(let n in fj){let r=t[n],a=fj[n];r===`transparent`&&(a===`fill`||a===`stroke`)||r!=null&&(SO(r)&&(r=Ppe(r,i.gradient,``)),e[a]=r)}for(let e in pj){let n=t[e];n!=null&&(a||=[],a.push(`${pj[e]}: ${n};`))}return a&&(e.style=a.join(` `)),e}function zhe(e){Cj.svgMarkTypes=e.svgMarkTypes??[`text`],Cj.svgOnTop=e.svgOnTop??!0,Cj.debug=e.debug??!1}function Pk(e,t){return e=String(e||``).toLowerCase(),arguments.length>1?(Mj[e]=t,this):Mj[e]}function Bhe(e,t,n){let r=[],i=new NO().union(t),a=e.marktype;return a?Vhe(e,i,n,r):a===`group`?Uhe(e,i,n,r):V(`Intersect scene must be mark node or group item.`)}function Vhe(e,t,n,r){if(Hhe(e,t,n)){let i=e.items,a=e.marktype,o=i.length,s=0;if(a===`group`)for(;s=0;a--)if(n[a]!=r[a])return!1;for(a=n.length-1;a>=0;a--)if(i=n[a],!Fk(e[i],t[i],i))return!1;return typeof e==typeof t}function Jhe(){tme(),Npe()}var Ik,Lk,Rk,Yhe,Xhe,Zhe,Qhe,$he,zk,ege,Bk,Vk,Hk,Uk,Wk,Gk,Kk,qk,Jk,Yk,Xk,Zk,Qk,tge,nge,rge,ige,age,oge,sge,cge,lge,uge,dge,fge,pge,mge,hge,gge,$k,_ge,vge,yge,bge,xge,Sge,Cge,wge,eA,tA,Tge,nA,rA,iA,aA,oA,sA,cA,lA,uA,dA,fA,pA,mA,hA,gA,_A,Ege,vA,yA,Dge,Oge,kge,Age,jge,Mge,Nge,bA,Pge,Fge,Ige,Lge,Rge,zge,Bge,xA,SA,Vge,CA,wA,TA,Hge,EA,DA,OA,Uge,Wge,Gge,kA,AA,jA,MA,Kge,NA,PA,FA,IA,qge,LA,RA,zA,BA,Jge,Yge,VA,HA,UA,WA,Xge,GA,KA,qA,JA,Zge,YA,XA,ZA,QA,$A,ej,tj,nj,rj,ij,aj,oj,sj,cj,lj,uj,dj,fj,pj,mj,hj,gj,_j,vj,yj,bj,xj,Sj,Cj,wj,Tj,Ej,Dj,Oj,kj,Aj,jj,Mj,Nj,Pj,Fj=o((()=>{Tg(),uue(),yw(),ST(),Hb(),xO(),Ik=0,Lk=`p_`,Rk={basis:{curve:Gle},"basis-closed":{curve:Kle},"basis-open":{curve:Jle},bundle:{curve:Ww,tension:`beta`,value:.85},cardinal:{curve:qw,tension:`tension`,value:0},"cardinal-open":{curve:$w,tension:`tension`,value:0},"cardinal-closed":{curve:Xw,tension:`tension`,value:0},"catmull-rom":{curve:rT,tension:`alpha`,value:.5},"catmull-rom-closed":{curve:oT,tension:`alpha`,value:.5},"catmull-rom-open":{curve:cT,tension:`alpha`,value:.5},linear:{curve:Ew},"linear-closed":{curve:$le},monotone:{horizontal:nue,vertical:tue},natural:{curve:iue},step:{curve:oue},"step-after":{curve:cue},"step-before":{curve:sue}},Yhe={m:2,l:2,h:1,v:1,z:0,c:6,s:4,q:4,t:2,a:7},Xhe=/[mlhvzcsqta]([^mlhvzcsqta]*)/gi,Zhe=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,Qhe=/^((\s+,?\s*)|(,\s*))/,$he=/^[01]/,zk=Math.PI/180,ege=1e-14,Bk=Math.PI/2,Vk=Math.PI*2,Hk=Math.sqrt(3)/2,Uk={},Wk={},Gk=[].join,Kk=[`l`,0,0,0,0,0,0,0],qk=.5773502691896257,Jk={circle:{draw:function(e,t){let n=Math.sqrt(t)/2;e.moveTo(n,0),e.arc(0,0,n,0,Vk)}},cross:{draw:function(e,t){var n=Math.sqrt(t)/2,r=n/2.5;e.moveTo(-n,-r),e.lineTo(-n,r),e.lineTo(-r,r),e.lineTo(-r,n),e.lineTo(r,n),e.lineTo(r,r),e.lineTo(n,r),e.lineTo(n,-r),e.lineTo(r,-r),e.lineTo(r,-n),e.lineTo(-r,-n),e.lineTo(-r,-r),e.closePath()}},diamond:{draw:function(e,t){let n=Math.sqrt(t)/2;e.moveTo(-n,0),e.lineTo(0,-n),e.lineTo(n,0),e.lineTo(0,n),e.closePath()}},square:{draw:function(e,t){var n=Math.sqrt(t),r=-n/2;e.rect(r,r,n,n)}},arrow:{draw:function(e,t){var n=Math.sqrt(t)/2,r=n/7,i=n/2.5,a=n/8;e.moveTo(-r,n),e.lineTo(r,n),e.lineTo(r,-a),e.lineTo(i,-a),e.lineTo(0,-n),e.lineTo(-i,-a),e.lineTo(-r,-a),e.closePath()}},wedge:{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n,i=r-n*qk,a=n/4;e.moveTo(0,-r-i),e.lineTo(-a,r-i),e.lineTo(a,r-i),e.closePath()}},triangle:{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n,i=r-n*qk;e.moveTo(0,-r-i),e.lineTo(-n,r-i),e.lineTo(n,r-i),e.closePath()}},"triangle-up":{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n;e.moveTo(0,-r),e.lineTo(-n,r),e.lineTo(n,r),e.closePath()}},"triangle-down":{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n;e.moveTo(0,r),e.lineTo(-n,-r),e.lineTo(n,-r),e.closePath()}},"triangle-right":{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n;e.moveTo(r,0),e.lineTo(-r,-n),e.lineTo(-r,n),e.closePath()}},"triangle-left":{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n;e.moveTo(-r,0),e.lineTo(r,-n),e.lineTo(r,n),e.closePath()}},stroke:{draw:function(e,t){let n=Math.sqrt(t)/2;e.moveTo(-n,0),e.lineTo(n,0)}}},Yk={},Xk=.448084975506,Zk=e=>e.x||0,Qk=e=>e.y||0,tge=e=>e.width||0,nge=e=>e.height||0,rge=e=>(e.x||0)+(e.width||0),ige=e=>(e.y||0)+(e.height||0),age=e=>e.startAngle||0,oge=e=>e.endAngle||0,sge=e=>e.padAngle||0,cge=e=>e.innerRadius||0,lge=e=>e.outerRadius||0,uge=e=>e.cornerRadius||0,dge=e=>kO(e.cornerRadiusTopLeft,e.cornerRadius)||0,fge=e=>kO(e.cornerRadiusTopRight,e.cornerRadius)||0,pge=e=>kO(e.cornerRadiusBottomRight,e.cornerRadius)||0,mge=e=>kO(e.cornerRadiusBottomLeft,e.cornerRadius)||0,hge=e=>kO(e.size,64),gge=e=>e.size||1,$k=e=>e.defined!==!1,_ge=e=>Vpe(e.shape||`circle`),vge=Ble().startAngle(age).endAngle(oge).padAngle(sge).innerRadius(cge).outerRadius(lge).cornerRadius(uge),yge=Nw().x(Zk).y1(Qk).y0(ige).defined($k),bge=Nw().y(Qk).x1(Zk).x0(rge).defined($k),xge=jw().x(Zk).y(Qk).defined($k),Sge=qpe().x(Zk).y(Qk).width(tge).height(nge).cornerRadius(dge,fge,pge,mge),Cge=Ule().type(_ge).size(hge),wge=Jpe().x(Zk).y(Qk).defined($k).size(gge),eA=1,NO.prototype={clone(){return new NO(this)},clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this},empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE},equals(e){return this.x1===e.x1&&this.y1===e.y1&&this.x2===e.x2&&this.y2===e.y2},set(e,t,n,r){return nthis.x2&&(this.x2=e),t>this.y2&&(this.y2=t),this},expand(e){return this.x1-=e,this.y1-=e,this.x2+=e,this.y2+=e,this},round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this},scale(e){return this.x1*=e,this.y1*=e,this.x2*=e,this.y2*=e,this},translate(e,t){return this.x1+=e,this.x2+=e,this.y1+=t,this.y2+=t,this},rotate(e,t,n){let r=this.rotatedPoints(e,t,n);return this.clear().add(r[0],r[1]).add(r[2],r[3]).add(r[4],r[5]).add(r[6],r[7])},rotatedPoints(e,t,n){var{x1:r,y1:i,x2:a,y2:o}=this,s=Math.cos(e),c=Math.sin(e),l=t-t*s+n*c,u=n-t*c-n*s;return[s*r-c*i+l,c*r+s*i+u,s*r-c*o+l,c*r+s*o+u,s*a-c*i+l,c*a+s*i+u,s*a-c*o+l,c*a+s*o+u]},union(e){return e.x1this.x2&&(this.x2=e.x2),e.y2>this.y2&&(this.y2=e.y2),this},intersect(e){return e.x1>this.x1&&(this.x1=e.x1),e.y1>this.y1&&(this.y1=e.y1),e.x2=e.x2&&this.y1<=e.y1&&this.y2>=e.y2},alignsWith(e){return e&&(this.x1==e.x1||this.x2==e.x2||this.y1==e.y1||this.y2==e.y2)},intersects(e){return e&&!(this.x2e.x2||this.y2e.y2)},contains(e,t){return!(ethis.x2||tthis.y2)},width(){return this.x2-this.x1},height(){return this.y2-this.y1}},U(FO,PO),tA=class{constructor(e){this._pending=0,this._loader=e||Vb()}pending(){return this._pending}sanitizeURL(e){let t=this;return nme(t),t._loader.sanitize(e,{context:`href`}).then(e=>(IO(t),e)).catch(()=>(IO(t),null))}loadImage(e){let t=this,n=xT();return nme(t),t._loader.sanitize(e,{context:`image`}).then(e=>{let r=e.href;if(!r||!n)throw{url:r};let i=new n,a=sg(e,`crossOrigin`)?e.crossOrigin:`anonymous`;return a!=null&&(i.crossOrigin=a),i.onload=()=>IO(t),i.onerror=()=>IO(t),i.src=r,i}).catch(e=>(IO(t),{complete:!1,width:0,height:0,src:e&&e.url||``}))}ready(){let e=this;return new Promise(t=>{function n(r){e.pending()?setTimeout(()=>{n(!0)},10):t(r)}n(!1)})}},Tge=Vk-1e-8,uA=(e,t)=>nA.add(e,t),dA=(e,t)=>uA(rA=e,iA=t),fA=e=>uA(e,nA.y1),pA=e=>uA(nA.x1,e),mA=(e,t)=>oA*e+cA*t,hA=(e,t)=>sA*e+lA*t,gA=(e,t)=>uA(mA(e,t),hA(e,t)),_A=(e,t)=>dA(mA(e,t),hA(e,t)),Ege={beginPath(){},closePath(){},moveTo:_A,lineTo:_A,rect(e,t,n,r){aA?(gA(e+n,t),gA(e+n,t+r),gA(e,t+r),_A(e,t)):(uA(e+n,t+r),dA(e,t))},quadraticCurveTo(e,t,n,r){let i=mA(e,t),a=hA(e,t),o=mA(n,r),s=hA(n,r);rme(rA,i,o,fA),rme(iA,a,s,pA),dA(o,s)},bezierCurveTo(e,t,n,r,i,a){let o=mA(e,t),s=hA(e,t),c=mA(n,r),l=hA(n,r),u=mA(i,a),d=hA(i,a);ime(rA,o,c,u,fA),ime(iA,s,l,d,pA),dA(u,d)},arc(e,t,n,r,i,a){if(r+=aA,i+=aA,rA=n*Math.cos(i)+e,iA=n*Math.sin(i)+t,Math.abs(i-r)>Tge)uA(e-n,t-n),uA(e+n,t+n);else{let o=r=>uA(n*Math.cos(r)+e,n*Math.sin(r)+t),s,c;if(o(r),o(i),i!==r)if(r%=Vk,r<0&&(r+=Vk),i%=Vk,i<0&&(i+=Vk),ii;++c,s-=Bk)o(s);else for(s=r-r%Bk+Bk,c=0;c<4&&s=0;)if(e[r].type===t&&(!n||e[r].handler===n))return r;return-1}handlers(e){let t=this._handlers,n=[];if(e)n.push(...t[this.eventName(e)]);else for(let e in t)n.push(...t[e]);return n}eventName(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}handleHref(e,t,n){this._loader.sanitize(n,{context:`href`}).then(t=>{let n=new MouseEvent(e.type,e),r=Ck(null,`a`);for(let e in t)r.setAttribute(e,t[e]);r.dispatchEvent(n)}).catch(()=>{})}handleTooltip(e,t,n){if(t&&t.tooltip!=null){t=uhe(t,e,this.canvas(),this._origin);let r=n&&t&&t.tooltip||null;this._tooltip.call(this._obj,this,e,t,r)}}getItemBoundingClientRect(e){let t=this.canvas();if(!t)return;let n=t.getBoundingClientRect(),r=this._origin,i=e.bounds,a=i.width(),o=i.height(),s=i.x1+r[0]+n.left,c=i.y1+r[1]+n.top;for(;e.mark&&(e=e.mark.group);)s+=e.x||0,c+=e.y||0;return{x:s,y:c,width:a,height:o,left:s,top:c,right:s+a,bottom:c+o}}},OA=class{constructor(e){this._el=null,this._bgcolor=null,this._loader=new tA(e)}initialize(e,t,n,r,i){return this._el=e,this.resize(t,n,r,i)}element(){return this._el}canvas(){return this._el&&this._el.firstChild}background(e){return arguments.length===0?this._bgcolor:(this._bgcolor=e,this)}resize(e,t,n,r){return this._width=e,this._height=t,this._origin=n||[0,0],this._scale=r||1,this}dirty(){}render(e,t){let n=this;return n._call=function(){n._render(e,t)},n._call(),n._call=null,n}_render(){}renderAsync(e,t){let n=this.render(e,t);return this._ready?this._ready.then(()=>n):Promise.resolve(n)}_load(e,t){var n=this,r=n._loader[e](t);if(!n._ready){let e=n._call;n._ready=n._loader.ready().then(t=>{t&&e(),n._ready=null})}return r}sanitizeURL(e){return this._load(`sanitizeURL`,e)}loadImage(e){return this._load(`loadImage`,e)}},Uge=`keydown`,Wge=`keypress`,Gge=`keyup`,kA=`dragenter`,AA=`dragleave`,jA=`dragover`,MA=`pointerdown`,Kge=`pointerup`,NA=`pointermove`,PA=`pointerout`,FA=`pointerover`,IA=`mousedown`,qge=`mouseup`,LA=`mousemove`,RA=`mouseout`,zA=`mouseover`,BA=`click`,Jge=`dblclick`,Yge=`wheel`,VA=`mousewheel`,HA=`touchstart`,UA=`touchmove`,WA=`touchend`,Xge=[Uge,Wge,Gge,kA,AA,jA,MA,Kge,NA,PA,FA,IA,qge,LA,RA,zA,BA,Jge,Yge,VA,HA,UA,WA],GA=NA,KA=RA,qA=BA,JA=class extends DA{constructor(e,t){super(e,t),this._down=null,this._touch=null,this._first=!0,this._events={},this.events=Xge,this.pointermove=mhe([NA,LA],[FA,zA],[PA,RA]),this.dragover=mhe([jA],[kA],[AA]),this.pointerout=hhe([PA,RA]),this.dragleave=hhe([AA])}initialize(e,t,n){return this._canvas=e&&wk(e,`canvas`),[BA,IA,MA,NA,PA,AA].forEach(e=>fhe(this,e)),super.initialize(e,t,n)}canvas(){return this._canvas}context(){return this._canvas.getContext(`2d`)}DOMMouseScroll(e){this.fire(VA,e)}pointerdown(e){this._down=this._active,this.fire(MA,e)}mousedown(e){this._down=this._active,this.fire(IA,e)}click(e){this._down===this._active&&(this.fire(BA,e),this._down=null)}touchstart(e){this._touch=this.pickEvent(e.changedTouches[0]),this._first&&=(this._active=this._touch,!1),this.fire(HA,e,!0)}touchmove(e){this.fire(UA,e,!0)}touchend(e){this.fire(WA,e,!0),this._touch=null}fire(e,t,n){let r=n?this._touch:this._active,i=this._handlers[e];if(t.vegaType=e,e===qA&&r&&r.href?this.handleHref(t,r,r.href):(e===GA||e===KA)&&this.handleTooltip(t,r,e!==KA),i)for(let e=0,n=i.length;e=0&&r.splice(i,1),this}pickEvent(e){let t=Dk(e,this._canvas),n=this._origin;return this.pick(this._scene,t[0],t[1],t[0]-n[0],t[1]-n[1])}pick(e,t,n,r,i){let a=this.context();return wA[e.marktype].pick.call(this,a,e,t,n,r,i)}},Zge=e=>e===HA||e===UA||e===WA?[HA,UA,WA]:[e],YA=class extends OA{constructor(e){super(e),this._options={},this._redraw=!1,this._dirty=new NO,this._tempb=new NO}initialize(e,t,n,r,i,a){return this._options=a||{},this._canvas=this._options.externalContext?null:bT(1,1,this._options.type),e&&this._canvas&&(Ek(e,0).appendChild(this._canvas),this._canvas.setAttribute(`class`,`marks`)),super.initialize(e,t,n,r,i)}resize(e,t,n,r){if(super.resize(e,t,n,r),this._canvas)_he(this._canvas,this._width,this._height,this._origin,this._scale,this._options.context);else{let e=this._options.externalContext;e||V(`CanvasRenderer is missing a valid canvas or context`),e.scale(this._scale,this._scale),e.translate(this._origin[0],this._origin[1])}return this._redraw=!0,this}canvas(){return this._canvas}context(){return this._options.externalContext||(this._canvas?this._canvas.getContext(`2d`):null)}dirty(e){let t=this._tempb.clear().union(e.bounds),n=e.mark.group;for(;n;)t.translate(n.x||0,n.y||0),n=n.mark.group;this._dirty.union(t)}_render(e,t){let n=this.context(),r=this._origin,i=this._width,a=this._height,o=this._dirty,s=XA(r,i,a);n.save();let c=this._redraw||o.empty()?(this._redraw=!1,s.expand(1)):vhe(n,s.intersect(o),r);return this.clear(-r[0],-r[1],i,a),this.draw(n,e,c,t),n.restore(),o.clear(),this}draw(e,t,n,r){if(t.marktype!==`group`&&r!=null&&!r.includes(t.marktype))return;let i=wA[t.marktype];t.clip&&xme(e,t),i.draw.call(this,e,t,n,r),t.clip&&e.restore()}clear(e,t,n,r){let i=this._options,a=this.context();i.type!==`pdf`&&!i.externalContext&&a.clearRect(e,t,n,r),this._bgcolor!=null&&(a.fillStyle=this._bgcolor,a.fillRect(e,t,n,r))}},XA=(e,t,n)=>new NO().set(0,0,t,n).translate(-e[0],-e[1]),ZA=class extends DA{constructor(e,t){super(e,t);let n=this;n._hrefHandler=QA(n,(e,t)=>{t&&t.href&&n.handleHref(e,t,t.href)}),n._tooltipHandler=QA(n,(e,t)=>{n.handleTooltip(e,t,e.type!==KA)})}initialize(e,t,n){let r=this._svg;return r&&(r.removeEventListener(qA,this._hrefHandler),r.removeEventListener(GA,this._tooltipHandler),r.removeEventListener(KA,this._tooltipHandler)),this._svg=r=e&&wk(e,`svg`),r&&(r.addEventListener(qA,this._hrefHandler),r.addEventListener(GA,this._tooltipHandler),r.addEventListener(KA,this._tooltipHandler)),super.initialize(e,t,n)}canvas(){return this._svg}on(e,t){let n=this.eventName(e),r=this._handlers;if(this._handlerIndex(r[n],e,t)<0){let i={type:e,handler:t,listener:QA(this,t)};(r[n]||(r[n]=[])).push(i),this._svg&&this._svg.addEventListener(n,i.listener)}return this}off(e,t){let n=this.eventName(e),r=this._handlers[n],i=this._handlerIndex(r,e,t);return i>=0&&(this._svg&&this._svg.removeEventListener(n,r[i].listener),r.splice(i,1)),this}},QA=(e,t)=>n=>{let r=n.target.__data__;r=Array.isArray(r)?r[0]:r,n.vegaType=n.type,t.call(e._obj,n,r)},$A=`aria-hidden`,ej=`aria-label`,tj=`role`,nj=`aria-roledescription`,rj=`graphics-object`,ij=`graphics-symbol`,aj=(e,t,n)=>({[tj]:e,[nj]:t,[ej]:n||void 0}),oj=Cg([`axis-domain`,`axis-grid`,`axis-label`,`axis-tick`,`axis-title`,`legend-band`,`legend-entry`,`legend-gradient`,`legend-label`,`legend-title`,`legend-symbol`,`title`]),sj={axis:{desc:`axis`,caption:whe},legend:{desc:`legend`,caption:The},"title-text":{desc:`title`,caption:e=>`Title text '${Che(e)}'`},"title-subtitle":{desc:`subtitle`,caption:e=>`Subtitle text '${Che(e)}'`}},cj={ariaRole:tj,ariaRoleDescription:nj,description:ej},lj=e=>(e+``).replace(/&/g,`&`).replace(//g,`>`),uj=e=>lj(e).replace(/"/g,`"`).replace(/\t/g,` `).replace(/\n/g,` `).replace(/\r/g,` `),dj=e=>khe(kk(),e)+``,fj={fill:`fill`,fillOpacity:`fill-opacity`,stroke:`stroke`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,strokeCap:`stroke-linecap`,strokeJoin:`stroke-linejoin`,strokeDash:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeMiterLimit:`stroke-miterlimit`,opacity:`opacity`},pj={blend:`mix-blend-mode`},mj={fill:`none`,"stroke-miterlimit":4},hj=0,gj=`http://www.w3.org/2000/xmlns/`,_j=bA.xmlns,vj=class extends OA{constructor(e){super(e),this._dirtyID=0,this._dirty=[],this._svg=null,this._root=null,this._defs=null}initialize(e,t,n,r,i){return this._defs={},this._clearDefs(),e&&(this._svg=Tk(e,0,`svg`,_j),this._svg.setAttributeNS(gj,`xmlns`,_j),this._svg.setAttributeNS(gj,`xmlns:xlink`,bA[`xmlns:xlink`]),this._svg.setAttribute(`version`,bA.version),this._svg.setAttribute(`class`,`marks`),Ek(e,1),this._root=Tk(this._svg,hj,`g`,_j),Mk(this._root,mj),Ek(this._svg,1)),this.background(this._bgcolor),super.initialize(e,t,n,r,i)}background(e){return arguments.length&&this._svg&&this._svg.style.setProperty(`background-color`,e),super.background(...arguments)}resize(e,t,n,r){return super.resize(e,t,n,r),this._svg&&(Mk(this._svg,{width:this._width*this._scale,height:this._height*this._scale,viewBox:`0 0 ${this._width} ${this._height}`}),this._root.setAttribute(`transform`,`translate(${this._origin})`)),this._dirty=[],this}canvas(){return this._svg}svg(){let e=this._svg,t=this._bgcolor;if(!e)return null;let n;t&&(e.removeAttribute(`style`),n=Tk(e,hj,`rect`,_j),Mk(n,{width:this._width,height:this._height,fill:t}));let r=dj(e);return t&&(e.removeChild(n),this._svg.style.setProperty(`background-color`,t)),r}_render(e,t){return this._dirtyCheck()&&(this._dirtyAll&&this._clearDefs(),this.mark(this._root,e,void 0,t),Ek(this._root,1)),this.defs(),this._dirty=[],++this._dirtyID,this}dirty(e){e.dirty!==this._dirtyID&&(e.dirty=this._dirtyID,this._dirty.push(e))}isDirty(e){return this._dirtyAll||!e._svg||!e._svg.ownerSVGElement||e.dirty===this._dirtyID}_dirtyCheck(){this._dirtyAll=!0;let e=this._dirty;if(!e.length||!this._dirtyID)return!0;let t=++this._dirtyID,n,r,i,a,o,s,c;for(o=0,s=e.length;o{e.dirty=t})),!r.zdirty){if(n.exit){a.nested&&r.items.length?(c=r.items[0],c._svg&&this._update(a,c._svg,c)):n._svg&&(c=n._svg.parentNode,c&&c.removeChild(n._svg)),n._svg=null;continue}n=a.nested?r.items[0]:n,n._update!==t&&(!n._svg||!n._svg.ownerSVGElement?(this._dirtyAll=!1,Ahe(n,t)):this._update(a,n._svg,n),n._update=t)}return!this._dirtyAll}mark(e,t,n,r){if(!this.isDirty(t))return t._svg;let i=this._svg,a=t.marktype,o=wA[a],s=t.interactive===!1?`none`:null,c=o.tag===`g`,l=Phe(t,e,n,`g`,i);if(a!==`group`&&r!=null&&!r.includes(a))return Ek(l,0),t._svg;l.setAttribute(`class`,she(t));let u=bhe(t);for(let e in u)Nk(l,e,u[e]);c||Nk(l,`pointer-events`,s),Nk(l,`clip-path`,t.clip?MO(this,t,t.group):null);let d=null,f=0,p=e=>{let t=this.isDirty(e),n=Phe(e,l,d,o.tag,i);t&&(this._update(o,n,e),c&&Nhe(this,n,e,r)),d=n,++f};return o.nested?t.items.length&&p(t.items[0]):qO(t,p),Ek(l,f),l}_update(e,t,n){yj=t,bj=t.__values__,yhe(Ak,n),e.attr(Ak,n,this);let r=xj[e.type];r&&r.call(this,e,t,n),yj&&this.style(yj,n)}style(e,t){if(t!=null){for(let n in fj){let r=n===`font`?_k(t):t[n];if(r===bj[n])continue;let i=fj[n];r==null?e.removeAttribute(i):(SO(r)&&(r=Ppe(r,this._defs.gradient,Lhe())),e.setAttribute(i,r+``)),bj[n]=r}for(let n in pj)jk(e,pj[n],t[n])}}defs(){let e=this._svg,t=this._defs,n=t.el,r=0;for(let i in t.gradient)n||(t.el=n=Tk(e,1,`defs`,_j)),r=jhe(n,t.gradient[i],r);for(let i in t.clipping)n||(t.el=n=Tk(e,1,`defs`,_j)),r=Mhe(n,t.clipping[i],r);n&&(r===0?(e.removeChild(n),t.el=null):Ek(n,r))}_clearDefs(){let e=this._defs;e.gradient={},e.clipping={}}},yj=null,bj=null,xj={group(e,t,n){let r=yj=t.childNodes[2];bj=r.__values__,e.foreground(Ak,n,this),bj=t.__values__,yj=t.childNodes[1],e.content(Ak,n,this);let i=yj=t.childNodes[0];e.background(Ak,n,this);let a=n.mark.interactive===!1?`none`:null;if(a!==bj.events&&(Nk(r,`pointer-events`,a),Nk(i,`pointer-events`,a),bj.events=a),n.strokeForeground&&n.stroke){let e=n.fill;Nk(r,`display`,null),this.style(i,n),Nk(i,`stroke`,null),e&&(n.fill=null),bj=r.__values__,this.style(r,n),e&&(n.fill=e),yj=null}else Nk(r,`display`,`none`)},image(e,t,n){n.smooth===!1?(jk(t,`image-rendering`,`optimizeSpeed`),jk(t,`image-rendering`,`pixelated`)):jk(t,`image-rendering`,null)},text(e,t,n){let r=mk(n),i,a,o,s;H(r)?(a=r.map(e=>gk(n,e)),i=a.join(` -`),i!==bj.text&&(Ek(t,0),o=t.ownerDocument,s=pk(n),a.forEach((e,r)=>{let i=Ck(o,`tspan`,_j);i.__data__=n,i.textContent=e,r&&(i.setAttribute(`x`,0),i.setAttribute(`dy`,s)),t.appendChild(i)}),bj.text=i)):(a=gk(n,r),a!==bj.text&&(t.textContent=a,bj.text=a)),Nk(t,`font-family`,_k(n)),Nk(t,`font-size`,fk(n)+`px`),Nk(t,`font-style`,n.fontStyle),Nk(t,`font-variant`,n.fontVariant),Nk(t,`font-weight`,n.fontWeight)}},Sj=class extends OA{constructor(e){super(e),this._text=null,this._defs={gradient:{},clipping:{}}}svg(){return this._text}_render(e){let t=kk();t.open(`svg`,ig({},bA,{class:`marks`,width:this._width*this._scale,height:this._height*this._scale,viewBox:`0 0 ${this._width} ${this._height}`}));let n=this._bgcolor;return n&&n!==`transparent`&&n!==`none`&&t.open(`rect`,{width:this._width,height:this._height,fill:n}).close(),t.open(`g`,mj,{transform:`translate(`+this._origin+`)`}),this.mark(t,e),t.close(),this.defs(t),this._text=t.close()+``,this}mark(e,t){let n=wA[t.marktype],r=n.tag,i=[yhe,n.attr];e.open(`g`,{class:she(t),"clip-path":t.clip?MO(this,t,t.group):null},bhe(t),{"pointer-events":r!==`g`&&t.interactive===!1?`none`:null});let a=a=>{let o=this.href(a);if(o&&e.open(`a`,o),e.open(r,this.attr(t,a,i,r===`g`?null:r)),r===`text`){let t=mk(a);if(H(t)){let n={x:0,dy:pk(a)};for(let r=0;rthis.mark(e,t)),e.close(),r&&o?(i&&(a.fill=null),a.stroke=o,e.open(`path`,this.attr(t,a,n.foreground,`bgrect`)).close(),i&&(a.fill=i)):e.open(`path`,this.attr(t,a,n.foreground,`bgfore`)).close()}e.close(),o&&e.close()};return n.nested?t.items&&t.items.length&&a(t.items[0]):qO(t,a),e.close()}href(e){let t=e.href,n;if(t){if(n=this._hrefs&&this._hrefs[t])return n;this.sanitizeURL(t).then(e=>{e[`xlink:href`]=e.href,e.href=null,(this._hrefs||={})[t]=e})}return null}attr(e,t,n,r){let i={},a=(e,t,n,r)=>{i[r||e]=t};return Array.isArray(n)?n.forEach(e=>e(a,t,this)):n(a,t,this),r&&Rhe(i,t,e,r,this._defs),i}defs(e){let t=this._defs.gradient,n=this._defs.clipping;if(Object.keys(t).length+Object.keys(n).length!==0){e.open(`defs`);for(let n in t){let r=t[n],i=r.stops;r.gradient===`radial`?(e.open(`pattern`,{id:Lk+n,viewBox:`0,0,1,1`,width:`100%`,height:`100%`,preserveAspectRatio:`xMidYMid slice`}),e.open(`rect`,{width:`1`,height:`1`,fill:`url(#`+n+`)`}).close(),e.close(),e.open(`radialGradient`,{id:n,fx:r.x1,fy:r.y1,fr:r.r1,cx:r.x2,cy:r.y2,r:r.r2})):e.open(`linearGradient`,{id:n,x1:r.x1,x2:r.x2,y1:r.y1,y2:r.y2});for(let t=0;t!Cj.svgMarkTypes.includes(e));this._svgRenderer.render(e,Cj.svgMarkTypes),this._canvasRenderer.render(e,n)}resize(e,t,n,r){return super.resize(e,t,n,r),this._svgRenderer.resize(e,t,n,r),this._canvasRenderer.resize(e,t,n,r),this}background(e){return Cj.svgOnTop?this._canvasRenderer.background(e):this._svgRenderer.background(e),this}},Tj=class extends JA{constructor(e,t){super(e,t)}initialize(e,t,n){let r=Tk(Tk(e,0,`div`),+!Cj.svgOnTop,`div`);return super.initialize(r,t,n)}},Ej=`canvas`,Dj=`hybrid`,Oj=`png`,kj=`svg`,Aj=`none`,jj={Canvas:Ej,PNG:Oj,SVG:kj,Hybrid:Dj,None:Aj},Mj={},Mj[Ej]=Mj[Oj]={renderer:YA,headless:YA,handler:JA},Mj[kj]={renderer:vj,headless:Sj,handler:ZA},Mj[Dj]={renderer:wj,headless:wj,handler:Tj},Mj[Aj]={},Nj=new NO,Pj=1e-9})),Qge=c({bound:()=>Ij,identifier:()=>Rj,mark:()=>zj,overlap:()=>Bj,render:()=>Vj,viewlayout:()=>Zj});function Ij(e){G.call(this,null,e)}function Lj(e,t,n){return t(e.bounds.clear(),e,n)}function Rj(e){G.call(this,0,e)}function $ge(e){return e._signals[IM]||(e._signals[IM]=e.add(0))}function zj(e){G.call(this,null,e)}function e_e(e){let t=e.groups,n=e.parent;return t&&t.size===1?t.get(Object.keys(t.object)[0]):t&&n?t.lookup(n):null}function Bj(e){G.call(this,null,e)}function Vj(e){G.call(this,null,e)}function Hj(e,t,n){return e[t]===n?0:(e[t]=n,1)}function t_e(e){var t=e.items[0].orient;return t===$j||t===eM}function n_e(e){let t=+e.grid;return[e.ticks?t++:-1,e.labels?t++:-1,t+ +e.domain]}function r_e(e,t,n,r){var i=t.items[0],a=i.datum,o=i.translate==null?.5:i.translate,s=i.orient,c=n_e(a),l=i.range,u=i.offset,d=i.position,f=i.minExtent,p=i.maxExtent,m=a.title&&i.items[c[2]].items[0],h=i.titlePadding,g=i.bounds,_=m&&hk(m),v=0,y=0,b,x;switch(WM.clear().union(g),g.clear(),(b=c[0])>-1&&g.union(i.items[b].bounds),(b=c[1])>-1&&g.union(i.items[b].bounds),s){case Qj:v=d||0,y=-u,x=Math.max(f,Math.min(p,-g.y1)),g.add(0,-x).add(l,0),m&&Uj(e,m,x,h,_,0,-1,g);break;case $j:v=-u,y=d||0,x=Math.max(f,Math.min(p,-g.x1)),g.add(-x,0).add(0,l),m&&Uj(e,m,x,h,_,1,-1,g);break;case eM:v=n+u,y=d||0,x=Math.max(f,Math.min(p,g.x2)),g.add(0,0).add(x,l),m&&Uj(e,m,x,h,_,1,1,g);break;case tM:v=d||0,y=r+u,x=Math.max(f,Math.min(p,g.y2)),g.add(0,0).add(l,x),m&&Uj(e,m,x,h,0,0,1,g);break;default:v=i.x,y=i.y}return LO(g.translate(v,y),i),Hj(i,`x`,v+o)|Hj(i,`y`,y+o)&&(i.bounds=WM,e.dirty(i),i.bounds=g,e.dirty(i)),i.mark.bounds.clear().union(g)}function Uj(e,t,n,r,i,a,o,s){let c=t.bounds;if(t.auto){let s=o*(n+i+r),l=0,u=0;e.dirty(t),a?l=(t.x||0)-(t.x=s):u=(t.y||0)-(t.y=s),t.mark.bounds.clear().union(c.translate(-l,-u)),e.dirty(t)}s.union(c)}function i_e(e){var t=e.items,n=t.length,r=0,i,a;let o={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};for(;r1)for(C=0;C0&&(y[C]+=A/2);if(s&&Wj(n.center,FM)&&u!==1)for(C=0;C0&&(b[C]+=j/2);for(C=0;Ci&&(e.warn(`Grid headers exceed limit: `+i),t=t.slice(0,i)),h+=a,v=0,b=t.length;v=0&&(C=n[y])==null;y-=f);s?(w=p==null?C.x:Math.round(C.bounds.x1+p*C.bounds.width()),T=h):(w=h,T=p==null?C.y:Math.round(C.bounds.y1+p*C.bounds.height())),x.union(S.bounds.translate(w-(S.x||0),T-(S.y||0))),S.x=w,S.y=T,e.dirty(S),g=o(g,x[l])}return g}function Jj(e,t,n,r,i,a){if(t){e.dirty(t);var o=n,s=n;r?o=Math.round(i.x1+a*i.width()):s=Math.round(i.y1+a*i.height()),t.bounds.translate(o-(t.x||0),s-(t.y||0)),t.mark.bounds.clear().union(t.bounds),t.x=o,t.y=s,e.dirty(t)}}function u_e(e,t){let n=e[t]||{};return(t,r)=>n[t]==null?e[t]==null?r:e[t]:n[t]}function d_e(e,t){let n=-1/0;return e.forEach(e=>{e.offset!=null&&(n=Math.max(n,e.offset))}),n>-1/0?n:t}function f_e(e,t,n,r,i,a,o){let s=u_e(n,t),c=d_e(e,s(`offset`,0)),l=s(`anchor`,oM),u=s(`frame`,dM),d=l===cM?1:l===sM?.5:0,f=u===fM?r.x1+d*r.width():d*(a||i.width()+2*i.x1),p=u===fM?i.y1+d*i.height():d*(o||r.height()+2*r.y1),m={align:MM,bounds:s(`bounds`,NM),columns:s(`direction`)===`vertical`?1:e.length,padding:s(`margin`,8),center:s(`center`),nodirty:!0};switch(t){case $j:m.anchor={x:Math.floor(r.x1)-c,column:cM,y:p,row:l};break;case eM:m.anchor={x:Math.ceil(r.x2)+c,y:p,row:l};break;case Qj:m.anchor={y:Math.floor(i.y1)-c,row:cM,x:f,column:l};break;case tM:m.anchor={y:Math.ceil(i.y2)+c,x:f,column:l};break;case nM:m.anchor={x:c,y:c};break;case rM:m.anchor={x:a-c,y:c,column:cM};break;case iM:m.anchor={x:c,y:o-c,row:cM};break;case aM:m.anchor={x:a-c,y:o-c,column:cM,row:cM};break}return m}function p_e(e,t){var n=t.items[0],r=n.datum,i=n.orient,a=n.bounds,o=n.x,s=n.y,c,l;return n._bounds?n._bounds.clear().union(a):n._bounds=a.clone(),a.clear(),h_e(e,n,n.items[0].items[0]),a=m_e(n,a),c=2*n.padding,l=2*n.padding,a.empty()||(c=Math.ceil(a.width()+c),l=Math.ceil(a.height()+l)),r.type===TM&&g_e(n.items[0].items[0].items[0].items),i!==AM&&(n.x=o=0,n.y=s=0),n.width=c,n.height=l,LO(a.set(o,s,o+c,s+l),n),n.mark.bounds.clear().union(a),n}function m_e(e,t){return e.items.forEach(e=>t.union(e.bounds)),t.empty()&&(t.x2=e.padding,t.y2=e.padding),t.x1=e.padding,t.y1=e.padding,t}function h_e(e,t,n){var r=t.padding,i=r-n.x,a=r-n.y;if(!t.datum.title)(i||a)&&Xj(e,n,i,a);else{var o=t.items[1].items[0],s=o.anchor,c=t.titlePadding||0,l=r-o.x,u=r-o.y;switch(o.orient){case $j:i+=Math.ceil(o.bounds.width())+c;break;case eM:case tM:break;default:a+=o.bounds.height()+c}switch((i||a)&&Xj(e,n,i,a),o.orient){case $j:u+=Yj(t,n,o,s,1,1);break;case eM:l+=Yj(t,n,o,cM,0,0)+c,u+=Yj(t,n,o,s,1,1);break;case tM:l+=Yj(t,n,o,s,0,0),u+=Yj(t,n,o,cM,-1,0,1)+c;break;default:l+=Yj(t,n,o,s,0,0)}(l||u)&&Xj(e,o,l,u),(l=Math.round(o.bounds.x1-r))<0&&(Xj(e,n,-l,0),Xj(e,o,-l,0))}}function Yj(e,t,n,r,i,a,o){let s=e.datum.type!==`symbol`,c=n.datum.vgrad,l=(s&&(a||!c)&&!o?t.items[0]:t).bounds[i?`y2`:`x2`]-e.padding,u=c&&a?l:0,d=c&&a?0:l,f=i<=0?0:hk(n);return Math.round(r===oM?u:r===cM?d-f:.5*(l-f))}function Xj(e,t,n,r){t.x+=n,t.y+=r,t.bounds.translate(n,r),t.mark.bounds.translate(n,r),e.dirty(t)}function g_e(e){let t=e.reduce((e,t)=>(e[t.column]=Math.max(t.bounds.x2-t.x,e[t.column]||0),e),{});e.forEach(e=>{e.width=t[e.column],e.height=e.bounds.y2-e.y})}function __e(e,t,n,r,i){var a=t.items[0],o=a.frame,s=a.orient,c=a.anchor,l=a.offset,u=a.padding,d=a.items[0].items[0],f=a.items[1]&&a.items[1].items[0],p=s===$j||s===eM?r:n,m=0,h=0,g=0,_=0,v=0,y;if(o===dM?s===$j&&(m=r,p=0):s===$j?(m=i.y2,p=i.y1):s===eM?(m=i.y1,p=i.y2):(m=i.x1,p=i.x2),y=c===oM?m:c===cM?p:(m+p)/2,f&&f.text){switch(s){case Qj:case tM:v=d.bounds.height()+u;break;case $j:_=d.bounds.width()+u;break;case eM:_=-d.bounds.width()-u;break}WM.clear().union(f.bounds),WM.translate(_-(f.x||0),v-(f.y||0)),Hj(f,`x`,_)|Hj(f,`y`,v)&&(e.dirty(f),f.bounds.clear().union(WM),f.mark.bounds.clear().union(WM),e.dirty(f)),WM.clear().union(f.bounds)}else WM.clear();switch(WM.union(d.bounds),s){case Qj:h=y,g=i.y1-WM.height()-l;break;case $j:h=i.x1-WM.width()-l,g=y;break;case eM:h=i.x2+WM.width()+l,g=y;break;case tM:h=y,g=i.y2+l;break;default:h=a.x,g=a.y}return Hj(a,`x`,h)|Hj(a,`y`,g)&&(WM.translate(h,g),e.dirty(a),a.bounds.clear().union(WM),t.bounds.clear().union(WM),e.dirty(a)),a.bounds}function Zj(e){G.call(this,null,e)}function v_e(e){return e&&e.mark.role!==`legend-entry`}function y_e(e,t,n){var r=t.items,i=Math.max(0,t.width||0),a=Math.max(0,t.height||0),o=new NO().set(0,0,i,a),s=o.clone(),c=o.clone(),l=[],u,d,f,p,m,h;for(m=0,h=r.length;m{f=e.orient||eM,f!==AM&&(t[f]||(t[f]=[])).push(e)});for(let r in t){let o=t[r];Kj(e,o,f_e(o,r,n.legends,s,c,i,a))}l.forEach(t=>{let r=t.bounds;if(r.equals(t._bounds)||(t.bounds=t._bounds,e.dirty(t),t.bounds=r,e.dirty(t)),n.autosize&&(n.autosize.type===EM||n.autosize.type===DM||n.autosize.type===OM))switch(t.orient){case $j:case eM:o.add(r.x1,0).add(r.x2,0);break;case Qj:case tM:o.add(0,r.y1).add(0,r.y2)}else o.union(r)})}o.union(s).union(c),u&&o.union(__e(e,u,i,a,o)),t.clip&&o.set(0,0,t.width||0,t.height||0),b_e(e,t,o,n)}function b_e(e,t,n,r){let i=r.autosize||{},a=i.type;if(e._autosize<1||!a)return;let o=e._width,s=e._height,c=Math.max(0,t.width||0),l=Math.max(0,Math.ceil(-n.x1)),u=Math.max(0,t.height||0),d=Math.max(0,Math.ceil(-n.y1)),f=Math.max(0,Math.ceil(n.x2-c)),p=Math.max(0,Math.ceil(n.y2-u));if(i.contains===wM){let t=e.padding();o-=t.left+t.right,s-=t.top+t.bottom}a===AM?(l=0,d=0,c=o,u=s):a===EM?(c=Math.max(0,o-l-f),u=Math.max(0,s-d-p)):a===DM?(c=Math.max(0,o-l-f),s=u+d+p):a===OM?(o=c+l+f,u=Math.max(0,s-d-p)):a===kM&&(o=c+l+f,s=u+d+p),e._resizeView(o,s,c,u,[l,d],i.resize)}var Qj,$j,eM,tM,nM,rM,iM,aM,oM,sM,cM,lM,uM,dM,fM,pM,mM,hM,gM,_M,vM,yM,bM,xM,SM,CM,wM,TM,EM,DM,OM,kM,AM,jM,MM,NM,PM,FM,IM,LM,RM,zM,BM,VM,HM,UM,WM,GM,KM,x_e=o((()=>{Bx(),Fj(),Tg(),Qj=`top`,$j=`left`,eM=`right`,tM=`bottom`,nM=`top-left`,rM=`top-right`,iM=`bottom-left`,aM=`bottom-right`,oM=`start`,sM=`middle`,cM=`end`,lM=`x`,uM=`y`,dM=`group`,fM=`bounds`,pM=`axis`,mM=`title`,hM=`frame`,gM=`scope`,_M=`legend`,vM=`row-header`,yM=`row-footer`,bM=`row-title`,xM=`column-header`,SM=`column-footer`,CM=`column-title`,wM=`padding`,TM=`symbol`,EM=`fit`,DM=`fit-x`,OM=`fit-y`,kM=`pad`,AM=`none`,jM=`all`,MM=`each`,NM=`flush`,PM=`column`,FM=`row`,U(Ij,G,{transform(e,t){let n=t.dataflow,r=e.mark,i=r.marktype,a=wA[i],o=a.bound,s=r.bounds,c;if(a.nested)r.items.length&&n.dirty(r.items[0]),s=Lj(r,o),r.items.forEach(e=>{e.bounds.clear().union(s)});else if(i===dM||e.modified())switch(t.visit(t.MOD,e=>n.dirty(e)),s.clear(),r.items.forEach(e=>s.union(Lj(e,o))),r.role){case pM:case _M:case mM:t.reflow()}else c=t.changed(t.REM),t.visit(t.ADD,e=>{s.union(Lj(e,o))}),t.visit(t.MOD,e=>{c||=s.alignsWith(e.bounds),n.dirty(e),s.union(Lj(e,o))}),c&&(s.clear(),r.items.forEach(e=>s.union(e.bounds)));return Ghe(r),t.modifies(`bounds`)}}),IM=`:vega_identifier:`,Rj.Definition={type:`Identifier`,metadata:{modifies:!0},params:[{name:`as`,type:`string`,required:!0}]},U(Rj,G,{transform(e,t){let n=$ge(t.dataflow),r=e.as,i=n.value;return t.visit(t.ADD,e=>e[r]=e[r]||++i),n.set(this.value=i),t}}),U(zj,G,{transform(e,t){let n=this.value;n||(n=t.dataflow.scenegraph().mark(e.markdef,e_e(e),e.index),n.group.context=e.context,e.context.group||(e.context.group=n.group),n.source=this.source,n.clip=e.clip,n.interactive=e.interactive,this.value=n);let r=n.marktype===dM?FO:PO;return t.visit(t.ADD,e=>r.call(e,n)),(e.modified(`clip`)||e.modified(`interactive`))&&(n.clip=e.clip,n.interactive=!!e.interactive,n.zdirty=!0,t.reflow()),n.items=t.source,t}}),LM={parity:e=>e.filter((e,t)=>t%2?e.opacity=0:1),greedy:(e,t)=>{let n;return e.filter((e,r)=>!r||!RM(n.bounds,e.bounds,t)?(n=e,1):e.opacity=0)}},RM=(e,t,n)=>n>Math.max(t.x1-e.x2,e.x1-t.x2,t.y1-e.y2,e.y1-t.y2),zM=(e,t)=>{for(var n=1,r=e.length,i=e[0].bounds,a;n{let t=e.bounds;return t.width()>1&&t.height()>1},VM=(e,t,n)=>{var r=e.range(),i=new NO;return t===Qj||t===tM?i.set(r[0],-1/0,r[1],1/0):i.set(-1/0,r[0],1/0,r[1]),i.expand(n||1),e=>i.encloses(e.bounds)},HM=e=>(e.forEach(e=>e.opacity=1),e),UM=(e,t)=>e.reflow(t.modified()).modifies(`opacity`),U(Bj,G,{transform(e,t){let n=LM[e.method]||LM.parity,r=e.separation||0,i=t.materialize(t.SOURCE).source,a,o;if(!i||!i.length)return;if(!e.method)return e.modified(`method`)&&(HM(i),t=UM(t,e)),t;if(i=i.filter(BM),!i.length)return;if(e.sort&&(i=i.slice().sort(e.sort)),a=HM(i),t=UM(t,e),a.length>=3&&zM(a,r)){do a=n(a,r);while(a.length>=3&&zM(a,r));a.length<3&&!xh(i).opacity&&(a.length>1&&(xh(a).opacity=0),xh(i).opacity=1)}e.boundScale&&e.boundTolerance>=0&&(o=VM(e.boundScale,e.boundOrient,+e.boundTolerance),i.forEach(e=>{o(e)||(e.opacity=0)}));let s=a[0].mark.bounds.clear();return i.forEach(e=>{e.opacity&&s.union(e.bounds)}),t}}),U(Vj,G,{transform(e,t){let n=t.dataflow;if(t.visit(t.ALL,e=>n.dirty(e)),t.fields&&t.fields.zindex){let e=t.source&&t.source[0];e&&(e.mark.zdirty=!0)}}}),WM=new NO,GM=(e,t)=>Math.floor(Math.min(e,t)),KM=(e,t)=>Math.ceil(Math.max(e,t)),U(Zj,G,{transform(e,t){let n=t.dataflow;return e.mark.items.forEach(t=>{e.layout&&s_e(n,t,e.layout),y_e(n,t,e)}),v_e(e.mark.group)?t.reflow():t}})})),S_e=c({axisticks:()=>qM,datajoin:()=>JM,encode:()=>YM,legendentries:()=>XM,linkpath:()=>ZM,pie:()=>QM,scale:()=>eN,sortitems:()=>iN,stack:()=>aN});function qM(e){G.call(this,null,e)}function JM(e){G.call(this,null,e)}function C_e(){return Jb({})}function w_e(e){let t=lg().test(e=>e.exit);return t.lookup=n=>t.get(e(n)),t}function YM(e){G.call(this,null,e)}function XM(e){G.call(this,[],e)}function ZM(e){G.call(this,{},e)}function QM(e){G.call(this,null,e)}function T_e(e){let t=e.type;return!e.bins&&(t===`linear`||t===`pow`||t===`sqrt`)}function $M(e){return KD(e)&&e!==`sequential`}function eN(e){G.call(this,null,e),this.modified(!0)}function E_e(e){var t=e.type,n=``,r;return t===`sequential`?iO+`-`+tO:(D_e(e)&&(r=e.rawDomain?e.rawDomain.length:e.domain?e.domain.length+ +(e.domainMid!=null):0,n=r===2?iO+`-`:r===3?aO+`-`:``),(n+t||`linear`).toLowerCase())}function D_e(e){let t=e.type;return KD(t)&&t!==`time`&&t!==`utc`&&(e.scheme||e.range&&e.range.length&&e.range.every(gg))}function O_e(e,t,n){let r=k_e(e,t.domainRaw,n);if(r>-1)return r;var i=t.domain,a=e.type,o=t.zero||t.zero===void 0&&T_e(e),s,c;if(!i)return 0;if((o||t.domainMin!=null||t.domainMax!=null||t.domainMid!=null)&&(s=(i=i.slice()).length-1||1,o&&(i[0]>0&&(i[0]=0),i[s]<0&&(i[s]=0)),t.domainMin!=null&&(i[0]=t.domainMin),t.domainMax!=null&&(i[s]=t.domainMax),t.domainMid!=null)){c=t.domainMid;let e=c>i[s]?s+1:ce+(t<0?-1:+(t>0)),0))!==t.length&&n.warn(`Log scale domain includes zero: `+W(t)),t}function j_e(e,t,n){let r=t.bins;if(r&&!H(r)){let t=e.domain(),n=t[0],i=xh(t),a=r.step,o=r.start==null?n:r.start,s=r.stop==null?i:r.stop;a||V(`Scale bins parameter missing step property.`),oi&&(s=a*Math.floor(i/a)),r=Zg(o,s+a/2,a)}return r?e.bins=r:e.bins&&delete e.bins,e.type===`bin-ordinal`&&(r?!t.domain&&!t.domainRaw&&(e.domain(r),n=r.length):e.bins=e.domain()),n}function M_e(e,t,n){var r=e.type,i=t.round||!1,a=t.range;if(t.rangeStep!=null)a=N_e(r,t,n);else if(t.scheme&&(a=P_e(r,t,n),Jh(a))){if(e.interpolator)return e.interpolator(a);V(`Scale type ${r} does not support interpolating color schemes.`)}if(a&&Xfe(r))return e.interpolator(XD(rN(a,t.reverse),t.interpolate,t.interpolateGamma));a&&t.interpolate&&e.interpolate?e.interpolate(ZD(t.interpolate,t.interpolateGamma)):Jh(e.round)?e.round(i):Jh(e.rangeRound)&&e.interpolate(i?uD:cD),a&&e.range(rN(a,t.reverse))}function N_e(e,t,n){e!==`band`&&e!==`point`&&V(`Only band and point scales support rangeStep.`);var r=(t.paddingOuter==null?t.padding:t.paddingOuter)||0,i=e===`point`?1:(t.paddingInner==null?t.padding:t.paddingInner)||0;return[0,t.rangeStep*HD(n,i,r)]}function P_e(e,t,n){var r=t.schemeExtent,i,a;return H(t.scheme)?a=XD(t.scheme,t.interpolate,t.interpolateGamma):(i=t.scheme.toLowerCase(),a=QD(i),a||V(`Unrecognized scheme name: ${t.scheme}`)),n=e===`threshold`?n+1:e===`bin-ordinal`?n-1:e===`quantile`||e===`quantize`?+t.schemeCount||CN:n,Xfe(e)?nN(a,r,t.reverse):Jh(a)?$fe(nN(a,r),n):e===`ordinal`?a:a.slice(0,n)}function nN(e,t,n){return Jh(e)&&(t||n)?Qfe(e,rN(t||[0,1],n)):e}function rN(e,t){return t?e.slice().reverse():e}function iN(e){G.call(this,null,e)}function aN(e){G.call(this,null,e)}function F_e(e,t,n,r,i){for(var a=(t-e.sum)/2,o=e.length,s=0,c;se(u),o,s,c,l,u,d,f,p,m;if(t==null)i.push(e.slice());else for(o={},s=0,c=e.length;sm&&(m=p),n&&f.sort(n)}return i.max=m,i}var oN,sN,cN,lN,uN,dN,fN,pN,mN,hN,gN,_N,vN,yN,bN,xN,SN,CN,wN,TN,EN,DN,ON,z_e=o((()=>{Bx(),xO(),Tg(),Qg(),hD(),U(qM,G,{transform(e,t){if(this.value&&!e.modified())return t.StopPropagation;var n=t.dataflow.locale(),r=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=this.value,a=e.scale,o=$D(a,e.count==null?e.values?e.values.length:10:e.count,e.minstep),s=e.format||ape(n,a,o,e.formatSpecifier,e.formatType,!!e.values),c=e.values?ipe(a,e.values,o):eO(a,o);return i&&(r.rem=i),i=c.map((e,t)=>Jb({index:t/(c.length-1||1),tickIndex:t,value:e,label:s(e)})),e.extra&&i.length&&i.push(Jb({index:-1,tickIndex:-1,extra:{value:i[0].value},label:``})),r.source=i,r.add=i,this.value=i,r}}),U(JM,G,{transform(e,t){var n=t.dataflow,r=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=e.item||C_e,a=e.key||Kb,o=this.value;return H(r.encode)&&(r.encode=null),o&&(e.modified(`key`)||t.modified(a))&&V(`DataJoin does not support modified key function or fields.`),o||(t=t.addAll(),this.value=o=w_e(a)),t.visit(t.ADD,e=>{let t=a(e),n=o.get(t);n?n.exit?(o.empty--,r.add.push(n)):r.mod.push(n):(n=i(e),o.set(t,n),r.add.push(n)),n.datum=e,n.exit=!1}),t.visit(t.MOD,e=>{let t=a(e),n=o.get(t);n&&(n.datum=e,r.mod.push(n))}),t.visit(t.REM,e=>{let t=a(e),n=o.get(t);e===n.datum&&!n.exit&&(r.rem.push(n),n.exit=!0,++o.empty)}),t.changed(t.ADD_MOD)&&r.modifies(`datum`),(t.clean()||e.clean&&o.empty>n.cleanThreshold)&&n.runAfter(o.clean),r}}),U(YM,G,{transform(e,t){var n=t.fork(t.ADD_REM),r=e.mod||!1,i=e.encoders,a=t.encode;if(H(a))if(n.changed()||a.every(e=>i[e]))a=a[0],n.encode=null;else return t.StopPropagation;var o=a===`enter`,s=i.update||fh,c=i.enter||fh,l=i.exit||fh,u=(a&&!o?i[a]:s)||fh;if(t.changed(t.ADD)&&(t.visit(t.ADD,t=>{c(t,e),s(t,e)}),n.modifies(c.output),n.modifies(s.output),u!==fh&&u!==s&&(t.visit(t.ADD,t=>{u(t,e)}),n.modifies(u.output))),t.changed(t.REM)&&l!==fh&&(t.visit(t.REM,t=>{l(t,e)}),n.modifies(l.output)),o||u!==fh){let i=t.MOD|(e.modified()?t.REFLOW:0);o?(t.visit(i,t=>{let i=c(t,e)||r;(u(t,e)||i)&&n.mod.push(t)}),n.mod.length&&n.modifies(c.output)):t.visit(i,t=>{(u(t,e)||r)&&n.mod.push(t)}),n.mod.length&&n.modifies(u.output)}return n.changed()?n:t.StopPropagation}}),U(XM,G,{transform(e,t){if(this.value!=null&&!e.modified())return t.StopPropagation;var n=t.dataflow.locale(),r=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=this.value,a=e.type||`symbol`,o=e.scale,s=+e.limit,c=$D(o,e.count==null?5:e.count,e.minstep),l=!!e.values||a===`symbol`,u=e.format||dpe(n,o,c,a,e.formatSpecifier,e.formatType,l),d=e.values||spe(o,c),f,p,m,h,g;return i&&(r.rem=i),a===`symbol`?(s&&d.length>s?(t.dataflow.warn(`Symbol legend count exceeds limit, filtering items.`),i=d.slice(0,s-1),g=!0):i=d,Jh(m=e.size)?(!e.values&&o(i[0])===0&&(i=i.slice(1)),h=i.reduce((t,n)=>Math.max(t,m(n,e)),0)):m=ng(h=m||8),i=i.map((t,n)=>Jb({index:n,label:u(t,n,i),value:t,offset:h,size:m(t,e)})),g&&(g=d[i.length],i.push(Jb({index:i.length,label:`\u2026${d.length-i.length} entries`,value:g,offset:h,size:m(g,e)})))):a===`gradient`?(f=o.domain(),p=epe(o,f[0],xh(f)),d.length<3&&!e.values&&f[0]!==xh(f)&&(d=[f[0],xh(f)]),i=d.map((e,t)=>Jb({index:t,label:u(e,t,d),value:e,perc:p(e)}))):(m=d.length-1,p=fpe(o),i=d.map((e,t)=>Jb({index:t,label:u(e,t,d),value:e,perc:t?p(e):0,perc2:t===m?1:p(d[t+1])}))),r.source=i,r.add=i,this.value=i,r}}),oN=e=>e.source.x,sN=e=>e.source.y,cN=e=>e.target.x,lN=e=>e.target.y,ZM.Definition={type:`LinkPath`,metadata:{modifies:!0},params:[{name:`sourceX`,type:`field`,default:`source.x`},{name:`sourceY`,type:`field`,default:`source.y`},{name:`targetX`,type:`field`,default:`target.x`},{name:`targetY`,type:`field`,default:`target.y`},{name:`orient`,type:`enum`,default:`vertical`,values:[`horizontal`,`vertical`,`radial`]},{name:`shape`,type:`enum`,default:`line`,values:[`line`,`arc`,`curve`,`diagonal`,`orthogonal`]},{name:`require`,type:`signal`},{name:`as`,type:`string`,default:`path`}]},U(ZM,G,{transform(e,t){var n=e.sourceX||oN,r=e.sourceY||sN,i=e.targetX||cN,a=e.targetY||lN,o=e.as||`path`,s=e.orient||`vertical`,c=e.shape||`line`,l=SN.get(c+`-`+s)||SN.get(c);return l||V(`LinkPath unsupported type: `+e.shape+(e.orient?`-`+e.orient:``)),t.visit(t.SOURCE,e=>{e[o]=l(n(e),r(e),i(e),a(e))}),t.reflow(e.modified()).modifies(o)}}),uN=(e,t,n,r)=>`M`+e+`,`+t+`L`+n+`,`+r,dN=(e,t,n,r)=>uN(t*Math.cos(e),t*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),fN=(e,t,n,r)=>{var i=n-e,a=r-t,o=Math.hypot(i,a)/2,s=180*Math.atan2(a,i)/Math.PI;return`M`+e+`,`+t+`A`+o+`,`+o+` `+s+` 0 1 `+n+`,`+r},pN=(e,t,n,r)=>fN(t*Math.cos(e),t*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),mN=(e,t,n,r)=>{let i=n-e,a=r-t,o=.2*(i+a),s=.2*(a-i);return`M`+e+`,`+t+`C`+(e+o)+`,`+(t+s)+` `+(n+s)+`,`+(r-o)+` `+n+`,`+r},hN=(e,t,n,r)=>mN(t*Math.cos(e),t*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),gN=(e,t,n,r)=>`M`+e+`,`+t+`V`+r+`H`+n,_N=(e,t,n,r)=>`M`+e+`,`+t+`H`+n+`V`+r,vN=(e,t,n,r)=>{let i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),c=Math.abs(n-e)>Math.PI?n<=e:n>e;return`M`+t*i+`,`+t*a+`A`+t+`,`+t+` 0 0,`+ +!!c+` `+t*o+`,`+t*s+`L`+r*o+`,`+r*s},yN=(e,t,n,r)=>{let i=(e+n)/2;return`M`+e+`,`+t+`C`+i+`,`+t+` `+i+`,`+r+` `+n+`,`+r},bN=(e,t,n,r)=>{let i=(t+r)/2;return`M`+e+`,`+t+`C`+e+`,`+i+` `+n+`,`+i+` `+n+`,`+r},xN=(e,t,n,r)=>{let i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),c=(t+r)/2;return`M`+t*i+`,`+t*a+`C`+c*i+`,`+c*a+` `+c*o+`,`+c*s+` `+r*o+`,`+r*s},SN=lg({line:uN,"line-radial":dN,arc:fN,"arc-radial":pN,curve:mN,"curve-radial":hN,"orthogonal-horizontal":gN,"orthogonal-vertical":_N,"orthogonal-radial":vN,"diagonal-horizontal":yN,"diagonal-vertical":bN,"diagonal-radial":xN}),QM.Definition={type:`Pie`,metadata:{modifies:!0},params:[{name:`field`,type:`field`},{name:`startAngle`,type:`number`,default:0},{name:`endAngle`,type:`number`,default:6.283185307179586},{name:`sort`,type:`boolean`,default:!1},{name:`as`,type:`string`,array:!0,length:2,default:[`startAngle`,`endAngle`]}]},U(QM,G,{transform(e,t){var n=e.as||[`startAngle`,`endAngle`],r=n[0],i=n[1],a=e.field||uh,o=e.startAngle||0,s=e.endAngle==null?2*Math.PI:e.endAngle,c=t.source,l=c.map(a),u=l.length,d=o,f=(s-o)/yoe(l),p=Zg(u),m,h,g;for(e.sort&&p.sort((e,t)=>l[e]-l[t]),m=0;m1?0:e<-1?MN:Math.acos(e)}function AN(e){return e>1?NN:e<-1?-NN:Math.asin(e)}var jN,MN,NN,PN,FN,IN,LN,RN,zN,BN,VN,HN,UN,WN,GN,KN,qN,JN,YN,XN,ZN=o((()=>{jN=1e-6,MN=Math.PI,NN=MN/2,PN=MN/4,FN=MN*2,IN=180/MN,LN=MN/180,RN=Math.abs,zN=Math.atan,BN=Math.atan2,VN=Math.cos,HN=Math.ceil,UN=Math.exp,WN=Math.hypot,GN=Math.log,KN=Math.pow,qN=Math.sin,JN=Math.sign||function(e){return e>0?1:e<0?-1:0},YN=Math.sqrt,XN=Math.tan}));function QN(){}var $N=o((()=>{}));function eP(e,t){e&&aP.hasOwnProperty(e.type)&&aP[e.type](e,t)}function tP(e,t,n){var r=-1,i=e.length-n,a;for(t.lineStart();++r{iP={Feature:function(e,t){eP(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r=0?1:-1,i=r*n,a=VN(t),o=qN(t),s=mP*o,c=pP*a+s*VN(i),l=s*r*qN(i);cP.add(BN(l,c)),fP=e,pP=a,mP=o}function U_e(e){return lP=new Rg,rP(e,hP),lP*2}var cP,lP,uP,dP,fP,pP,mP,hP,gP=o((()=>{Qg(),ZN(),$N(),oP(),cP=new Rg,lP=new Rg,hP={point:QN,lineStart:QN,lineEnd:QN,polygonStart:function(){cP=new Rg,hP.lineStart=B_e,hP.lineEnd=V_e},polygonEnd:function(){var e=+cP;lP.add(e<0?FN+e:e),this.lineStart=this.lineEnd=this.point=QN},sphere:function(){lP.add(FN)}}}));function _P(e){return[BN(e[1],e[0]),AN(e[2])]}function vP(e){var t=e[0],n=e[1],r=VN(n);return[r*VN(t),r*qN(t),qN(n)]}function yP(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function bP(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function xP(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function SP(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function CP(e){var t=YN(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var wP=o((()=>{ZN()}));function TP(e,t){VP.push(HP=[MP=e,PP=e]),tFP&&(FP=t)}function EP(e,t){var n=vP([e*LN,t*LN]);if(zP){var r=bP(zP,n),i=bP([r[1],-r[0],0],r);CP(i),i=_P(i);var a=e-IP,o=a>0?1:-1,s=i[0]*IN*o,c,l=RN(a)>180;l^(o*IPFP&&(FP=c)):(s=(s+360)%360-180,l^(o*IPFP&&(FP=t))),l?eAP(MP,PP)&&(PP=e):AP(e,PP)>AP(MP,PP)&&(MP=e):PP>=MP?(ePP&&(PP=e)):e>IP?AP(MP,e)>AP(MP,PP)&&(PP=e):AP(e,PP)>AP(MP,PP)&&(MP=e)}else VP.push(HP=[MP=e,PP=e]);tFP&&(FP=t),zP=n,IP=e}function DP(){UP.point=EP}function OP(){HP[0]=MP,HP[1]=PP,UP.point=TP,zP=null}function kP(e,t){if(zP){var n=e-IP;BP.add(RN(n)>180?n+(n>0?360:-360):n)}else LP=e,RP=t;hP.point(e,t),EP(e,t)}function W_e(){hP.lineStart()}function G_e(){kP(LP,RP),hP.lineEnd(),RN(BP)>1e-6&&(MP=-(PP=180)),HP[0]=MP,HP[1]=PP,zP=null}function AP(e,t){return(t-=e)<0?t+360:t}function K_e(e,t){return e[0]-t[0]}function jP(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tAP(r[0],r[1])&&(r[1]=i[1]),AP(i[0],r[1])>AP(r[0],r[1])&&(r[0]=i[0])):a.push(r=i);for(o=-1/0,n=a.length-1,t=0,r=a[n];t<=n;r=i,++t)i=a[t],(s=AP(r[1],i[0]))>o&&(o=s,MP=i[0],PP=r[1])}return VP=HP=null,MP===1/0||NP===1/0?[[NaN,NaN],[NaN,NaN]]:[[MP,NP],[PP,FP]]}var MP,NP,PP,FP,IP,LP,RP,zP,BP,VP,HP,UP,J_e=o((()=>{Qg(),gP(),wP(),ZN(),oP(),UP={point:TP,lineStart:DP,lineEnd:OP,polygonStart:function(){UP.point=kP,UP.lineStart=W_e,UP.lineEnd=G_e,BP=new Rg,hP.polygonStart()},polygonEnd:function(){hP.polygonEnd(),UP.point=TP,UP.lineStart=DP,UP.lineEnd=OP,cP<0?(MP=-(PP=180),NP=-(FP=90)):BP>1e-6?FP=90:BP<-1e-6&&(NP=-90),HP[0]=MP,HP[1]=PP},sphere:function(){MP=-(PP=180),NP=-(FP=90)}}}));function WP(e,t){e*=LN,t*=LN;var n=VN(t);GP(n*VN(e),n*qN(e),qN(t))}function GP(e,t,n){++YP,ZP+=(e-ZP)/YP,QP+=(t-QP)/YP,$P+=(n-$P)/YP}function KP(){dF.point=Y_e}function Y_e(e,t){e*=LN,t*=LN;var n=VN(t);cF=n*VN(e),lF=n*qN(e),uF=qN(t),dF.point=X_e,GP(cF,lF,uF)}function X_e(e,t){e*=LN,t*=LN;var n=VN(t),r=n*VN(e),i=n*qN(e),a=qN(t),o=BN(YN((o=lF*a-uF*i)*o+(o=uF*r-cF*a)*o+(o=cF*i-lF*r)*o),cF*r+lF*i+uF*a);XP+=o,eF+=o*(cF+(cF=r)),tF+=o*(lF+(lF=i)),nF+=o*(uF+(uF=a)),GP(cF,lF,uF)}function qP(){dF.point=WP}function Z_e(){dF.point=$_e}function Q_e(){JP(oF,sF),dF.point=WP}function $_e(e,t){oF=e,sF=t,e*=LN,t*=LN,dF.point=JP;var n=VN(t);cF=n*VN(e),lF=n*qN(e),uF=qN(t),GP(cF,lF,uF)}function JP(e,t){e*=LN,t*=LN;var n=VN(t),r=n*VN(e),i=n*qN(e),a=qN(t),o=lF*a-uF*i,s=uF*r-cF*a,c=cF*i-lF*r,l=WN(o,s,c),u=AN(l),d=l&&-u/l;rF.add(d*o),iF.add(d*s),aF.add(d*c),XP+=u,eF+=u*(cF+(cF=r)),tF+=u*(lF+(lF=i)),nF+=u*(uF+(uF=a)),GP(cF,lF,uF)}function eve(e){YP=XP=ZP=QP=$P=eF=tF=nF=0,rF=new Rg,iF=new Rg,aF=new Rg,rP(e,dF);var t=+rF,n=+iF,r=+aF,i=WN(t,n,r);return i<1e-12&&(t=eF,n=tF,r=nF,XP<1e-6&&(t=ZP,n=QP,r=$P),i=WN(t,n,r),i<1e-12)?[NaN,NaN]:[BN(n,t)*IN,AN(r/i)*IN]}var YP,XP,ZP,QP,$P,eF,tF,nF,rF,iF,aF,oF,sF,cF,lF,uF,dF,tve=o((()=>{Qg(),ZN(),$N(),oP(),dF={sphere:QN,point:WP,lineStart:KP,lineEnd:qP,polygonStart:function(){dF.lineStart=Z_e,dF.lineEnd=Q_e},polygonEnd:function(){dF.lineStart=KP,dF.lineEnd=qP}}}));function fF(e,t){function n(n,r){return n=e(n,r),t(n[0],n[1])}return e.invert&&t.invert&&(n.invert=function(n,r){return n=t.invert(n,r),n&&e.invert(n[0],n[1])}),n}var pF=o((()=>{}));function mF(e,t){return RN(e)>MN&&(e-=Math.round(e/FN)*FN),[e,t]}function hF(e,t,n){return(e%=FN)?t||n?fF(_F(e),vF(t,n)):_F(e):t||n?vF(t,n):mF}function gF(e){return function(t,n){return t+=e,RN(t)>MN&&(t-=Math.round(t/FN)*FN),[t,n]}}function _F(e){var t=gF(e);return t.invert=gF(-e),t}function vF(e,t){var n=VN(e),r=qN(e),i=VN(t),a=qN(t);function o(e,t){var o=VN(t),s=VN(e)*o,c=qN(e)*o,l=qN(t),u=l*n+s*r;return[BN(c*i-u*a,s*n-l*r),AN(u*i+c*a)]}return o.invert=function(e,t){var o=VN(t),s=VN(e)*o,c=qN(e)*o,l=qN(t),u=l*i-c*a;return[BN(c*i+l*a,s*n+u*r),AN(u*n-s*r)]},o}function nve(e){e=hF(e[0]*LN,e[1]*LN,e.length>2?e[2]*LN:0);function t(t){return t=e(t[0]*LN,t[1]*LN),t[0]*=IN,t[1]*=IN,t}return t.invert=function(t){return t=e.invert(t[0]*LN,t[1]*LN),t[0]*=IN,t[1]*=IN,t},t}var yF=o((()=>{pF(),ZN(),mF.invert=mF}));function rve(e,t,n,r,i,a){if(n){var o=VN(t),s=qN(t),c=r*n;i==null?(i=t+r*FN,a=t-c/2):(i=bF(o,i),a=bF(o,a),(r>0?ia)&&(i+=r*FN));for(var l,u=i;r>0?u>a:u{wP(),ZN()}));function SF(){var e=[],t;return{point:function(e,n,r){t.push([e,n,r])},lineStart:function(){e.push(t=[])},lineEnd:QN,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}var CF=o((()=>{$N()}));function wF(e,t){return RN(e[0]-t[0])<1e-6&&RN(e[1]-t[1])<1e-6}var TF=o((()=>{ZN()}));function EF(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function DF(e,t,n,r,i){var a=[],o=[],s,c;if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,n=e[0],r=e[t],c;if(wF(n,r)){if(!n[2]&&!r[2]){for(i.lineStart(),s=0;s=0;--s)i.point((d=u[s])[0],d[1]);else r(f.x,f.p.x,-1,i);f=f.p}f=f.o,u=f.z,p=!p}while(!f.v);i.lineEnd()}}}function OF(e){if(t=e.length){for(var t,n=0,r=e[0],i;++n{TF(),ZN()}));function AF(e){return RN(e[0])<=MN?e[0]:JN(e[0])*((RN(e[0])+MN)%FN-MN)}function ive(e,t){var n=AF(t),r=t[1],i=qN(r),a=[qN(n),-VN(n),0],o=0,s=0,c=new Rg;i===1?r=NN+jN:i===-1&&(r=-NN-jN);for(var l=0,u=e.length;l=0?1:-1,E=T*w,D=E>MN,O=g*S;if(c.add(BN(O*T*qN(E),_*C+O*VN(E))),o+=D?w+T*FN:w,D^m>=n^b>=n){var k=bP(vP(p),vP(y));CP(k);var A=bP(a,k);CP(A);var j=(D^w>=0?-1:1)*AN(A[2]);(r>j||r===j&&(k[0]||k[1]))&&(s+=D^w>=0?1:-1)}}return(o<-1e-6||o<1e-6&&c<-1e-12)^s&1}var jF=o((()=>{Qg(),wP(),ZN()}));function MF(e,t,n,r){return function(i){var a=t(i),o=SF(),s=t(o),c=!1,l,u,d,f={point:p,lineStart:h,lineEnd:g,polygonStart:function(){f.point=_,f.lineStart=v,f.lineEnd=y,u=[],l=[]},polygonEnd:function(){f.point=p,f.lineStart=h,f.lineEnd=g,u=goe(u);var e=ive(l,r);u.length?(c||=(i.polygonStart(),!0),DF(u,ove,e,n,i)):e&&(c||=(i.polygonStart(),!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),c&&=(i.polygonEnd(),!1),u=l=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function p(t,n){e(t,n)&&i.point(t,n)}function m(e,t){a.point(e,t)}function h(){f.point=m,a.lineStart()}function g(){f.point=p,a.lineEnd()}function _(e,t){d.push([e,t]),s.point(e,t)}function v(){s.lineStart(),d=[]}function y(){_(d[0][0],d[0][1]),s.lineEnd();var e=s.clean(),t=o.result(),n,r=t.length,a,f,p;if(d.pop(),l.push(d),d=null,r){if(e&1){if(f=t[0],(a=f.length-1)>0){for(c||=(i.polygonStart(),!0),i.lineStart(),n=0;n1&&e&2&&t.push(t.pop().concat(t.shift())),u.push(t.filter(ave))}}return f}}function ave(e){return e.length>1}function ove(e,t){return((e=e.x)[0]<0?e[1]-NN-jN:NN-e[1])-((t=t.x)[0]<0?t[1]-NN-jN:NN-t[1])}var NF=o((()=>{CF(),kF(),ZN(),jF(),Qg()}));function sve(e){var t=NaN,n=NaN,r=NaN,i;return{lineStart:function(){e.lineStart(),i=1},point:function(a,o){var s=a>0?MN:-MN,c=RN(a-t);RN(c-MN)<1e-6?(e.point(t,n=(n+o)/2>0?NN:-NN),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),e.point(a,n),i=0):r!==s&&c>=MN&&(RN(t-r)<1e-6&&(t-=r*jN),RN(a-s)<1e-6&&(a-=s*jN),n=cve(t,n,a,o),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),i=0),e.point(t=a,n=o),r=s},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-i}}}function cve(e,t,n,r){var i,a,o=qN(e-n);return RN(o)>1e-6?zN((qN(t)*(a=VN(r))*qN(n)-qN(r)*(i=VN(t))*qN(e))/(i*a*o)):(t+r)/2}function lve(e,t,n,r){var i;if(e==null)i=n*NN,r.point(-MN,i),r.point(0,i),r.point(MN,i),r.point(MN,0),r.point(MN,-i),r.point(0,-i),r.point(-MN,-i),r.point(-MN,0),r.point(-MN,i);else if(RN(e[0]-t[0])>1e-6){var a=e[0]{NF(),ZN(),PF=MF(function(){return!0},sve,lve,[-MN,-NN])}));function uve(e){var t=VN(e),n=2*LN,r=t>0,i=RN(t)>jN;function a(t,r,i,a){rve(a,e,n,i,t,r)}function o(e,n){return VN(e)*VN(n)>t}function s(e){var t,n,a,s,u;return{lineStart:function(){s=a=!1,u=1},point:function(d,f){var p=[d,f],m,h=o(d,f),g=r?h?0:l(d,f):h?l(d+(d<0?MN:-MN),f):0;if(!t&&(s=a=h)&&e.lineStart(),h!==a&&(m=c(t,p),(!m||wF(t,m)||wF(p,m))&&(p[2]=1)),h!==a)u=0,h?(e.lineStart(),m=c(p,t),e.point(m[0],m[1])):(m=c(t,p),e.point(m[0],m[1],2),e.lineEnd()),t=m;else if(i&&t&&r^h){var _;!(g&n)&&(_=c(p,t,!0))&&(u=0,r?(e.lineStart(),e.point(_[0][0],_[0][1]),e.point(_[1][0],_[1][1]),e.lineEnd()):(e.point(_[1][0],_[1][1]),e.lineEnd(),e.lineStart(),e.point(_[0][0],_[0][1],3)))}h&&(!t||!wF(t,p))&&e.point(p[0],p[1]),t=p,a=h,n=g},lineEnd:function(){a&&e.lineEnd(),t=null},clean:function(){return u|(s&&a)<<1}}}function c(e,n,r){var i=vP(e),a=vP(n),o=[1,0,0],s=bP(i,a),c=yP(s,s),l=s[0],u=c-l*l;if(!u)return!r&&e;var d=t*c/u,f=-t*l/u,p=bP(o,s),m=SP(o,d);xP(m,SP(s,f));var h=p,g=yP(m,h),_=yP(h,h),v=g*g-_*(yP(m,m)-1);if(!(v<0)){var y=YN(v),b=SP(h,(-g-y)/_);if(xP(b,m),b=_P(b),!r)return b;var x=e[0],S=n[0],C=e[1],w=n[1],T;S0^b[1]<(RN(b[0]-x)<1e-6?C:w):C<=b[1]&&b[1]<=w:E>MN^(x<=b[0]&&b[0]<=S)){var k=SP(h,(-g+y)/_);return xP(k,m),[b,_P(k)]}}}function l(t,n){var i=r?e:MN-e,a=0;return t<-i?a|=1:t>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return MF(o,s,a,r?[0,-e]:[-MN,e-MN])}var IF=o((()=>{wP(),xF(),ZN(),TF(),NF()}));function dve(e,t,n,r,i,a){var o=e[0],s=e[1],c=t[0],l=t[1],u=0,d=1,f=c-o,p=l-s,m=n-o;if(!(!f&&m>0)){if(m/=f,f<0){if(m0){if(m>d)return;m>u&&(u=m)}if(m=i-o,!(!f&&m<0)){if(m/=f,f<0){if(m>d)return;m>u&&(u=m)}else if(f>0){if(m0)){if(m/=p,p<0){if(m0){if(m>d)return;m>u&&(u=m)}if(m=a-s,!(!p&&m<0)){if(m/=p,p<0){if(m>d)return;m>u&&(u=m)}else if(p>0){if(m0&&(e[0]=o+u*f,e[1]=s+u*p),d<1&&(t[0]=o+d*f,t[1]=s+d*p),!0}}}}}var fve=o((()=>{}));function LF(e,t,n,r){function i(i,a){return e<=i&&i<=n&&t<=a&&a<=r}function a(i,a,s,l){var u=0,d=0;if(i==null||(u=o(i,s))!==(d=o(a,s))||c(i,a)<0^s>0)do l.point(u===0||u===3?e:n,u>1?r:t);while((u=(u+s+4)%4)!==d);else l.point(a[0],a[1])}function o(r,i){return RN(r[0]-e)<1e-6?i>0?0:3:RN(r[0]-n)<1e-6?i>0?2:1:RN(r[1]-t)<1e-6?+(i>0):i>0?3:2}function s(e,t){return c(e.x,t.x)}function c(e,t){var n=o(e,1),r=o(t,1);return n===r?n===0?t[1]-e[1]:n===1?e[0]-t[0]:n===2?e[1]-t[1]:t[0]-e[0]:n-r}return function(o){var c=o,l=SF(),u,d,f,p,m,h,g,_,v,y,b,x={point:S,lineStart:E,lineEnd:D,polygonStart:w,polygonEnd:T};function S(e,t){i(e,t)&&c.point(e,t)}function C(){for(var t=0,n=0,i=d.length;nr&&(f-l)*(r-u)>(p-u)*(e-l)&&++t:p<=r&&(f-l)*(r-u)<(p-u)*(e-l)&&--t;return t}function w(){c=l,u=[],d=[],b=!0}function T(){var e=C(),t=b&&e,n=(u=goe(u)).length;(t||n)&&(o.polygonStart(),t&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),n&&DF(u,s,e,a,o),o.polygonEnd()),c=o,u=d=f=null}function E(){x.point=O,d&&d.push(f=[]),y=!0,v=!1,g=_=NaN}function D(){u&&(O(p,m),h&&v&&l.rejoin(),u.push(l.result())),x.point=S,v&&c.lineEnd()}function O(a,o){var s=i(a,o);if(d&&f.push([a,o]),y)p=a,m=o,h=s,y=!1,s&&(c.lineStart(),c.point(a,o));else if(s&&v)c.point(a,o);else{var l=[g=Math.max(zF,Math.min(RF,g)),_=Math.max(zF,Math.min(RF,_))],u=[a=Math.max(zF,Math.min(RF,a)),o=Math.max(zF,Math.min(RF,o))];dve(l,u,e,t,n,r)?(v||(c.lineStart(),c.point(l[0],l[1])),c.point(u[0],u[1]),s||c.lineEnd(),b=!1):s&&(c.lineStart(),c.point(a,o),b=!1)}g=a,_=o,v=s}return x}}var RF,zF,BF=o((()=>{ZN(),CF(),fve(),kF(),Qg(),RF=1e9,zF=-RF}));function VF(e,t,n){var r=Zg(e,t-jN,n).concat(t);return function(e){return r.map(function(t){return[e,t]})}}function HF(e,t,n){var r=Zg(e,t-jN,n).concat(t);return function(e){return r.map(function(t){return[t,e]})}}function pve(){var e,t,n,r,i,a,o,s,c=10,l=c,u=90,d=360,f,p,m,h,g=2.5;function _(){return{type:`MultiLineString`,coordinates:v()}}function v(){return Zg(HN(r/u)*u,n,u).map(m).concat(Zg(HN(s/d)*d,o,d).map(h)).concat(Zg(HN(t/c)*c,e,c).filter(function(e){return RN(e%u)>jN}).map(f)).concat(Zg(HN(a/l)*l,i,l).filter(function(e){return RN(e%d)>jN}).map(p))}return _.lines=function(){return v().map(function(e){return{type:`LineString`,coordinates:e}})},_.outline=function(){return{type:`Polygon`,coordinates:[m(r).concat(h(o).slice(1),m(n).reverse().slice(1),h(s).reverse().slice(1))]}},_.extent=function(e){return arguments.length?_.extentMajor(e).extentMinor(e):_.extentMinor()},_.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],o=+e[1][1],r>n&&(e=r,r=n,n=e),s>o&&(e=s,s=o,o=e),_.precision(g)):[[r,s],[n,o]]},_.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],a=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),a>i&&(n=a,a=i,i=n),_.precision(g)):[[t,a],[e,i]]},_.step=function(e){return arguments.length?_.stepMajor(e).stepMinor(e):_.stepMinor()},_.stepMajor=function(e){return arguments.length?(u=+e[0],d=+e[1],_):[u,d]},_.stepMinor=function(e){return arguments.length?(c=+e[0],l=+e[1],_):[c,l]},_.precision=function(c){return arguments.length?(g=+c,f=VF(a,i,90),p=HF(t,e,g),m=VF(s,o,90),h=HF(r,n,g),_):g},_.extentMajor([[-180,-90+jN],[180,90-jN]]).extentMinor([[-180,-80-jN],[180,80+jN]])}var mve=o((()=>{Qg(),ZN()})),UF,WF=o((()=>{UF=e=>e}));function hve(){QF.point=gve}function gve(e,t){QF.point=GF,JF=XF=e,YF=ZF=t}function GF(e,t){qF.add(ZF*e-XF*t),XF=e,ZF=t}function _ve(){GF(JF,YF)}var KF,qF,JF,YF,XF,ZF,QF,vve=o((()=>{Qg(),ZN(),$N(),KF=new Rg,qF=new Rg,QF={point:QN,lineStart:QN,lineEnd:QN,polygonStart:function(){QF.lineStart=hve,QF.lineEnd=_ve},polygonEnd:function(){QF.lineStart=QF.lineEnd=QF.point=QN,KF.add(RN(qF)),qF=new Rg},result:function(){var e=KF/2;return KF=new Rg,e}}}));function yve(e,t){e<$F&&($F=e),e>tI&&(tI=e),tnI&&(nI=t)}var $F,eI,tI,nI,rI,iI=o((()=>{$N(),$F=1/0,eI=$F,tI=-$F,nI=tI,rI={point:yve,lineStart:QN,lineEnd:QN,polygonStart:QN,polygonEnd:QN,result:function(){var e=[[$F,eI],[tI,nI]];return tI=nI=-(eI=$F=1/0),e}}}));function aI(e,t){lI+=e,uI+=t,++dI}function oI(){SI.point=bve}function bve(e,t){SI.point=xve,aI(bI=e,xI=t)}function xve(e,t){var n=e-bI,r=t-xI,i=YN(n*n+r*r);fI+=i*(bI+e)/2,pI+=i*(xI+t)/2,mI+=i,aI(bI=e,xI=t)}function sI(){SI.point=aI}function Sve(){SI.point=wve}function Cve(){cI(vI,yI)}function wve(e,t){SI.point=cI,aI(vI=bI=e,yI=xI=t)}function cI(e,t){var n=e-bI,r=t-xI,i=YN(n*n+r*r);fI+=i*(bI+e)/2,pI+=i*(xI+t)/2,mI+=i,i=xI*e-bI*t,hI+=i*(bI+e),gI+=i*(xI+t),_I+=i*3,aI(bI=e,xI=t)}var lI,uI,dI,fI,pI,mI,hI,gI,_I,vI,yI,bI,xI,SI,Tve=o((()=>{ZN(),lI=0,uI=0,dI=0,fI=0,pI=0,mI=0,hI=0,gI=0,_I=0,SI={point:aI,lineStart:oI,lineEnd:sI,polygonStart:function(){SI.lineStart=Sve,SI.lineEnd=Cve},polygonEnd:function(){SI.point=aI,SI.lineStart=oI,SI.lineEnd=sI},result:function(){var e=_I?[hI/_I,gI/_I]:mI?[fI/mI,pI/mI]:dI?[lI/dI,uI/dI]:[NaN,NaN];return lI=uI=dI=fI=pI=mI=hI=gI=_I=0,e}}}));function CI(e){this._context=e}var Eve=o((()=>{ZN(),$N(),CI.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:this._context.moveTo(e,t),this._point=1;break;case 1:this._context.lineTo(e,t);break;default:this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,FN);break}},result:QN}}));function Dve(e,t){jI.point=wI,DI=kI=e,OI=AI=t}function wI(e,t){kI-=e,AI-=t,TI.add(YN(kI*kI+AI*AI)),kI=e,AI=t}var TI,EI,DI,OI,kI,AI,jI,Ove=o((()=>{Qg(),ZN(),$N(),TI=new Rg,jI={point:QN,lineStart:function(){jI.point=Dve},lineEnd:function(){EI&&wI(DI,OI),jI.point=QN},polygonStart:function(){EI=!0},polygonEnd:function(){EI=null},result:function(){var e=+TI;return TI=new Rg,e}}}));function MI(e){let t=1;this._+=e[0];for(let n=e.length;t=0))throw RangeError(`invalid digits: ${e}`);if(t>15)return MI;if(t!==NI){let e=10**t;NI=t,PI=function(t){let n=1;this._+=t[0];for(let r=t.length;n{LI=class{constructor(e){this._append=e==null?MI:kve(e),this._radius=4.5,this._=``}pointRadius(e){return this._radius=+e,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+=`Z`),this._point=NaN}point(e,t){switch(this._point){case 0:this._append`M${e},${t}`,this._point=1;break;case 1:this._append`L${e},${t}`;break;default:if(this._append`M${e},${t}`,this._radius!==FI||this._append!==PI){let e=this._radius,t=this._;this._=``,this._append`m0,${e}a${e},${e} 0 1,1 0,${-2*e}a${e},${e} 0 1,1 0,${2*e}z`,FI=e,PI=this._append,II=this._,this._=t}this._+=II;break}}result(){let e=this._;return this._=``,e.length?e:null}}}));function RI(e,t){let n=3,r=4.5,i,a;function o(e){return e&&(typeof r==`function`&&a.pointRadius(+r.apply(this,arguments)),rP(e,i(a))),a.result()}return o.area=function(e){return rP(e,i(QF)),QF.result()},o.measure=function(e){return rP(e,i(jI)),jI.result()},o.bounds=function(e){return rP(e,i(rI)),rI.result()},o.centroid=function(e){return rP(e,i(SI)),SI.result()},o.projection=function(t){return arguments.length?(i=t==null?(e=null,UF):(e=t).stream,o):e},o.context=function(e){return arguments.length?(a=e==null?(t=null,new LI(n)):new CI(t=e),typeof r!=`function`&&a.pointRadius(r),o):t},o.pointRadius=function(e){return arguments.length?(r=typeof e==`function`?e:(a.pointRadius(+e),+e),o):r},o.digits=function(e){if(!arguments.length)return n;if(e==null)n=null;else{let t=Math.floor(e);if(!(t>=0))throw RangeError(`invalid digits: ${e}`);n=t}return t===null&&(a=new LI(n)),o},o.projection(e).digits(n).context(t)}var jve=o((()=>{WF(),oP(),vve(),iI(),Tve(),Eve(),Ove(),Ave()}));function zI(e){return function(t){var n=new BI;for(var r in e)n[r]=e[r];return n.stream=t,n}}function BI(){}var VI=o((()=>{BI.prototype={constructor:BI,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}}}));function HI(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),rP(n,e.stream(rI)),t(rI.result()),r!=null&&e.clipExtent(r),e}function UI(e,t,n){return HI(e,function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+t[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-a*(n[1][1]+n[0][1]))/2;e.scale(150*a).translate([o,s])},n)}function WI(e,t,n){return UI(e,[[0,0],t],n)}function GI(e,t,n){return HI(e,function(n){var r=+t,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];e.scale(150*i).translate([a,o])},n)}function KI(e,t,n){return HI(e,function(n){var r=+t,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([a,o])},n)}var qI=o((()=>{oP(),iI()}));function JI(e,t){return+t?Nve(e,t):Mve(e)}function Mve(e){return zI({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function Nve(e,t){function n(r,i,a,o,s,c,l,u,d,f,p,m,h,g){var _=l-r,v=u-i,y=_*_+v*v;if(y>4*t&&h--){var b=o+f,x=s+p,S=c+m,C=YN(b*b+x*x+S*S),w=AN(S/=C),T=RN(RN(S)-1)<1e-6||RN(a-d)<1e-6?(a+d)/2:BN(x,b),E=e(T,w),D=E[0],O=E[1],k=D-r,A=O-i,j=v*k-_*A;(j*j/y>t||RN((_*k+v*A)/y-.5)>.3||o*f+s*p+c*m{wP(),ZN(),VI(),YI=16,XI=VN(30*LN)}));function Fve(e){return zI({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}function Ive(e,t,n,r,i){function a(a,o){return a*=r,o*=i,[t+e*a,n-e*o]}return a.invert=function(a,o){return[(a-t)/e*r,(n-o)/e*i]},a}function ZI(e,t,n,r,i,a){if(!a)return Ive(e,t,n,r,i);var o=VN(a),s=qN(a),c=o*e,l=s*e,u=o/e,d=s/e,f=(s*n-o*t)/e,p=(s*t+o*n)/e;function m(e,a){return e*=r,a*=i,[c*e-l*a+t,n-l*e-c*a]}return m.invert=function(e,t){return[r*(u*e-d*t+f),i*(p-d*e-u*t)]},m}function QI(e){return $I(function(){return e})()}function $I(e){var t,n=150,r=480,i=250,a=0,o=0,s=0,c=0,l=0,u,d=0,f=1,p=1,m=null,h=PF,g=null,_,v,y,b=UF,x=.5,S,C,w,T,E;function D(e){return w(e[0]*LN,e[1]*LN)}function O(e){return e=w.invert(e[0],e[1]),e&&[e[0]*IN,e[1]*IN]}D.stream=function(e){return T&&E===e?T:T=eL(Fve(u)(h(S(b(E=e)))))},D.preclip=function(e){return arguments.length?(h=e,m=void 0,A()):h},D.postclip=function(e){return arguments.length?(b=e,g=_=v=y=null,A()):b},D.clipAngle=function(e){return arguments.length?(h=+e?uve(m=e*LN):(m=null,PF),A()):m*IN},D.clipExtent=function(e){return arguments.length?(b=e==null?(g=_=v=y=null,UF):LF(g=+e[0][0],_=+e[0][1],v=+e[1][0],y=+e[1][1]),A()):g==null?null:[[g,_],[v,y]]},D.scale=function(e){return arguments.length?(n=+e,k()):n},D.translate=function(e){return arguments.length?(r=+e[0],i=+e[1],k()):[r,i]},D.center=function(e){return arguments.length?(a=e[0]%360*LN,o=e[1]%360*LN,k()):[a*IN,o*IN]},D.rotate=function(e){return arguments.length?(s=e[0]%360*LN,c=e[1]%360*LN,l=e.length>2?e[2]%360*LN:0,k()):[s*IN,c*IN,l*IN]},D.angle=function(e){return arguments.length?(d=e%360*LN,k()):d*IN},D.reflectX=function(e){return arguments.length?(f=e?-1:1,k()):f<0},D.reflectY=function(e){return arguments.length?(p=e?-1:1,k()):p<0},D.precision=function(e){return arguments.length?(S=JI(C,x=e*e),A()):YN(x)},D.fitExtent=function(e,t){return UI(D,e,t)},D.fitSize=function(e,t){return WI(D,e,t)},D.fitWidth=function(e,t){return GI(D,e,t)},D.fitHeight=function(e,t){return KI(D,e,t)};function k(){var e=ZI(n,0,0,f,p,d).apply(null,t(a,o)),m=ZI(n,r-e[0],i-e[1],f,p,d);return u=hF(s,c,l),C=fF(t,m),w=fF(u,C),S=JI(C,x),A()}function A(){return T=E=null,D}return function(){return t=e.apply(this,arguments),D.invert=t.invert&&O,k()}}var eL,tL=o((()=>{FF(),IF(),BF(),pF(),WF(),ZN(),yF(),VI(),qI(),Pve(),eL=zI({point:function(e,t){this.stream.point(e*LN,t*LN)}})}));function nL(e){var t=0,n=MN/3,r=$I(e),i=r(t,n);return i.parallels=function(e){return arguments.length?r(t=e[0]*LN,n=e[1]*LN):[t*IN,n*IN]},i}var rL=o((()=>{ZN(),tL()}));function Lve(e){var t=VN(e);function n(e,n){return[e*t,qN(n)/t]}return n.invert=function(e,n){return[e/t,AN(n*t)]},n}var Rve=o((()=>{ZN()}));function zve(e,t){var n=qN(e),r=(n+qN(t))/2;if(RN(r)<1e-6)return Lve(e);var i=1+n*(2*r-n),a=YN(i)/r;function o(e,t){var n=YN(i-2*r*qN(t))/r;return[n*qN(e*=r),a-n*VN(e)]}return o.invert=function(e,t){var n=a-t,o=BN(e,RN(n))*JN(n);return n*r<0&&(o-=MN*JN(e)*JN(n)),[o/r,AN((i-(e*e+n*n)*r*r)/(2*r))]},o}function iL(){return nL(zve).scale(155.424).center([0,33.6442])}var aL=o((()=>{ZN(),rL(),Rve()}));function oL(){return iL().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}var sL=o((()=>{aL()}));function Bve(e){var t=e.length;return{point:function(n,r){for(var i=-1;++i=.12&&s<.234&&a>=-.425&&a<-.214?i:s>=.166&&s<.234&&a>=-.214&&a<-.115?o:n).invert(e)},u.stream=function(r){return e&&t===r?e:e=Bve([n.stream(t=r),i.stream(r),o.stream(r)])},u.precision=function(e){return arguments.length?(n.precision(e),i.precision(e),o.precision(e),d()):n.precision()},u.scale=function(e){return arguments.length?(n.scale(e),i.scale(e*.35),o.scale(e),u.translate(n.translate())):n.scale()},u.translate=function(e){if(!arguments.length)return n.translate();var t=n.scale(),c=+e[0],u=+e[1];return r=n.translate(e).clipExtent([[c-.455*t,u-.238*t],[c+.455*t,u+.238*t]]).stream(l),a=i.translate([c-.307*t,u+.201*t]).clipExtent([[c-.425*t+jN,u+.12*t+jN],[c-.214*t-jN,u+.234*t-jN]]).stream(l),s=o.translate([c-.205*t,u+.212*t]).clipExtent([[c-.214*t+jN,u+.166*t+jN],[c-.115*t-jN,u+.234*t-jN]]).stream(l),d()},u.fitExtent=function(e,t){return UI(u,e,t)},u.fitSize=function(e,t){return WI(u,e,t)},u.fitWidth=function(e,t){return GI(u,e,t)},u.fitHeight=function(e,t){return KI(u,e,t)};function d(){return e=t=null,u}return u.scale(1070)}var Hve=o((()=>{ZN(),sL(),aL(),qI()}));function cL(e){return function(t,n){var r=VN(t),i=VN(n),a=e(r*i);return a===1/0?[2,0]:[a*i*qN(t),a*qN(n)]}}function lL(e){return function(t,n){var r=YN(t*t+n*n),i=e(r),a=qN(i),o=VN(i);return[BN(t*a,r*o),AN(r&&n*a/r)]}}var uL=o((()=>{ZN()}));function Uve(){return QI(dL).scale(124.75).clipAngle(179.999)}var dL,Wve=o((()=>{ZN(),uL(),tL(),dL=cL(function(e){return YN(2/(1+e))}),dL.invert=lL(function(e){return 2*AN(e/2)})}));function Gve(){return QI(fL).scale(79.4188).clipAngle(179.999)}var fL,Kve=o((()=>{ZN(),uL(),tL(),fL=cL(function(e){return(e=kN(e))&&e/qN(e)}),fL.invert=lL(function(e){return e})}));function pL(e,t){return[e,GN(XN((NN+t)/2))]}function qve(){return mL(pL).scale(961/FN)}function mL(e){var t=QI(e),n=t.center,r=t.scale,i=t.translate,a=t.clipExtent,o=null,s,c,l;t.scale=function(e){return arguments.length?(r(e),u()):r()},t.translate=function(e){return arguments.length?(i(e),u()):i()},t.center=function(e){return arguments.length?(n(e),u()):n()},t.clipExtent=function(e){return arguments.length?(e==null?o=s=c=l=null:(o=+e[0][0],s=+e[0][1],c=+e[1][0],l=+e[1][1]),u()):o==null?null:[[o,s],[c,l]]};function u(){var n=MN*r(),i=t(nve(t.rotate()).invert([0,0]));return a(o==null?[[i[0]-n,i[1]-n],[i[0]+n,i[1]+n]]:e===pL?[[Math.max(i[0]-n,o),s],[Math.min(i[0]+n,c),l]]:[[o,Math.max(i[1]-n,s)],[c,Math.min(i[1]+n,l)]])}return u()}var hL=o((()=>{ZN(),yF(),tL(),pL.invert=function(e,t){return[e,2*zN(UN(t))-NN]}}));function gL(e){return XN((NN+e)/2)}function Jve(e,t){var n=VN(e),r=e===t?qN(e):GN(n/VN(t))/GN(gL(t)/gL(e)),i=n*KN(gL(e),r)/r;if(!r)return pL;function a(e,t){i>0?t<-NN+1e-6&&(t=-NN+jN):t>NN-1e-6&&(t=NN-jN);var n=i/KN(gL(t),r);return[n*qN(r*e),i-n*VN(r*e)]}return a.invert=function(e,t){var n=i-t,a=JN(r)*YN(e*e+n*n),o=BN(e,RN(n))*JN(n);return n*r<0&&(o-=MN*JN(e)*JN(n)),[o/r,2*zN(KN(i/a,1/r))-NN]},a}function Yve(){return nL(Jve).scale(109.5).parallels([30,30])}var Xve=o((()=>{ZN(),rL(),hL()}));function _L(e,t){return[e,t]}function Zve(){return QI(_L).scale(152.63)}var vL=o((()=>{tL(),_L.invert=_L}));function Qve(e,t){var n=VN(e),r=e===t?qN(e):(n-VN(t))/(t-e),i=n/r+e;if(RN(r)<1e-6)return _L;function a(e,t){var n=i-t,a=r*e;return[n*qN(a),i-n*VN(a)]}return a.invert=function(e,t){var n=i-t,a=BN(e,RN(n))*JN(n);return n*r<0&&(a-=MN*JN(e)*JN(n)),[a/r,i-JN(r)*YN(e*e+n*n)]},a}function $ve(){return nL(Qve).scale(131.154).center([0,13.9389])}var eye=o((()=>{ZN(),rL(),vL()}));function yL(e,t){var n=AN(wL*qN(t)),r=n*n,i=r*r*r;return[e*VN(n)/(wL*(bL+3*xL*r+i*(7*SL+9*CL*r))),n*(bL+xL*r+i*(SL+CL*r))]}function tye(){return QI(yL).scale(177.158)}var bL,xL,SL,CL,wL,TL,nye=o((()=>{tL(),ZN(),bL=1.340264,xL=-.081106,SL=893e-6,CL=.003796,wL=YN(3)/2,TL=12,yL.invert=function(e,t){for(var n=t,r=n*n,i=r*r*r,a=0,o,s,c;a{ZN(),uL(),tL(),EL.invert=lL(zN)}));function aye(){var e=1,t=0,n=0,r=1,i=1,a=0,o,s,c=null,l,u,d,f=1,p=1,m=zI({point:function(e,t){var n=y([e,t]);this.stream.point(n[0],n[1])}}),h=UF,g,_;function v(){return f=e*r,p=e*i,g=_=null,y}function y(e){var r=e[0]*f,i=e[1]*p;if(a){var c=i*o-r*s;r=r*o+i*s,i=c}return[r+t,i+n]}return y.invert=function(e){var r=e[0]-t,i=e[1]-n;if(a){var c=i*o+r*s;r=r*o-i*s,i=c}return[r/f,i/p]},y.stream=function(e){return g&&_===e?g:g=m(h(_=e))},y.postclip=function(e){return arguments.length?(h=e,c=l=u=d=null,v()):h},y.clipExtent=function(e){return arguments.length?(h=e==null?(c=l=u=d=null,UF):LF(c=+e[0][0],l=+e[0][1],u=+e[1][0],d=+e[1][1]),v()):c==null?null:[[c,l],[u,d]]},y.scale=function(t){return arguments.length?(e=+t,v()):e},y.translate=function(e){return arguments.length?(t=+e[0],n=+e[1],v()):[t,n]},y.angle=function(e){return arguments.length?(a=e%360*LN,s=qN(a),o=VN(a),v()):a*IN},y.reflectX=function(e){return arguments.length?(r=e?-1:1,v()):r<0},y.reflectY=function(e){return arguments.length?(i=e?-1:1,v()):i<0},y.fitExtent=function(e,t){return UI(y,e,t)},y.fitSize=function(e,t){return WI(y,e,t)},y.fitWidth=function(e,t){return GI(y,e,t)},y.fitHeight=function(e,t){return KI(y,e,t)},y}var oye=o((()=>{BF(),WF(),VI(),qI(),ZN()}));function DL(e,t){var n=t*t,r=n*n;return[e*(.8707-.131979*n+r*(-.013791+r*(.003971*n-.001529*r))),t*(1.007226+n*(.015085+r*(-.044475+.028874*n-.005916*r)))]}function sye(){return QI(DL).scale(175.295)}var cye=o((()=>{tL(),ZN(),DL.invert=function(e,t){var n=t,r=25,i;do{var a=n*n,o=a*a;n-=i=(n*(1.007226+a*(.015085+o*(-.044475+.028874*a-.005916*o)))-t)/(1.007226+a*(.015085*3+o*(-.044475*7+.028874*9*a-.005916*11*o)))}while(RN(i)>1e-6&&--r>0);return[e/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]}}));function OL(e,t){return[VN(t)*qN(e),qN(t)]}function lye(){return QI(OL).scale(249.5).clipAngle(90+jN)}var uye=o((()=>{ZN(),uL(),tL(),OL.invert=lL(AN)}));function kL(e,t){var n=VN(t),r=1+VN(e)*n;return[n*qN(e)/r,qN(t)/r]}function dye(){return QI(kL).scale(250).clipAngle(142)}var fye=o((()=>{ZN(),uL(),tL(),kL.invert=lL(function(e){return 2*zN(e)})}));function AL(e,t){return[GN(XN((NN+t)/2)),-e]}function pye(){var e=mL(AL),t=e.center,n=e.rotate;return e.center=function(e){return arguments.length?t([-e[1],e[0]]):(e=t(),[e[1],-e[0]])},e.rotate=function(e){return arguments.length?n([e[0],e[1],e.length>2?e[2]+90:90]):(e=n(),[e[0],e[1],e[2]-90])},n([0,0,90]).scale(159.155)}var mye=o((()=>{ZN(),hL(),AL.invert=function(e,t){return[-t,2*zN(UN(e))-NN]}})),jL=o((()=>{gP(),J_e(),tve(),xF(),FF(),IF(),BF(),jF(),Qg(),ZN(),$N(),oP(),mve(),jve(),sL(),Hve(),Wve(),Kve(),Xve(),aL(),eye(),nye(),vL(),iye(),oye(),tL(),hL(),cye(),uye(),fye(),mye(),yF(),VI()}));function ML(e){return e>1?LL:e<-1?-LL:Math.asin(e)}function hye(e){return e>0?Math.sqrt(e):0}var NL,PL,FL,IL,LL,RL,zL=o((()=>{NL=Math.abs,PL=Math.cos,FL=Math.sin,IL=Math.PI,LL=IL/2,IL/4,RL=hye(2),IL*2,180/IL,IL/180}));function gye(e,t){var n=e*FL(t),r=30,i;do t-=i=(t+FL(t)-n)/(1+PL(t));while(NL(i)>1e-6&&--r>0);return t/2}function _ye(e,t,n){function r(r,i){return[e*r*PL(i=gye(n,i)),t*FL(i)]}return r.invert=function(r,i){return i=ML(i/t),[r/(e*PL(i)),ML((2*i+FL(2*i))/n)]},r}function vye(){return QI(BL).scale(169.529)}var BL,yye=o((()=>{jL(),zL(),BL=_ye(RL/LL,RL,IL)})),bye=o((()=>{jL(),zL(),yye(),Qg()}));function xye(e,t){return function n(){let r=t();return r.type=e,r.path=RI().projection(r),r.copy=r.copy||function(){let e=n();return WL.forEach(t=>{r[t]&&e[t](r[t]())}),e.path.pointRadius(r.path.pointRadius()),e},Gfe(r)}}function VL(e,t){if(!e||typeof e!=`string`)throw Error(`Projection type must be a name string.`);return e=e.toLowerCase(),arguments.length>1?(GL[e]=xye(e,t),this):GL[e]||null}function HL(e){return e&&e.path||UL}var UL,WL,GL,KL=o((()=>{jL(),bye(),xO(),UL=RI(),WL=[`clipAngle`,`clipExtent`,`scale`,`translate`,`center`,`rotate`,`parallels`,`precision`,`reflectX`,`reflectY`,`coefficient`,`distance`,`fraction`,`lobes`,`parallel`,`radius`,`ratio`,`spacing`,`tilt`],GL={albers:oL,albersusa:Vve,azimuthalequalarea:Uve,azimuthalequidistant:Gve,conicconformal:Yve,conicequalarea:iL,conicequidistant:$ve,equalEarth:tye,equirectangular:Zve,gnomonic:rye,identity:aye,mercator:qve,mollweide:vye,naturalEarth1:sye,orthographic:lye,stereographic:dye,transversemercator:pye};for(let e in GL)VL(e,GL[e])})),Sye=c({contour:()=>iR,geojson:()=>aR,geopath:()=>oR,geopoint:()=>sR,geoshape:()=>cR,graticule:()=>lR,heatmap:()=>uR,isocontour:()=>YL,kde2d:()=>nR,projection:()=>fR});function Cye(){}function qL(){var e=1,t=1,n=s;function r(e,t){return t.map(t=>i(e,t))}function i(e,t){var r=[],i=[];return a(e,t,a=>{n(a,e,t),wye(a)>0?r.push([a]):i.push(a)}),i.forEach(e=>{for(var t=0,n=r.length,i;t=r,f,p;for(mR[d<<1].forEach(m);++c=r,mR[u|d<<1].forEach(m);for(mR[d<<0].forEach(m);++l=r,f=n[l*e]>=r,mR[d<<1|f<<2].forEach(m);++c=r,p=f,f=n[l*e+c+1]>=r,mR[u|d<<1|f<<2|p<<3].forEach(m);mR[d|f<<3].forEach(m)}for(c=-1,f=n[l*e]>=r,mR[f<<2].forEach(m);++c=r,mR[f<<2|p<<3].forEach(m);mR[f<<3].forEach(m);function m(e){var t=[e[0][0]+c,e[0][1]+l],n=[e[1][0]+c,e[1][1]+l],r=o(t),u=o(n),d,f;(d=s[r])?(f=a[u])?(delete s[d.end],delete a[f.start],d===f?(d.ring.push(n),i(d.ring)):a[d.start]=s[f.end]={start:d.start,end:f.end,ring:d.ring.concat(f.ring)}):(delete s[d.end],d.ring.push(n),s[d.end=u]=d):(d=a[u])?(f=s[r])?(delete a[d.start],delete s[f.end],d===f?(d.ring.push(n),i(d.ring)):a[f.start]=s[d.end]={start:f.start,end:d.end,ring:f.ring.concat(d.ring)}):(delete a[d.start],d.ring.unshift(t),a[d.start=r]=d):a[r]=s[u]={start:r,end:u,ring:[t,n]}}}function o(t){return t[0]*2+t[1]*(e+1)*4}function s(n,r,i){n.forEach(n=>{var a=n[0],o=n[1],s=a|0,c=o|0,l,u=r[c*e+s];a>0&&a0&&o=0&&a>=0||V(`invalid size`),e=i,t=a,r},r.smooth=function(e){return arguments.length?(n=e?s:Cye,r):n===s},r}function wye(e){for(var t=0,n=e.length,r=e[n-1][1]*e[0][0]-e[n-1][0]*e[0][1];++tr!=p>r&&n<(f-l)*(r-u)/(p-u)+l&&(i=-i)}return i}function Dye(e,t,n){var r;return Oye(e,t,n)&&kye(e[r=+(e[0]===t[0])],n[r],t[r])}function Oye(e,t,n){return(t[0]-e[0])*(n[1]-e[1])===(n[0]-e[0])*(t[1]-e[1])}function kye(e,t,n){return e<=t&&t<=n||n<=t&&t<=e}function JL(e,t,n){return function(r){var i=og(r),a=n?Math.min(i[0],0):i[0],o=i[1],s=o-a,c=t?Kg(a,o,e):s/(e+1);return Zg(a+c,o,c)}}function YL(e){G.call(this,null,e)}function Aye(e,t,n){let r=JL(n.levels||10,n.nice,n.zero!==!1);return n.resolve===`shared`?r(e.map(e=>qg(t(e).values))):r}function jye(e,t,n,r){let i=r.scale||t.scale,a=r.translate||t.translate;if(Jh(i)&&(i=i(n,r)),Jh(a)&&(a=a(n,r)),(i===1||i==null)&&!a)return;let o=(mg(i)?i:i[0])||1,s=(mg(i)?i:i[1])||1,c=a&&a[0]||0,l=a&&a[1]||0;e.forEach(XL(t,o,s,c,l))}function XL(e,t,n,r,i){let a=e.x1||0,o=e.y1||0,s=t*n<0;function c(e){e.forEach(l)}function l(e){s&&e.reverse(),e.forEach(u)}function u(e){e[0]=(e[0]-a)*t+r,e[1]=(e[1]-o)*n+i}return function(e){return e.coordinates.forEach(c),e}}function ZL(e,t,n){let r=e>=0?e:Wx(t,n);return Math.round((Math.sqrt(4*r*r+1)-1)/2)}function QL(e){return Jh(e)?e:ng(+e)}function $L(){var e=e=>e[0],t=e=>e[1],n=uh,r=[-1,-1],i=960,a=500,o=2;function s(s,c){let l=ZL(r[0],s,e)>>o,u=ZL(r[1],s,t)>>o,d=l?l+2:0,f=u?u+2:0,p=2*d+(i>>o),m=2*f+(a>>o),h=new Float32Array(p*m),g=new Float32Array(p*m),_=h;s.forEach(r=>{let i=d+(+e(r)>>o),a=f+(+t(r)>>o);i>=0&&i=0&&a0&&u>0?(eR(p,m,h,g,l),tR(p,m,g,h,u),eR(p,m,h,g,l),tR(p,m,g,h,u),eR(p,m,h,g,l),tR(p,m,g,h,u)):l>0?(eR(p,m,h,g,l),eR(p,m,g,h,l),eR(p,m,h,g,l),_=g):u>0&&(tR(p,m,h,g,u),tR(p,m,g,h,u),tR(p,m,h,g,u),_=g);let v=c?2**(-2*o):1/yoe(_);for(let e=0,t=p*m;e>o),y2:f+(a>>o)}}return s.x=function(t){return arguments.length?(e=QL(t),s):e},s.y=function(e){return arguments.length?(t=QL(e),s):t},s.weight=function(e){return arguments.length?(n=QL(e),s):n},s.size=function(e){if(!arguments.length)return[i,a];var t=+e[0],n=+e[1];return t>=0&&n>=0||V(`invalid size`),i=t,a=n,s},s.cellSize=function(e){return arguments.length?((e=+e)>=1||V(`invalid cell size`),o=Math.floor(Math.log(e)/Math.LN2),s):1<=i&&(t>=a&&(s-=n[t-a+o*e]),r[t-i+o*e]=s/Math.min(t+1,e-1+a-t,a))}function tR(e,t,n,r,i){let a=(i<<1)+1;for(let o=0;o=i&&(s>=a&&(c-=n[o+(s-a)*e]),r[o+(s-i)*e]=c/Math.min(s+1,t-1+a-s,a))}function nR(e){G.call(this,null,e)}function rR(e,t){return hR.forEach(n=>t[n]==null?0:e[n](t[n])),e}function Mye(e,t){var n=[],r=e=>e(s),i,a,o,s,c,l;if(t==null)n.push(e);else for(i={},a=0,o=e.length;ae(t(n)):r=>{var i=e.pointRadius(),a=e.pointRadius(n)(t(r));return e.pointRadius(i),a};return r.context=t=>(e.context(t),r),r}function lR(e){G.call(this,[],e),this.generator=pve()}function uR(e){G.call(this,null,e)}function Fye(e,t){let n;return Jh(e)?(n=n=>RT(e(n,t)),n.dep=dR(e)):n=ng(RT(e||`#888`)),n}function Iye(e,t){let n;return Jh(e)?(n=n=>e(n,t),n.dep=dR(e)):e?n=ng(e):(n=e=>e.$value/e.$max||0,n.dep=!0),n}function dR(e){if(!Jh(e))return!1;let t=Cg(Xm(e));return t.$x||t.$y||t.$value||t.$max}function Lye(e,t,n,r){let i=e.width,a=e.height,o=e.x1||0,s=e.y1||0,c=e.x2||i,l=e.y2||a,u=e.values,d=u?e=>u[e]:lh,f=bT(c-o,l-s),p=f.getContext(`2d`),m=p.getImageData(0,0,c-o,l-s),h=m.data;for(let e=s,a=0;ee.concat(Vye(t)),[])}}function Vye(e){return e.type===_R?e.features:Gh(e).filter(e=>e!=null).map(e=>e.type===gR?e:{type:gR,geometry:e})}var mR,hR,gR,_R,vR,Hye=o((()=>{Bx(),Tg(),Qg(),jS(),KL(),jL(),UE(),ST(),mR=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]],YL.Definition={type:`Isocontour`,metadata:{generates:!0},params:[{name:`field`,type:`field`},{name:`thresholds`,type:`number`,array:!0},{name:`levels`,type:`number`},{name:`nice`,type:`boolean`,default:!1},{name:`resolve`,type:`enum`,values:[`shared`,`independent`],default:`independent`},{name:`zero`,type:`boolean`,default:!0},{name:`smooth`,type:`boolean`,default:!0},{name:`scale`,type:`number`,expr:!0},{name:`translate`,type:`number`,array:!0,expr:!0},{name:`as`,type:`string`,null:!0,default:`contour`}]},U(YL,G,{transform(e,t){if(this.value&&!t.changed()&&!e.modified())return t.StopPropagation;var n=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=t.materialize(t.SOURCE).source,i=e.field||ch,a=qL().smooth(e.smooth!==!1),o=e.thresholds||Aye(r,i,e),s=e.as===null?null:e.as||`contour`,c=[];return r.forEach(t=>{let n=i(t),r=a.size([n.width,n.height])(n.values,H(o)?o:o(n.values));jye(r,n,t,e),r.forEach(e=>{c.push(Xb(t,Jb(s==null?e:{[s]:e})))})}),this.value&&(n.rem=this.value),this.value=n.source=n.add=c,n}}),nR.Definition={type:`KDE2D`,metadata:{generates:!0},params:[{name:`size`,type:`number`,array:!0,length:2,required:!0},{name:`x`,type:`field`,required:!0},{name:`y`,type:`field`,required:!0},{name:`weight`,type:`field`},{name:`groupby`,type:`field`,array:!0},{name:`cellSize`,type:`number`},{name:`bandwidth`,type:`number`,array:!0,length:2},{name:`counts`,type:`boolean`,default:!1},{name:`as`,type:`string`,default:`grid`}]},hR=[`x`,`y`,`weight`,`size`,`cellSize`,`bandwidth`],U(nR,G,{transform(e,t){if(this.value&&!t.changed()&&!e.modified())return t.StopPropagation;var n=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=t.materialize(t.SOURCE).source,i=Mye(r,e.groupby),a=(e.groupby||[]).map(Ym),o=rR($L(),e),s=e.as||`grid`,c=[];function l(e,t){for(let n=0;nJb(l({[s]:o(t,e.counts)},t.dims))),this.value&&(n.rem=this.value),this.value=n.source=n.add=c,n}}),iR.Definition={type:`Contour`,metadata:{generates:!0},params:[{name:`size`,type:`number`,array:!0,length:2,required:!0},{name:`values`,type:`number`,array:!0},{name:`x`,type:`field`},{name:`y`,type:`field`},{name:`weight`,type:`field`},{name:`cellSize`,type:`number`},{name:`bandwidth`,type:`number`},{name:`count`,type:`number`},{name:`nice`,type:`boolean`,default:!1},{name:`thresholds`,type:`number`,array:!0},{name:`smooth`,type:`boolean`,default:!0}]},U(iR,G,{transform(e,t){if(this.value&&!t.changed()&&!e.modified())return t.StopPropagation;var n=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=qL().smooth(e.smooth!==!1),i=e.values,a=e.thresholds||JL(e.count||10,e.nice,!!i),o=e.size,s,c;return i||=(i=t.materialize(t.SOURCE).source,s=rR($L(),e)(i,!0),c=XL(s,s.scale||1,s.scale||1,0,0),o=[s.width,s.height],s.values),a=H(a)?a:a(i),i=r.size(o)(i,a),c&&i.forEach(c),this.value&&(n.rem=this.value),this.value=n.source=n.add=(i||[]).map(Jb),n}}),gR=`Feature`,_R=`FeatureCollection`,vR=`MultiPoint`,aR.Definition={type:`GeoJSON`,metadata:{},params:[{name:`fields`,type:`field`,array:!0,length:2},{name:`geojson`,type:`field`}]},U(aR,G,{transform(e,t){var n=this._features,r=this._points,i=e.fields,a=i&&i[0],o=i&&i[1],s=e.geojson||!i&&ch,c=t.ADD,l=e.modified()||t.changed(t.REM)||t.modified(Xm(s))||a&&t.modified(Xm(a))||o&&t.modified(Xm(o));(!this.value||l)&&(c=t.SOURCE,this._features=n=[],this._points=r=[]),s&&t.visit(c,e=>n.push(s(e))),a&&o&&(t.visit(c,e=>{var t=a(e),n=o(e);t!=null&&n!=null&&(t=+t)===t&&(n=+n)===n&&r.push([t,n])}),n=n.concat({type:gR,geometry:{type:vR,coordinates:r}})),this.value={type:_R,features:n}}}),oR.Definition={type:`GeoPath`,metadata:{modifies:!0},params:[{name:`projection`,type:`projection`},{name:`field`,type:`field`},{name:`pointRadius`,type:`number`,expr:!0},{name:`as`,type:`string`,default:`path`}]},U(oR,G,{transform(e,t){var n=t.fork(t.ALL),r=this.value,i=e.field||ch,a=e.as||`path`,o=n.SOURCE;!r||e.modified()?(this.value=r=HL(e.projection),n.materialize().reflow()):o=i===ch||t.modified(i.fields)?n.ADD_MOD:n.ADD;let s=Nye(r,e.pointRadius);return n.visit(o,e=>e[a]=r(i(e))),r.pointRadius(s),n.modifies(a)}}),sR.Definition={type:`GeoPoint`,metadata:{modifies:!0},params:[{name:`projection`,type:`projection`,required:!0},{name:`fields`,type:`field`,array:!0,required:!0,length:2},{name:`as`,type:`string`,array:!0,length:2,default:[`x`,`y`]}]},U(sR,G,{transform(e,t){var n=e.projection,r=e.fields[0],i=e.fields[1],a=e.as||[`x`,`y`],o=a[0],s=a[1],c;function l(e){let t=n([r(e),i(e)]);t?(e[o]=t[0],e[s]=t[1]):(e[o]=void 0,e[s]=void 0)}return e.modified()?t=t.materialize().reflow(!0).visit(t.SOURCE,l):(c=t.modified(r.fields)||t.modified(i.fields),t.visit(c?t.ADD_MOD:t.ADD,l)),t.modifies(a)}}),cR.Definition={type:`GeoShape`,metadata:{modifies:!0,nomod:!0},params:[{name:`projection`,type:`projection`},{name:`field`,type:`field`,default:`datum`},{name:`pointRadius`,type:`number`,expr:!0},{name:`as`,type:`string`,default:`shape`}]},U(cR,G,{transform(e,t){var n=t.fork(t.ALL),r=this.value,i=e.as||`shape`,a=n.ADD;return(!r||e.modified())&&(this.value=r=Pye(HL(e.projection),e.field||ah(`datum`),e.pointRadius),n.materialize().reflow(),a=n.SOURCE),n.visit(a,e=>e[i]=r),n.modifies(i)}}),lR.Definition={type:`Graticule`,metadata:{changes:!0,generates:!0},params:[{name:`extent`,type:`array`,array:!0,length:2,content:{type:`number`,array:!0,length:2}},{name:`extentMajor`,type:`array`,array:!0,length:2,content:{type:`number`,array:!0,length:2}},{name:`extentMinor`,type:`array`,array:!0,length:2,content:{type:`number`,array:!0,length:2}},{name:`step`,type:`number`,array:!0,length:2},{name:`stepMajor`,type:`number`,array:!0,length:2,default:[90,360]},{name:`stepMinor`,type:`number`,array:!0,length:2,default:[10,10]},{name:`precision`,type:`number`,default:2.5}]},U(lR,G,{transform(e,t){var n=this.value,r=this.generator,i;if(!n.length||e.modified())for(let t in e)Jh(r[t])&&r[t](e[t]);return i=r(),n.length?t.mod.push(Zb(n[0],i)):t.add.push(Jb(i)),n[0]=i,t}}),uR.Definition={type:`heatmap`,metadata:{modifies:!0},params:[{name:`field`,type:`field`},{name:`color`,type:`string`,expr:!0},{name:`opacity`,type:`number`,expr:!0},{name:`resolve`,type:`enum`,values:[`shared`,`independent`],default:`independent`},{name:`as`,type:`string`,default:`image`}]},U(uR,G,{transform(e,t){if(!t.changed()&&!e.modified())return t.StopPropagation;var n=t.materialize(t.SOURCE).source,r=e.resolve===`shared`,i=e.field||ch,a=Iye(e.opacity,e),o=Fye(e.color,e),s=e.as||`image`,c={$x:0,$y:0,$value:0,$max:r?qg(n.map(e=>qg(i(e).values))):0};return n.forEach(e=>{let t=i(e),n=ig({},e,c);r||(n.$max=qg(t.values||[])),e[s]=Lye(t,n,o.dep?o:ng(o(n)),a.dep?a:ng(a(n)))}),t.reflow(!0).modifies(s)}}),U(fR,G,{transform(e,t){let n=this.value;return!n||e.modified(`type`)?(this.value=n=zye(e.type),WL.forEach(t=>{e[t]!=null&&pR(n,t,e[t])})):WL.forEach(t=>{e.modified(t)&&pR(n,t,e[t])}),e.pointRadius!=null&&n.path.pointRadius(e.pointRadius),e.fit&&Rye(n,e),t.fork(t.NO_SOURCE|t.NO_FIELDS)}})}));function Uye(e,t){var n,r=1;e??=0,t??=0;function i(){var i,a=n.length,o,s=0,c=0;for(i=0;i{}));function Gye(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return yR(this.cover(t,n),t,n,e)}function yR(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,c=e._y0,l=e._x1,u=e._y1,d,f,p,m,h,g,_,v;if(!a)return e._root=o,e;for(;a.length;)if((h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f,i=a,!(a=a[_=g<<1|h]))return i[_]=o,e;if(p=+e._x.call(null,a.data),m=+e._y.call(null,a.data),t===p&&n===m)return o.next=a,i?i[_]=o:e._root=o,e;do i=i?i[_]=[,,,,]:e._root=[,,,,],(h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f;while((_=g<<1|h)==(v=(m>=f)<<1|p>=d));return i[v]=a,i[_]=o,e}function Kye(e){var t,n,r=e.length,i,a,o=Array(r),s=Array(r),c=1/0,l=1/0,u=-1/0,d=-1/0;for(n=0;nu&&(u=i),ad&&(d=a));if(c>u||l>d)return this;for(this.cover(c,l).cover(u,d),n=0;n{}));function Jye(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,c,l;n>e||e>=i||r>t||t>=a;)switch(l=(t{}));function Xye(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}var Zye=o((()=>{}));function Qye(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}var $ye=o((()=>{}));function bR(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}var xR=o((()=>{}));function ebe(e,t,n){var r,i=this._x0,a=this._y0,o,s,c,l,u=this._x1,d=this._y1,f=[],p=this._root,m,h;for(p&&f.push(new bR(p,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);m=f.pop();)if(!(!(p=m.node)||(o=m.x0)>u||(s=m.y0)>d||(c=m.x1)=_)<<1|e>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=m)}else{var v=e-+this._x.call(null,p.data),y=t-+this._y.call(null,p.data),b=v*v+y*y;if(b{xR()}));function nbe(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._x1,l=this._y1,u,d,f,p,m,h,g,_;if(!n)return this;if(n.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(h=d>=(p=(s+l)/2))?s=p:l=p,t=n,!(n=n[g=h<<1|m]))return this;if(!n.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(r=t,_=g)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[g]=a:delete t[g],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function rbe(e){for(var t=0,n=e.length;t{}));function abe(){return this._root}var obe=o((()=>{}));function sbe(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}var cbe=o((()=>{}));function lbe(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new bR(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,c=n.y1)&&r.length){var l=(a+s)/2,u=(o+c)/2;(i=r[3])&&t.push(new bR(i,l,u,s,c)),(i=r[2])&&t.push(new bR(i,a,u,l,c)),(i=r[1])&&t.push(new bR(i,l,o,s,u)),(i=r[0])&&t.push(new bR(i,a,o,l,u))}return this}var ube=o((()=>{xR()}));function dbe(e){var t=[],n=[],r;for(this._root&&t.push(new bR(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.x1,l=r.y1,u=(o+c)/2,d=(s+l)/2;(a=i[0])&&t.push(new bR(a,o,s,u,d)),(a=i[1])&&t.push(new bR(a,u,s,c,d)),(a=i[2])&&t.push(new bR(a,o,d,u,l)),(a=i[3])&&t.push(new bR(a,u,d,c,l))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}var fbe=o((()=>{xR()}));function pbe(e){return e[0]}function mbe(e){return arguments.length?(this._x=e,this):this._x}var hbe=o((()=>{}));function gbe(e){return e[1]}function _be(e){return arguments.length?(this._y=e,this):this._y}var vbe=o((()=>{}));function SR(e,t,n){var r=new CR(t??pbe,n??gbe,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function CR(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function wR(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var TR,ybe=o((()=>{qye(),Yye(),Zye(),$ye(),tbe(),ibe(),obe(),cbe(),ube(),fbe(),hbe(),vbe(),TR=SR.prototype=CR.prototype,TR.copy=function(){var e=new CR(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=wR(t),e;for(n=[{source:t,target:e._root=[,,,,]}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=[,,,,]}):t.target[i]=wR(r));return e},TR.add=Gye,TR.addAll=Kye,TR.cover=Jye,TR.data=Xye,TR.extent=Qye,TR.find=ebe,TR.remove=nbe,TR.removeAll=rbe,TR.root=abe,TR.size=sbe,TR.visit=lbe,TR.visitAfter=dbe,TR.x=mbe,TR.y=_be})),ER=o((()=>{ybe()}));function DR(e){return function(){return e}}var OR=o((()=>{}));function kR(e){return(e()-.5)*1e-6}var AR=o((()=>{}));function bbe(e){return e.x+e.vx}function xbe(e){return e.y+e.vy}function Sbe(e){var t,n,r,i=1,a=1;typeof e!=`function`&&(e=DR(e==null?1:+e));function o(){for(var e,o=t.length,c,l,u,d,f,p,m=0;ml.index){var h=u-s.x-s.vx,g=d-s.y-s.vy,_=h*h+g*g;_u+m||ad+m||oe.r&&(e.r=e[t].r)}function c(){if(t){var r,i=t.length,a;for(n=Array(i),r=0;r{ER(),OR(),AR()}));function wbe(e){return e.index}function jR(e,t){var n=e.get(t);if(!n)throw Error(`node not found: `+t);return n}function Tbe(e){var t=wbe,n=d,r,i=DR(30),a,o,s,c,l,u=1;e??=[];function d(e){return 1/Math.min(s[e.source.index],s[e.target.index])}function f(t){for(var n=0,i=e.length;n[t(e,n,o),e])),d;for(n=0,s=Array(i);n{OR(),AR()}));function MR(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}function Obe(e,t){for(var n=0,r=e.length,i;n{FR={value:()=>{}},NR.prototype=MR.prototype={constructor:NR,on:function(e,t){var n=this._,r=Dbe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r{kbe()}));function IR(){return JR||=(ZR(jbe),XR.now()+YR)}function jbe(){JR=0}function LR(){this._call=this._time=this._next=null}function RR(e,t,n){var r=new LR;return r.restart(e,t,n),r}function Mbe(){IR(),++VR;for(var e=GR,t;e;)(t=JR-e._time)>=0&&e._call.call(void 0,t),e=e._next;--VR}function zR(){JR=(qR=XR.now())+YR,VR=HR=0;try{Mbe()}finally{VR=0,Pbe(),JR=0}}function Nbe(){var e=XR.now(),t=e-qR;t>WR&&(YR-=t,qR=e)}function Pbe(){for(var e,t=GR,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:GR=n);KR=e,BR(r)}function BR(e){VR||(HR&&=clearTimeout(HR),e-JR>24?(e<1/0&&(HR=setTimeout(zR,e-XR.now()-YR)),UR&&=clearInterval(UR)):(UR||=(qR=XR.now(),setInterval(Nbe,WR)),VR=1,ZR(zR)))}var VR,HR,UR,WR,GR,KR,qR,JR,YR,XR,ZR,QR=o((()=>{VR=0,HR=0,UR=0,WR=1e3,qR=0,JR=0,YR=0,XR=typeof performance==`object`&&performance.now?performance:Date,ZR=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)},LR.prototype=RR.prototype={constructor:LR,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?IR():+n)+(t==null?0:+t),!this._next&&KR!==this&&(KR?KR._next=this:GR=this,KR=this),this._call=e,this._time=n,BR()},stop:function(){this._call&&(this._call=null,this._time=1/0,BR())}}}));function Fbe(e,t,n){var r=new LR,i=t;return t==null?(r.restart(e,t,n),r):(r._restart=r.restart,r.restart=function(e,t,n){t=+t,n=n==null?IR():+n,r._restart(function a(o){o+=i,r._restart(a,i+=t,n),e(o)},t,n)},r.restart(e,t,n),r)}var Ibe=o((()=>{QR()})),$R=o((()=>{QR(),Ibe()}));function Lbe(){let e=1;return()=>(e=(ez*e+tz)%nz)/nz}var ez,tz,nz,Rbe=o((()=>{ez=1664525,tz=1013904223,nz=4294967296}));function zbe(e){return e.x}function Bbe(e){return e.y}function Vbe(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=RR(d),l=MR(`tick`,`end`),u=Lbe();e??=[];function d(){f(),l.call(`tick`,t),n1?(n==null?s.delete(e):s.set(e,m(n)),t):s.get(e)},find:function(t,n,r){var i=0,a=e.length,o,s,c,l,u;for(r==null?r=1/0:r*=r,i=0;i1?(l.on(e,n),t):l.on(e)}}}var rz,iz,az=o((()=>{Abe(),$R(),Rbe(),rz=10,iz=Math.PI*(3-Math.sqrt(5))}));function Hbe(){var e,t,n,r,i=DR(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=SR(e,zbe,Bbe).visitAfter(d);for(r=n,i=0;i=s)){(e.data!==t||e.next)&&(d===0&&(d=kR(n),m+=d*d),f===0&&(f=kR(n),m+=f*f),m{ER(),OR(),AR(),az()}));function Wbe(e){var t=DR(.1),n,r,i;typeof e!=`function`&&(e=DR(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t{OR()}));function Kbe(e){var t=DR(.1),n,r,i;typeof e!=`function`&&(e=DR(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t{OR()})),Jbe=o((()=>{Wye(),Cbe(),Ebe(),Ube(),OR(),az(),Gbe(),qbe()})),Ybe=c({force:()=>oz});function oz(e){G.call(this,null,e)}function Xbe(e,t){return()=>e.touch(t).run()}function Zbe(e,t){let n=Vbe(e),r=n.stop,i=n.restart,a=!1;return n.stopped=()=>a,n.restart=()=>(a=!1,i()),n.stop=()=>(a=!0,r()),sz(n,t,!0).on(`end`,()=>a=!0)}function sz(e,t,n,r){var i=Gh(t.forces),a,o,s,c;for(a=0,o=uz.length;at(e,n):t)}var cz,lz,uz,dz,fz,txe=o((()=>{Bx(),Tg(),Jbe(),cz={center:Uye,collide:Sbe,nbody:Hbe,link:Tbe,x:Wbe,y:Kbe},lz=`forces`,uz=[`alpha`,`alphaMin`,`alphaTarget`,`velocityDecay`,`forces`],dz=[`static`,`iterations`],fz=[`x`,`y`,`vx`,`vy`],oz.Definition={type:`Force`,metadata:{modifies:!0},params:[{name:`static`,type:`boolean`,default:!1},{name:`restart`,type:`boolean`,default:!1},{name:`iterations`,type:`number`,default:300},{name:`alpha`,type:`number`,default:1},{name:`alphaMin`,type:`number`,default:.001},{name:`alphaTarget`,type:`number`,default:0},{name:`velocityDecay`,type:`number`,default:.4},{name:`forces`,type:`param`,array:!0,params:[{key:{force:`center`},params:[{name:`x`,type:`number`,default:0},{name:`y`,type:`number`,default:0}]},{key:{force:`collide`},params:[{name:`radius`,type:`number`,expr:!0},{name:`strength`,type:`number`,default:.7},{name:`iterations`,type:`number`,default:1}]},{key:{force:`nbody`},params:[{name:`strength`,type:`number`,default:-30,expr:!0},{name:`theta`,type:`number`,default:.9},{name:`distanceMin`,type:`number`,default:1},{name:`distanceMax`,type:`number`}]},{key:{force:`link`},params:[{name:`links`,type:`data`},{name:`id`,type:`field`},{name:`distance`,type:`number`,default:30,expr:!0},{name:`strength`,type:`number`,expr:!0},{name:`iterations`,type:`number`,default:1}]},{key:{force:`x`},params:[{name:`strength`,type:`number`,default:.1},{name:`x`,type:`field`}]},{key:{force:`y`},params:[{name:`strength`,type:`number`,default:.1},{name:`y`,type:`field`}]}]},{name:`as`,type:`string`,array:!0,modify:!1,default:fz}]},U(oz,G,{transform(e,t){var n=this.value,r=t.changed(t.ADD_REM),i=e.modified(uz),a=e.iterations||300;if(n?(r&&(t.modifies(`index`),n.nodes(t.source)),(i||t.changed(t.MOD))&&sz(n,e,0,t)):(this.value=n=Zbe(t.source,e),n.on(`tick`,Xbe(t.dataflow,this)),e.static||(r=!0,n.tick()),t.modifies(`index`)),i||r||e.modified(dz)||t.changed()&&e.restart){if(n.alpha(Math.max(n.alpha(),e.alpha||1)).alphaDecay(1-n.alphaMin()**(1/a)),e.static)for(n.stop();--a>=0;)n.tick();else if(n.stopped()&&n.restart(),!r)return t.StopPropagation}return this.finish(e,t)},finish(e,t){let n=t.dataflow;for(let e=this._argops,t=0,s=e.length,c;t{}));function dxe(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function fxe(){return this.eachAfter(dxe)}var pxe=o((()=>{}));function mxe(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}var hxe=o((()=>{}));function gxe(e,t){for(var n=this,r=[n],i,a,o=-1;n=r.pop();)if(e.call(t,n,++o,this),i=n.children)for(a=i.length-1;a>=0;--a)r.push(i[a]);return this}var _xe=o((()=>{}));function vxe(e,t){for(var n=this,r=[n],i=[],a,o,s,c=-1;n=r.pop();)if(i.push(n),a=n.children)for(o=0,s=a.length;o{}));function bxe(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}var xxe=o((()=>{}));function Sxe(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}var Cxe=o((()=>{}));function wxe(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}var Txe=o((()=>{}));function Exe(e){for(var t=this,n=Dxe(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}function Dxe(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}var Oxe=o((()=>{}));function kxe(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}var Axe=o((()=>{}));function jxe(){return Array.from(this)}var Mxe=o((()=>{}));function Nxe(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}var Pxe=o((()=>{}));function Fxe(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}var Ixe=o((()=>{}));function*Lxe(){var e=this,t,n=[e],r,i,a;do for(t=n.reverse(),n=[];e=t.pop();)if(yield e,r=e.children)for(i=0,a=r.length;i{}));function pz(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=Vxe)):t===void 0&&(t=Bxe);for(var n=new hz(e),r,i=[n],a,o,s,c;r=i.pop();)if((o=t(r.data))&&(c=(o=Array.from(o)).length))for(r.children=o,s=c-1;s>=0;--s)i.push(a=o[s]=new hz(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(mz)}function zxe(){return pz(this).eachBefore(Hxe)}function Bxe(e){return e.children}function Vxe(e){return Array.isArray(e)?e[1]:null}function Hxe(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function mz(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function hz(e){this.data=e,this.depth=this.height=0,this.parent=null}var gz=o((()=>{pxe(),hxe(),_xe(),yxe(),xxe(),Cxe(),Txe(),Oxe(),Axe(),Mxe(),Pxe(),Ixe(),Rxe(),hz.prototype=pz.prototype={constructor:hz,count:fxe,each:mxe,eachAfter:vxe,eachBefore:gxe,find:bxe,sum:Sxe,sort:wxe,path:Exe,ancestors:kxe,descendants:jxe,leaves:Nxe,links:Fxe,copy:zxe,[Symbol.iterator]:Lxe}}));function _z(e){return e==null?null:vz(e)}function vz(e){if(typeof e!=`function`)throw Error();return e}var yz=o((()=>{}));function bz(){return 0}function xz(e){return function(){return e}}var Sz=o((()=>{}));function Uxe(){let e=1;return()=>(e=(Cz*e+wz)%Tz)/Tz}var Cz,wz,Tz,Wxe=o((()=>{Cz=1664525,wz=1013904223,Tz=4294967296}));function Gxe(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Kxe(e,t){let n=e.length,r,i;for(;n;)i=t()*n--|0,r=e[n],e[n]=e[i],e[i]=r;return e}var Ez=o((()=>{}));function qxe(e,t){for(var n=0,r=(e=Kxe(Array.from(e),t)).length,i=[],a,o;n0&&n*n>r*r+i*i}function kz(e,t){for(var n=0;n1e-6?(D+Math.sqrt(D*D-4*E*O))/(2*E):O/D);return{x:r+S+C*k,y:i+w+T*k,r:k}}var Mz=o((()=>{Ez()}));function Nz(e,t,n){var r=e.x-t.x,i,a,o=e.y-t.y,s,c,l=r*r+o*o;l?(a=t.r+n.r,a*=a,c=e.r+n.r,c*=c,a>c?(i=(l+c-a)/(2*l),s=Math.sqrt(Math.max(0,c/l-i*i)),n.x=e.x-i*r-s*o,n.y=e.y-i*o+s*r):(i=(l+a-c)/(2*l),s=Math.sqrt(Math.max(0,a/l-i*i)),n.x=t.x+i*r-s*o,n.y=t.y+i*o+s*r)):(n.x=t.x+n.r,n.y=t.y)}function Pz(e,t){var n=e.r+t.r-1e-6,r=t.x-e.x,i=t.y-e.y;return n>0&&n*n>r*r+i*i}function Fz(e){var t=e._,n=e.next._,r=t.r+n.r,i=(t.x*n.r+n.x*t.r)/r,a=(t.y*n.r+n.y*t.r)/r;return i*i+a*a}function Iz(e){this._=e,this.next=null,this.previous=null}function Zxe(e,t){if(!(a=(e=Gxe(e)).length))return 0;var n=e[0],r,i,a,o,s,c,l,u,d,f;if(n.x=0,n.y=0,!(a>1))return n.r;if(r=e[1],n.x=-r.r,r.x=n.r,r.y=0,!(a>2))return n.r+r.r;Nz(r,n,i=e[2]),n=new Iz(n),r=new Iz(r),i=new Iz(i),n.next=i.previous=r,r.next=n.previous=i,i.next=r.previous=n;pack:for(c=3;c{Ez(),Mz()}));function Qxe(e){return Math.sqrt(e.value)}function $xe(){var e=null,t=1,n=1,r=bz;function i(i){let a=Uxe();return i.x=t/2,i.y=n/2,e?i.eachBefore(Rz(e)).eachAfter(zz(r,.5,a)).eachBefore(Bz(1)):i.eachBefore(Rz(Qxe)).eachAfter(zz(bz,1,a)).eachAfter(zz(r,i.r/Math.min(t,n),a)).eachBefore(Bz(Math.min(t,n)/(2*i.r))),i}return i.radius=function(t){return arguments.length?(e=_z(t),i):e},i.size=function(e){return arguments.length?(t=+e[0],n=+e[1],i):[t,n]},i.padding=function(e){return arguments.length?(r=typeof e==`function`?e:xz(+e),i):r},i}function Rz(e){return function(t){t.children||(t.r=Math.max(0,+e(t)||0))}}function zz(e,t,n){return function(r){if(i=r.children){var i,a,o=i.length,s=e(r)*t||0,c;if(s)for(a=0;a{yz(),Sz(),Wxe(),Lz()}));function Vz(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}var Hz=o((()=>{}));function Uz(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s{}));function tSe(){var e=1,t=1,n=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=n,i.x1=e,i.y1=t/o,i.eachBefore(a(t,o)),r&&i.eachBefore(Vz),i}function a(e,t){return function(r){r.children&&Uz(r,r.x0,e*(r.depth+1)/t,r.x1,e*(r.depth+2)/t);var i=r.x0,a=r.y0,o=r.x1-n,s=r.y1-n;o{Hz(),Wz()}));function rSe(e){return e.id}function iSe(e){return e.parentId}function Gz(){var e=rSe,t=iSe,n;function r(r){var i=Array.from(r),a=e,o=t,s,c,l,u,d,f,p,m,h=new Map;if(n!=null){let e=i.map((e,t)=>aSe(n(e,t,r))),t=e.map(Kz),s=new Set(e).add(``);for(let n of t)s.has(n)||(s.add(n),e.push(n),t.push(Kz(n)),i.push(Xz));a=(t,n)=>e[n],o=(e,n)=>t[n]}for(l=0,s=i.length;l=0&&(f=i[e],f.data===Xz);--e)f.data=null}if(u.parent=Jz,u.eachBefore(function(e){e.depth=e.parent.depth+1,--s}).eachBefore(mz),u.parent=null,s>0)throw Error(`cycle`);return u}return r.id=function(t){return arguments.length?(e=_z(t),r):e},r.parentId=function(e){return arguments.length?(t=_z(e),r):t},r.path=function(e){return arguments.length?(n=_z(e),r):n},r}function aSe(e){e=`${e}`;let t=e.length;return qz(e,t-1)&&!qz(e,t-2)&&(e=e.slice(0,-1)),e[0]===`/`?e:`/${e}`}function Kz(e){let t=e.length;if(t<2)return``;for(;--t>1&&!qz(e,t););return e.slice(0,t)}function qz(e,t){if(e[t]===`/`){let n=0;for(;t>0&&e[--t]===`\\`;)++n;if(!(n&1))return!0}return!1}var Jz,Yz,Xz,oSe=o((()=>{yz(),gz(),Jz={depth:-1},Yz={},Xz={}}));function sSe(e,t){return e.parent===t.parent?1:2}function Zz(e){var t=e.children;return t?t[0]:e.t}function Qz(e){var t=e.children;return t?t[t.length-1]:e.t}function cSe(e,t,n){var r=n/(t.i-e.i);t.c-=r,t.s+=n,e.c+=r,t.z+=n,t.m+=n}function lSe(e){for(var t=0,n=0,r=e.children,i=r.length,a;--i>=0;)a=r[i],a.z+=t,a.m+=t,t+=a.s+(n+=a.c)}function uSe(e,t,n){return e.a.parent===t.parent?e.a:n}function $z(e,t){this._=e,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=t}function dSe(e){for(var t=new $z(e,0),n,r=[t],i,a,o,s;n=r.pop();)if(a=n._.children)for(n.children=Array(s=a.length),o=s-1;o>=0;--o)r.push(i=n.children[o]=new $z(a[o],o)),i.parent=n;return(t.parent=new $z(null,0)).children=[t],t}function fSe(){var e=sSe,t=1,n=1,r=null;function i(i){var s=dSe(i);if(s.eachAfter(a),s.parent.m=-s.z,s.eachBefore(o),r)i.eachBefore(c);else{var l=i,u=i,d=i;i.eachBefore(function(e){e.xu.x&&(u=e),e.depth>d.depth&&(d=e)});var f=l===u?1:e(l,u)/2,p=f-l.x,m=t/(u.x+f+p),h=n/(d.depth||1);i.eachBefore(function(e){e.x=(e.x+p)*m,e.y=e.depth*h})}return i}function a(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n){lSe(t);var a=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+e(t._,i._));t.parent.A=s(t,i,t.parent.A||r[0])}function o(e){e._.x=e.z+e.parent.m,e.m+=e.parent.m}function s(t,n,r){if(n){for(var i=t,a=t,o=n,s=i.parent.children[0],c=i.m,l=a.m,u=o.m,d=s.m,f;o=Qz(o),i=Zz(i),o&&i;)s=Zz(s),a=Qz(a),a.a=t,f=o.z+u-i.z-c+e(o._,i._),f>0&&(cSe(uSe(o,t,r),t,f),c+=f,l+=f),u+=o.m,c+=i.m,d+=s.m,l+=a.m;o&&!Qz(a)&&(a.t=o,a.m+=u-l),i&&!Zz(s)&&(s.t=i,s.m+=c-d,r=t)}return r}function c(e){e.x*=t,e.y=e.depth*n}return i.separation=function(t){return arguments.length?(e=t,i):e},i.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],i):r?null:[t,n]},i.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],i):r?[t,n]:null},i}var pSe=o((()=>{gz(),$z.prototype=Object.create(hz.prototype)}));function eB(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(i-n)/e.value;++s{}));function nB(e,t,n,r,i,a){for(var o=[],s=t.children,c,l,u=0,d=0,f=s.length,p,m,h=t.value,g,_,v,y,b,x,S;uv&&(v=l),S=g*g*x,y=Math.max(v/S,S/_),y>b){g-=l;break}b=y}o.push(c={value:g,dice:p{Wz(),tB(),rB=(1+Math.sqrt(5))/2,iB=(function e(t){function n(e,n,r,i,a){nB(t,e,n,r,i,a)}return n.ratio=function(t){return e((t=+t)>1?t:1)},n})(rB)}));function mSe(){var e=iB,t=!1,n=1,r=1,i=[0],a=bz,o=bz,s=bz,c=bz,l=bz;function u(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(d),i=[0],t&&e.eachBefore(Vz),e}function d(t){var n=i[t.depth],r=t.x0+n,u=t.y0+n,d=t.x1-n,f=t.y1-n;d{Hz(),aB(),yz(),Sz()}));function gSe(e,t,n,r,i){var a=e.children,o,s=a.length,c,l=Array(s+1);for(l[0]=c=o=0;o=t-1){var c=a[e];c.x0=r,c.y0=i,c.x1=o,c.y1=s;return}for(var d=l[e],f=n/2+d,p=e+1,m=t-1;p>>1;l[h]s-i){var v=n?(r*_+o*g)/n:o;u(e,p,g,r,i,v,s),u(p,t,_,v,i,o,s)}else{var y=n?(i*_+s*g)/n:s;u(e,p,g,r,i,o,y),u(p,t,_,r,y,o,s)}}}var _Se=o((()=>{}));function vSe(e,t,n,r,i){(e.depth&1?eB:Uz)(e,t,n,r,i)}var ySe=o((()=>{Wz(),tB()})),oB,bSe=o((()=>{Wz(),tB(),aB(),oB=(function e(t){function n(e,n,r,i,a){if((o=e._squarify)&&o.ratio===t)for(var o,s,c,l,u=-1,d,f=o.length,p=e.value;++u1?t:1)},n})(rB)})),xSe=o((()=>{uxe(),gz(),eSe(),Lz(),Mz(),nSe(),oSe(),pSe(),hSe(),_Se(),Wz(),tB(),ySe(),aB(),bSe()})),SSe=c({nest:()=>cB,pack:()=>uB,partition:()=>dB,stratify:()=>fB,tree:()=>pB,treelinks:()=>mB,treemap:()=>hB});function sB(e,t,n){let r={};return e.each(e=>{let i=e.data;n(i)&&(r[t(i)]=e)}),e.lookup=r,e}function cB(e){G.call(this,null,e)}function CSe(){let e=[],t={entries:e=>r(n(e,0),0),key:n=>(e.push(n),t)};function n(t,r){if(r>=e.length)return t;let i=t.length,a=e[r++],o={},s={},c=-1,l,u,d;for(;++ce.length)return t;let i=[];for(let e in t)i.push({key:e,values:r(t[e],n)});return i}return t}function lB(e){G.call(this,null,e)}function wSe(e,t,n){for(let r,i=0,a=t.length;i{Bx(),Tg(),xSe(),cB.Definition={type:`Nest`,metadata:{treesource:!0,changes:!0},params:[{name:`keys`,type:`field`,array:!0},{name:`generate`,type:`boolean`}]},gB=e=>e.values,U(cB,G,{transform(e,t){t.source||V(`Nest transform requires an upstream data source.`);var n=e.generate,r=e.modified(),i=t.clone(),a=this.value;return(!a||r||t.changed())&&(a&&a.each(e=>{e.children&&Gb(e.data)&&i.rem.push(e.data)}),this.value=a=pz({values:Gh(e.keys).reduce((e,t)=>(e.key(t),e),CSe()).entries(i.source)},gB),n&&a.each(e=>{e.children&&(e=Jb(e.data),i.add.push(e),i.source.push(e))}),sB(a,Kb,Kb)),i.source.root=a,i}}),_B=(e,t)=>e.parent===t.parent?1:2,U(lB,G,{transform(e,t){(!t.source||!t.source.root)&&V(this.constructor.name+` transform requires a backing tree data source.`);let n=this.layout(e.method),r=this.fields,i=t.source.root,a=e.as||r;e.field?i.sum(e.field):i.count(),e.sort&&i.sort(Qb(e.sort,e=>e.data)),wSe(n,this.params,e),n.separation&&n.separation(e.separation===!1?uh:_B);try{this.value=n(i)}catch(e){V(e)}return i.each(e=>TSe(e,r,a)),t.reflow(e.modified()).modifies(a).modifies(`leaf`)}}),vB=[`x`,`y`,`r`,`depth`,`children`],uB.Definition={type:`Pack`,metadata:{tree:!0,modifies:!0},params:[{name:`field`,type:`field`},{name:`sort`,type:`compare`},{name:`padding`,type:`number`,default:0},{name:`radius`,type:`field`,default:null},{name:`size`,type:`number`,array:!0,length:2},{name:`as`,type:`string`,array:!0,length:vB.length,default:vB}]},U(uB,lB,{layout:$xe,params:[`radius`,`size`,`padding`],fields:vB}),yB=[`x0`,`y0`,`x1`,`y1`,`depth`,`children`],dB.Definition={type:`Partition`,metadata:{tree:!0,modifies:!0},params:[{name:`field`,type:`field`},{name:`sort`,type:`compare`},{name:`padding`,type:`number`,default:0},{name:`round`,type:`boolean`,default:!1},{name:`size`,type:`number`,array:!0,length:2},{name:`as`,type:`string`,array:!0,length:yB.length,default:yB}]},U(dB,lB,{layout:tSe,params:[`size`,`round`,`padding`],fields:yB}),fB.Definition={type:`Stratify`,metadata:{treesource:!0},params:[{name:`key`,type:`field`,required:!0},{name:`parentKey`,type:`field`,required:!0}]},U(fB,G,{transform(e,t){t.source||V(`Stratify transform requires an upstream data source.`);let n=this.value,r=e.modified(),i=t.fork(t.ALL).materialize(t.SOURCE),a=!n||r||t.changed(t.ADD_REM)||t.modified(e.key.fields)||t.modified(e.parentKey.fields);return i.source=i.source.slice(),a&&(n=i.source.length?sB(Gz().id(e.key).parentId(e.parentKey)(i.source),e.key,dh):sB(Gz()([{}]),e.key,e.key)),i.source.root=this.value=n,i}}),bB={tidy:fSe,cluster:lxe},xB=[`x`,`y`,`depth`,`children`],pB.Definition={type:`Tree`,metadata:{tree:!0,modifies:!0},params:[{name:`field`,type:`field`},{name:`sort`,type:`compare`},{name:`method`,type:`enum`,default:`tidy`,values:[`tidy`,`cluster`]},{name:`size`,type:`number`,array:!0,length:2},{name:`nodeSize`,type:`number`,array:!0,length:2},{name:`separation`,type:`boolean`,default:!0},{name:`as`,type:`string`,array:!0,length:xB.length,default:xB}]},U(pB,lB,{layout(e){let t=e||`tidy`;if(sg(bB,t))return bB[t]();V(`Unrecognized Tree layout method: `+t)},params:[`size`,`nodeSize`],fields:xB}),mB.Definition={type:`TreeLinks`,metadata:{tree:!0,generates:!0,changes:!0},params:[]},U(mB,G,{transform(e,t){let n=this.value,r=t.source&&t.source.root,i=t.fork(t.NO_SOURCE),a={};return r||V(`TreeLinks transform requires a tree data source.`),t.changed(t.ADD_REM)?(i.rem=n,t.visit(t.SOURCE,e=>a[Kb(e)]=1),r.each(e=>{let t=e.data,n=e.parent&&e.parent.data;n&&a[Kb(t)]&&a[Kb(n)]&&i.add.push(Jb({source:n,target:t}))}),this.value=i.add):t.changed(t.MOD)&&(t.visit(t.MOD,e=>a[Kb(e)]=1),n.forEach(e=>{(a[Kb(e.source)]||a[Kb(e.target)])&&i.mod.push(e)})),i}}),SB={binary:gSe,dice:Uz,slice:eB,slicedice:vSe,squarify:iB,resquarify:oB},CB=[`x0`,`y0`,`x1`,`y1`,`depth`,`children`],hB.Definition={type:`Treemap`,metadata:{tree:!0,modifies:!0},params:[{name:`field`,type:`field`},{name:`sort`,type:`compare`},{name:`method`,type:`enum`,default:`squarify`,values:[`squarify`,`resquarify`,`binary`,`dice`,`slice`,`slicedice`]},{name:`padding`,type:`number`,default:0},{name:`paddingInner`,type:`number`,default:0},{name:`paddingOuter`,type:`number`,default:0},{name:`paddingTop`,type:`number`,default:0},{name:`paddingRight`,type:`number`,default:0},{name:`paddingBottom`,type:`number`,default:0},{name:`paddingLeft`,type:`number`,default:0},{name:`ratio`,type:`number`,default:1.618033988749895},{name:`round`,type:`boolean`,default:!1},{name:`size`,type:`number`,array:!0,length:2},{name:`as`,type:`string`,array:!0,length:CB.length,default:CB}]},U(hB,lB,{layout(){let e=mSe();return e.ratio=t=>{let n=e.tile();n.ratio&&e.tile(n.ratio(t))},e.method=t=>{sg(SB,t)?e.tile(SB[t]):V(`Unrecognized Treemap layout method: `+t)},e},params:[`method`,`ratio`,`size`,`round`,`padding`,`paddingInner`,`paddingOuter`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`],fields:CB})})),DSe=c({label:()=>kB});function OSe(e,t){let n=e.bitmap();return(t||[]).forEach(t=>n.set(e(t.boundary[0]),e(t.boundary[3]))),[n,void 0]}function kSe(e,t,n,r,i){let a=e.width,o=e.height,s=r||i,c=bT(a,o).getContext(`2d`),l=bT(a,o).getContext(`2d`),u=s&&bT(a,o).getContext(`2d`);n.forEach(e=>TB(c,e,!1)),TB(l,t,!1),s&&TB(u,t,!0);let d=wB(c,a,o),f=wB(l,a,o),p=s&&wB(u,a,o),m=e.bitmap(),h=s&&e.bitmap(),g,_,v,y,b,x,S,C;for(_=0;_{t.items.forEach(t=>TB(e,t.items,n))}):wA[r].draw(e,{items:n?t.map(ASe):t})}function ASe(e){let t=Xb(e,{});return t.stroke&&t.strokeOpacity!==0||t.fill&&t.fillOpacity!==0?{...t,strokeOpacity:1,stroke:`#000`,fillOpacity:0}:t}function jSe(e,t){let n=new Uint32Array(~~((e*t+NB)/NB));function r(e,t){n[e]|=t}function i(e,t){n[e]&=t}return{array:n,get:(t,r)=>{let i=r*e+t;return n[i>>>jB]&1<<(i&MB)},set:(t,n)=>{let i=n*e+t;r(i>>>jB,1<<(i&MB))},clear:(t,n)=>{let r=n*e+t;i(r>>>jB,~(1<<(r&MB)))},getRange:(t,r,i,a)=>{let o=a,s,c,l,u;for(;o>=r;--o)if(s=o*e+t,c=o*e+i,l=s>>>jB,u=c>>>jB,l===u){if(n[l]&PB[s&MB]&FB[(c&MB)+1])return!0}else{if(n[l]&PB[s&MB]||n[u]&FB[(c&MB)+1])return!0;for(let e=l+1;e{let o,s,c,l,u;for(;n<=a;++n)if(o=n*e+t,s=n*e+i,c=o>>>jB,l=s>>>jB,c===l)r(c,PB[o&MB]&FB[(s&MB)+1]);else for(r(c,PB[o&MB]),r(l,FB[(s&MB)+1]),u=c+1;u{let o,s,c,l,u;for(;n<=a;++n)if(o=n*e+t,s=n*e+r,c=o>>>jB,l=s>>>jB,c===l)i(c,FB[o&MB]|PB[(s&MB)+1]);else for(i(c,FB[o&MB]),i(l,PB[(s&MB)+1]),u=c+1;un<0||r<0||a>=t||i>=e}}function MSe(e,t,n){let r=Math.max(1,Math.sqrt(e*t/1e6)),i=~~((e+2*n+r)/r),a=~~((t+2*n+r)/r),o=e=>~~((e+n)/r);return o.invert=e=>e*r-n,o.bitmap=()=>jSe(i,a),o.ratio=r,o.padding=n,o.width=e,o.height=t,o}function NSe(e,t,n,r){let i=e.width,a=e.height;return function(e){let t=e.datum.datum.items[r].items,n=t.length,o=e.datum.fontSize,s=SA.width(e.datum,e.datum.text),c=0,l,u,d,f,p,m,h;for(let r=0;r=c&&(c=h,e.x=p,e.y=m);return p=s/2,m=o/2,l=e.x-p,u=e.x+p,d=e.y-m,f=e.y+m,e.align=`center`,l<0&&u<=i?e.align=`left`:0<=l&&ii||t-(o=r/2)<0||t+o>a}function DB(e,t,n,r,i,a,o,s){let c=i*a/(r*2),l=e(t-c),u=e(t+c),d=e(n-(a/=2)),f=e(n+a);return o.outOfBounds(l,d,u,f)||o.getRange(l,d,u,f)||s&&s.getRange(l,d,u,f)}function PSe(e,t,n,r){let i=e.width,a=e.height,o=t[0],s=t[1];function c(t,n,r,c,l){let u=e.invert(t),d=e.invert(n),f=r,p=a,m;if(!EB(u,d,c,l,i,a)&&!DB(e,u,d,l,c,f,o,s)&&!DB(e,u,d,l,c,l,o,null)){for(;p-f>=1;)m=(f+p)/2,DB(e,u,d,l,c,m,o,s)?p=m:f=m;if(f>r)return[u,d,f,!0]}}return function(t){let s=t.datum.datum.items[r].items,l=s.length,u=t.datum.fontSize,d=SA.width(t.datum,t.datum.text),f=n?u:0,p=!1,m=!1,h=0,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M;for(let r=0;r_&&(M=g,g=_,_=M),v>y&&(M=v,v=y,y=M),w=e(g),E=e(_),T=~~((w+E)/2),D=e(v),k=e(y),O=~~((D+k)/2),S=T;S>=w;--S)for(C=O;C>=D;--C)j=c(S,C,f,d,u),j&&([t.x,t.y,f,p]=j);for(S=T;S<=E;++S)for(C=O;C<=k;++C)j=c(S,C,f,d,u),j&&([t.x,t.y,f,p]=j);!p&&!n&&(A=Math.abs(_-g+y-v),b=(g+_)/2,x=(v+y)/2,A>=h&&!EB(b,x,d,u,i,a)&&!DB(e,b,x,u,d,u,o,null)&&(h=A,t.x=b,t.y=x,m=!0))}return p||m?(b=d/2,x=u/2,o.setRange(e(t.x-b),e(t.y-x),e(t.x+b),e(t.y+x)),t.align=`center`,t.baseline=`middle`,!0):!1}}function FSe(e,t,n,r){let i=e.width,a=e.height,o=t[0],s=t[1],c=e.bitmap();return function(t){let l=t.datum.datum.items[r].items,u=l.length,d=t.datum.fontSize,f=SA.width(t.datum,t.datum.text),p=[],m=n?d:0,h=!1,g=!1,_=0,v,y,b,x,S,C,w,T,E,D,O,k;for(let r=0;r=1;)O=(E+D)/2,DB(e,S,C,d,f,O,o,s)?D=O:E=O;E>m&&(t.x=S,t.y=C,m=E,h=!0)}}!h&&!n&&(k=Math.abs(y-v+x-b),S=(v+y)/2,C=(b+x)/2,k>=_&&!EB(S,C,f,d,i,a)&&!DB(e,S,C,d,f,d,o,null)&&(_=k,t.x=S,t.y=C,g=!0))}return h||g?(S=f/2,C=d/2,o.setRange(e(t.x-S),e(t.y-C),e(t.x+S),e(t.y+C)),t.align=`center`,t.baseline=`middle`,!0):!1}}function ISe(e,t,n,r){let i=e.width,a=e.height,o=t[0],s=t[1],c=r.length;return function(t){let l=t.boundary,u=t.datum.fontSize;if(l[2]<0||l[5]<0||l[0]>i||l[3]>a)return!1;let d=t.textWidth??0,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E;for(let i=0;i>>2&3)-1,m=f===0&&p===0||r[i]<0,h=f&&p?Math.SQRT1_2:1,g=r[i]<0?-1:1,_=l[1+f]+r[i]*f*h,S=l[4+p]+g*u*p/2+r[i]*p*h,y=S-u/2,b=S+u/2,C=e(_),T=e(y),E=e(b),!d)if(OB(C,C,T,E,o,s,_,_,y,b,l,m))d=SA.width(t.datum,t.datum.text);else continue;if(x=_+g*d*f/2,_=x-d/2,v=x+d/2,C=e(_),w=e(v),OB(C,w,T,E,o,s,_,v,y,b,l,m))return t.x=f?f*g<0?v:_:x,t.y=p?p*g<0?b:y:S,t.align=RB[f*g+1],t.baseline=zB[p*g+1],o.setRange(C,T,w,E),!0}return!1}}function OB(e,t,n,r,i,a,o,s,c,l,u,d){return!(i.outOfBounds(e,n,t,r)||(d&&a||i).getRange(e,n,t,r))}function LSe(e,t,n,r,i,a,o,s,c,l,u){if(!e.length)return e;let d=Math.max(r.length,i.length),f=RSe(r,d),p=zSe(i,d),m=BSe(e[0].datum),h=m===`group`&&e[0].datum.items[c].marktype,g=h===`area`,_=VSe(m,h,s,c),v=l===null||l===1/0,y=g&&u===`naive`,b=-1,x=-1,S=e.map(e=>{let t=v?SA.width(e,e.text):void 0;return b=Math.max(b,t),x=Math.max(x,e.fontSize),{datum:e,opacity:0,x:void 0,y:void 0,align:void 0,baseline:void 0,boundary:_(e),textWidth:t}});l=l===null||l===1/0?Math.max(b,x)+Math.max(...r):l;let C=MSe(t[0],t[1],l),w;if(!y){n&&S.sort((e,t)=>n(e.datum,t.datum));let t=!1;for(let e=0;ee.datum);w=a.length||r?kSe(C,r||[],a,t,g):OSe(C,o&&S)}let T=g?VB[u](C,w,o,c):ISe(C,w,p,f);return S.forEach(e=>e.opacity=+T(e)),S}function RSe(e,t){let n=new Float64Array(t),r=e.length;for(let t=0;t[e.x,e.x,e.x,e.y,e.y,e.y];return e?e===`line`||e===`area`?e=>i(e.datum):t===`line`?e=>{let t=e.datum.items[r].items;return i(t.length?t[n===`start`?0:t.length-1]:{x:NaN,y:NaN})}:e=>{let t=e.datum.bounds;return[t.x1,(t.x1+t.x2)/2,t.x2,t.y1,(t.y1+t.y2)/2,t.y2]}:i}function kB(e){G.call(this,null,e)}var AB,jB,MB,NB,PB,FB,IB,LB,RB,zB,BB,VB,HB,UB,HSe=o((()=>{Fj(),ST(),Bx(),Tg(),AB=4278190080,jB=5,MB=31,NB=32,PB=new Uint32Array(33),FB=new Uint32Array(33),FB[0]=0,PB[0]=~FB[0];for(let e=1;e<=NB;++e)FB[e]=FB[e-1]<<1|1,PB[e]=~FB[e];IB=[-1,-1,1,1],LB=[-1,1,-1,1],RB=[`right`,`center`,`left`],zB=[`bottom`,`middle`,`top`],BB={"top-left":0,top:1,"top-right":2,left:4,middle:5,right:6,"bottom-left":8,bottom:9,"bottom-right":10},VB={naive:NSe,"reduced-search":PSe,floodfill:FSe},HB=[`x`,`y`,`opacity`,`align`,`baseline`],UB=[`top-left`,`left`,`bottom-left`,`top`,`bottom`,`top-right`,`right`,`bottom-right`],kB.Definition={type:`Label`,metadata:{modifies:!0},params:[{name:`size`,type:`number`,array:!0,length:2,required:!0},{name:`sort`,type:`compare`},{name:`anchor`,type:`string`,array:!0,default:UB},{name:`offset`,type:`number`,array:!0,default:[1]},{name:`padding`,type:`number`,default:0,null:!0},{name:`lineAnchor`,type:`string`,values:[`start`,`end`],default:`end`},{name:`markIndex`,type:`number`,default:0},{name:`avoidBaseMark`,type:`boolean`,default:!0},{name:`avoidMarks`,type:`data`,array:!0},{name:`method`,type:`string`,default:`naive`},{name:`as`,type:`string`,array:!0,length:HB.length,default:HB}]},U(kB,G,{transform(e,t){function n(n){let r=e[n];return Jh(r)&&t.modified(r.fields)}let r=e.modified();if(!(r||t.changed(t.ADD_REM)||n(`sort`)))return;(!e.size||e.size.length!==2)&&V(`Size parameter should be specified as a [width, height] array.`);let i=e.as||HB;return LSe(t.materialize(t.SOURCE).source||[],e.size,e.sort,Gh(e.offset==null?1:e.offset),Gh(e.anchor||UB),e.avoidMarks||[],e.avoidBaseMark!==!1,e.lineAnchor||`end`,e.markIndex||0,e.padding===void 0?0:e.padding,e.method||`naive`).forEach(e=>{let t=e.datum;t[i[0]]=e.x,t[i[1]]=e.y,t[i[2]]=e.opacity,t[i[3]]=e.align,t[i[4]]=e.baseline}),t.reflow(r).modifies(i)}})})),USe=c({loess:()=>GB,regression:()=>KB});function WB(e,t){var n=[],r=function(e){return e(s)},i,a,o,s,c,l;if(t==null)n.push(e);else for(i={},a=0,o=e.length;a{jS(),Bx(),Tg(),GB.Definition={type:`Loess`,metadata:{generates:!0},params:[{name:`x`,type:`field`,required:!0},{name:`y`,type:`field`,required:!0},{name:`groupby`,type:`field`,array:!0},{name:`bandwidth`,type:`number`,default:.3},{name:`as`,type:`string`,array:!0}]},U(GB,G,{transform(e,t){let n=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){let r=t.materialize(t.SOURCE).source,i=WB(r,e.groupby),a=(e.groupby||[]).map(Ym),o=a.length,s=e.as||[Ym(e.x),Ym(e.y)],c=[];i.forEach(t=>{SS(t,e.x,e.y,e.bandwidth||.3).forEach(e=>{let n={};for(let e=0;ee===`poly`?t:e===`quad`?2:1,KB.Definition={type:`Regression`,metadata:{generates:!0},params:[{name:`x`,type:`field`,required:!0},{name:`y`,type:`field`,required:!0},{name:`groupby`,type:`field`,array:!0},{name:`method`,type:`string`,default:`linear`,values:Object.keys(qB)},{name:`order`,type:`number`,default:3},{name:`extent`,type:`number`,array:!0,length:2},{name:`params`,type:`boolean`,default:!1},{name:`as`,type:`string`,array:!0}]},U(KB,G,{transform(e,t){let n=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){let r=t.materialize(t.SOURCE).source,i=WB(r,e.groupby),a=(e.groupby||[]).map(Ym),o=e.method||`linear`,s=e.order==null?3:e.order,c=JB(o,s),l=e.as||[Ym(e.x),Ym(e.y)],u=qB[o],d=[],f=e.extent;sg(qB,o)||V(`Invalid regression method: `+o),f!=null&&o===`log`&&f[0]<=0&&(t.dataflow.warn(`Ignoring extent with values <= 0 for log regression.`),f=null),i.forEach(n=>{if(n.length<=c){t.dataflow.warn(`Skipping regression with more parameters than data points.`);return}let r=u(n,e.x,e.y,s);if(e.params){d.push(Jb({keys:n.dims,coef:r.coef,rSquared:r.rSquared}));return}let i=f||og(n,e.x),p=e=>{let t={};for(let e=0;ep([e,r.predict(e)])):CS(r.predict,i,25,200).forEach(p)}),this.value&&(n.rem=this.value),this.value=n.add=n.source=d}return n}})}));function YB(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(dl==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);dl==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d{XB=11102230246251565e-32,ZB=134217729,QB=3.000000000000001*XB}));function KSe(e,t,n,r,i,a,o){let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=e-i,E=n-i,D=t-a,O=r-a;b=T*O,f=ZB*T,p=f-(f-T),m=T-p,f=ZB*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=D*E,f=ZB*D,p=f-(f-D),m=D-p,f=ZB*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,iV[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,iV[1]=y-(_+d)+(d-S),w=v+_,d=w-v,iV[2]=v-(w-d)+(_-d),iV[3]=w;let k=GSe(4,iV),A=nV*o;if(k>=A||-k>=A||(d=e-T,s=e-(T+d)+(d-i),d=n-E,l=n-(E+d)+(d-i),d=t-D,c=t-(D+d)+(d-a),d=r-O,u=r-(O+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(A=rV*o+QB*Math.abs(k),k+=T*u+O*s-(D*l+E*c),k>=A||-k>=A))return k;b=s*O,f=ZB*s,p=f-(f-s),m=s-p,f=ZB*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=c*E,f=ZB*c,p=f-(f-c),m=c-p,f=ZB*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,cV[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,cV[1]=y-(_+d)+(d-S),w=v+_,d=w-v,cV[2]=v-(w-d)+(_-d),cV[3]=w;let j=YB(4,iV,4,cV,aV);b=T*u,f=ZB*T,p=f-(f-T),m=T-p,f=ZB*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=D*l,f=ZB*D,p=f-(f-D),m=D-p,f=ZB*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,cV[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,cV[1]=y-(_+d)+(d-S),w=v+_,d=w-v,cV[2]=v-(w-d)+(_-d),cV[3]=w;let M=YB(j,aV,4,cV,oV);b=s*u,f=ZB*s,p=f-(f-s),m=s-p,f=ZB*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=ZB*c,p=f-(f-c),m=c-p,f=ZB*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,cV[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,cV[1]=y-(_+d)+(d-S),w=v+_,d=w-v,cV[2]=v-(w-d)+(_-d),cV[3]=w;let ee=YB(M,oV,4,cV,sV);return sV[ee-1]}function eV(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=tV*l?c:-KSe(e,t,n,r,i,a,l)}var tV,nV,rV,iV,aV,oV,sV,cV,qSe=o((()=>{$B(),tV=(3+16*XB)*XB,nV=(2+12*XB)*XB,rV=(9+64*XB)*XB*XB,iV=K(4),aV=K(8),oV=K(12),sV=K(16),cV=K(4)})),JSe=o((()=>{$B(),(7+56*XB)*XB,(3+28*XB)*XB,(26+288*XB)*XB*XB,K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(8),K(8),K(8),K(4),K(8),K(8),K(16),K(12),K(192),K(192)})),YSe=o((()=>{$B(),(10+96*XB)*XB,(4+48*XB)*XB,(44+576*XB)*XB*XB,K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(8),K(8),K(8),K(8),K(8),K(8),K(8),K(8),K(8),K(4),K(4),K(4),K(8),K(16),K(16),K(16),K(32),K(32),K(48),K(64),K(1152),K(1152)})),XSe=o((()=>{$B(),(16+224*XB)*XB,(5+72*XB)*XB,(71+1408*XB)*XB*XB,K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(24),K(24),K(24),K(24),K(24),K(24),K(24),K(24),K(24),K(24),K(1152),K(1152),K(1152),K(1152),K(1152),K(2304),K(2304),K(3456),K(5760),K(8),K(8),K(8),K(16),K(24),K(48),K(48),K(96),K(192),K(384),K(384),K(384),K(768),K(96),K(96),K(96),K(1152)})),ZSe=o((()=>{qSe(),JSe(),YSe(),XSe()}));function QSe(e,t){let n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function lV(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function $Se(e,t,n,r,i,a,o,s){let c=e-o,l=t-s,u=n-o,d=r-s,f=i-o,p=a-s,m=c*c+l*l,h=u*u+d*d,g=f*f+p*p;return c*(d*g-h*p)-l*(u*g-h*f)+m*(u*p-d*f)<0}function eCe(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c),p=(l*u-s*d)*f,m=(o*d-c*u)*f;return p*p+m*m}function tCe(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c);return{x:e+(l*u-s*d)*f,y:t+(o*d-c*u)*f}}function uV(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){let r=e[i],a=t[r],o=i-1;for(;o>=n&&t[e[o]]>a;)e[o+1]=e[o--];e[o+1]=r}else{let i=n+r>>1,a=n+1,o=r;dV(e,i,a),t[e[n]]>t[e[r]]&&dV(e,n,r),t[e[a]]>t[e[r]]&&dV(e,a,r),t[e[n]]>t[e[a]]&&dV(e,n,a);let s=e[a],c=t[s];for(;;){do a++;while(t[e[a]]c);if(o=o-n?(uV(e,t,a,r),uV(e,t,n,o-1)):(uV(e,t,n,o-1),uV(e,t,a,r))}}function dV(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function nCe(e){return e[0]}function rCe(e){return e[1]}var fV,pV,mV,iCe=o((()=>{ZSe(),fV=2**-52,pV=new Uint32Array(512),mV=class e{static from(t,n=nCe,r=rCe){let i=t.length,a=new Float64Array(i*2);for(let e=0;e>1;if(t>0&&typeof e[0]!=`number`)throw Error(`Expected coords to contain numbers.`);this.coords=e;let n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){let{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,a=e.length>>1,o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t=0;tc&&(c=n),r>l&&(l=r),this._ids[t]=t}let u=(o+c)/2,d=(s+l)/2,f=0,p=0,m=0;for(let t=0,n=1/0;t0&&(p=t,n=r)}let _=e[2*p],v=e[2*p+1],y=1/0;for(let t=0;tr&&(t[n++]=i,r=a)}this.hull=t.subarray(0,n),this.triangles=new Uint32Array,this.halfedges=new Int32Array;return}if(eV(h,g,_,v,b,x)<0){let e=p,t=_,n=v;p=m,_=b,v=x,m=e,b=t,x=n}let S=tCe(h,g,_,v,b,x);this._cx=S.x,this._cy=S.y;for(let t=0;t0&&Math.abs(l-o)<=fV&&Math.abs(u-s)<=fV||(o=l,s=u,c===f||c===p||c===m))continue;let d=0;for(let e=0,t=this._hashKey(l,u);e=0;)if(h=g,h===d){h=-1;break}if(h===-1)continue;let _=this._addTriangle(h,c,n[h],-1,-1,r[h]);r[c]=this._legalize(_+2),r[h]=_,C++;let v=n[h];for(;g=n[v],eV(l,u,e[2*v],e[2*v+1],e[2*g],e[2*g+1])<0;)_=this._addTriangle(v,c,g,r[c],-1,r[v]),r[c]=this._legalize(_+2),n[v]=v,C--,v=g;if(h===d)for(;g=t[h],eV(l,u,e[2*g],e[2*g+1],e[2*h],e[2*h+1])<0;)_=this._addTriangle(g,c,h,-1,r[h],r[g]),this._legalize(_+2),r[g]=_,n[h]=h,C--,h=g;this._hullStart=t[c]=h,n[h]=t[v]=c,n[c]=v,i[this._hashKey(l,u)]=c,i[this._hashKey(e[2*h],e[2*h+1])]=h}this.hull=new Uint32Array(C);for(let e=0,t=this._hullStart;e{hV=1e-6,gV=class{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=``}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;let r=e+n,i=t;if(n<0)throw Error(`negative radius`);this._x1===null?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>hV||Math.abs(this._y1-i)>hV)&&(this._+=`L`+r+`,`+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}})),vV,yV=o((()=>{vV=class{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}})),bV,xV=o((()=>{_V(),yV(),bV=class{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((i=+i)>=(n=+n)))throw Error(`invalid bounds`);this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){let{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i,a,o=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r=0,s=0,c=n.length,l,u;r1;)i-=2;for(let e=2;e0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function cCe(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}function lCe(e,t,n,r){let i=e.length,a=new Float64Array(i*2);for(let o=0;o{iCe(),_V(),yV(),xV(),SV=2*Math.PI,CV=Math.pow,wV=class e{static from(t,n=aCe,r=oCe,i){return new e(`length`in t?lCe(t,n,r,i):Float64Array.from(uCe(t,n,r,i)))}constructor(e){this._delaunator=new mV(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){let e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&sCe(e)){this.collinear=Int32Array.from({length:t.length/2},(e,t)=>t).sort((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]);let e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new bV(this,e)}*neighbors(e){let{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:a,collinear:o}=this;if(o){let t=o.indexOf(e);t>0&&(yield o[t-1]),t=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){let{inedges:r,hull:i,_hullIndex:a,halfedges:o,triangles:s,points:c}=this;if(r[e]===-1||!c.length)return(e+1)%(c.length>>1);let l=e,u=CV(t-c[e*2],2)+CV(n-c[e*2+1],2),d=r[e],f=d;do{let r=s[f],d=CV(t-c[r*2],2)+CV(n-c[r*2+1],2);if(d{dCe(),xV()})),pCe=c({voronoi:()=>TV});function TV(e){G.call(this,null,e)}function mCe(e){let t=e[0][0],n=e[0][1],r=e.length-1;for(;e[r][0]===t&&e[r][1]===n;--r);return`M`+e.slice(0,r+1).join(`L`)+`Z`}function hCe(e){return e.length===2&&e[0][0]===e[1][0]&&e[0][1]===e[1][1]}var EV,gCe=o((()=>{Bx(),Tg(),fCe(),TV.Definition={type:`Voronoi`,metadata:{modifies:!0},params:[{name:`x`,type:`field`,required:!0},{name:`y`,type:`field`,required:!0},{name:`size`,type:`number`,array:!0,length:2},{name:`extent`,type:`array`,array:!0,length:2,default:[[-1e5,-1e5],[1e5,1e5]],content:{type:`number`,array:!0,length:2}},{name:`as`,type:`string`,default:`path`}]},EV=[-1e5,-1e5,1e5,1e5],U(TV,G,{transform(e,t){let n=e.as||`path`,r=t.source;if(!r||!r.length)return t;let i=e.size;i=i?[0,0,i[0],i[1]]:(i=e.extent)?[i[0][0],i[0][1],i[1][0],i[1][1]]:EV;let a=this.value=wV.from(r,e.x,e.y).voronoi(i);for(let e=0,t=r.length;ekV});function vCe(){var e=[256,256],t,n,r,i,a,o,s,c=DV,l=[],u=Math.random,d={};d.layout=function(){for(var c=f(bT()),d=wCe((e[0]>>5)*e[1]),m=null,h=l.length,g=-1,_=[],v=l.map(e=>({text:t(e),font:n(e),style:i(e),weight:a(e),rotate:o(e),size:~~(r(e)+1e-14),padding:s(e),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:e})).sort((e,t)=>t.size-e.size);++g>1,y.y=e[1]*(u()+.5)>>1,yCe(c,y,v,g),y.hasText&&p(d,y,m)&&(_.push(y),m?xCe(m,y):m=[{x:y.x+y.x0,y:y.y+y.y0},{x:y.x+y.x1,y:y.y+y.y1}],y.x-=e[0]>>1,y.y-=e[1]>>1)}return _};function f(e){e.width=e.height=1;var t=Math.sqrt(e.getContext(`2d`).getImageData(0,0,1,1).data.length>>2);e.width=(jV<<5)/t,e.height=MV/t;var n=e.getContext(`2d`);return n.fillStyle=n.strokeStyle=`red`,n.textAlign=`center`,{context:n,ratio:t}}function p(t,n,r){for(var i=n.x,a=n.y,o=Math.hypot(e[0],e[1]),s=c(e),l=u()<.5?1:-1,d=-l,f,p,m;(f=s(d+=l))&&(p=~~f[0],m=~~f[1],!(Math.min(Math.abs(p),Math.abs(m))>=o));)if(n.x=i+p,n.y=a+m,!(n.x+n.x0<0||n.y+n.y0<0||n.x+n.x1>e[0]||n.y+n.y1>e[1])&&(!r||!bCe(n,t,e[0]))&&(!r||SCe(n,r))){for(var h=n.sprite,g=n.width>>5,_=e[0]>>5,v=n.x-(g<<4),y=v&127,b=32-y,x=n.y1-n.y0,S=(n.y+n.y0)*_+(v>>5),C,w=0;w>>y:0);S+=_}return n.sprite=null,!0}return!1}return d.words=function(e){return arguments.length?(l=e,d):l},d.size=function(t){return arguments.length?(e=[+t[0],+t[1]],d):e},d.font=function(e){return arguments.length?(n=OV(e),d):n},d.fontStyle=function(e){return arguments.length?(i=OV(e),d):i},d.fontWeight=function(e){return arguments.length?(a=OV(e),d):a},d.rotate=function(e){return arguments.length?(o=OV(e),d):o},d.text=function(e){return arguments.length?(t=OV(e),d):t},d.spiral=function(e){return arguments.length?(c=NV[e]||e,d):c},d.fontSize=function(e){return arguments.length?(r=OV(e),d):r},d.padding=function(e){return arguments.length?(s=OV(e),d):s},d.random=function(e){return arguments.length?(u=e,d):u},d}function yCe(e,t,n,r){if(!t.sprite){var i=e.context,a=e.ratio;i.clearRect(0,0,(jV<<5)/a,MV/a);var o=0,s=0,c=0,l=n.length,u,d,f,p,m;for(--r;++r>5<<5,f=~~Math.max(Math.abs(v+y),Math.abs(v-y))}else u=u+31>>5<<5;if(f>c&&(c=f),o+u>=jV<<5&&(o=0,s+=c,c=0),s+f>=MV)break;i.translate((o+(u>>1))/a,(s+(f>>1))/a),t.rotate&&i.rotate(t.rotate*AV),i.fillText(t.text,0,0),t.padding&&(i.lineWidth=2*t.padding,i.strokeText(t.text,0,0)),i.restore(),t.width=u,t.height=f,t.xoff=o,t.yoff=s,t.x1=u>>1,t.y1=f>>1,t.x0=-t.x1,t.y0=-t.y1,t.hasText=!0,o+=u}for(var x=i.getImageData(0,0,(jV<<5)/a,MV/a).data,S=[];--r>=0;)if(t=n[r],t.hasText){for(u=t.width,d=u>>5,f=t.y1-t.y0,p=0;p>5),E=x[(s+m)*(jV<<5)+(o+p)<<2]?1<<31-p%32:0;S[T]|=E,C|=E}C?w=m:(t.y0++,f--,m--,s++)}t.y1=t.y0+w,t.sprite=S.slice(0,(t.y1-t.y0)*d)}}}function bCe(e,t,n){n>>=5;for(var r=e.sprite,i=e.width>>5,a=e.x-(i<<4),o=a&127,s=32-o,c=e.y1-e.y0,l=(e.y+e.y0)*n+(a>>5),u,d=0;d>>o:0))&t[l+f])return!0;l+=n}return!1}function xCe(e,t){var n=e[0],r=e[1];t.x+t.x0r.x&&(r.x=t.x+t.x1),t.y+t.y1>r.y&&(r.y=t.y+t.y1)}function SCe(e,t){return e.x+e.x1>t[0].x&&e.x+e.x0t[0].y&&e.y+e.y0{ST(),Bx(),Tg(),xO(),jS(),AV=Math.PI/180,jV=64,MV=2048,NV={archimedean:DV,rectangular:CCe},PV=[`x`,`y`,`font`,`fontSize`,`fontStyle`,`fontWeight`,`angle`],FV=[`text`,`font`,`rotate`,`fontSize`,`fontStyle`,`fontWeight`],kV.Definition={type:`Wordcloud`,metadata:{modifies:!0},params:[{name:`size`,type:`number`,array:!0,length:2},{name:`font`,type:`string`,expr:!0,default:`sans-serif`},{name:`fontStyle`,type:`string`,expr:!0,default:`normal`},{name:`fontWeight`,type:`string`,expr:!0,default:`normal`},{name:`fontSize`,type:`number`,expr:!0,default:14},{name:`fontSizeRange`,type:`number`,array:`nullable`,default:[10,50]},{name:`rotate`,type:`number`,expr:!0,default:0},{name:`text`,type:`field`},{name:`spiral`,type:`string`,values:[`archimedean`,`rectangular`]},{name:`padding`,type:`number`,expr:!0},{name:`as`,type:`string`,array:!0,length:7,default:PV}]},U(kV,G,{transform(e,t){e.size&&!(e.size[0]&&e.size[1])&&V(`Wordcloud size dimensions must be non-zero.`);function n(n){let r=e[n];return Jh(r)&&t.modified(r.fields)}let r=e.modified();if(!(r||t.changed(t.ADD_REM)||FV.some(n)))return;let i=t.materialize(t.SOURCE).source,a=this.value,o=e.as||PV,s=e.fontSize||14,c;if(Jh(s)?c=e.fontSizeRange:s=ng(s),c){let e=s,t=WD(`sqrt`)().domain(og(i,e)).range(c);s=n=>t(e(n))}i.forEach(e=>{e[o[0]]=NaN,e[o[1]]=NaN,e[o[3]]=0});let l=a.words(i).text(e.text).size(e.size||[500,500]).padding(e.padding||1).spiral(e.spiral||`archimedean`).rotate(e.rotate||0).font(e.font||`sans-serif`).fontStyle(e.fontStyle||`normal`).fontWeight(e.fontWeight||`normal`).fontSize(s).random(wS).layout(),u=a.size(),d=u[0]>>1,f=u[1]>>1,p=l.length;for(let e=0,t,n;ezV,resolvefilter:()=>BV});function DCe(){let e=8,t=[],n=UV(0),r=IV(0,e),i=IV(0,e);return{data:()=>t,seen:()=>n=OCe(n,t.length),add(e){for(let n=0,r=t.length,i=e.length,a;nt.length,curr:()=>r,prev:()=>i,reset:e=>i[e]=r[e],all:()=>e<257?255:e<65537?65535:4294967295,set(e,t){r[e]|=t},clear(e,t){r[e]&=~t},resize(t,n){(t>r.length||n>e)&&(e=Math.max(n,e),r=IV(t,e,r),i=IV(t,e))}}}function OCe(e,t,n){return e.length>=t?e:(n||=new e.constructor(t),n.set(e),n)}function IV(e,t,n){let r=(t<257?VV:t<65537?HV:UV)(e);return n&&r.set(n),r}function LV(e,t,n){let r=1<0)for(f=0;fe,size:()=>n}}function kCe(e,t){return e.sort.call(t,(t,n)=>{let r=e[t],i=e[n];return ri)}),Xae(e,t)}function ACe(e,t,n,r,i,a,o,s,c){let l=0,u=0,d;for(d=0;l{Qg(),Bx(),Tg(),VV=e=>new Uint8Array(e),HV=e=>new Uint16Array(e),UV=e=>new Uint32Array(e),zV.Definition={type:`CrossFilter`,metadata:{},params:[{name:`fields`,type:`field`,array:!0,required:!0},{name:`query`,type:`array`,array:!0,required:!0,content:{type:`number`,array:!0,length:2}}]},U(zV,G,{transform(e,t){return this._dims?e.modified(`fields`)||e.fields.some(e=>t.modified(e.fields))?this.reinit(e,t):this.eval(e,t):this.init(e,t)},init(e,t){let n=e.fields,r=e.query,i=this._indices={},a=this._dims=[],o=r.length,s=0,c,l;for(;s{let e=i.remove(t,n);for(let t in r)r[t].reindex(e)})},update(e,t,n){let r=this._dims,i=e.query,a=t.stamp,o=r.length,s=0,c,l;for(n.filters=0,l=0;lp)for(g=p,_=Math.min(d,m);g<_;++g)v=c[g],a[v]!==n&&(s[v]=o[v],a[v]=n,r.push(v)),o[v]^=h;if(f>m)for(g=Math.max(d,m),_=f;g<_;++g)v=c[g],a[v]!==n&&(s[v]=o[v],a[v]=n,r.push(v)),o[v]^=h;else if(fu)for(p=u,m=Math.min(c,d);pd)for(p=Math.max(c,d),m=l;ps[e]&n?null:o[e];return a.filter(a.MOD,l),i&i-1?(a.filter(a.ADD,e=>{let t=s[e]&n;return!t&&t^c[e]&n?o[e]:null}),a.filter(a.REM,e=>{let t=s[e]&n;return t&&!(t^(t^c[e]&n))?o[e]:null})):(a.filter(a.ADD,l),a.filter(a.REM,e=>(s[e]&n)===i?o[e]:null)),a.filter(a.SOURCE,e=>l(e._index))}})}));function WV(e){this.type=e}function MCe(e){switch(e.type){case kH:return e.elements;case AH:case NH:return[e.left,e.right];case jH:return[e.callee].concat(e.arguments);case MH:return[e.test,e.consequent,e.alternate];case PH:return[e.object,e.property];case FH:return e.properties;case DH:return[e.key,e.value];case IH:return[e.argument];case OH:case EH:case TH:default:return[]}}function GV(e,t){if(!e)throw Error(`ASSERT: `+t)}function KV(e){return e>=48&&e<=57}function qV(e){return`0123456789abcdefABCDEF`.includes(e)}function JV(e){return`01234567`.includes(e)}function NCe(e){return e===32||e===9||e===11||e===12||e===160||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e)}function YV(e){return e===10||e===13||e===8232||e===8233}function XV(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e===92||e>=128&&yU.test(String.fromCharCode(e))}function ZV(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===92||e>=128&&bU.test(String.fromCharCode(e))}function QV(){for(;q1114111||e!==`}`)&&dH({},sU,_U),t<=65535?String.fromCharCode(t):(n=(t-65536>>10)+55296,r=(t-65536&1023)+56320,String.fromCharCode(n,r))}function eH(){var e=RH.charCodeAt(q++),t=String.fromCharCode(e);for(e===92&&(RH.charCodeAt(q)!==117&&dH({},sU,_U),++q,e=$V(`u`),(!e||e===`\\`||!XV(e.charCodeAt(0)))&&dH({},sU,_U),t=e);q>>=`)return q+=4,{type:qH,value:o,start:e,end:q};if(a=o.substr(0,3),a===`>>>`||a===`<<=`||a===`>>=`)return q+=3,{type:qH,value:a,start:e,end:q};if(i=a.substr(0,2),r===i[1]&&`+-<>&|`.includes(r)||i===`=>`)return q+=2,{type:qH,value:i,start:e,end:q};if(i===`//`&&dH({},sU,_U),`<>=!+-*%&|^/`.includes(r))return++q,{type:qH,value:r,start:e,end:q};dH({},sU,_U)}function LCe(e){let t=``;for(;q{if(parseInt(t,16)<=1114111)return`x`;dH({},pU)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,`x`));try{new RegExp(n)}catch{dH({},pU)}try{return new RegExp(e,t)}catch{return null}}function VCe(){var e=RH[q],t,n,r,i;for(GV(e===`/`,`Regular expression literal must start with a slash`),t=RH[q++],n=!1,r=!1;q=0&&dH({},pU,n),{value:n,literal:t}}function UCe(){var e,t,n,r;return BH=null,QV(),e=q,t=VCe(),n=HCe(),r=BCe(t.value,n.value),{literal:t.literal+n.literal,value:r,regex:{pattern:t.value,flags:n.value},start:e,end:q}}function WCe(e){return e.type===UH||e.type===WH||e.type===VH||e.type===GH}function rH(){if(QV(),q>=zH)return{type:HH,start:q,end:q};let e=RH.charCodeAt(q);return XV(e)?ICe():e===40||e===41||e===59?tH():e===39||e===34?zCe():e===46?KV(RH.charCodeAt(q+1))?nH():tH():KV(e)?nH():tH()}function iH(){let e=BH;return q=e.end,BH=rH(),q=e.end,e}function aH(){let e=q;BH=rH(),q=e}function GCe(e){let t=new WV(XH);return t.elements=e,t}function oH(e,t,n){let r=new WV(e===`||`||e===`&&`?nU:ZH);return r.operator=e,r.left=t,r.right=n,r}function KCe(e,t){let n=new WV(QH);return n.callee=e,n.arguments=t,n}function qCe(e,t,n){let r=new WV($H);return r.test=e,r.consequent=t,r.alternate=n,r}function sH(e){let t=new WV(eU);return t.name=e,t}function cH(e){let t=new WV(tU);return t.value=e.value,t.raw=RH.slice(e.start,e.end),e.regex&&(t.raw===`//`&&(t.raw=`/(?:)/`),t.regex=e.regex),t}function lH(e,t,n){let r=new WV(rU);return r.computed=e===`[`,r.object=t,r.property=n,r.computed||(n.member=!0),r}function JCe(e){let t=new WV(iU);return t.properties=e,t}function uH(e,t,n){let r=new WV(aU);return r.key=t,r.value=n,r.kind=e,r}function YCe(e,t){let n=new WV(oU);return n.operator=e,n.argument=t,n.prefix=!0,n}function dH(e,t){var n,r=Array.prototype.slice.call(arguments,2),i=t.replace(/%(\d)/g,(e,t)=>(GV(t`:case`<=`:case`>=`:case`instanceof`:case`in`:t=7;break;case`<<`:case`>>`:case`>>>`:t=8;break;case`+`:case`-`:t=9;break;case`*`:case`/`:case`%`:t=11;break}return t}function owe(){var e=BH,t,n,r,i,a,o,s,c=vH(),l;if(r=BH,i=yH(r),i===0)return c;for(r.prec=i,iH(),t=[e,BH],o=vH(),a=[c,r,o];(i=yH(BH))>0;){for(;a.length>2&&i<=a[a.length-2].prec;)o=a.pop(),s=a.pop().value,c=a.pop(),t.pop(),n=oH(s,c,o),a.push(n);r=iH(),r.prec=i,a.push(r),t.push(BH),n=vH(),a.push(n)}for(l=a.length-1,n=a[l],t.pop();l>1;)t.pop(),n=oH(a[l-1].value,a[l-2],n),l-=2;return n}function bH(){var e=owe(),t,n;return mH(`?`)&&(iH(),t=bH(),pH(`:`),n=bH(),e=qCe(e,t,n)),e}function xH(){let e=bH();if(mH(`,`))throw Error(vU);return e}function SH(e){RH=e,q=0,zH=RH.length,BH=null,aH();let t=xH();if(BH.type!==HH)throw Error(`Unexpect token after expression.`);return t}function CH(e){function t(t,n,r,i){let a=e(n[0]);return r&&(a=r+`(`+a+`)`,r.lastIndexOf(`new `,0)===0&&(a=`(`+a+`)`)),a+`.`+t+(i<0?``:i===0?`()`:`(`+n.slice(1).map(e).join(`,`)+`)`)}function n(e,n,r){return i=>t(e,i,n,r)}let r=`new Date`,i=`String`,a=`RegExp`;return{isNaN:`Number.isNaN`,isFinite:`Number.isFinite`,abs:`Math.abs`,acos:`Math.acos`,asin:`Math.asin`,atan:`Math.atan`,atan2:`Math.atan2`,ceil:`Math.ceil`,cos:`Math.cos`,exp:`Math.exp`,floor:`Math.floor`,hypot:`Math.hypot`,log:`Math.log`,max:`Math.max`,min:`Math.min`,pow:`Math.pow`,random:`Math.random`,round:`Math.round`,sin:`Math.sin`,sqrt:`Math.sqrt`,tan:`Math.tan`,clamp:function(t){t.length<3&&V(`Missing arguments to clamp function.`),t.length>3&&V(`Too many arguments to clamp function.`);let n=t.map(e);return`Math.max(`+n[1]+`, Math.min(`+n[2]+`,`+n[0]+`))`},now:`Date.now`,utc:`Date.UTC`,datetime:r,date:n(`getDate`,r,0),day:n(`getDay`,r,0),year:n(`getFullYear`,r,0),month:n(`getMonth`,r,0),hours:n(`getHours`,r,0),minutes:n(`getMinutes`,r,0),seconds:n(`getSeconds`,r,0),milliseconds:n(`getMilliseconds`,r,0),time:n(`getTime`,r,0),timezoneoffset:n(`getTimezoneOffset`,r,0),utcdate:n(`getUTCDate`,r,0),utcday:n(`getUTCDay`,r,0),utcyear:n(`getUTCFullYear`,r,0),utcmonth:n(`getUTCMonth`,r,0),utchours:n(`getUTCHours`,r,0),utcminutes:n(`getUTCMinutes`,r,0),utcseconds:n(`getUTCSeconds`,r,0),utcmilliseconds:n(`getUTCMilliseconds`,r,0),length:n(`length`,null,-1),parseFloat:`parseFloat`,parseInt:`parseInt`,upper:n(`toUpperCase`,i,0),lower:n(`toLowerCase`,i,0),substring:n(`substring`,i),split:n(`split`,i),trim:n(`trim`,i,0),btoa:`btoa`,atob:`atob`,encodeURIComponent:`encodeURIComponent`,regexp:a,test:n(`test`,a),if:function(t){t.length<3&&V(`Missing arguments to if function.`),t.length>3&&V(`Too many arguments to if function.`);let n=t.map(e);return`(`+n[0]+`?`+n[1]+`:`+n[2]+`)`}}}function swe(e){let t=e&&e.length-1;return t&&(e[0]===`"`&&e[t]===`"`||e[0]===`'`&&e[t]===`'`)?e.slice(1,-1):e}function wH(e){e||={};let t=e.allowed?Cg(e.allowed):{},n=e.forbidden?Cg(e.forbidden):{},r=e.constants||CU,i=(e.functions||CH)(d),a=e.globalvar,o=e.fieldvar,s=Jh(a)?a:e=>`${a}["${e}"]`,c={},l={},u=0;function d(e){if(gg(e))return e;let t=f[e.type];return t??V(`Unsupported type: `+e.type),t(e)}let f={Literal:e=>e.raw,Identifier:e=>{let i=e.name;return u>0?i:sg(n,i)?V(`Illegal identifier: `+i):sg(r,i)?r[i]:sg(t,i)?i:(c[i]=1,s(i))},MemberExpression:e=>{let t=!e.computed,n=d(e.object);t&&(u+=1);let r=d(e.property);return n===o&&(l[swe(r)]=1),t&&--u,n+(t?`.`+r:`[`+r+`]`)},CallExpression:e=>{e.callee.type!==`Identifier`&&V(`Illegal callee type: `+e.callee.type);let t=e.callee.name,n=e.arguments,r=sg(i,t)&&i[t];return r||V(`Unrecognized function: `+t),Jh(r)?r(n):r+`(`+n.map(d).join(`,`)+`)`},ArrayExpression:e=>`[`+e.elements.map(d).join(`,`)+`]`,BinaryExpression:e=>`(`+d(e.left)+` `+e.operator+` `+d(e.right)+`)`,UnaryExpression:e=>`(`+e.operator+d(e.argument)+`)`,ConditionalExpression:e=>`(`+d(e.test)+`?`+d(e.consequent)+`:`+d(e.alternate)+`)`,LogicalExpression:e=>`(`+d(e.left)+e.operator+d(e.right)+`)`,ObjectExpression:e=>{for(let t of e.properties){let e=t.key.name;ph.has(e)&&V(`Illegal property: `+e)}return`{`+e.properties.map(d).join(`,`)+`}`},Property:e=>{u+=1;let t=d(e.key);return--u,t+`:`+d(e.value)}};function p(e){let t={code:d(e),globals:Object.keys(c),fields:Object.keys(l)};return c={},l={},t}return p.functions=i,p.constants=r,p}var TH,EH,DH,OH,kH,AH,jH,MH,NH,PH,FH,IH,LH,RH,q,zH,BH,VH,HH,UH,WH,GH,KH,qH,JH,YH,XH,ZH,QH,$H,eU,tU,nU,rU,iU,aU,oU,sU,cU,lU,uU,dU,fU,pU,mU,hU,gU,_U,vU,yU,bU,xU,SU,CU,wU=o((()=>{Tg(),TH=`RawCode`,EH=`Literal`,DH=`Property`,OH=`Identifier`,kH=`ArrayExpression`,AH=`BinaryExpression`,jH=`CallExpression`,MH=`ConditionalExpression`,NH=`LogicalExpression`,PH=`MemberExpression`,FH=`ObjectExpression`,IH=`UnaryExpression`,WV.prototype.visit=function(e){let t,n,r;if(e(this))return 1;for(t=MCe(this),n=0,r=t.length;n`,LH[UH]=`Identifier`,LH[WH]=`Keyword`,LH[GH]=`Null`,LH[KH]=`Numeric`,LH[qH]=`Punctuator`,LH[JH]=`String`,LH[YH]=`RegularExpression`,XH=`ArrayExpression`,ZH=`BinaryExpression`,QH=`CallExpression`,$H=`ConditionalExpression`,eU=`Identifier`,tU=`Literal`,nU=`LogicalExpression`,rU=`MemberExpression`,iU=`ObjectExpression`,aU=`Property`,oU=`UnaryExpression`,sU=`Unexpected token %0`,cU=`Unexpected number`,lU=`Unexpected string`,uU=`Unexpected identifier`,dU=`Unexpected reserved word`,fU=`Unexpected end of input`,pU=`Invalid regular expression`,mU=`Invalid regular expression: missing /`,hU=`Octal literals are not allowed in strict mode.`,gU=`Duplicate data property in object literal not allowed in strict mode`,_U=`ILLEGAL`,vU=`Disabled.`,yU=RegExp(`[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]`),bU=RegExp(`[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]`),xU={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1},SU={if:1},CU={NaN:`NaN`,E:`Math.E`,LN2:`Math.LN2`,LN10:`Math.LN10`,LOG2E:`Math.LOG2E`,LOG10E:`Math.LOG10E`,PI:`Math.PI`,SQRT1_2:`Math.SQRT1_2`,SQRT2:`Math.SQRT2`,MIN_VALUE:`Number.MIN_VALUE`,MAX_VALUE:`Number.MAX_VALUE`}}));function TU(e){return(!e.getter||!e.getter[OU])&&(e.getter=ah(e.field),e.getter[OU]=!0),e.getter}function EU(e,t){for(var n=t.fields,r=t.values,i=n.length,a=0,o,s;a=r[a])return!1}else if(s.type===UU){if(o>r[a])return!1}else if(s.type===WU){if(o<=r[a])return!1}else if(s.type===GU){if(oig(t.fields?{values:t.fields.map(t=>TU(t)(e.datum))}:{[FU]:IU(e.datum)},t))}function dwe(e,t,n,r){for(var i=this.context.data[e],a=i?i.values.value:[],o={},s={},c={},l,u,d,f,p,m,h,g,_,v,y=a.length,b=0,x,S;b(e[u[n].field]=t,e),{})))}else p=FU,m=IU(l),h=o[p]||(o[p]={}),g=h[f]||(h[f]=[]),g.push(m),n&&(g=s[f]||(s[f]=[]),g.push({[FU]:m}));if(t||=AU,o[FU]?o[FU]=QU[`${FU}_${t}`](...Object.values(o[FU])):Object.keys(o).forEach(e=>{o[e]=Object.keys(o[e]).map(t=>o[e][t]).reduce((n,r)=>n===void 0?r:QU[`${c[e]}_${t}`](n,r))}),a=Object.keys(s),n&&a.length){let e=r?MU:jU;o[e]=t===AU?{[NU]:a.reduce((e,t)=>(e.push(...s[t]),e),[])}:{[PU]:a.map(e=>({[NU]:s[e]}))}}return o}function DU(e,t,n,r){t[0].type!==`Literal`&&V(`First argument to selection functions must be a string literal.`);let i=t[0].value,a=t.length>=2&&xh(t).value,o=`@unit`,s=$U+i;a===kU&&!sg(r,o)&&(r[o]=n.getData(i).indataRef(n,`unit`)),sg(r,s)||(r[s]=n.getData(i).tuplesRef())}var OU,kU,AU,jU,MU,NU,PU,FU,IU,LU,RU,zU,BU,VU,HU,UU,WU,GU,KU,qU,JU,YU,XU,ZU,QU,$U,fwe=o((()=>{Qg(),Tg(),wU(),OU=Symbol(`vega_selection_getter`),kU=`intersect`,AU=`union`,jU=`vlMulti`,MU=`vlPoint`,NU=`or`,PU=`and`,FU=`_vgsid_`,IU=ah(FU),LU=`E`,RU=`R`,zU=`R-E`,BU=`R-LE`,VU=`R-RE`,HU=`E-LT`,UU=`E-LTE`,WU=`E-GT`,GU=`E-GTE`,KU=`E-VALID`,qU=`E-ONE`,JU=`index:unit`,YU=Pg(IU),XU=YU.left,ZU=YU.right,QU={[`${FU}_union`]:woe,[`${FU}_intersect`]:xoe,E_union:function(e,t){if(!e.length)return t;for(var n=0,r=t.length;nt.includes(e)):t},R_union:function(e,t){var n=Ch(t[0]),r=Ch(t[1]);return n>r&&(n=t[1],r=t[0]),e.length?(e[0]>n&&(e[0]=n),e[1]r&&(n=t[1],r=t[0]),e.length?rr&&(e[1]=r),e):[n,r]}},$U=`:`}));function eW(e){let t=this.context.data[e];return t?t.values.value:[]}function pwe(e,t,n){let r=this.context.data[e][`index:`+t],i=r?r.value.get(n):void 0;return i&&i.count}function mwe(e,t){let n=this.context.dataflow,r=this.context.data[e].input;return n.pulse(r,n.changeset().remove(dh).insert(t)),1}function hwe(e,t,n){if(e){let n=this.context.dataflow,r=e.mark.source;n.pulse(r,n.changeset().encode(e,t))}return n===void 0?e:n}function tW(e,t,n){return!Number.isInteger(e)||!Number.isInteger(t)?``:(TW.setYear(2e3),TW.setMonth(e),TW.setDate(t),xW.call(this,TW,n))}function gwe(e){return tW.call(this,e,1,`%B`)}function _we(e){return tW.call(this,e,1,`%b`)}function vwe(e){return tW.call(this,0,2+e,`%A`)}function ywe(e){return tW.call(this,0,2+e,`%a`)}function nW(e,t,n,r){t[0].type!==`Literal`&&V(`First argument to data functions must be a string literal.`);let i=t[0].value,a=`:`+i;if(!sg(a,r))try{r[a]=n.getData(i).tuplesRef()}catch{}}function bwe(e,t,n,r){t[0].type!==`Literal`&&V(`First argument to indata must be a string literal.`),t[1].type!==`Literal`&&V(`Second argument to indata must be a string literal.`);let i=t[0].value,a=t[1].value,o=`@`+a;sg(o,r)||(r[o]=n.getData(i).indataRef(n,a))}function rW(e,t,n,r){if(t[0].type===`Literal`)iW(n,r,t[0].value);else for(e in n.scales)iW(n,r,e)}function iW(e,t,n){let r=`%`+n;if(!sg(t,r))try{t[r]=e.scaleRef(n)}catch{}}function aW(e,t){if(gg(e)){let n=t.scales[e];return n&&Kfe(n.value)?n.value:void 0}else if(Jh(e))return Kfe(e)?e:void 0}function xwe(e,t,n){t.__bandwidth=e=>e&&e.bandwidth?e.bandwidth():0,n._bandwidth=rW,n._range=rW,n._scale=rW;let r=t=>`_[`+(t.type===`Literal`?W(`%`+t.value):W(`%`)+`+`+e(t))+`]`;return{_bandwidth:e=>`this.__bandwidth(${r(e[0])})`,_range:e=>`${r(e[0])}.range()`,_scale:t=>`${r(t[0])}(${e(t[1])})`}}function oW(e,t){return function(n,r,i){if(n){let t=aW(n,(i||this).context);return t&&t.path[e](r)}else return t(r)}}function Swe(e,t){let n=aW(e,(t||this).context);return n&&n.scale()}function Cwe(e){let t=this.context.group,n=!1;if(t)for(;e;){if(e===t){n=!0;break}e=e.mark.group}return n}function sW(e,t,n){try{e[t].apply(e,[`EXPRESSION`].concat([].slice.call(n)))}catch(t){e.warn(t)}return n[n.length-1]}function wwe(){return sW(this.context.dataflow,`warn`,arguments)}function Twe(){return sW(this.context.dataflow,`info`,arguments)}function Ewe(){return sW(this.context.dataflow,`debug`,arguments)}function cW(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function lW(e){let t=RT(e),n=cW(t.r),r=cW(t.g),i=cW(t.b);return .2126*n+.7152*r+.0722*i}function Dwe(e,t){let n=lW(e),r=lW(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function Owe(){let e=[].slice.call(arguments);return e.unshift({}),ig(...e)}function uW(e,t){return e===t||e!==e&&t!==t?!0:H(e)?H(t)&&e.length===t.length?kwe(e,t):!1:gh(e)&&gh(t)?dW(e,t):!1}function kwe(e,t){for(let n=0,r=e.length;ndW(e,t)}function Awe(e,t,n,r,i,a){let o=this.context.dataflow,s=this.context.data[e],c=s.input,l=o.stamp(),u=s.changes,d,f;if(o._trigger===!1||!(c.value.length||t||r))return 0;if((!u||u.stamp{s.modified=!0,o.pulse(c,u).run()},!0,1)),n&&(d=n===!0?dh:H(n)||Gb(n)?n:fW(n),u.remove(d)),t&&u.insert(t),r&&(d=fW(r),c.value.some(d)?u.remove(d):u.insert(r)),i){if(Jh(i))throw Error(`modify parameter must be a data tuple, not a function`);for(f in a)u.modify(i,f,a[f])}return 1}function jwe(e){let t=e.touches,n=t[0].clientX-t[1].clientX,r=t[0].clientY-t[1].clientY;return Math.hypot(n,r)}function Mwe(e){let t=e.touches;return Math.atan2(t[0].clientY-t[1].clientY,t[0].clientX-t[1].clientX)}function Nwe(e,t){let n=kW[t]||(kW[t]=ah(t));return H(e)?e.map(n):n(e)}function pW(e){return H(e)||ArrayBuffer.isView(e)?e:null}function mW(e){return pW(e)||(gg(e)?e:null)}function Pwe(e,...t){return pW(e).join(...t)}function Fwe(e,...t){return mW(e).indexOf(...t)}function Iwe(e,...t){return mW(e).lastIndexOf(...t)}function Lwe(e,...t){return mW(e).slice(...t)}function Rwe(e,t,n){return Jh(n)&&V(`Function argument passed to replace.`),!gg(t)&&!hg(t)&&V(`Please pass a string or RegExp argument to replace.`),String(e).replace(t,n)}function zwe(e){return pW(e).slice().reverse()}function Bwe(e){return pW(e).slice().sort(Qh)}function Vwe(e,t,n){return HD(e||0,t||0,n||0)}function Hwe(e,t){let n=aW(e,(t||this).context);return n&&n.bandwidth?n.bandwidth():0}function Uwe(e,t){let n=aW(e,(t||this).context);return n?n.copy():void 0}function Wwe(e,t){let n=aW(e,(t||this).context);return n?n.domain():[]}function Gwe(e,t,n){let r=aW(e,(n||this).context);return r?H(t)?(r.invertRange||r.invert)(t):(r.invert||r.invertExtent)(t):void 0}function Kwe(e,t){let n=aW(e,(t||this).context);return n&&n.range?n.range():[]}function qwe(e,t,n){let r=aW(e,(n||this).context);return r?r(t):void 0}function Jwe(e,t,n,r,i){e=aW(e,(i||this).context);let a=Fpe(t,n),o=e.domain(),s=o[0],c=xh(o),l=ch;return c-s?l=epe(e,s,c):e=(e.interpolator?WD(`sequential`)().interpolator(e.interpolator()):WD(`linear`)().interpolate(e.interpolate()).range(e.range())).domain([s=0,c=1]),e.ticks&&(o=e.ticks(+r||15),s!==o[0]&&o.unshift(s),c!==xh(o)&&o.push(c)),o.forEach(t=>a.stop(l(t),e(t))),a}function Ywe(e,t,n){let r=aW(e,(n||this).context);return function(e){return r?r.path.context(e)(t):``}}function Xwe(e){let t=null;return function(n){return n?EO(n,t||=TO(e)):e}}function hW(e,t){let n=eW.call(t,e);return n.root&&n.root.lookup||{}}function Zwe(e,t,n){let r=hW(e,this),i=r[t],a=r[n];return i&&a?i.path(a).map(AW):void 0}function Qwe(e,t){let n=hW(e,this)[t];return n?n.ancestors().map(AW):void 0}function $we(){let e=jW();return e?e.screen:{}}function eTe(){let e=jW();return e?[e.innerWidth,e.innerHeight]:[void 0,void 0]}function tTe(){let e=this.context.dataflow,t=e.container&&e.container();return t?[t.clientWidth,t.clientHeight]:[void 0,void 0]}function gW(e,t,n){if(!e)return[];let[r,i]=e,a=new NO().set(r[0],r[1],i[0],i[1]);return Bhe(n||this.context.dataflow.scenegraph().root,a,nTe(t))}function nTe(e){let t=null;if(e){let n=Gh(e.marktype),r=Gh(e.markname);t=e=>(!n.length||n.some(t=>e.marktype===t))&&(!r.length||r.some(t=>e.name===t))}return t}function rTe(e,t,n,r=5){e=Gh(e);let i=e[e.length-1];return i===void 0||Math.hypot(i[0]-t,i[1]-n)>r?[...e,[t,n]]:e}function iTe(e){return Gh(e).reduce((t,[n,r],i)=>t+=i==0?`M ${n},${r} `:i===e.length-1?` Z`:`L ${n},${r} `,``)}function aTe(e,t,n){let{x:r,y:i,mark:a}=n,o=new NO().set(2**53-1,2**53-1,-(2**53-1),-(2**53-1));for(let[e,n]of t)eo.x2&&(o.x2=e),no.y2&&(o.y2=n);return o.translate(r,i),gW([[o.x1,o.y1],[o.x2,o.y2]],e,a).filter(e=>oTe(e.x,e.y,t))}function oTe(e,t,n){let r=0;for(let i=0,a=n.length-1;it!=s>t&&e<(o-c)*(t-l)/(s-l)+c&&r++}return r&1}function sTe(e){let t=CH(e);NW.forEach(e=>t[e]=PW+e);for(let e in MW)t[e]=FW+e;return ig(t,xwe(e,MW,IW)),t}function _W(e,t,n){return arguments.length===1?MW[e]:(MW[e]=t,n&&(IW[e]=n),RW&&(RW.functions[e]=FW+e),this)}function vW(e,t){let n={},r;try{e=gg(e)?e:W(e)+``,r=SH(e)}catch{V(`Expression parse error: `+e)}r.visit(e=>{if(e.type!==`CallExpression`)return;let r=e.callee.name,i=LW.visitors[r];i&&i(r,e.arguments,t,n)});let i=RW(r);return i.globals.forEach(e=>{let r=`$`+e;!sg(n,r)&&t.getSignal(e)&&(n[r]=t.signalRef(e))}),{$expr:ig({code:i.code},t.options.ast?{ast:r}:null),$fields:i.fields,$params:n}}var yW,bW,xW,SW,CW,wW,TW,EW,DW,OW,kW,AW,jW,MW,NW,PW,FW,IW,LW,RW,zW=o((()=>{Tg(),wU(),xO(),jL(),UE(),Bx(),Fj(),fwe(),jS(),wy(),Qg(),yW=e=>function(t,n){let r=this.context.dataflow.locale();return t===null?`null`:r[e](n)(t)},bW=yW(`format`),xW=yW(`timeFormat`),SW=yW(`utcFormat`),CW=yW(`timeParse`),wW=yW(`utcParse`),TW=new Date(2e3,0,1),EW=oW(`area`,U_e),DW=oW(`bounds`,q_e),OW=oW(`centroid`,eve),kW={},AW=e=>e.data,jW=()=>typeof window<`u`&&window||null,MW={random(){return wS()},cumulativeNormal:Xx,cumulativeLogNormal:nS,cumulativeUniform:cS,densityNormal:Yx,densityLogNormal:tS,densityUniform:sS,quantileNormal:Zx,quantileLogNormal:rS,quantileUniform:lS,sampleNormal:Jx,sampleLogNormal:eS,sampleUniform:oS,isArray:H,isBoolean:fg,isDate:pg,isDefined(e){return e!==void 0},isNumber:mg,isObject:gh,isRegExp:hg,isString:gg,isTuple:Gb,isValid(e){return e!=null&&e===e},toBoolean:bg,toDate(e){return xg(e)},toNumber:Ch,toString:Sg,indexof:Fwe,join:Pwe,lastindexof:Iwe,replace:Rwe,reverse:zwe,sort:Bwe,slice:Lwe,flush:Aie,lerp:Hie,merge:Owe,pad:Zie,peek:xh,pluck:Nwe,span:yg,inrange:dg,truncate:oae,rgb:RT,lab:gE,hcl:SE,hsl:qT,luminance:lW,contrast:Dwe,sequence:Zg,format:bW,utcFormat:SW,utcParse:wW,utcOffset:Nv,utcSequence:Iv,timeFormat:xW,timeParse:CW,timeOffset:Mv,timeSequence:Fv,timeUnitSpecifier:pv,monthFormat:gwe,monthAbbrevFormat:_we,dayFormat:vwe,dayAbbrevFormat:ywe,quarter:Uh,utcquarter:Wh,week:gv,utcweek:xv,dayofyear:hv,utcdayofyear:bv,warn:wwe,info:Twe,debug:Ewe,extent(e){return og(e)},inScope:Cwe,intersect:gW,clampRange:qh,pinchDistance:jwe,pinchAngle:Mwe,screen:$we,containerSize:tTe,windowSize:eTe,bandspace:Vwe,setdata:mwe,pathShape:Xwe,panLinear:Dh,panLog:Oh,panPow:kh,panSymlog:Ah,zoomLinear:Mh,zoomLog:Nh,zoomPow:Ph,zoomSymlog:Fh,encode:hwe,modify:Awe,lassoAppend:rTe,lassoPath:iTe,intersectLasso:aTe},NW=[`view`,`item`,`group`,`xy`,`x`,`y`],PW=`event.vega.`,FW=`this.`,IW={},LW={forbidden:[`_`],allowed:[`datum`,`event`,`item`],fieldvar:`datum`,globalvar:e=>`_[${W(`$`+e)}]`,functions:sTe,constants:CU,visitors:IW},RW=wH(LW),_W(`bandwidth`,Hwe,rW),_W(`copy`,Uwe,rW),_W(`domain`,Wwe,rW),_W(`range`,Kwe,rW),_W(`invert`,Gwe,rW),_W(`scale`,qwe,rW),_W(`gradient`,Jwe,rW),_W(`geoArea`,EW,rW),_W(`geoBounds`,DW,rW),_W(`geoCentroid`,OW,rW),_W(`geoShape`,Ywe,rW),_W(`geoScale`,Swe,rW),_W(`indata`,pwe,bwe),_W(`data`,eW,nW),_W(`treePath`,Zwe,nW),_W(`treeAncestors`,Qwe,nW),_W(`vlSelectionTest`,cwe,DU),_W(`vlSelectionIdTest`,lwe,DU),_W(`vlSelectionResolve`,dwe,DU),_W(`vlSelectionTuples`,uwe)}));function cTe(e){let t=this,n=e.operators||[];return e.background&&(t.background=e.background),e.eventConfig&&(t.eventConfig=e.eventConfig),e.locale&&(t.locale=e.locale),n.forEach(e=>t.parseOperator(e)),n.forEach(e=>t.parseOperatorParameters(e)),(e.streams||[]).forEach(e=>t.parseStream(e)),(e.updates||[]).forEach(e=>t.parseUpdate(e)),t.resolve()}function lTe(e,t){let n=``;return KW[t]?n:(e.x2&&(e.x?(qW[t]&&(n+=`if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;`),n+=`o.width=o.x2-o.x;`):n+=`o.x=o.x2-(o.width||0);`),e.xc&&(n+=`o.x=o.xc-(o.width||0)/2;`),e.y2&&(e.y?(qW[t]&&(n+=`if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;`),n+=`o.height=o.y2-o.y;`):n+=`o.y=o.y2-(o.height||0);`),e.yc&&(n+=`o.y=o.yc-(o.height||0)/2;`),n)}function BW(e){return(e+``).toLowerCase()}function uTe(e){return BW(e)===`operator`}function dTe(e){return BW(e)===`collect`}function VW(e,t,n){n.endsWith(`;`)||(n=`return(`+n+`);`);let r=Function(...t.concat(n));return e&&e.functions?r.bind(e.functions):r}function fTe(e,t,n,r){return`((u = ${e}) < (v = ${t}) || u == null) && v != null ? ${n} +`)}function l(t){return t.map(u).join(e)}function u(e){return e==null?``:e instanceof Date?Tae(e):t.test(e+=``)?`"`+e.replace(/"/g,`""`)+`"`:e}return{parse:r,parseRows:i,format:o,formatBody:s,formatRows:c,formatRow:l,formatValue:u}}var Mg,Ng,Pg,Fg,Ig,Dae=o((()=>{Mg={},Ng={},Pg=34,Fg=10,Ig=13})),Oae=o((()=>{Dae()}));function kae(e){return e}var Aae=o((()=>{}));function jae(e){if(e==null)return kae;var t,n,r=e.scale[0],i=e.scale[1],a=e.translate[0],o=e.translate[1];return function(e,s){s||(t=n=0);var c=2,l=e.length,u=Array(l);for(u[0]=(t+=e[0])*r+a,u[1]=(n+=e[1])*i+o;c{Aae()}));function Nae(e,t){for(var n,r=e.length,i=r-t;i<--r;)n=e[i],e[i++]=e[r],e[r]=n}var Pae=o((()=>{}));function Fae(e,t){return typeof t==`string`&&(t=e.objects[t]),t.type===`GeometryCollection`?{type:`FeatureCollection`,features:t.geometries.map(function(t){return Iae(e,t)})}:Iae(e,t)}function Iae(e,t){var n=t.id,r=t.bbox,i=t.properties==null?{}:t.properties,a=Lae(e,t);return n==null&&r==null?{type:`Feature`,properties:i,geometry:a}:r==null?{type:`Feature`,id:n,properties:i,geometry:a}:{type:`Feature`,id:n,bbox:r,properties:i,geometry:a}}function Lae(e,t){var n=jae(e.transform),r=e.arcs;function i(e,t){t.length&&t.pop();for(var i=r[e<0?~e:e],a=0,o=i.length;a{Pae(),Mae()}));function zae(e,t){var n={},r={},i={},a=[],o=-1;t.forEach(function(n,r){var i=e.arcs[n<0?~n:n],a;i.length<3&&!i[1][0]&&!i[1][1]&&(a=t[++o],t[o]=n,t[r]=a)}),t.forEach(function(e){var t=s(e),n=t[0],a=t[1],o,c;if(o=i[n])if(delete i[o.end],o.push(e),o.end=a,c=r[a]){delete r[c.start];var l=c===o?o:o.concat(c);r[l.start=o.start]=i[l.end=c.end]=l}else r[o.start]=i[o.end]=o;else if(o=r[a])if(delete r[o.start],o.unshift(e),o.start=n,c=i[n]){delete i[c.end];var u=c===o?o:c.concat(o);r[u.start=c.start]=i[u.end=o.end]=u}else r[o.start]=i[o.end]=o;else o=[e],r[o.start=n]=i[o.end=a]=o});function s(t){var n=e.arcs[t<0?~t:t],r=n[0],i;return e.transform?(i=[0,0],n.forEach(function(e){i[0]+=e[0],i[1]+=e[1]})):i=n[n.length-1],t<0?[i,r]:[r,i]}function c(e,t){for(var r in e){var i=e[r];delete t[i.start],delete i.start,delete i.end,i.forEach(function(e){n[e<0?~e:e]=1}),a.push(i)}}return c(i,r),c(r,i),t.forEach(function(e){n[e<0?~e:e]||a.push([e])}),a}var Bae=o((()=>{}));function Vae(e){return Lae(e,Hae.apply(this,arguments))}function Hae(e,t,n){var r,i,a;if(arguments.length>1)r=Uae(e,t,n);else for(i=0,r=Array(a=e.arcs.length);i{Rae(),Bae()})),Gae=o((()=>{Mae(),Rae(),Wae(),Bae(),Aae()}));function Lg(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}var Rg=o((()=>{}));function Kae(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}var qae=o((()=>{}));function zg(e){let t,n,r;e.length===2?(t=e===Lg||e===Kae?e:Jae,n=e,r=e):(t=Lg,n=(t,n)=>Lg(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i>>1;n(e[t],r)<0?i=t+1:a=t}while(i>>1;n(e[t],r)<=0?i=t+1:a=t}while(in&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function Jae(){return 0}var Yae=o((()=>{Rg(),qae()}));function Xae(e){return e===null?NaN:+e}function*Zae(e,t){if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)(r=t(r,++n,e))!=null&&(r=+r)>=r&&(yield r)}}var Qae=o((()=>{})),Bg,Vg,Hg,$ae=o((()=>{Rg(),Yae(),Qae(),Bg=zg(Lg),Vg=Bg.right,Hg=Bg.left,zg(Xae).center}));function eoe(e,t){let n=0,r,i=0,a=0;if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(r=t-i,i+=r/++n,a+=r*(t-i));else{let o=-1;for(let s of e)(s=t(s,++o,e))!=null&&(s=+s)>=s&&(r=s-i,i+=r/++n,a+=r*(s-i))}if(n>1)return a/(n-1)}var toe=o((()=>{}));function noe(e,t){let n=eoe(e,t);return n&&Math.sqrt(n)}var roe=o((()=>{toe()})),Ug,ioe=o((()=>{Ug=class{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){let t=this._partials,n=0;for(let r=0;r0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,i=r-(a-n),!i););t>0&&(i<0&&e[t-1]<0||i>0&&e[t-1]>0)&&(r=i*2,n=a+r,r==n-a&&(a=n))}return a}}}));function Wg({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function aoe({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function ooe({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function soe(e){return typeof e==`object`&&e?e.valueOf():e}var Gg,Kg,qg=o((()=>{Gg=class extends Map{constructor(e,t=soe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(Wg(this,e))}has(e){return super.has(Wg(this,e))}set(e,t){return super.set(aoe(this,e),t)}delete(e){return super.delete(ooe(this,e))}},Kg=class extends Set{constructor(e,t=soe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let t of e)this.add(t)}has(e){return super.has(Wg(this,e))}add(e){return super.add(aoe(this,e))}delete(e){return super.delete(ooe(this,e))}}}));function coe(e,t){return Array.from(t,t=>e[t])}var loe=o((()=>{}));function uoe(e=Lg){if(e===Lg)return doe;if(typeof e!=`function`)throw TypeError(`compare is not a function`);return(t,n)=>{let r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function doe(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et))}var foe=o((()=>{Rg()}));function Jg(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=poe?10:a>=moe?5:a>=hoe?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/lt&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*lt&&--c),c0))return[];if(e===t)return[e];let r=t=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e{poe=Math.sqrt(50),moe=Math.sqrt(10),hoe=Math.sqrt(2)}));function Qg(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n=i)&&(n=i)}return n}var _oe=o((()=>{}));function $g(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n>t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}var voe=o((()=>{}));function yoe(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?doe:uoe(i);r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1),u=Math.max(n,Math.floor(t-o*c/a+l)),d=Math.min(r,Math.floor(t+(a-o)*c/a+l));yoe(e,t,u,d,i)}let a=e[t],o=n,s=r;for(e_(e,n,t),i(e[r],a)>0&&e_(e,n,r);o0;)--s}i(e[n],a)===0?e_(e,n,s):(++s,e_(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}return e}function e_(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}var boe=o((()=>{foe()}));function t_(e,t,n){if(e=Float64Array.from(Zae(e,n)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return $g(e);if(t>=1)return Qg(e);var r,i=(r-1)*t,a=Math.floor(i),o=Qg(yoe(e,a).subarray(0,a+1));return o+($g(e.subarray(a+1))-o)*(i-a)}}function xoe(e,t,n=Xae){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}var Soe=o((()=>{_oe(),voe(),boe(),Qae()}));function Coe(e,t){let n=0,r=0;if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(++n,r+=t);else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(a=+a)>=a&&(++n,r+=a)}if(n)return r/n}var woe=o((()=>{}));function Toe(e,t){return t_(e,.5,t)}var Eoe=o((()=>{Soe()}));function*Doe(e){for(let t of e)yield*t}function Ooe(e){return Array.from(Doe(e))}var koe=o((()=>{}));function n_(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r{}));function joe(e,t){let n=0;if(t===void 0)for(let t of e)(t=+t)&&(n+=t);else{let r=-1;for(let i of e)(i=+t(i,++r,e))&&(n+=i)}return n}var Moe=o((()=>{}));function Noe(e,...t){e=new Kg(e),t=t.map(Poe);out:for(let n of e)for(let r of t)if(!r.has(n)){e.delete(n);continue out}return e}function Poe(e){return e instanceof Kg?e:new Kg(e)}var Foe=o((()=>{qg()}));function Ioe(...e){let t=new Kg;for(let n of e)for(let e of n)t.add(e);return t}var Loe=o((()=>{qg()})),r_=o((()=>{$ae(),Rg(),Yae(),qae(),roe(),ioe(),qg(),foe(),goe(),Soe(),_oe(),woe(),Eoe(),koe(),voe(),loe(),boe(),Aoe(),Moe(),toe(),Foe(),Loe()}));function Roe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function i_(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}var a_=o((()=>{}));function o_(e){return e=i_(Math.abs(e)),e?e[1]:NaN}var s_=o((()=>{a_()}));function zoe(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}var Boe=o((()=>{}));function Voe(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var Hoe=o((()=>{}));function c_(e){if(!(t=Uoe.exec(e)))throw Error(`invalid format: `+e);var t;return new l_({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function l_(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}var Uoe,Woe=o((()=>{Uoe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i,c_.prototype=l_.prototype,l_.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type}}));function Goe(e){out:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var Koe=o((()=>{}));function qoe(e,t){var n=i_(e,t);if(!n)return u_=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(u_=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+i_(e,Math.max(0,t+a-1))[0]}var u_,Joe=o((()=>{a_()}));function Yoe(e,t){var n=i_(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var Xoe=o((()=>{a_()})),d_,Zoe=o((()=>{a_(),Joe(),Xoe(),d_={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:Roe,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Yoe(e*100,t),r:Yoe,s:qoe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)}}));function Qoe(e){return e}var $oe=o((()=>{}));function ese(e){var t=e.grouping===void 0||e.thousands===void 0?Qoe:zoe(f_.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?Qoe:Voe(f_.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=c_(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):d_[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=d_[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=Goe(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&u_!==void 0?p_[8+u_/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++op||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(o_(t)/3)))*3,r=10**-n,i=l((e=c_(e),e.type=`f`,e),{suffix:p_[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var f_,p_,tse=o((()=>{s_(),Boe(),Hoe(),Woe(),Koe(),Zoe(),Joe(),$oe(),f_=Array.prototype.map,p_=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`]}));function nse(e){return m_=ese(e),h_=m_.format,g_=m_.formatPrefix,m_}var m_,h_,g_,rse=o((()=>{tse(),nse({thousands:`,`,grouping:[3],currency:[`$`,``]})}));function ise(e){return Math.max(0,-o_(Math.abs(e)))}var ase=o((()=>{s_()}));function ose(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(o_(t)/3)))*3-o_(Math.abs(e)))}var sse=o((()=>{s_()}));function cse(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,o_(t)-o_(e))+1}var lse=o((()=>{s_()})),__=o((()=>{rse(),tse(),Woe(),ase(),sse(),lse()}));function v_(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(sv_(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}),n&&(i.count=(t,r)=>(y_.setTime(+t),b_.setTime(+r),e(y_),e(b_),Math.floor(n(y_,b_))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var y_,b_,x_=o((()=>{y_=new Date,b_=new Date})),S_,use=o((()=>{x_(),S_=v_(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e),S_.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?v_(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):S_),S_.range})),C_,w_,T_,E_,D_,O_,k_,A_=o((()=>{C_=1e3,w_=C_*60,T_=w_*60,E_=T_*24,D_=E_*7,O_=E_*30,k_=E_*365})),j_,M_=o((()=>{x_(),A_(),j_=v_(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*C_)},(e,t)=>(t-e)/C_,e=>e.getUTCSeconds()),j_.range})),N_,P_,F_=o((()=>{x_(),A_(),N_=v_(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*C_)},(e,t)=>{e.setTime(+e+t*w_)},(e,t)=>(t-e)/w_,e=>e.getMinutes()),N_.range,P_=v_(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*w_)},(e,t)=>(t-e)/w_,e=>e.getUTCMinutes()),P_.range})),I_,L_,R_=o((()=>{x_(),A_(),I_=v_(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*C_-e.getMinutes()*w_)},(e,t)=>{e.setTime(+e+t*T_)},(e,t)=>(t-e)/T_,e=>e.getHours()),I_.range,L_=v_(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*T_)},(e,t)=>(t-e)/T_,e=>e.getUTCHours()),L_.range})),z_,B_,V_,H_=o((()=>{x_(),A_(),z_=v_(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*w_)/E_,e=>e.getDate()-1),z_.range,B_=v_(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/E_,e=>e.getUTCDate()-1),B_.range,V_=v_(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/E_,e=>Math.floor(e/E_)),V_.range}));function U_(e){return v_(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*w_)/D_)}function W_(e){return v_(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/D_)}var G_,K_,q_,J_,Y_,X_,Z_,Q_,$_,ev,tv,nv,rv,iv,av=o((()=>{x_(),A_(),G_=U_(0),K_=U_(1),q_=U_(2),J_=U_(3),Y_=U_(4),X_=U_(5),Z_=U_(6),G_.range,K_.range,q_.range,J_.range,Y_.range,X_.range,Z_.range,Q_=W_(0),$_=W_(1),ev=W_(2),tv=W_(3),nv=W_(4),rv=W_(5),iv=W_(6),Q_.range,$_.range,ev.range,tv.range,nv.range,rv.range,iv.range})),ov,sv,cv=o((()=>{x_(),ov=v_(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth()),ov.range,sv=v_(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth()),sv.range})),lv,uv,dv=o((()=>{x_(),lv=v_(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear()),lv.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:v_(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),lv.range,uv=v_(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear()),uv.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:v_(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),uv.range}));function fv(e,t,n,r,i,a){let o=[[j_,1,C_],[j_,5,5*C_],[j_,15,15*C_],[j_,30,30*C_],[a,1,w_],[a,5,5*w_],[a,15,15*w_],[a,30,30*w_],[i,1,T_],[i,3,3*T_],[i,6,6*T_],[i,12,12*T_],[r,1,E_],[r,2,2*E_],[n,1,D_],[t,1,O_],[t,3,3*O_],[e,1,k_]];function s(e,t,n){let r=te).right(o,i);if(a===o.length)return e.every(Zg(t/k_,n/k_,r));if(a===0)return S_.every(Math.max(Zg(t,n,r),1));let[s,c]=o[i/o[a-1][2]{r_(),A_(),use(),M_(),F_(),R_(),H_(),av(),cv(),dv(),[pv,mv]=fv(uv,sv,Q_,V_,L_,P_),[hv,gv]=fv(lv,ov,G_,z_,I_,N_)})),_v=o((()=>{x_(),use(),M_(),F_(),R_(),H_(),av(),cv(),dv(),dse()}));function vv(e){let t=ng(e).slice(),n={};return t.length||V(`Missing time unit.`),t.forEach(e=>{fg(ny,e)?n[e]=1:V(`Invalid time unit: ${e}.`)}),(n.week||n.day?1:0)+(n.quarter||n.month||n.date?1:0)+ +!!n.dayofyear>1&&V(`Incompatible time units: ${e}`),t.sort((e,t)=>ny[e]-ny[t]),t}function yv(e,t){let n=ug({},ry,t),r=vv(e),i=r.length,a=``,o=0,s,c;for(o=0;oo;--s)if(c=r.slice(o,s).join(`-`),n[c]!=null){a+=n[c],o=s;break}return a.trim()}function bv(e){return iy.setFullYear(e),iy.setMonth(0),iy.setDate(1),iy.setHours(0,0,0,0),iy}function xv(e){return Cv(new Date(e))}function Sv(e){return wv(new Date(e))}function Cv(e){return z_.count(bv(e.getFullYear())-1,e)}function wv(e){return G_.count(bv(e.getFullYear())-1,e)}function Tv(e){return bv(e).getDay()}function fse(e,t,n,r,i,a,o){if(0<=e&&e<100){let s=new Date(-1,t,n,r,i,a,o);return s.setFullYear(e),s}return new Date(e,t,n,r,i,a,o)}function Ev(e){return Ov(new Date(e))}function Dv(e){return kv(new Date(e))}function Ov(e){let t=Date.UTC(e.getUTCFullYear(),0,1);return B_.count(t-1,e)}function kv(e){let t=Date.UTC(e.getUTCFullYear(),0,1);return Q_.count(t-1,e)}function Av(e){return iy.setTime(Date.UTC(e,0,1)),iy.getUTCDay()}function pse(e,t,n,r,i,a,o){if(0<=e&&e<100){let e=new Date(Date.UTC(-1,t,n,r,i,a,o));return e.setUTCFullYear(n.y),e}return new Date(Date.UTC(e,t,n,r,i,a,o))}function jv(e,t,n,r,i){let a=t||1,o=Mh(e),s=(e,t,i)=>(i||=e,mse(n[i],r[i],e===o&&a,t)),c=new Date,l=Og(e),u=l.year?s(Gv):cg(2012),d=l.month?s(qv):l.quarter?s(Kv):bh,f=l.week&&l.day?s(`day`,1,`weekday`):l.week?s(Jv,1):l.day?s(`day`,1):l.date?s(Yv,1):l.dayofyear?s(Xv,1):xh,p=l.hours?s(Zv):bh,m=l.minutes?s(Qv):bh,h=l.seconds?s($v):bh,g=l.milliseconds?s(ey):bh;return function(e){c.setTime(+e);let t=u(c);return i(t,d(c),f(c,t),p(c),m(c),h(c),g(c))}}function mse(e,t,n,r){let i=n<=1?e:r?(t,i)=>r+n*Math.floor((e(t,i)-r)/n):(t,r)=>n*Math.floor(e(t,r)/n);return t?(e,n)=>t(i(e,n),n):i}function Mv(e,t,n){return t+e*7-(n+6)%7}function Nv(e,t){return jv(e,t||1,ay,oy,fse)}function Pv(e,t){return jv(e,t||1,sy,cy,pse)}function Fv(e){return ly[e]}function Iv(e){return uy[e]}function Lv(e,t,n){return e?e.offset(t,n):void 0}function Rv(e,t,n){return Lv(Fv(e),t,n)}function zv(e,t,n){return Lv(Iv(e),t,n)}function Bv(e,t,n,r){return e?e.range(t,n,r):void 0}function Vv(e,t,n,r){return Bv(Fv(e),t,n,r)}function Hv(e,t,n,r){return Bv(Iv(e),t,n,r)}function Uv(e){let t=e.extent,n=e.maxbins||40,r=Math.abs(wg(t))/n,i=zg(e=>e[2]).right(Ey,r),a,o;return i===Ey.length?(a=Ty,o=Zg(t[0]/_y,t[1]/_y,n)):i?(i=Ey[r/Ey[i-1][2]{let n=t(e),r=new Date(n);return Number.isNaN(+r)&&V(`Invalid date: ${n}`),r}),a=ky.findIndex(e=>!e.aligned(i,r)),o=ky.findIndex(e=>!e.skippable&&!e.aligned(i,r)),s=o>a+1?o:a,{units:c,step:l}=ky[s-1];return{units:c,step:l}}var Gv,Kv,qv,Jv,Yv,Xv,Zv,Qv,$v,ey,ty,ny,ry,iy,ay,oy,sy,cy,ly,uy,dy,fy,py,my,hy,gy,_y,vy,yy,by,xy,Sy,Cy,wy,Ty,Ey,Dy,Oy,ky,Ay=o((()=>{Ag(),_v(),r_(),Gv=`year`,Kv=`quarter`,qv=`month`,Jv=`week`,Yv=`date`,Xv=`dayofyear`,Zv=`hours`,Qv=`minutes`,$v=`seconds`,ey=`milliseconds`,ty=[Gv,Kv,qv,Jv,Yv,`day`,Xv,Zv,Qv,$v,ey],ny=ty.reduce((e,t,n)=>(e[t]=1+n,e),{}),ry={[Gv]:`%Y `,[Kv]:`Q%q `,[qv]:`%b `,[Yv]:`%d `,[Jv]:`W%U `,day:`%a `,[Xv]:`%j `,[Zv]:`%H:00`,[Qv]:`00:%M`,[$v]:`:%S`,[ey]:`.%L`,[`${Gv}-${qv}`]:`%Y-%m `,[`${Gv}-${qv}-${Yv}`]:`%Y-%m-%d `,[`${Zv}-${Qv}`]:`%H:%M`},iy=new Date,ay={[Gv]:e=>e.getFullYear(),[Kv]:e=>Math.floor(e.getMonth()/3),[qv]:e=>e.getMonth(),[Yv]:e=>e.getDate(),[Zv]:e=>e.getHours(),[Qv]:e=>e.getMinutes(),[$v]:e=>e.getSeconds(),[ey]:e=>e.getMilliseconds(),[Xv]:e=>Cv(e),[Jv]:e=>wv(e),weekday:(e,t)=>Mv(wv(e),e.getDay(),Tv(t)),day:(e,t)=>Mv(1,e.getDay(),Tv(t))},oy={[Kv]:e=>3*e,[Jv]:(e,t)=>Mv(e,0,Tv(t))},sy={[Gv]:e=>e.getUTCFullYear(),[Kv]:e=>Math.floor(e.getUTCMonth()/3),[qv]:e=>e.getUTCMonth(),[Yv]:e=>e.getUTCDate(),[Zv]:e=>e.getUTCHours(),[Qv]:e=>e.getUTCMinutes(),[$v]:e=>e.getUTCSeconds(),[ey]:e=>e.getUTCMilliseconds(),[Xv]:e=>Ov(e),[Jv]:e=>kv(e),day:(e,t)=>Mv(1,e.getUTCDay(),Av(t)),weekday:(e,t)=>Mv(kv(e),e.getUTCDay(),Av(t))},cy={[Kv]:e=>3*e,[Jv]:(e,t)=>Mv(e,0,Av(t))},ly={[Gv]:lv,[Kv]:ov.every(3),[qv]:ov,[Jv]:G_,[Yv]:z_,day:z_,[Xv]:z_,[Zv]:I_,[Qv]:N_,[$v]:j_,[ey]:S_},uy={[Gv]:uv,[Kv]:sv.every(3),[qv]:sv,[Jv]:Q_,[Yv]:B_,day:B_,[Xv]:B_,[Zv]:L_,[Qv]:P_,[$v]:j_,[ey]:S_},dy=1e3,fy=dy*60,py=fy*60,my=py*24,hy=my*7,gy=my*30,_y=my*365,vy=[Gv,qv,Yv,Zv,Qv,$v,ey],yy=vy.slice(0,-1),by=yy.slice(0,-1),xy=by.slice(0,-1),Sy=xy.slice(0,-1),Cy=[Gv,Jv],wy=[Gv,qv],Ty=[Gv],Ey=[[yy,1,dy],[yy,5,5*dy],[yy,15,15*dy],[yy,30,30*dy],[by,1,fy],[by,5,5*fy],[by,15,15*fy],[by,30,30*fy],[xy,1,py],[xy,3,3*py],[xy,6,6*py],[xy,12,12*py],[Sy,1,my],[Cy,1,hy],[wy,1,gy],[wy,3,3*gy],[Ty,1,_y]],Dy={[Gv]:e=>e.getFullYear(),[qv]:e=>e.getMonth(),[Yv]:e=>e.getDate(),day:e=>e.getDay(),[Zv]:e=>e.getHours(),[Qv]:e=>e.getMinutes(),[$v]:e=>e.getSeconds(),[ey]:e=>e.getMilliseconds()},Oy={[Gv]:e=>e.getUTCFullYear(),[qv]:e=>e.getUTCMonth(),[Yv]:e=>e.getUTCDate(),day:e=>e.getUTCDay(),[Zv]:e=>e.getUTCHours(),[Qv]:e=>e.getUTCMinutes(),[$v]:e=>e.getUTCSeconds(),[ey]:e=>e.getUTCMilliseconds()},ky=[{units:[Gv,qv,Yv,Zv,Qv,$v,ey],step:1,aligned:()=>!0},{units:[Gv,qv,Yv,Zv,Qv,$v],step:1,aligned:(e,t)=>e.every(e=>t[ey](e)===0)},{units:[Gv,qv,Yv,Zv,Qv],step:1,aligned:(e,t)=>e.every(e=>t[$v](e)===0)},{units:[Gv,qv,Yv,Zv,Qv],step:5,aligned:(e,t)=>e.every(e=>t[Qv](e)%5==0)},{units:[Gv,qv,Yv,Zv,Qv],step:10,aligned:(e,t)=>e.every(e=>t[Qv](e)%10==0)},{units:[Gv,qv,Yv,Zv],step:1,aligned:(e,t)=>e.every(e=>t[Qv](e)===0)},{units:[Gv,qv,Yv],step:1,aligned:(e,t)=>e.every(e=>t[Zv](e)===0)},{units:[Gv,Jv],step:1,skippable:!0,aligned:(e,t)=>new Set(e.map(e=>t.day(e))).size===1},{units:[Gv,qv],step:1,aligned:(e,t)=>e.every(e=>t[Yv](e)===1)},{units:[Gv,qv],step:3,aligned:(e,t)=>e.every(e=>t[qv](e)%3==0)},{units:[Gv],step:1,aligned:(e,t)=>e.every(e=>t[qv](e)===0)},{units:[Gv],step:10,aligned:(e,t)=>e.every(e=>t[Gv](e)%10==0)},{aligned:()=>!1}]}));function jy(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function My(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Ny(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function Py(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,o=e.shortDays,s=e.months,c=e.shortMonths,l=Iy(i),u=Ly(i),d=Iy(a),f=Ly(a),p=Iy(o),m=Ly(o),h=Iy(s),g=Ly(s),_=Iy(c),v=Ly(c),y={a:ee,A:N,b:te,B:ne,c:null,d:Hy,e:Hy,f:Fse,g:Gse,G:qse,H:Mse,I:Nse,j:Pse,L:Uy,m:Ise,M:Lse,p:P,q:re,Q:Yy,s:Xy,S:Rse,u:zse,U:Bse,V:Vse,w:Hse,W:Use,x:null,X:null,y:Wse,Y:Kse,Z:Jse,"%":Jy},b={a:F,A:ie,b:ae,B:oe,c:null,d:Gy,e:Gy,f:Qse,g:cce,G:uce,H:Yse,I:Xse,j:Zse,L:Ky,m:$se,M:ece,p:se,q:ce,Q:Yy,s:Xy,S:tce,u:nce,U:rce,V:ice,w:ace,W:oce,x:null,X:null,y:sce,Y:lce,Z:dce,"%":Jy},x={a:E,A:D,b:O,B:k,c:A,d:By,e:By,f:Ose,g:zy,G:Ry,H:Vy,I:Vy,j:wse,L:Dse,m:Cse,M:Tse,p:T,q:Sse,Q:Ase,s:jse,S:Ese,u:_se,U:vse,V:yse,w:gse,W:bse,x:j,X:M,y:zy,Y:Ry,Z:xse,"%":kse};y.x=S(n,y),y.X=S(r,y),y.c=S(t,y),b.x=S(n,b),b.X=S(r,b),b.c=S(t,b);function S(e,t){return function(n){var r=[],i=-1,a=0,o=e.length,s,c,l;for(n instanceof Date||(n=new Date(+n));++i53)return null;`w`in r||(r.w=1),`Z`in r?(a=My(Ny(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?$_.ceil(a):$_(a),a=B_.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=jy(Ny(r.y,0,1)),o=a.getDay(),a=o>4||o===0?K_.ceil(a):K_(a),a=z_.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else(`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?My(Ny(r.y,0,1)).getUTCDay():jy(Ny(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,My(r)):jy(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in Zy?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function A(e,n,r){return w(e,t,n,r)}function j(e,t,r){return w(e,n,t,r)}function M(e,t,n){return w(e,r,t,n)}function ee(e){return o[e.getDay()]}function N(e){return a[e.getDay()]}function te(e){return c[e.getMonth()]}function ne(e){return s[e.getMonth()]}function P(e){return i[+(e.getHours()>=12)]}function re(e){return 1+~~(e.getMonth()/3)}function F(e){return o[e.getUTCDay()]}function ie(e){return a[e.getUTCDay()]}function ae(e){return c[e.getUTCMonth()]}function oe(e){return s[e.getUTCMonth()]}function se(e){return i[+(e.getUTCHours()>=12)]}function ce(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}function Fy(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a[e.toLowerCase(),t]))}function gse(e,t,n){var r=Qy.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function _se(e,t,n){var r=Qy.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function vse(e,t,n){var r=Qy.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function yse(e,t,n){var r=Qy.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function bse(e,t,n){var r=Qy.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function Ry(e,t,n){var r=Qy.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function zy(e,t,n){var r=Qy.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function xse(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function Sse(e,t,n){var r=Qy.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function Cse(e,t,n){var r=Qy.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function By(e,t,n){var r=Qy.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function wse(e,t,n){var r=Qy.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function Vy(e,t,n){var r=Qy.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function Tse(e,t,n){var r=Qy.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function Ese(e,t,n){var r=Qy.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function Dse(e,t,n){var r=Qy.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function Ose(e,t,n){var r=Qy.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function kse(e,t,n){var r=$y.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Ase(e,t,n){var r=Qy.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function jse(e,t,n){var r=Qy.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function Hy(e,t){return Fy(e.getDate(),t,2)}function Mse(e,t){return Fy(e.getHours(),t,2)}function Nse(e,t){return Fy(e.getHours()%12||12,t,2)}function Pse(e,t){return Fy(1+z_.count(lv(e),e),t,3)}function Uy(e,t){return Fy(e.getMilliseconds(),t,3)}function Fse(e,t){return Uy(e,t)+`000`}function Ise(e,t){return Fy(e.getMonth()+1,t,2)}function Lse(e,t){return Fy(e.getMinutes(),t,2)}function Rse(e,t){return Fy(e.getSeconds(),t,2)}function zse(e){var t=e.getDay();return t===0?7:t}function Bse(e,t){return Fy(G_.count(lv(e)-1,e),t,2)}function Wy(e){var t=e.getDay();return t>=4||t===0?Y_(e):Y_.ceil(e)}function Vse(e,t){return e=Wy(e),Fy(Y_.count(lv(e),e)+(lv(e).getDay()===4),t,2)}function Hse(e){return e.getDay()}function Use(e,t){return Fy(K_.count(lv(e)-1,e),t,2)}function Wse(e,t){return Fy(e.getFullYear()%100,t,2)}function Gse(e,t){return e=Wy(e),Fy(e.getFullYear()%100,t,2)}function Kse(e,t){return Fy(e.getFullYear()%1e4,t,4)}function qse(e,t){var n=e.getDay();return e=n>=4||n===0?Y_(e):Y_.ceil(e),Fy(e.getFullYear()%1e4,t,4)}function Jse(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+Fy(t/60|0,`0`,2)+Fy(t%60,`0`,2)}function Gy(e,t){return Fy(e.getUTCDate(),t,2)}function Yse(e,t){return Fy(e.getUTCHours(),t,2)}function Xse(e,t){return Fy(e.getUTCHours()%12||12,t,2)}function Zse(e,t){return Fy(1+B_.count(uv(e),e),t,3)}function Ky(e,t){return Fy(e.getUTCMilliseconds(),t,3)}function Qse(e,t){return Ky(e,t)+`000`}function $se(e,t){return Fy(e.getUTCMonth()+1,t,2)}function ece(e,t){return Fy(e.getUTCMinutes(),t,2)}function tce(e,t){return Fy(e.getUTCSeconds(),t,2)}function nce(e){var t=e.getUTCDay();return t===0?7:t}function rce(e,t){return Fy(Q_.count(uv(e)-1,e),t,2)}function qy(e){var t=e.getUTCDay();return t>=4||t===0?nv(e):nv.ceil(e)}function ice(e,t){return e=qy(e),Fy(nv.count(uv(e),e)+(uv(e).getUTCDay()===4),t,2)}function ace(e){return e.getUTCDay()}function oce(e,t){return Fy($_.count(uv(e)-1,e),t,2)}function sce(e,t){return Fy(e.getUTCFullYear()%100,t,2)}function cce(e,t){return e=qy(e),Fy(e.getUTCFullYear()%100,t,2)}function lce(e,t){return Fy(e.getUTCFullYear()%1e4,t,4)}function uce(e,t){var n=e.getUTCDay();return e=n>=4||n===0?nv(e):nv.ceil(e),Fy(e.getUTCFullYear()%1e4,t,4)}function dce(){return`+0000`}function Jy(){return`%`}function Yy(e){return+e}function Xy(e){return Math.floor(e/1e3)}var Zy,Qy,$y,eb,tb=o((()=>{_v(),Zy={"-":``,_:` `,0:`0`},Qy=/^\s*\d+/,$y=/^%/,eb=/[\\^$*+?|[\]().{}]/g}));function fce(e){return nb=Py(e),rb=nb.format,ib=nb.parse,ab=nb.utcFormat,ob=nb.utcParse,nb}var nb,rb,ib,ab,ob,pce=o((()=>{tb(),fce({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]})})),sb=o((()=>{pce(),tb()}));function cb(e){let t={};return n=>t[n]||(t[n]=e(n))}function mce(e,t){return n=>{let r=e(n),i=r.indexOf(t);if(i<0)return r;let a=hce(r,i),o=ai;)if(r[a]!==`0`){++a;break}return r.slice(0,a)+o}}function hce(e,t){let n=e.lastIndexOf(`e`),r;if(n>0)return n;for(n=e.length;--n>t;)if(r=e.charCodeAt(n),r>=48&&r<=57)return n+1}function lb(e){let t=cb(e.format),n=e.formatPrefix;return{format:t,formatPrefix:n,formatFloat(e){let n=c_(e||`,`);if(n.precision==null){switch(n.precision=12,n.type){case`%`:n.precision-=2;break;case`e`:--n.precision;break}return mce(t(n),t(`.1f`)(1)[1])}else return t(n)},formatSpan(e,r,i,a){a=c_(a??`,f`);let o=Zg(e,r,i),s=Math.max(Math.abs(e),Math.abs(r)),c;if(a.precision==null)switch(a.type){case`s`:return isNaN(c=ose(o,s))||(a.precision=c),n(a,s);case``:case`e`:case`g`:case`p`:case`r`:isNaN(c=cse(o,s))||(a.precision=c-(a.type===`e`));break;case`f`:case`%`:isNaN(c=ise(o))||(a.precision=c-(a.type===`%`)*2);break}return t(a)}}}function ub(){return bb=lb({format:h_,formatPrefix:g_})}function db(e){return lb(ese(e))}function fb(e){return arguments.length?bb=db(e):bb}function pb(e,t,n){n||={},Dh(n)||V(`Invalid time multi-format specifier: ${n}`);let r=t($v),i=t(Qv),a=t(Zv),o=t(Yv),s=t(Jv),c=t(qv),l=t(Kv),u=t(Gv),d=e(n.milliseconds||`.%L`),f=e(n.seconds||`:%S`),p=e(n.minutes||`%I:%M`),m=e(n.hours||`%I %p`),h=e(n.date||n.day||`%a %d`),g=e(n.week||`%b %d`),_=e(n.month||`%B`),v=e(n.quarter||`%B`),y=e(n.year||`%Y`);return e=>(r(e)xg(e)?t(e):pb(t,Fv,e),utcFormat:e=>xg(e)?n(e):pb(n,Iv,e),timeParse:cb(e.parse),utcParse:cb(e.utcParse)}}function hb(){return xb=mb({format:rb,parse:ib,utcFormat:ab,utcParse:ob})}function gb(e){return mb(Py(e))}function _b(e){return arguments.length?xb=gb(e):xb}function vb(e,t){let n=e?db(e):fb(),r=t?gb(t):_b();return Sb(n,r)}function yb(e,t){let n=arguments.length;return n&&n!==2&&V(`defaultLocale expects either zero or two arguments.`),n?Sb(fb(e),_b(t)):Sb(fb(),_b())}function gce(){return ub(),hb(),yb()}var bb,xb,Sb,Cb=o((()=>{r_(),__(),Ay(),Ag(),sb(),ub(),hb(),Sb=(e,t)=>ug({},e,t)}));function _ce(e){return t=>({options:t||{},sanitize:yce,load:vce,fileAccess:!1,file:bce(e),http:Sce})}async function vce(e,t){let n=await this.sanitize(e,t),r=n.href;return n.localFile?this.file(r):this.http(r,t?.http)}async function yce(e,t){t=ug({},this.options,t);let n=this.fileAccess,r={href:null},i,a,o,s=Pb.test(e.replace(Fb,``));(e==null||typeof e!=`string`||!s)&&V(`Sanitize failure, invalid URI: `+W(e));let c=Nb.test(e);return(o=t.baseURL)&&!c&&(!e.startsWith(`/`)&&!o.endsWith(`/`)&&(e=`/`+e),e=o+e),a=(i=e.startsWith(Ib))||t.mode===`file`||t.mode!==`http`&&!c&&n,i?e=e.slice(7):e.startsWith(`//`)&&(t.defaultProtocol===`file`?(e=e.slice(2),a=!0):e=(t.defaultProtocol||`http`)+`:`+e),Object.defineProperty(r,"localFile",{value:!!a}),r.href=e,t.target&&(r.target=t.target+``),t.rel&&(r.rel=t.rel+``),t.context===`image`&&t.crossOrigin&&(r.crossOrigin=t.crossOrigin+``),r}function bce(e){return e?t=>new Promise((n,r)=>{e.readFile(t,(e,t)=>{e?r(e):n(t)})}):xce}async function xce(){V(`No file system access.`)}async function Sce(e,t){let n=ug({},this.options.http,t),r=t&&t.response,i=await fetch(e,n);return i.ok?ig(i[r])?i[r]():i.text():V(i.status+``+i.statusText)}function wb(e,t){if(!e||!e.length)return`unknown`;let n=e.length,r=Ub.length,i=Ub.map((e,t)=>t+1);for(let a=0,o=0,s,c;ae===0?t:e,0)-1]}function Tb(e,t){return t.reduce((t,n)=>(t[n]=wb(e,n),t),{})}function Eb(e){let t=function(t,n){let r={delimiter:e};return Db(t,n?ug(n,r):r)};return t.responseType=`text`,t}function Db(e,t){return t.header&&(e=t.header.map(W).join(t.delimiter)+` +`+e),Eae(t.delimiter).parse(e+``)}function Cce(e){return typeof Buffer==`function`&&ig(Buffer.isBuffer)?Buffer.isBuffer(e):!1}function Ob(e,t){let n=t&&t.property?gh(t.property):yh;return Dh(e)&&!Cce(e)?wce(n(e),t):n(JSON.parse(e))}function wce(e,t){return!H(e)&&Jie(e)&&(e=[...e]),t&&t.copy?JSON.parse(JSON.stringify(e)):e}function kb(e,t){let n,r,i,a;return e=Ob(e,t),t&&t.feature?(n=Fae,i=t.feature):t&&t.mesh?(n=Vae,i=t.mesh,a=Gb[t.filter]):V(`Missing TopoJSON feature or mesh parameter.`),r=(r=e.objects[i])?n(e,r,a):V(`Invalid TopoJSON object: `+i),r&&r.features||[r]}function Ab(e,t){return arguments.length>1?(Kb[e]=t,this):fg(Kb,e)?Kb[e]:null}function jb(e){let t=Ab(e);return t&&t.responseType||`text`}function Mb(e,t,n,r){t||={};let i=Ab(t.type||`json`);return i||V(`Unknown data format type: `+t.type),e=i(e,t),t.parse&&Tce(e,t.parse,n,r),fg(e,`columns`)&&delete e.columns,e}function Tce(e,t,n,r){if(!e.length)return;let i=_b();n||=i.timeParse,r||=i.utcParse;let a=e.columns||Object.keys(e[0]),o,s,c,l,u,d;t===`auto`&&(t=Tb(e,a)),a=Object.keys(t);let f=a.map(e=>{let i=t[e],a,o;if(i&&(i.startsWith(`date:`)||i.startsWith(`utc:`)))return a=i.split(/:(.+)?/,2),o=a[1],(o[0]===`'`&&o[o.length-1]===`'`||o[0]===`"`&&o[o.length-1]===`"`)&&(o=o.slice(1,-1)),(a[0]===`utc`?r:n)(o);if(!Hb[i])throw Error(`Illegal format pattern: `+e+`:`+i);return Hb[i]});for(c=0,u=e.length,d=a.length;c{Ag(),Oae(),Gae(),Cb(),Nb=/^(data:|([A-Za-z]+:)?\/\/)/,Pb=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,Fb=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Ib=`file://`,Lb=e=>e!=null&&e===e,Rb=e=>e===`true`||e===`false`||e===!0||e===!1,zb=e=>!Number.isNaN(Date.parse(e)),Bb=e=>!Number.isNaN(+e)&&!(e instanceof Date),Vb=e=>Bb(e)&&Number.isInteger(+e),Hb={boolean:Tg,integer:Ph,number:Ph,date:Eg,string:Dg,unknown:yh},Ub=[Rb,Vb,Bb,zb],Wb=[`boolean`,`integer`,`number`,`date`],Db.responseType=`text`,Ob.responseType=`json`,Gb={interior:(e,t)=>e!==t,exterior:(e,t)=>e===t},kb.responseType=`json`,Kb={dsv:Db,csv:Eb(`,`),tsv:Eb(` `),json:Ob,topojson:kb},qb=_ce(null)}));function Yb(e){let t=e||yh,n=[],r={};return n.add=e=>{let i=t(e);return r[i]||(r[i]=1,n.push(e)),n},n.remove=e=>{let i=t(e);if(r[i]){r[i]=0;let t=n.indexOf(e);t>=0&&n.splice(t,1)}return n},n}async function Xb(e,t){try{await t(e)}catch(t){e.error(t)}}function Zb(e){return!!(e&&Qb(e))}function Qb(e){return e[Cx]}function $b(e,t){return e[Cx]=t,e}function ex(e){let t=e===Object(e)?e:{data:e};return Qb(t)?t:$b(t,wx++)}function tx(e){return nx(e,ex({}))}function nx(e,t){for(let n in e)t[n]=e[n];return t}function rx(e,t){return $b(t,Qb(e))}function ix(e,t){return e?t?(n,r)=>e(n,r)||Qb(t(n))-Qb(t(r)):(t,n)=>e(t,n)||Qb(t)-Qb(n):null}function ax(e){return e&&e.constructor===ox}function ox(){let e=[],t=[],n=[],r=[],i=[],a=null,o=!1;return{constructor:ox,insert(t){let n=ng(t),r=n.length;for(let t=0;t{m(e)&&(l[Qb(e)]=-1)});for(d=0,f=e.length;d0&&(_(h,m,p.value),s.modifies(m));for(d=0,f=i.length;d{m(e)&&l[Qb(e)]>0&&_(e,p.field,p.value)}),s.modifies(p.field);if(o)s.mod=t.length||r.length?c.filter(e=>l[Qb(e)]>0):c.slice();else for(g in u)s.mod.push(u[g]);return(a||a==null&&(t.length||r.length))&&s.clean(!0),s}}}function sx(){Object.defineProperty(this,Tx,{writable:!0,value:{}})}function cx(e,t,n,r){this.id=++Ex,this.value=e,this.stamp=-1,this.rank=-1,this.qrank=-1,this.flags=0,t&&(this._update=t),n&&this.parameters(n,r)}function lx(e){return function(t){let n=this.flags;return arguments.length===0?!!(n&e):(this.flags=t?n|e:n&~e,this)}}function Ece(e,t,n,r){let i=1,a;return e instanceof cx?a=e:e&&e.prototype instanceof cx?a=new e:ig(e)?a=new cx(null,e):(i=0,a=new cx(e,t)),this.rank(a),i&&(r=n,n=t),n&&this.connect(a,a.parameters(n,r)),this.touch(a),a}function Dce(e,t){let n=e.rank,r=t.length;for(let i=0;it=e);return n.requests=0,n.done=()=>{--n.requests===0&&(e._pending=null,t(e))},e._pending=n}function Pce(e,t,n,r,i){return(e instanceof cx?Ice:Fce)(this,e,t,n,r,i),this}function Fce(e,t,n,r,i,a){let o=ug({},a,Mx),s,c;ig(n)||(n=cg(n)),r===void 0?s=t=>e.touch(n(t)):ig(r)?(c=new cx(null,r,i,!1),s=t=>{c.evaluate(t);let r=n(t),i=c.value;ax(i)?e.pulse(r,i,a):e.update(r,i,o)}):s=t=>e.update(n(t),r,o),t.apply(s)}function Ice(e,t,n,r,i,a){if(r===void 0)t.targets().add(n);else{let o=a||{},s=new cx(null,Lce(n,r),i,!1);s.modified(o.force),s.rank=t.rank,t.targets().add(s),n&&(s.skip(!0),s.value=n.value,s.targets().add(n),e.connect(n,[s]))}}function Lce(e,t){return t=ig(t)?t:cg(t),e?function(n,r){let i=t(n,r);return e.skip()||(e.skip(i!==this.value).value=i),i}:t}function Rce(e){e.rank=++this._rank}function zce(e){let t=[e],n,r,i;for(;t.length;)if(this.rank(n=t.pop()),r=n._targets)for(i=r.length;--i>=0;)t.push(n=r[i]),n===e&&V(`Cycle detected in dataflow graph.`)}function fx(e,t,n){this.dataflow=e,this.stamp=t??-1,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=n||null}function px(e,t){let n=[];return kg(e,t,e=>n.push(e)),n}function mx(e,t){let n={};return e.visit(t,e=>{n[Qb(e)]=1}),e=>n[Qb(e)]?null:e}function hx(e,t){return e?(n,r)=>e(n,r)&&t(n,r):t}function gx(e,t,n,r){let i=this,a=0;this.dataflow=e,this.stamp=t,this.fields=null,this.encode=r||null,this.pulses=n;for(let e of n)if(e.stamp===t){if(e.fields){let t=i.fields||={};for(let n in e.fields)t[n]=1}e.changed(i.ADD)&&(a|=i.ADD),e.changed(i.REM)&&(a|=i.REM),e.changed(i.MOD)&&(a|=i.MOD)}this.changes=a}async function Bce(e,t,n){let r=this,i=[];if(r._pulse)return _x(r);if(r._pending&&await r._pending,t&&await Xb(r,t),!r._touched.length)return r.debug(`Dataflow invoked, but nothing to do.`),r;let a=++r._clock;r._pulse=new fx(r,a,e),r._touched.forEach(e=>r._enqueue(e,!0)),r._touched=Yb(vh);let o=0,s,c,l;try{for(;r._heap.size()>0;){if(s=r._heap.pop(),s.rank!==s.qrank){r._enqueue(s,!0);continue}c=s.run(r._getPulse(s,e)),c.then?c=await c:c.async&&(i.push(c.async),c=Nx),c!==Nx&&s._targets&&s._targets.forEach(e=>r._enqueue(e)),++o}}catch(e){r._heap.clear(),l=e}if(r._input={},r._pulse=null,r.debug(`Pulse ${a}: ${o} operators`),l&&(r._postrun=[],r.error(l)),r._postrun.length){let e=r._postrun.sort((e,t)=>t.priority-e.priority);r._postrun=[];for(let t=0;tr.runAsync(null,()=>{e.forEach(e=>{try{e(r)}catch(e){r.error(e)}})})),r}async function Vce(e,t,n){for(;this._running;)await this._running;let r=()=>this._running=null;return(this._running=this.evaluate(e,t,n)).then(r,r),this._running}function Hce(e,t,n){return this._pulse?_x(this):(this.evaluate(e,t,n),this)}function Uce(e,t,n){if(this._pulse||t)this._postrun.push({priority:n||0,callback:e});else try{e(this)}catch(e){this.error(e)}}function _x(e){return e.error(`Dataflow already running. Use runAsync() to chain invocations.`),e}function Wce(e,t){let n=e.stampe.pulse),t):this._input[e.id]||Kce(this._pulse,n&&n.pulse)}function Kce(e,t){return t&&t.stamp===e.stamp?t:(e=e.fork(),t&&t!==Nx&&(e.source=t.source),e)}function qce(e,t){let n=t||Wx;return this._pulse?this._enqueue(e):this._touched.add(e),n.skip&&e.skip(!0),this}function Jce(e,t,n){let r=n||Wx;return(e.set(t)||r.force)&&this.touch(e,r),this}function Yce(e,t,n){this.touch(e,n||Wx);let r=new fx(this,this._clock+ +!this._pulse),i=e.pulse&&e.pulse.source||[];return r.target=e,this._input[e.id]=t.pulse(r,i),this}function Xce(e){let t=[];return{clear:()=>t=[],size:()=>t.length,peek:()=>t[0],push:n=>(t.push(n),vx(t,0,t.length-1,e)),pop:()=>{let n=t.pop(),r;return t.length?(r=t[0],t[0]=n,Zce(t,0,e)):r=n,r}}}function vx(e,t,n,r){let i,a,o=e[n];for(;n>t;){if(a=n-1>>1,i=e[a],r(o,i)<0){e[n]=i,n=a;continue}break}return e[n]=o}function Zce(e,t,n){let r=t,i=e.length,a=e[t],o=(t<<1)+1,s;for(;o=0&&(o=s),e[t]=e[o],t=o,o=(t<<1)+1;return e[t]=a,vx(e,r,t,n)}function yx(){this.logger(Th()),this.logLevel(1),this._clock=0,this._rank=0,this._locale=yb();try{this._loader=qb()}catch{}this._touched=Yb(vh),this._input={},this._pulse=null,this._heap=Xce((e,t)=>e.qrank-t.qrank),this._postrun=[]}function bx(e){return function(){return this._log[e].apply(this,arguments)}}function G(e,t){cx.call(this,e,null,t)}function xx(e){let t=Sx(e);return t&&t.Definition||null}function Sx(e){return e&&=e.toLowerCase(),fg(Gx,e)?Gx[e]:null}var Cx,wx,Tx,Ex,Dx,Ox,kx,Ax,jx,Mx,Nx,Px,Fx,Ix,Lx,Rx,zx,Bx,Vx,Hx,Ux,Wx,Gx,Kx=o((()=>{Ag(),Jb(),Cb(),Cx=Symbol(`vega_id`),wx=1,Tx=`_:mod:_`,sx.prototype={set(e,t,n,r){let i=this,a=i[e],o=i[Tx];return t!=null&&t>=0?(a[t]!==n||r)&&(a[t]=n,o[t+`:`+e]=-1,o[e]=-1):(a!==n||r)&&(i[e]=n,o[e]=H(n)?1+n.length:-1),i},modified(e,t){let n=this[Tx];if(!arguments.length){for(let e in n)if(n[e])return!0;return!1}else if(H(e)){for(let t=0;t=0?t+1{o instanceof cx?(o!==this&&(t&&o.targets().add(this),a.push(o)),i.push({op:o,name:e,index:n})):r.set(e,n,o)};for(o in e)if(s=e[o],o===Dx)ng(s).forEach(e=>{e instanceof cx?e!==this&&(e.targets().add(this),a.push(e)):V(`Pulse parameters must be operator instances.`)}),this.source=s;else if(H(s))for(r.set(o,-1,Array(c=s.length)),l=0;l{let n=Date.now();return n-t>e?(t=n,1):0})},debounce(e){let t=dx();return this.targets().add(dx(null,null,lg(e,e=>{let n=e.dataflow;t.receive(e),n&&n.run&&n.run()}))),t},between(e,t){let n=!1;return e.targets().add(dx(null,null,()=>n=!0)),t.targets().add(dx(null,null,()=>n=!1)),this.filter(()=>n)},detach(){this._filter=Sh,this._targets=null}},Mx={skip:!0},Nx={},Px=1,Fx=2,Ix=4,Lx=3,Rx=5,zx=7,Bx=8,Vx=16,Hx=32,Ux=64,fx.prototype={StopPropagation:Nx,ADD:Px,REM:Fx,MOD:Ix,ADD_REM:Lx,ADD_MOD:Rx,ALL:zx,REFLOW:Bx,SOURCE:Vx,NO_SOURCE:Hx,NO_FIELDS:Ux,fork(e){return new fx(this.dataflow).init(this,e)},clone(){let e=this.fork(zx);return e.add=e.add.slice(),e.rem=e.rem.slice(),e.mod=e.mod.slice(),e.source&&=e.source.slice(),e.materialize(23)},addAll(){let e=this;return!e.source||e.add===e.rem||!e.rem.length&&e.source.length===e.add.length?e:(e=new fx(this.dataflow).init(this),e.add=e.source,e.rem=[],e)},init(e,t){let n=this;return n.stamp=e.stamp,n.encode=e.encode,e.fields&&!(t&Ux)&&(n.fields=e.fields),t&Px?(n.addF=e.addF,n.add=e.add):(n.addF=null,n.add=[]),t&Fx?(n.remF=e.remF,n.rem=e.rem):(n.remF=null,n.rem=[]),t&Ix?(n.modF=e.modF,n.mod=e.mod):(n.modF=null,n.mod=[]),t&Hx?(n.srcF=null,n.source=null):(n.srcF=e.srcF,n.source=e.source,e.cleans&&(n.cleans=e.cleans)),n},runAfter(e){this.dataflow.runAfter(e)},changed(e){let t=e||zx;return t&Px&&this.add.length||t&Fx&&this.rem.length||t&Ix&&this.mod.length},reflow(e){if(e)return this.fork(zx).reflow();let t=this.add.length,n=this.source&&this.source.length;return n&&n!==t&&(this.mod=this.source,t&&this.filter(Ix,mx(this,Px))),this},clean(e){return arguments.length?(this.cleans=!!e,this):this.cleans},modifies(e){let t=this.fields||={};return H(e)?e.forEach(e=>t[e]=!0):t[e]=!0,this},modified(e,t){let n=this.fields;return(t||this.mod.length)&&n?arguments.length?H(e)?e.some(e=>n[e]):n[e]:!!n:!1},filter(e,t){let n=this;return e&Px&&(n.addF=hx(n.addF,t)),e&Fx&&(n.remF=hx(n.remF,t)),e&Ix&&(n.modF=hx(n.modF,t)),e&Vx&&(n.srcF=hx(n.srcF,t)),n},materialize(e){e||=zx;let t=this;return e&Px&&t.addF&&(t.add=px(t.add,t.addF),t.addF=null),e&Fx&&t.remF&&(t.rem=px(t.rem,t.remF),t.remF=null),e&Ix&&t.modF&&(t.mod=px(t.mod,t.modF),t.modF=null),e&Vx&&t.srcF&&(t.source=t.source.filter(t.srcF),t.srcF=null),t},visit(e,t){let n=this,r=t;if(e&Vx)return kg(n.source,n.srcF,r),n;e&Px&&kg(n.add,n.addF,r),e&Fx&&kg(n.rem,n.remF,r),e&Ix&&kg(n.mod,n.modF,r);let i=n.source;if(e&Bx&&i){let e=n.add.length+n.mod.length;e===i.length||(e?kg(i,mx(n,Rx),r):kg(i,n.srcF,r))}return n}},U(gx,fx,{fork(e){let t=new fx(this.dataflow).init(this,e&this.NO_FIELDS);return e!==void 0&&(e&t.ADD&&this.visit(t.ADD,e=>t.add.push(e)),e&t.REM&&this.visit(t.REM,e=>t.rem.push(e)),e&t.MOD&&this.visit(t.MOD,e=>t.mod.push(e))),t},changed(e){return this.changes&e},modified(e){let t=this,n=t.fields;return n&&t.changes&t.MOD?H(e)?e.some(e=>n[e]):n[e]:0},filter(){V(`MultiPulse does not support filtering.`)},materialize(){V(`MultiPulse does not support materialization.`)},visit(e,t){let n=this,r=n.pulses,i=r.length,a=0;if(e&n.SOURCE)for(;athis.pulse=e):t!==e.StopPropagation&&(this.pulse=t),t},evaluate(e){let t=this.marshall(e.stamp),n=this.transform(t,e);return t.clear(),n},transform(){}}),Gx={}}));function*qx(e,t){if(t==null)for(let t of e)t!=null&&t!==``&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)r=t(r,++n,e),r!=null&&r!==``&&(r=+r)>=r&&(yield r)}}function Jx(e,t,n){let r=Float64Array.from(qx(e,n));return r.sort(Lg),t.map(e=>xoe(r,e))}function Yx(e,t){return Jx(e,[.25,.5,.75],t)}function Xx(e,t){let n=e.length,r=noe(e,t),i=Yx(e,t),a=(i[2]-i[0])/1.34;return 1.06*(Math.min(r,a)||r||Math.abs(i[0])||1)*n**-.2}function Zx(e){let t=e.maxbins||20,n=e.base||10,r=Math.log(n),i=e.divide||[5,2],a=e.extent[0],o=e.extent[1],s,c,l,u,d,f,p=e.span||o-a||Math.abs(a)||1;if(e.step)s=e.step;else if(e.steps){for(u=p/t,d=0,f=e.steps.length;dt;)s*=n;for(d=0,f=i.length;d=l&&p/u<=t&&(s=u)}u=Math.log(s);let m=n**(-(u>=0?0:~~(-u/r)+1)-1);return(e.nice||e.nice===void 0)&&(u=Math.floor(a/s+m)*s,a=ae);let i=e.length,a=new Float64Array(i),o=0,s=1,c=r(e[0]),l=c,u=c+t,d;for(;s=u){for(l=(c+l)/2;o>1);oi;)e[o--]=e[r]}r=i,i=a}return e}function ele(e){return function(){return e=(1103515245*e+12345)%2147483647,e/2147483647}}function tle(e,t){t??(t=e,e=0);let n,r,i,a={min(e){return arguments.length?(n=e||0,i=r-n,a):n},max(e){return arguments.length?(r=e||0,i=r-n,a):r},sample(){return n+Math.floor(i*AS())},pdf(e){return e===Math.floor(e)&&e>=n&&e=r?1:(t-n+1)/i},icdf(e){return e>=0&&e<=1?n-1+Math.floor(e*i):NaN}};return a.min(e).max(t)}function eS(e,t){e||=0,t??=1;let n=0,r=0,i,a;if(NS===NS)n=NS,NS=NaN;else{do n=AS()*2-1,r=AS()*2-1,i=n*n+r*r;while(i===0||i>1);a=Math.sqrt(-2*Math.log(i)/i),n*=a,NS=r*a}return e+n*t}function tS(e,t,n){n??=1;let r=(e-(t||0))/n;return Math.exp(-.5*r*r)/(n*jS)}function nS(e,t,n){t||=0,n??=1;let r=(e-t)/n,i=Math.abs(r),a;if(i>37)a=0;else{let e=Math.exp(-i*i/2),t;i<7.07106781186547?(t=.0352624965998911*i+.700383064443688,t=t*i+6.37396220353165,t=t*i+33.912866078383,t=t*i+112.079291497871,t=t*i+221.213596169931,t=t*i+220.206867912376,a=e*t,t=.0883883476483184*i+1.75566716318264,t=t*i+16.064177579207,t=t*i+86.7807322029461,t=t*i+296.564248779674,t=t*i+637.333633378831,t=t*i+793.826512519948,t=t*i+440.413735824752,a/=t):(t=i+.65,t=i+4/t,t=i+3/t,t=i+2/t,t=i+1/t,a=e/t/2.506628274631)}return r>0?1-a:a}function rS(e,t,n){return e<0||e>1?NaN:(t||0)+(n??1)*MS*nle(2*e-1)}function nle(e){let t=-Math.log((1-e)*(1+e)),n;return t<6.25?(t-=3.125,n=-364441206401782e-35,n=-16850591381820166e-35+n*t,n=128584807152564e-32+n*t,n=11157877678025181e-33+n*t,n=-1333171662854621e-31+n*t,n=20972767875968562e-33+n*t,n=6637638134358324e-30+n*t,n=-4054566272975207e-29+n*t,n=-8151934197605472e-29+n*t,n=26335093153082323e-28+n*t,n=-12975133253453532e-27+n*t,n=-5415412054294628e-26+n*t,n=1.0512122733215323e-9+n*t,n=-4.112633980346984e-9+n*t,n=-2.9070369957882005e-8+n*t,n=4.2347877827932404e-7+n*t,n=-13654692000834679e-22+n*t,n=-13882523362786469e-21+n*t,n=.00018673420803405714+n*t,n=-.000740702534166267+n*t,n=-.006033670871430149+n*t,n=.24015818242558962+n*t,n=1.6536545626831027+n*t):t<16?(t=Math.sqrt(t)-3.25,n=2.2137376921775787e-9,n=9.075656193888539e-8+n*t,n=-2.7517406297064545e-7+n*t,n=1.8239629214389228e-8+n*t,n=15027403968909828e-22+n*t,n=-4013867526981546e-21+n*t,n=29234449089955446e-22+n*t,n=12475304481671779e-21+n*t,n=-47318229009055734e-21+n*t,n=6828485145957318e-20+n*t,n=24031110387097894e-21+n*t,n=-.0003550375203628475+n*t,n=.0009532893797373805+n*t,n=-.0016882755560235047+n*t,n=.002491442096107851+n*t,n=-.003751208507569241+n*t,n=.005370914553590064+n*t,n=1.0052589676941592+n*t,n=3.0838856104922208+n*t):Number.isFinite(t)?(t=Math.sqrt(t)-5,n=-27109920616438573e-27,n=-2555641816996525e-25+n*t,n=1.5076572693500548e-9+n*t,n=-3.789465440126737e-9+n*t,n=7.61570120807834e-9+n*t,n=-1.496002662714924e-8+n*t,n=2.914795345090108e-8+n*t,n=-6.771199775845234e-8+n*t,n=2.2900482228026655e-7+n*t,n=-9.9298272942317e-7+n*t,n=4526062597223154e-21+n*t,n=-1968177810553167e-20+n*t,n=7599527703001776e-20+n*t,n=-.00021503011930044477+n*t,n=-.00013871931833623122+n*t,n=1.0103004648645344+n*t,n=4.849906401408584+n*t):n=1/0,n*e}function iS(e,t){let n,r,i={mean(e){return arguments.length?(n=e||0,i):n},stdev(e){return arguments.length?(r=e??1,i):r},sample:()=>eS(n,r),pdf:e=>tS(e,n,r),cdf:e=>nS(e,n,r),icdf:e=>rS(e,n,r)};return i.mean(e).stdev(t)}function aS(e,t){let n=iS(),r=0,i={data(n){return arguments.length?(e=n,r=n?n.length:0,i.bandwidth(t)):e},bandwidth(n){return arguments.length?(t=n,!t&&e&&(t=Xx(e)),i):t},sample(){return e[~~(AS()*r)]+t*n.sample()},pdf(i){let a=0,o=0;for(;ooS(n,r),pdf:e=>sS(e,n,r),cdf:e=>cS(e,n,r),icdf:e=>lS(e,n,r)};return i.mean(e).stdev(t)}function dS(e,t){let n=0,r;function i(e){let t=[],r=0,i;for(i=0;i=t&&e<=n?1/(n-t):0}function mS(e,t,n){return n??(n=t??1,t=0),en?1:(e-t)/(n-t)}function hS(e,t,n){return n??(n=t??1,t=0),e>=0&&e<=1?t+e*(n-t):NaN}function gS(e,t){let n,r,i={min(e){return arguments.length?(n=e||0,i):n},max(e){return arguments.length?(r=e??1,i):r},sample:()=>fS(n,r),pdf:e=>pS(e,n,r),cdf:e=>mS(e,n,r),icdf:e=>hS(e,n,r)};return t??(t=e??1,e=0),i.min(e).max(t)}function _S(e,t,n){let r=0,i=0;for(let a of e){let e=n(a);t(a)==null||e==null||isNaN(e)||(r+=(e-r)/++i)}return{coef:[r],predict:()=>r,rSquared:0}}function vS(e,t,n,r){let i=r-e*e,a=Math.abs(i)<1e-24?0:(n-e*t)/i;return[t-a*e,a]}function yS(e,t,n,r){e=e.filter(e=>{let r=t(e),i=n(e);return r!=null&&(r=+r)>=r&&i!=null&&(i=+i)>=i}),r&&e.sort((e,n)=>t(e)-t(n));let i=e.length,a=new Float64Array(i),o=new Float64Array(i),s=0,c=0,l=0,u,d,f;for(f of e)a[s]=u=+t(f),o[s]=d=+n(f),++s,c+=(u-c)/s,l+=(d-l)/s;for(s=0;s=a&&o!=null&&(o=+o)>=o&&r(a,o,++i)}function xS(e,t,n,r,i){let a=0,o=0;return bS(e,t,n,(e,t)=>{let n=t-i(e),s=t-r;a+=n*n,o+=s*s}),1-a/o}function SS(e,t,n){let r=0,i=0,a=0,o=0,s=0;bS(e,t,n,(e,t)=>{++s,r+=(e-r)/s,i+=(t-i)/s,a+=(e*t-a)/s,o+=(e*e-o)/s});let c=vS(r,i,a,o),l=e=>c[0]+c[1]*e;return{coef:c,predict:l,rSquared:xS(e,t,n,i,l)}}function CS(e,t,n){let r=0,i=0,a=0,o=0,s=0;bS(e,t,n,(e,t)=>{++s,e=Math.log(e),r+=(e-r)/s,i+=(t-i)/s,a+=(e*t-a)/s,o+=(e*e-o)/s});let c=vS(r,i,a,o),l=e=>c[0]+c[1]*Math.log(e);return{coef:c,predict:l,rSquared:xS(e,t,n,i,l)}}function wS(e,t,n){let[r,i,a,o]=yS(e,t,n),s=0,c=0,l=0,u=0,d=0,f,p,m;bS(e,t,n,(e,t)=>{f=r[d++],p=Math.log(t),m=f*t,s+=(t*p-s)/d,c+=(m-c)/d,l+=(m*p-l)/d,u+=(f*m-u)/d});let[h,g]=vS(c/o,s/o,l/o,u/o),_=e=>Math.exp(h+g*(e-a));return{coef:[Math.exp(h-g*a),g],predict:_,rSquared:xS(e,t,n,o,_)}}function TS(e,t,n){let r=0,i=0,a=0,o=0,s=0,c=0;bS(e,t,n,(e,t)=>{let n=Math.log(e),l=Math.log(t);++c,r+=(n-r)/c,i+=(l-i)/c,a+=(n*l-a)/c,o+=(n*n-o)/c,s+=(t-s)/c});let l=vS(r,i,a,o),u=e=>l[0]*e**+l[1];return l[0]=Math.exp(l[0]),{coef:l,predict:u,rSquared:xS(e,t,n,s,u)}}function ES(e,t,n){let[r,i,a,o]=yS(e,t,n),s=r.length,c=0,l=0,u=0,d=0,f=0,p,m,h,g;for(p=0;p(e-=a,y*e*e+b*e+x+o);return{coef:[x-b*a+y*a*a+o,b-2*y*a,y],predict:S,rSquared:xS(e,t,n,o,S)}}function DS(e,t,n,r){if(r===0)return _S(e,t,n);if(r===1)return SS(e,t,n);if(r===2)return ES(e,t,n);let[i,a,o,s]=yS(e,t,n),c=i.length,l=[],u=[],d=r+1,f,p,m,h,g;for(f=0;f{e-=o;let t=s+_[0]+_[1]*e+_[2]*e*e;for(f=3;f=0;--a)for(s=t[a],c=1,i[a]+=s,o=1;o<=a;++o)c*=(a+1-o)/o,i[a-o]+=s*n**+o*c;return i[0]+=r,i}function ile(e){let t=e.length-1,n=[],r,i,a,o,s;for(r=0;rMath.abs(e[r][o])&&(o=i);for(a=r;a=r;a--)e[a][i]-=e[a][r]*e[r][i]/e[r][r]}for(i=t-1;i>=0;--i){for(s=0,a=i+1;ai[o]-n?r:o,c=0,l=0,p=0,m=0,h=0,g=1/Math.abs(i[s]-n||1);for(let e=r;e<=o;++e){let t=i[e],r=a[e],o=ale(Math.abs(n-t)*g)*f[e],s=t*o;c+=o,l+=s,p+=r*o,m+=r*s,h+=t*s}let[_,v]=vS(l/c,p/c,m/c,h/c);u[e]=_+v*n,d[e]=Math.abs(a[e]-u[e]),ole(i,e+1,t)}if(e===PS)break;let n=Toe(d);if(Math.abs(n)=1?FS:(r=1-t*t)*r}return sle(i,u,o,s)}function ale(e){return(e=1-e*e*e)*e*e}function ole(e,t,n){let r=e[t],i=n[0],a=n[1]+1;if(!(a>=e.length))for(;t>i&&e[a]-r<=r-e[i];)n[0]=++i,n[1]=a,++a}function sle(e,t,n,r){let i=e.length,a=[],o=0,s=0,c=[],l;for(;o[t,e(t)],a=t[0],o=t[1],s=o-a,c=s/r,l=[i(a)],u=[];if(n===r){for(let e=1;e0;)u.push(i(a+e/n*s))}let d=l[0],f=u[u.length-1],p=1/s,m=cle(d[1],u);for(;f;){let e=i((d[0]+f[0])/2);e[0]-d[0]>=c&&lle(d,e,f,p,m)>IS?u.push(e):(d=f,l.push(f),u.pop()),f=u[u.length-1]}return l}function cle(e,t){let n=e,r=e,i=t.length;for(let e=0;er&&(r=i)}return 1/(r-n)}function lle(e,t,n,r,i){let a=Math.atan2(i*(n[1]-e[1]),r*(n[0]-e[0])),o=Math.atan2(i*(t[1]-e[1]),r*(t[0]-e[0]));return Math.abs(a-o)}var AS,jS,MS,NS,PS,FS,IS,LS=o((()=>{r_(),AS=Math.random,jS=Math.sqrt(2*Math.PI),MS=Math.SQRT2,NS=NaN,PS=2,FS=1e-12,IS=.5*Math.PI/180})),ule=c({aggregate:()=>WS,bin:()=>GS,collect:()=>qS,compare:()=>JS,countpattern:()=>YS,cross:()=>XS,density:()=>QS,dotbin:()=>tC,expression:()=>nC,extent:()=>rC,facet:()=>aC,field:()=>oC,filter:()=>sC,flatten:()=>cC,fold:()=>lC,formula:()=>uC,generate:()=>dC,impute:()=>fC,joinaggregate:()=>pC,kde:()=>mC,key:()=>hC,load:()=>gC,lookup:()=>vC,multiextent:()=>yC,multivalues:()=>bC,params:()=>xC,pivot:()=>SC,prefacet:()=>CC,project:()=>wC,proxy:()=>TC,quantile:()=>EC,relay:()=>DC,sample:()=>OC,sequence:()=>kC,sieve:()=>AC,subflow:()=>iC,timeunit:()=>jC,tupleindex:()=>MC,values:()=>NC,window:()=>FC});function dle(e){return t=>{let n=e.length,r=1,i=String(e[0](t));for(;rug({name:e,aggregate_param:r,out:n||e},RC,t)}function BS(e,t,n){return zC[e](n,t)}function VS(e,t){return e.idx-t.idx}function ple(e){let t={};e.forEach(e=>t[e.name]=e);let n=e=>{e.req&&e.req.forEach(e=>{t[e]||n(t[e]=zC[e]())})};return e.forEach(n),Object.values(t).sort(VS)}function mle(){this.valid=0,this.missing=0,this._ops.forEach(e=>e.aggregate_param==null?e.init(this):e.init(this,e.aggregate_param))}function hle(e,t){if(e==null||e===``){++this.missing;return}e===e&&(++this.valid,this._ops.forEach(n=>n.add(this,e,t)))}function gle(e,t){if(e==null||e===``){--this.missing;return}e===e&&(--this.valid,this._ops.forEach(n=>n.rem(this,e,t)))}function _le(e){return this._out.forEach(t=>e[t.out]=t.value(this)),e}function HS(e,t){let n=t||yh,r=ple(e),i=e.slice().sort(VS);function a(e){this._ops=r,this._out=i,this.cell=e,this.init()}return a.prototype.init=mle,a.prototype.add=hle,a.prototype.rem=gle,a.prototype.set=_le,a.prototype.get=n,a.fields=e.map(e=>e.out),a}function US(e){this._key=e?gh(e):Qb,this.reset()}function WS(e){G.call(this,null,e),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}function GS(e){G.call(this,null,e)}function KS(e,t,n){let r=e,i=t||[],a=n||[],o={},s=0;return{add:e=>a.push(e),remove:e=>o[r(e)]=++s,size:()=>i.length,data:(e,t)=>(s&&=(i=i.filter(e=>!o[r(e)]),o={},0),t&&e&&i.sort(e),a.length&&(i=e?oae(e,i,a.sort(e)):i.concat(a),a=[]),i)}}function qS(e){G.call(this,[],e)}function JS(e){cx.call(this,null,vle,e)}function vle(e){return this.value&&!e.modified()?this.value:og(e.fields,e.orders)}function YS(e){G.call(this,null,e)}function yle(e,t,n){switch(t){case`upper`:e=e.toUpperCase();break;case`lower`:e=e.toLowerCase();break}return e.match(n)}function XS(e){G.call(this,null,e)}function ble(e,t,n,r){for(var i=[],a={},o=e.length,s=0,c,l;sZS(e,t))):typeof r[n]===GC&&r[n](e[n]);return r}function QS(e){G.call(this,null,e)}function xle(e){return()=>e.materialize(e.SOURCE).source}function $S(e,t){return e?e.map((e,n)=>t[n]||oh(e)):null}function eC(e,t,n){let r=[],i=e=>e(c),a,o,s,c,l,u;if(t==null)r.push(e.map(n));else for(a={},o=0,s=e.length;ot(n,e),sh(t),oh(t))}function rC(e){G.call(this,[void 0,void 0],e)}function iC(e,t){cx.call(this,e),this.parent=t,this.count=0}function aC(e){G.call(this,{},e),this._keys=mg();let t=this._targets=[];t.active=0,t.forEach=e=>{for(let n=0,r=t.active;ngh(e)):gh(e.name,e.as)}function sC(e){G.call(this,mg(),e)}function cC(e){G.call(this,[],e)}function lC(e){G.call(this,[],e)}function uC(e){G.call(this,null,e)}function dC(e){G.call(this,[],e)}function fC(e){G.call(this,[],e)}function wle(e){var t=e.method||ZC.value,n;if(ZC[t]==null)V(`Unrecognized imputation method: `+t);else if(t===ZC.value)return n=e.value===void 0?0:e.value,()=>n;else return ZC[t]}function Tle(e){let t=e.field;return e=>e?t(e):NaN}function Ele(e,t,n,r){var i=e=>e(g),a=[],o=r?r.slice():[],s={},c={},l,u,d,f,p,m,h,g;for(o.forEach((e,t)=>s[e]=t+1),f=0,h=e.length;fi&&(i=o[1]);return[r,i]}function bC(e){cx.call(this,null,Ale,e)}function Ale(e){return this.value&&!e.modified()?this.value:e.values.reduce((e,t)=>e.concat(t),[])}function xC(e){G.call(this,null,e)}function SC(e){WS.call(this,e)}function jle(e,t){let n=e.field,r=e.value,i=(e.op===`count`?`__count__`:e.op)||`sum`,a=sh(n).concat(sh(r)),o=Nle(n,e.limit||0,t);return t.changed()&&e.set(`__pivot__`,null,null,!0),{key:e.key,groupby:e.groupby,ops:o.map(()=>i),fields:o.map(e=>Mle(e,n,r,a)),as:o.map(e=>e+``),modified:e.modified.bind(e)}}function Mle(e,t,n,r){return ah(r=>t(r)===e?n(r):NaN,r,e+``)}function Nle(e,t,n){let r={},i=[];return n.visit(n.SOURCE,t=>{let n=e(t);r[n]||(r[n]=1,i.push(n))}),i.sort(sg),t?i.slice(0,t):i}function CC(e){aC.call(this,e)}function wC(e){G.call(this,null,e)}function Ple(e,t,n,r){for(let i=0,a=n.length;ic[e]=1)}p(e.sort),t.forEach((e,t)=>{let c=n[t],m=r[t],h=i[t]||null,g=oh(c),_=zS(e,g,a[t]);if(p(c),o.push(_),fg(tw,e))s.push(Fle(e,c,m,_));else{if(c==null&&e!==`count`&&V(`Null aggregate field specified.`),e===`count`){u.push(_);return}f=!1;let t=l[g];t||(t=l[g]=[],t.field=c,d.push(t)),t.push(BS(e,h,_))}}),(u.length||d.length)&&(this.cell=Lle(d,u,f)),this.inputs=Object.keys(c)}function Lle(e,t,n){e=e.map(e=>HS(e,e.field));let r={num:0,agg:null,store:!1,count:t};if(!n)for(var i=e.length,a=r.agg=Array(i),o=0;on?n:e}function zle(e,t,n,r){e.p0=e.i0,e.p1=e.i1;let i=t[0]==null?0:n+t[0],a=t[1]==null?r:n+t[1]+1;e.i0=IC(i,0,r),e.i1=IC(a,0,r),e.index=n}function Ble(e,t){let n=e.i0,r=e.i1-1,i=e.compare,a=e.data,o=a.length-1;n>0&&!i(a[n],a[n-1])&&(e.i0=t.left(a,a[n])),r{Ag(),Kx(),LS(),r_(),Ay(),LC=()=>{},RC={init:LC,add:LC,rem:LC,idx:0},zC={values:{init:e=>e.cell.store=!0,value:e=>e.cell.data.values(),idx:-1},count:{value:e=>e.cell.num},__count__:{value:e=>e.missing+e.valid},missing:{value:e=>e.missing},valid:{value:e=>e.valid},sum:{init:e=>e.sum=0,value:e=>e.valid?e.sum:void 0,add:(e,t)=>e.sum+=+t,rem:(e,t)=>e.sum-=t},product:{init:e=>e.product=1,value:e=>e.valid?e.product:void 0,add:(e,t)=>e.product*=t,rem:(e,t)=>e.product/=t},mean:{init:e=>e.mean=0,value:e=>e.valid?e.mean:void 0,add:(e,t)=>(e.mean_d=t-e.mean,e.mean+=e.mean_d/e.valid),rem:(e,t)=>(e.mean_d=t-e.mean,e.mean-=e.valid?e.mean_d/e.valid:e.mean)},average:{value:e=>e.valid?e.mean:void 0,req:[`mean`],idx:1},variance:{init:e=>e.dev=0,value:e=>e.valid>1?Math.max(0,e.dev)/(e.valid-1):void 0,add:(e,t)=>e.dev+=e.mean_d*(t-e.mean),rem:(e,t)=>e.dev-=e.mean_d*(t-e.mean),req:[`mean`],idx:1},variancep:{value:e=>e.valid?Math.max(0,e.dev)/e.valid:void 0,req:[`variance`],idx:2},stdev:{value:e=>e.valid>1?Math.sqrt(Math.max(0,e.dev)/(e.valid-1)):void 0,req:[`variance`],idx:2},stdevp:{value:e=>e.valid?Math.sqrt(Math.max(0,e.dev)/e.valid):void 0,req:[`variance`],idx:2},stderr:{value:e=>e.valid>1?Math.sqrt(Math.max(0,e.dev)/(e.valid*(e.valid-1))):void 0,req:[`variance`],idx:2},distinct:{value:e=>e.cell.data.distinct(e.get),req:[`values`],idx:3},ci0:{value:e=>e.cell.data.ci0(e.get),req:[`values`],idx:3},ci1:{value:e=>e.cell.data.ci1(e.get),req:[`values`],idx:3},median:{value:e=>e.cell.data.q2(e.get),req:[`values`],idx:3},q1:{value:e=>e.cell.data.q1(e.get),req:[`values`],idx:3},q3:{value:e=>e.cell.data.q3(e.get),req:[`values`],idx:3},min:{init:e=>e.min=void 0,value:e=>e.min=Number.isNaN(e.min)?e.cell.data.min(e.get):e.min,add:(e,t)=>{(t{t<=e.min&&(e.min=NaN)},req:[`values`],idx:4},max:{init:e=>e.max=void 0,value:e=>e.max=Number.isNaN(e.max)?e.cell.data.max(e.get):e.max,add:(e,t)=>{(t>e.max||e.max===void 0)&&(e.max=t)},rem:(e,t)=>{t>=e.max&&(e.max=NaN)},req:[`values`],idx:4},argmin:{init:e=>e.argmin=void 0,value:e=>e.argmin||e.cell.data.argmin(e.get),add:(e,t,n)=>{t{t<=e.min&&(e.argmin=void 0)},req:[`min`,`values`],idx:3},argmax:{init:e=>e.argmax=void 0,value:e=>e.argmax||e.cell.data.argmax(e.get),add:(e,t,n)=>{t>e.max&&(e.argmax=n)},rem:(e,t)=>{t>=e.max&&(e.argmax=void 0)},req:[`max`,`values`],idx:3},exponential:{init:(e,t)=>{e.exp=0,e.exp_r=t},value:e=>e.valid?e.exp*(1-e.exp_r)/(1-e.exp_r**e.valid):void 0,add:(e,t)=>e.exp=e.exp_r*e.exp+t,rem:(e,t)=>e.exp=(e.exp-t/e.exp_r**(e.valid-1))/e.exp_r},exponentialb:{value:e=>e.valid?e.exp*(1-e.exp_r):void 0,req:[`exponential`],idx:1}},BC=Object.keys(zC).filter(e=>e!==`__count__`),[...BC,`__count__`].forEach(e=>{zC[e]=fle(e,zC[e])}),VC=US.prototype,VC.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null},VC.add=function(e){this._add.push(e)},VC.rem=function(e){this._rem.push(e)},VC.values=function(){if(this._get=null,this._rem.length===0)return this._add;let e=this._add,t=this._rem,n=this._key,r=e.length,i=t.length,a=Array(r-i),o={},s,c,l;for(s=0;s=0;)a=e(t[r])+``,fg(n,a)||(n[a]=1,++i);return i},VC.extent=function(e){if(this._get!==e||!this._ext){let t=this.values(),n=zie(t,e);this._ext=[t[n[0]],t[n[1]]],this._get=e}return this._ext},VC.argmin=function(e){return this.extent(e)[0]||{}},VC.argmax=function(e){return this.extent(e)[1]||{}},VC.min=function(e){let t=this.extent(e)[0];return t==null?void 0:e(t)},VC.max=function(e){let t=this.extent(e)[1];return t==null?void 0:e(t)},VC.quartile=function(e){return(this._get!==e||!this._q)&&(this._q=Yx(this.values(),e),this._get=e),this._q},VC.q1=function(e){return this.quartile(e)[0]},VC.q2=function(e){return this.quartile(e)[1]},VC.q3=function(e){return this.quartile(e)[2]},VC.ci=function(e){return(this._get!==e||!this._ci)&&(this._ci=Qx(this.values(),1e3,.05,e),this._get=e),this._ci},VC.ci0=function(e){return this.ci(e)[0]},VC.ci1=function(e){return this.ci(e)[1]},WS.Definition={type:`Aggregate`,metadata:{generates:!0,changes:!0},params:[{name:`groupby`,type:`field`,array:!0},{name:`ops`,type:`enum`,array:!0,values:BC},{name:`aggregate_params`,type:`number`,null:!0,array:!0},{name:`fields`,type:`field`,null:!0,array:!0},{name:`as`,type:`string`,null:!0,array:!0},{name:`drop`,type:`boolean`,default:!0},{name:`cross`,type:`boolean`,default:!1},{name:`key`,type:`field`}]},U(WS,G,{transform(e,t){let n=this,r=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=e.modified();return n.stamp=r.stamp,n.value&&(i||t.modified(n._inputs,!0))?(n._prev=n.value,n.value=i?n.init(e):Object.create(null),t.visit(t.SOURCE,e=>n.add(e))):(n.value=n.value||n.init(e),t.visit(t.REM,e=>n.rem(e)),t.visit(t.ADD,e=>n.add(e))),r.modifies(n._outputs),n._drop=e.drop!==!1,e.cross&&n._dims.length>1&&(n._drop=!1,n.cross()),t.clean()&&n._drop&&r.clean(!0).runAfter(()=>this.clean()),n.changes(r)},cross(){let e=this,t=e.value,n=e._dnames,r=n.map(()=>({})),i=n.length;function a(e){let t,a,o,s;for(t in e)for(o=e[t].tuple,a=0;a{let t=oh(e);return i(e),n.push(t),t}),this.cellkey=e.key?e.key:RS(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];let a=e.fields||[null],o=e.ops||[`count`],s=e.aggregate_params||[null],c=e.as||[],l=a.length,u={},d,f,p,m,h,g,_;for(l!==o.length&&V(`Unmatched number of fields and aggregate ops.`),_=0;_HS(e,e.field)),Object.create(null)},cellkey:RS(),cell(e,t){let n=this.value[e];return n?n.num===0&&this._drop&&n.stamp{let t=r(e);e[s]=t,e[c]=t==null?null:i+a*(1+(t-i)/a)}:e=>e[s]=r(e)),t.modifies(n?o:s)},_bins(e){if(this.value&&!e.modified())return this.value;let t=e.field,n=Zx(e),r=n.step,i=n.start,a=i+Math.ceil((n.stop-i)/r)*r,o,s;(o=e.anchor)!=null&&(s=o-(i+r*Math.floor((o-i)/r)),i+=s,a+=s);let c=function(e){let n=Ph(t(e));return n==null?null:na?1/0:(n=Math.max(i,Math.min(n,a-r)),i+r*Math.floor(HC+(n-i)/r))};return c.start=i,c.stop=a,c.step=r,this.value=ah(c,sh(t),e.name||`bin_`+oh(t))}}),qS.Definition={type:`Collect`,metadata:{source:!0},params:[{name:`sort`,type:`compare`}]},U(qS,G,{transform(e,t){let n=t.fork(t.ALL),r=KS(Qb,this.value,n.materialize(n.ADD).add),i=e.sort,a=t.changed()||i&&(e.modified(`sort`)||t.modified(i.fields));return n.visit(n.REM,r.remove),this.modified(a),this.value=n.source=r.data(ix(i),a),t.source&&t.source.root&&(this.value.root=t.source.root),n}}),U(JS,cx),YS.Definition={type:`CountPattern`,metadata:{generates:!0,changes:!0},params:[{name:`field`,type:`field`,required:!0},{name:`case`,type:`enum`,values:[`upper`,`lower`,`mixed`],default:`mixed`},{name:`pattern`,type:`string`,default:`[\\w"]+`},{name:`stopwords`,type:`string`,default:``},{name:`as`,type:`string`,array:!0,length:2,default:[`text`,`count`]}]},U(YS,G,{transform(e,t){let n=t=>n=>{for(var r=yle(s(n),e.case,a)||[],i,c=0,l=r.length;ci[e]=1+(i[e]||0)),u=n(e=>--i[e]);return r?t.visit(t.SOURCE,l):(t.visit(t.ADD,l),t.visit(t.REM,u)),this._finish(t,c)},_parameterCheck(e,t){let n=!1;return(e.modified(`stopwords`)||!this._stop)&&(this._stop=RegExp(`^`+(e.stopwords||``)+`$`,`i`),n=!0),(e.modified(`pattern`)||!this._match)&&(this._match=new RegExp(e.pattern||`[\\w']+`,`g`),n=!0),(e.modified(`field`)||t.modified(e.field.fields))&&(n=!0),n&&(this._counts={}),n},_finish(e,t){let n=this._counts,r=this._tuples||={},i=t[0],a=t[1],o=e.fork(e.NO_SOURCE|e.NO_FIELDS),s,c,l;for(s in n)c=r[s],l=n[s]||0,!c&&l?(r[s]=c=ex({}),c[i]=s,c[a]=l,o.add.push(c)):l===0?(c&&o.rem.push(c),n[s]=null,r[s]=null):c[a]!==l&&(c[a]=l,o.mod.push(c));return o.modifies(t)}}),XS.Definition={type:`Cross`,metadata:{generates:!0},params:[{name:`filter`,type:`expr`},{name:`as`,type:`string`,array:!0,length:2,default:[`a`,`b`]}]},U(XS,G,{transform(e,t){let n=t.fork(t.NO_SOURCE),r=e.as||[`a`,`b`],i=r[0],a=r[1],o=!this.value||t.changed(t.ADD_REM)||e.modified(`as`)||e.modified(`filter`),s=this.value;return o?(s&&(n.rem=s),s=t.materialize(t.SOURCE).source,n.add=this.value=ble(s,i,a,e.filter||Sh)):n.mod=s,n.source=this.value,n.modifies(r)}}),UC={kde:aS,mixture:dS,normal:iS,lognormal:uS,uniform:gS},WC=`distributions`,GC=`function`,KC=`field`,qC=[{key:{function:`normal`},params:[{name:`mean`,type:`number`,default:0},{name:`stdev`,type:`number`,default:1}]},{key:{function:`lognormal`},params:[{name:`mean`,type:`number`,default:0},{name:`stdev`,type:`number`,default:1}]},{key:{function:`uniform`},params:[{name:`min`,type:`number`,default:0},{name:`max`,type:`number`,default:1}]},{key:{function:`kde`},params:[{name:`field`,type:`field`,required:!0},{name:`from`,type:`data`},{name:`bandwidth`,type:`number`,default:0}]}],JC={key:{function:`mixture`},params:[{name:`distributions`,type:`param`,array:!0,params:qC},{name:`weights`,type:`number`,array:!0}]},QS.Definition={type:`Density`,metadata:{generates:!0},params:[{name:`extent`,type:`number`,array:!0,length:2},{name:`steps`,type:`number`},{name:`minsteps`,type:`number`,default:25},{name:`maxsteps`,type:`number`,default:200},{name:`method`,type:`string`,default:`pdf`,values:[`pdf`,`cdf`]},{name:`distribution`,type:`param`,params:qC.concat(JC)},{name:`as`,type:`string`,array:!0,default:[`value`,`density`]}]},U(QS,G,{transform(e,t){let n=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){let r=ZS(e.distribution,xle(t)),i=e.steps||e.minsteps||25,a=e.steps||e.maxsteps||200,o=e.method||`pdf`;o!==`pdf`&&o!==`cdf`&&V(`Invalid density method: `+o),!e.extent&&!r.data&&V(`Missing density extent parameter.`),o=r[o];let s=e.as||[`value`,`density`],c=e.extent||dg(r.data()),l=kS(o,c,i,a).map(e=>{let t={};return t[s[0]]=e[0],t[s[1]]=e[1],ex(t)});this.value&&(n.rem=this.value),this.value=n.add=n.source=l}return n}}),YC=`bin`,tC.Definition={type:`DotBin`,metadata:{modifies:!0},params:[{name:`field`,type:`field`,required:!0},{name:`groupby`,type:`field`,array:!0},{name:`step`,type:`number`},{name:`smooth`,type:`boolean`,default:!1},{name:`as`,type:`string`,default:YC}]},XC=(e,t)=>wg(dg(e,t))/30,U(tC,G,{transform(e,t){if(this.value&&!(e.modified()||t.changed()))return t;let n=t.materialize(t.SOURCE).source,r=eC(t.source,e.groupby,yh),i=e.smooth||!1,a=e.field,o=e.step||XC(n,a),s=ix((e,t)=>a(e)-a(t)),c=e.as||YC,l=r.length,u=1/0,d=-1/0,f=0,p;for(;fd&&(d=t),e[++p][c]=t}return this.value={start:u,stop:d,step:o},t.reflow(!0).modifies(c)}}),U(nC,cx),rC.Definition={type:`Extent`,metadata:{},params:[{name:`field`,type:`field`,required:!0}]},U(rC,G,{transform(e,t){let n=this.value,r=e.field,i=t.changed()||t.modified(r.fields)||e.modified(`field`),a=n[0],o=n[1];if((i||a==null)&&(a=1/0,o=-1/0),t.visit(i?t.SOURCE:t.ADD,e=>{let t=Ph(r(e));t!=null&&(to&&(o=t))}),!Number.isFinite(a)||!Number.isFinite(o)){let e=oh(r);e&&=` for field "${e}"`,t.dataflow.warn(`Infinite extent${e}: [${a}, ${o}]`),a=o=void 0}this.value=[a,o]}}),U(iC,cx,{connect(e){return this.detachSubflow=e.detachSubflow,this.targets().add(e),e.source=this},add(e){this.count+=1,this.value.add.push(e)},rem(e){--this.count,this.value.rem.push(e)},mod(e){this.value.mod.push(e)},init(e){this.value.init(e,e.NO_SOURCE)},evaluate(){return this.value}}),U(aC,G,{activate(e){this._targets[this._targets.active++]=e},subflow(e,t,n,r){let i=this.value,a=fg(i,e)&&i[e],o,s;return a?a.value.stampe&&e.count>0);this.initTargets(e)}},initTargets(e){let t=this._targets,n=t.length,r=e?e.length:0,i=0;for(;ithis.subflow(e,i,t);return this._group=e.group||{},this.initTargets(),t.visit(t.REM,e=>{let t=Qb(e),n=a.get(t);n!==void 0&&(a.delete(t),s(n).rem(e))}),t.visit(t.ADD,e=>{let t=r(e);a.set(Qb(e),t),s(t).add(e)}),o||t.modified(r.fields)?t.visit(t.MOD,e=>{let t=Qb(e),n=a.get(t),i=r(e);n===i?s(i).mod(e):(a.set(t,i),s(n).rem(e),s(i).add(e))}):t.changed(t.MOD)&&t.visit(t.MOD,e=>{s(a.get(Qb(e))).mod(e)}),o&&t.visit(t.REFLOW,e=>{let t=Qb(e),n=a.get(t),i=r(e);n!==i&&(a.set(t,i),s(n).rem(e),s(i).add(e))}),t.clean()?n.runAfter(()=>{this.clean(),a.clean()}):a.empty>n.cleanThreshold&&n.runAfter(a.clean),t}}),U(oC,cx),sC.Definition={type:`Filter`,metadata:{changes:!0},params:[{name:`expr`,type:`expr`,required:!0}]},U(sC,G,{transform(e,t){let n=t.dataflow,r=this.value,i=t.fork(),a=i.add,o=i.rem,s=i.mod,c=e.expr,l=!0;t.visit(t.REM,e=>{let t=Qb(e);r.has(t)?r.delete(t):o.push(e)}),t.visit(t.ADD,t=>{c(t,e)?a.push(t):r.set(Qb(t),1)});function u(t){let n=Qb(t),i=c(t,e),u=r.get(n);i&&u?(r.delete(n),a.push(t)):!i&&!u?(r.set(n,1),o.push(t)):l&&i&&!u&&s.push(t)}return t.visit(t.MOD,u),e.modified()&&(l=!1,t.visit(t.REFLOW,u)),r.empty>n.cleanThreshold&&n.runAfter(r.clean),i}}),cC.Definition={type:`Flatten`,metadata:{generates:!0},params:[{name:`fields`,type:`field`,array:!0,required:!0},{name:`index`,type:`string`},{name:`as`,type:`string`,array:!0}]},U(cC,G,{transform(e,t){let n=t.fork(t.NO_SOURCE),r=e.fields,i=$S(r,e.as||[]),a=e.index||null,o=i.length;return n.rem=this.value,t.visit(t.SOURCE,e=>{let t=r.map(t=>t(e)),s=t.reduce((e,t)=>Math.max(e,t.length),0),c=0,l,u;for(;c{for(let t=0,a;tt[r]=n(t,e))}}),U(dC,G,{transform(e,t){let n=t.fork(t.ALL),r=e.generator,i=this.value,a=e.size-i.length,o,s,c;if(a>0){for(o=[];--a>=0;)o.push(c=ex(r(e))),i.push(c);n.add=n.add.length?n.materialize(n.ADD).add.concat(o):o}else s=i.slice(0,-a),n.rem=n.rem.length?n.materialize(n.REM).rem.concat(s):s,i=i.slice(-a);return n.source=this.value=i,n}}),ZC={value:`value`,median:Toe,mean:Coe,min:$g,max:Qg},QC=[],fC.Definition={type:`Impute`,metadata:{changes:!0},params:[{name:`field`,type:`field`,required:!0},{name:`key`,type:`field`,required:!0},{name:`keyvals`,array:!0},{name:`groupby`,type:`field`,array:!0},{name:`method`,type:`enum`,default:`value`,values:[`value`,`mean`,`median`,`max`,`min`]},{name:`value`,default:0}]},U(fC,G,{transform(e,t){var n=t.fork(t.ALL),r=wle(e),i=Tle(e),a=oh(e.field),o=oh(e.key),s=(e.groupby||[]).map(oh),c=Ele(t.source,e.groupby,e.key,e.keyvals),l=[],u=this.value,d=c.domain.length,f,p,m,h,g,_,v,y,b,x;for(g=0,y=c.length;gn.add(e))):(i=n.value=n.value||this.init(e),t.visit(t.REM,e=>n.rem(e)),t.visit(t.ADD,e=>n.add(e))),n.changes(),t.visit(t.SOURCE,e=>{ug(e,i[n.cellkey(e)].tuple)}),t.reflow(r).modifies(this._outputs)},changes(){let e=this._adds,t=this._mods,n,r;for(n=0,r=this._alen;n{let n=aS(t,o)[s],r=e.counts?t.length:1;kS(n,u||dg(t),d,f).forEach(e=>{let n={};for(let e=0;e(this._pending=ng(e.data),e=>e.touch(this)))}:n.request(e.url,e.format).then(e=>_C(this,t,ng(e.data)))}}),vC.Definition={type:`Lookup`,metadata:{modifies:!0},params:[{name:`index`,type:`index`,params:[{name:`from`,type:`data`,required:!0},{name:`key`,type:`field`,required:!0}]},{name:`values`,type:`field`,array:!0},{name:`fields`,type:`field`,array:!0,required:!0},{name:`as`,type:`string`,array:!0},{name:`default`,default:null}]},U(vC,G,{transform(e,t){let n=e.fields,r=e.index,i=e.values,a=e.default==null?null:e.default,o=e.modified(),s=n.length,c=o?t.SOURCE:t.ADD,l=t,u=e.as,d,f,p;return i?(f=i.length,s>1&&!u&&V(`Multi-field lookup requires explicit "as" parameter.`),u&&u.length!==s*f&&V(`The "as" parameter has too few output field names.`),u||=i.map(oh),d=function(e){for(var t=0,o=0,c,l;tt.modified(e.fields)),c|=p?t.MOD:0),t.visit(c,d),l.modifies(u)}}),U(yC,cx),U(bC,cx),U(xC,G,{transform(e,t){return this.modified(e.modified()),this.value=e,t.fork(t.NO_SOURCE|t.NO_FIELDS)}}),SC.Definition={type:`Pivot`,metadata:{generates:!0,changes:!0},params:[{name:`groupby`,type:`field`,array:!0},{name:`field`,type:`field`,required:!0},{name:`value`,type:`field`,required:!0},{name:`op`,type:`enum`,values:BC,default:`sum`},{name:`limit`,type:`number`,default:0},{name:`key`,type:`field`}]},U(SC,WS,{_transform:WS.prototype.transform,transform(e,t){return this._transform(jle(e,t),t)}}),U(CC,aC,{transform(e,t){let n=e.subflow,r=e.field,i=e=>this.subflow(Qb(e),n,t,e);return(e.modified(`field`)||r&&t.modified(sh(r)))&&V(`PreFacet does not support field modification.`),this.initTargets(),r?(t.visit(t.MOD,e=>{let t=i(e);r(e).forEach(e=>t.mod(e))}),t.visit(t.ADD,e=>{let t=i(e);r(e).forEach(e=>t.add(ex(e)))}),t.visit(t.REM,e=>{let t=i(e);r(e).forEach(e=>t.rem(e))})):(t.visit(t.MOD,e=>i(e).mod(e)),t.visit(t.ADD,e=>i(e).add(e)),t.visit(t.REM,e=>i(e).rem(e))),t.clean()&&t.runAfter(()=>this.clean()),t}}),wC.Definition={type:`Project`,metadata:{generates:!0,changes:!0},params:[{name:`fields`,type:`field`,array:!0},{name:`as`,type:`string`,null:!0,array:!0}]},U(wC,G,{transform(e,t){let n=t.fork(t.NO_SOURCE),r=e.fields,i=$S(e.fields,e.as||[]),a=r?(e,t)=>Ple(e,t,r,i):nx,o;return this.value?o=this.value:(t=t.addAll(),o=this.value={}),t.visit(t.REM,e=>{let t=Qb(e);n.rem.push(o[t]),o[t]=null}),t.visit(t.ADD,e=>{let t=a(e,ex({}));o[Qb(e)]=t,n.add.push(t)}),t.visit(t.MOD,e=>{n.mod.push(a(e,o[Qb(e)]))}),n}}),U(TC,G,{transform(e,t){return this.value=e.value,e.modified(`value`)?t.fork(t.NO_SOURCE|t.NO_FIELDS):t.StopPropagation}}),EC.Definition={type:`Quantile`,metadata:{generates:!0,changes:!0},params:[{name:`groupby`,type:`field`,array:!0},{name:`field`,type:`field`,required:!0},{name:`probs`,type:`number`,array:!0},{name:`step`,type:`number`,default:.01},{name:`as`,type:`string`,array:!0,default:[`prob`,`value`]}]},$C=1e-14,U(EC,G,{transform(e,t){let n=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=e.as||[`prob`,`value`];if(this.value&&!e.modified()&&!t.changed())return n.source=this.value,n;let i=t.materialize(t.SOURCE).source,a=eC(i,e.groupby,e.field),o=(e.groupby||[]).map(oh),s=[],c=e.step||.01,l=e.probs||n_(c/2,1-$C,c),u=l.length;return a.forEach(e=>{let t=Jx(e,l);for(let n=0;n{let t=Qb(e);n.rem.push(r[t]),r[t]=null}),t.visit(t.ADD,e=>{let t=tx(e);r[Qb(e)]=t,n.add.push(t)}),t.visit(t.MOD,e=>{let t=r[Qb(e)];for(let r in e)t[r]=e[r],n.modifies(r);n.mod.push(t)})),n}}),OC.Definition={type:`Sample`,metadata:{},params:[{name:`size`,type:`number`,default:1e3}]},U(OC,G,{transform(e,t){let n=t.fork(t.NO_SOURCE),r=e.modified(`size`),i=e.size,a=this.value.reduce((e,t)=>(e[Qb(t)]=1,e),{}),o=this.value,s=this.count,c=0;function l(e){let t,r;o.length=c&&(t=o[r],a[Qb(t)]&&n.rem.push(t),o[r]=e)),++s}if(t.rem.length&&(t.visit(t.REM,e=>{let t=Qb(e);a[t]&&(a[t]=-1,n.rem.push(e)),--s}),o=o.filter(e=>a[Qb(e)]!==-1)),(t.rem.length||r)&&o.length{a[Qb(e)]||l(e)}),c=-1),r&&o.length>i){let e=o.length-i;for(let t=0;t{a[Qb(e)]&&n.mod.push(e)}),t.add.length&&t.visit(t.ADD,l),(t.add.length||c<0)&&(n.add=o.filter(e=>!a[Qb(e)])),this.count=s,this.value=n.source=o,n}}),kC.Definition={type:`Sequence`,metadata:{generates:!0,changes:!0},params:[{name:`start`,type:`number`,required:!0},{name:`stop`,type:`number`,required:!0},{name:`step`,type:`number`,default:1},{name:`as`,type:`string`,default:`data`}]},U(kC,G,{transform(e,t){if(this.value&&!e.modified())return;let n=t.materialize().fork(t.MOD),r=e.as||`data`;return n.rem=this.value?t.rem.concat(this.value):t.rem,this.value=n_(e.start,e.stop,e.step||1).map(e=>{let t={};return t[r]=e,ex(t)}),n.add=t.add.concat(this.value),n}}),U(AC,G,{transform(e,t){return this.value=t.source,t.changed()?t.fork(t.NO_SOURCE|t.NO_FIELDS):t.StopPropagation}}),ew=[`unit0`,`unit1`],jC.Definition={type:`TimeUnit`,metadata:{modifies:!0},params:[{name:`field`,type:`field`,required:!0},{name:`interval`,type:`boolean`,default:!0},{name:`units`,type:`enum`,values:ty,array:!0},{name:`step`,type:`number`,default:1},{name:`maxbins`,type:`number`,default:40},{name:`extent`,type:`date`,array:!0},{name:`inferUnits`,type:`boolean`,default:!1},{name:`timezone`,type:`enum`,default:`local`,values:[`local`,`utc`]},{name:`as`,type:`string`,array:!0,length:2,default:ew}]},U(jC,G,{transform(e,t){let n=e.field,r=e.interval!==!1,i=e.timezone===`utc`,a=this._floor(e,t),o=(i?Iv:Fv)(a.unit).offset,s=e.as||ew,c=s[0],l=s[1],u=a.step,d=a.start||1/0,f=a.stop||-1/0,p=t.ADD;return(e.modified()||t.changed(t.REM)||t.modified(sh(n)))&&(t=t.reflow(!0),p=t.SOURCE,d=1/0,f=-1/0),t.visit(p,e=>{let t=n(e),i,s;t==null?(e[c]=null,r&&(e[l]=null)):(e[c]=i=s=a(t),r&&(e[l]=s=o(i,u)),if&&(f=s))}),a.start=d,a.stop=f,t.modifies(r?s:c)},_floor(e,t){let n=e.timezone===`utc`;e.inferUnits&&(e.units||e.step!=null||e.maxbins!=null||e.extent)&&t.dataflow.warn(`TimeUnit inferUnits overrides units, step, maxbins and extent.`);let{units:r,step:i}=e.inferUnits?Wv(t.materialize(t.SOURCE).source,e.field,n):e.units?{units:e.units,step:e.step||1}:Uv({extent:e.extent||dg(t.materialize(t.SOURCE).source,e.field),maxbins:e.maxbins}),a=vv(r),o=this.value||{},s=(n?Pv:Nv)(a,i);return s.unit=Mh(a),s.units=a,s.step=i,s.start=o.start,s.stop=o.stop,this.value=s}}),U(MC,G,{transform(e,t){let n=t.dataflow,r=e.field,i=this.value,a=e=>i.set(r(e),e),o=!0;return e.modified(`field`)||t.modified(r.fields)?(i.clear(),t.visit(t.SOURCE,a)):t.changed()?(t.visit(t.REM,e=>i.delete(r(e))),t.visit(t.ADD,a)):o=!1,this.modified(o),i.empty>n.cleanThreshold&&n.runAfter(i.clean),t.fork()}}),U(NC,G,{transform(e,t){(!this.value||e.modified(`field`)||e.modified(`sort`)||t.changed()||e.sort&&t.modified(e.sort.fields))&&(this.value=(e.sort?t.source.slice().sort(ix(e.sort)):t.source).map(e.field))}}),tw={row_number:function(){return{next:e=>e.index+1}},rank:function(){let e;return{init:()=>e=1,next:t=>{let n=t.index,r=t.data;return n&&t.compare(r[n-1],r[n])?e=n+1:e}}},dense_rank:function(){let e;return{init:()=>e=1,next:t=>{let n=t.index,r=t.data;return n&&t.compare(r[n-1],r[n])?++e:e}}},percent_rank:function(){let e=tw.rank(),t=e.next;return{init:e.init,next:e=>(t(e)-1)/(e.data.length-1)}},cume_dist:function(){let e;return{init:()=>e=0,next:t=>{let n=t.data,r=t.compare,i=t.index;if(e0||V(`ntile num must be greater than zero.`);let n=tw.cume_dist(),r=n.next;return{init:n.init,next:e=>Math.ceil(t*r(e))}},lag:function(e,t){return t=+t||1,{next:n=>{let r=n.index-t;return r>=0?e(n.data[r]):null}}},lead:function(e,t){return t=+t||1,{next:n=>{let r=n.index+t,i=n.data;return re(t.data[t.i0])}},last_value:function(e){return{next:t=>e(t.data[t.i1-1])}},nth_value:function(e,t){return t=+t,t>0||V(`nth_value nth must be greater than zero.`),{next:n=>{let r=n.i0+(t-1);return rt=null,next:n=>{let r=e(n.data[n.index]);return r==null?t:t=r}}},next_value:function(e){let t,n;return{init:()=>(t=null,n=-1),next:r=>{let i=r.data;return r.index<=n?t:(n=Ile(e,i,r.index))<0?(n=i.length,t=null):t=e(i[n])}}}},nw=Object.keys(tw),rw=PC.prototype,rw.init=function(){this.windows.forEach(e=>e.init()),this.cell&&this.cell.init()},rw.update=function(e,t){let n=this.cell,r=this.windows,i=e.data,a=r&&r.length,o;if(n){for(o=e.p0;othis.group(i(e)),o=this.state;(!o||n)&&(o=this.state=new PC(e)),n||t.modified(o.inputs)?(this.value={},t.visit(t.SOURCE,e=>a(e).add(e))):(t.visit(t.REM,e=>a(e).remove(e)),t.visit(t.ADD,e=>a(e).add(e)));for(let t=0,n=this._mlen;t{}));function Hle(e){return e>1?0:e<-1?mw:Math.acos(e)}function ow(e){return e>=1?hw:e<=-1?-hw:Math.asin(e)}var sw,cw,lw,uw,dw,fw,pw,mw,hw,gw,_w=o((()=>{sw=Math.abs,cw=Math.atan2,lw=Math.cos,uw=Math.max,dw=Math.min,fw=Math.sin,pw=Math.sqrt,mw=Math.PI,hw=mw/2,gw=2*mw}));function vw(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw Error(`invalid digits: ${e}`);if(t>15)return vw;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;t{bw=Math.PI,xw=2*bw,Sw=1e-6,Cw=xw-Sw,ww=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?vw:Ule(e)}moveTo(e,t){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,t){this._append`L${this._x1=+e},${this._y1=+t}`}quadraticCurveTo(e,t,n,r){this._append`Q${+e},${+t},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(e,t,n,r,i,a){this._append`C${+e},${+t},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(e,t,n,r,i){if(e=+e,t=+t,n=+n,r=+r,i=+i,i<0)throw Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(this._x1===null)this._append`M${this._x1=e},${this._y1=t}`;else if(d>Sw)if(!(Math.abs(u*s-c*l)>Sw)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((bw-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>Sw&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>Sw||Math.abs(this._y1-l)>Sw)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%xw+xw),d>Cw?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>Sw&&this._append`A${n},${n},0,${+(d>=bw)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}},yw.prototype=ww.prototype})),Tw=o((()=>{Wle()}));function Ew(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new ww(t)}var Dw=o((()=>{Tw()}));function Gle(e){return e.innerRadius}function Kle(e){return e.outerRadius}function qle(e){return e.startAngle}function Jle(e){return e.endAngle}function Yle(e){return e&&e.padAngle}function Xle(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function Ow(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/pw(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=v*v+y*y,x=i-a,S=f*h-m*p,C=(y<0?-1:1)*pw(uw(0,x*x*b-S*S)),w=(S*y-v*C)/b,T=(-S*v-y*C)/b,E=(S*y+v*C)/b,D=(-S*v+y*C)/b,O=w-g,k=T-_,A=E-g,j=D-_;return O*O+k*k>A*A+j*j&&(w=E,T=D),{cx:w,cy:T,x01:-u,y01:-d,x11:w*(i/x-1),y11:T*(i/x-1)}}function Zle(){var e=Gle,t=Kle,n=iw(0),r=null,i=qle,a=Jle,o=Yle,s=null,c=Ew(l);function l(){var l,u,d=+e.apply(this,arguments),f=+t.apply(this,arguments),p=i.apply(this,arguments)-hw,m=a.apply(this,arguments)-hw,h=sw(m-p),g=m>p;if(s||=l=c(),f1e-12))s.moveTo(0,0);else if(h>gw-1e-12)s.moveTo(f*lw(p),f*fw(p)),s.arc(0,0,f,p,m,!g),d>1e-12&&(s.moveTo(d*lw(m),d*fw(m)),s.arc(0,0,d,m,p,g));else{var _=p,v=m,y=p,b=m,x=h,S=h,C=o.apply(this,arguments)/2,w=C>1e-12&&(r?+r.apply(this,arguments):pw(d*d+f*f)),T=dw(sw(f-d)/2,+n.apply(this,arguments)),E=T,D=T,O,k;if(w>1e-12){var A=ow(w/d*fw(C)),j=ow(w/f*fw(C));(x-=A*2)>1e-12?(A*=g?1:-1,y+=A,b-=A):(x=0,y=b=(p+m)/2),(S-=j*2)>1e-12?(j*=g?1:-1,_+=j,v-=j):(S=0,_=v=(p+m)/2)}var M=f*lw(_),ee=f*fw(_),N=d*lw(b),te=d*fw(b);if(T>1e-12){var ne=f*lw(v),P=f*fw(v),re=d*lw(y),F=d*fw(y),ie;if(h1e-12?D>1e-12?(O=Ow(re,F,M,ee,f,D,g),k=Ow(ne,P,N,te,f,D,g),s.moveTo(O.cx+O.x01,O.cy+O.y01),D1e-12)||!(x>1e-12)?s.lineTo(N,te):E>1e-12?(O=Ow(N,te,ne,P,d,-E,g),k=Ow(M,ee,re,F,d,-E,g),s.lineTo(O.cx+O.x01,O.cy+O.y01),E{aw(),_w(),Dw()}));function kw(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}var Aw=o((()=>{Array.prototype.slice}));function jw(e){this._context=e}function Mw(e){return new jw(e)}var Nw=o((()=>{jw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}}}));function Pw(e){return e[0]}function Fw(e){return e[1]}var Iw=o((()=>{}));function Lw(e,t){var n=iw(!0),r=null,i=Mw,a=null,o=Ew(s);e=typeof e==`function`?e:e===void 0?Pw:iw(e),t=typeof t==`function`?t:t===void 0?Fw:iw(t);function s(s){var c,l=(s=kw(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c{Aw(),aw(),Nw(),Dw(),Iw()}));function zw(e,t,n){var r=null,i=iw(!0),a=null,o=Mw,s=null,c=Ew(l);e=typeof e==`function`?e:e===void 0?Pw:iw(+e),t=typeof t==`function`?t:iw(t===void 0?0:+t),n=typeof n==`function`?n:n===void 0?Fw:iw(+n);function l(l){var u,d,f,p=(l=kw(l)).length,m,h=!1,g,_=Array(p),v=Array(p);for(a??(s=o(g=c())),u=0;u<=p;++u){if(!(u=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return Lw().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:iw(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:iw(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:iw(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:iw(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:iw(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:iw(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:iw(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var $le=o((()=>{Aw(),aw(),Nw(),Rw(),Dw(),Iw()})),Bw,Vw=o((()=>{_w(),Bw={draw(e,t){let n=pw(t/mw);e.moveTo(n,0),e.arc(0,0,n,0,gw)}}}));function eue(e,t){let n=null,r=Ew(i);e=typeof e==`function`?e:iw(e||Bw),t=typeof t==`function`?t:iw(t===void 0?64:+t);function i(){let i;if(n||=i=r(),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),i)return n=null,i+``||null}return i.type=function(t){return arguments.length?(e=typeof t==`function`?t:iw(t),i):e},i.size=function(e){return arguments.length?(t=typeof e==`function`?e:iw(+e),i):t},i.context=function(e){return arguments.length?(n=e??null,i):n},i}var tue=o((()=>{aw(),Dw(),Vw()}));function Hw(){}var Uw=o((()=>{}));function Ww(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function Gw(e){this._context=e}function nue(e){return new Gw(e)}var Kw=o((()=>{Gw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Ww(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Ww(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}}}));function qw(e){this._context=e}function rue(e){return new qw(e)}var iue=o((()=>{Uw(),Kw(),qw.prototype={areaStart:Hw,areaEnd:Hw,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Ww(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}}}));function Jw(e){this._context=e}function aue(e){return new Jw(e)}var oue=o((()=>{Kw(),Jw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Ww(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}}}));function Yw(e,t){this._basis=new Gw(e),this._beta=t}var Xw,sue=o((()=>{Kw(),Yw.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var r=e[0],i=t[0],a=e[n]-r,o=t[n]-i,s=-1,c;++s<=n;)c=s/n,this._basis.point(this._beta*e[s]+(1-this._beta)*(r+c*a),this._beta*t[s]+(1-this._beta)*(i+c*o));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}},Xw=(function e(t){function n(e){return t===1?new Gw(e):new Yw(e,t)}return n.beta=function(t){return e(+t)},n})(.85)}));function Zw(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function Qw(e,t){this._context=e,this._k=(1-t)/6}var $w,eT=o((()=>{Qw.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Zw(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:Zw(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},$w=(function e(t){function n(e){return new Qw(e,t)}return n.tension=function(t){return e(+t)},n})(0)}));function tT(e,t){this._context=e,this._k=(1-t)/6}var nT,rT=o((()=>{Uw(),eT(),tT.prototype={areaStart:Hw,areaEnd:Hw,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:Zw(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},nT=(function e(t){function n(e){return new tT(e,t)}return n.tension=function(t){return e(+t)},n})(0)}));function iT(e,t){this._context=e,this._k=(1-t)/6}var aT,oT=o((()=>{eT(),iT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Zw(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},aT=(function e(t){function n(e){return new iT(e,t)}return n.tension=function(t){return e(+t)},n})(0)}));function sT(e,t,n){var r=e._x1,i=e._y1,a=e._x2,o=e._y2;if(e._l01_a>1e-12){var s=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,c=3*e._l01_a*(e._l01_a+e._l12_a);r=(r*s-e._x0*e._l12_2a+e._x2*e._l01_2a)/c,i=(i*s-e._y0*e._l12_2a+e._y2*e._l01_2a)/c}if(e._l23_a>1e-12){var l=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,u=3*e._l23_a*(e._l23_a+e._l12_a);a=(a*l+e._x1*e._l23_2a-t*e._l12_2a)/u,o=(o*l+e._y1*e._l23_2a-n*e._l12_2a)/u}e._context.bezierCurveTo(r,i,a,o,e._x2,e._y2)}function cT(e,t){this._context=e,this._alpha=t}var lT,uT=o((()=>{_w(),eT(),cT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=(n*n+r*r)**+this._alpha)}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:sT(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},lT=(function e(t){function n(e){return t?new cT(e,t):new Qw(e,0)}return n.alpha=function(t){return e(+t)},n})(.5)}));function dT(e,t){this._context=e,this._alpha=t}var fT,cue=o((()=>{rT(),Uw(),uT(),dT.prototype={areaStart:Hw,areaEnd:Hw,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=(n*n+r*r)**+this._alpha)}switch(this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:sT(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},fT=(function e(t){function n(e){return t?new dT(e,t):new tT(e,0)}return n.alpha=function(t){return e(+t)},n})(.5)}));function pT(e,t){this._context=e,this._alpha=t}var mT,lue=o((()=>{oT(),uT(),pT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=(n*n+r*r)**+this._alpha)}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:sT(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},mT=(function e(t){function n(e){return t?new pT(e,t):new iT(e,0)}return n.alpha=function(t){return e(+t)},n})(.5)}));function hT(e){this._context=e}function uue(e){return new hT(e)}var due=o((()=>{Uw(),hT.prototype={areaStart:Hw,areaEnd:Hw,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}}}));function gT(e){return e<0?-1:1}function _T(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(gT(a)+gT(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function vT(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function yT(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function bT(e){this._context=e}function xT(e){this._context=new ST(e)}function ST(e){this._context=e}function fue(e){return new bT(e)}function pue(e){return new xT(e)}var mue=o((()=>{bT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:yT(this,this._t0,vT(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,yT(this,vT(this,n=_T(this,e,t)),n);break;default:yT(this,this._t0,n=_T(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}},(xT.prototype=Object.create(bT.prototype)).point=function(e,t){bT.prototype.point.call(this,t,e)},ST.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}}}));function CT(e){this._context=e}function wT(e){var t,n=e.length-1,r,i=Array(n),a=Array(n),o=Array(n);for(i[0]=0,a[0]=2,o[0]=e[0]+2*e[1],t=1;t=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t{CT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=wT(e),i=wT(t),a=0,o=1;o{TT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}this._x=e,this._y=t}}})),xue=o((()=>{Qle(),$le(),Rw(),Aw(),aw(),_w(),Nw(),Dw(),tue(),Vw(),iue(),oue(),Kw(),sue(),rT(),oT(),eT(),cue(),lue(),uT(),due(),mue(),gue(),bue()}));function ET(e,t){if(typeof document<`u`&&document.createElement){let n=document.createElement(`canvas`);if(n&&n.getContext)return n.width=e,n.height=t,n}return null}var DT,OT=o((()=>{DT=()=>typeof Image<`u`?Image:null}));function kT(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function AT(e,t){switch(arguments.length){case 0:break;case 1:typeof e==`function`?this.interpolator(e):this.range(e);break;default:this.domain(e),typeof t==`function`?this.interpolator(t):this.range(t);break}return this}var jT=o((()=>{}));function MT(){var e=new Gg,t=[],n=[],r=NT;function i(i){let a=e.get(i);if(a===void 0){if(r!==NT)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new Gg;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return MT(t,n).unknown(r)},kT.apply(i,arguments),i}var NT,Sue=o((()=>{r_(),jT(),NT=Symbol(`implicit`)}));function PT(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function FT(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}var IT=o((()=>{}));function LT(){}function RT(){return this.rgb().formatHex()}function Cue(){return this.rgb().formatHex8()}function wue(){return QT(this).formatHsl()}function zT(){return this.rgb().formatRgb()}function BT(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=lE.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?VT(t):n===3?new GT(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?HT(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?HT(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=uE.exec(e))?new GT(t[1],t[2],t[3],1):(t=dE.exec(e))?new GT(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=fE.exec(e))?HT(t[1],t[2],t[3],t[4]):(t=pE.exec(e))?HT(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=mE.exec(e))?ZT(t[1],t[2]/100,t[3]/100,1):(t=hE.exec(e))?ZT(t[1],t[2]/100,t[3]/100,t[4]):gE.hasOwnProperty(e)?VT(gE[e]):e===`transparent`?new GT(NaN,NaN,NaN,0):null}function VT(e){return new GT(e>>16&255,e>>8&255,e&255,1)}function HT(e,t,n,r){return r<=0&&(e=t=n=NaN),new GT(e,t,n,r)}function UT(e){return e instanceof LT||(e=BT(e)),e?(e=e.rgb(),new GT(e.r,e.g,e.b,e.opacity)):new GT}function WT(e,t,n,r){return arguments.length===1?UT(e):new GT(e,t,n,r??1)}function GT(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function KT(){return`#${XT(this.r)}${XT(this.g)}${XT(this.b)}`}function Tue(){return`#${XT(this.r)}${XT(this.g)}${XT(this.b)}${XT((isNaN(this.opacity)?1:this.opacity)*255)}`}function qT(){let e=JT(this.opacity);return`${e===1?`rgb(`:`rgba(`}${YT(this.r)}, ${YT(this.g)}, ${YT(this.b)}${e===1?`)`:`, ${e})`}`}function JT(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function YT(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function XT(e){return e=YT(e),(e<16?`0`:``)+e.toString(16)}function ZT(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new eE(e,t,n,r)}function QT(e){if(e instanceof eE)return new eE(e.h,e.s,e.l,e.opacity);if(e instanceof LT||(e=BT(e)),!e)return new eE;if(e instanceof eE)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new eE(o,s,c,e.opacity)}function $T(e,t,n,r){return arguments.length===1?QT(e):new eE(e,t,n,r??1)}function eE(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function tE(e){return e=(e||0)%360,e<0?e+360:e}function nE(e){return Math.max(0,Math.min(1,e||0))}function rE(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var iE,aE,oE,sE,cE,lE,uE,dE,fE,pE,mE,hE,gE,_E=o((()=>{IT(),iE=.7,aE=1/iE,oE=`\\s*([+-]?\\d+)\\s*`,sE=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,cE=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,lE=/^#([0-9a-f]{3,8})$/,uE=RegExp(`^rgb\\(${oE},${oE},${oE}\\)$`),dE=RegExp(`^rgb\\(${cE},${cE},${cE}\\)$`),fE=RegExp(`^rgba\\(${oE},${oE},${oE},${sE}\\)$`),pE=RegExp(`^rgba\\(${cE},${cE},${cE},${sE}\\)$`),mE=RegExp(`^hsl\\(${sE},${cE},${cE}\\)$`),hE=RegExp(`^hsla\\(${sE},${cE},${cE},${sE}\\)$`),gE={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},PT(LT,BT,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:RT,formatHex:RT,formatHex8:Cue,formatHsl:wue,formatRgb:zT,toString:zT}),PT(GT,WT,FT(LT,{brighter(e){return e=e==null?aE:aE**+e,new GT(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?iE:iE**+e,new GT(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new GT(YT(this.r),YT(this.g),YT(this.b),JT(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:KT,formatHex:KT,formatHex8:Tue,formatRgb:qT,toString:qT})),PT(eE,$T,FT(LT,{brighter(e){return e=e==null?aE:aE**+e,new eE(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?iE:iE**+e,new eE(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new GT(rE(e>=240?e-240:e+120,i,r),rE(e,i,r),rE(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new eE(tE(this.h),nE(this.s),nE(this.l),JT(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=JT(this.opacity);return`${e===1?`hsl(`:`hsla(`}${tE(this.h)}, ${nE(this.s)*100}%, ${nE(this.l)*100}%${e===1?`)`:`, ${e})`}`}}))})),vE,yE,bE=o((()=>{vE=Math.PI/180,yE=180/Math.PI}));function xE(e){if(e instanceof CE)return new CE(e.l,e.a,e.b,e.opacity);if(e instanceof kE)return AE(e);e instanceof GT||(e=UT(e));var t=DE(e.r),n=DE(e.g),r=DE(e.b),i=wE((.2225045*t+.7168786*n+.0606169*r)/NE),a,o;return t===n&&n===r?a=o=i:(a=wE((.4360747*t+.3850649*n+.1430804*r)/ME),o=wE((.0139322*t+.0971045*n+.7141733*r)/PE)),new CE(116*i-16,500*(a-i),200*(i-o),e.opacity)}function SE(e,t,n,r){return arguments.length===1?xE(e):new CE(e,t,n,r??1)}function CE(e,t,n,r){this.l=+e,this.a=+t,this.b=+n,this.opacity=+r}function wE(e){return e>RE?e**(1/3):e/LE+FE}function TE(e){return e>IE?e*e*e:LE*(e-FE)}function EE(e){return 255*(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055)}function DE(e){return(e/=255)<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Eue(e){if(e instanceof kE)return new kE(e.h,e.c,e.l,e.opacity);if(e instanceof CE||(e=xE(e)),e.a===0&&e.b===0)return new kE(NaN,0{IT(),_E(),bE(),jE=18,ME=.96422,NE=1,PE=.82521,FE=4/29,IE=6/29,LE=3*IE*IE,RE=IE*IE*IE,PT(CE,SE,FT(LT,{brighter(e){return new CE(this.l+jE*(e??1),this.a,this.b,this.opacity)},darker(e){return new CE(this.l-jE*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,t=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return t=ME*TE(t),e=NE*TE(e),n=PE*TE(n),new GT(EE(3.1338561*t-1.6168667*e-.4906146*n),EE(-.9787684*t+1.9161415*e+.033454*n),EE(.0719453*t-.2289914*e+1.4052427*n),this.opacity)}})),PT(kE,OE,FT(LT,{brighter(e){return new kE(this.h,this.c,this.l+jE*(e??1),this.opacity)},darker(e){return new kE(this.h,this.c,this.l-jE*(e??1),this.opacity)},rgb(){return AE(this).rgb()}}))}));function Oue(e){if(e instanceof BE)return new BE(e.h,e.s,e.l,e.opacity);e instanceof GT||(e=UT(e));var t=e.r/255,n=e.g/255,r=e.b/255,i=(JE*r+KE*t-qE*n)/(JE+KE-qE),a=r-i,o=(GE*(n-i)-UE*a)/WE,s=Math.sqrt(o*o+a*a)/(GE*i*(1-i)),c=s?Math.atan2(o,a)*yE-120:NaN;return new BE(c<0?c+360:c,s,i,e.opacity)}function zE(e,t,n,r){return arguments.length===1?Oue(e):new BE(e,t,n,r??1)}function BE(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}var VE,HE,UE,WE,GE,KE,qE,JE,kue=o((()=>{IT(),_E(),bE(),VE=-.14861,HE=1.78277,UE=-.29227,WE=-.90649,GE=1.97294,KE=GE*WE,qE=GE*HE,JE=HE*UE-WE*VE,PT(BE,zE,FT(LT,{brighter(e){return e=e==null?aE:aE**+e,new BE(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?iE:iE**+e,new BE(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=isNaN(this.h)?0:(this.h+120)*vE,t=+this.l,n=isNaN(this.s)?0:this.s*t*(1-t),r=Math.cos(e),i=Math.sin(e);return new GT(255*(t+n*(VE*r+HE*i)),255*(t+n*(UE*r+WE*i)),255*(t+GE*r*n),this.opacity)}}))})),YE=o((()=>{_E(),Due(),kue()}));function Aue(e,t,n,r,i){var a=e*e,o=a*e;return((1-3*e+3*a-o)*t+(4-6*a+3*o)*n+(1+3*e+3*a-3*o)*r+o*i)/6}function jue(e){var t=e.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),i=e[r],a=e[r+1],o=r>0?e[r-1]:2*i-a,s=r{}));function Mue(e){var t=e.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*t),i=e[(r+t-1)%t],a=e[r%t],o=e[(r+1)%t],s=e[(r+2)%t];return Aue((n-r/t)*t,i,a,o,s)}}var Nue=o((()=>{XE()})),ZE,Pue=o((()=>{ZE=e=>()=>e}));function Fue(e,t){return function(n){return e+n*t}}function Iue(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function QE(e,t){var n=t-e;return n?Fue(e,n>180||n<-180?n-360*Math.round(n/360):n):ZE(isNaN(e)?t:e)}function Lue(e){return(e=+e)==1?$E:function(t,n){return n-t?Iue(t,n,e):ZE(isNaN(t)?n:t)}}function $E(e,t){var n=t-e;return n?Fue(e,n):ZE(isNaN(e)?t:e)}var eD=o((()=>{Pue()}));function Rue(e){return function(t){var n=t.length,r=Array(n),i=Array(n),a=Array(n),o,s;for(o=0;o{YE(),XE(),Nue(),eD(),tD=(function e(t){var n=Lue(t);function r(e,t){var r=n((e=WT(e)).r,(t=WT(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=$E(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1),zue=Rue(jue),Bue=Rue(Mue)}));function nD(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i{}));function Uue(e,t){return(Hue(t)?nD:Wue)(e,t)}function Wue(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o{lD(),rD()}));function Kue(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}var que=o((()=>{}));function iD(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var aD=o((()=>{}));function Jue(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=cD(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var Yue=o((()=>{lD()}));function Xue(e){return function(){return e}}function Zue(e){return function(t){return e(t)+``}}function Que(e,t){var n=oD.lastIndex=sD.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=oD.exec(e))&&(i=sD.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:iD(r,i)})),n=sD.lastIndex;return n{aD(),oD=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,sD=new RegExp(oD.source,`g`)}));function cD(e,t){var n=typeof t,r;return t==null||n===`boolean`?ZE(t):(n===`number`?iD:n===`string`?(r=BT(t))?(t=r,tD):Que:t instanceof BT?tD:t instanceof Date?Kue:Hue(t)?nD:Array.isArray(t)?Wue:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?Jue:iD)(e,t)}var lD=o((()=>{YE(),Vue(),Gue(),que(),aD(),Yue(),$ue(),Pue(),rD()}));function ede(e){var t=e.length;return function(n){return e[Math.max(0,Math.min(t-1,Math.floor(n*t)))]}}var tde=o((()=>{}));function nde(e,t){var n=QE(+e,+t);return function(e){var t=n(e);return t-360*Math.floor(t/360)}}var rde=o((()=>{eD()}));function uD(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var ide=o((()=>{}));function ade(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r{dD=180/Math.PI,fD={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1}}));function sde(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?fD:ade(t.a,t.b,t.c,t.d,t.e,t.f)}function cde(e){return e==null||(pD||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),pD.setAttribute(`transform`,e),!(e=pD.transform.baseVal.consolidate()))?fD:(e=e.matrix,ade(e.a,e.b,e.c,e.d,e.e,e.f))}var pD,lde=o((()=>{ode()}));function ude(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:iD(e,i)},{i:c-2,x:iD(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:iD(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:iD(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:iD(e,n)},{i:s-2,x:iD(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t{aD(),lde(),dde=ude(sde,`px, `,`px)`,`deg)`),fde=ude(cde,`, `,`)`,`)`)}));function mde(e){return((e=Math.exp(e))+1/e)/2}function hde(e){return((e=Math.exp(e))-1/e)/2}function gde(e){return((e=Math.exp(2*e))-1)/(e+1)}var _de,vde,yde=o((()=>{_de=1e-12,vde=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<_de)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=mde(y),c=s/(n*g)*(i*gde(t*r+y)-hde(y));return[a+c*d,o+c*f,s*i/mde(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4)}));function bde(e){return function(t,n){var r=e((t=$T(t)).h,(n=$T(n)).h),i=$E(t.s,n.s),a=$E(t.l,n.l),o=$E(t.opacity,n.opacity);return function(e){return t.h=r(e),t.s=i(e),t.l=a(e),t.opacity=o(e),t+``}}}var xde,Sde,Cde=o((()=>{YE(),eD(),xde=bde(QE),Sde=bde($E)}));function wde(e,t){var n=$E((e=SE(e)).l,(t=SE(t)).l),r=$E(e.a,t.a),i=$E(e.b,t.b),a=$E(e.opacity,t.opacity);return function(t){return e.l=n(t),e.a=r(t),e.b=i(t),e.opacity=a(t),e+``}}var Tde=o((()=>{YE(),eD()}));function Ede(e){return function(t,n){var r=e((t=OE(t)).h,(n=OE(n)).h),i=$E(t.c,n.c),a=$E(t.l,n.l),o=$E(t.opacity,n.opacity);return function(e){return t.h=r(e),t.c=i(e),t.l=a(e),t.opacity=o(e),t+``}}}var Dde,Ode,kde=o((()=>{YE(),eD(),Dde=Ede(QE),Ode=Ede($E)}));function Ade(e){return(function t(n){n=+n;function r(t,r){var i=e((t=zE(t)).h,(r=zE(r)).h),a=$E(t.s,r.s),o=$E(t.l,r.l),s=$E(t.opacity,r.opacity);return function(e){return t.h=i(e),t.s=a(e),t.l=o(e**+n),t.opacity=s(e),t+``}}return r.gamma=t,r})(1)}var jde,Mde,Nde=o((()=>{YE(),eD(),jde=Ade(QE),Mde=Ade($E)}));function mD(e,t){t===void 0&&(t=e,e=cD);for(var n=0,r=t.length-1,i=t[0],a=Array(r<0?0:r);n{lD()}));function Fde(e,t){for(var n=Array(t),r=0;r{})),Lde=c({interpolate:()=>cD,interpolateArray:()=>Uue,interpolateBasis:()=>jue,interpolateBasisClosed:()=>Mue,interpolateCubehelix:()=>jde,interpolateCubehelixLong:()=>Mde,interpolateDate:()=>Kue,interpolateDiscrete:()=>ede,interpolateHcl:()=>Dde,interpolateHclLong:()=>Ode,interpolateHsl:()=>xde,interpolateHslLong:()=>Sde,interpolateHue:()=>nde,interpolateLab:()=>wde,interpolateNumber:()=>iD,interpolateNumberArray:()=>nD,interpolateObject:()=>Jue,interpolateRgb:()=>tD,interpolateRgbBasis:()=>zue,interpolateRgbBasisClosed:()=>Bue,interpolateRound:()=>uD,interpolateString:()=>Que,interpolateTransformCss:()=>dde,interpolateTransformSvg:()=>fde,interpolateZoom:()=>vde,piecewise:()=>mD,quantize:()=>Fde}),hD=o((()=>{lD(),Gue(),XE(),Nue(),que(),tde(),rde(),aD(),rD(),Yue(),ide(),$ue(),pde(),yde(),Vue(),Cde(),Tde(),kde(),Nde(),Pde(),Ide()}));function Rde(e){return function(){return e}}var zde=o((()=>{}));function gD(e){return+e}var _D=o((()=>{}));function vD(e){return e}function yD(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Rde(isNaN(t)?NaN:.5)}function Bde(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function Vde(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i2?Hde:Vde,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),iD))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,gD),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=uD,u()},d.clamp=function(e){return arguments.length?(o=e?!0:vD,u()):o!==vD},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function Ude(){return xD()(vD,vD)}var SD,CD=o((()=>{r_(),hD(),zde(),_D(),SD=[0,1]}));function Wde(e,t,n,r){var i=Zg(e,t,n),a;switch(r=c_(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=ose(i,o))&&(r.precision=a),g_(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=cse(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=ise(i))&&(r.precision=a-(r.type===`%`)*2);break}return h_(r)}var Gde=o((()=>{r_(),__()}));function wD(e){var t=e.domain;return e.ticks=function(e){var n=t();return Yg(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Wde(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s0;){if(l=Xg(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function Kde(){var e=Ude();return e.copy=function(){return bD(e,Kde())},kT.apply(e,arguments),wD(e)}var TD=o((()=>{r_(),CD(),jT(),Gde()}));function qde(e){var t;function n(e){return e==null||isNaN(e=+e)?t:e}return n.invert=n,n.domain=n.range=function(t){return arguments.length?(e=Array.from(t,gD),n):e.slice()},n.unknown=function(e){return arguments.length?(t=e,n):t},n.copy=function(){return qde(e).unknown(t)},e=arguments.length?Array.from(e,gD):[0,1],wD(n)}var Jde=o((()=>{TD(),_D()}));function Yde(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return a{}));function Zde(e){return Math.log(e)}function Qde(e){return Math.exp(e)}function $de(e){return-Math.log(-e)}function efe(e){return-Math.exp(-e)}function tfe(e){return isFinite(e)?+(`1e`+e):e<0?0:e}function nfe(e){return e===10?tfe:e===Math.E?Math.exp:t=>e**+t}function rfe(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function ife(e){return(t,n)=>-e(-t,n)}function ED(e){let t=e(Zde,Qde),n=t.domain,r=10,i,a;function o(){return i=rfe(r),a=nfe(r),n()[0]<0?(i=ife(i),a=ife(a),e($de,efe)):e(Zde,Qde),t}return t.base=function(e){return arguments.length?(r=+e,o()):r},t.domain=function(e){return arguments.length?(n(e),o()):n()},t.ticks=e=>{let t=n(),o=t[0],s=t[t.length-1],c=s0){for(;l<=u;++l)for(d=1;ds)break;m.push(f)}}else for(;l<=u;++l)for(d=r-1;d>=1;--d)if(f=l>0?d/a(-l):d*a(l),!(fs)break;m.push(f)}m.length*2{if(e??=10,n??=r===10?`s`:`,`,typeof n!=`function`&&(!(r%1)&&(n=c_(n)).precision==null&&(n.trim=!0),n=h_(n)),e===1/0)return n;let o=Math.max(1,r*e/t.ticks().length);return e=>{let t=e/a(Math.round(i(e)));return t*rn(Yde(n(),{floor:e=>a(Math.floor(i(e))),ceil:e=>a(Math.ceil(i(e)))})),t}function afe(){let e=ED(xD()).domain([1,10]);return e.copy=()=>bD(e,afe()).base(e.base()),kT.apply(e,arguments),e}var DD=o((()=>{r_(),__(),Xde(),CD(),jT()}));function ofe(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function sfe(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function OD(e){var t=1,n=e(ofe(t),sfe(t));return n.constant=function(n){return arguments.length?e(ofe(t=+n),sfe(t)):t},wD(n)}function cfe(){var e=OD(xD());return e.copy=function(){return bD(e,cfe()).constant(e.constant())},kT.apply(e,arguments)}var kD=o((()=>{TD(),CD(),jT()}));function lfe(e){return function(t){return t<0?-((-t)**+e):t**+e}}function ufe(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function dfe(e){return e<0?-e*e:e*e}function AD(e){var t=e(vD,vD),n=1;function r(){return n===1?e(vD,vD):n===.5?e(ufe,dfe):e(lfe(n),lfe(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,r()):n},wD(t)}function jD(){var e=AD(xD());return e.copy=function(){return bD(e,jD()).exponent(e.exponent())},kT.apply(e,arguments),e}function ffe(){return jD.apply(null,arguments).exponent(.5)}var MD=o((()=>{TD(),CD(),jT()}));function pfe(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r0?n[i-1]:e[0],i{r_(),jT()}));function hfe(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[Vg(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return hfe().domain([e,t]).range(i).unknown(a)},kT.apply(wD(o),arguments)}var gfe=o((()=>{r_(),TD(),jT()}));function _fe(){var e=[.5],t=[0,1],n,r=1;function i(i){return i!=null&&i<=i?t[Vg(e,i,0,r)]:n}return i.domain=function(n){return arguments.length?(e=Array.from(n),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(n){return arguments.length?(t=Array.from(n),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(n){var r=t.indexOf(n);return[e[r-1],e[r]]},i.unknown=function(e){return arguments.length?(n=e,i):n},i.copy=function(){return _fe().domain(e).range(t).unknown(n)},kT.apply(i,arguments)}var vfe=o((()=>{r_(),jT()}));function yfe(e){return new Date(e)}function bfe(e){return e instanceof Date?+e:+new Date(+e)}function ND(e,t,n,r,i,a,o,s,c,l){var u=Ude(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e){_v(),sb(),CD(),jT(),Xde()}));function Cfe(){return kT.apply(ND(pv,mv,uv,sv,Q_,B_,L_,P_,j_,ab).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}var wfe=o((()=>{_v(),sb(),Sfe(),jT()}));function PD(){var e=0,t=1,n,r,i,a,o=vD,s=!1,c;function l(e){return e==null||isNaN(e=+e)?c:o(i===0?.5:(e=(a(e)-n)*i,s?Math.max(0,Math.min(1,e)):e))}l.domain=function(o){return arguments.length?([e,t]=o,n=a(e=+e),r=a(t=+t),i=n===r?0:1/(r-n),l):[e,t]},l.clamp=function(e){return arguments.length?(s=!!e,l):s},l.interpolator=function(e){return arguments.length?(o=e,l):o};function u(e){return function(t){var n,r;return arguments.length?([n,r]=t,o=e(n,r),l):[o(0),o(1)]}}return l.range=u(cD),l.rangeRound=u(uD),l.unknown=function(e){return arguments.length?(c=e,l):c},function(o){return a=o,n=o(e),r=o(t),i=n===r?0:1/(r-n),l}}function FD(e,t){return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function ID(){var e=wD(PD()(vD));return e.copy=function(){return FD(e,ID())},AT.apply(e,arguments)}function Tfe(){var e=ED(PD()).domain([1,10]);return e.copy=function(){return FD(e,Tfe()).base(e.base())},AT.apply(e,arguments)}function Efe(){var e=OD(PD());return e.copy=function(){return FD(e,Efe()).constant(e.constant())},AT.apply(e,arguments)}function LD(){var e=AD(PD());return e.copy=function(){return FD(e,LD()).exponent(e.exponent())},AT.apply(e,arguments)}function Dfe(){return LD.apply(null,arguments).exponent(.5)}var Ofe=o((()=>{hD(),CD(),jT(),TD(),DD(),kD(),MD()}));function RD(){var e=0,t=.5,n=1,r=1,i,a,o,s,c,l=vD,u,d=!1,f;function p(e){return isNaN(e=+e)?f:(e=.5+((e=+u(e))-a)*(r*e{hD(),CD(),jT(),TD(),DD(),Ofe(),kD(),MD()})),Pfe=o((()=>{r_(),Sue(),Jde(),TD(),DD(),kD(),MD(),CD(),_D(),mfe(),gfe(),vfe(),Sfe(),wfe(),Ofe(),Nfe(),Gde()}));function BD(e){for(var t=e.length/6|0,n=Array(t),r=0;r{})),Ffe,Ife=o((()=>{VD(),Ffe=BD(`1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf`)})),Lfe,Rfe=o((()=>{VD(),Lfe=BD(`7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666`)})),zfe,Bfe=o((()=>{VD(),zfe=BD(`1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666`)})),Vfe,Hfe=o((()=>{VD(),Vfe=BD(`4269d0efb118ff725c6cc5b03ca951ff8ab7a463f297bbf59c6b4e9498a0`)})),Ufe,Wfe=o((()=>{VD(),Ufe=BD(`a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928`)})),Gfe,Kfe=o((()=>{VD(),Gfe=BD(`fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2`)})),qfe,Jfe=o((()=>{VD(),qfe=BD(`b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc`)})),Yfe,Xfe=o((()=>{VD(),Yfe=BD(`e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999`)})),Zfe,Qfe=o((()=>{VD(),Zfe=BD(`66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3`)})),$fe,epe=o((()=>{VD(),$fe=BD(`8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f`)})),tpe=o((()=>{Ife(),Rfe(),Bfe(),Hfe(),Wfe(),Kfe(),Jfe(),Xfe(),Qfe(),epe(),VD(),hD(),YE()}));function HD(e,t,n){let r=e-t+n*2;return e?r>0?r:1:0}function npe(e){return function(t){let n=t[0],r=t[1],i;return r=r&&n[c]<=i&&(a<0&&(a=c),o=c);if(!(a<0))return r=e.invertExtent(n[a]),i=e.invertExtent(n[o]),[r[0]===void 0?r[1]:r[0],i[1]===void 0?i[0]:i[1]]}}function UD(){let e=MT().unknown(void 0),t=e.domain,n=e.range,r=[0,1],i,a,o=!1,s=0,c=0,l=.5;delete e.unknown;function u(){let e=t().length,u=r[1]p+i*e);return n(u?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),u()):t()},e.range=function(e){return arguments.length?(r=[+e[0],+e[1]],u()):r.slice()},e.rangeRound=function(e){return r=[+e[0],+e[1]],o=!0,u()},e.bandwidth=function(){return a},e.step=function(){return i},e.round=function(e){return arguments.length?(o=!!e,u()):o},e.padding=function(e){return arguments.length?(c=Math.max(0,Math.min(1,e)),s=c,u()):s},e.paddingInner=function(e){return arguments.length?(s=Math.max(0,Math.min(1,e)),u()):s},e.paddingOuter=function(e){return arguments.length?(c=Math.max(0,Math.min(1,e)),u()):c},e.align=function(e){return arguments.length?(l=Math.max(0,Math.min(1,e)),u()):l},e.invertRange=function(e){if(e[0]==null||e[1]==null)return;let i=r[1]r[1-i])))return u=Math.max(0,Vg(o,c)-1),d=c===l?u:Vg(o,l)-1,c-o[u]>a+1e-10&&++u,i&&(f=u,u=s-d,d=s-f),u>d?void 0:t().slice(u,d+1)},e.invert=function(t){let n=e.invertRange([t,t]);return n&&n[0]},e.copy=function(){return UD().domain(t()).range(r).round(o).paddingInner(s).paddingOuter(c).align(l)},u()}function ipe(e){let t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,e.copy=function(){return ipe(t())},e}function ape(){return ipe(UD().paddingInner(1))}function ope(e){return Rpe.call(e,Ph)}function spe(){let e=[],t=[];function n(n){return n==null||n!==n?void 0:t[(Vg(e,n)-1)%t.length]}return n.domain=function(t){return arguments.length?(e=ope(t),n):e.slice()},n.range=function(e){return arguments.length?(t=zpe.call(e),n):t.slice()},n.tickFormat=function(t,n){return Wde(e[0],Mh(e),t??10,n)},n.copy=function(){return spe().domain(n.domain()).range(n.range())},n}function cpe(e){return e[hO]=!0,e}function lpe(e){return e&&e[hO]===!0}function upe(e,t,n){let r=function(){let n=t();return n.invertRange||=n.invert?npe(n):n.invertExtent?rpe(n):void 0,n.type=e,cpe(n)};return r.metadata=Og(ng(n)),r}function WD(e,t,n){return arguments.length>1?(mO.set(e,upe(e,t,n)),this):dpe(e)?mO.get(e):void 0}function dpe(e){return mO.has(e)}function GD(e,t){let n=mO.get(e);return n&&n.metadata[t]}function KD(e){return GD(e,lO)}function qD(e){return GD(e,uO)}function JD(e){return GD(e,dO)}function YD(e){return GD(e,`log`)}function fpe(e){return GD(e,pO)}function ppe(e){return GD(e,fO)}function mpe(e){return GD(e,oO)}function hpe(e,t){let n=t[0],r=Mh(t)-n;return function(t){return e(n+t*r)}}function XD(e,t,n){return mD(ZD(t||`rgb`,n),e)}function gpe(e,t){let n=Array(t),r=t+1;for(let i=0;ie[t]?o[t](e[t]()):0),o)}function ZD(e,t){let n=Lde[vpe(e)];return t!=null&&n&&n.gamma?n.gamma(t):n}function vpe(e){return`interpolate`+e.toLowerCase().split(`-`).map(e=>e[0].toUpperCase()+e.slice(1)).join(``)}function ype(e){if(H(e))return e;let t=e.length/6|0,n=Array(t);for(let r=0;r1?(gO[e]=t,this):gO[e]}function $D(e,t,n){let r;if(yg(t)&&(e.bins&&(t=Math.max(t,e.bins.length)),n!=null)){let r=e.domain(),i=Math.min(r[0],Mh(r)),a=Math.max(r[0],Mh(r));if(t=Math.min(t,Math.floor((a-i)/n||1)+1),!e.bins&&!YD(e.type)&&!fpe(e.type)&&i1&&Zg(i,a,t)a&&(r=a,a=i,i=r,o=Gpe),i=Math.floor(i),a=Math.ceil(a),t=t.map(t=>[t,e(t)]).filter(e=>i<=e[1]&&e[1]<=a).sort(o).map(e=>e[0]),n>0&&t.length>1){let e=[t[0],Mh(t)];for(;t.length>n&&t.length>=3;)t=t.filter((e,t)=>!(t%2));t.length<3&&(t=e)}return t}function eO(e,t){return e.bins?xpe(e,e.bins,t):e.ticks?e.ticks(t):e.domain()}function Spe(e,t,n,r,i,a){let o=t.type,s=Upe;if(o===`time`||i===`time`)s=e.timeFormat(r);else if(o===`utc`||i===`utc`)s=e.utcFormat(r);else if(YD(o)){let i=e.formatFloat(r);if(a||t.bins)s=i;else{let e=Cpe(t,n,!1);s=t=>e(t)?i(t):``}}else if(t.tickFormat){let i=t.domain();s=e.formatSpan(i[0],i[i.length-1],n,r)}else r&&(s=e.format(r));return s}function Cpe(e,t,n){let r=eO(e,t),i=e.base(),a=Math.log(i),o=Math.max(1,i*t/r.length),s=e=>{let t=e/i**+Math.round(Math.log(e)/a);return t*i1?r[1]-r[0]:r[0],o;for(o=1;o(e-r)/a}function Ape(e,t,n,r){let i=r||t.type;return xg(n)&&fpe(i)&&(n=n.replace(/%a/g,`%A`).replace(/%b/g,`%B`)),!n&&i===`time`?e.timeFormat(`%A, %d %B %Y, %X`):!n&&i===`utc`?e.utcFormat(`%A, %d %B %Y, %X UTC`):Ope(e,t,5,null,n,r,!0)}function jpe(e,t,n){n||={};let r=Math.max(3,n.maxlen||7),i=Ape(e,t,n.format,n.formatType);if(JD(t.type)){let e=wpe(t).slice(1).map(i),n=e.length;return`${n} boundar${n===1?`y`:`ies`}: ${e.join(`, `)}`}else if(qD(t.type)){let e=t.domain(),n=e.length,a=n>r?e.slice(0,r-2).map(i).join(`, `)+`, ending with `+e.slice(-1).map(i):e.map(i).join(`, `);return`${n} value${n===1?``:`s`}: ${a}`}else{let e=t.domain();return`values from ${i(e[0])} to ${i(Mh(e))}`}}var Mpe,tO,nO,rO,Npe,iO,aO,oO,sO,cO,Ppe,Fpe,Ipe,Lpe,lO,uO,dO,fO,pO,Rpe,zpe,mO,hO,Bpe,Vpe,Hpe,gO,Upe,Wpe,Gpe,_O,vO,Kpe,qpe,yO,Jpe,Ype,bO,xO=o((()=>{Ag(),r_(),Pfe(),hD(),tpe(),Ay(),Mpe=`identity`,tO=`linear`,nO=`sqrt`,rO=`symlog`,Npe=`time`,iO=`sequential`,aO=`diverging`,oO=`quantile`,sO=`quantize`,cO=`threshold`,Ppe=`ordinal`,Fpe=`point`,Ipe=`band`,Lpe=`bin-ordinal`,lO=`continuous`,uO=`discrete`,dO=`discretizing`,fO=`interpolating`,pO=`temporal`,Rpe=Array.prototype.map,zpe=Array.prototype.slice,mO=new Map,hO=Symbol(`vega_scale`),WD(Mpe,qde),WD(tO,Kde,lO),WD(`log`,afe,[lO,`log`]),WD(`pow`,jD,lO),WD(nO,ffe,lO),WD(rO,cfe,lO),WD(Npe,xfe,[lO,pO]),WD(`utc`,Cfe,[lO,pO]),WD(iO,ID,[lO,fO]),WD(`${iO}-${tO}`,ID,[lO,fO]),WD(`${iO}-log`,Tfe,[lO,fO,`log`]),WD(`${iO}-pow`,LD,[lO,fO]),WD(`${iO}-${nO}`,Dfe,[lO,fO]),WD(`${iO}-${rO}`,Efe,[lO,fO]),WD(`${aO}-${tO}`,kfe,[lO,fO]),WD(`${aO}-log`,Afe,[lO,fO,`log`]),WD(`${aO}-pow`,zD,[lO,fO]),WD(`${aO}-${nO}`,Mfe,[lO,fO]),WD(`${aO}-${rO}`,jfe,[lO,fO]),WD(oO,pfe,[dO,oO]),WD(sO,hfe,dO),WD(cO,_fe,dO),WD(Lpe,spe,[uO,dO]),WD(Ppe,MT,uO),WD(Ipe,UD,uO),WD(Fpe,ape,uO),Bpe=[`clamp`,`base`,`constant`,`exponent`],Vpe={blues:`cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90`,greens:`d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429`,greys:`e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e`,oranges:`fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303`,purples:`e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c`,reds:`fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13`,blueGreen:`d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429`,bluePurple:`ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71`,greenBlue:`d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1`,orangeRed:`fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403`,purpleBlue:`dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281`,purpleBlueGreen:`dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353`,purpleRed:`dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a`,redPurple:`fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174`,yellowGreen:`e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034`,yellowOrangeBrown:`feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204`,yellowOrangeRed:`fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225`,blueOrange:`134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07`,brownBlueGreen:`704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147`,purpleGreen:`5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29`,purpleOrange:`4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07`,redBlue:`8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85`,redGrey:`8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434`,yellowGreenBlue:`eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185`,redYellowBlue:`a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695`,redYellowGreen:`a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837`,pinkYellowGreen:`8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419`,spectral:`9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2`,viridis:`440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725`,magma:`0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf`,inferno:`0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4`,plasma:`0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921`,cividis:`00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647`,rainbow:`6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa`,sinebow:`ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040`,turbo:`23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00`,browns:`eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632`,tealBlues:`bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985`,teals:`bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667`,warmGreys:`dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e`,goldGreen:`f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36`,goldOrange:`f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26`,goldRed:`f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e`,lightGreyRed:`efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b`,lightGreyTeal:`e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc`,lightMulti:`e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c`,lightOrange:`f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b`,lightTealBlue:`e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988`,darkBlue:`3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff`,darkGold:`3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff`,darkGreen:`3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa`,darkMulti:`3737371f5287197d8c29a86995ce3fffe800ffffff`,darkRed:`3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c`},Hpe={accent:Lfe,category10:Ffe,category20:`1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5`,category20b:`393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6`,category20c:`3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9`,dark2:zfe,observable10:Vfe,paired:Ufe,pastel1:Gfe,pastel2:qfe,set1:Yfe,set2:Zfe,set3:$fe,tableau10:`4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac`,tableau20:`4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5`},gO={},bpe(Hpe,ype),bpe(Vpe,e=>XD(ype(e))),Upe=e=>H(e)?e.map(e=>String(e)):String(e),Wpe=(e,t)=>e[1]-t[1],Gpe=(e,t)=>t[1]-e[1],_O={[oO]:`quantiles`,[sO]:`thresholds`,[cO]:`domain`},vO={[oO]:`quantiles`,[sO]:`domain`},Kpe=e=>_O[e.type]||e.bins,qpe=e=>(t,n,r)=>{let i=yO(r[n+1],yO(r.max,1/0)),a=bO(t,e),o=bO(i,e);return a&&o?a+` – `+o:o?`< `+o:`≥ `+a},yO=(e,t)=>e??t,Jpe=e=>(t,n)=>n?e(t):null,Ype=e=>t=>e(t),bO=(e,t)=>Number.isFinite(e)?t(e):null}));function Xpe(){Ik=0}function SO(e){return e&&e.gradient}function Zpe(e,t,n){let r=e.gradient,i=e.id,a=r===`radial`?Lk:``;return i||(i=e.id=`gradient_`+Ik++,r===`radial`?(e.x1=CO(e.x1,.5),e.y1=CO(e.y1,.5),e.r1=CO(e.r1,0),e.x2=CO(e.x2,.5),e.y2=CO(e.y2,.5),e.r2=CO(e.r2,.5),a=Lk):(e.x1=CO(e.x1,0),e.y1=CO(e.y1,0),e.x2=CO(e.x2,1),e.y2=CO(e.y2,0))),t[i]=e,`url(`+(n||``)+`#`+a+i+`)`}function CO(e,t){return e??t}function Qpe(e,t){var n=[],r;return r={gradient:`linear`,x1:e?e[0]:0,y1:e?e[1]:0,x2:t?t[0]:1,y2:t?t[1]:0,stops:n,stop:function(e,t){return n.push({offset:e,color:t}),r}}}function wO(e,t,n){var r=fg(Rk,e)&&Rk[e],i=null;return r&&(i=r.curve||r[t||`vertical`],r.tension&&n!=null&&(i=i[r.tension](n))),i}function TO(e){let t=[];return(e.match(pge)||[]).forEach(e=>{let n=e[0],r=n.toLowerCase(),i=fge[r],a=$pe(r,i,e.slice(1).trim()),o=a.length;if(o1&&(h=Math.sqrt(h),n*=h,r*=h);let g=f/n,_=d/n,v=-d/r,y=f/r,b=g*s+_*c,x=v*s+y*c,S=g*e+_*t,C=v*e+y*t,w=1/((S-b)*(S-b)+(C-x)*(C-x))-.25;w<0&&(w=0);let T=Math.sqrt(w);a==i&&(T=-T);let E=.5*(b+S)-T*(C-x),D=.5*(x+C)+T*(S-b),O=Math.atan2(x-D,b-E),k=Math.atan2(C-D,S-E)-O;k<0&&a===1?k+=Vk:k>0&&a===0&&(k-=Vk);let A=Math.ceil(Math.abs(k/(Bk+.001))),j=[];for(let e=0;e+e}function OO(e,t,n){return Math.max(t,Math.min(e,n))}function ume(){var e=ome,t=sme,n=cme,r=lme,i=DO(0),a=i,o=i,s=i,c=null;function l(l,u,d){var f,p=u??+e.call(this,l),m=d??+t.call(this,l),h=+n.call(this,l),g=+r.call(this,l),_=Math.min(h,g)/2,v=OO(+i.call(this,l),0,_),y=OO(+a.call(this,l),0,_),b=OO(+o.call(this,l),0,_),x=OO(+s.call(this,l),0,_);if(c||=f=yw(),v<=0&&y<=0&&b<=0&&x<=0)c.rect(p,m,h,g);else{var S=p+h,C=m+g;c.moveTo(p+v,m),c.lineTo(S-y,m),c.bezierCurveTo(S-Xk*y,m,S,m+Xk*y,S,m+y),c.lineTo(S,C-x),c.bezierCurveTo(S,C-Xk*x,S-Xk*x,C,S-x,C),c.lineTo(p+b,C),c.bezierCurveTo(p+Xk*b,C,p,C-Xk*b,p,C-b),c.lineTo(p,m+v),c.bezierCurveTo(p,m+Xk*v,p+Xk*v,m,p+v,m),c.closePath()}if(f)return c=null,f+``||null}return l.x=function(t){return arguments.length?(e=DO(t),l):e},l.y=function(e){return arguments.length?(t=DO(e),l):t},l.width=function(e){return arguments.length?(n=DO(e),l):n},l.height=function(e){return arguments.length?(r=DO(e),l):r},l.cornerRadius=function(e,t,n,r){return arguments.length?(i=DO(e),a=t==null?i:DO(t),s=n==null?i:DO(n),o=r==null?a:DO(r),l):i},l.context=function(e){return arguments.length?(c=e??null,l):c},l}function dme(){var e,t,n,r,i=null,a,o,s,c;function l(e,t,n){let r=n/2;if(a){var l=s-t,u=e-o;if(l||u){var d=Math.hypot(l,u),f=(l/=d)*c,p=(u/=d)*c,m=Math.atan2(u,l);i.moveTo(o-f,s-p),i.lineTo(e-l*r,t-u*r),i.arc(e,t,r,m-Math.PI,m),i.lineTo(o+f,s+p),i.arc(o,s,c,m,m+Math.PI)}else i.arc(e,t,r,0,Vk);i.closePath()}else a=1;o=e,s=t,c=r}function u(o){var s,c=o.length,u,d=!1,f;for(i??=f=yw(),s=0;s<=c;++s)!(s_ge?(u=o*o+s*a,u>=0&&(u=Math.sqrt(u),c=(-o+u)/a,l=(-o-u)/a)):c=.5*s/o,0f)return!1;h>d&&(d=h)}else if(p>0){if(h0?(e.globalAlpha=n,e.fillStyle=Dme(e,t,t.fill),!0):!1}function GO(e,t,n){var r=(r=t.strokeWidth)??1;return r<=0?!1:(n*=t.strokeOpacity==null?1:t.strokeOpacity,n>0?(e.globalAlpha=n,e.strokeStyle=Dme(e,t,t.stroke),e.lineWidth=r,e.lineCap=t.strokeCap||`butt`,e.lineJoin=t.strokeJoin||`miter`,e.miterLimit=t.strokeMiterLimit==null?4:t.strokeMiterLimit,e.setLineDash&&(e.setLineDash(t.strokeDash||Wge),e.lineDashOffset=t.strokeDashOffset||0),!0):!1)}function Ome(e,t){return e.zindex-t.zindex||e.index-t.index}function KO(e){if(!e.zdirty)return e.zitems;var t=e.items,n=[],r,i,a;for(i=0,a=t.length;i=0;)if(r=t(n[i]))return r;if(n===a){for(n=e.items,i=n.length;--i>=0;)if(!n[i].zindex&&(r=t(n[i])))return r}return null}function YO(e){return function(t,n,r){qO(n,n=>{(!r||r.intersects(n.bounds))&&Ame(e,t,n,n)})}}function kme(e){return function(t,n,r){n.items.length&&(!r||r.intersects(n.bounds))&&Ame(e,t,n.items[0],n.items)}}function Ame(e,t,n,r){var i=n.opacity==null?1:n.opacity;i!==0&&(e(t,r)||(HO(t,n),n.fill&&WO(t,n,i)&&t.fill(),n.stroke&&GO(t,n,i)&&t.stroke()))}function XO(e){return e||=Sh,function(t,n,r,i,a,o){return r*=t.pixelRatio,i*=t.pixelRatio,JO(n,n=>{let s=n.bounds;if(!(s&&!s.contains(a,o)||!s)&&e(t,n,r,i,a,o))return n})}}function ZO(e,t){return function(n,r,i,a){var o=Array.isArray(r)?r[0]:r,s=t??o.fill,c=o.stroke&&n.isPointInStroke,l,u;return c&&(l=o.strokeWidth,u=o.strokeCap,n.lineWidth=l??1,n.lineCap=u??`butt`),e(n,r)?!1:s&&n.isPointInPath(i,a)||c&&n.isPointInStroke(i,a)}}function QO(e){return XO(ZO(e))}function $O(e,t){return`translate(`+e+`,`+t+`)`}function ek(e){return`rotate(`+e+`)`}function jme(e,t){return`scale(`+e+`,`+t+`)`}function Mme(e){return $O(e.x||0,e.y||0)}function Nme(e){return $O(e.x||0,e.y||0)+(e.angle?` `+ek(e.angle):``)}function Pme(e){return $O(e.x||0,e.y||0)+(e.angle?` `+ek(e.angle):``)+(e.scaleX||e.scaleY?` `+jme(e.scaleX||1,e.scaleY||1):``)}function tk(e,t,n){function r(e,n){e(`transform`,Nme(n)),e(`d`,t(null,n))}function i(e,n){return t(RO(e,n.angle),n),LO(e,n,!0).translate(n.x||0,n.y||0)}function a(e,n){var r=n.x||0,i=n.y||0,a=n.angle||0;e.translate(r,i),a&&e.rotate(a*=zk),e.beginPath(),t(e,n),a&&e.rotate(-a),e.translate(-r,-i)}return{type:e,tag:`path`,nested:!1,attr:r,bound:i,draw:YO(a),pick:QO(a),isect:n||zO(a)}}function Fme(e,t){for(var n=e[0].orient===`horizontal`?t[1]:t[0],r=e[0].orient===`horizontal`?`y`:`x`,i=e.length,a=1/0,o,s;--i>=0;)e[i].defined!==!1&&(s=Math.abs(e[i][r]-n),s=0;)if(e[r].defined!==!1&&(i=e[r].x-t[0],a=e[r].y-t[1],o=i*i+a*a,o=0;)if(e[n].defined!==!1&&(r=e[n].x-t[0],i=e[n].y-t[1],a=r*r+i*i,r=e[n].size||1,a.5&&t<1.5?.5-Math.abs(t-1):0:e.strokeOffset}function Vme(e,t){e(`transform`,Mme(t))}function Hme(e,t){let n=Bme(t);e(`d`,jO(null,t,n,n))}function Ume(e,t){e(`class`,`background`),e(`aria-hidden`,!0),Hme(e,t)}function Wme(e,t){e(`class`,`foreground`),e(`aria-hidden`,!0),t.strokeForeground?Hme(e,t):e(`d`,``)}function Gme(e,t,n){e(`clip-path`,t.clip?MO(n,t,t):null)}function Kme(e,t){if(!t.clip&&t.items){let n=t.items,r=n.length;for(let t=0;t{let i=t.x||0,a=t.y||0,o=t.strokeForeground,s=t.opacity==null?1:t.opacity;(t.stroke||t.fill)&&s&&(rk(e,t,i,a),HO(e,t),t.fill&&WO(e,t,s)&&e.fill(),t.stroke&&!o&&GO(e,t,s)&&e.stroke()),e.save(),e.translate(i,a),t.clip&&zme(e,t),n&&n.translate(-i,-a),qO(t,t=>{(t.marktype===`group`||r==null||r.includes(t.marktype))&&this.draw(e,t,n,r)}),n&&n.translate(i,a),e.restore(),o&&t.stroke&&s&&(rk(e,t,i,a),HO(e,t),GO(e,t,s)&&e.stroke())})}function Jme(e,t,n,r,i,a){if(t.bounds&&!t.bounds.contains(i,a)||!t.items)return null;let o=n*e.pixelRatio,s=r*e.pixelRatio;return JO(t,c=>{let l,u,d,f=c.bounds;if(f&&!f.contains(i,a))return;u=c.x||0,d=c.y||0;let p=u+(c.width||0),m=d+(c.height||0),h=c.clip;if(h&&(ip||am))return;if(e.save(),e.translate(u,d),u=i-u,d=a-d,h&&AO(c)&&!Yge(e,c,o,s))return e.restore(),null;let g=c.strokeForeground,_=t.interactive!==!1;return _&&g&&c.stroke&&Jge(e,c,o,s)?(e.restore(),c):(l=JO(c,e=>Yme(e,u,d)?this.pick(e,n,r,u,d):null),!l&&_&&(c.fill||!g&&c.stroke)&&qge(e,c,o,s)&&(l=c),e.restore(),l||null)})}function Yme(e,t,n){return(e.interactive!==!1||e.marktype===`group`)&&e.bounds&&e.bounds.contains(t,n)}function ik(e,t){var n=e.image;return(!n||e.url&&e.url!==n.url)&&(n={complete:!1,width:0,height:0},t.loadImage(e.url).then(t=>{e.image=t,e.image.url=e.url})),n}function ak(e,t){return e.width==null?!t||!t.width?0:e.aspect!==!1&&e.height?e.height*t.width/t.height:t.width:e.width}function ok(e,t){return e.height==null?!t||!t.height?0:e.aspect!==!1&&e.width?e.width*t.height/t.width:t.height:e.height}function sk(e,t){return e===`center`?t/2:e===`right`?t:0}function ck(e,t){return e===`middle`?t/2:e===`bottom`?t:0}function Xme(e,t,n){let r=ik(t,n),i=ak(t,r),a=ok(t,r),o=(t.x||0)-sk(t.align,i),s=(t.y||0)-ck(t.baseline,a);e(`href`,!r.src&&r.toDataURL?r.toDataURL():r.src||``,bA[`xmlns:xlink`],`xlink:href`),e(`transform`,$O(o,s)),e(`width`,i),e(`height`,a),e(`preserveAspectRatio`,t.aspect===!1?`none`:`xMidYMid`)}function Zme(e,t){let n=t.image,r=ak(t,n),i=ok(t,n),a=(t.x||0)-sk(t.align,r),o=(t.y||0)-ck(t.baseline,i);return e.set(a,o,a+r,o+i)}function Qme(e,t,n){qO(t,t=>{if(n&&!n.intersects(t.bounds))return;let r=ik(t,this),i=ak(t,r),a=ok(t,r);if(i===0||a===0)return;let o=(t.x||0)-sk(t.align,i),s=(t.y||0)-ck(t.baseline,a),c,l,u;t.aspect!==!1&&(c=r.width/r.height,l=t.width/t.height,c===c&&l===l&&c!==l&&(l{if(!(n&&!n.intersects(t.bounds))){var r=t.opacity==null?1:t.opacity;r&&ohe(e,t,r)&&(HO(e,t),e.stroke())}})}function che(e,t,n,r){return e.isPointInStroke?ohe(e,t,1)&&e.isPointInStroke(n,r):!1}function lhe(e){SA.width=e&&vA?dk:uk}function uk(e,t){return uhe(gk(e,t),fk(e))}function uhe(e,t){return~~(.8*e.length*t)}function dk(e,t){return fk(e)<=0||!(t=gk(e,t))?0:dhe(t,vk(e))}function dhe(e,t){let n=`(${t}) ${e}`,r=xA.get(n);return r===void 0&&(vA.font=t,r=vA.measureText(e).width,xA.set(n,r)),r}function fk(e){return e.fontSize==null?11:+e.fontSize||0}function pk(e){return e.lineHeight==null?fk(e)+2:e.lineHeight}function fhe(e){return H(e)?e.length>1?e:e[0]:e}function mk(e){return fhe(e.lineBreak&&e.text&&!H(e.text)?e.text.split(e.lineBreak):e.text)}function hk(e){let t=mk(e);return(H(t)?t.length-1:0)*pk(e)}function gk(e,t){let n=t==null?``:(t+``).trim();return e.limit>0&&n.length?mhe(e,n):n}function phe(e){if(SA.width===dk){let t=vk(e);return e=>dhe(e,t)}else if(SA.width===uk){let t=fk(e);return e=>uhe(e,t)}else return t=>SA.width(e,t)}function mhe(e,t){var n=+e.limit,r=phe(e);if(r(t)>>1,r(t.slice(c))>n?o=c+1:s=c;return i+t.slice(o)}else{for(;o>>1),r(t.slice(0,c))Math.max(e,SA.width(t,n)),0)):d=SA.width(t,u),i===`center`?c-=d/2:i===`right`&&(c-=d),e.set(c+=o,l+=s,c+d,l+r),t.angle&&!n)e.rotate(t.angle*zk,o,s);else if(n===2)return e.rotatedPoints(t.angle*zk,o,s);return e}function ghe(e,t,n){qO(t,t=>{var r=t.opacity==null?1:t.opacity,i,a,o,s,c,l,u;if(!(n&&!n.intersects(t.bounds)||r===0||t.fontSize<=0||t.text==null||t.text.length===0)){if(e.font=vk(t),e.textAlign=t.align||`left`,i=bk(t),a=i.x1,o=i.y1,t.angle&&(e.save(),e.translate(a,o),e.rotate(t.angle*zk),a=o=0),a+=t.dx||0,o+=(t.dy||0)+yk(t),l=mk(t),HO(e,t),H(l))for(c=pk(t),s=0;st;)e.removeChild(n[--r]);return e}function whe(e){return`mark-`+e.marktype+(e.role?` role-`+e.role:``)+(e.name?` `+e.name:``)}function Dk(e,t){if(t.getScreenCTM){let n=The(e,t.getScreenCTM());if(n)return n}return Ehe(e,t,t.getBoundingClientRect())}function The(e,t){if(!t)return null;let n=t.a*t.d-t.b*t.c;if(!n)return null;let r=e.clientX-t.e,i=e.clientY-t.f;return[(t.d*r-t.c*i)/n,(t.a*i-t.b*r)/n]}function Ehe(e,t,n){let r=t.offsetWidth?n.width/t.offsetWidth:1,i=t.offsetHeight?n.height/t.offsetHeight:1;return[(e.clientX-n.left)/r-(t.clientLeft||0),(e.clientY-n.top)/i-(t.clientTop||0)]}function Dhe(e,t,n,r){var i=e&&e.mark,a,o;if(i&&(a=wA[i.marktype]).tip){for(o=Dk(t,n),o[0]-=r[0],o[1]-=r[1];e=e.mark.group;)o[0]-=e.x||0,o[1]-=e.y||0;e=a.tip(i.items,o)}return e}function Ohe(e,t,n,r){e.element().setAttribute(`title`,r||``)}function khe(e,t){m_e(t).forEach(t=>Ahe(e,t))}function Ahe(e,t){let n=e.canvas();n&&!e._events[t]&&(e._events[t]=1,n.addEventListener(t,e[t]?n=>e[t](n):n=>e.fire(t,n)))}function Ok(e,t,n){t.forEach(t=>e.fire(t,n))}function jhe(e,t,n){return function(r){let i=this._active,a=this.pickEvent(r);a===i?Ok(this,e,r):((!i||!i.exit)&&Ok(this,n,r),this._active=a,Ok(this,t,r),Ok(this,e,r))}}function Mhe(e){return function(t){Ok(this,e,t),this._active=null}}function Nhe(){return typeof window<`u`&&window.devicePixelRatio||1}function Phe(e,t,n,r,i,a){let o=typeof HTMLElement<`u`&&e instanceof HTMLElement&&e.parentNode!=null,s=e.getContext(`2d`),c=o?Nhe():i;e.width=t*c,e.height=n*c;for(let e in a)s[e]=a[e];return o&&c!==1&&(e.style.width=t+`px`,e.style.height=n+`px`),s.pixelRatio=c,s.setTransform(c,0,0,c,c*r[0],c*r[1]),e}function Fhe(e,t,n){return t.expand(1).round(),e.pixelRatio%1&&t.scale(e.pixelRatio).round().scale(1/e.pixelRatio),t.translate(-(n[0]%1),-(n[1]%1)),e.beginPath(),e.rect(t.x1,t.y1,t.width(),t.height()),e.clip(),t}function Ihe(e,t){let n=t.aria===!1;if(e(QA,n||void 0),n||t.description==null)for(let t in sj)e(sj[t],void 0);else{let n=t.mark.marktype;e($A,t.description),e(ej,t.ariaRole||(n===`group`?nj:rj)),e(tj,t.ariaRoleDescription||`${n} mark`)}}function Lhe(e){return e.aria===!1?{[QA]:!0}:aj[e.role]?null:oj[e.role]?zhe(e,oj[e.role]):Rhe(e)}function Rhe(e){let t=e.marktype,n=t===`group`||t===`text`||e.items.some(e=>e.description!=null&&e.aria!==!1);return ij(n?nj:rj,`${t} mark container`,e.description)}function zhe(e,t){try{let n=e.items[0],r=t.caption||(()=>``);return ij(t.role||rj,t.desc,e.description||n.description||r(n))}catch{return null}}function Bhe(e){return ng(e.text).join(` `)}function Vhe(e){let t=e.datum,n=e.orient,r=t.title?Uhe(e):null,i=e.context,a=i.scales[t.scale].value,o=i.dataflow.locale(),s=a.type;return`${n===`left`||n===`right`?`Y`:`X`}-axis`+(r?` titled '${r}'`:``)+` for a ${qD(s)?`discrete`:s} scale with ${jpe(o,a,e)}`}function Hhe(e){let t=e.datum,n=t.title?Uhe(e):null,r=`${t.type||``} legend`.trim(),i=t.scales,a=Object.keys(i),o=e.context,s=o.scales[i[a[0]]].value,c=o.dataflow.locale();return Ghe(r)+(n?` titled '${n}'`:``)+` for ${Whe(a)} with ${jpe(c,s,e)}`}function Uhe(e){try{return ng(Mh(e.items).items[0].text).join(` `)}catch{return null}}function Whe(e){return e=e.map(e=>e+(e===`fill`||e===`stroke`?` color`:``)),e.length<2?e[0]:e.slice(0,-1).join(`, `)+` and `+Mh(e)}function Ghe(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function kk(){let e=``,t=``,n=``,r=[],i=()=>t=n=``,a=a=>{t&&(e+=`${t}>${n}`,i()),r.push(a)},o=(e,n)=>(n!=null&&(t+=` ${e}="${lj(n)}"`),s),s={open(e,...n){a(e),t=`<`+e;for(let e of n)for(let t in e)o(t,e[t]);return s},close(){let a=r.pop();return t?e+=t+(n?`>${n}`:`/>`):e+=``,i(),s},attr:o,text:e=>(n+=cj(e),s),toString:()=>e};return s}function Khe(e,t){if(e.open(t.tagName),t.hasAttributes()){let n=t.attributes,r=n.length;for(let t=0;t{i=e.mark(t,n,i,r),++a}),Ek(t,1+a)}function Zhe(e,t,n,r,i){let a=e._svg,o;if(!a&&(o=t.ownerDocument,a=Ck(o,r,gj),e._svg=a,e.mark&&(a.__data__=e,a.__values__={fill:`default`},r===`g`))){let t=Ck(o,`path`,gj);a.appendChild(t),t.__data__=e;let n=Ck(o,`g`,gj);a.appendChild(n),n.__data__=e;let r=Ck(o,`path`,gj);a.appendChild(r),r.__data__=e,r.__values__={fill:`default`}}return(a.ownerSVGElement!==i||Qhe(a,n))&&t.insertBefore(a,n?n.nextSibling:t.firstChild),a}function Qhe(e,t){return e.parentNode&&e.parentNode.childNodes.length>1&&e.previousSibling!=t}function Ak(e,t,n){t!==yj[e]&&(n?$he(vj,e,t,n):Nk(vj,e,t),yj[e]=t)}function jk(e,t,n){n!==yj[t]&&(n==null?e.style.removeProperty(t):e.style.setProperty(t,n+``),yj[t]=n)}function Mk(e,t){for(let n in t)Nk(e,n,t[n])}function Nk(e,t,n){n==null?e.removeAttribute(t):e.setAttribute(t,n)}function $he(e,t,n,r){n==null?e.removeAttributeNS(r,t):e.setAttributeNS(r,t,n)}function ege(){let e;return typeof window>`u`?``:(e=window.location).hash?e.href.slice(0,-e.hash.length):e.href}function tge(e,t,n,r,i){let a;if(t==null||(r===`bgrect`&&n.interactive===!1&&(e[`pointer-events`]=`none`),r===`bgfore`&&(n.interactive===!1&&(e[`pointer-events`]=`none`),e.display=`none`,t.fill!==null)))return e;r===`image`&&t.smooth===!1&&(a=[`image-rendering: optimizeSpeed;`,`image-rendering: pixelated;`]),r===`text`&&(e[`font-family`]=_k(t),e[`font-size`]=fk(t)+`px`,e[`font-style`]=t.fontStyle,e[`font-variant`]=t.fontVariant,e[`font-weight`]=t.fontWeight);for(let n in dj){let r=t[n],a=dj[n];r===`transparent`&&(a===`fill`||a===`stroke`)||r!=null&&(SO(r)&&(r=Zpe(r,i.gradient,``)),e[a]=r)}for(let e in fj){let n=t[e];n!=null&&(a||=[],a.push(`${fj[e]}: ${n};`))}return a&&(e.style=a.join(` `)),e}function nge(e){Sj.svgMarkTypes=e.svgMarkTypes??[`text`],Sj.svgOnTop=e.svgOnTop??!0,Sj.debug=e.debug??!1}function Pk(e,t){return e=String(e||``).toLowerCase(),arguments.length>1?(jj[e]=t,this):jj[e]}function rge(e,t,n){let r=[],i=new NO().union(t),a=e.marktype;return a?ige(e,i,n,r):a===`group`?oge(e,i,n,r):V(`Intersect scene must be mark node or group item.`)}function ige(e,t,n,r){if(age(e,t,n)){let i=e.items,a=e.marktype,o=i.length,s=0;if(a===`group`)for(;s=0;a--)if(n[a]!=r[a])return!1;for(a=n.length-1;a>=0;a--)if(i=n[a],!Fk(e[i],t[i],i))return!1;return typeof e==typeof t}function dge(){vme(),Xpe()}var Ik,Lk,Rk,fge,pge,mge,hge,gge,zk,_ge,Bk,Vk,Hk,Uk,Wk,Gk,Kk,qk,Jk,Yk,Xk,Zk,Qk,vge,yge,bge,xge,Sge,Cge,wge,Tge,Ege,Dge,Oge,kge,Age,jge,Mge,Nge,$k,Pge,Fge,Ige,Lge,Rge,zge,Bge,Vge,eA,tA,Hge,nA,rA,iA,aA,oA,sA,cA,lA,uA,dA,fA,pA,mA,hA,gA,_A,Uge,vA,yA,Wge,Gge,Kge,qge,Jge,Yge,Xge,bA,Zge,Qge,$ge,e_e,t_e,n_e,r_e,xA,SA,i_e,CA,wA,TA,a_e,EA,DA,OA,o_e,s_e,c_e,kA,AA,jA,MA,l_e,NA,PA,FA,IA,u_e,LA,RA,zA,BA,d_e,f_e,VA,HA,UA,WA,p_e,GA,KA,qA,JA,m_e,YA,h_e,XA,ZA,QA,$A,ej,tj,nj,rj,ij,aj,oj,sj,cj,lj,uj,dj,fj,pj,mj,hj,gj,_j,vj,yj,bj,xj,Sj,Cj,wj,Tj,Ej,Dj,Oj,kj,Aj,jj,Mj,Nj,Pj=o((()=>{Ag(),xue(),Tw(),OT(),Jb(),xO(),Ik=0,Lk=`p_`,Rk={basis:{curve:nue},"basis-closed":{curve:rue},"basis-open":{curve:aue},bundle:{curve:Xw,tension:`beta`,value:.85},cardinal:{curve:$w,tension:`tension`,value:0},"cardinal-open":{curve:aT,tension:`tension`,value:0},"cardinal-closed":{curve:nT,tension:`tension`,value:0},"catmull-rom":{curve:lT,tension:`alpha`,value:.5},"catmull-rom-closed":{curve:fT,tension:`alpha`,value:.5},"catmull-rom-open":{curve:mT,tension:`alpha`,value:.5},linear:{curve:Mw},"linear-closed":{curve:uue},monotone:{horizontal:pue,vertical:fue},natural:{curve:hue},step:{curve:_ue},"step-after":{curve:yue},"step-before":{curve:vue}},fge={m:2,l:2,h:1,v:1,z:0,c:6,s:4,q:4,t:2,a:7},pge=/[mlhvzcsqta]([^mlhvzcsqta]*)/gi,mge=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,hge=/^((\s+,?\s*)|(,\s*))/,gge=/^[01]/,zk=Math.PI/180,_ge=1e-14,Bk=Math.PI/2,Vk=Math.PI*2,Hk=Math.sqrt(3)/2,Uk={},Wk={},Gk=[].join,Kk=[`l`,0,0,0,0,0,0,0],qk=.5773502691896257,Jk={circle:{draw:function(e,t){let n=Math.sqrt(t)/2;e.moveTo(n,0),e.arc(0,0,n,0,Vk)}},cross:{draw:function(e,t){var n=Math.sqrt(t)/2,r=n/2.5;e.moveTo(-n,-r),e.lineTo(-n,r),e.lineTo(-r,r),e.lineTo(-r,n),e.lineTo(r,n),e.lineTo(r,r),e.lineTo(n,r),e.lineTo(n,-r),e.lineTo(r,-r),e.lineTo(r,-n),e.lineTo(-r,-n),e.lineTo(-r,-r),e.closePath()}},diamond:{draw:function(e,t){let n=Math.sqrt(t)/2;e.moveTo(-n,0),e.lineTo(0,-n),e.lineTo(n,0),e.lineTo(0,n),e.closePath()}},square:{draw:function(e,t){var n=Math.sqrt(t),r=-n/2;e.rect(r,r,n,n)}},arrow:{draw:function(e,t){var n=Math.sqrt(t)/2,r=n/7,i=n/2.5,a=n/8;e.moveTo(-r,n),e.lineTo(r,n),e.lineTo(r,-a),e.lineTo(i,-a),e.lineTo(0,-n),e.lineTo(-i,-a),e.lineTo(-r,-a),e.closePath()}},wedge:{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n,i=r-n*qk,a=n/4;e.moveTo(0,-r-i),e.lineTo(-a,r-i),e.lineTo(a,r-i),e.closePath()}},triangle:{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n,i=r-n*qk;e.moveTo(0,-r-i),e.lineTo(-n,r-i),e.lineTo(n,r-i),e.closePath()}},"triangle-up":{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n;e.moveTo(0,-r),e.lineTo(-n,r),e.lineTo(n,r),e.closePath()}},"triangle-down":{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n;e.moveTo(0,r),e.lineTo(-n,-r),e.lineTo(n,-r),e.closePath()}},"triangle-right":{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n;e.moveTo(r,0),e.lineTo(-r,-n),e.lineTo(-r,n),e.closePath()}},"triangle-left":{draw:function(e,t){var n=Math.sqrt(t)/2,r=Hk*n;e.moveTo(-r,0),e.lineTo(r,-n),e.lineTo(r,n),e.closePath()}},stroke:{draw:function(e,t){let n=Math.sqrt(t)/2;e.moveTo(-n,0),e.lineTo(n,0)}}},Yk={},Xk=.448084975506,Zk=e=>e.x||0,Qk=e=>e.y||0,vge=e=>e.width||0,yge=e=>e.height||0,bge=e=>(e.x||0)+(e.width||0),xge=e=>(e.y||0)+(e.height||0),Sge=e=>e.startAngle||0,Cge=e=>e.endAngle||0,wge=e=>e.padAngle||0,Tge=e=>e.innerRadius||0,Ege=e=>e.outerRadius||0,Dge=e=>e.cornerRadius||0,Oge=e=>kO(e.cornerRadiusTopLeft,e.cornerRadius)||0,kge=e=>kO(e.cornerRadiusTopRight,e.cornerRadius)||0,Age=e=>kO(e.cornerRadiusBottomRight,e.cornerRadius)||0,jge=e=>kO(e.cornerRadiusBottomLeft,e.cornerRadius)||0,Mge=e=>kO(e.size,64),Nge=e=>e.size||1,$k=e=>e.defined!==!1,Pge=e=>ime(e.shape||`circle`),Fge=Zle().startAngle(Sge).endAngle(Cge).padAngle(wge).innerRadius(Tge).outerRadius(Ege).cornerRadius(Dge),Ige=zw().x(Zk).y1(Qk).y0(xge).defined($k),Lge=zw().y(Qk).x1(Zk).x0(bge).defined($k),Rge=Lw().x(Zk).y(Qk).defined($k),zge=ume().x(Zk).y(Qk).width(vge).height(yge).cornerRadius(Oge,kge,Age,jge),Bge=eue().type(Pge).size(Mge),Vge=dme().x(Zk).y(Qk).defined($k).size(Nge),eA=1,NO.prototype={clone(){return new NO(this)},clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this},empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE},equals(e){return this.x1===e.x1&&this.y1===e.y1&&this.x2===e.x2&&this.y2===e.y2},set(e,t,n,r){return nthis.x2&&(this.x2=e),t>this.y2&&(this.y2=t),this},expand(e){return this.x1-=e,this.y1-=e,this.x2+=e,this.y2+=e,this},round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this},scale(e){return this.x1*=e,this.y1*=e,this.x2*=e,this.y2*=e,this},translate(e,t){return this.x1+=e,this.x2+=e,this.y1+=t,this.y2+=t,this},rotate(e,t,n){let r=this.rotatedPoints(e,t,n);return this.clear().add(r[0],r[1]).add(r[2],r[3]).add(r[4],r[5]).add(r[6],r[7])},rotatedPoints(e,t,n){var{x1:r,y1:i,x2:a,y2:o}=this,s=Math.cos(e),c=Math.sin(e),l=t-t*s+n*c,u=n-t*c-n*s;return[s*r-c*i+l,c*r+s*i+u,s*r-c*o+l,c*r+s*o+u,s*a-c*i+l,c*a+s*i+u,s*a-c*o+l,c*a+s*o+u]},union(e){return e.x1this.x2&&(this.x2=e.x2),e.y2>this.y2&&(this.y2=e.y2),this},intersect(e){return e.x1>this.x1&&(this.x1=e.x1),e.y1>this.y1&&(this.y1=e.y1),e.x2=e.x2&&this.y1<=e.y1&&this.y2>=e.y2},alignsWith(e){return e&&(this.x1==e.x1||this.x2==e.x2||this.y1==e.y1||this.y2==e.y2)},intersects(e){return e&&!(this.x2e.x2||this.y2e.y2)},contains(e,t){return!(ethis.x2||tthis.y2)},width(){return this.x2-this.x1},height(){return this.y2-this.y1}},U(FO,PO),tA=class{constructor(e){this._pending=0,this._loader=e||qb()}pending(){return this._pending}sanitizeURL(e){let t=this;return yme(t),t._loader.sanitize(e,{context:`href`}).then(e=>(IO(t),e)).catch(()=>(IO(t),null))}loadImage(e){let t=this,n=DT();return yme(t),t._loader.sanitize(e,{context:`image`}).then(e=>{let r=e.href;if(!r||!n)throw{url:r};let i=new n,a=fg(e,`crossOrigin`)?e.crossOrigin:`anonymous`;return a!=null&&(i.crossOrigin=a),i.onload=()=>IO(t),i.onerror=()=>IO(t),i.src=r,i}).catch(e=>(IO(t),{complete:!1,width:0,height:0,src:e&&e.url||``}))}ready(){let e=this;return new Promise(t=>{function n(r){e.pending()?setTimeout(()=>{n(!0)},10):t(r)}n(!1)})}},Hge=Vk-1e-8,uA=(e,t)=>nA.add(e,t),dA=(e,t)=>uA(rA=e,iA=t),fA=e=>uA(e,nA.y1),pA=e=>uA(nA.x1,e),mA=(e,t)=>oA*e+cA*t,hA=(e,t)=>sA*e+lA*t,gA=(e,t)=>uA(mA(e,t),hA(e,t)),_A=(e,t)=>dA(mA(e,t),hA(e,t)),Uge={beginPath(){},closePath(){},moveTo:_A,lineTo:_A,rect(e,t,n,r){aA?(gA(e+n,t),gA(e+n,t+r),gA(e,t+r),_A(e,t)):(uA(e+n,t+r),dA(e,t))},quadraticCurveTo(e,t,n,r){let i=mA(e,t),a=hA(e,t),o=mA(n,r),s=hA(n,r);bme(rA,i,o,fA),bme(iA,a,s,pA),dA(o,s)},bezierCurveTo(e,t,n,r,i,a){let o=mA(e,t),s=hA(e,t),c=mA(n,r),l=hA(n,r),u=mA(i,a),d=hA(i,a);xme(rA,o,c,u,fA),xme(iA,s,l,d,pA),dA(u,d)},arc(e,t,n,r,i,a){if(r+=aA,i+=aA,rA=n*Math.cos(i)+e,iA=n*Math.sin(i)+t,Math.abs(i-r)>Hge)uA(e-n,t-n),uA(e+n,t+n);else{let o=r=>uA(n*Math.cos(r)+e,n*Math.sin(r)+t),s,c;if(o(r),o(i),i!==r)if(r%=Vk,r<0&&(r+=Vk),i%=Vk,i<0&&(i+=Vk),ii;++c,s-=Bk)o(s);else for(s=r-r%Bk+Bk,c=0;c<4&&s=0;)if(e[r].type===t&&(!n||e[r].handler===n))return r;return-1}handlers(e){let t=this._handlers,n=[];if(e)n.push(...t[this.eventName(e)]);else for(let e in t)n.push(...t[e]);return n}eventName(e){let t=e.indexOf(`.`);return t<0?e:e.slice(0,t)}handleHref(e,t,n){this._loader.sanitize(n,{context:`href`}).then(t=>{let n=new MouseEvent(e.type,e),r=Ck(null,`a`);for(let e in t)r.setAttribute(e,t[e]);r.dispatchEvent(n)}).catch(()=>{})}handleTooltip(e,t,n){if(t&&t.tooltip!=null){t=Dhe(t,e,this.canvas(),this._origin);let r=n&&t&&t.tooltip||null;this._tooltip.call(this._obj,this,e,t,r)}}getItemBoundingClientRect(e){let t=this.canvas();if(!t)return;let n=t.getBoundingClientRect(),r=this._origin,i=e.bounds,a=i.width(),o=i.height(),s=i.x1+r[0]+n.left,c=i.y1+r[1]+n.top;for(;e.mark&&(e=e.mark.group);)s+=e.x||0,c+=e.y||0;return{x:s,y:c,width:a,height:o,left:s,top:c,right:s+a,bottom:c+o}}},OA=class{constructor(e){this._el=null,this._bgcolor=null,this._loader=new tA(e)}initialize(e,t,n,r,i){return this._el=e,this.resize(t,n,r,i)}element(){return this._el}canvas(){return this._el&&this._el.firstChild}background(e){return arguments.length===0?this._bgcolor:(this._bgcolor=e,this)}resize(e,t,n,r){return this._width=e,this._height=t,this._origin=n||[0,0],this._scale=r||1,this}dirty(){}render(e,t){let n=this;return n._call=function(){n._render(e,t)},n._call(),n._call=null,n}_render(){}renderAsync(e,t){let n=this.render(e,t);return this._ready?this._ready.then(()=>n):Promise.resolve(n)}_load(e,t){var n=this,r=n._loader[e](t);if(!n._ready){let e=n._call;n._ready=n._loader.ready().then(t=>{t&&e(),n._ready=null})}return r}sanitizeURL(e){return this._load(`sanitizeURL`,e)}loadImage(e){return this._load(`loadImage`,e)}},o_e=`keydown`,s_e=`keypress`,c_e=`keyup`,kA=`dragenter`,AA=`dragleave`,jA=`dragover`,MA=`pointerdown`,l_e=`pointerup`,NA=`pointermove`,PA=`pointerout`,FA=`pointerover`,IA=`mousedown`,u_e=`mouseup`,LA=`mousemove`,RA=`mouseout`,zA=`mouseover`,BA=`click`,d_e=`dblclick`,f_e=`wheel`,VA=`mousewheel`,HA=`touchstart`,UA=`touchmove`,WA=`touchend`,p_e=[o_e,s_e,c_e,kA,AA,jA,MA,l_e,NA,PA,FA,IA,u_e,LA,RA,zA,BA,d_e,f_e,VA,HA,UA,WA],GA=NA,KA=RA,qA=BA,JA=class extends DA{constructor(e,t){super(e,t),this._down=null,this._touch=null,this._first=!0,this._events={},this.events=p_e,this.pointermove=jhe([NA,LA],[FA,zA],[PA,RA]),this.dragover=jhe([jA],[kA],[AA]),this.pointerout=Mhe([PA,RA]),this.dragleave=Mhe([AA])}initialize(e,t,n){return this._canvas=e&&wk(e,`canvas`),[BA,IA,MA,NA,PA,AA].forEach(e=>khe(this,e)),super.initialize(e,t,n)}canvas(){return this._canvas}context(){return this._canvas.getContext(`2d`)}DOMMouseScroll(e){this.fire(VA,e)}pointerdown(e){this._down=this._active,this.fire(MA,e)}mousedown(e){this._down=this._active,this.fire(IA,e)}click(e){this._down===this._active&&(this.fire(BA,e),this._down=null)}touchstart(e){this._touch=this.pickEvent(e.changedTouches[0]),this._first&&=(this._active=this._touch,!1),this.fire(HA,e,!0)}touchmove(e){this.fire(UA,e,!0)}touchend(e){this.fire(WA,e,!0),this._touch=null}fire(e,t,n){let r=n?this._touch:this._active,i=this._handlers[e];if(t.vegaType=e,e===qA&&r&&r.href?this.handleHref(t,r,r.href):(e===GA||e===KA)&&this.handleTooltip(t,r,e!==KA),i)for(let e=0,n=i.length;e=0&&r.splice(i,1),this}pickEvent(e){let t=Dk(e,this._canvas),n=this._origin;return this.pick(this._scene,t[0],t[1],t[0]-n[0],t[1]-n[1])}pick(e,t,n,r,i){let a=this.context();return wA[e.marktype].pick.call(this,a,e,t,n,r,i)}},m_e=e=>e===HA||e===UA||e===WA?[HA,UA,WA]:[e],YA=class extends OA{constructor(e){super(e),this._options={},this._redraw=!1,this._dirty=new NO,this._tempb=new NO}initialize(e,t,n,r,i,a){return this._options=a||{},this._canvas=this._options.externalContext?null:ET(1,1,this._options.type),e&&this._canvas&&(Ek(e,0).appendChild(this._canvas),this._canvas.setAttribute(`class`,`marks`)),super.initialize(e,t,n,r,i)}resize(e,t,n,r){if(super.resize(e,t,n,r),this._canvas)Phe(this._canvas,this._width,this._height,this._origin,this._scale,this._options.context);else{let e=this._options.externalContext;e||V(`CanvasRenderer is missing a valid canvas or context`),e.scale(this._scale,this._scale),e.translate(this._origin[0],this._origin[1])}return this._redraw=!0,this}canvas(){return this._canvas}context(){return this._options.externalContext||(this._canvas?this._canvas.getContext(`2d`):null)}dirty(e){let t=this._tempb.clear().union(e.bounds),n=e.mark.group;for(;n;)t.translate(n.x||0,n.y||0),n=n.mark.group;this._dirty.union(t)}_render(e,t){let n=this.context(),r=this._origin,i=this._width,a=this._height,o=this._dirty,s=h_e(r,i,a);n.save();let c=this._redraw||o.empty()?(this._redraw=!1,s.expand(1)):Fhe(n,s.intersect(o),r);return this.clear(-r[0],-r[1],i,a),this.draw(n,e,c,t),n.restore(),o.clear(),this}draw(e,t,n,r){if(t.marktype!==`group`&&r!=null&&!r.includes(t.marktype))return;let i=wA[t.marktype];t.clip&&Rme(e,t),i.draw.call(this,e,t,n,r),t.clip&&e.restore()}clear(e,t,n,r){let i=this._options,a=this.context();i.type!==`pdf`&&!i.externalContext&&a.clearRect(e,t,n,r),this._bgcolor!=null&&(a.fillStyle=this._bgcolor,a.fillRect(e,t,n,r))}},h_e=(e,t,n)=>new NO().set(0,0,t,n).translate(-e[0],-e[1]),XA=class extends DA{constructor(e,t){super(e,t);let n=this;n._hrefHandler=ZA(n,(e,t)=>{t&&t.href&&n.handleHref(e,t,t.href)}),n._tooltipHandler=ZA(n,(e,t)=>{n.handleTooltip(e,t,e.type!==KA)})}initialize(e,t,n){let r=this._svg;return r&&(r.removeEventListener(qA,this._hrefHandler),r.removeEventListener(GA,this._tooltipHandler),r.removeEventListener(KA,this._tooltipHandler)),this._svg=r=e&&wk(e,`svg`),r&&(r.addEventListener(qA,this._hrefHandler),r.addEventListener(GA,this._tooltipHandler),r.addEventListener(KA,this._tooltipHandler)),super.initialize(e,t,n)}canvas(){return this._svg}on(e,t){let n=this.eventName(e),r=this._handlers;if(this._handlerIndex(r[n],e,t)<0){let i={type:e,handler:t,listener:ZA(this,t)};(r[n]||(r[n]=[])).push(i),this._svg&&this._svg.addEventListener(n,i.listener)}return this}off(e,t){let n=this.eventName(e),r=this._handlers[n],i=this._handlerIndex(r,e,t);return i>=0&&(this._svg&&this._svg.removeEventListener(n,r[i].listener),r.splice(i,1)),this}},ZA=(e,t)=>n=>{let r=n.target.__data__;r=Array.isArray(r)?r[0]:r,n.vegaType=n.type,t.call(e._obj,n,r)},QA=`aria-hidden`,$A=`aria-label`,ej=`role`,tj=`aria-roledescription`,nj=`graphics-object`,rj=`graphics-symbol`,ij=(e,t,n)=>({[ej]:e,[tj]:t,[$A]:n||void 0}),aj=Og([`axis-domain`,`axis-grid`,`axis-label`,`axis-tick`,`axis-title`,`legend-band`,`legend-entry`,`legend-gradient`,`legend-label`,`legend-title`,`legend-symbol`,`title`]),oj={axis:{desc:`axis`,caption:Vhe},legend:{desc:`legend`,caption:Hhe},"title-text":{desc:`title`,caption:e=>`Title text '${Bhe(e)}'`},"title-subtitle":{desc:`subtitle`,caption:e=>`Subtitle text '${Bhe(e)}'`}},sj={ariaRole:ej,ariaRoleDescription:tj,description:$A},cj=e=>(e+``).replace(/&/g,`&`).replace(//g,`>`),lj=e=>cj(e).replace(/"/g,`"`).replace(/\t/g,` `).replace(/\n/g,` `).replace(/\r/g,` `),uj=e=>Khe(kk(),e)+``,dj={fill:`fill`,fillOpacity:`fill-opacity`,stroke:`stroke`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,strokeCap:`stroke-linecap`,strokeJoin:`stroke-linejoin`,strokeDash:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeMiterLimit:`stroke-miterlimit`,opacity:`opacity`},fj={blend:`mix-blend-mode`},pj={fill:`none`,"stroke-miterlimit":4},mj=0,hj=`http://www.w3.org/2000/xmlns/`,gj=bA.xmlns,_j=class extends OA{constructor(e){super(e),this._dirtyID=0,this._dirty=[],this._svg=null,this._root=null,this._defs=null}initialize(e,t,n,r,i){return this._defs={},this._clearDefs(),e&&(this._svg=Tk(e,0,`svg`,gj),this._svg.setAttributeNS(hj,`xmlns`,gj),this._svg.setAttributeNS(hj,`xmlns:xlink`,bA[`xmlns:xlink`]),this._svg.setAttribute(`version`,bA.version),this._svg.setAttribute(`class`,`marks`),Ek(e,1),this._root=Tk(this._svg,mj,`g`,gj),Mk(this._root,pj),Ek(this._svg,1)),this.background(this._bgcolor),super.initialize(e,t,n,r,i)}background(e){return arguments.length&&this._svg&&this._svg.style.setProperty(`background-color`,e),super.background(...arguments)}resize(e,t,n,r){return super.resize(e,t,n,r),this._svg&&(Mk(this._svg,{width:this._width*this._scale,height:this._height*this._scale,viewBox:`0 0 ${this._width} ${this._height}`}),this._root.setAttribute(`transform`,`translate(${this._origin})`)),this._dirty=[],this}canvas(){return this._svg}svg(){let e=this._svg,t=this._bgcolor;if(!e)return null;let n;t&&(e.removeAttribute(`style`),n=Tk(e,mj,`rect`,gj),Mk(n,{width:this._width,height:this._height,fill:t}));let r=uj(e);return t&&(e.removeChild(n),this._svg.style.setProperty(`background-color`,t)),r}_render(e,t){return this._dirtyCheck()&&(this._dirtyAll&&this._clearDefs(),this.mark(this._root,e,void 0,t),Ek(this._root,1)),this.defs(),this._dirty=[],++this._dirtyID,this}dirty(e){e.dirty!==this._dirtyID&&(e.dirty=this._dirtyID,this._dirty.push(e))}isDirty(e){return this._dirtyAll||!e._svg||!e._svg.ownerSVGElement||e.dirty===this._dirtyID}_dirtyCheck(){this._dirtyAll=!0;let e=this._dirty;if(!e.length||!this._dirtyID)return!0;let t=++this._dirtyID,n,r,i,a,o,s,c;for(o=0,s=e.length;o{e.dirty=t})),!r.zdirty){if(n.exit){a.nested&&r.items.length?(c=r.items[0],c._svg&&this._update(a,c._svg,c)):n._svg&&(c=n._svg.parentNode,c&&c.removeChild(n._svg)),n._svg=null;continue}n=a.nested?r.items[0]:n,n._update!==t&&(!n._svg||!n._svg.ownerSVGElement?(this._dirtyAll=!1,qhe(n,t)):this._update(a,n._svg,n),n._update=t)}return!this._dirtyAll}mark(e,t,n,r){if(!this.isDirty(t))return t._svg;let i=this._svg,a=t.marktype,o=wA[a],s=t.interactive===!1?`none`:null,c=o.tag===`g`,l=Zhe(t,e,n,`g`,i);if(a!==`group`&&r!=null&&!r.includes(a))return Ek(l,0),t._svg;l.setAttribute(`class`,whe(t));let u=Lhe(t);for(let e in u)Nk(l,e,u[e]);c||Nk(l,`pointer-events`,s),Nk(l,`clip-path`,t.clip?MO(this,t,t.group):null);let d=null,f=0,p=e=>{let t=this.isDirty(e),n=Zhe(e,l,d,o.tag,i);t&&(this._update(o,n,e),c&&Xhe(this,n,e,r)),d=n,++f};return o.nested?t.items.length&&p(t.items[0]):qO(t,p),Ek(l,f),l}_update(e,t,n){vj=t,yj=t.__values__,Ihe(Ak,n),e.attr(Ak,n,this);let r=bj[e.type];r&&r.call(this,e,t,n),vj&&this.style(vj,n)}style(e,t){if(t!=null){for(let n in dj){let r=n===`font`?_k(t):t[n];if(r===yj[n])continue;let i=dj[n];r==null?e.removeAttribute(i):(SO(r)&&(r=Zpe(r,this._defs.gradient,ege())),e.setAttribute(i,r+``)),yj[n]=r}for(let n in fj)jk(e,fj[n],t[n])}}defs(){let e=this._svg,t=this._defs,n=t.el,r=0;for(let i in t.gradient)n||(t.el=n=Tk(e,1,`defs`,gj)),r=Jhe(n,t.gradient[i],r);for(let i in t.clipping)n||(t.el=n=Tk(e,1,`defs`,gj)),r=Yhe(n,t.clipping[i],r);n&&(r===0?(e.removeChild(n),t.el=null):Ek(n,r))}_clearDefs(){let e=this._defs;e.gradient={},e.clipping={}}},vj=null,yj=null,bj={group(e,t,n){let r=vj=t.childNodes[2];yj=r.__values__,e.foreground(Ak,n,this),yj=t.__values__,vj=t.childNodes[1],e.content(Ak,n,this);let i=vj=t.childNodes[0];e.background(Ak,n,this);let a=n.mark.interactive===!1?`none`:null;if(a!==yj.events&&(Nk(r,`pointer-events`,a),Nk(i,`pointer-events`,a),yj.events=a),n.strokeForeground&&n.stroke){let e=n.fill;Nk(r,`display`,null),this.style(i,n),Nk(i,`stroke`,null),e&&(n.fill=null),yj=r.__values__,this.style(r,n),e&&(n.fill=e),vj=null}else Nk(r,`display`,`none`)},image(e,t,n){n.smooth===!1?(jk(t,`image-rendering`,`optimizeSpeed`),jk(t,`image-rendering`,`pixelated`)):jk(t,`image-rendering`,null)},text(e,t,n){let r=mk(n),i,a,o,s;H(r)?(a=r.map(e=>gk(n,e)),i=a.join(` +`),i!==yj.text&&(Ek(t,0),o=t.ownerDocument,s=pk(n),a.forEach((e,r)=>{let i=Ck(o,`tspan`,gj);i.__data__=n,i.textContent=e,r&&(i.setAttribute(`x`,0),i.setAttribute(`dy`,s)),t.appendChild(i)}),yj.text=i)):(a=gk(n,r),a!==yj.text&&(t.textContent=a,yj.text=a)),Nk(t,`font-family`,_k(n)),Nk(t,`font-size`,fk(n)+`px`),Nk(t,`font-style`,n.fontStyle),Nk(t,`font-variant`,n.fontVariant),Nk(t,`font-weight`,n.fontWeight)}},xj=class extends OA{constructor(e){super(e),this._text=null,this._defs={gradient:{},clipping:{}}}svg(){return this._text}_render(e){let t=kk();t.open(`svg`,ug({},bA,{class:`marks`,width:this._width*this._scale,height:this._height*this._scale,viewBox:`0 0 ${this._width} ${this._height}`}));let n=this._bgcolor;return n&&n!==`transparent`&&n!==`none`&&t.open(`rect`,{width:this._width,height:this._height,fill:n}).close(),t.open(`g`,pj,{transform:`translate(`+this._origin+`)`}),this.mark(t,e),t.close(),this.defs(t),this._text=t.close()+``,this}mark(e,t){let n=wA[t.marktype],r=n.tag,i=[Ihe,n.attr];e.open(`g`,{class:whe(t),"clip-path":t.clip?MO(this,t,t.group):null},Lhe(t),{"pointer-events":r!==`g`&&t.interactive===!1?`none`:null});let a=a=>{let o=this.href(a);if(o&&e.open(`a`,o),e.open(r,this.attr(t,a,i,r===`g`?null:r)),r===`text`){let t=mk(a);if(H(t)){let n={x:0,dy:pk(a)};for(let r=0;rthis.mark(e,t)),e.close(),r&&o?(i&&(a.fill=null),a.stroke=o,e.open(`path`,this.attr(t,a,n.foreground,`bgrect`)).close(),i&&(a.fill=i)):e.open(`path`,this.attr(t,a,n.foreground,`bgfore`)).close()}e.close(),o&&e.close()};return n.nested?t.items&&t.items.length&&a(t.items[0]):qO(t,a),e.close()}href(e){let t=e.href,n;if(t){if(n=this._hrefs&&this._hrefs[t])return n;this.sanitizeURL(t).then(e=>{e[`xlink:href`]=e.href,e.href=null,(this._hrefs||={})[t]=e})}return null}attr(e,t,n,r){let i={},a=(e,t,n,r)=>{i[r||e]=t};return Array.isArray(n)?n.forEach(e=>e(a,t,this)):n(a,t,this),r&&tge(i,t,e,r,this._defs),i}defs(e){let t=this._defs.gradient,n=this._defs.clipping;if(Object.keys(t).length+Object.keys(n).length!==0){e.open(`defs`);for(let n in t){let r=t[n],i=r.stops;r.gradient===`radial`?(e.open(`pattern`,{id:Lk+n,viewBox:`0,0,1,1`,width:`100%`,height:`100%`,preserveAspectRatio:`xMidYMid slice`}),e.open(`rect`,{width:`1`,height:`1`,fill:`url(#`+n+`)`}).close(),e.close(),e.open(`radialGradient`,{id:n,fx:r.x1,fy:r.y1,fr:r.r1,cx:r.x2,cy:r.y2,r:r.r2})):e.open(`linearGradient`,{id:n,x1:r.x1,x2:r.x2,y1:r.y1,y2:r.y2});for(let t=0;t!Sj.svgMarkTypes.includes(e));this._svgRenderer.render(e,Sj.svgMarkTypes),this._canvasRenderer.render(e,n)}resize(e,t,n,r){return super.resize(e,t,n,r),this._svgRenderer.resize(e,t,n,r),this._canvasRenderer.resize(e,t,n,r),this}background(e){return Sj.svgOnTop?this._canvasRenderer.background(e):this._svgRenderer.background(e),this}},wj=class extends JA{constructor(e,t){super(e,t)}initialize(e,t,n){let r=Tk(Tk(e,0,`div`),+!Sj.svgOnTop,`div`);return super.initialize(r,t,n)}},Tj=`canvas`,Ej=`hybrid`,Dj=`png`,Oj=`svg`,kj=`none`,Aj={Canvas:Tj,PNG:Dj,SVG:Oj,Hybrid:Ej,None:kj},jj={},jj[Tj]=jj[Dj]={renderer:YA,headless:YA,handler:JA},jj[Oj]={renderer:_j,headless:xj,handler:XA},jj[Ej]={renderer:Cj,headless:Cj,handler:wj},jj[kj]={},Mj=new NO,Nj=1e-9})),g_e=c({bound:()=>Fj,identifier:()=>Lj,mark:()=>Rj,overlap:()=>zj,render:()=>Bj,viewlayout:()=>Xj});function Fj(e){G.call(this,null,e)}function Ij(e,t,n){return t(e.bounds.clear(),e,n)}function Lj(e){G.call(this,0,e)}function __e(e){return e._signals[FM]||(e._signals[FM]=e.add(0))}function Rj(e){G.call(this,null,e)}function v_e(e){let t=e.groups,n=e.parent;return t&&t.size===1?t.get(Object.keys(t.object)[0]):t&&n?t.lookup(n):null}function zj(e){G.call(this,null,e)}function Bj(e){G.call(this,null,e)}function Vj(e,t,n){return e[t]===n?0:(e[t]=n,1)}function y_e(e){var t=e.items[0].orient;return t===Qj||t===$j}function b_e(e){let t=+e.grid;return[e.ticks?t++:-1,e.labels?t++:-1,t+ +e.domain]}function x_e(e,t,n,r){var i=t.items[0],a=i.datum,o=i.translate==null?.5:i.translate,s=i.orient,c=b_e(a),l=i.range,u=i.offset,d=i.position,f=i.minExtent,p=i.maxExtent,m=a.title&&i.items[c[2]].items[0],h=i.titlePadding,g=i.bounds,_=m&&hk(m),v=0,y=0,b,x;switch(UM.clear().union(g),g.clear(),(b=c[0])>-1&&g.union(i.items[b].bounds),(b=c[1])>-1&&g.union(i.items[b].bounds),s){case Zj:v=d||0,y=-u,x=Math.max(f,Math.min(p,-g.y1)),g.add(0,-x).add(l,0),m&&Hj(e,m,x,h,_,0,-1,g);break;case Qj:v=-u,y=d||0,x=Math.max(f,Math.min(p,-g.x1)),g.add(-x,0).add(0,l),m&&Hj(e,m,x,h,_,1,-1,g);break;case $j:v=n+u,y=d||0,x=Math.max(f,Math.min(p,g.x2)),g.add(0,0).add(x,l),m&&Hj(e,m,x,h,_,1,1,g);break;case eM:v=d||0,y=r+u,x=Math.max(f,Math.min(p,g.y2)),g.add(0,0).add(l,x),m&&Hj(e,m,x,h,0,0,1,g);break;default:v=i.x,y=i.y}return LO(g.translate(v,y),i),Vj(i,`x`,v+o)|Vj(i,`y`,y+o)&&(i.bounds=UM,e.dirty(i),i.bounds=g,e.dirty(i)),i.mark.bounds.clear().union(g)}function Hj(e,t,n,r,i,a,o,s){let c=t.bounds;if(t.auto){let s=o*(n+i+r),l=0,u=0;e.dirty(t),a?l=(t.x||0)-(t.x=s):u=(t.y||0)-(t.y=s),t.mark.bounds.clear().union(c.translate(-l,-u)),e.dirty(t)}s.union(c)}function S_e(e){var t=e.items,n=t.length,r=0,i,a;let o={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};for(;r1)for(C=0;C0&&(y[C]+=A/2);if(s&&Uj(n.center,PM)&&u!==1)for(C=0;C0&&(b[C]+=j/2);for(C=0;Ci&&(e.warn(`Grid headers exceed limit: `+i),t=t.slice(0,i)),h+=a,v=0,b=t.length;v=0&&(C=n[y])==null;y-=f);s?(w=p==null?C.x:Math.round(C.bounds.x1+p*C.bounds.width()),T=h):(w=h,T=p==null?C.y:Math.round(C.bounds.y1+p*C.bounds.height())),x.union(S.bounds.translate(w-(S.x||0),T-(S.y||0))),S.x=w,S.y=T,e.dirty(S),g=o(g,x[l])}return g}function qj(e,t,n,r,i,a){if(t){e.dirty(t);var o=n,s=n;r?o=Math.round(i.x1+a*i.width()):s=Math.round(i.y1+a*i.height()),t.bounds.translate(o-(t.x||0),s-(t.y||0)),t.mark.bounds.clear().union(t.bounds),t.x=o,t.y=s,e.dirty(t)}}function O_e(e,t){let n=e[t]||{};return(t,r)=>n[t]==null?e[t]==null?r:e[t]:n[t]}function k_e(e,t){let n=-1/0;return e.forEach(e=>{e.offset!=null&&(n=Math.max(n,e.offset))}),n>-1/0?n:t}function A_e(e,t,n,r,i,a,o){let s=O_e(n,t),c=k_e(e,s(`offset`,0)),l=s(`anchor`,aM),u=s(`frame`,uM),d=l===sM?1:l===oM?.5:0,f=u===dM?r.x1+d*r.width():d*(a||i.width()+2*i.x1),p=u===dM?i.y1+d*i.height():d*(o||r.height()+2*r.y1),m={align:jM,bounds:s(`bounds`,MM),columns:s(`direction`)===`vertical`?1:e.length,padding:s(`margin`,8),center:s(`center`),nodirty:!0};switch(t){case Qj:m.anchor={x:Math.floor(r.x1)-c,column:sM,y:p,row:l};break;case $j:m.anchor={x:Math.ceil(r.x2)+c,y:p,row:l};break;case Zj:m.anchor={y:Math.floor(i.y1)-c,row:sM,x:f,column:l};break;case eM:m.anchor={y:Math.ceil(i.y2)+c,x:f,column:l};break;case tM:m.anchor={x:c,y:c};break;case nM:m.anchor={x:a-c,y:c,column:sM};break;case rM:m.anchor={x:c,y:o-c,row:sM};break;case iM:m.anchor={x:a-c,y:o-c,column:sM,row:sM};break}return m}function j_e(e,t){var n=t.items[0],r=n.datum,i=n.orient,a=n.bounds,o=n.x,s=n.y,c,l;return n._bounds?n._bounds.clear().union(a):n._bounds=a.clone(),a.clear(),N_e(e,n,n.items[0].items[0]),a=M_e(n,a),c=2*n.padding,l=2*n.padding,a.empty()||(c=Math.ceil(a.width()+c),l=Math.ceil(a.height()+l)),r.type===wM&&P_e(n.items[0].items[0].items[0].items),i!==kM&&(n.x=o=0,n.y=s=0),n.width=c,n.height=l,LO(a.set(o,s,o+c,s+l),n),n.mark.bounds.clear().union(a),n}function M_e(e,t){return e.items.forEach(e=>t.union(e.bounds)),t.empty()&&(t.x2=e.padding,t.y2=e.padding),t.x1=e.padding,t.y1=e.padding,t}function N_e(e,t,n){var r=t.padding,i=r-n.x,a=r-n.y;if(!t.datum.title)(i||a)&&Yj(e,n,i,a);else{var o=t.items[1].items[0],s=o.anchor,c=t.titlePadding||0,l=r-o.x,u=r-o.y;switch(o.orient){case Qj:i+=Math.ceil(o.bounds.width())+c;break;case $j:case eM:break;default:a+=o.bounds.height()+c}switch((i||a)&&Yj(e,n,i,a),o.orient){case Qj:u+=Jj(t,n,o,s,1,1);break;case $j:l+=Jj(t,n,o,sM,0,0)+c,u+=Jj(t,n,o,s,1,1);break;case eM:l+=Jj(t,n,o,s,0,0),u+=Jj(t,n,o,sM,-1,0,1)+c;break;default:l+=Jj(t,n,o,s,0,0)}(l||u)&&Yj(e,o,l,u),(l=Math.round(o.bounds.x1-r))<0&&(Yj(e,n,-l,0),Yj(e,o,-l,0))}}function Jj(e,t,n,r,i,a,o){let s=e.datum.type!==`symbol`,c=n.datum.vgrad,l=(s&&(a||!c)&&!o?t.items[0]:t).bounds[i?`y2`:`x2`]-e.padding,u=c&&a?l:0,d=c&&a?0:l,f=i<=0?0:hk(n);return Math.round(r===aM?u:r===sM?d-f:.5*(l-f))}function Yj(e,t,n,r){t.x+=n,t.y+=r,t.bounds.translate(n,r),t.mark.bounds.translate(n,r),e.dirty(t)}function P_e(e){let t=e.reduce((e,t)=>(e[t.column]=Math.max(t.bounds.x2-t.x,e[t.column]||0),e),{});e.forEach(e=>{e.width=t[e.column],e.height=e.bounds.y2-e.y})}function F_e(e,t,n,r,i){var a=t.items[0],o=a.frame,s=a.orient,c=a.anchor,l=a.offset,u=a.padding,d=a.items[0].items[0],f=a.items[1]&&a.items[1].items[0],p=s===Qj||s===$j?r:n,m=0,h=0,g=0,_=0,v=0,y;if(o===uM?s===Qj&&(m=r,p=0):s===Qj?(m=i.y2,p=i.y1):s===$j?(m=i.y1,p=i.y2):(m=i.x1,p=i.x2),y=c===aM?m:c===sM?p:(m+p)/2,f&&f.text){switch(s){case Zj:case eM:v=d.bounds.height()+u;break;case Qj:_=d.bounds.width()+u;break;case $j:_=-d.bounds.width()-u;break}UM.clear().union(f.bounds),UM.translate(_-(f.x||0),v-(f.y||0)),Vj(f,`x`,_)|Vj(f,`y`,v)&&(e.dirty(f),f.bounds.clear().union(UM),f.mark.bounds.clear().union(UM),e.dirty(f)),UM.clear().union(f.bounds)}else UM.clear();switch(UM.union(d.bounds),s){case Zj:h=y,g=i.y1-UM.height()-l;break;case Qj:h=i.x1-UM.width()-l,g=y;break;case $j:h=i.x2+UM.width()+l,g=y;break;case eM:h=y,g=i.y2+l;break;default:h=a.x,g=a.y}return Vj(a,`x`,h)|Vj(a,`y`,g)&&(UM.translate(h,g),e.dirty(a),a.bounds.clear().union(UM),t.bounds.clear().union(UM),e.dirty(a)),a.bounds}function Xj(e){G.call(this,null,e)}function I_e(e){return e&&e.mark.role!==`legend-entry`}function L_e(e,t,n){var r=t.items,i=Math.max(0,t.width||0),a=Math.max(0,t.height||0),o=new NO().set(0,0,i,a),s=o.clone(),c=o.clone(),l=[],u,d,f,p,m,h;for(m=0,h=r.length;m{f=e.orient||$j,f!==kM&&(t[f]||(t[f]=[])).push(e)});for(let r in t){let o=t[r];Gj(e,o,A_e(o,r,n.legends,s,c,i,a))}l.forEach(t=>{let r=t.bounds;if(r.equals(t._bounds)||(t.bounds=t._bounds,e.dirty(t),t.bounds=r,e.dirty(t)),n.autosize&&(n.autosize.type===TM||n.autosize.type===EM||n.autosize.type===DM))switch(t.orient){case Qj:case $j:o.add(r.x1,0).add(r.x2,0);break;case Zj:case eM:o.add(0,r.y1).add(0,r.y2)}else o.union(r)})}o.union(s).union(c),u&&o.union(F_e(e,u,i,a,o)),t.clip&&o.set(0,0,t.width||0,t.height||0),R_e(e,t,o,n)}function R_e(e,t,n,r){let i=r.autosize||{},a=i.type;if(e._autosize<1||!a)return;let o=e._width,s=e._height,c=Math.max(0,t.width||0),l=Math.max(0,Math.ceil(-n.x1)),u=Math.max(0,t.height||0),d=Math.max(0,Math.ceil(-n.y1)),f=Math.max(0,Math.ceil(n.x2-c)),p=Math.max(0,Math.ceil(n.y2-u));if(i.contains===CM){let t=e.padding();o-=t.left+t.right,s-=t.top+t.bottom}a===kM?(l=0,d=0,c=o,u=s):a===TM?(c=Math.max(0,o-l-f),u=Math.max(0,s-d-p)):a===EM?(c=Math.max(0,o-l-f),s=u+d+p):a===DM?(o=c+l+f,u=Math.max(0,s-d-p)):a===OM&&(o=c+l+f,s=u+d+p),e._resizeView(o,s,c,u,[l,d],i.resize)}var Zj,Qj,$j,eM,tM,nM,rM,iM,aM,oM,sM,cM,lM,uM,dM,fM,pM,mM,hM,gM,_M,vM,yM,bM,xM,SM,CM,wM,TM,EM,DM,OM,kM,AM,jM,MM,NM,PM,FM,IM,LM,RM,zM,BM,VM,HM,UM,WM,GM,z_e=o((()=>{Kx(),Pj(),Ag(),Zj=`top`,Qj=`left`,$j=`right`,eM=`bottom`,tM=`top-left`,nM=`top-right`,rM=`bottom-left`,iM=`bottom-right`,aM=`start`,oM=`middle`,sM=`end`,cM=`x`,lM=`y`,uM=`group`,dM=`bounds`,fM=`axis`,pM=`title`,mM=`frame`,hM=`scope`,gM=`legend`,_M=`row-header`,vM=`row-footer`,yM=`row-title`,bM=`column-header`,xM=`column-footer`,SM=`column-title`,CM=`padding`,wM=`symbol`,TM=`fit`,EM=`fit-x`,DM=`fit-y`,OM=`pad`,kM=`none`,AM=`all`,jM=`each`,MM=`flush`,NM=`column`,PM=`row`,U(Fj,G,{transform(e,t){let n=t.dataflow,r=e.mark,i=r.marktype,a=wA[i],o=a.bound,s=r.bounds,c;if(a.nested)r.items.length&&n.dirty(r.items[0]),s=Ij(r,o),r.items.forEach(e=>{e.bounds.clear().union(s)});else if(i===uM||e.modified())switch(t.visit(t.MOD,e=>n.dirty(e)),s.clear(),r.items.forEach(e=>s.union(Ij(e,o))),r.role){case fM:case gM:case pM:t.reflow()}else c=t.changed(t.REM),t.visit(t.ADD,e=>{s.union(Ij(e,o))}),t.visit(t.MOD,e=>{c||=s.alignsWith(e.bounds),n.dirty(e),s.union(Ij(e,o))}),c&&(s.clear(),r.items.forEach(e=>s.union(e.bounds)));return cge(r),t.modifies(`bounds`)}}),FM=`:vega_identifier:`,Lj.Definition={type:`Identifier`,metadata:{modifies:!0},params:[{name:`as`,type:`string`,required:!0}]},U(Lj,G,{transform(e,t){let n=__e(t.dataflow),r=e.as,i=n.value;return t.visit(t.ADD,e=>e[r]=e[r]||++i),n.set(this.value=i),t}}),U(Rj,G,{transform(e,t){let n=this.value;n||(n=t.dataflow.scenegraph().mark(e.markdef,v_e(e),e.index),n.group.context=e.context,e.context.group||(e.context.group=n.group),n.source=this.source,n.clip=e.clip,n.interactive=e.interactive,this.value=n);let r=n.marktype===uM?FO:PO;return t.visit(t.ADD,e=>r.call(e,n)),(e.modified(`clip`)||e.modified(`interactive`))&&(n.clip=e.clip,n.interactive=!!e.interactive,n.zdirty=!0,t.reflow()),n.items=t.source,t}}),IM={parity:e=>e.filter((e,t)=>t%2?e.opacity=0:1),greedy:(e,t)=>{let n;return e.filter((e,r)=>!r||!LM(n.bounds,e.bounds,t)?(n=e,1):e.opacity=0)}},LM=(e,t,n)=>n>Math.max(t.x1-e.x2,e.x1-t.x2,t.y1-e.y2,e.y1-t.y2),RM=(e,t)=>{for(var n=1,r=e.length,i=e[0].bounds,a;n{let t=e.bounds;return t.width()>1&&t.height()>1},BM=(e,t,n)=>{var r=e.range(),i=new NO;return t===Zj||t===eM?i.set(r[0],-1/0,r[1],1/0):i.set(-1/0,r[0],1/0,r[1]),i.expand(n||1),e=>i.encloses(e.bounds)},VM=e=>(e.forEach(e=>e.opacity=1),e),HM=(e,t)=>e.reflow(t.modified()).modifies(`opacity`),U(zj,G,{transform(e,t){let n=IM[e.method]||IM.parity,r=e.separation||0,i=t.materialize(t.SOURCE).source,a,o;if(!i||!i.length)return;if(!e.method)return e.modified(`method`)&&(VM(i),t=HM(t,e)),t;if(i=i.filter(zM),!i.length)return;if(e.sort&&(i=i.slice().sort(e.sort)),a=VM(i),t=HM(t,e),a.length>=3&&RM(a,r)){do a=n(a,r);while(a.length>=3&&RM(a,r));a.length<3&&!Mh(i).opacity&&(a.length>1&&(Mh(a).opacity=0),Mh(i).opacity=1)}e.boundScale&&e.boundTolerance>=0&&(o=BM(e.boundScale,e.boundOrient,+e.boundTolerance),i.forEach(e=>{o(e)||(e.opacity=0)}));let s=a[0].mark.bounds.clear();return i.forEach(e=>{e.opacity&&s.union(e.bounds)}),t}}),U(Bj,G,{transform(e,t){let n=t.dataflow;if(t.visit(t.ALL,e=>n.dirty(e)),t.fields&&t.fields.zindex){let e=t.source&&t.source[0];e&&(e.mark.zdirty=!0)}}}),UM=new NO,WM=(e,t)=>Math.floor(Math.min(e,t)),GM=(e,t)=>Math.ceil(Math.max(e,t)),U(Xj,G,{transform(e,t){let n=t.dataflow;return e.mark.items.forEach(t=>{e.layout&&T_e(n,t,e.layout),L_e(n,t,e)}),I_e(e.mark.group)?t.reflow():t}})})),B_e=c({axisticks:()=>KM,datajoin:()=>qM,encode:()=>JM,legendentries:()=>YM,linkpath:()=>XM,pie:()=>ZM,scale:()=>$M,sortitems:()=>rN,stack:()=>iN});function KM(e){G.call(this,null,e)}function qM(e){G.call(this,null,e)}function V_e(){return ex({})}function H_e(e){let t=mg().test(e=>e.exit);return t.lookup=n=>t.get(e(n)),t}function JM(e){G.call(this,null,e)}function YM(e){G.call(this,[],e)}function XM(e){G.call(this,{},e)}function ZM(e){G.call(this,null,e)}function U_e(e){let t=e.type;return!e.bins&&(t===`linear`||t===`pow`||t===`sqrt`)}function QM(e){return KD(e)&&e!==`sequential`}function $M(e){G.call(this,null,e),this.modified(!0)}function W_e(e){var t=e.type,n=``,r;return t===`sequential`?iO+`-`+tO:(G_e(e)&&(r=e.rawDomain?e.rawDomain.length:e.domain?e.domain.length+ +(e.domainMid!=null):0,n=r===2?iO+`-`:r===3?aO+`-`:``),(n+t||`linear`).toLowerCase())}function G_e(e){let t=e.type;return KD(t)&&t!==`time`&&t!==`utc`&&(e.scheme||e.range&&e.range.length&&e.range.every(xg))}function K_e(e,t,n){let r=q_e(e,t.domainRaw,n);if(r>-1)return r;var i=t.domain,a=e.type,o=t.zero||t.zero===void 0&&U_e(e),s,c;if(!i)return 0;if((o||t.domainMin!=null||t.domainMax!=null||t.domainMid!=null)&&(s=(i=i.slice()).length-1||1,o&&(i[0]>0&&(i[0]=0),i[s]<0&&(i[s]=0)),t.domainMin!=null&&(i[0]=t.domainMin),t.domainMax!=null&&(i[s]=t.domainMax),t.domainMid!=null)){c=t.domainMid;let e=c>i[s]?s+1:ce+(t<0?-1:+(t>0)),0))!==t.length&&n.warn(`Log scale domain includes zero: `+W(t)),t}function Y_e(e,t,n){let r=t.bins;if(r&&!H(r)){let t=e.domain(),n=t[0],i=Mh(t),a=r.step,o=r.start==null?n:r.start,s=r.stop==null?i:r.stop;a||V(`Scale bins parameter missing step property.`),oi&&(s=a*Math.floor(i/a)),r=n_(o,s+a/2,a)}return r?e.bins=r:e.bins&&delete e.bins,e.type===`bin-ordinal`&&(r?!t.domain&&!t.domainRaw&&(e.domain(r),n=r.length):e.bins=e.domain()),n}function X_e(e,t,n){var r=e.type,i=t.round||!1,a=t.range;if(t.rangeStep!=null)a=Z_e(r,t,n);else if(t.scheme&&(a=Q_e(r,t,n),ig(a))){if(e.interpolator)return e.interpolator(a);V(`Scale type ${r} does not support interpolating color schemes.`)}if(a&&ppe(r))return e.interpolator(XD(nN(a,t.reverse),t.interpolate,t.interpolateGamma));a&&t.interpolate&&e.interpolate?e.interpolate(ZD(t.interpolate,t.interpolateGamma)):ig(e.round)?e.round(i):ig(e.rangeRound)&&e.interpolate(i?uD:cD),a&&e.range(nN(a,t.reverse))}function Z_e(e,t,n){e!==`band`&&e!==`point`&&V(`Only band and point scales support rangeStep.`);var r=(t.paddingOuter==null?t.padding:t.paddingOuter)||0,i=e===`point`?1:(t.paddingInner==null?t.padding:t.paddingInner)||0;return[0,t.rangeStep*HD(n,i,r)]}function Q_e(e,t,n){var r=t.schemeExtent,i,a;return H(t.scheme)?a=XD(t.scheme,t.interpolate,t.interpolateGamma):(i=t.scheme.toLowerCase(),a=QD(i),a||V(`Unrecognized scheme name: ${t.scheme}`)),n=e===`threshold`?n+1:e===`bin-ordinal`?n-1:e===`quantile`||e===`quantize`?+t.schemeCount||SN:n,ppe(e)?tN(a,r,t.reverse):ig(a)?gpe(tN(a,r),n):e===`ordinal`?a:a.slice(0,n)}function tN(e,t,n){return ig(e)&&(t||n)?hpe(e,nN(t||[0,1],n)):e}function nN(e,t){return t?e.slice().reverse():e}function rN(e){G.call(this,null,e)}function iN(e){G.call(this,null,e)}function $_e(e,t,n,r,i){for(var a=(t-e.sum)/2,o=e.length,s=0,c;se(u),o,s,c,l,u,d,f,p,m;if(t==null)i.push(e.slice());else for(o={},s=0,c=e.length;sm&&(m=p),n&&f.sort(n)}return i.max=m,i}var aN,oN,sN,cN,lN,uN,dN,fN,pN,mN,hN,gN,_N,vN,yN,bN,xN,SN,CN,wN,TN,EN,DN,rve=o((()=>{Kx(),xO(),Ag(),r_(),hD(),U(KM,G,{transform(e,t){if(this.value&&!e.modified())return t.StopPropagation;var n=t.dataflow.locale(),r=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=this.value,a=e.scale,o=$D(a,e.count==null?e.values?e.values.length:10:e.count,e.minstep),s=e.format||Spe(n,a,o,e.formatSpecifier,e.formatType,!!e.values),c=e.values?xpe(a,e.values,o):eO(a,o);return i&&(r.rem=i),i=c.map((e,t)=>ex({index:t/(c.length-1||1),tickIndex:t,value:e,label:s(e)})),e.extra&&i.length&&i.push(ex({index:-1,tickIndex:-1,extra:{value:i[0].value},label:``})),r.source=i,r.add=i,this.value=i,r}}),U(qM,G,{transform(e,t){var n=t.dataflow,r=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=e.item||V_e,a=e.key||Qb,o=this.value;return H(r.encode)&&(r.encode=null),o&&(e.modified(`key`)||t.modified(a))&&V(`DataJoin does not support modified key function or fields.`),o||(t=t.addAll(),this.value=o=H_e(a)),t.visit(t.ADD,e=>{let t=a(e),n=o.get(t);n?n.exit?(o.empty--,r.add.push(n)):r.mod.push(n):(n=i(e),o.set(t,n),r.add.push(n)),n.datum=e,n.exit=!1}),t.visit(t.MOD,e=>{let t=a(e),n=o.get(t);n&&(n.datum=e,r.mod.push(n))}),t.visit(t.REM,e=>{let t=a(e),n=o.get(t);e===n.datum&&!n.exit&&(r.rem.push(n),n.exit=!0,++o.empty)}),t.changed(t.ADD_MOD)&&r.modifies(`datum`),(t.clean()||e.clean&&o.empty>n.cleanThreshold)&&n.runAfter(o.clean),r}}),U(JM,G,{transform(e,t){var n=t.fork(t.ADD_REM),r=e.mod||!1,i=e.encoders,a=t.encode;if(H(a))if(n.changed()||a.every(e=>i[e]))a=a[0],n.encode=null;else return t.StopPropagation;var o=a===`enter`,s=i.update||Ch,c=i.enter||Ch,l=i.exit||Ch,u=(a&&!o?i[a]:s)||Ch;if(t.changed(t.ADD)&&(t.visit(t.ADD,t=>{c(t,e),s(t,e)}),n.modifies(c.output),n.modifies(s.output),u!==Ch&&u!==s&&(t.visit(t.ADD,t=>{u(t,e)}),n.modifies(u.output))),t.changed(t.REM)&&l!==Ch&&(t.visit(t.REM,t=>{l(t,e)}),n.modifies(l.output)),o||u!==Ch){let i=t.MOD|(e.modified()?t.REFLOW:0);o?(t.visit(i,t=>{let i=c(t,e)||r;(u(t,e)||i)&&n.mod.push(t)}),n.mod.length&&n.modifies(c.output)):t.visit(i,t=>{(u(t,e)||r)&&n.mod.push(t)}),n.mod.length&&n.modifies(u.output)}return n.changed()?n:t.StopPropagation}}),U(YM,G,{transform(e,t){if(this.value!=null&&!e.modified())return t.StopPropagation;var n=t.dataflow.locale(),r=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=this.value,a=e.type||`symbol`,o=e.scale,s=+e.limit,c=$D(o,e.count==null?5:e.count,e.minstep),l=!!e.values||a===`symbol`,u=e.format||Ope(n,o,c,a,e.formatSpecifier,e.formatType,l),d=e.values||wpe(o,c),f,p,m,h,g;return i&&(r.rem=i),a===`symbol`?(s&&d.length>s?(t.dataflow.warn(`Symbol legend count exceeds limit, filtering items.`),i=d.slice(0,s-1),g=!0):i=d,ig(m=e.size)?(!e.values&&o(i[0])===0&&(i=i.slice(1)),h=i.reduce((t,n)=>Math.max(t,m(n,e)),0)):m=cg(h=m||8),i=i.map((t,n)=>ex({index:n,label:u(t,n,i),value:t,offset:h,size:m(t,e)})),g&&(g=d[i.length],i.push(ex({index:i.length,label:`\u2026${d.length-i.length} entries`,value:g,offset:h,size:m(g,e)})))):a===`gradient`?(f=o.domain(),p=_pe(o,f[0],Mh(f)),d.length<3&&!e.values&&f[0]!==Mh(f)&&(d=[f[0],Mh(f)]),i=d.map((e,t)=>ex({index:t,label:u(e,t,d),value:e,perc:p(e)}))):(m=d.length-1,p=kpe(o),i=d.map((e,t)=>ex({index:t,label:u(e,t,d),value:e,perc:t?p(e):0,perc2:t===m?1:p(d[t+1])}))),r.source=i,r.add=i,this.value=i,r}}),aN=e=>e.source.x,oN=e=>e.source.y,sN=e=>e.target.x,cN=e=>e.target.y,XM.Definition={type:`LinkPath`,metadata:{modifies:!0},params:[{name:`sourceX`,type:`field`,default:`source.x`},{name:`sourceY`,type:`field`,default:`source.y`},{name:`targetX`,type:`field`,default:`target.x`},{name:`targetY`,type:`field`,default:`target.y`},{name:`orient`,type:`enum`,default:`vertical`,values:[`horizontal`,`vertical`,`radial`]},{name:`shape`,type:`enum`,default:`line`,values:[`line`,`arc`,`curve`,`diagonal`,`orthogonal`]},{name:`require`,type:`signal`},{name:`as`,type:`string`,default:`path`}]},U(XM,G,{transform(e,t){var n=e.sourceX||aN,r=e.sourceY||oN,i=e.targetX||sN,a=e.targetY||cN,o=e.as||`path`,s=e.orient||`vertical`,c=e.shape||`line`,l=xN.get(c+`-`+s)||xN.get(c);return l||V(`LinkPath unsupported type: `+e.shape+(e.orient?`-`+e.orient:``)),t.visit(t.SOURCE,e=>{e[o]=l(n(e),r(e),i(e),a(e))}),t.reflow(e.modified()).modifies(o)}}),lN=(e,t,n,r)=>`M`+e+`,`+t+`L`+n+`,`+r,uN=(e,t,n,r)=>lN(t*Math.cos(e),t*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),dN=(e,t,n,r)=>{var i=n-e,a=r-t,o=Math.hypot(i,a)/2,s=180*Math.atan2(a,i)/Math.PI;return`M`+e+`,`+t+`A`+o+`,`+o+` `+s+` 0 1 `+n+`,`+r},fN=(e,t,n,r)=>dN(t*Math.cos(e),t*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),pN=(e,t,n,r)=>{let i=n-e,a=r-t,o=.2*(i+a),s=.2*(a-i);return`M`+e+`,`+t+`C`+(e+o)+`,`+(t+s)+` `+(n+s)+`,`+(r-o)+` `+n+`,`+r},mN=(e,t,n,r)=>pN(t*Math.cos(e),t*Math.sin(e),r*Math.cos(n),r*Math.sin(n)),hN=(e,t,n,r)=>`M`+e+`,`+t+`V`+r+`H`+n,gN=(e,t,n,r)=>`M`+e+`,`+t+`H`+n+`V`+r,_N=(e,t,n,r)=>{let i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),c=Math.abs(n-e)>Math.PI?n<=e:n>e;return`M`+t*i+`,`+t*a+`A`+t+`,`+t+` 0 0,`+ +!!c+` `+t*o+`,`+t*s+`L`+r*o+`,`+r*s},vN=(e,t,n,r)=>{let i=(e+n)/2;return`M`+e+`,`+t+`C`+i+`,`+t+` `+i+`,`+r+` `+n+`,`+r},yN=(e,t,n,r)=>{let i=(t+r)/2;return`M`+e+`,`+t+`C`+e+`,`+i+` `+n+`,`+i+` `+n+`,`+r},bN=(e,t,n,r)=>{let i=Math.cos(e),a=Math.sin(e),o=Math.cos(n),s=Math.sin(n),c=(t+r)/2;return`M`+t*i+`,`+t*a+`C`+c*i+`,`+c*a+` `+c*o+`,`+c*s+` `+r*o+`,`+r*s},xN=mg({line:lN,"line-radial":uN,arc:dN,"arc-radial":fN,curve:pN,"curve-radial":mN,"orthogonal-horizontal":hN,"orthogonal-vertical":gN,"orthogonal-radial":_N,"diagonal-horizontal":vN,"diagonal-vertical":yN,"diagonal-radial":bN}),ZM.Definition={type:`Pie`,metadata:{modifies:!0},params:[{name:`field`,type:`field`},{name:`startAngle`,type:`number`,default:0},{name:`endAngle`,type:`number`,default:6.283185307179586},{name:`sort`,type:`boolean`,default:!1},{name:`as`,type:`string`,array:!0,length:2,default:[`startAngle`,`endAngle`]}]},U(ZM,G,{transform(e,t){var n=e.as||[`startAngle`,`endAngle`],r=n[0],i=n[1],a=e.field||xh,o=e.startAngle||0,s=e.endAngle==null?2*Math.PI:e.endAngle,c=t.source,l=c.map(a),u=l.length,d=o,f=(s-o)/joe(l),p=n_(u),m,h,g;for(e.sort&&p.sort((e,t)=>l[e]-l[t]),m=0;m1?0:e<-1?jN:Math.acos(e)}function kN(e){return e>1?MN:e<-1?-MN:Math.asin(e)}var AN,jN,MN,NN,PN,FN,IN,LN,RN,zN,BN,VN,HN,UN,WN,GN,KN,qN,JN,YN,XN=o((()=>{AN=1e-6,jN=Math.PI,MN=jN/2,NN=jN/4,PN=jN*2,FN=180/jN,IN=jN/180,LN=Math.abs,RN=Math.atan,zN=Math.atan2,BN=Math.cos,VN=Math.ceil,HN=Math.exp,UN=Math.hypot,WN=Math.log,GN=Math.pow,KN=Math.sin,qN=Math.sign||function(e){return e>0?1:e<0?-1:0},JN=Math.sqrt,YN=Math.tan}));function ZN(){}var QN=o((()=>{}));function $N(e,t){e&&iP.hasOwnProperty(e.type)&&iP[e.type](e,t)}function eP(e,t,n){var r=-1,i=e.length-n,a;for(t.lineStart();++r{rP={Feature:function(e,t){$N(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r=0?1:-1,i=r*n,a=BN(t),o=KN(t),s=pP*o,c=fP*a+s*BN(i),l=s*r*KN(i);sP.add(zN(l,c)),dP=e,fP=a,pP=o}function sve(e){return cP=new Ug,nP(e,mP),cP*2}var sP,cP,lP,uP,dP,fP,pP,mP,hP=o((()=>{r_(),XN(),QN(),aP(),sP=new Ug,cP=new Ug,mP={point:ZN,lineStart:ZN,lineEnd:ZN,polygonStart:function(){sP=new Ug,mP.lineStart=ive,mP.lineEnd=ave},polygonEnd:function(){var e=+sP;cP.add(e<0?PN+e:e),this.lineStart=this.lineEnd=this.point=ZN},sphere:function(){cP.add(PN)}}}));function gP(e){return[zN(e[1],e[0]),kN(e[2])]}function _P(e){var t=e[0],n=e[1],r=BN(n);return[r*BN(t),r*KN(t),KN(n)]}function vP(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function yP(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function bP(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function xP(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function SP(e){var t=JN(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var CP=o((()=>{XN()}));function wP(e,t){BP.push(VP=[jP=e,NP=e]),tPP&&(PP=t)}function TP(e,t){var n=_P([e*IN,t*IN]);if(RP){var r=yP(RP,n),i=yP([r[1],-r[0],0],r);SP(i),i=gP(i);var a=e-FP,o=a>0?1:-1,s=i[0]*FN*o,c,l=LN(a)>180;l^(o*FPPP&&(PP=c)):(s=(s+360)%360-180,l^(o*FPPP&&(PP=t))),l?ekP(jP,NP)&&(NP=e):kP(e,NP)>kP(jP,NP)&&(jP=e):NP>=jP?(eNP&&(NP=e)):e>FP?kP(jP,e)>kP(jP,NP)&&(NP=e):kP(e,NP)>kP(jP,NP)&&(jP=e)}else BP.push(VP=[jP=e,NP=e]);tPP&&(PP=t),RP=n,FP=e}function EP(){HP.point=TP}function DP(){VP[0]=jP,VP[1]=NP,HP.point=wP,RP=null}function OP(e,t){if(RP){var n=e-FP;zP.add(LN(n)>180?n+(n>0?360:-360):n)}else IP=e,LP=t;mP.point(e,t),TP(e,t)}function cve(){mP.lineStart()}function lve(){OP(IP,LP),mP.lineEnd(),LN(zP)>1e-6&&(jP=-(NP=180)),VP[0]=jP,VP[1]=NP,RP=null}function kP(e,t){return(t-=e)<0?t+360:t}function uve(e,t){return e[0]-t[0]}function AP(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tkP(r[0],r[1])&&(r[1]=i[1]),kP(i[0],r[1])>kP(r[0],r[1])&&(r[0]=i[0])):a.push(r=i);for(o=-1/0,n=a.length-1,t=0,r=a[n];t<=n;r=i,++t)i=a[t],(s=kP(r[1],i[0]))>o&&(o=s,jP=i[0],NP=r[1])}return BP=VP=null,jP===1/0||MP===1/0?[[NaN,NaN],[NaN,NaN]]:[[jP,MP],[NP,PP]]}var jP,MP,NP,PP,FP,IP,LP,RP,zP,BP,VP,HP,fve=o((()=>{r_(),hP(),CP(),XN(),aP(),HP={point:wP,lineStart:EP,lineEnd:DP,polygonStart:function(){HP.point=OP,HP.lineStart=cve,HP.lineEnd=lve,zP=new Ug,mP.polygonStart()},polygonEnd:function(){mP.polygonEnd(),HP.point=wP,HP.lineStart=EP,HP.lineEnd=DP,sP<0?(jP=-(NP=180),MP=-(PP=90)):zP>1e-6?PP=90:zP<-1e-6&&(MP=-90),VP[0]=jP,VP[1]=NP},sphere:function(){jP=-(NP=180),MP=-(PP=90)}}}));function UP(e,t){e*=IN,t*=IN;var n=BN(t);WP(n*BN(e),n*KN(e),KN(t))}function WP(e,t,n){++JP,XP+=(e-XP)/JP,ZP+=(t-ZP)/JP,QP+=(n-QP)/JP}function GP(){uF.point=pve}function pve(e,t){e*=IN,t*=IN;var n=BN(t);sF=n*BN(e),cF=n*KN(e),lF=KN(t),uF.point=mve,WP(sF,cF,lF)}function mve(e,t){e*=IN,t*=IN;var n=BN(t),r=n*BN(e),i=n*KN(e),a=KN(t),o=zN(JN((o=cF*a-lF*i)*o+(o=lF*r-sF*a)*o+(o=sF*i-cF*r)*o),sF*r+cF*i+lF*a);YP+=o,$P+=o*(sF+(sF=r)),eF+=o*(cF+(cF=i)),tF+=o*(lF+(lF=a)),WP(sF,cF,lF)}function KP(){uF.point=UP}function hve(){uF.point=_ve}function gve(){qP(aF,oF),uF.point=UP}function _ve(e,t){aF=e,oF=t,e*=IN,t*=IN,uF.point=qP;var n=BN(t);sF=n*BN(e),cF=n*KN(e),lF=KN(t),WP(sF,cF,lF)}function qP(e,t){e*=IN,t*=IN;var n=BN(t),r=n*BN(e),i=n*KN(e),a=KN(t),o=cF*a-lF*i,s=lF*r-sF*a,c=sF*i-cF*r,l=UN(o,s,c),u=kN(l),d=l&&-u/l;nF.add(d*o),rF.add(d*s),iF.add(d*c),YP+=u,$P+=u*(sF+(sF=r)),eF+=u*(cF+(cF=i)),tF+=u*(lF+(lF=a)),WP(sF,cF,lF)}function vve(e){JP=YP=XP=ZP=QP=$P=eF=tF=0,nF=new Ug,rF=new Ug,iF=new Ug,nP(e,uF);var t=+nF,n=+rF,r=+iF,i=UN(t,n,r);return i<1e-12&&(t=$P,n=eF,r=tF,YP<1e-6&&(t=XP,n=ZP,r=QP),i=UN(t,n,r),i<1e-12)?[NaN,NaN]:[zN(n,t)*FN,kN(r/i)*FN]}var JP,YP,XP,ZP,QP,$P,eF,tF,nF,rF,iF,aF,oF,sF,cF,lF,uF,yve=o((()=>{r_(),XN(),QN(),aP(),uF={sphere:ZN,point:UP,lineStart:GP,lineEnd:KP,polygonStart:function(){uF.lineStart=hve,uF.lineEnd=gve},polygonEnd:function(){uF.lineStart=GP,uF.lineEnd=KP}}}));function dF(e,t){function n(n,r){return n=e(n,r),t(n[0],n[1])}return e.invert&&t.invert&&(n.invert=function(n,r){return n=t.invert(n,r),n&&e.invert(n[0],n[1])}),n}var fF=o((()=>{}));function pF(e,t){return LN(e)>jN&&(e-=Math.round(e/PN)*PN),[e,t]}function mF(e,t,n){return(e%=PN)?t||n?dF(gF(e),_F(t,n)):gF(e):t||n?_F(t,n):pF}function hF(e){return function(t,n){return t+=e,LN(t)>jN&&(t-=Math.round(t/PN)*PN),[t,n]}}function gF(e){var t=hF(e);return t.invert=hF(-e),t}function _F(e,t){var n=BN(e),r=KN(e),i=BN(t),a=KN(t);function o(e,t){var o=BN(t),s=BN(e)*o,c=KN(e)*o,l=KN(t),u=l*n+s*r;return[zN(c*i-u*a,s*n-l*r),kN(u*i+c*a)]}return o.invert=function(e,t){var o=BN(t),s=BN(e)*o,c=KN(e)*o,l=KN(t),u=l*i-c*a;return[zN(c*i+l*a,s*n+u*r),kN(u*n-s*r)]},o}function bve(e){e=mF(e[0]*IN,e[1]*IN,e.length>2?e[2]*IN:0);function t(t){return t=e(t[0]*IN,t[1]*IN),t[0]*=FN,t[1]*=FN,t}return t.invert=function(t){return t=e.invert(t[0]*IN,t[1]*IN),t[0]*=FN,t[1]*=FN,t},t}var vF=o((()=>{fF(),XN(),pF.invert=pF}));function xve(e,t,n,r,i,a){if(n){var o=BN(t),s=KN(t),c=r*n;i==null?(i=t+r*PN,a=t-c/2):(i=yF(o,i),a=yF(o,a),(r>0?ia)&&(i+=r*PN));for(var l,u=i;r>0?u>a:u{CP(),XN()}));function xF(){var e=[],t;return{point:function(e,n,r){t.push([e,n,r])},lineStart:function(){e.push(t=[])},lineEnd:ZN,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}var SF=o((()=>{QN()}));function CF(e,t){return LN(e[0]-t[0])<1e-6&&LN(e[1]-t[1])<1e-6}var wF=o((()=>{XN()}));function TF(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function EF(e,t,n,r,i){var a=[],o=[],s,c;if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,n=e[0],r=e[t],c;if(CF(n,r)){if(!n[2]&&!r[2]){for(i.lineStart(),s=0;s=0;--s)i.point((d=u[s])[0],d[1]);else r(f.x,f.p.x,-1,i);f=f.p}f=f.o,u=f.z,p=!p}while(!f.v);i.lineEnd()}}}function DF(e){if(t=e.length){for(var t,n=0,r=e[0],i;++n{wF(),XN()}));function kF(e){return LN(e[0])<=jN?e[0]:qN(e[0])*((LN(e[0])+jN)%PN-jN)}function Sve(e,t){var n=kF(t),r=t[1],i=KN(r),a=[KN(n),-BN(n),0],o=0,s=0,c=new Ug;i===1?r=MN+AN:i===-1&&(r=-MN-AN);for(var l=0,u=e.length;l=0?1:-1,E=T*w,D=E>jN,O=g*S;if(c.add(zN(O*T*KN(E),_*C+O*BN(E))),o+=D?w+T*PN:w,D^m>=n^b>=n){var k=yP(_P(p),_P(y));SP(k);var A=yP(a,k);SP(A);var j=(D^w>=0?-1:1)*kN(A[2]);(r>j||r===j&&(k[0]||k[1]))&&(s+=D^w>=0?1:-1)}}return(o<-1e-6||o<1e-6&&c<-1e-12)^s&1}var AF=o((()=>{r_(),CP(),XN()}));function jF(e,t,n,r){return function(i){var a=t(i),o=xF(),s=t(o),c=!1,l,u,d,f={point:p,lineStart:h,lineEnd:g,polygonStart:function(){f.point=_,f.lineStart=v,f.lineEnd=y,u=[],l=[]},polygonEnd:function(){f.point=p,f.lineStart=h,f.lineEnd=g,u=Ooe(u);var e=Sve(l,r);u.length?(c||=(i.polygonStart(),!0),EF(u,wve,e,n,i)):e&&(c||=(i.polygonStart(),!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),c&&=(i.polygonEnd(),!1),u=l=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function p(t,n){e(t,n)&&i.point(t,n)}function m(e,t){a.point(e,t)}function h(){f.point=m,a.lineStart()}function g(){f.point=p,a.lineEnd()}function _(e,t){d.push([e,t]),s.point(e,t)}function v(){s.lineStart(),d=[]}function y(){_(d[0][0],d[0][1]),s.lineEnd();var e=s.clean(),t=o.result(),n,r=t.length,a,f,p;if(d.pop(),l.push(d),d=null,r){if(e&1){if(f=t[0],(a=f.length-1)>0){for(c||=(i.polygonStart(),!0),i.lineStart(),n=0;n1&&e&2&&t.push(t.pop().concat(t.shift())),u.push(t.filter(Cve))}}return f}}function Cve(e){return e.length>1}function wve(e,t){return((e=e.x)[0]<0?e[1]-MN-AN:MN-e[1])-((t=t.x)[0]<0?t[1]-MN-AN:MN-t[1])}var MF=o((()=>{SF(),OF(),XN(),AF(),r_()}));function Tve(e){var t=NaN,n=NaN,r=NaN,i;return{lineStart:function(){e.lineStart(),i=1},point:function(a,o){var s=a>0?jN:-jN,c=LN(a-t);LN(c-jN)<1e-6?(e.point(t,n=(n+o)/2>0?MN:-MN),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),e.point(a,n),i=0):r!==s&&c>=jN&&(LN(t-r)<1e-6&&(t-=r*AN),LN(a-s)<1e-6&&(a-=s*AN),n=Eve(t,n,a,o),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),i=0),e.point(t=a,n=o),r=s},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-i}}}function Eve(e,t,n,r){var i,a,o=KN(e-n);return LN(o)>1e-6?RN((KN(t)*(a=BN(r))*KN(n)-KN(r)*(i=BN(t))*KN(e))/(i*a*o)):(t+r)/2}function Dve(e,t,n,r){var i;if(e==null)i=n*MN,r.point(-jN,i),r.point(0,i),r.point(jN,i),r.point(jN,0),r.point(jN,-i),r.point(0,-i),r.point(-jN,-i),r.point(-jN,0),r.point(-jN,i);else if(LN(e[0]-t[0])>1e-6){var a=e[0]{MF(),XN(),NF=jF(function(){return!0},Tve,Dve,[-jN,-MN])}));function Ove(e){var t=BN(e),n=2*IN,r=t>0,i=LN(t)>AN;function a(t,r,i,a){xve(a,e,n,i,t,r)}function o(e,n){return BN(e)*BN(n)>t}function s(e){var t,n,a,s,u;return{lineStart:function(){s=a=!1,u=1},point:function(d,f){var p=[d,f],m,h=o(d,f),g=r?h?0:l(d,f):h?l(d+(d<0?jN:-jN),f):0;if(!t&&(s=a=h)&&e.lineStart(),h!==a&&(m=c(t,p),(!m||CF(t,m)||CF(p,m))&&(p[2]=1)),h!==a)u=0,h?(e.lineStart(),m=c(p,t),e.point(m[0],m[1])):(m=c(t,p),e.point(m[0],m[1],2),e.lineEnd()),t=m;else if(i&&t&&r^h){var _;!(g&n)&&(_=c(p,t,!0))&&(u=0,r?(e.lineStart(),e.point(_[0][0],_[0][1]),e.point(_[1][0],_[1][1]),e.lineEnd()):(e.point(_[1][0],_[1][1]),e.lineEnd(),e.lineStart(),e.point(_[0][0],_[0][1],3)))}h&&(!t||!CF(t,p))&&e.point(p[0],p[1]),t=p,a=h,n=g},lineEnd:function(){a&&e.lineEnd(),t=null},clean:function(){return u|(s&&a)<<1}}}function c(e,n,r){var i=_P(e),a=_P(n),o=[1,0,0],s=yP(i,a),c=vP(s,s),l=s[0],u=c-l*l;if(!u)return!r&&e;var d=t*c/u,f=-t*l/u,p=yP(o,s),m=xP(o,d);bP(m,xP(s,f));var h=p,g=vP(m,h),_=vP(h,h),v=g*g-_*(vP(m,m)-1);if(!(v<0)){var y=JN(v),b=xP(h,(-g-y)/_);if(bP(b,m),b=gP(b),!r)return b;var x=e[0],S=n[0],C=e[1],w=n[1],T;S0^b[1]<(LN(b[0]-x)<1e-6?C:w):C<=b[1]&&b[1]<=w:E>jN^(x<=b[0]&&b[0]<=S)){var k=xP(h,(-g+y)/_);return bP(k,m),[b,gP(k)]}}}function l(t,n){var i=r?e:jN-e,a=0;return t<-i?a|=1:t>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return jF(o,s,a,r?[0,-e]:[-jN,e-jN])}var FF=o((()=>{CP(),bF(),XN(),wF(),MF()}));function kve(e,t,n,r,i,a){var o=e[0],s=e[1],c=t[0],l=t[1],u=0,d=1,f=c-o,p=l-s,m=n-o;if(!(!f&&m>0)){if(m/=f,f<0){if(m0){if(m>d)return;m>u&&(u=m)}if(m=i-o,!(!f&&m<0)){if(m/=f,f<0){if(m>d)return;m>u&&(u=m)}else if(f>0){if(m0)){if(m/=p,p<0){if(m0){if(m>d)return;m>u&&(u=m)}if(m=a-s,!(!p&&m<0)){if(m/=p,p<0){if(m>d)return;m>u&&(u=m)}else if(p>0){if(m0&&(e[0]=o+u*f,e[1]=s+u*p),d<1&&(t[0]=o+d*f,t[1]=s+d*p),!0}}}}}var Ave=o((()=>{}));function IF(e,t,n,r){function i(i,a){return e<=i&&i<=n&&t<=a&&a<=r}function a(i,a,s,l){var u=0,d=0;if(i==null||(u=o(i,s))!==(d=o(a,s))||c(i,a)<0^s>0)do l.point(u===0||u===3?e:n,u>1?r:t);while((u=(u+s+4)%4)!==d);else l.point(a[0],a[1])}function o(r,i){return LN(r[0]-e)<1e-6?i>0?0:3:LN(r[0]-n)<1e-6?i>0?2:1:LN(r[1]-t)<1e-6?+(i>0):i>0?3:2}function s(e,t){return c(e.x,t.x)}function c(e,t){var n=o(e,1),r=o(t,1);return n===r?n===0?t[1]-e[1]:n===1?e[0]-t[0]:n===2?e[1]-t[1]:t[0]-e[0]:n-r}return function(o){var c=o,l=xF(),u,d,f,p,m,h,g,_,v,y,b,x={point:S,lineStart:E,lineEnd:D,polygonStart:w,polygonEnd:T};function S(e,t){i(e,t)&&c.point(e,t)}function C(){for(var t=0,n=0,i=d.length;nr&&(f-l)*(r-u)>(p-u)*(e-l)&&++t:p<=r&&(f-l)*(r-u)<(p-u)*(e-l)&&--t;return t}function w(){c=l,u=[],d=[],b=!0}function T(){var e=C(),t=b&&e,n=(u=Ooe(u)).length;(t||n)&&(o.polygonStart(),t&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),n&&EF(u,s,e,a,o),o.polygonEnd()),c=o,u=d=f=null}function E(){x.point=O,d&&d.push(f=[]),y=!0,v=!1,g=_=NaN}function D(){u&&(O(p,m),h&&v&&l.rejoin(),u.push(l.result())),x.point=S,v&&c.lineEnd()}function O(a,o){var s=i(a,o);if(d&&f.push([a,o]),y)p=a,m=o,h=s,y=!1,s&&(c.lineStart(),c.point(a,o));else if(s&&v)c.point(a,o);else{var l=[g=Math.max(RF,Math.min(LF,g)),_=Math.max(RF,Math.min(LF,_))],u=[a=Math.max(RF,Math.min(LF,a)),o=Math.max(RF,Math.min(LF,o))];kve(l,u,e,t,n,r)?(v||(c.lineStart(),c.point(l[0],l[1])),c.point(u[0],u[1]),s||c.lineEnd(),b=!1):s&&(c.lineStart(),c.point(a,o),b=!1)}g=a,_=o,v=s}return x}}var LF,RF,zF=o((()=>{XN(),SF(),Ave(),OF(),r_(),LF=1e9,RF=-LF}));function BF(e,t,n){var r=n_(e,t-AN,n).concat(t);return function(e){return r.map(function(t){return[e,t]})}}function VF(e,t,n){var r=n_(e,t-AN,n).concat(t);return function(e){return r.map(function(t){return[t,e]})}}function jve(){var e,t,n,r,i,a,o,s,c=10,l=c,u=90,d=360,f,p,m,h,g=2.5;function _(){return{type:`MultiLineString`,coordinates:v()}}function v(){return n_(VN(r/u)*u,n,u).map(m).concat(n_(VN(s/d)*d,o,d).map(h)).concat(n_(VN(t/c)*c,e,c).filter(function(e){return LN(e%u)>AN}).map(f)).concat(n_(VN(a/l)*l,i,l).filter(function(e){return LN(e%d)>AN}).map(p))}return _.lines=function(){return v().map(function(e){return{type:`LineString`,coordinates:e}})},_.outline=function(){return{type:`Polygon`,coordinates:[m(r).concat(h(o).slice(1),m(n).reverse().slice(1),h(s).reverse().slice(1))]}},_.extent=function(e){return arguments.length?_.extentMajor(e).extentMinor(e):_.extentMinor()},_.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],o=+e[1][1],r>n&&(e=r,r=n,n=e),s>o&&(e=s,s=o,o=e),_.precision(g)):[[r,s],[n,o]]},_.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],a=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),a>i&&(n=a,a=i,i=n),_.precision(g)):[[t,a],[e,i]]},_.step=function(e){return arguments.length?_.stepMajor(e).stepMinor(e):_.stepMinor()},_.stepMajor=function(e){return arguments.length?(u=+e[0],d=+e[1],_):[u,d]},_.stepMinor=function(e){return arguments.length?(c=+e[0],l=+e[1],_):[c,l]},_.precision=function(c){return arguments.length?(g=+c,f=BF(a,i,90),p=VF(t,e,g),m=BF(s,o,90),h=VF(r,n,g),_):g},_.extentMajor([[-180,-90+AN],[180,90-AN]]).extentMinor([[-180,-80-AN],[180,80+AN]])}var Mve=o((()=>{r_(),XN()})),HF,UF=o((()=>{HF=e=>e}));function Nve(){ZF.point=Pve}function Pve(e,t){ZF.point=WF,qF=YF=e,JF=XF=t}function WF(e,t){KF.add(XF*e-YF*t),YF=e,XF=t}function Fve(){WF(qF,JF)}var GF,KF,qF,JF,YF,XF,ZF,Ive=o((()=>{r_(),XN(),QN(),GF=new Ug,KF=new Ug,ZF={point:ZN,lineStart:ZN,lineEnd:ZN,polygonStart:function(){ZF.lineStart=Nve,ZF.lineEnd=Fve},polygonEnd:function(){ZF.lineStart=ZF.lineEnd=ZF.point=ZN,GF.add(LN(KF)),KF=new Ug},result:function(){var e=GF/2;return GF=new Ug,e}}}));function Lve(e,t){eeI&&(eI=e),t<$F&&($F=t),t>tI&&(tI=t)}var QF,$F,eI,tI,nI,rI=o((()=>{QN(),QF=1/0,$F=QF,eI=-QF,tI=eI,nI={point:Lve,lineStart:ZN,lineEnd:ZN,polygonStart:ZN,polygonEnd:ZN,result:function(){var e=[[QF,$F],[eI,tI]];return eI=tI=-($F=QF=1/0),e}}}));function iI(e,t){cI+=e,lI+=t,++uI}function aI(){xI.point=Rve}function Rve(e,t){xI.point=zve,iI(yI=e,bI=t)}function zve(e,t){var n=e-yI,r=t-bI,i=JN(n*n+r*r);dI+=i*(yI+e)/2,fI+=i*(bI+t)/2,pI+=i,iI(yI=e,bI=t)}function oI(){xI.point=iI}function Bve(){xI.point=Hve}function Vve(){sI(_I,vI)}function Hve(e,t){xI.point=sI,iI(_I=yI=e,vI=bI=t)}function sI(e,t){var n=e-yI,r=t-bI,i=JN(n*n+r*r);dI+=i*(yI+e)/2,fI+=i*(bI+t)/2,pI+=i,i=bI*e-yI*t,mI+=i*(yI+e),hI+=i*(bI+t),gI+=i*3,iI(yI=e,bI=t)}var cI,lI,uI,dI,fI,pI,mI,hI,gI,_I,vI,yI,bI,xI,Uve=o((()=>{XN(),cI=0,lI=0,uI=0,dI=0,fI=0,pI=0,mI=0,hI=0,gI=0,xI={point:iI,lineStart:aI,lineEnd:oI,polygonStart:function(){xI.lineStart=Bve,xI.lineEnd=Vve},polygonEnd:function(){xI.point=iI,xI.lineStart=aI,xI.lineEnd=oI},result:function(){var e=gI?[mI/gI,hI/gI]:pI?[dI/pI,fI/pI]:uI?[cI/uI,lI/uI]:[NaN,NaN];return cI=lI=uI=dI=fI=pI=mI=hI=gI=0,e}}}));function SI(e){this._context=e}var Wve=o((()=>{XN(),QN(),SI.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:this._context.moveTo(e,t),this._point=1;break;case 1:this._context.lineTo(e,t);break;default:this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,PN);break}},result:ZN}}));function Gve(e,t){AI.point=CI,EI=OI=e,DI=kI=t}function CI(e,t){OI-=e,kI-=t,wI.add(JN(OI*OI+kI*kI)),OI=e,kI=t}var wI,TI,EI,DI,OI,kI,AI,Kve=o((()=>{r_(),XN(),QN(),wI=new Ug,AI={point:ZN,lineStart:function(){AI.point=Gve},lineEnd:function(){TI&&CI(EI,DI),AI.point=ZN},polygonStart:function(){TI=!0},polygonEnd:function(){TI=null},result:function(){var e=+wI;return wI=new Ug,e}}}));function jI(e){let t=1;this._+=e[0];for(let n=e.length;t=0))throw RangeError(`invalid digits: ${e}`);if(t>15)return jI;if(t!==MI){let e=10**t;MI=t,NI=function(t){let n=1;this._+=t[0];for(let r=t.length;n{II=class{constructor(e){this._append=e==null?jI:qve(e),this._radius=4.5,this._=``}pointRadius(e){return this._radius=+e,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+=`Z`),this._point=NaN}point(e,t){switch(this._point){case 0:this._append`M${e},${t}`,this._point=1;break;case 1:this._append`L${e},${t}`;break;default:if(this._append`M${e},${t}`,this._radius!==PI||this._append!==NI){let e=this._radius,t=this._;this._=``,this._append`m0,${e}a${e},${e} 0 1,1 0,${-2*e}a${e},${e} 0 1,1 0,${2*e}z`,PI=e,NI=this._append,FI=this._,this._=t}this._+=FI;break}}result(){let e=this._;return this._=``,e.length?e:null}}}));function LI(e,t){let n=3,r=4.5,i,a;function o(e){return e&&(typeof r==`function`&&a.pointRadius(+r.apply(this,arguments)),nP(e,i(a))),a.result()}return o.area=function(e){return nP(e,i(ZF)),ZF.result()},o.measure=function(e){return nP(e,i(AI)),AI.result()},o.bounds=function(e){return nP(e,i(nI)),nI.result()},o.centroid=function(e){return nP(e,i(xI)),xI.result()},o.projection=function(t){return arguments.length?(i=t==null?(e=null,HF):(e=t).stream,o):e},o.context=function(e){return arguments.length?(a=e==null?(t=null,new II(n)):new SI(t=e),typeof r!=`function`&&a.pointRadius(r),o):t},o.pointRadius=function(e){return arguments.length?(r=typeof e==`function`?e:(a.pointRadius(+e),+e),o):r},o.digits=function(e){if(!arguments.length)return n;if(e==null)n=null;else{let t=Math.floor(e);if(!(t>=0))throw RangeError(`invalid digits: ${e}`);n=t}return t===null&&(a=new II(n)),o},o.projection(e).digits(n).context(t)}var Yve=o((()=>{UF(),aP(),Ive(),rI(),Uve(),Wve(),Kve(),Jve()}));function RI(e){return function(t){var n=new zI;for(var r in e)n[r]=e[r];return n.stream=t,n}}function zI(){}var BI=o((()=>{zI.prototype={constructor:zI,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}}}));function VI(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),nP(n,e.stream(nI)),t(nI.result()),r!=null&&e.clipExtent(r),e}function HI(e,t,n){return VI(e,function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+t[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-a*(n[1][1]+n[0][1]))/2;e.scale(150*a).translate([o,s])},n)}function UI(e,t,n){return HI(e,[[0,0],t],n)}function WI(e,t,n){return VI(e,function(n){var r=+t,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];e.scale(150*i).translate([a,o])},n)}function GI(e,t,n){return VI(e,function(n){var r=+t,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([a,o])},n)}var KI=o((()=>{aP(),rI()}));function qI(e,t){return+t?Zve(e,t):Xve(e)}function Xve(e){return RI({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function Zve(e,t){function n(r,i,a,o,s,c,l,u,d,f,p,m,h,g){var _=l-r,v=u-i,y=_*_+v*v;if(y>4*t&&h--){var b=o+f,x=s+p,S=c+m,C=JN(b*b+x*x+S*S),w=kN(S/=C),T=LN(LN(S)-1)<1e-6||LN(a-d)<1e-6?(a+d)/2:zN(x,b),E=e(T,w),D=E[0],O=E[1],k=D-r,A=O-i,j=v*k-_*A;(j*j/y>t||LN((_*k+v*A)/y-.5)>.3||o*f+s*p+c*m{CP(),XN(),BI(),JI=16,YI=BN(30*IN)}));function $ve(e){return RI({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}function eye(e,t,n,r,i){function a(a,o){return a*=r,o*=i,[t+e*a,n-e*o]}return a.invert=function(a,o){return[(a-t)/e*r,(n-o)/e*i]},a}function XI(e,t,n,r,i,a){if(!a)return eye(e,t,n,r,i);var o=BN(a),s=KN(a),c=o*e,l=s*e,u=o/e,d=s/e,f=(s*n-o*t)/e,p=(s*t+o*n)/e;function m(e,a){return e*=r,a*=i,[c*e-l*a+t,n-l*e-c*a]}return m.invert=function(e,t){return[r*(u*e-d*t+f),i*(p-d*e-u*t)]},m}function ZI(e){return QI(function(){return e})()}function QI(e){var t,n=150,r=480,i=250,a=0,o=0,s=0,c=0,l=0,u,d=0,f=1,p=1,m=null,h=NF,g=null,_,v,y,b=HF,x=.5,S,C,w,T,E;function D(e){return w(e[0]*IN,e[1]*IN)}function O(e){return e=w.invert(e[0],e[1]),e&&[e[0]*FN,e[1]*FN]}D.stream=function(e){return T&&E===e?T:T=$I($ve(u)(h(S(b(E=e)))))},D.preclip=function(e){return arguments.length?(h=e,m=void 0,A()):h},D.postclip=function(e){return arguments.length?(b=e,g=_=v=y=null,A()):b},D.clipAngle=function(e){return arguments.length?(h=+e?Ove(m=e*IN):(m=null,NF),A()):m*FN},D.clipExtent=function(e){return arguments.length?(b=e==null?(g=_=v=y=null,HF):IF(g=+e[0][0],_=+e[0][1],v=+e[1][0],y=+e[1][1]),A()):g==null?null:[[g,_],[v,y]]},D.scale=function(e){return arguments.length?(n=+e,k()):n},D.translate=function(e){return arguments.length?(r=+e[0],i=+e[1],k()):[r,i]},D.center=function(e){return arguments.length?(a=e[0]%360*IN,o=e[1]%360*IN,k()):[a*FN,o*FN]},D.rotate=function(e){return arguments.length?(s=e[0]%360*IN,c=e[1]%360*IN,l=e.length>2?e[2]%360*IN:0,k()):[s*FN,c*FN,l*FN]},D.angle=function(e){return arguments.length?(d=e%360*IN,k()):d*FN},D.reflectX=function(e){return arguments.length?(f=e?-1:1,k()):f<0},D.reflectY=function(e){return arguments.length?(p=e?-1:1,k()):p<0},D.precision=function(e){return arguments.length?(S=qI(C,x=e*e),A()):JN(x)},D.fitExtent=function(e,t){return HI(D,e,t)},D.fitSize=function(e,t){return UI(D,e,t)},D.fitWidth=function(e,t){return WI(D,e,t)},D.fitHeight=function(e,t){return GI(D,e,t)};function k(){var e=XI(n,0,0,f,p,d).apply(null,t(a,o)),m=XI(n,r-e[0],i-e[1],f,p,d);return u=mF(s,c,l),C=dF(t,m),w=dF(u,C),S=qI(C,x),A()}function A(){return T=E=null,D}return function(){return t=e.apply(this,arguments),D.invert=t.invert&&O,k()}}var $I,eL=o((()=>{PF(),FF(),zF(),fF(),UF(),XN(),vF(),BI(),KI(),Qve(),$I=RI({point:function(e,t){this.stream.point(e*IN,t*IN)}})}));function tL(e){var t=0,n=jN/3,r=QI(e),i=r(t,n);return i.parallels=function(e){return arguments.length?r(t=e[0]*IN,n=e[1]*IN):[t*FN,n*FN]},i}var nL=o((()=>{XN(),eL()}));function tye(e){var t=BN(e);function n(e,n){return[e*t,KN(n)/t]}return n.invert=function(e,n){return[e/t,kN(n*t)]},n}var nye=o((()=>{XN()}));function rye(e,t){var n=KN(e),r=(n+KN(t))/2;if(LN(r)<1e-6)return tye(e);var i=1+n*(2*r-n),a=JN(i)/r;function o(e,t){var n=JN(i-2*r*KN(t))/r;return[n*KN(e*=r),a-n*BN(e)]}return o.invert=function(e,t){var n=a-t,o=zN(e,LN(n))*qN(n);return n*r<0&&(o-=jN*qN(e)*qN(n)),[o/r,kN((i-(e*e+n*n)*r*r)/(2*r))]},o}function rL(){return tL(rye).scale(155.424).center([0,33.6442])}var iL=o((()=>{XN(),nL(),nye()}));function aL(){return rL().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}var oL=o((()=>{iL()}));function iye(e){var t=e.length;return{point:function(n,r){for(var i=-1;++i=.12&&s<.234&&a>=-.425&&a<-.214?i:s>=.166&&s<.234&&a>=-.214&&a<-.115?o:n).invert(e)},u.stream=function(r){return e&&t===r?e:e=iye([n.stream(t=r),i.stream(r),o.stream(r)])},u.precision=function(e){return arguments.length?(n.precision(e),i.precision(e),o.precision(e),d()):n.precision()},u.scale=function(e){return arguments.length?(n.scale(e),i.scale(e*.35),o.scale(e),u.translate(n.translate())):n.scale()},u.translate=function(e){if(!arguments.length)return n.translate();var t=n.scale(),c=+e[0],u=+e[1];return r=n.translate(e).clipExtent([[c-.455*t,u-.238*t],[c+.455*t,u+.238*t]]).stream(l),a=i.translate([c-.307*t,u+.201*t]).clipExtent([[c-.425*t+AN,u+.12*t+AN],[c-.214*t-AN,u+.234*t-AN]]).stream(l),s=o.translate([c-.205*t,u+.212*t]).clipExtent([[c-.214*t+AN,u+.166*t+AN],[c-.115*t-AN,u+.234*t-AN]]).stream(l),d()},u.fitExtent=function(e,t){return HI(u,e,t)},u.fitSize=function(e,t){return UI(u,e,t)},u.fitWidth=function(e,t){return WI(u,e,t)},u.fitHeight=function(e,t){return GI(u,e,t)};function d(){return e=t=null,u}return u.scale(1070)}var oye=o((()=>{XN(),oL(),iL(),KI()}));function sL(e){return function(t,n){var r=BN(t),i=BN(n),a=e(r*i);return a===1/0?[2,0]:[a*i*KN(t),a*KN(n)]}}function cL(e){return function(t,n){var r=JN(t*t+n*n),i=e(r),a=KN(i),o=BN(i);return[zN(t*a,r*o),kN(r&&n*a/r)]}}var lL=o((()=>{XN()}));function sye(){return ZI(uL).scale(124.75).clipAngle(179.999)}var uL,cye=o((()=>{XN(),lL(),eL(),uL=sL(function(e){return JN(2/(1+e))}),uL.invert=cL(function(e){return 2*kN(e/2)})}));function lye(){return ZI(dL).scale(79.4188).clipAngle(179.999)}var dL,uye=o((()=>{XN(),lL(),eL(),dL=sL(function(e){return(e=ON(e))&&e/KN(e)}),dL.invert=cL(function(e){return e})}));function fL(e,t){return[e,WN(YN((MN+t)/2))]}function dye(){return pL(fL).scale(961/PN)}function pL(e){var t=ZI(e),n=t.center,r=t.scale,i=t.translate,a=t.clipExtent,o=null,s,c,l;t.scale=function(e){return arguments.length?(r(e),u()):r()},t.translate=function(e){return arguments.length?(i(e),u()):i()},t.center=function(e){return arguments.length?(n(e),u()):n()},t.clipExtent=function(e){return arguments.length?(e==null?o=s=c=l=null:(o=+e[0][0],s=+e[0][1],c=+e[1][0],l=+e[1][1]),u()):o==null?null:[[o,s],[c,l]]};function u(){var n=jN*r(),i=t(bve(t.rotate()).invert([0,0]));return a(o==null?[[i[0]-n,i[1]-n],[i[0]+n,i[1]+n]]:e===fL?[[Math.max(i[0]-n,o),s],[Math.min(i[0]+n,c),l]]:[[o,Math.max(i[1]-n,s)],[c,Math.min(i[1]+n,l)]])}return u()}var mL=o((()=>{XN(),vF(),eL(),fL.invert=function(e,t){return[e,2*RN(HN(t))-MN]}}));function hL(e){return YN((MN+e)/2)}function fye(e,t){var n=BN(e),r=e===t?KN(e):WN(n/BN(t))/WN(hL(t)/hL(e)),i=n*GN(hL(e),r)/r;if(!r)return fL;function a(e,t){i>0?t<-MN+1e-6&&(t=-MN+AN):t>MN-1e-6&&(t=MN-AN);var n=i/GN(hL(t),r);return[n*KN(r*e),i-n*BN(r*e)]}return a.invert=function(e,t){var n=i-t,a=qN(r)*JN(e*e+n*n),o=zN(e,LN(n))*qN(n);return n*r<0&&(o-=jN*qN(e)*qN(n)),[o/r,2*RN(GN(i/a,1/r))-MN]},a}function pye(){return tL(fye).scale(109.5).parallels([30,30])}var mye=o((()=>{XN(),nL(),mL()}));function gL(e,t){return[e,t]}function hye(){return ZI(gL).scale(152.63)}var _L=o((()=>{eL(),gL.invert=gL}));function gye(e,t){var n=BN(e),r=e===t?KN(e):(n-BN(t))/(t-e),i=n/r+e;if(LN(r)<1e-6)return gL;function a(e,t){var n=i-t,a=r*e;return[n*KN(a),i-n*BN(a)]}return a.invert=function(e,t){var n=i-t,a=zN(e,LN(n))*qN(n);return n*r<0&&(a-=jN*qN(e)*qN(n)),[a/r,i-qN(r)*JN(e*e+n*n)]},a}function _ye(){return tL(gye).scale(131.154).center([0,13.9389])}var vye=o((()=>{XN(),nL(),_L()}));function vL(e,t){var n=kN(CL*KN(t)),r=n*n,i=r*r*r;return[e*BN(n)/(CL*(yL+3*bL*r+i*(7*xL+9*SL*r))),n*(yL+bL*r+i*(xL+SL*r))]}function yye(){return ZI(vL).scale(177.158)}var yL,bL,xL,SL,CL,wL,bye=o((()=>{eL(),XN(),yL=1.340264,bL=-.081106,xL=893e-6,SL=.003796,CL=JN(3)/2,wL=12,vL.invert=function(e,t){for(var n=t,r=n*n,i=r*r*r,a=0,o,s,c;a{XN(),lL(),eL(),TL.invert=cL(RN)}));function Cye(){var e=1,t=0,n=0,r=1,i=1,a=0,o,s,c=null,l,u,d,f=1,p=1,m=RI({point:function(e,t){var n=y([e,t]);this.stream.point(n[0],n[1])}}),h=HF,g,_;function v(){return f=e*r,p=e*i,g=_=null,y}function y(e){var r=e[0]*f,i=e[1]*p;if(a){var c=i*o-r*s;r=r*o+i*s,i=c}return[r+t,i+n]}return y.invert=function(e){var r=e[0]-t,i=e[1]-n;if(a){var c=i*o+r*s;r=r*o-i*s,i=c}return[r/f,i/p]},y.stream=function(e){return g&&_===e?g:g=m(h(_=e))},y.postclip=function(e){return arguments.length?(h=e,c=l=u=d=null,v()):h},y.clipExtent=function(e){return arguments.length?(h=e==null?(c=l=u=d=null,HF):IF(c=+e[0][0],l=+e[0][1],u=+e[1][0],d=+e[1][1]),v()):c==null?null:[[c,l],[u,d]]},y.scale=function(t){return arguments.length?(e=+t,v()):e},y.translate=function(e){return arguments.length?(t=+e[0],n=+e[1],v()):[t,n]},y.angle=function(e){return arguments.length?(a=e%360*IN,s=KN(a),o=BN(a),v()):a*FN},y.reflectX=function(e){return arguments.length?(r=e?-1:1,v()):r<0},y.reflectY=function(e){return arguments.length?(i=e?-1:1,v()):i<0},y.fitExtent=function(e,t){return HI(y,e,t)},y.fitSize=function(e,t){return UI(y,e,t)},y.fitWidth=function(e,t){return WI(y,e,t)},y.fitHeight=function(e,t){return GI(y,e,t)},y}var wye=o((()=>{zF(),UF(),BI(),KI(),XN()}));function EL(e,t){var n=t*t,r=n*n;return[e*(.8707-.131979*n+r*(-.013791+r*(.003971*n-.001529*r))),t*(1.007226+n*(.015085+r*(-.044475+.028874*n-.005916*r)))]}function Tye(){return ZI(EL).scale(175.295)}var Eye=o((()=>{eL(),XN(),EL.invert=function(e,t){var n=t,r=25,i;do{var a=n*n,o=a*a;n-=i=(n*(1.007226+a*(.015085+o*(-.044475+.028874*a-.005916*o)))-t)/(1.007226+a*(.015085*3+o*(-.044475*7+.028874*9*a-.005916*11*o)))}while(LN(i)>1e-6&&--r>0);return[e/(.8707+(a=n*n)*(-.131979+a*(-.013791+a*a*a*(.003971-.001529*a)))),n]}}));function DL(e,t){return[BN(t)*KN(e),KN(t)]}function Dye(){return ZI(DL).scale(249.5).clipAngle(90+AN)}var Oye=o((()=>{XN(),lL(),eL(),DL.invert=cL(kN)}));function OL(e,t){var n=BN(t),r=1+BN(e)*n;return[n*KN(e)/r,KN(t)/r]}function kye(){return ZI(OL).scale(250).clipAngle(142)}var Aye=o((()=>{XN(),lL(),eL(),OL.invert=cL(function(e){return 2*RN(e)})}));function kL(e,t){return[WN(YN((MN+t)/2)),-e]}function jye(){var e=pL(kL),t=e.center,n=e.rotate;return e.center=function(e){return arguments.length?t([-e[1],e[0]]):(e=t(),[e[1],-e[0]])},e.rotate=function(e){return arguments.length?n([e[0],e[1],e.length>2?e[2]+90:90]):(e=n(),[e[0],e[1],e[2]-90])},n([0,0,90]).scale(159.155)}var Mye=o((()=>{XN(),mL(),kL.invert=function(e,t){return[-t,2*RN(HN(e))-MN]}})),AL=o((()=>{hP(),fve(),yve(),bF(),PF(),FF(),zF(),AF(),r_(),XN(),QN(),aP(),Mve(),Yve(),oL(),oye(),cye(),uye(),mye(),iL(),vye(),bye(),_L(),Sye(),wye(),eL(),mL(),Eye(),Oye(),Aye(),Mye(),vF(),BI()}));function jL(e){return e>1?IL:e<-1?-IL:Math.asin(e)}function Nye(e){return e>0?Math.sqrt(e):0}var ML,NL,PL,FL,IL,LL,RL=o((()=>{ML=Math.abs,NL=Math.cos,PL=Math.sin,FL=Math.PI,IL=FL/2,FL/4,LL=Nye(2),FL*2,180/FL,FL/180}));function Pye(e,t){var n=e*PL(t),r=30,i;do t-=i=(t+PL(t)-n)/(1+NL(t));while(ML(i)>1e-6&&--r>0);return t/2}function Fye(e,t,n){function r(r,i){return[e*r*NL(i=Pye(n,i)),t*PL(i)]}return r.invert=function(r,i){return i=jL(i/t),[r/(e*NL(i)),jL((2*i+PL(2*i))/n)]},r}function Iye(){return ZI(zL).scale(169.529)}var zL,Lye=o((()=>{AL(),RL(),zL=Fye(LL/IL,LL,FL)})),Rye=o((()=>{AL(),RL(),Lye(),r_()}));function zye(e,t){return function n(){let r=t();return r.type=e,r.path=LI().projection(r),r.copy=r.copy||function(){let e=n();return UL.forEach(t=>{r[t]&&e[t](r[t]())}),e.path.pointRadius(r.path.pointRadius()),e},cpe(r)}}function BL(e,t){if(!e||typeof e!=`string`)throw Error(`Projection type must be a name string.`);return e=e.toLowerCase(),arguments.length>1?(WL[e]=zye(e,t),this):WL[e]||null}function VL(e){return e&&e.path||HL}var HL,UL,WL,GL=o((()=>{AL(),Rye(),xO(),HL=LI(),UL=[`clipAngle`,`clipExtent`,`scale`,`translate`,`center`,`rotate`,`parallels`,`precision`,`reflectX`,`reflectY`,`coefficient`,`distance`,`fraction`,`lobes`,`parallel`,`radius`,`ratio`,`spacing`,`tilt`],WL={albers:aL,albersusa:aye,azimuthalequalarea:sye,azimuthalequidistant:lye,conicconformal:pye,conicequalarea:rL,conicequidistant:_ye,equalEarth:yye,equirectangular:hye,gnomonic:xye,identity:Cye,mercator:dye,mollweide:Iye,naturalEarth1:Tye,orthographic:Dye,stereographic:kye,transversemercator:jye};for(let e in WL)BL(e,WL[e])})),Bye=c({contour:()=>rR,geojson:()=>iR,geopath:()=>aR,geopoint:()=>oR,geoshape:()=>sR,graticule:()=>cR,heatmap:()=>lR,isocontour:()=>JL,kde2d:()=>tR,projection:()=>dR});function Vye(){}function KL(){var e=1,t=1,n=s;function r(e,t){return t.map(t=>i(e,t))}function i(e,t){var r=[],i=[];return a(e,t,a=>{n(a,e,t),Hye(a)>0?r.push([a]):i.push(a)}),i.forEach(e=>{for(var t=0,n=r.length,i;t=r,f,p;for(pR[d<<1].forEach(m);++c=r,pR[u|d<<1].forEach(m);for(pR[d<<0].forEach(m);++l=r,f=n[l*e]>=r,pR[d<<1|f<<2].forEach(m);++c=r,p=f,f=n[l*e+c+1]>=r,pR[u|d<<1|f<<2|p<<3].forEach(m);pR[d|f<<3].forEach(m)}for(c=-1,f=n[l*e]>=r,pR[f<<2].forEach(m);++c=r,pR[f<<2|p<<3].forEach(m);pR[f<<3].forEach(m);function m(e){var t=[e[0][0]+c,e[0][1]+l],n=[e[1][0]+c,e[1][1]+l],r=o(t),u=o(n),d,f;(d=s[r])?(f=a[u])?(delete s[d.end],delete a[f.start],d===f?(d.ring.push(n),i(d.ring)):a[d.start]=s[f.end]={start:d.start,end:f.end,ring:d.ring.concat(f.ring)}):(delete s[d.end],d.ring.push(n),s[d.end=u]=d):(d=a[u])?(f=s[r])?(delete a[d.start],delete s[f.end],d===f?(d.ring.push(n),i(d.ring)):a[f.start]=s[d.end]={start:f.start,end:d.end,ring:f.ring.concat(d.ring)}):(delete a[d.start],d.ring.unshift(t),a[d.start=r]=d):a[r]=s[u]={start:r,end:u,ring:[t,n]}}}function o(t){return t[0]*2+t[1]*(e+1)*4}function s(n,r,i){n.forEach(n=>{var a=n[0],o=n[1],s=a|0,c=o|0,l,u=r[c*e+s];a>0&&a0&&o=0&&a>=0||V(`invalid size`),e=i,t=a,r},r.smooth=function(e){return arguments.length?(n=e?s:Vye,r):n===s},r}function Hye(e){for(var t=0,n=e.length,r=e[n-1][1]*e[0][0]-e[n-1][0]*e[0][1];++tr!=p>r&&n<(f-l)*(r-u)/(p-u)+l&&(i=-i)}return i}function Gye(e,t,n){var r;return Kye(e,t,n)&&qye(e[r=+(e[0]===t[0])],n[r],t[r])}function Kye(e,t,n){return(t[0]-e[0])*(n[1]-e[1])===(n[0]-e[0])*(t[1]-e[1])}function qye(e,t,n){return e<=t&&t<=n||n<=t&&t<=e}function qL(e,t,n){return function(r){var i=dg(r),a=n?Math.min(i[0],0):i[0],o=i[1],s=o-a,c=t?Zg(a,o,e):s/(e+1);return n_(a+c,o,c)}}function JL(e){G.call(this,null,e)}function Jye(e,t,n){let r=qL(n.levels||10,n.nice,n.zero!==!1);return n.resolve===`shared`?r(e.map(e=>Qg(t(e).values))):r}function Yye(e,t,n,r){let i=r.scale||t.scale,a=r.translate||t.translate;if(ig(i)&&(i=i(n,r)),ig(a)&&(a=a(n,r)),(i===1||i==null)&&!a)return;let o=(yg(i)?i:i[0])||1,s=(yg(i)?i:i[1])||1,c=a&&a[0]||0,l=a&&a[1]||0;e.forEach(YL(t,o,s,c,l))}function YL(e,t,n,r,i){let a=e.x1||0,o=e.y1||0,s=t*n<0;function c(e){e.forEach(l)}function l(e){s&&e.reverse(),e.forEach(u)}function u(e){e[0]=(e[0]-a)*t+r,e[1]=(e[1]-o)*n+i}return function(e){return e.coordinates.forEach(c),e}}function XL(e,t,n){let r=e>=0?e:Xx(t,n);return Math.round((Math.sqrt(4*r*r+1)-1)/2)}function ZL(e){return ig(e)?e:cg(+e)}function QL(){var e=e=>e[0],t=e=>e[1],n=xh,r=[-1,-1],i=960,a=500,o=2;function s(s,c){let l=XL(r[0],s,e)>>o,u=XL(r[1],s,t)>>o,d=l?l+2:0,f=u?u+2:0,p=2*d+(i>>o),m=2*f+(a>>o),h=new Float32Array(p*m),g=new Float32Array(p*m),_=h;s.forEach(r=>{let i=d+(+e(r)>>o),a=f+(+t(r)>>o);i>=0&&i=0&&a0&&u>0?($L(p,m,h,g,l),eR(p,m,g,h,u),$L(p,m,h,g,l),eR(p,m,g,h,u),$L(p,m,h,g,l),eR(p,m,g,h,u)):l>0?($L(p,m,h,g,l),$L(p,m,g,h,l),$L(p,m,h,g,l),_=g):u>0&&(eR(p,m,h,g,u),eR(p,m,g,h,u),eR(p,m,h,g,u),_=g);let v=c?2**(-2*o):1/joe(_);for(let e=0,t=p*m;e>o),y2:f+(a>>o)}}return s.x=function(t){return arguments.length?(e=ZL(t),s):e},s.y=function(e){return arguments.length?(t=ZL(e),s):t},s.weight=function(e){return arguments.length?(n=ZL(e),s):n},s.size=function(e){if(!arguments.length)return[i,a];var t=+e[0],n=+e[1];return t>=0&&n>=0||V(`invalid size`),i=t,a=n,s},s.cellSize=function(e){return arguments.length?((e=+e)>=1||V(`invalid cell size`),o=Math.floor(Math.log(e)/Math.LN2),s):1<=i&&(t>=a&&(s-=n[t-a+o*e]),r[t-i+o*e]=s/Math.min(t+1,e-1+a-t,a))}function eR(e,t,n,r,i){let a=(i<<1)+1;for(let o=0;o=i&&(s>=a&&(c-=n[o+(s-a)*e]),r[o+(s-i)*e]=c/Math.min(s+1,t-1+a-s,a))}function tR(e){G.call(this,null,e)}function nR(e,t){return mR.forEach(n=>t[n]==null?0:e[n](t[n])),e}function Xye(e,t){var n=[],r=e=>e(s),i,a,o,s,c,l;if(t==null)n.push(e);else for(i={},a=0,o=e.length;ae(t(n)):r=>{var i=e.pointRadius(),a=e.pointRadius(n)(t(r));return e.pointRadius(i),a};return r.context=t=>(e.context(t),r),r}function cR(e){G.call(this,[],e),this.generator=jve()}function lR(e){G.call(this,null,e)}function $ye(e,t){let n;return ig(e)?(n=n=>WT(e(n,t)),n.dep=uR(e)):n=cg(WT(e||`#888`)),n}function ebe(e,t){let n;return ig(e)?(n=n=>e(n,t),n.dep=uR(e)):e?n=cg(e):(n=e=>e.$value/e.$max||0,n.dep=!0),n}function uR(e){if(!ig(e))return!1;let t=Og(sh(e));return t.$x||t.$y||t.$value||t.$max}function tbe(e,t,n,r){let i=e.width,a=e.height,o=e.x1||0,s=e.y1||0,c=e.x2||i,l=e.y2||a,u=e.values,d=u?e=>u[e]:bh,f=ET(c-o,l-s),p=f.getContext(`2d`),m=p.getImageData(0,0,c-o,l-s),h=m.data;for(let e=s,a=0;ee.concat(abe(t)),[])}}function abe(e){return e.type===gR?e.features:ng(e).filter(e=>e!=null).map(e=>e.type===hR?e:{type:hR,geometry:e})}var pR,mR,hR,gR,_R,obe=o((()=>{Kx(),Ag(),r_(),LS(),GL(),AL(),YE(),OT(),pR=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]],JL.Definition={type:`Isocontour`,metadata:{generates:!0},params:[{name:`field`,type:`field`},{name:`thresholds`,type:`number`,array:!0},{name:`levels`,type:`number`},{name:`nice`,type:`boolean`,default:!1},{name:`resolve`,type:`enum`,values:[`shared`,`independent`],default:`independent`},{name:`zero`,type:`boolean`,default:!0},{name:`smooth`,type:`boolean`,default:!0},{name:`scale`,type:`number`,expr:!0},{name:`translate`,type:`number`,array:!0,expr:!0},{name:`as`,type:`string`,null:!0,default:`contour`}]},U(JL,G,{transform(e,t){if(this.value&&!t.changed()&&!e.modified())return t.StopPropagation;var n=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=t.materialize(t.SOURCE).source,i=e.field||yh,a=KL().smooth(e.smooth!==!1),o=e.thresholds||Jye(r,i,e),s=e.as===null?null:e.as||`contour`,c=[];return r.forEach(t=>{let n=i(t),r=a.size([n.width,n.height])(n.values,H(o)?o:o(n.values));Yye(r,n,t,e),r.forEach(e=>{c.push(nx(t,ex(s==null?e:{[s]:e})))})}),this.value&&(n.rem=this.value),this.value=n.source=n.add=c,n}}),tR.Definition={type:`KDE2D`,metadata:{generates:!0},params:[{name:`size`,type:`number`,array:!0,length:2,required:!0},{name:`x`,type:`field`,required:!0},{name:`y`,type:`field`,required:!0},{name:`weight`,type:`field`},{name:`groupby`,type:`field`,array:!0},{name:`cellSize`,type:`number`},{name:`bandwidth`,type:`number`,array:!0,length:2},{name:`counts`,type:`boolean`,default:!1},{name:`as`,type:`string`,default:`grid`}]},mR=[`x`,`y`,`weight`,`size`,`cellSize`,`bandwidth`],U(tR,G,{transform(e,t){if(this.value&&!t.changed()&&!e.modified())return t.StopPropagation;var n=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=t.materialize(t.SOURCE).source,i=Xye(r,e.groupby),a=(e.groupby||[]).map(oh),o=nR(QL(),e),s=e.as||`grid`,c=[];function l(e,t){for(let n=0;nex(l({[s]:o(t,e.counts)},t.dims))),this.value&&(n.rem=this.value),this.value=n.source=n.add=c,n}}),rR.Definition={type:`Contour`,metadata:{generates:!0},params:[{name:`size`,type:`number`,array:!0,length:2,required:!0},{name:`values`,type:`number`,array:!0},{name:`x`,type:`field`},{name:`y`,type:`field`},{name:`weight`,type:`field`},{name:`cellSize`,type:`number`},{name:`bandwidth`,type:`number`},{name:`count`,type:`number`},{name:`nice`,type:`boolean`,default:!1},{name:`thresholds`,type:`number`,array:!0},{name:`smooth`,type:`boolean`,default:!0}]},U(rR,G,{transform(e,t){if(this.value&&!t.changed()&&!e.modified())return t.StopPropagation;var n=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=KL().smooth(e.smooth!==!1),i=e.values,a=e.thresholds||qL(e.count||10,e.nice,!!i),o=e.size,s,c;return i||=(i=t.materialize(t.SOURCE).source,s=nR(QL(),e)(i,!0),c=YL(s,s.scale||1,s.scale||1,0,0),o=[s.width,s.height],s.values),a=H(a)?a:a(i),i=r.size(o)(i,a),c&&i.forEach(c),this.value&&(n.rem=this.value),this.value=n.source=n.add=(i||[]).map(ex),n}}),hR=`Feature`,gR=`FeatureCollection`,_R=`MultiPoint`,iR.Definition={type:`GeoJSON`,metadata:{},params:[{name:`fields`,type:`field`,array:!0,length:2},{name:`geojson`,type:`field`}]},U(iR,G,{transform(e,t){var n=this._features,r=this._points,i=e.fields,a=i&&i[0],o=i&&i[1],s=e.geojson||!i&&yh,c=t.ADD,l=e.modified()||t.changed(t.REM)||t.modified(sh(s))||a&&t.modified(sh(a))||o&&t.modified(sh(o));(!this.value||l)&&(c=t.SOURCE,this._features=n=[],this._points=r=[]),s&&t.visit(c,e=>n.push(s(e))),a&&o&&(t.visit(c,e=>{var t=a(e),n=o(e);t!=null&&n!=null&&(t=+t)===t&&(n=+n)===n&&r.push([t,n])}),n=n.concat({type:hR,geometry:{type:_R,coordinates:r}})),this.value={type:gR,features:n}}}),aR.Definition={type:`GeoPath`,metadata:{modifies:!0},params:[{name:`projection`,type:`projection`},{name:`field`,type:`field`},{name:`pointRadius`,type:`number`,expr:!0},{name:`as`,type:`string`,default:`path`}]},U(aR,G,{transform(e,t){var n=t.fork(t.ALL),r=this.value,i=e.field||yh,a=e.as||`path`,o=n.SOURCE;!r||e.modified()?(this.value=r=VL(e.projection),n.materialize().reflow()):o=i===yh||t.modified(i.fields)?n.ADD_MOD:n.ADD;let s=Zye(r,e.pointRadius);return n.visit(o,e=>e[a]=r(i(e))),r.pointRadius(s),n.modifies(a)}}),oR.Definition={type:`GeoPoint`,metadata:{modifies:!0},params:[{name:`projection`,type:`projection`,required:!0},{name:`fields`,type:`field`,array:!0,required:!0,length:2},{name:`as`,type:`string`,array:!0,length:2,default:[`x`,`y`]}]},U(oR,G,{transform(e,t){var n=e.projection,r=e.fields[0],i=e.fields[1],a=e.as||[`x`,`y`],o=a[0],s=a[1],c;function l(e){let t=n([r(e),i(e)]);t?(e[o]=t[0],e[s]=t[1]):(e[o]=void 0,e[s]=void 0)}return e.modified()?t=t.materialize().reflow(!0).visit(t.SOURCE,l):(c=t.modified(r.fields)||t.modified(i.fields),t.visit(c?t.ADD_MOD:t.ADD,l)),t.modifies(a)}}),sR.Definition={type:`GeoShape`,metadata:{modifies:!0,nomod:!0},params:[{name:`projection`,type:`projection`},{name:`field`,type:`field`,default:`datum`},{name:`pointRadius`,type:`number`,expr:!0},{name:`as`,type:`string`,default:`shape`}]},U(sR,G,{transform(e,t){var n=t.fork(t.ALL),r=this.value,i=e.as||`shape`,a=n.ADD;return(!r||e.modified())&&(this.value=r=Qye(VL(e.projection),e.field||gh(`datum`),e.pointRadius),n.materialize().reflow(),a=n.SOURCE),n.visit(a,e=>e[i]=r),n.modifies(i)}}),cR.Definition={type:`Graticule`,metadata:{changes:!0,generates:!0},params:[{name:`extent`,type:`array`,array:!0,length:2,content:{type:`number`,array:!0,length:2}},{name:`extentMajor`,type:`array`,array:!0,length:2,content:{type:`number`,array:!0,length:2}},{name:`extentMinor`,type:`array`,array:!0,length:2,content:{type:`number`,array:!0,length:2}},{name:`step`,type:`number`,array:!0,length:2},{name:`stepMajor`,type:`number`,array:!0,length:2,default:[90,360]},{name:`stepMinor`,type:`number`,array:!0,length:2,default:[10,10]},{name:`precision`,type:`number`,default:2.5}]},U(cR,G,{transform(e,t){var n=this.value,r=this.generator,i;if(!n.length||e.modified())for(let t in e)ig(r[t])&&r[t](e[t]);return i=r(),n.length?t.mod.push(rx(n[0],i)):t.add.push(ex(i)),n[0]=i,t}}),lR.Definition={type:`heatmap`,metadata:{modifies:!0},params:[{name:`field`,type:`field`},{name:`color`,type:`string`,expr:!0},{name:`opacity`,type:`number`,expr:!0},{name:`resolve`,type:`enum`,values:[`shared`,`independent`],default:`independent`},{name:`as`,type:`string`,default:`image`}]},U(lR,G,{transform(e,t){if(!t.changed()&&!e.modified())return t.StopPropagation;var n=t.materialize(t.SOURCE).source,r=e.resolve===`shared`,i=e.field||yh,a=ebe(e.opacity,e),o=$ye(e.color,e),s=e.as||`image`,c={$x:0,$y:0,$value:0,$max:r?Qg(n.map(e=>Qg(i(e).values))):0};return n.forEach(e=>{let t=i(e),n=ug({},e,c);r||(n.$max=Qg(t.values||[])),e[s]=tbe(t,n,o.dep?o:cg(o(n)),a.dep?a:cg(a(n)))}),t.reflow(!0).modifies(s)}}),U(dR,G,{transform(e,t){let n=this.value;return!n||e.modified(`type`)?(this.value=n=rbe(e.type),UL.forEach(t=>{e[t]!=null&&fR(n,t,e[t])})):UL.forEach(t=>{e.modified(t)&&fR(n,t,e[t])}),e.pointRadius!=null&&n.path.pointRadius(e.pointRadius),e.fit&&nbe(n,e),t.fork(t.NO_SOURCE|t.NO_FIELDS)}})}));function sbe(e,t){var n,r=1;e??=0,t??=0;function i(){var i,a=n.length,o,s=0,c=0;for(i=0;i{}));function lbe(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return vR(this.cover(t,n),t,n,e)}function vR(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,a=e._root,o={data:r},s=e._x0,c=e._y0,l=e._x1,u=e._y1,d,f,p,m,h,g,_,v;if(!a)return e._root=o,e;for(;a.length;)if((h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f,i=a,!(a=a[_=g<<1|h]))return i[_]=o,e;if(p=+e._x.call(null,a.data),m=+e._y.call(null,a.data),t===p&&n===m)return o.next=a,i?i[_]=o:e._root=o,e;do i=i?i[_]=[,,,,]:e._root=[,,,,],(h=t>=(d=(s+l)/2))?s=d:l=d,(g=n>=(f=(c+u)/2))?c=f:u=f;while((_=g<<1|h)==(v=(m>=f)<<1|p>=d));return i[v]=a,i[_]=o,e}function ube(e){var t,n,r=e.length,i,a,o=Array(r),s=Array(r),c=1/0,l=1/0,u=-1/0,d=-1/0;for(n=0;nu&&(u=i),ad&&(d=a));if(c>u||l>d)return this;for(this.cover(c,l).cover(u,d),n=0;n{}));function fbe(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,a=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,a=(r=Math.floor(t))+1;else{for(var o=i-n||1,s=this._root,c,l;n>e||e>=i||r>t||t>=a;)switch(l=(t{}));function mbe(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}var hbe=o((()=>{}));function gbe(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}var _be=o((()=>{}));function yR(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}var bR=o((()=>{}));function vbe(e,t,n){var r,i=this._x0,a=this._y0,o,s,c,l,u=this._x1,d=this._y1,f=[],p=this._root,m,h;for(p&&f.push(new yR(p,i,a,u,d)),n==null?n=1/0:(i=e-n,a=t-n,u=e+n,d=t+n,n*=n);m=f.pop();)if(!(!(p=m.node)||(o=m.x0)>u||(s=m.y0)>d||(c=m.x1)=_)<<1|e>=g)&&(m=f[f.length-1],f[f.length-1]=f[f.length-1-h],f[f.length-1-h]=m)}else{var v=e-+this._x.call(null,p.data),y=t-+this._y.call(null,p.data),b=v*v+y*y;if(b{bR()}));function bbe(e){if(isNaN(u=+this._x.call(null,e))||isNaN(d=+this._y.call(null,e)))return this;var t,n=this._root,r,i,a,o=this._x0,s=this._y0,c=this._x1,l=this._y1,u,d,f,p,m,h,g,_;if(!n)return this;if(n.length)for(;;){if((m=u>=(f=(o+c)/2))?o=f:c=f,(h=d>=(p=(s+l)/2))?s=p:l=p,t=n,!(n=n[g=h<<1|m]))return this;if(!n.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(r=t,_=g)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(a=n.next)&&delete n.next,i?(a?i.next=a:delete i.next,this):t?(a?t[g]=a:delete t[g],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[_]=n:this._root=n),this):(this._root=a,this)}function xbe(e){for(var t=0,n=e.length;t{}));function Cbe(){return this._root}var wbe=o((()=>{}));function Tbe(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}var Ebe=o((()=>{}));function Dbe(e){var t=[],n,r=this._root,i,a,o,s,c;for(r&&t.push(new yR(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,a=n.x0,o=n.y0,s=n.x1,c=n.y1)&&r.length){var l=(a+s)/2,u=(o+c)/2;(i=r[3])&&t.push(new yR(i,l,u,s,c)),(i=r[2])&&t.push(new yR(i,a,u,l,c)),(i=r[1])&&t.push(new yR(i,l,o,s,u)),(i=r[0])&&t.push(new yR(i,a,o,l,u))}return this}var Obe=o((()=>{bR()}));function kbe(e){var t=[],n=[],r;for(this._root&&t.push(new yR(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var a,o=r.x0,s=r.y0,c=r.x1,l=r.y1,u=(o+c)/2,d=(s+l)/2;(a=i[0])&&t.push(new yR(a,o,s,u,d)),(a=i[1])&&t.push(new yR(a,u,s,c,d)),(a=i[2])&&t.push(new yR(a,o,d,u,l)),(a=i[3])&&t.push(new yR(a,u,d,c,l))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}var Abe=o((()=>{bR()}));function jbe(e){return e[0]}function Mbe(e){return arguments.length?(this._x=e,this):this._x}var Nbe=o((()=>{}));function Pbe(e){return e[1]}function Fbe(e){return arguments.length?(this._y=e,this):this._y}var Ibe=o((()=>{}));function xR(e,t,n){var r=new SR(t??jbe,n??Pbe,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function SR(e,t,n,r,i,a){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=a,this._root=void 0}function CR(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var wR,Lbe=o((()=>{dbe(),pbe(),hbe(),_be(),ybe(),Sbe(),wbe(),Ebe(),Obe(),Abe(),Nbe(),Ibe(),wR=xR.prototype=SR.prototype,wR.copy=function(){var e=new SR(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=CR(t),e;for(n=[{source:t,target:e._root=[,,,,]}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=[,,,,]}):t.target[i]=CR(r));return e},wR.add=lbe,wR.addAll=ube,wR.cover=fbe,wR.data=mbe,wR.extent=gbe,wR.find=vbe,wR.remove=bbe,wR.removeAll=xbe,wR.root=Cbe,wR.size=Tbe,wR.visit=Dbe,wR.visitAfter=kbe,wR.x=Mbe,wR.y=Fbe})),TR=o((()=>{Lbe()}));function ER(e){return function(){return e}}var DR=o((()=>{}));function OR(e){return(e()-.5)*1e-6}var kR=o((()=>{}));function Rbe(e){return e.x+e.vx}function zbe(e){return e.y+e.vy}function Bbe(e){var t,n,r,i=1,a=1;typeof e!=`function`&&(e=ER(e==null?1:+e));function o(){for(var e,o=t.length,c,l,u,d,f,p,m=0;ml.index){var h=u-s.x-s.vx,g=d-s.y-s.vy,_=h*h+g*g;_u+m||ad+m||oe.r&&(e.r=e[t].r)}function c(){if(t){var r,i=t.length,a;for(n=Array(i),r=0;r{TR(),DR(),kR()}));function Hbe(e){return e.index}function AR(e,t){var n=e.get(t);if(!n)throw Error(`node not found: `+t);return n}function Ube(e){var t=Hbe,n=d,r,i=ER(30),a,o,s,c,l,u=1;e??=[];function d(e){return 1/Math.min(s[e.source.index],s[e.target.index])}function f(t){for(var n=0,i=e.length;n[t(e,n,o),e])),d;for(n=0,s=Array(i);n{DR(),kR()}));function jR(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}function Kbe(e,t){for(var n=0,r=e.length,i;n{PR={value:()=>{}},MR.prototype=jR.prototype={constructor:MR,on:function(e,t){var n=this._,r=Gbe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r{qbe()}));function FR(){return qR||=(XR(Ybe),YR.now()+JR)}function Ybe(){qR=0}function IR(){this._call=this._time=this._next=null}function LR(e,t,n){var r=new IR;return r.restart(e,t,n),r}function Xbe(){FR(),++BR;for(var e=WR,t;e;)(t=qR-e._time)>=0&&e._call.call(void 0,t),e=e._next;--BR}function RR(){qR=(KR=YR.now())+JR,BR=VR=0;try{Xbe()}finally{BR=0,Qbe(),qR=0}}function Zbe(){var e=YR.now(),t=e-KR;t>UR&&(JR-=t,KR=e)}function Qbe(){for(var e,t=WR,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:WR=n);GR=e,zR(r)}function zR(e){BR||(VR&&=clearTimeout(VR),e-qR>24?(e<1/0&&(VR=setTimeout(RR,e-YR.now()-JR)),HR&&=clearInterval(HR)):(HR||=(KR=YR.now(),setInterval(Zbe,UR)),BR=1,XR(RR)))}var BR,VR,HR,UR,WR,GR,KR,qR,JR,YR,XR,ZR=o((()=>{BR=0,VR=0,HR=0,UR=1e3,KR=0,qR=0,JR=0,YR=typeof performance==`object`&&performance.now?performance:Date,XR=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)},IR.prototype=LR.prototype={constructor:IR,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?FR():+n)+(t==null?0:+t),!this._next&&GR!==this&&(GR?GR._next=this:WR=this,GR=this),this._call=e,this._time=n,zR()},stop:function(){this._call&&(this._call=null,this._time=1/0,zR())}}}));function $be(e,t,n){var r=new IR,i=t;return t==null?(r.restart(e,t,n),r):(r._restart=r.restart,r.restart=function(e,t,n){t=+t,n=n==null?FR():+n,r._restart(function a(o){o+=i,r._restart(a,i+=t,n),e(o)},t,n)},r.restart(e,t,n),r)}var exe=o((()=>{ZR()})),QR=o((()=>{ZR(),exe()}));function txe(){let e=1;return()=>(e=($R*e+ez)%tz)/tz}var $R,ez,tz,nxe=o((()=>{$R=1664525,ez=1013904223,tz=4294967296}));function rxe(e){return e.x}function ixe(e){return e.y}function axe(e){var t,n=1,r=.001,i=1-r**(1/300),a=0,o=.6,s=new Map,c=LR(d),l=jR(`tick`,`end`),u=txe();e??=[];function d(){f(),l.call(`tick`,t),n1?(n==null?s.delete(e):s.set(e,m(n)),t):s.get(e)},find:function(t,n,r){var i=0,a=e.length,o,s,c,l,u;for(r==null?r=1/0:r*=r,i=0;i1?(l.on(e,n),t):l.on(e)}}}var nz,rz,iz=o((()=>{Jbe(),QR(),nxe(),nz=10,rz=Math.PI*(3-Math.sqrt(5))}));function oxe(){var e,t,n,r,i=ER(-30),a,o=1,s=1/0,c=.81;function l(n){var i,a=e.length,o=xR(e,rxe,ixe).visitAfter(d);for(r=n,i=0;i=s)){(e.data!==t||e.next)&&(d===0&&(d=OR(n),m+=d*d),f===0&&(f=OR(n),m+=f*f),m{TR(),DR(),kR(),iz()}));function cxe(e){var t=ER(.1),n,r,i;typeof e!=`function`&&(e=ER(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t{DR()}));function uxe(e){var t=ER(.1),n,r,i;typeof e!=`function`&&(e=ER(e==null?0:+e));function a(e){for(var t=0,a=n.length,o;t{DR()})),fxe=o((()=>{cbe(),Vbe(),Wbe(),sxe(),DR(),iz(),lxe(),dxe()})),pxe=c({force:()=>az});function az(e){G.call(this,null,e)}function mxe(e,t){return()=>e.touch(t).run()}function hxe(e,t){let n=axe(e),r=n.stop,i=n.restart,a=!1;return n.stopped=()=>a,n.restart=()=>(a=!1,i()),n.stop=()=>(a=!0,r()),oz(n,t,!0).on(`end`,()=>a=!0)}function oz(e,t,n,r){var i=ng(t.forces),a,o,s,c;for(a=0,o=lz.length;at(e,n):t)}var sz,cz,lz,uz,dz,yxe=o((()=>{Kx(),Ag(),fxe(),sz={center:sbe,collide:Bbe,nbody:oxe,link:Ube,x:cxe,y:uxe},cz=`forces`,lz=[`alpha`,`alphaMin`,`alphaTarget`,`velocityDecay`,`forces`],uz=[`static`,`iterations`],dz=[`x`,`y`,`vx`,`vy`],az.Definition={type:`Force`,metadata:{modifies:!0},params:[{name:`static`,type:`boolean`,default:!1},{name:`restart`,type:`boolean`,default:!1},{name:`iterations`,type:`number`,default:300},{name:`alpha`,type:`number`,default:1},{name:`alphaMin`,type:`number`,default:.001},{name:`alphaTarget`,type:`number`,default:0},{name:`velocityDecay`,type:`number`,default:.4},{name:`forces`,type:`param`,array:!0,params:[{key:{force:`center`},params:[{name:`x`,type:`number`,default:0},{name:`y`,type:`number`,default:0}]},{key:{force:`collide`},params:[{name:`radius`,type:`number`,expr:!0},{name:`strength`,type:`number`,default:.7},{name:`iterations`,type:`number`,default:1}]},{key:{force:`nbody`},params:[{name:`strength`,type:`number`,default:-30,expr:!0},{name:`theta`,type:`number`,default:.9},{name:`distanceMin`,type:`number`,default:1},{name:`distanceMax`,type:`number`}]},{key:{force:`link`},params:[{name:`links`,type:`data`},{name:`id`,type:`field`},{name:`distance`,type:`number`,default:30,expr:!0},{name:`strength`,type:`number`,expr:!0},{name:`iterations`,type:`number`,default:1}]},{key:{force:`x`},params:[{name:`strength`,type:`number`,default:.1},{name:`x`,type:`field`}]},{key:{force:`y`},params:[{name:`strength`,type:`number`,default:.1},{name:`y`,type:`field`}]}]},{name:`as`,type:`string`,array:!0,modify:!1,default:dz}]},U(az,G,{transform(e,t){var n=this.value,r=t.changed(t.ADD_REM),i=e.modified(lz),a=e.iterations||300;if(n?(r&&(t.modifies(`index`),n.nodes(t.source)),(i||t.changed(t.MOD))&&oz(n,e,0,t)):(this.value=n=hxe(t.source,e),n.on(`tick`,mxe(t.dataflow,this)),e.static||(r=!0,n.tick()),t.modifies(`index`)),i||r||e.modified(uz)||t.changed()&&e.restart){if(n.alpha(Math.max(n.alpha(),e.alpha||1)).alphaDecay(1-n.alphaMin()**(1/a)),e.static)for(n.stop();--a>=0;)n.tick();else if(n.stopped()&&n.restart(),!r)return t.StopPropagation}return this.finish(e,t)},finish(e,t){let n=t.dataflow;for(let e=this._argops,t=0,s=e.length,c;t{}));function kxe(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function Axe(){return this.eachAfter(kxe)}var jxe=o((()=>{}));function Mxe(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}var Nxe=o((()=>{}));function Pxe(e,t){for(var n=this,r=[n],i,a,o=-1;n=r.pop();)if(e.call(t,n,++o,this),i=n.children)for(a=i.length-1;a>=0;--a)r.push(i[a]);return this}var Fxe=o((()=>{}));function Ixe(e,t){for(var n=this,r=[n],i=[],a,o,s,c=-1;n=r.pop();)if(i.push(n),a=n.children)for(o=0,s=a.length;o{}));function Rxe(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}var zxe=o((()=>{}));function Bxe(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}var Vxe=o((()=>{}));function Hxe(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}var Uxe=o((()=>{}));function Wxe(e){for(var t=this,n=Gxe(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}function Gxe(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}var Kxe=o((()=>{}));function qxe(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}var Jxe=o((()=>{}));function Yxe(){return Array.from(this)}var Xxe=o((()=>{}));function Zxe(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}var Qxe=o((()=>{}));function $xe(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}var eSe=o((()=>{}));function*tSe(){var e=this,t,n=[e],r,i,a;do for(t=n.reverse(),n=[];e=t.pop();)if(yield e,r=e.children)for(i=0,a=r.length;i{}));function fz(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=aSe)):t===void 0&&(t=iSe);for(var n=new mz(e),r,i=[n],a,o,s,c;r=i.pop();)if((o=t(r.data))&&(c=(o=Array.from(o)).length))for(r.children=o,s=c-1;s>=0;--s)i.push(a=o[s]=new mz(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(pz)}function rSe(){return fz(this).eachBefore(oSe)}function iSe(e){return e.children}function aSe(e){return Array.isArray(e)?e[1]:null}function oSe(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function pz(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function mz(e){this.data=e,this.depth=this.height=0,this.parent=null}var hz=o((()=>{jxe(),Nxe(),Fxe(),Lxe(),zxe(),Vxe(),Uxe(),Kxe(),Jxe(),Xxe(),Qxe(),eSe(),nSe(),mz.prototype=fz.prototype={constructor:mz,count:Axe,each:Mxe,eachAfter:Ixe,eachBefore:Pxe,find:Rxe,sum:Bxe,sort:Hxe,path:Wxe,ancestors:qxe,descendants:Yxe,leaves:Zxe,links:$xe,copy:rSe,[Symbol.iterator]:tSe}}));function gz(e){return e==null?null:_z(e)}function _z(e){if(typeof e!=`function`)throw Error();return e}var vz=o((()=>{}));function yz(){return 0}function bz(e){return function(){return e}}var xz=o((()=>{}));function sSe(){let e=1;return()=>(e=(Sz*e+Cz)%wz)/wz}var Sz,Cz,wz,cSe=o((()=>{Sz=1664525,Cz=1013904223,wz=4294967296}));function lSe(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function uSe(e,t){let n=e.length,r,i;for(;n;)i=t()*n--|0,r=e[n],e[n]=e[i],e[i]=r;return e}var Tz=o((()=>{}));function dSe(e,t){for(var n=0,r=(e=uSe(Array.from(e),t)).length,i=[],a,o;n0&&n*n>r*r+i*i}function Oz(e,t){for(var n=0;n1e-6?(D+Math.sqrt(D*D-4*E*O))/(2*E):O/D);return{x:r+S+C*k,y:i+w+T*k,r:k}}var jz=o((()=>{Tz()}));function Mz(e,t,n){var r=e.x-t.x,i,a,o=e.y-t.y,s,c,l=r*r+o*o;l?(a=t.r+n.r,a*=a,c=e.r+n.r,c*=c,a>c?(i=(l+c-a)/(2*l),s=Math.sqrt(Math.max(0,c/l-i*i)),n.x=e.x-i*r-s*o,n.y=e.y-i*o+s*r):(i=(l+a-c)/(2*l),s=Math.sqrt(Math.max(0,a/l-i*i)),n.x=t.x+i*r-s*o,n.y=t.y+i*o+s*r)):(n.x=t.x+n.r,n.y=t.y)}function Nz(e,t){var n=e.r+t.r-1e-6,r=t.x-e.x,i=t.y-e.y;return n>0&&n*n>r*r+i*i}function Pz(e){var t=e._,n=e.next._,r=t.r+n.r,i=(t.x*n.r+n.x*t.r)/r,a=(t.y*n.r+n.y*t.r)/r;return i*i+a*a}function Fz(e){this._=e,this.next=null,this.previous=null}function hSe(e,t){if(!(a=(e=lSe(e)).length))return 0;var n=e[0],r,i,a,o,s,c,l,u,d,f;if(n.x=0,n.y=0,!(a>1))return n.r;if(r=e[1],n.x=-r.r,r.x=n.r,r.y=0,!(a>2))return n.r+r.r;Mz(r,n,i=e[2]),n=new Fz(n),r=new Fz(r),i=new Fz(i),n.next=i.previous=r,r.next=n.previous=i,i.next=r.previous=n;pack:for(c=3;c{Tz(),jz()}));function gSe(e){return Math.sqrt(e.value)}function _Se(){var e=null,t=1,n=1,r=yz;function i(i){let a=sSe();return i.x=t/2,i.y=n/2,e?i.eachBefore(Lz(e)).eachAfter(Rz(r,.5,a)).eachBefore(zz(1)):i.eachBefore(Lz(gSe)).eachAfter(Rz(yz,1,a)).eachAfter(Rz(r,i.r/Math.min(t,n),a)).eachBefore(zz(Math.min(t,n)/(2*i.r))),i}return i.radius=function(t){return arguments.length?(e=gz(t),i):e},i.size=function(e){return arguments.length?(t=+e[0],n=+e[1],i):[t,n]},i.padding=function(e){return arguments.length?(r=typeof e==`function`?e:bz(+e),i):r},i}function Lz(e){return function(t){t.children||(t.r=Math.max(0,+e(t)||0))}}function Rz(e,t,n){return function(r){if(i=r.children){var i,a,o=i.length,s=e(r)*t||0,c;if(s)for(a=0;a{vz(),xz(),cSe(),Iz()}));function Bz(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}var Vz=o((()=>{}));function Hz(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s{}));function ySe(){var e=1,t=1,n=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=n,i.x1=e,i.y1=t/o,i.eachBefore(a(t,o)),r&&i.eachBefore(Bz),i}function a(e,t){return function(r){r.children&&Hz(r,r.x0,e*(r.depth+1)/t,r.x1,e*(r.depth+2)/t);var i=r.x0,a=r.y0,o=r.x1-n,s=r.y1-n;o{Vz(),Uz()}));function xSe(e){return e.id}function SSe(e){return e.parentId}function Wz(){var e=xSe,t=SSe,n;function r(r){var i=Array.from(r),a=e,o=t,s,c,l,u,d,f,p,m,h=new Map;if(n!=null){let e=i.map((e,t)=>CSe(n(e,t,r))),t=e.map(Gz),s=new Set(e).add(``);for(let n of t)s.has(n)||(s.add(n),e.push(n),t.push(Gz(n)),i.push(Yz));a=(t,n)=>e[n],o=(e,n)=>t[n]}for(l=0,s=i.length;l=0&&(f=i[e],f.data===Yz);--e)f.data=null}if(u.parent=qz,u.eachBefore(function(e){e.depth=e.parent.depth+1,--s}).eachBefore(pz),u.parent=null,s>0)throw Error(`cycle`);return u}return r.id=function(t){return arguments.length?(e=gz(t),r):e},r.parentId=function(e){return arguments.length?(t=gz(e),r):t},r.path=function(e){return arguments.length?(n=gz(e),r):n},r}function CSe(e){e=`${e}`;let t=e.length;return Kz(e,t-1)&&!Kz(e,t-2)&&(e=e.slice(0,-1)),e[0]===`/`?e:`/${e}`}function Gz(e){let t=e.length;if(t<2)return``;for(;--t>1&&!Kz(e,t););return e.slice(0,t)}function Kz(e,t){if(e[t]===`/`){let n=0;for(;t>0&&e[--t]===`\\`;)++n;if(!(n&1))return!0}return!1}var qz,Jz,Yz,wSe=o((()=>{vz(),hz(),qz={depth:-1},Jz={},Yz={}}));function TSe(e,t){return e.parent===t.parent?1:2}function Xz(e){var t=e.children;return t?t[0]:e.t}function Zz(e){var t=e.children;return t?t[t.length-1]:e.t}function ESe(e,t,n){var r=n/(t.i-e.i);t.c-=r,t.s+=n,e.c+=r,t.z+=n,t.m+=n}function DSe(e){for(var t=0,n=0,r=e.children,i=r.length,a;--i>=0;)a=r[i],a.z+=t,a.m+=t,t+=a.s+(n+=a.c)}function OSe(e,t,n){return e.a.parent===t.parent?e.a:n}function Qz(e,t){this._=e,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=t}function kSe(e){for(var t=new Qz(e,0),n,r=[t],i,a,o,s;n=r.pop();)if(a=n._.children)for(n.children=Array(s=a.length),o=s-1;o>=0;--o)r.push(i=n.children[o]=new Qz(a[o],o)),i.parent=n;return(t.parent=new Qz(null,0)).children=[t],t}function ASe(){var e=TSe,t=1,n=1,r=null;function i(i){var s=kSe(i);if(s.eachAfter(a),s.parent.m=-s.z,s.eachBefore(o),r)i.eachBefore(c);else{var l=i,u=i,d=i;i.eachBefore(function(e){e.xu.x&&(u=e),e.depth>d.depth&&(d=e)});var f=l===u?1:e(l,u)/2,p=f-l.x,m=t/(u.x+f+p),h=n/(d.depth||1);i.eachBefore(function(e){e.x=(e.x+p)*m,e.y=e.depth*h})}return i}function a(t){var n=t.children,r=t.parent.children,i=t.i?r[t.i-1]:null;if(n){DSe(t);var a=(n[0].z+n[n.length-1].z)/2;i?(t.z=i.z+e(t._,i._),t.m=t.z-a):t.z=a}else i&&(t.z=i.z+e(t._,i._));t.parent.A=s(t,i,t.parent.A||r[0])}function o(e){e._.x=e.z+e.parent.m,e.m+=e.parent.m}function s(t,n,r){if(n){for(var i=t,a=t,o=n,s=i.parent.children[0],c=i.m,l=a.m,u=o.m,d=s.m,f;o=Zz(o),i=Xz(i),o&&i;)s=Xz(s),a=Zz(a),a.a=t,f=o.z+u-i.z-c+e(o._,i._),f>0&&(ESe(OSe(o,t,r),t,f),c+=f,l+=f),u+=o.m,c+=i.m,d+=s.m,l+=a.m;o&&!Zz(a)&&(a.t=o,a.m+=u-l),i&&!Xz(s)&&(s.t=i,s.m+=c-d,r=t)}return r}function c(e){e.x*=t,e.y=e.depth*n}return i.separation=function(t){return arguments.length?(e=t,i):e},i.size=function(e){return arguments.length?(r=!1,t=+e[0],n=+e[1],i):r?null:[t,n]},i.nodeSize=function(e){return arguments.length?(r=!0,t=+e[0],n=+e[1],i):r?[t,n]:null},i}var jSe=o((()=>{hz(),Qz.prototype=Object.create(mz.prototype)}));function $z(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(i-n)/e.value;++s{}));function tB(e,t,n,r,i,a){for(var o=[],s=t.children,c,l,u=0,d=0,f=s.length,p,m,h=t.value,g,_,v,y,b,x,S;uv&&(v=l),S=g*g*x,y=Math.max(v/S,S/_),y>b){g-=l;break}b=y}o.push(c={value:g,dice:p{Uz(),eB(),nB=(1+Math.sqrt(5))/2,rB=(function e(t){function n(e,n,r,i,a){tB(t,e,n,r,i,a)}return n.ratio=function(t){return e((t=+t)>1?t:1)},n})(nB)}));function MSe(){var e=rB,t=!1,n=1,r=1,i=[0],a=yz,o=yz,s=yz,c=yz,l=yz;function u(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(d),i=[0],t&&e.eachBefore(Bz),e}function d(t){var n=i[t.depth],r=t.x0+n,u=t.y0+n,d=t.x1-n,f=t.y1-n;d{Vz(),iB(),vz(),xz()}));function PSe(e,t,n,r,i){var a=e.children,o,s=a.length,c,l=Array(s+1);for(l[0]=c=o=0;o=t-1){var c=a[e];c.x0=r,c.y0=i,c.x1=o,c.y1=s;return}for(var d=l[e],f=n/2+d,p=e+1,m=t-1;p>>1;l[h]s-i){var v=n?(r*_+o*g)/n:o;u(e,p,g,r,i,v,s),u(p,t,_,v,i,o,s)}else{var y=n?(i*_+s*g)/n:s;u(e,p,g,r,i,o,y),u(p,t,_,r,y,o,s)}}}var FSe=o((()=>{}));function ISe(e,t,n,r,i){(e.depth&1?$z:Hz)(e,t,n,r,i)}var LSe=o((()=>{Uz(),eB()})),aB,RSe=o((()=>{Uz(),eB(),iB(),aB=(function e(t){function n(e,n,r,i,a){if((o=e._squarify)&&o.ratio===t)for(var o,s,c,l,u=-1,d,f=o.length,p=e.value;++u1?t:1)},n})(nB)})),zSe=o((()=>{Oxe(),hz(),vSe(),Iz(),jz(),bSe(),wSe(),jSe(),NSe(),FSe(),Uz(),eB(),LSe(),iB(),RSe()})),BSe=c({nest:()=>sB,pack:()=>lB,partition:()=>uB,stratify:()=>dB,tree:()=>fB,treelinks:()=>pB,treemap:()=>mB});function oB(e,t,n){let r={};return e.each(e=>{let i=e.data;n(i)&&(r[t(i)]=e)}),e.lookup=r,e}function sB(e){G.call(this,null,e)}function VSe(){let e=[],t={entries:e=>r(n(e,0),0),key:n=>(e.push(n),t)};function n(t,r){if(r>=e.length)return t;let i=t.length,a=e[r++],o={},s={},c=-1,l,u,d;for(;++ce.length)return t;let i=[];for(let e in t)i.push({key:e,values:r(t[e],n)});return i}return t}function cB(e){G.call(this,null,e)}function HSe(e,t,n){for(let r,i=0,a=t.length;i{Kx(),Ag(),zSe(),sB.Definition={type:`Nest`,metadata:{treesource:!0,changes:!0},params:[{name:`keys`,type:`field`,array:!0},{name:`generate`,type:`boolean`}]},hB=e=>e.values,U(sB,G,{transform(e,t){t.source||V(`Nest transform requires an upstream data source.`);var n=e.generate,r=e.modified(),i=t.clone(),a=this.value;return(!a||r||t.changed())&&(a&&a.each(e=>{e.children&&Zb(e.data)&&i.rem.push(e.data)}),this.value=a=fz({values:ng(e.keys).reduce((e,t)=>(e.key(t),e),VSe()).entries(i.source)},hB),n&&a.each(e=>{e.children&&(e=ex(e.data),i.add.push(e),i.source.push(e))}),oB(a,Qb,Qb)),i.source.root=a,i}}),gB=(e,t)=>e.parent===t.parent?1:2,U(cB,G,{transform(e,t){(!t.source||!t.source.root)&&V(this.constructor.name+` transform requires a backing tree data source.`);let n=this.layout(e.method),r=this.fields,i=t.source.root,a=e.as||r;e.field?i.sum(e.field):i.count(),e.sort&&i.sort(ix(e.sort,e=>e.data)),HSe(n,this.params,e),n.separation&&n.separation(e.separation===!1?xh:gB);try{this.value=n(i)}catch(e){V(e)}return i.each(e=>USe(e,r,a)),t.reflow(e.modified()).modifies(a).modifies(`leaf`)}}),_B=[`x`,`y`,`r`,`depth`,`children`],lB.Definition={type:`Pack`,metadata:{tree:!0,modifies:!0},params:[{name:`field`,type:`field`},{name:`sort`,type:`compare`},{name:`padding`,type:`number`,default:0},{name:`radius`,type:`field`,default:null},{name:`size`,type:`number`,array:!0,length:2},{name:`as`,type:`string`,array:!0,length:_B.length,default:_B}]},U(lB,cB,{layout:_Se,params:[`radius`,`size`,`padding`],fields:_B}),vB=[`x0`,`y0`,`x1`,`y1`,`depth`,`children`],uB.Definition={type:`Partition`,metadata:{tree:!0,modifies:!0},params:[{name:`field`,type:`field`},{name:`sort`,type:`compare`},{name:`padding`,type:`number`,default:0},{name:`round`,type:`boolean`,default:!1},{name:`size`,type:`number`,array:!0,length:2},{name:`as`,type:`string`,array:!0,length:vB.length,default:vB}]},U(uB,cB,{layout:ySe,params:[`size`,`round`,`padding`],fields:vB}),dB.Definition={type:`Stratify`,metadata:{treesource:!0},params:[{name:`key`,type:`field`,required:!0},{name:`parentKey`,type:`field`,required:!0}]},U(dB,G,{transform(e,t){t.source||V(`Stratify transform requires an upstream data source.`);let n=this.value,r=e.modified(),i=t.fork(t.ALL).materialize(t.SOURCE),a=!n||r||t.changed(t.ADD_REM)||t.modified(e.key.fields)||t.modified(e.parentKey.fields);return i.source=i.source.slice(),a&&(n=i.source.length?oB(Wz().id(e.key).parentId(e.parentKey)(i.source),e.key,Sh):oB(Wz()([{}]),e.key,e.key)),i.source.root=this.value=n,i}}),yB={tidy:ASe,cluster:Dxe},bB=[`x`,`y`,`depth`,`children`],fB.Definition={type:`Tree`,metadata:{tree:!0,modifies:!0},params:[{name:`field`,type:`field`},{name:`sort`,type:`compare`},{name:`method`,type:`enum`,default:`tidy`,values:[`tidy`,`cluster`]},{name:`size`,type:`number`,array:!0,length:2},{name:`nodeSize`,type:`number`,array:!0,length:2},{name:`separation`,type:`boolean`,default:!0},{name:`as`,type:`string`,array:!0,length:bB.length,default:bB}]},U(fB,cB,{layout(e){let t=e||`tidy`;if(fg(yB,t))return yB[t]();V(`Unrecognized Tree layout method: `+t)},params:[`size`,`nodeSize`],fields:bB}),pB.Definition={type:`TreeLinks`,metadata:{tree:!0,generates:!0,changes:!0},params:[]},U(pB,G,{transform(e,t){let n=this.value,r=t.source&&t.source.root,i=t.fork(t.NO_SOURCE),a={};return r||V(`TreeLinks transform requires a tree data source.`),t.changed(t.ADD_REM)?(i.rem=n,t.visit(t.SOURCE,e=>a[Qb(e)]=1),r.each(e=>{let t=e.data,n=e.parent&&e.parent.data;n&&a[Qb(t)]&&a[Qb(n)]&&i.add.push(ex({source:n,target:t}))}),this.value=i.add):t.changed(t.MOD)&&(t.visit(t.MOD,e=>a[Qb(e)]=1),n.forEach(e=>{(a[Qb(e.source)]||a[Qb(e.target)])&&i.mod.push(e)})),i}}),xB={binary:PSe,dice:Hz,slice:$z,slicedice:ISe,squarify:rB,resquarify:aB},SB=[`x0`,`y0`,`x1`,`y1`,`depth`,`children`],mB.Definition={type:`Treemap`,metadata:{tree:!0,modifies:!0},params:[{name:`field`,type:`field`},{name:`sort`,type:`compare`},{name:`method`,type:`enum`,default:`squarify`,values:[`squarify`,`resquarify`,`binary`,`dice`,`slice`,`slicedice`]},{name:`padding`,type:`number`,default:0},{name:`paddingInner`,type:`number`,default:0},{name:`paddingOuter`,type:`number`,default:0},{name:`paddingTop`,type:`number`,default:0},{name:`paddingRight`,type:`number`,default:0},{name:`paddingBottom`,type:`number`,default:0},{name:`paddingLeft`,type:`number`,default:0},{name:`ratio`,type:`number`,default:1.618033988749895},{name:`round`,type:`boolean`,default:!1},{name:`size`,type:`number`,array:!0,length:2},{name:`as`,type:`string`,array:!0,length:SB.length,default:SB}]},U(mB,cB,{layout(){let e=MSe();return e.ratio=t=>{let n=e.tile();n.ratio&&e.tile(n.ratio(t))},e.method=t=>{fg(xB,t)?e.tile(xB[t]):V(`Unrecognized Treemap layout method: `+t)},e},params:[`method`,`ratio`,`size`,`round`,`padding`,`paddingInner`,`paddingOuter`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`],fields:SB})})),GSe=c({label:()=>OB});function KSe(e,t){let n=e.bitmap();return(t||[]).forEach(t=>n.set(e(t.boundary[0]),e(t.boundary[3]))),[n,void 0]}function qSe(e,t,n,r,i){let a=e.width,o=e.height,s=r||i,c=ET(a,o).getContext(`2d`),l=ET(a,o).getContext(`2d`),u=s&&ET(a,o).getContext(`2d`);n.forEach(e=>wB(c,e,!1)),wB(l,t,!1),s&&wB(u,t,!0);let d=CB(c,a,o),f=CB(l,a,o),p=s&&CB(u,a,o),m=e.bitmap(),h=s&&e.bitmap(),g,_,v,y,b,x,S,C;for(_=0;_{t.items.forEach(t=>wB(e,t.items,n))}):wA[r].draw(e,{items:n?t.map(JSe):t})}function JSe(e){let t=nx(e,{});return t.stroke&&t.strokeOpacity!==0||t.fill&&t.fillOpacity!==0?{...t,strokeOpacity:1,stroke:`#000`,fillOpacity:0}:t}function YSe(e,t){let n=new Uint32Array(~~((e*t+MB)/MB));function r(e,t){n[e]|=t}function i(e,t){n[e]&=t}return{array:n,get:(t,r)=>{let i=r*e+t;return n[i>>>AB]&1<<(i&jB)},set:(t,n)=>{let i=n*e+t;r(i>>>AB,1<<(i&jB))},clear:(t,n)=>{let r=n*e+t;i(r>>>AB,~(1<<(r&jB)))},getRange:(t,r,i,a)=>{let o=a,s,c,l,u;for(;o>=r;--o)if(s=o*e+t,c=o*e+i,l=s>>>AB,u=c>>>AB,l===u){if(n[l]&NB[s&jB]&PB[(c&jB)+1])return!0}else{if(n[l]&NB[s&jB]||n[u]&PB[(c&jB)+1])return!0;for(let e=l+1;e{let o,s,c,l,u;for(;n<=a;++n)if(o=n*e+t,s=n*e+i,c=o>>>AB,l=s>>>AB,c===l)r(c,NB[o&jB]&PB[(s&jB)+1]);else for(r(c,NB[o&jB]),r(l,PB[(s&jB)+1]),u=c+1;u{let o,s,c,l,u;for(;n<=a;++n)if(o=n*e+t,s=n*e+r,c=o>>>AB,l=s>>>AB,c===l)i(c,PB[o&jB]|NB[(s&jB)+1]);else for(i(c,PB[o&jB]),i(l,NB[(s&jB)+1]),u=c+1;un<0||r<0||a>=t||i>=e}}function XSe(e,t,n){let r=Math.max(1,Math.sqrt(e*t/1e6)),i=~~((e+2*n+r)/r),a=~~((t+2*n+r)/r),o=e=>~~((e+n)/r);return o.invert=e=>e*r-n,o.bitmap=()=>YSe(i,a),o.ratio=r,o.padding=n,o.width=e,o.height=t,o}function ZSe(e,t,n,r){let i=e.width,a=e.height;return function(e){let t=e.datum.datum.items[r].items,n=t.length,o=e.datum.fontSize,s=SA.width(e.datum,e.datum.text),c=0,l,u,d,f,p,m,h;for(let r=0;r=c&&(c=h,e.x=p,e.y=m);return p=s/2,m=o/2,l=e.x-p,u=e.x+p,d=e.y-m,f=e.y+m,e.align=`center`,l<0&&u<=i?e.align=`left`:0<=l&&ii||t-(o=r/2)<0||t+o>a}function EB(e,t,n,r,i,a,o,s){let c=i*a/(r*2),l=e(t-c),u=e(t+c),d=e(n-(a/=2)),f=e(n+a);return o.outOfBounds(l,d,u,f)||o.getRange(l,d,u,f)||s&&s.getRange(l,d,u,f)}function QSe(e,t,n,r){let i=e.width,a=e.height,o=t[0],s=t[1];function c(t,n,r,c,l){let u=e.invert(t),d=e.invert(n),f=r,p=a,m;if(!TB(u,d,c,l,i,a)&&!EB(e,u,d,l,c,f,o,s)&&!EB(e,u,d,l,c,l,o,null)){for(;p-f>=1;)m=(f+p)/2,EB(e,u,d,l,c,m,o,s)?p=m:f=m;if(f>r)return[u,d,f,!0]}}return function(t){let s=t.datum.datum.items[r].items,l=s.length,u=t.datum.fontSize,d=SA.width(t.datum,t.datum.text),f=n?u:0,p=!1,m=!1,h=0,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M;for(let r=0;r_&&(M=g,g=_,_=M),v>y&&(M=v,v=y,y=M),w=e(g),E=e(_),T=~~((w+E)/2),D=e(v),k=e(y),O=~~((D+k)/2),S=T;S>=w;--S)for(C=O;C>=D;--C)j=c(S,C,f,d,u),j&&([t.x,t.y,f,p]=j);for(S=T;S<=E;++S)for(C=O;C<=k;++C)j=c(S,C,f,d,u),j&&([t.x,t.y,f,p]=j);!p&&!n&&(A=Math.abs(_-g+y-v),b=(g+_)/2,x=(v+y)/2,A>=h&&!TB(b,x,d,u,i,a)&&!EB(e,b,x,u,d,u,o,null)&&(h=A,t.x=b,t.y=x,m=!0))}return p||m?(b=d/2,x=u/2,o.setRange(e(t.x-b),e(t.y-x),e(t.x+b),e(t.y+x)),t.align=`center`,t.baseline=`middle`,!0):!1}}function $Se(e,t,n,r){let i=e.width,a=e.height,o=t[0],s=t[1],c=e.bitmap();return function(t){let l=t.datum.datum.items[r].items,u=l.length,d=t.datum.fontSize,f=SA.width(t.datum,t.datum.text),p=[],m=n?d:0,h=!1,g=!1,_=0,v,y,b,x,S,C,w,T,E,D,O,k;for(let r=0;r=1;)O=(E+D)/2,EB(e,S,C,d,f,O,o,s)?D=O:E=O;E>m&&(t.x=S,t.y=C,m=E,h=!0)}}!h&&!n&&(k=Math.abs(y-v+x-b),S=(v+y)/2,C=(b+x)/2,k>=_&&!TB(S,C,f,d,i,a)&&!EB(e,S,C,d,f,d,o,null)&&(_=k,t.x=S,t.y=C,g=!0))}return h||g?(S=f/2,C=d/2,o.setRange(e(t.x-S),e(t.y-C),e(t.x+S),e(t.y+C)),t.align=`center`,t.baseline=`middle`,!0):!1}}function eCe(e,t,n,r){let i=e.width,a=e.height,o=t[0],s=t[1],c=r.length;return function(t){let l=t.boundary,u=t.datum.fontSize;if(l[2]<0||l[5]<0||l[0]>i||l[3]>a)return!1;let d=t.textWidth??0,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E;for(let i=0;i>>2&3)-1,m=f===0&&p===0||r[i]<0,h=f&&p?Math.SQRT1_2:1,g=r[i]<0?-1:1,_=l[1+f]+r[i]*f*h,S=l[4+p]+g*u*p/2+r[i]*p*h,y=S-u/2,b=S+u/2,C=e(_),T=e(y),E=e(b),!d)if(DB(C,C,T,E,o,s,_,_,y,b,l,m))d=SA.width(t.datum,t.datum.text);else continue;if(x=_+g*d*f/2,_=x-d/2,v=x+d/2,C=e(_),w=e(v),DB(C,w,T,E,o,s,_,v,y,b,l,m))return t.x=f?f*g<0?v:_:x,t.y=p?p*g<0?b:y:S,t.align=LB[f*g+1],t.baseline=RB[p*g+1],o.setRange(C,T,w,E),!0}return!1}}function DB(e,t,n,r,i,a,o,s,c,l,u,d){return!(i.outOfBounds(e,n,t,r)||(d&&a||i).getRange(e,n,t,r))}function tCe(e,t,n,r,i,a,o,s,c,l,u){if(!e.length)return e;let d=Math.max(r.length,i.length),f=nCe(r,d),p=rCe(i,d),m=iCe(e[0].datum),h=m===`group`&&e[0].datum.items[c].marktype,g=h===`area`,_=aCe(m,h,s,c),v=l===null||l===1/0,y=g&&u===`naive`,b=-1,x=-1,S=e.map(e=>{let t=v?SA.width(e,e.text):void 0;return b=Math.max(b,t),x=Math.max(x,e.fontSize),{datum:e,opacity:0,x:void 0,y:void 0,align:void 0,baseline:void 0,boundary:_(e),textWidth:t}});l=l===null||l===1/0?Math.max(b,x)+Math.max(...r):l;let C=XSe(t[0],t[1],l),w;if(!y){n&&S.sort((e,t)=>n(e.datum,t.datum));let t=!1;for(let e=0;ee.datum);w=a.length||r?qSe(C,r||[],a,t,g):KSe(C,o&&S)}let T=g?BB[u](C,w,o,c):eCe(C,w,p,f);return S.forEach(e=>e.opacity=+T(e)),S}function nCe(e,t){let n=new Float64Array(t),r=e.length;for(let t=0;t[e.x,e.x,e.x,e.y,e.y,e.y];return e?e===`line`||e===`area`?e=>i(e.datum):t===`line`?e=>{let t=e.datum.items[r].items;return i(t.length?t[n===`start`?0:t.length-1]:{x:NaN,y:NaN})}:e=>{let t=e.datum.bounds;return[t.x1,(t.x1+t.x2)/2,t.x2,t.y1,(t.y1+t.y2)/2,t.y2]}:i}function OB(e){G.call(this,null,e)}var kB,AB,jB,MB,NB,PB,FB,IB,LB,RB,zB,BB,VB,HB,oCe=o((()=>{Pj(),OT(),Kx(),Ag(),kB=4278190080,AB=5,jB=31,MB=32,NB=new Uint32Array(33),PB=new Uint32Array(33),PB[0]=0,NB[0]=~PB[0];for(let e=1;e<=MB;++e)PB[e]=PB[e-1]<<1|1,NB[e]=~PB[e];FB=[-1,-1,1,1],IB=[-1,1,-1,1],LB=[`right`,`center`,`left`],RB=[`bottom`,`middle`,`top`],zB={"top-left":0,top:1,"top-right":2,left:4,middle:5,right:6,"bottom-left":8,bottom:9,"bottom-right":10},BB={naive:ZSe,"reduced-search":QSe,floodfill:$Se},VB=[`x`,`y`,`opacity`,`align`,`baseline`],HB=[`top-left`,`left`,`bottom-left`,`top`,`bottom`,`top-right`,`right`,`bottom-right`],OB.Definition={type:`Label`,metadata:{modifies:!0},params:[{name:`size`,type:`number`,array:!0,length:2,required:!0},{name:`sort`,type:`compare`},{name:`anchor`,type:`string`,array:!0,default:HB},{name:`offset`,type:`number`,array:!0,default:[1]},{name:`padding`,type:`number`,default:0,null:!0},{name:`lineAnchor`,type:`string`,values:[`start`,`end`],default:`end`},{name:`markIndex`,type:`number`,default:0},{name:`avoidBaseMark`,type:`boolean`,default:!0},{name:`avoidMarks`,type:`data`,array:!0},{name:`method`,type:`string`,default:`naive`},{name:`as`,type:`string`,array:!0,length:VB.length,default:VB}]},U(OB,G,{transform(e,t){function n(n){let r=e[n];return ig(r)&&t.modified(r.fields)}let r=e.modified();if(!(r||t.changed(t.ADD_REM)||n(`sort`)))return;(!e.size||e.size.length!==2)&&V(`Size parameter should be specified as a [width, height] array.`);let i=e.as||VB;return tCe(t.materialize(t.SOURCE).source||[],e.size,e.sort,ng(e.offset==null?1:e.offset),ng(e.anchor||HB),e.avoidMarks||[],e.avoidBaseMark!==!1,e.lineAnchor||`end`,e.markIndex||0,e.padding===void 0?0:e.padding,e.method||`naive`).forEach(e=>{let t=e.datum;t[i[0]]=e.x,t[i[1]]=e.y,t[i[2]]=e.opacity,t[i[3]]=e.align,t[i[4]]=e.baseline}),t.reflow(r).modifies(i)}})})),sCe=c({loess:()=>WB,regression:()=>GB});function UB(e,t){var n=[],r=function(e){return e(s)},i,a,o,s,c,l;if(t==null)n.push(e);else for(i={},a=0,o=e.length;a{LS(),Kx(),Ag(),WB.Definition={type:`Loess`,metadata:{generates:!0},params:[{name:`x`,type:`field`,required:!0},{name:`y`,type:`field`,required:!0},{name:`groupby`,type:`field`,array:!0},{name:`bandwidth`,type:`number`,default:.3},{name:`as`,type:`string`,array:!0}]},U(WB,G,{transform(e,t){let n=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){let r=t.materialize(t.SOURCE).source,i=UB(r,e.groupby),a=(e.groupby||[]).map(oh),o=a.length,s=e.as||[oh(e.x),oh(e.y)],c=[];i.forEach(t=>{OS(t,e.x,e.y,e.bandwidth||.3).forEach(e=>{let n={};for(let e=0;ee===`poly`?t:e===`quad`?2:1,GB.Definition={type:`Regression`,metadata:{generates:!0},params:[{name:`x`,type:`field`,required:!0},{name:`y`,type:`field`,required:!0},{name:`groupby`,type:`field`,array:!0},{name:`method`,type:`string`,default:`linear`,values:Object.keys(KB)},{name:`order`,type:`number`,default:3},{name:`extent`,type:`number`,array:!0,length:2},{name:`params`,type:`boolean`,default:!1},{name:`as`,type:`string`,array:!0}]},U(GB,G,{transform(e,t){let n=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){let r=t.materialize(t.SOURCE).source,i=UB(r,e.groupby),a=(e.groupby||[]).map(oh),o=e.method||`linear`,s=e.order==null?3:e.order,c=qB(o,s),l=e.as||[oh(e.x),oh(e.y)],u=KB[o],d=[],f=e.extent;fg(KB,o)||V(`Invalid regression method: `+o),f!=null&&o===`log`&&f[0]<=0&&(t.dataflow.warn(`Ignoring extent with values <= 0 for log regression.`),f=null),i.forEach(n=>{if(n.length<=c){t.dataflow.warn(`Skipping regression with more parameters than data points.`);return}let r=u(n,e.x,e.y,s);if(e.params){d.push(ex({keys:n.dims,coef:r.coef,rSquared:r.rSquared}));return}let i=f||dg(n,e.x),p=e=>{let t={};for(let e=0;ep([e,r.predict(e)])):kS(r.predict,i,25,200).forEach(p)}),this.value&&(n.rem=this.value),this.value=n.add=n.source=d}return n}})}));function JB(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(dl==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);dl==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d{YB=11102230246251565e-32,XB=134217729,ZB=3.000000000000001*YB}));function uCe(e,t,n,r,i,a,o){let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=e-i,E=n-i,D=t-a,O=r-a;b=T*O,f=XB*T,p=f-(f-T),m=T-p,f=XB*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=D*E,f=XB*D,p=f-(f-D),m=D-p,f=XB*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,rV[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,rV[1]=y-(_+d)+(d-S),w=v+_,d=w-v,rV[2]=v-(w-d)+(_-d),rV[3]=w;let k=lCe(4,rV),A=tV*o;if(k>=A||-k>=A||(d=e-T,s=e-(T+d)+(d-i),d=n-E,l=n-(E+d)+(d-i),d=t-D,c=t-(D+d)+(d-a),d=r-O,u=r-(O+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(A=nV*o+ZB*Math.abs(k),k+=T*u+O*s-(D*l+E*c),k>=A||-k>=A))return k;b=s*O,f=XB*s,p=f-(f-s),m=s-p,f=XB*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=c*E,f=XB*c,p=f-(f-c),m=c-p,f=XB*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,sV[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,sV[1]=y-(_+d)+(d-S),w=v+_,d=w-v,sV[2]=v-(w-d)+(_-d),sV[3]=w;let j=JB(4,rV,4,sV,iV);b=T*u,f=XB*T,p=f-(f-T),m=T-p,f=XB*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=D*l,f=XB*D,p=f-(f-D),m=D-p,f=XB*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,sV[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,sV[1]=y-(_+d)+(d-S),w=v+_,d=w-v,sV[2]=v-(w-d)+(_-d),sV[3]=w;let M=JB(j,iV,4,sV,aV);b=s*u,f=XB*s,p=f-(f-s),m=s-p,f=XB*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=XB*c,p=f-(f-c),m=c-p,f=XB*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,sV[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,sV[1]=y-(_+d)+(d-S),w=v+_,d=w-v,sV[2]=v-(w-d)+(_-d),sV[3]=w;let ee=JB(M,aV,4,sV,oV);return oV[ee-1]}function $B(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=eV*l?c:-uCe(e,t,n,r,i,a,l)}var eV,tV,nV,rV,iV,aV,oV,sV,dCe=o((()=>{QB(),eV=(3+16*YB)*YB,tV=(2+12*YB)*YB,nV=(9+64*YB)*YB*YB,rV=K(4),iV=K(8),aV=K(12),oV=K(16),sV=K(4)})),fCe=o((()=>{QB(),(7+56*YB)*YB,(3+28*YB)*YB,(26+288*YB)*YB*YB,K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(8),K(8),K(8),K(4),K(8),K(8),K(16),K(12),K(192),K(192)})),pCe=o((()=>{QB(),(10+96*YB)*YB,(4+48*YB)*YB,(44+576*YB)*YB*YB,K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(8),K(8),K(8),K(8),K(8),K(8),K(8),K(8),K(8),K(4),K(4),K(4),K(8),K(16),K(16),K(16),K(32),K(32),K(48),K(64),K(1152),K(1152)})),mCe=o((()=>{QB(),(16+224*YB)*YB,(5+72*YB)*YB,(71+1408*YB)*YB*YB,K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(4),K(24),K(24),K(24),K(24),K(24),K(24),K(24),K(24),K(24),K(24),K(1152),K(1152),K(1152),K(1152),K(1152),K(2304),K(2304),K(3456),K(5760),K(8),K(8),K(8),K(16),K(24),K(48),K(48),K(96),K(192),K(384),K(384),K(384),K(768),K(96),K(96),K(96),K(1152)})),hCe=o((()=>{dCe(),fCe(),pCe(),mCe()}));function gCe(e,t){let n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function cV(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function _Ce(e,t,n,r,i,a,o,s){let c=e-o,l=t-s,u=n-o,d=r-s,f=i-o,p=a-s,m=c*c+l*l,h=u*u+d*d,g=f*f+p*p;return c*(d*g-h*p)-l*(u*g-h*f)+m*(u*p-d*f)<0}function vCe(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c),p=(l*u-s*d)*f,m=(o*d-c*u)*f;return p*p+m*m}function yCe(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c);return{x:e+(l*u-s*d)*f,y:t+(o*d-c*u)*f}}function lV(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){let r=e[i],a=t[r],o=i-1;for(;o>=n&&t[e[o]]>a;)e[o+1]=e[o--];e[o+1]=r}else{let i=n+r>>1,a=n+1,o=r;uV(e,i,a),t[e[n]]>t[e[r]]&&uV(e,n,r),t[e[a]]>t[e[r]]&&uV(e,a,r),t[e[n]]>t[e[a]]&&uV(e,n,a);let s=e[a],c=t[s];for(;;){do a++;while(t[e[a]]c);if(o=o-n?(lV(e,t,a,r),lV(e,t,n,o-1)):(lV(e,t,n,o-1),lV(e,t,a,r))}}function uV(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function bCe(e){return e[0]}function xCe(e){return e[1]}var dV,fV,pV,SCe=o((()=>{hCe(),dV=2**-52,fV=new Uint32Array(512),pV=class e{static from(t,n=bCe,r=xCe){let i=t.length,a=new Float64Array(i*2);for(let e=0;e>1;if(t>0&&typeof e[0]!=`number`)throw Error(`Expected coords to contain numbers.`);this.coords=e;let n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){let{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,a=e.length>>1,o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t=0;tc&&(c=n),r>l&&(l=r),this._ids[t]=t}let u=(o+c)/2,d=(s+l)/2,f=0,p=0,m=0;for(let t=0,n=1/0;t0&&(p=t,n=r)}let _=e[2*p],v=e[2*p+1],y=1/0;for(let t=0;tr&&(t[n++]=i,r=a)}this.hull=t.subarray(0,n),this.triangles=new Uint32Array,this.halfedges=new Int32Array;return}if($B(h,g,_,v,b,x)<0){let e=p,t=_,n=v;p=m,_=b,v=x,m=e,b=t,x=n}let S=yCe(h,g,_,v,b,x);this._cx=S.x,this._cy=S.y;for(let t=0;t0&&Math.abs(l-o)<=dV&&Math.abs(u-s)<=dV||(o=l,s=u,c===f||c===p||c===m))continue;let d=0;for(let e=0,t=this._hashKey(l,u);e=0;)if(h=g,h===d){h=-1;break}if(h===-1)continue;let _=this._addTriangle(h,c,n[h],-1,-1,r[h]);r[c]=this._legalize(_+2),r[h]=_,C++;let v=n[h];for(;g=n[v],$B(l,u,e[2*v],e[2*v+1],e[2*g],e[2*g+1])<0;)_=this._addTriangle(v,c,g,r[c],-1,r[v]),r[c]=this._legalize(_+2),n[v]=v,C--,v=g;if(h===d)for(;g=t[h],$B(l,u,e[2*g],e[2*g+1],e[2*h],e[2*h+1])<0;)_=this._addTriangle(g,c,h,-1,r[h],r[g]),this._legalize(_+2),r[g]=_,n[h]=h,C--,h=g;this._hullStart=t[c]=h,n[h]=t[v]=c,n[c]=v,i[this._hashKey(l,u)]=c,i[this._hashKey(e[2*h],e[2*h+1])]=h}this.hull=new Uint32Array(C);for(let e=0,t=this._hullStart;e{mV=1e-6,hV=class{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=``}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,n){e=+e,t=+t,n=+n;let r=e+n,i=t;if(n<0)throw Error(`negative radius`);this._x1===null?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>mV||Math.abs(this._y1-i)>mV)&&(this._+=`L`+r+`,`+i),n&&(this._+=`A${n},${n},0,1,1,${e-n},${t}A${n},${n},0,1,1,${this._x1=r},${this._y1=i}`)}rect(e,t,n,r){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+n}v${+r}h${-n}Z`}value(){return this._||null}}})),_V,vV=o((()=>{_V=class{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}})),yV,bV=o((()=>{gV(),vV(),yV=class{constructor(e,[t,n,r,i]=[0,0,960,500]){if(!((r=+r)>=(t=+t))||!((i=+i)>=(n=+n)))throw Error(`invalid bounds`);this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=r,this.xmin=t,this.ymax=i,this.ymin=n,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){let{delaunay:{points:e,hull:t,triangles:n},vectors:r}=this,i,a,o=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(let r=0,s=0,c=n.length,l,u;r1;)i-=2;for(let e=2;e0){if(t>=this.ymax)return null;(a=(this.ymax-t)/r)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/n)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function ECe(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}function DCe(e,t,n,r){let i=e.length,a=new Float64Array(i*2);for(let o=0;o{SCe(),gV(),vV(),bV(),xV=2*Math.PI,SV=Math.pow,CV=class e{static from(t,n=CCe,r=wCe,i){return new e(`length`in t?DCe(t,n,r,i):Float64Array.from(OCe(t,n,r,i)))}constructor(e){this._delaunator=new pV(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){let e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&TCe(e)){this.collinear=Int32Array.from({length:t.length/2},(e,t)=>t).sort((e,n)=>t[2*e]-t[2*n]||t[2*e+1]-t[2*n+1]);let e=this.collinear[0],n=this.collinear[this.collinear.length-1],r=[t[2*e],t[2*e+1],t[2*n],t[2*n+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let e=0,n=t.length/2;e0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],a[r[0]]=1,r.length===2&&(a[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(e){return new yV(this,e)}*neighbors(e){let{inedges:t,hull:n,_hullIndex:r,halfedges:i,triangles:a,collinear:o}=this;if(o){let t=o.indexOf(e);t>0&&(yield o[t-1]),t=0&&i!==n&&i!==r;)n=i;return i}_step(e,t,n){let{inedges:r,hull:i,_hullIndex:a,halfedges:o,triangles:s,points:c}=this;if(r[e]===-1||!c.length)return(e+1)%(c.length>>1);let l=e,u=SV(t-c[e*2],2)+SV(n-c[e*2+1],2),d=r[e],f=d;do{let r=s[f],d=SV(t-c[r*2],2)+SV(n-c[r*2+1],2);if(d{kCe(),bV()})),jCe=c({voronoi:()=>wV});function wV(e){G.call(this,null,e)}function MCe(e){let t=e[0][0],n=e[0][1],r=e.length-1;for(;e[r][0]===t&&e[r][1]===n;--r);return`M`+e.slice(0,r+1).join(`L`)+`Z`}function NCe(e){return e.length===2&&e[0][0]===e[1][0]&&e[0][1]===e[1][1]}var TV,PCe=o((()=>{Kx(),Ag(),ACe(),wV.Definition={type:`Voronoi`,metadata:{modifies:!0},params:[{name:`x`,type:`field`,required:!0},{name:`y`,type:`field`,required:!0},{name:`size`,type:`number`,array:!0,length:2},{name:`extent`,type:`array`,array:!0,length:2,default:[[-1e5,-1e5],[1e5,1e5]],content:{type:`number`,array:!0,length:2}},{name:`as`,type:`string`,default:`path`}]},TV=[-1e5,-1e5,1e5,1e5],U(wV,G,{transform(e,t){let n=e.as||`path`,r=t.source;if(!r||!r.length)return t;let i=e.size;i=i?[0,0,i[0],i[1]]:(i=e.extent)?[i[0][0],i[0][1],i[1][0],i[1][1]]:TV;let a=this.value=CV.from(r,e.x,e.y).voronoi(i);for(let e=0,t=r.length;eOV});function ICe(){var e=[256,256],t,n,r,i,a,o,s,c=EV,l=[],u=Math.random,d={};d.layout=function(){for(var c=f(ET()),d=HCe((e[0]>>5)*e[1]),m=null,h=l.length,g=-1,_=[],v=l.map(e=>({text:t(e),font:n(e),style:i(e),weight:a(e),rotate:o(e),size:~~(r(e)+1e-14),padding:s(e),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:e})).sort((e,t)=>t.size-e.size);++g>1,y.y=e[1]*(u()+.5)>>1,LCe(c,y,v,g),y.hasText&&p(d,y,m)&&(_.push(y),m?zCe(m,y):m=[{x:y.x+y.x0,y:y.y+y.y0},{x:y.x+y.x1,y:y.y+y.y1}],y.x-=e[0]>>1,y.y-=e[1]>>1)}return _};function f(e){e.width=e.height=1;var t=Math.sqrt(e.getContext(`2d`).getImageData(0,0,1,1).data.length>>2);e.width=(AV<<5)/t,e.height=jV/t;var n=e.getContext(`2d`);return n.fillStyle=n.strokeStyle=`red`,n.textAlign=`center`,{context:n,ratio:t}}function p(t,n,r){for(var i=n.x,a=n.y,o=Math.hypot(e[0],e[1]),s=c(e),l=u()<.5?1:-1,d=-l,f,p,m;(f=s(d+=l))&&(p=~~f[0],m=~~f[1],!(Math.min(Math.abs(p),Math.abs(m))>=o));)if(n.x=i+p,n.y=a+m,!(n.x+n.x0<0||n.y+n.y0<0||n.x+n.x1>e[0]||n.y+n.y1>e[1])&&(!r||!RCe(n,t,e[0]))&&(!r||BCe(n,r))){for(var h=n.sprite,g=n.width>>5,_=e[0]>>5,v=n.x-(g<<4),y=v&127,b=32-y,x=n.y1-n.y0,S=(n.y+n.y0)*_+(v>>5),C,w=0;w>>y:0);S+=_}return n.sprite=null,!0}return!1}return d.words=function(e){return arguments.length?(l=e,d):l},d.size=function(t){return arguments.length?(e=[+t[0],+t[1]],d):e},d.font=function(e){return arguments.length?(n=DV(e),d):n},d.fontStyle=function(e){return arguments.length?(i=DV(e),d):i},d.fontWeight=function(e){return arguments.length?(a=DV(e),d):a},d.rotate=function(e){return arguments.length?(o=DV(e),d):o},d.text=function(e){return arguments.length?(t=DV(e),d):t},d.spiral=function(e){return arguments.length?(c=MV[e]||e,d):c},d.fontSize=function(e){return arguments.length?(r=DV(e),d):r},d.padding=function(e){return arguments.length?(s=DV(e),d):s},d.random=function(e){return arguments.length?(u=e,d):u},d}function LCe(e,t,n,r){if(!t.sprite){var i=e.context,a=e.ratio;i.clearRect(0,0,(AV<<5)/a,jV/a);var o=0,s=0,c=0,l=n.length,u,d,f,p,m;for(--r;++r>5<<5,f=~~Math.max(Math.abs(v+y),Math.abs(v-y))}else u=u+31>>5<<5;if(f>c&&(c=f),o+u>=AV<<5&&(o=0,s+=c,c=0),s+f>=jV)break;i.translate((o+(u>>1))/a,(s+(f>>1))/a),t.rotate&&i.rotate(t.rotate*kV),i.fillText(t.text,0,0),t.padding&&(i.lineWidth=2*t.padding,i.strokeText(t.text,0,0)),i.restore(),t.width=u,t.height=f,t.xoff=o,t.yoff=s,t.x1=u>>1,t.y1=f>>1,t.x0=-t.x1,t.y0=-t.y1,t.hasText=!0,o+=u}for(var x=i.getImageData(0,0,(AV<<5)/a,jV/a).data,S=[];--r>=0;)if(t=n[r],t.hasText){for(u=t.width,d=u>>5,f=t.y1-t.y0,p=0;p>5),E=x[(s+m)*(AV<<5)+(o+p)<<2]?1<<31-p%32:0;S[T]|=E,C|=E}C?w=m:(t.y0++,f--,m--,s++)}t.y1=t.y0+w,t.sprite=S.slice(0,(t.y1-t.y0)*d)}}}function RCe(e,t,n){n>>=5;for(var r=e.sprite,i=e.width>>5,a=e.x-(i<<4),o=a&127,s=32-o,c=e.y1-e.y0,l=(e.y+e.y0)*n+(a>>5),u,d=0;d>>o:0))&t[l+f])return!0;l+=n}return!1}function zCe(e,t){var n=e[0],r=e[1];t.x+t.x0r.x&&(r.x=t.x+t.x1),t.y+t.y1>r.y&&(r.y=t.y+t.y1)}function BCe(e,t){return e.x+e.x1>t[0].x&&e.x+e.x0t[0].y&&e.y+e.y0{OT(),Kx(),Ag(),xO(),LS(),kV=Math.PI/180,AV=64,jV=2048,MV={archimedean:EV,rectangular:VCe},NV=[`x`,`y`,`font`,`fontSize`,`fontStyle`,`fontWeight`,`angle`],PV=[`text`,`font`,`rotate`,`fontSize`,`fontStyle`,`fontWeight`],OV.Definition={type:`Wordcloud`,metadata:{modifies:!0},params:[{name:`size`,type:`number`,array:!0,length:2},{name:`font`,type:`string`,expr:!0,default:`sans-serif`},{name:`fontStyle`,type:`string`,expr:!0,default:`normal`},{name:`fontWeight`,type:`string`,expr:!0,default:`normal`},{name:`fontSize`,type:`number`,expr:!0,default:14},{name:`fontSizeRange`,type:`number`,array:`nullable`,default:[10,50]},{name:`rotate`,type:`number`,expr:!0,default:0},{name:`text`,type:`field`},{name:`spiral`,type:`string`,values:[`archimedean`,`rectangular`]},{name:`padding`,type:`number`,expr:!0},{name:`as`,type:`string`,array:!0,length:7,default:NV}]},U(OV,G,{transform(e,t){e.size&&!(e.size[0]&&e.size[1])&&V(`Wordcloud size dimensions must be non-zero.`);function n(n){let r=e[n];return ig(r)&&t.modified(r.fields)}let r=e.modified();if(!(r||t.changed(t.ADD_REM)||PV.some(n)))return;let i=t.materialize(t.SOURCE).source,a=this.value,o=e.as||NV,s=e.fontSize||14,c;if(ig(s)?c=e.fontSizeRange:s=cg(s),c){let e=s,t=WD(`sqrt`)().domain(dg(i,e)).range(c);s=n=>t(e(n))}i.forEach(e=>{e[o[0]]=NaN,e[o[1]]=NaN,e[o[3]]=0});let l=a.words(i).text(e.text).size(e.size||[500,500]).padding(e.padding||1).spiral(e.spiral||`archimedean`).rotate(e.rotate||0).font(e.font||`sans-serif`).fontStyle(e.fontStyle||`normal`).fontWeight(e.fontWeight||`normal`).fontSize(s).random(AS).layout(),u=a.size(),d=u[0]>>1,f=u[1]>>1,p=l.length;for(let e=0,t,n;eRV,resolvefilter:()=>zV});function GCe(){let e=8,t=[],n=HV(0),r=FV(0,e),i=FV(0,e);return{data:()=>t,seen:()=>n=KCe(n,t.length),add(e){for(let n=0,r=t.length,i=e.length,a;nt.length,curr:()=>r,prev:()=>i,reset:e=>i[e]=r[e],all:()=>e<257?255:e<65537?65535:4294967295,set(e,t){r[e]|=t},clear(e,t){r[e]&=~t},resize(t,n){(t>r.length||n>e)&&(e=Math.max(n,e),r=FV(t,e,r),i=FV(t,e))}}}function KCe(e,t,n){return e.length>=t?e:(n||=new e.constructor(t),n.set(e),n)}function FV(e,t,n){let r=(t<257?BV:t<65537?VV:HV)(e);return n&&r.set(n),r}function IV(e,t,n){let r=1<0)for(f=0;fe,size:()=>n}}function qCe(e,t){return e.sort.call(t,(t,n)=>{let r=e[t],i=e[n];return ri)}),coe(e,t)}function JCe(e,t,n,r,i,a,o,s,c){let l=0,u=0,d;for(d=0;l{r_(),Kx(),Ag(),BV=e=>new Uint8Array(e),VV=e=>new Uint16Array(e),HV=e=>new Uint32Array(e),RV.Definition={type:`CrossFilter`,metadata:{},params:[{name:`fields`,type:`field`,array:!0,required:!0},{name:`query`,type:`array`,array:!0,required:!0,content:{type:`number`,array:!0,length:2}}]},U(RV,G,{transform(e,t){return this._dims?e.modified(`fields`)||e.fields.some(e=>t.modified(e.fields))?this.reinit(e,t):this.eval(e,t):this.init(e,t)},init(e,t){let n=e.fields,r=e.query,i=this._indices={},a=this._dims=[],o=r.length,s=0,c,l;for(;s{let e=i.remove(t,n);for(let t in r)r[t].reindex(e)})},update(e,t,n){let r=this._dims,i=e.query,a=t.stamp,o=r.length,s=0,c,l;for(n.filters=0,l=0;lp)for(g=p,_=Math.min(d,m);g<_;++g)v=c[g],a[v]!==n&&(s[v]=o[v],a[v]=n,r.push(v)),o[v]^=h;if(f>m)for(g=Math.max(d,m),_=f;g<_;++g)v=c[g],a[v]!==n&&(s[v]=o[v],a[v]=n,r.push(v)),o[v]^=h;else if(fu)for(p=u,m=Math.min(c,d);pd)for(p=Math.max(c,d),m=l;ps[e]&n?null:o[e];return a.filter(a.MOD,l),i&i-1?(a.filter(a.ADD,e=>{let t=s[e]&n;return!t&&t^c[e]&n?o[e]:null}),a.filter(a.REM,e=>{let t=s[e]&n;return t&&!(t^(t^c[e]&n))?o[e]:null})):(a.filter(a.ADD,l),a.filter(a.REM,e=>(s[e]&n)===i?o[e]:null)),a.filter(a.SOURCE,e=>l(e._index))}})}));function UV(e){this.type=e}function XCe(e){switch(e.type){case OH:return e.elements;case kH:case MH:return[e.left,e.right];case AH:return[e.callee].concat(e.arguments);case jH:return[e.test,e.consequent,e.alternate];case NH:return[e.object,e.property];case PH:return e.properties;case EH:return[e.key,e.value];case FH:return[e.argument];case DH:case TH:case wH:default:return[]}}function WV(e,t){if(!e)throw Error(`ASSERT: `+t)}function GV(e){return e>=48&&e<=57}function KV(e){return`0123456789abcdefABCDEF`.includes(e)}function qV(e){return`01234567`.includes(e)}function ZCe(e){return e===32||e===9||e===11||e===12||e===160||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e)}function JV(e){return e===10||e===13||e===8232||e===8233}function YV(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e===92||e>=128&&vU.test(String.fromCharCode(e))}function XV(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===92||e>=128&&yU.test(String.fromCharCode(e))}function ZV(){for(;q1114111||e!==`}`)&&uH({},oU,gU),t<=65535?String.fromCharCode(t):(n=(t-65536>>10)+55296,r=(t-65536&1023)+56320,String.fromCharCode(n,r))}function $V(){var e=LH.charCodeAt(q++),t=String.fromCharCode(e);for(e===92&&(LH.charCodeAt(q)!==117&&uH({},oU,gU),++q,e=QV(`u`),(!e||e===`\\`||!YV(e.charCodeAt(0)))&&uH({},oU,gU),t=e);q>>=`)return q+=4,{type:KH,value:o,start:e,end:q};if(a=o.substr(0,3),a===`>>>`||a===`<<=`||a===`>>=`)return q+=3,{type:KH,value:a,start:e,end:q};if(i=a.substr(0,2),r===i[1]&&`+-<>&|`.includes(r)||i===`=>`)return q+=2,{type:KH,value:i,start:e,end:q};if(i===`//`&&uH({},oU,gU),`<>=!+-*%&|^/`.includes(r))return++q,{type:KH,value:r,start:e,end:q};uH({},oU,gU)}function twe(e){let t=``;for(;q{if(parseInt(t,16)<=1114111)return`x`;uH({},fU)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,`x`));try{new RegExp(n)}catch{uH({},fU)}try{return new RegExp(e,t)}catch{return null}}function awe(){var e=LH[q],t,n,r,i;for(WV(e===`/`,`Regular expression literal must start with a slash`),t=LH[q++],n=!1,r=!1;q=0&&uH({},fU,n),{value:n,literal:t}}function swe(){var e,t,n,r;return zH=null,ZV(),e=q,t=awe(),n=owe(),r=iwe(t.value,n.value),{literal:t.literal+n.literal,value:r,regex:{pattern:t.value,flags:n.value},start:e,end:q}}function cwe(e){return e.type===HH||e.type===UH||e.type===BH||e.type===WH}function nH(){if(ZV(),q>=RH)return{type:VH,start:q,end:q};let e=LH.charCodeAt(q);return YV(e)?ewe():e===40||e===41||e===59?eH():e===39||e===34?rwe():e===46?GV(LH.charCodeAt(q+1))?tH():eH():GV(e)?tH():eH()}function rH(){let e=zH;return q=e.end,zH=nH(),q=e.end,e}function iH(){let e=q;zH=nH(),q=e}function lwe(e){let t=new UV(YH);return t.elements=e,t}function aH(e,t,n){let r=new UV(e===`||`||e===`&&`?tU:XH);return r.operator=e,r.left=t,r.right=n,r}function uwe(e,t){let n=new UV(ZH);return n.callee=e,n.arguments=t,n}function dwe(e,t,n){let r=new UV(QH);return r.test=e,r.consequent=t,r.alternate=n,r}function oH(e){let t=new UV($H);return t.name=e,t}function sH(e){let t=new UV(eU);return t.value=e.value,t.raw=LH.slice(e.start,e.end),e.regex&&(t.raw===`//`&&(t.raw=`/(?:)/`),t.regex=e.regex),t}function cH(e,t,n){let r=new UV(nU);return r.computed=e===`[`,r.object=t,r.property=n,r.computed||(n.member=!0),r}function fwe(e){let t=new UV(rU);return t.properties=e,t}function lH(e,t,n){let r=new UV(iU);return r.key=t,r.value=n,r.kind=e,r}function pwe(e,t){let n=new UV(aU);return n.operator=e,n.argument=t,n.prefix=!0,n}function uH(e,t){var n,r=Array.prototype.slice.call(arguments,2),i=t.replace(/%(\d)/g,(e,t)=>(WV(t`:case`<=`:case`>=`:case`instanceof`:case`in`:t=7;break;case`<<`:case`>>`:case`>>>`:t=8;break;case`+`:case`-`:t=9;break;case`*`:case`/`:case`%`:t=11;break}return t}function wwe(){var e=zH,t,n,r,i,a,o,s,c=_H(),l;if(r=zH,i=vH(r),i===0)return c;for(r.prec=i,rH(),t=[e,zH],o=_H(),a=[c,r,o];(i=vH(zH))>0;){for(;a.length>2&&i<=a[a.length-2].prec;)o=a.pop(),s=a.pop().value,c=a.pop(),t.pop(),n=aH(s,c,o),a.push(n);r=rH(),r.prec=i,a.push(r),t.push(zH),n=_H(),a.push(n)}for(l=a.length-1,n=a[l],t.pop();l>1;)t.pop(),n=aH(a[l-1].value,a[l-2],n),l-=2;return n}function yH(){var e=wwe(),t,n;return pH(`?`)&&(rH(),t=yH(),fH(`:`),n=yH(),e=dwe(e,t,n)),e}function bH(){let e=yH();if(pH(`,`))throw Error(_U);return e}function xH(e){LH=e,q=0,RH=LH.length,zH=null,iH();let t=bH();if(zH.type!==VH)throw Error(`Unexpect token after expression.`);return t}function SH(e){function t(t,n,r,i){let a=e(n[0]);return r&&(a=r+`(`+a+`)`,r.lastIndexOf(`new `,0)===0&&(a=`(`+a+`)`)),a+`.`+t+(i<0?``:i===0?`()`:`(`+n.slice(1).map(e).join(`,`)+`)`)}function n(e,n,r){return i=>t(e,i,n,r)}let r=`new Date`,i=`String`,a=`RegExp`;return{isNaN:`Number.isNaN`,isFinite:`Number.isFinite`,abs:`Math.abs`,acos:`Math.acos`,asin:`Math.asin`,atan:`Math.atan`,atan2:`Math.atan2`,ceil:`Math.ceil`,cos:`Math.cos`,exp:`Math.exp`,floor:`Math.floor`,hypot:`Math.hypot`,log:`Math.log`,max:`Math.max`,min:`Math.min`,pow:`Math.pow`,random:`Math.random`,round:`Math.round`,sin:`Math.sin`,sqrt:`Math.sqrt`,tan:`Math.tan`,clamp:function(t){t.length<3&&V(`Missing arguments to clamp function.`),t.length>3&&V(`Too many arguments to clamp function.`);let n=t.map(e);return`Math.max(`+n[1]+`, Math.min(`+n[2]+`,`+n[0]+`))`},now:`Date.now`,utc:`Date.UTC`,datetime:r,date:n(`getDate`,r,0),day:n(`getDay`,r,0),year:n(`getFullYear`,r,0),month:n(`getMonth`,r,0),hours:n(`getHours`,r,0),minutes:n(`getMinutes`,r,0),seconds:n(`getSeconds`,r,0),milliseconds:n(`getMilliseconds`,r,0),time:n(`getTime`,r,0),timezoneoffset:n(`getTimezoneOffset`,r,0),utcdate:n(`getUTCDate`,r,0),utcday:n(`getUTCDay`,r,0),utcyear:n(`getUTCFullYear`,r,0),utcmonth:n(`getUTCMonth`,r,0),utchours:n(`getUTCHours`,r,0),utcminutes:n(`getUTCMinutes`,r,0),utcseconds:n(`getUTCSeconds`,r,0),utcmilliseconds:n(`getUTCMilliseconds`,r,0),length:n(`length`,null,-1),parseFloat:`parseFloat`,parseInt:`parseInt`,upper:n(`toUpperCase`,i,0),lower:n(`toLowerCase`,i,0),substring:n(`substring`,i),split:n(`split`,i),trim:n(`trim`,i,0),btoa:`btoa`,atob:`atob`,encodeURIComponent:`encodeURIComponent`,regexp:a,test:n(`test`,a),if:function(t){t.length<3&&V(`Missing arguments to if function.`),t.length>3&&V(`Too many arguments to if function.`);let n=t.map(e);return`(`+n[0]+`?`+n[1]+`:`+n[2]+`)`}}}function Twe(e){let t=e&&e.length-1;return t&&(e[0]===`"`&&e[t]===`"`||e[0]===`'`&&e[t]===`'`)?e.slice(1,-1):e}function CH(e){e||={};let t=e.allowed?Og(e.allowed):{},n=e.forbidden?Og(e.forbidden):{},r=e.constants||SU,i=(e.functions||SH)(d),a=e.globalvar,o=e.fieldvar,s=ig(a)?a:e=>`${a}["${e}"]`,c={},l={},u=0;function d(e){if(xg(e))return e;let t=f[e.type];return t??V(`Unsupported type: `+e.type),t(e)}let f={Literal:e=>e.raw,Identifier:e=>{let i=e.name;return u>0?i:fg(n,i)?V(`Illegal identifier: `+i):fg(r,i)?r[i]:fg(t,i)?i:(c[i]=1,s(i))},MemberExpression:e=>{let t=!e.computed,n=d(e.object);t&&(u+=1);let r=d(e.property);return n===o&&(l[Twe(r)]=1),t&&--u,n+(t?`.`+r:`[`+r+`]`)},CallExpression:e=>{e.callee.type!==`Identifier`&&V(`Illegal callee type: `+e.callee.type);let t=e.callee.name,n=e.arguments,r=fg(i,t)&&i[t];return r||V(`Unrecognized function: `+t),ig(r)?r(n):r+`(`+n.map(d).join(`,`)+`)`},ArrayExpression:e=>`[`+e.elements.map(d).join(`,`)+`]`,BinaryExpression:e=>`(`+d(e.left)+` `+e.operator+` `+d(e.right)+`)`,UnaryExpression:e=>`(`+e.operator+d(e.argument)+`)`,ConditionalExpression:e=>`(`+d(e.test)+`?`+d(e.consequent)+`:`+d(e.alternate)+`)`,LogicalExpression:e=>`(`+d(e.left)+e.operator+d(e.right)+`)`,ObjectExpression:e=>{for(let t of e.properties){let e=t.key.name;wh.has(e)&&V(`Illegal property: `+e)}return`{`+e.properties.map(d).join(`,`)+`}`},Property:e=>{u+=1;let t=d(e.key);return--u,t+`:`+d(e.value)}};function p(e){let t={code:d(e),globals:Object.keys(c),fields:Object.keys(l)};return c={},l={},t}return p.functions=i,p.constants=r,p}var wH,TH,EH,DH,OH,kH,AH,jH,MH,NH,PH,FH,IH,LH,q,RH,zH,BH,VH,HH,UH,WH,GH,KH,qH,JH,YH,XH,ZH,QH,$H,eU,tU,nU,rU,iU,aU,oU,sU,cU,lU,uU,dU,fU,pU,mU,hU,gU,_U,vU,yU,bU,xU,SU,CU=o((()=>{Ag(),wH=`RawCode`,TH=`Literal`,EH=`Property`,DH=`Identifier`,OH=`ArrayExpression`,kH=`BinaryExpression`,AH=`CallExpression`,jH=`ConditionalExpression`,MH=`LogicalExpression`,NH=`MemberExpression`,PH=`ObjectExpression`,FH=`UnaryExpression`,UV.prototype.visit=function(e){let t,n,r;if(e(this))return 1;for(t=XCe(this),n=0,r=t.length;n`,IH[HH]=`Identifier`,IH[UH]=`Keyword`,IH[WH]=`Null`,IH[GH]=`Numeric`,IH[KH]=`Punctuator`,IH[qH]=`String`,IH[JH]=`RegularExpression`,YH=`ArrayExpression`,XH=`BinaryExpression`,ZH=`CallExpression`,QH=`ConditionalExpression`,$H=`Identifier`,eU=`Literal`,tU=`LogicalExpression`,nU=`MemberExpression`,rU=`ObjectExpression`,iU=`Property`,aU=`UnaryExpression`,oU=`Unexpected token %0`,sU=`Unexpected number`,cU=`Unexpected string`,lU=`Unexpected identifier`,uU=`Unexpected reserved word`,dU=`Unexpected end of input`,fU=`Invalid regular expression`,pU=`Invalid regular expression: missing /`,mU=`Octal literals are not allowed in strict mode.`,hU=`Duplicate data property in object literal not allowed in strict mode`,gU=`ILLEGAL`,_U=`Disabled.`,vU=RegExp(`[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]`),yU=RegExp(`[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]`),bU={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1},xU={if:1},SU={NaN:`NaN`,E:`Math.E`,LN2:`Math.LN2`,LN10:`Math.LN10`,LOG2E:`Math.LOG2E`,LOG10E:`Math.LOG10E`,PI:`Math.PI`,SQRT1_2:`Math.SQRT1_2`,SQRT2:`Math.SQRT2`,MIN_VALUE:`Number.MIN_VALUE`,MAX_VALUE:`Number.MAX_VALUE`}}));function wU(e){return(!e.getter||!e.getter[DU])&&(e.getter=gh(e.field),e.getter[DU]=!0),e.getter}function TU(e,t){for(var n=t.fields,r=t.values,i=n.length,a=0,o,s;a=r[a])return!1}else if(s.type===HU){if(o>r[a])return!1}else if(s.type===UU){if(o<=r[a])return!1}else if(s.type===WU){if(oug(t.fields?{values:t.fields.map(t=>wU(t)(e.datum))}:{[PU]:FU(e.datum)},t))}function kwe(e,t,n,r){for(var i=this.context.data[e],a=i?i.values.value:[],o={},s={},c={},l,u,d,f,p,m,h,g,_,v,y=a.length,b=0,x,S;b(e[u[n].field]=t,e),{})))}else p=PU,m=FU(l),h=o[p]||(o[p]={}),g=h[f]||(h[f]=[]),g.push(m),n&&(g=s[f]||(s[f]=[]),g.push({[PU]:m}));if(t||=kU,o[PU]?o[PU]=ZU[`${PU}_${t}`](...Object.values(o[PU])):Object.keys(o).forEach(e=>{o[e]=Object.keys(o[e]).map(t=>o[e][t]).reduce((n,r)=>n===void 0?r:ZU[`${c[e]}_${t}`](n,r))}),a=Object.keys(s),n&&a.length){let e=r?jU:AU;o[e]=t===kU?{[MU]:a.reduce((e,t)=>(e.push(...s[t]),e),[])}:{[NU]:a.map(e=>({[MU]:s[e]}))}}return o}function EU(e,t,n,r){t[0].type!==`Literal`&&V(`First argument to selection functions must be a string literal.`);let i=t[0].value,a=t.length>=2&&Mh(t).value,o=`@unit`,s=QU+i;a===OU&&!fg(r,o)&&(r[o]=n.getData(i).indataRef(n,`unit`)),fg(r,s)||(r[s]=n.getData(i).tuplesRef())}var DU,OU,kU,AU,jU,MU,NU,PU,FU,IU,LU,RU,zU,BU,VU,HU,UU,WU,GU,KU,qU,JU,YU,XU,ZU,QU,Awe=o((()=>{r_(),Ag(),CU(),DU=Symbol(`vega_selection_getter`),OU=`intersect`,kU=`union`,AU=`vlMulti`,jU=`vlPoint`,MU=`or`,NU=`and`,PU=`_vgsid_`,FU=gh(PU),IU=`E`,LU=`R`,RU=`R-E`,zU=`R-LE`,BU=`R-RE`,VU=`E-LT`,HU=`E-LTE`,UU=`E-GT`,WU=`E-GTE`,GU=`E-VALID`,KU=`E-ONE`,qU=`index:unit`,JU=zg(FU),YU=JU.left,XU=JU.right,ZU={[`${PU}_union`]:Ioe,[`${PU}_intersect`]:Noe,E_union:function(e,t){if(!e.length)return t;for(var n=0,r=t.length;nt.includes(e)):t},R_union:function(e,t){var n=Ph(t[0]),r=Ph(t[1]);return n>r&&(n=t[1],r=t[0]),e.length?(e[0]>n&&(e[0]=n),e[1]r&&(n=t[1],r=t[0]),e.length?rr&&(e[1]=r),e):[n,r]}},QU=`:`}));function $U(e){let t=this.context.data[e];return t?t.values.value:[]}function jwe(e,t,n){let r=this.context.data[e][`index:`+t],i=r?r.value.get(n):void 0;return i&&i.count}function Mwe(e,t){let n=this.context.dataflow,r=this.context.data[e].input;return n.pulse(r,n.changeset().remove(Sh).insert(t)),1}function Nwe(e,t,n){if(e){let n=this.context.dataflow,r=e.mark.source;n.pulse(r,n.changeset().encode(e,t))}return n===void 0?e:n}function eW(e,t,n){return!Number.isInteger(e)||!Number.isInteger(t)?``:(wW.setYear(2e3),wW.setMonth(e),wW.setDate(t),bW.call(this,wW,n))}function Pwe(e){return eW.call(this,e,1,`%B`)}function Fwe(e){return eW.call(this,e,1,`%b`)}function Iwe(e){return eW.call(this,0,2+e,`%A`)}function Lwe(e){return eW.call(this,0,2+e,`%a`)}function tW(e,t,n,r){t[0].type!==`Literal`&&V(`First argument to data functions must be a string literal.`);let i=t[0].value,a=`:`+i;if(!fg(a,r))try{r[a]=n.getData(i).tuplesRef()}catch{}}function Rwe(e,t,n,r){t[0].type!==`Literal`&&V(`First argument to indata must be a string literal.`),t[1].type!==`Literal`&&V(`Second argument to indata must be a string literal.`);let i=t[0].value,a=t[1].value,o=`@`+a;fg(o,r)||(r[o]=n.getData(i).indataRef(n,a))}function nW(e,t,n,r){if(t[0].type===`Literal`)rW(n,r,t[0].value);else for(e in n.scales)rW(n,r,e)}function rW(e,t,n){let r=`%`+n;if(!fg(t,r))try{t[r]=e.scaleRef(n)}catch{}}function iW(e,t){if(xg(e)){let n=t.scales[e];return n&&lpe(n.value)?n.value:void 0}else if(ig(e))return lpe(e)?e:void 0}function zwe(e,t,n){t.__bandwidth=e=>e&&e.bandwidth?e.bandwidth():0,n._bandwidth=nW,n._range=nW,n._scale=nW;let r=t=>`_[`+(t.type===`Literal`?W(`%`+t.value):W(`%`)+`+`+e(t))+`]`;return{_bandwidth:e=>`this.__bandwidth(${r(e[0])})`,_range:e=>`${r(e[0])}.range()`,_scale:t=>`${r(t[0])}(${e(t[1])})`}}function aW(e,t){return function(n,r,i){if(n){let t=iW(n,(i||this).context);return t&&t.path[e](r)}else return t(r)}}function Bwe(e,t){let n=iW(e,(t||this).context);return n&&n.scale()}function Vwe(e){let t=this.context.group,n=!1;if(t)for(;e;){if(e===t){n=!0;break}e=e.mark.group}return n}function oW(e,t,n){try{e[t].apply(e,[`EXPRESSION`].concat([].slice.call(n)))}catch(t){e.warn(t)}return n[n.length-1]}function Hwe(){return oW(this.context.dataflow,`warn`,arguments)}function Uwe(){return oW(this.context.dataflow,`info`,arguments)}function Wwe(){return oW(this.context.dataflow,`debug`,arguments)}function sW(e){let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function cW(e){let t=WT(e),n=sW(t.r),r=sW(t.g),i=sW(t.b);return .2126*n+.7152*r+.0722*i}function Gwe(e,t){let n=cW(e),r=cW(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function Kwe(){let e=[].slice.call(arguments);return e.unshift({}),ug(...e)}function lW(e,t){return e===t||e!==e&&t!==t?!0:H(e)?H(t)&&e.length===t.length?qwe(e,t):!1:Dh(e)&&Dh(t)?uW(e,t):!1}function qwe(e,t){for(let n=0,r=e.length;nuW(e,t)}function Jwe(e,t,n,r,i,a){let o=this.context.dataflow,s=this.context.data[e],c=s.input,l=o.stamp(),u=s.changes,d,f;if(o._trigger===!1||!(c.value.length||t||r))return 0;if((!u||u.stamp{s.modified=!0,o.pulse(c,u).run()},!0,1)),n&&(d=n===!0?Sh:H(n)||Zb(n)?n:dW(n),u.remove(d)),t&&u.insert(t),r&&(d=dW(r),c.value.some(d)?u.remove(d):u.insert(r)),i){if(ig(i))throw Error(`modify parameter must be a data tuple, not a function`);for(f in a)u.modify(i,f,a[f])}return 1}function Ywe(e){let t=e.touches,n=t[0].clientX-t[1].clientX,r=t[0].clientY-t[1].clientY;return Math.hypot(n,r)}function Xwe(e){let t=e.touches;return Math.atan2(t[0].clientY-t[1].clientY,t[0].clientX-t[1].clientX)}function Zwe(e,t){let n=OW[t]||(OW[t]=gh(t));return H(e)?e.map(n):n(e)}function fW(e){return H(e)||ArrayBuffer.isView(e)?e:null}function pW(e){return fW(e)||(xg(e)?e:null)}function Qwe(e,...t){return fW(e).join(...t)}function $we(e,...t){return pW(e).indexOf(...t)}function eTe(e,...t){return pW(e).lastIndexOf(...t)}function tTe(e,...t){return pW(e).slice(...t)}function nTe(e,t,n){return ig(n)&&V(`Function argument passed to replace.`),!xg(t)&&!bg(t)&&V(`Please pass a string or RegExp argument to replace.`),String(e).replace(t,n)}function rTe(e){return fW(e).slice().reverse()}function iTe(e){return fW(e).slice().sort(sg)}function aTe(e,t,n){return HD(e||0,t||0,n||0)}function oTe(e,t){let n=iW(e,(t||this).context);return n&&n.bandwidth?n.bandwidth():0}function sTe(e,t){let n=iW(e,(t||this).context);return n?n.copy():void 0}function cTe(e,t){let n=iW(e,(t||this).context);return n?n.domain():[]}function lTe(e,t,n){let r=iW(e,(n||this).context);return r?H(t)?(r.invertRange||r.invert)(t):(r.invert||r.invertExtent)(t):void 0}function uTe(e,t){let n=iW(e,(t||this).context);return n&&n.range?n.range():[]}function dTe(e,t,n){let r=iW(e,(n||this).context);return r?r(t):void 0}function fTe(e,t,n,r,i){e=iW(e,(i||this).context);let a=Qpe(t,n),o=e.domain(),s=o[0],c=Mh(o),l=yh;return c-s?l=_pe(e,s,c):e=(e.interpolator?WD(`sequential`)().interpolator(e.interpolator()):WD(`linear`)().interpolate(e.interpolate()).range(e.range())).domain([s=0,c=1]),e.ticks&&(o=e.ticks(+r||15),s!==o[0]&&o.unshift(s),c!==Mh(o)&&o.push(c)),o.forEach(t=>a.stop(l(t),e(t))),a}function pTe(e,t,n){let r=iW(e,(n||this).context);return function(e){return r?r.path.context(e)(t):``}}function mTe(e){let t=null;return function(n){return n?EO(n,t||=TO(e)):e}}function mW(e,t){let n=$U.call(t,e);return n.root&&n.root.lookup||{}}function hTe(e,t,n){let r=mW(e,this),i=r[t],a=r[n];return i&&a?i.path(a).map(kW):void 0}function gTe(e,t){let n=mW(e,this)[t];return n?n.ancestors().map(kW):void 0}function _Te(){let e=AW();return e?e.screen:{}}function vTe(){let e=AW();return e?[e.innerWidth,e.innerHeight]:[void 0,void 0]}function yTe(){let e=this.context.dataflow,t=e.container&&e.container();return t?[t.clientWidth,t.clientHeight]:[void 0,void 0]}function hW(e,t,n){if(!e)return[];let[r,i]=e,a=new NO().set(r[0],r[1],i[0],i[1]);return rge(n||this.context.dataflow.scenegraph().root,a,bTe(t))}function bTe(e){let t=null;if(e){let n=ng(e.marktype),r=ng(e.markname);t=e=>(!n.length||n.some(t=>e.marktype===t))&&(!r.length||r.some(t=>e.name===t))}return t}function xTe(e,t,n,r=5){e=ng(e);let i=e[e.length-1];return i===void 0||Math.hypot(i[0]-t,i[1]-n)>r?[...e,[t,n]]:e}function STe(e){return ng(e).reduce((t,[n,r],i)=>t+=i==0?`M ${n},${r} `:i===e.length-1?` Z`:`L ${n},${r} `,``)}function CTe(e,t,n){let{x:r,y:i,mark:a}=n,o=new NO().set(2**53-1,2**53-1,-(2**53-1),-(2**53-1));for(let[e,n]of t)eo.x2&&(o.x2=e),no.y2&&(o.y2=n);return o.translate(r,i),hW([[o.x1,o.y1],[o.x2,o.y2]],e,a).filter(e=>wTe(e.x,e.y,t))}function wTe(e,t,n){let r=0;for(let i=0,a=n.length-1;it!=s>t&&e<(o-c)*(t-l)/(s-l)+c&&r++}return r&1}function TTe(e){let t=SH(e);MW.forEach(e=>t[e]=NW+e);for(let e in jW)t[e]=PW+e;return ug(t,zwe(e,jW,FW)),t}function gW(e,t,n){return arguments.length===1?jW[e]:(jW[e]=t,n&&(FW[e]=n),LW&&(LW.functions[e]=PW+e),this)}function _W(e,t){let n={},r;try{e=xg(e)?e:W(e)+``,r=xH(e)}catch{V(`Expression parse error: `+e)}r.visit(e=>{if(e.type!==`CallExpression`)return;let r=e.callee.name,i=IW.visitors[r];i&&i(r,e.arguments,t,n)});let i=LW(r);return i.globals.forEach(e=>{let r=`$`+e;!fg(n,r)&&t.getSignal(e)&&(n[r]=t.signalRef(e))}),{$expr:ug({code:i.code},t.options.ast?{ast:r}:null),$fields:i.fields,$params:n}}var vW,yW,bW,xW,SW,CW,wW,TW,EW,DW,OW,kW,AW,jW,MW,NW,PW,FW,IW,LW,RW=o((()=>{Ag(),CU(),xO(),AL(),YE(),Kx(),Pj(),Awe(),LS(),Ay(),r_(),vW=e=>function(t,n){let r=this.context.dataflow.locale();return t===null?`null`:r[e](n)(t)},yW=vW(`format`),bW=vW(`timeFormat`),xW=vW(`utcFormat`),SW=vW(`timeParse`),CW=vW(`utcParse`),wW=new Date(2e3,0,1),TW=aW(`area`,sve),EW=aW(`bounds`,dve),DW=aW(`centroid`,vve),OW={},kW=e=>e.data,AW=()=>typeof window<`u`&&window||null,jW={random(){return AS()},cumulativeNormal:nS,cumulativeLogNormal:cS,cumulativeUniform:mS,densityNormal:tS,densityLogNormal:sS,densityUniform:pS,quantileNormal:rS,quantileLogNormal:lS,quantileUniform:hS,sampleNormal:eS,sampleLogNormal:oS,sampleUniform:fS,isArray:H,isBoolean:_g,isDate:vg,isDefined(e){return e!==void 0},isNumber:yg,isObject:Dh,isRegExp:bg,isString:xg,isTuple:Zb,isValid(e){return e!=null&&e===e},toBoolean:Tg,toDate(e){return Eg(e)},toNumber:Ph,toString:Dg,indexof:$we,join:Qwe,lastindexof:eTe,replace:nTe,reverse:rTe,sort:iTe,slice:tTe,flush:Hie,lerp:eae,merge:Kwe,pad:lae,peek:Mh,pluck:Zwe,span:wg,inrange:gg,truncate:vae,rgb:WT,lab:SE,hcl:OE,hsl:$T,luminance:cW,contrast:Gwe,sequence:n_,format:yW,utcFormat:xW,utcParse:CW,utcOffset:zv,utcSequence:Hv,timeFormat:bW,timeParse:SW,timeOffset:Rv,timeSequence:Vv,timeUnitSpecifier:yv,monthFormat:Pwe,monthAbbrevFormat:Fwe,dayFormat:Iwe,dayAbbrevFormat:Lwe,quarter:eg,utcquarter:tg,week:Sv,utcweek:Dv,dayofyear:xv,utcdayofyear:Ev,warn:Hwe,info:Uwe,debug:Wwe,extent(e){return dg(e)},inScope:Vwe,intersect:hW,clampRange:Oie,pinchDistance:Ywe,pinchAngle:Xwe,screen:_Te,containerSize:yTe,windowSize:vTe,bandspace:aTe,setdata:Mwe,pathShape:mTe,panLinear:Rh,panLog:zh,panPow:Bh,panSymlog:Vh,zoomLinear:Uh,zoomLog:Wh,zoomPow:Gh,zoomSymlog:Kh,encode:Nwe,modify:Jwe,lassoAppend:xTe,lassoPath:STe,intersectLasso:CTe},MW=[`view`,`item`,`group`,`xy`,`x`,`y`],NW=`event.vega.`,PW=`this.`,FW={},IW={forbidden:[`_`],allowed:[`datum`,`event`,`item`],fieldvar:`datum`,globalvar:e=>`_[${W(`$`+e)}]`,functions:TTe,constants:SU,visitors:FW},LW=CH(IW),gW(`bandwidth`,oTe,nW),gW(`copy`,sTe,nW),gW(`domain`,cTe,nW),gW(`range`,uTe,nW),gW(`invert`,lTe,nW),gW(`scale`,dTe,nW),gW(`gradient`,fTe,nW),gW(`geoArea`,TW,nW),gW(`geoBounds`,EW,nW),gW(`geoCentroid`,DW,nW),gW(`geoShape`,pTe,nW),gW(`geoScale`,Bwe,nW),gW(`indata`,jwe,Rwe),gW(`data`,$U,tW),gW(`treePath`,hTe,tW),gW(`treeAncestors`,gTe,tW),gW(`vlSelectionTest`,Ewe,EU),gW(`vlSelectionIdTest`,Dwe,EU),gW(`vlSelectionResolve`,kwe,EU),gW(`vlSelectionTuples`,Owe)}));function ETe(e){let t=this,n=e.operators||[];return e.background&&(t.background=e.background),e.eventConfig&&(t.eventConfig=e.eventConfig),e.locale&&(t.locale=e.locale),n.forEach(e=>t.parseOperator(e)),n.forEach(e=>t.parseOperatorParameters(e)),(e.streams||[]).forEach(e=>t.parseStream(e)),(e.updates||[]).forEach(e=>t.parseUpdate(e)),t.resolve()}function DTe(e,t){let n=``;return GW[t]?n:(e.x2&&(e.x?(KW[t]&&(n+=`if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;`),n+=`o.width=o.x2-o.x;`):n+=`o.x=o.x2-(o.width||0);`),e.xc&&(n+=`o.x=o.xc-(o.width||0)/2;`),e.y2&&(e.y?(KW[t]&&(n+=`if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;`),n+=`o.height=o.y2-o.y;`):n+=`o.y=o.y2-(o.height||0);`),e.yc&&(n+=`o.y=o.yc-(o.height||0)/2;`),n)}function zW(e){return(e+``).toLowerCase()}function OTe(e){return zW(e)===`operator`}function kTe(e){return zW(e)===`collect`}function BW(e,t,n){n.endsWith(`;`)||(n=`return(`+n+`);`);let r=Function(...t.concat(n));return e&&e.functions?r.bind(e.functions):r}function ATe(e,t,n,r){return`((u = ${e}) < (v = ${t}) || u == null) && v != null ? ${n} : (u > v || v == null) && u != null ? ${r} : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${n} - : v !== v && u === u ? ${r} : `}function pTe(e){let t=this;uTe(e.type)||!e.type?t.operator(e,e.update?t.operatorExpression(e.update):null):t.transform(e,e.type)}function mTe(e){let t=this;if(e.params){let n=t.get(e.id);n||V(`Invalid operator id: `+e.id),t.dataflow.connect(n,n.parameters(t.parseParameters(e.params),e.react,e.initonly))}}function hTe(e,t){t||={};let n=this;for(let r in e){let i=e[r];t[r]=H(i)?i.map(e=>HW(e,n,t)):HW(i,n,t)}return t}function HW(e,t,n){if(!e||!gh(e))return e;for(let r=0,i=YW.length,a;re&&e.$tupleid?Kb:e);return t.fn[n]||(t.fn[n]=Xh(r,e.$order,t.expr.codegen))}function xTe(e,t){let n=e.$encode,r={};for(let e in n){let i=n[e];r[e]=Jm(t.encodeExpression(i.$expr),i.$fields),r[e].output=i.$output}return r}function STe(e,t){return t}function CTe(e,t){let n=e.$subflow;return function(e,r,i){let a=t.fork().parse(n),o=a.get(n.operators[0].id),s=a.signals.parent;return s&&s.set(i),o.detachSubflow=()=>t.detach(a),o}}function wTe(){return Kb}function TTe(e){var t=this,n=e.filter==null?void 0:t.eventExpression(e.filter),r=e.stream==null?void 0:t.get(e.stream),i;e.source?r=t.events(e.source,e.type,n):e.merge&&(i=e.merge.map(e=>t.get(e)),r=i[0].merge.apply(i[0],i.slice(1))),e.between&&(i=e.between.map(e=>t.get(e)),r=r.between(i[0],i[1])),e.filter&&(r=r.filter(n)),e.throttle!=null&&(r=r.throttle(+e.throttle)),e.debounce!=null&&(r=r.debounce(+e.debounce)),r??V(`Invalid stream definition: `+JSON.stringify(e)),e.consume&&r.consume(!0),t.stream(e,r)}function ETe(e){var t=this,n=gh(n=e.source)?n.$ref:n,r=t.get(n),i=null,a=e.update,o=void 0;r||V(`Source not defined: `+e.source),i=e.target&&e.target.$expr?t.eventExpression(e.target.$expr):t.get(e.target),a&&a.$expr&&(a.$params&&(o=t.parseParameters(a.$params)),a=t.handlerExpression(a.$expr)),t.update(e,r,i,a,o)}function DTe(e){var t=this,n={};if(e.signals){var r=n.signals={};Object.keys(t.signals).forEach(n=>{let i=t.signals[n];e.signals(n,i)&&(r[n]=i.value)})}if(e.data){var i=n.data={};Object.keys(t.data).forEach(n=>{let r=t.data[n];e.data(n,r)&&(i[n]=r.input.value)})}return t.subcontext&&e.recurse!==!1&&(n.subcontext=t.subcontext.map(t=>t.getState(e))),n}function OTe(e){var t=this,n=t.dataflow,r=e.data,i=e.signals;Object.keys(i||{}).forEach(e=>{n.update(t.signals[e],i[e],XW)}),Object.keys(r||{}).forEach(e=>{n.pulse(t.data[e].input,n.changeset().remove(dh).insert(r[e]))}),(e.subcontext||[]).forEach((e,n)=>{let r=t.subcontext[n];r&&r.setState(e)})}function UW(e,t,n,r){return new WW(e,t,n,r)}function WW(e,t,n,r){this.dataflow=e,this.transforms=t,this.events=e.events.bind(e),this.expr=r||JW,this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},n&&(this.functions=Object.create(n),this.functions.context=this)}function GW(e){this.dataflow=e.dataflow,this.transforms=e.transforms,this.events=e.events,this.expr=e.expr,this.signals=Object.create(e.signals),this.scales=Object.create(e.scales),this.nodes=Object.create(e.nodes),this.data=Object.create(e.data),this.fn=Object.create(e.fn),e.functions&&(this.functions=Object.create(e.functions),this.functions.context=this)}var KW,qW,JW,YW,XW,ZW=o((()=>{Tg(),Bx(),KW=Cg([`rule`]),qW=Cg([`group`,`image`,`rect`]),JW={operator:(e,t)=>VW(e,[`_`],t.code),parameter:(e,t)=>VW(e,[`datum`,`_`],t.code),event:(e,t)=>VW(e,[`event`],t.code),handler:(e,t)=>VW(e,[`_`,`event`],`var datum=event.item&&event.item.datum;return ${t.code};`),encode:(e,t)=>{let{marktype:n,channels:r}=t,i=`var o=item,datum=o.datum,m=0,$;`;for(let e in r){let t=`o[`+W(e)+`]`;i+=`$=${r[e].code};if(${t}!==$)${t}=$,m=1;`}return i+=lTe(r,n),i+=`return m;`,VW(e,[`item`,`_`],i)},codegen:{get(e){let t=`[${e.map(W).join(`][`)}]`,n=Function(`_`,`return _${t};`);return n.path=t,n},comparator(e,t){let n,r=Function(`a`,`b`,`var u, v; return `+e.map((e,r)=>{let i=t[r],a,o;return e.path?(a=`a${e.path}`,o=`b${e.path}`):((n||={})[`f`+r]=e,a=`this.f${r}(a)`,o=`this.f${r}(b)`),fTe(a,o,-i,i)}).join(``)+`0;`);return n?r.bind(n):r}}},YW=[{key:`$ref`,parse:gTe},{key:`$key`,parse:vTe},{key:`$expr`,parse:_Te},{key:`$field`,parse:yTe},{key:`$encode`,parse:xTe},{key:`$compare`,parse:bTe},{key:`$context`,parse:STe},{key:`$subflow`,parse:CTe},{key:`$tupleid`,parse:wTe}],XW={skip:!0},WW.prototype=GW.prototype={fork(){let e=new GW(this);return(this.subcontext||=[]).push(e),e},detach(e){this.subcontext=this.subcontext.filter(t=>t!==e);let t=Object.keys(e.nodes);for(let n of t)e.nodes[n]._targets=null;for(let n of t)e.nodes[n].detach();e.nodes=null},get(e){return this.nodes[e]},set(e,t){return this.nodes[e]=t},add(e,t){let n=this,r=n.dataflow,i=e.value;if(n.set(e.id,t),dTe(e.type)&&i&&(i.$ingest?r.ingest(t,i.$ingest,i.$format):i.$request?r.preload(t,i.$request,i.$format):r.pulse(t,r.changeset().insert(i))),e.root&&(n.root=t),e.parent){let i=n.get(e.parent.$ref);i?(r.connect(i,[t]),t.targets().add(i)):(n.unresolved=n.unresolved||[]).push(()=>{i=n.get(e.parent.$ref),r.connect(i,[t]),t.targets().add(i)})}if(e.signal&&(n.signals[e.signal]=t),e.scale&&(n.scales[e.scale]=t),e.data)for(let r in e.data){let i=n.data[r]||(n.data[r]={});e.data[r].forEach(e=>i[e]=t)}},resolve(){return(this.unresolved||[]).forEach(e=>e()),delete this.unresolved,this},operator(e,t){this.add(e,this.dataflow.add(e.value,t))},transform(e,t){this.add(e,this.dataflow.add(this.transforms[BW(t)]))},stream(e,t){this.set(e.id,t)},update(e,t,n,r,i){this.dataflow.on(t,n,r,i,e.options)},operatorExpression(e){return this.expr.operator(this,e)},parameterExpression(e){return this.expr.parameter(this,e)},eventExpression(e){return this.expr.event(this,e)},handlerExpression(e){return this.expr.handler(this,e)},encodeExpression(e){return this.expr.encode(this,e)},parse:cTe,parseOperator:pTe,parseOperatorParameters:mTe,parseParameters:hTe,parseStream:TTe,parseUpdate:ETe,getState:DTe,setState:OTe}}));function kTe(e){let t=e.container();t&&(t.setAttribute(`role`,`graphics-document`),t.setAttribute(`aria-roleDescription`,`visualization`),QW(t,e.description()))}function QW(e,t){e&&(t==null?e.removeAttribute(`aria-label`):e.setAttribute(`aria-label`,t))}function ATe(e){e.add(null,t=>(e._background=t.bg,e._resize=1,t.bg),{bg:e._signals.background})}function jTe(e){let t=e._signals.cursor||(e._signals.cursor=e.add({user:EG,item:null}));e.on(e.events(`view`,`pointermove`),t,(e,n)=>{let r=t.value,i=r?gg(r)?r:r.user:EG,a=n.item&&n.item.cursor||null;return r&&i===r.user&&a==r.item?r:{user:i,item:a}}),e.add(null,function(t){let n=t.cursor,r=this.value;return gg(n)||(r=n.item,n=n.user),$W(e,n&&n!==EG?n:r||n),r},{cursor:t})}function $W(e,t){let n=e.globalCursor()?typeof document<`u`&&document.body:e.container();if(n)return t==null?n.style.removeProperty(`cursor`):n.style.cursor=t}function eG(e,t){var n=e._runtime.data;return sg(n,t)||V(`Unrecognized data set: `+t),n[t]}function MTe(e,t){return arguments.length<2?eG(this,e).values.value:tG.call(this,e,ex().remove(dh).insert(t))}function tG(e,t){$b(t)||V(`Second argument to changes must be a changeset.`);let n=eG(this,e);return n.modified=!0,this.pulse(n.input,t)}function NTe(e,t){return tG.call(this,e,ex().insert(t))}function PTe(e,t){return tG.call(this,e,ex().remove(t))}function nG(e){var t=e.padding();return Math.max(0,e._viewWidth+t.left+t.right)}function rG(e){var t=e.padding();return Math.max(0,e._viewHeight+t.top+t.bottom)}function iG(e){var t=e.padding(),n=e._origin;return[t.left+n[0],t.top+n[1]]}function FTe(e){var t=iG(e),n=nG(e),r=rG(e);e._renderer.background(e.background()),e._renderer.resize(n,r,t),e._handler.origin(t),e._resizeListeners.forEach(t=>{try{t(n,r)}catch(t){e.error(t)}})}function ITe(e,t,n){var r=e._renderer,i=r&&r.canvas(),a,o,s;return i&&(s=iG(e),o=t.changedTouches?t.changedTouches[0]:t,a=Dk(o,i),a[0]-=s[0],a[1]-=s[1]),t.dataflow=e,t.item=n,t.vega=LTe(e,n,a),t}function LTe(e,t,n){let r=t?t.mark.marktype===`group`?t:t.mark.group:null;function i(e){var n=r,i;if(e){for(i=t;i;i=i.mark.group)if(i.mark.name===e){n=i;break}}return n&&n.mark&&n.mark.interactive?n:{}}function a(e){if(!e)return n;gg(e)&&(e=i(e));let t=n.slice();for(;e;)t[0]-=e.x||0,t[1]-=e.y||0,e=e.mark&&e.mark.group;return t}return{view:ng(e),item:ng(t||{}),group:i,xy:a,x:e=>a(e)[0],y:e=>a(e)[1]}}function RTe(e){let t=ig({defaults:{}},e),n=(e,t)=>{t.forEach(t=>{H(e[t])&&(e[t]=Cg(e[t]))})};return n(t.defaults,[`prevent`,`allow`]),n(t,[`view`,`window`,`selector`]),t}function aG(e,t,n,r){e._eventListeners.push({type:n,sources:Gh(t),handler:r})}function zTe(e,t){var n=e._eventConfig.defaults,r=n.prevent,i=n.allow;return r===!1||i===!0?!1:r===!0||i===!1?!0:r?r[t]:i?!i[t]:e.preventDefault()}function oG(e,t,n){let r=e._eventConfig&&e._eventConfig[t];return r===!1||gh(r)&&!r[n]?(e.warn(`Blocked ${t} ${n} event listener.`),!1):!0}function BTe(e,t,n){var r=this,i=new ix(n),a=function(n,a){r.runAsync(null,()=>{e===DG&&zTe(r,t)&&n.preventDefault(),i.receive(ITe(r,n,a))})},o;if(e===OG)oG(r,`timer`,t)&&r.timer(a,t);else if(e===DG)oG(r,`view`,t)&&r.addEventListener(t,a,AG);else if(e===kG?oG(r,`window`,t)&&typeof window<`u`&&(o=[window]):typeof document<`u`&&oG(r,`selector`,t)&&(o=Array.from(document.querySelectorAll(e))),!o)r.warn(`Can not resolve event source: `+e);else{for(var s=0,c=o.length;s=0;)t[i].stop();for(i=r.length;--i>=0;)for(o=r[i],a=o.sources.length;--a>=0;)o.sources[a].removeEventListener(o.type,o.handler);for(e&&e.call(this,this._handler,null,null,null),i=n.length;--i>=0;)c=n[i].type,s=n[i].handler,this._handler.off(c,s);return this}function uG(e,t,n){let r=document.createElement(e);for(let e in t)r.setAttribute(e,t[e]);return n!=null&&(r.textContent=n),r}function UTe(e,t,n){if(!t)return;let r=n.param,i=n.state;return i||(i=n.state={elements:null,active:!1,set:null,update:t=>{t!=e.signal(r.signal)&&e.runAsync(null,()=>{i.source=!0,e.signal(r.signal,t)})}},r.debounce&&(i.update=rg(r.debounce,i.update))),(r.input==null&&r.element?WTe:KTe)(i,t,r,e),i.active||(e.on(e._signals[r.signal],null,()=>{i.source?i.source=!1:i.set(e.signal(r.signal))}),i.active=!0),i}function WTe(e,t,n,r){let i=n.event||`input`,a=()=>e.update(t.value);r.signal(n.signal,t.value),t.addEventListener(i,a),aG(r,t,i,a),e.set=e=>{t.value=e,t.dispatchEvent(GTe(i))}}function GTe(e){return typeof Event<`u`?new Event(e):{type:e}}function KTe(e,t,n,r){let i=r.signal(n.signal),a=uG(`div`,{class:jG}),o=n.input===`radio`?a:a.appendChild(uG(`label`));o.appendChild(uG(`span`,{class:MG},n.name||n.signal)),t.appendChild(a);let s=qTe;switch(n.input){case`checkbox`:s=JTe;break;case`select`:s=YTe;break;case`radio`:s=XTe;break;case`range`:s=ZTe;break}s(e,o,n,i)}function qTe(e,t,n,r){let i=uG(`input`);for(let e in n)e!==`signal`&&e!==`element`&&i.setAttribute(e===`input`?`type`:e,n[e]);i.setAttribute(`name`,n.signal),i.value=r,t.appendChild(i),i.addEventListener(`input`,()=>e.update(i.value)),e.elements=[i],e.set=e=>i.value=e}function JTe(e,t,n,r){let i={type:`checkbox`,name:n.signal};r&&(i.checked=!0);let a=uG(`input`,i);t.appendChild(a),a.addEventListener(`change`,()=>e.update(a.checked)),e.elements=[a],e.set=e=>a.checked=!!e||null}function YTe(e,t,n,r){let i=uG(`select`,{name:n.signal}),a=n.labels||[];n.options.forEach((e,t)=>{let n={value:e};dG(e,r)&&(n.selected=!0),i.appendChild(uG(`option`,n,(a[t]||e)+``))}),t.appendChild(i),i.addEventListener(`change`,()=>{e.update(n.options[i.selectedIndex])}),e.elements=[i],e.set=e=>{for(let t=0,r=n.options.length;t{let s={type:`radio`,name:n.signal,value:t};dG(t,r)&&(s.checked=!0);let c=uG(`input`,s);c.addEventListener(`change`,()=>e.update(t));let l=uG(`label`,{},(a[o]||t)+``);return l.prepend(c),i.appendChild(l),c}),e.set=t=>{let n=e.elements,r=n.length;for(let e=0;e{c.textContent=s.value,e.update(+s.value)};s.addEventListener(`input`,l),s.addEventListener(`change`,l),e.elements=[s],e.set=e=>{s.value=e,c.textContent=e}}function dG(e,t){return e===t||e+``==t+``}function fG(e,t,n,r,i,a){return t||=new r(e.loader()),t.initialize(n,nG(e),rG(e),iG(e),i,a).background(e.background())}function pG(e,t){return t?function(){try{t.apply(this,arguments)}catch(t){e.error(t)}}:null}function QTe(e,t,n,r){let i=new r(e.loader(),pG(e,e.tooltip())).scene(e.scenegraph().root).initialize(n,iG(e),e);return t&&t.handlers().forEach(e=>{i.on(e.type,e.handler)}),i}function $Te(e,t){let n=this,r=n._renderType,i=n._eventConfig.bind,a=Pk(r);e=n._el=e?mG(n,e,!0):null,kTe(n),a||n.error(`Unrecognized renderer type: `+r);let o=a.handler||JA,s=e?a.renderer:a.headless;return n._renderer=s?fG(n,n._renderer,e,s):null,n._handler=QTe(n,n._handler,e,o),n._redraw=!0,e&&i!==`none`&&(t=t?n._elBind=mG(n,t,!0):e.appendChild(uG(`form`,{class:`vega-bindings`})),n._bind.forEach(e=>{e.param.element&&i!==`container`&&(e.element=mG(n,e.param.element,!!e.param.input))}),n._bind.forEach(e=>{UTe(n,e.element||t,e)})),n}function mG(e,t,n){if(typeof t==`string`)if(typeof document<`u`){if(t=document.querySelector(t),!t)return e.error(`Signal bind element not found: `+t),null}else return e.error(`DOM document instance not found.`),null;if(t&&n)try{t.textContent=``}catch(n){t=null,e.error(n)}return t}function hG(e){return gh(e)?{top:PG(e.top),bottom:PG(e.bottom),left:PG(e.left),right:PG(e.right)}:FG(PG(e))}async function gG(e,t,n,r){let i=Pk(t),a=i&&i.headless;return a||V(`Unrecognized renderer type: `+t),await e.runAsync(),fG(e,null,null,a,n,r).renderAsync(e._scenegraph.root)}async function eEe(e,t){e!==jj.Canvas&&e!==jj.SVG&&e!==jj.PNG&&V(`Unrecognized image type: `+e);let n=await gG(this,e,t);return e===jj.SVG?tEe(n.svg(),`image/svg+xml`):n.canvas().toDataURL(`image/png`)}function tEe(e,t){let n=new Blob([e],{type:t});return window.URL.createObjectURL(n)}async function nEe(e,t){return(await gG(this,jj.Canvas,e,t)).canvas()}async function rEe(e){return(await gG(this,jj.SVG,e)).svg()}function iEe(e,t,n){return UW(e,zx,MW,n).parse(t)}function aEe(e){var t=this._runtime.scales;return sg(t,e)||V(`Unrecognized scale or projection: `+e),t[e].value}function _G(e,t){var n=e.autosize(),r=e.padding();return t-(n&&n.contains===RG?r.left+r.right:0)}function vG(e,t){var n=e.autosize(),r=e.padding();return t-(n&&n.contains===RG?r.top+r.bottom:0)}function oEe(e){var t=e._signals,n=t[IG],r=t[LG],i=t[RG];function a(){e._autosize=e._resize=1}e._resizeWidth=e.add(null,t=>{e._width=t.size,e._viewWidth=_G(e,t.size),a()},{size:n}),e._resizeHeight=e.add(null,t=>{e._height=t.size,e._viewHeight=vG(e,t.size),a()},{size:r});let o=e.add(null,a,{pad:i});e._resizeWidth.rank=n.rank+1,e._resizeHeight.rank=r.rank+1,o.rank=i.rank+1}function sEe(e,t,n,r,i,a){this.runAfter(o=>{let s=0;o._autosize=0,o.width()!==n&&(s=1,o.signal(IG,n,zG),o._resizeWidth.skip(!0)),o.height()!==r&&(s=1,o.signal(LG,r,zG),o._resizeHeight.skip(!0)),o._viewWidth!==e&&(o._resize=1,o._viewWidth=e),o._viewHeight!==t&&(o._resize=1,o._viewHeight=t),(o._origin[0]!==i[0]||o._origin[1]!==i[1])&&(o._resize=1,o._origin=i),s&&o.run(`enter`),a&&o.runAfter(e=>e.resize())},!1,1)}function cEe(e){return this._runtime.getState(e||{data:lEe,signals:uEe,recurse:!0})}function lEe(e,t){return t.modified&&H(t.input.value)&&!e.startsWith(`_:vega:_`)}function uEe(e,t){return!(e===`parent`||t instanceof zx.proxy)}function dEe(e){return this.runAsync(null,t=>{t._trigger=!1,t._runtime.setState(e)},e=>{e._trigger=!0}),this}function fEe(e,t){function n(t){e({timestamp:Date.now(),elapsed:t})}this._timers.push(Fbe(n,t))}function pEe(e,t,n,r){let i=e.element();i&&i.setAttribute(`title`,mEe(r))}function mEe(e){return e==null?``:H(e)?yG(e):gh(e)&&!pg(e)?hEe(e):e+``}function hEe(e){return Object.keys(e).map(t=>{let n=e[t];return t+`: `+(H(n)?yG(n):bG(n))}).join(` -`)}function yG(e){return`[`+e.map(bG).join(`, `)+`]`}function bG(e){return H(e)?`[…]`:gh(e)&&!pg(e)?`{…}`:e}function gEe(){if(this.renderer()===`canvas`&&this._renderer._canvas){let e=null,t=()=>{e?.();let n=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);n.addEventListener(`change`,t),e=()=>{n.removeEventListener(`change`,t)},this._renderer._canvas.getContext(`2d`).pixelRatio=window.devicePixelRatio||1,this._redraw=!0,this._resize=1,this.resize().runAsync()};t()}}function xG(e,t){let n=this;if(t||={},px.call(n),t.loader&&n.loader(t.loader),t.logger&&n.logger(t.logger),t.logLevel!=null&&n.logLevel(t.logLevel),t.locale||e.locale){let r=ig({},e.locale,t.locale);n.locale(fb(r.number,r.time))}n._el=null,n._elBind=null,n._renderType=t.renderer||jj.Canvas,n._scenegraph=new EA;let r=n._scenegraph.root;n._renderer=null,n._tooltip=t.tooltip||pEe,n._redraw=!0,n._handler=new JA().scene(r),n._globalCursor=!1,n._preventDefault=!1,n._timers=[],n._eventListeners=[],n._resizeListeners=[],n._eventConfig=RTe(e.eventConfig),n.globalCursor(n._eventConfig.globalCursor);let i=iEe(n,e,t.expr);n._runtime=i,n._signals=i.signals,n._bind=(e.bindings||[]).map(e=>({state:null,param:ig({},e)})),i.root&&i.root.set(r),r.source=i.data.root.input,n.pulse(i.data.root.input,n.changeset().insert(r.items)),n._width=n.width(),n._height=n.height(),n._viewWidth=_G(n,n._width),n._viewHeight=vG(n,n._height),n._origin=[0,0],n._resize=0,n._autosize=1,oEe(n),ATe(n),jTe(n),n.description(e.description),t.hover&&n.hover(),t.container&&n.initialize(t.container,t.bind),t.watchPixelRatio&&n._watchPixelRatio()}function SG(e,t){return sg(e._signals,t)?e._signals[t]:V(`Unrecognized signal name: `+W(t))}function CG(e,t){let n=(e._targets||[]).filter(e=>e._update&&e._update.handler===t);return n.length?n[0]:null}function wG(e,t,n,r){let i=CG(n,r);return i||(i=pG(e,()=>r(t,n.value)),i.handler=r,e.on(n,null,i)),e}function TG(e,t,n){let r=CG(t,n);return r&&t._targets.remove(r),e}var EG,DG,OG,kG,AG,jG,MG,NG,PG,FG,IG,LG,RG,zG,_Ee=o((()=>{Tg(),Bx(),Fj(),Qg(),zW(),ZW(),$R(),_b(),EG=`default`,DG=`view`,OG=`timer`,kG=`window`,AG={trap:!1},jG=`vega-bind`,MG=`vega-bind-name`,NG=`vega-bind-radio`,PG=e=>+e||0,FG=e=>({top:e,bottom:e,left:e,right:e}),IG=`width`,LG=`height`,RG=`padding`,zG={skip:!0},U(xG,px,{async evaluate(e,t,n){if(await px.prototype.evaluate.call(this,e,t),this._redraw||this._resize)try{this._renderer&&(this._resize&&(this._resize=0,FTe(this)),await this._renderer.renderAsync(this._scenegraph.root)),this._redraw=!1}catch(e){this.error(e)}return n&&Wb(this,n),this},dirty(e){this._redraw=!0,this._renderer&&this._renderer.dirty(e)},description(e){if(arguments.length){let t=e==null?null:e+``;return t!==this._desc&&QW(this._el,this._desc=t),this}return this._desc},container(){return this._el},scenegraph(){return this._scenegraph},origin(){return this._origin.slice()},signal(e,t,n){let r=SG(this,e);return arguments.length===1?r.value:this.update(r,t,n)},width(e){return arguments.length?this.signal(`width`,e):this.signal(`width`)},height(e){return arguments.length?this.signal(`height`,e):this.signal(`height`)},padding(e){return arguments.length?this.signal(`padding`,hG(e)):hG(this.signal(`padding`))},autosize(e){return arguments.length?this.signal(`autosize`,e):this.signal(`autosize`)},background(e){return arguments.length?this.signal(`background`,e):this.signal(`background`)},renderer(e){return arguments.length?(Pk(e)||V(`Unrecognized renderer type: `+e),e!==this._renderType&&(this._renderType=e,this._resetRenderer()),this):this._renderType},tooltip(e){return arguments.length?(e!==this._tooltip&&(this._tooltip=e,this._resetRenderer()),this):this._tooltip},loader(e){return arguments.length?(e!==this._loader&&(px.prototype.loader.call(this,e),this._resetRenderer()),this):this._loader},resize(){return this._autosize=1,this.touch(SG(this,`autosize`))},_resetRenderer(){this._renderer&&(this._renderer=null,this.initialize(this._el,this._elBind))},_resizeView:sEe,addEventListener(e,t,n){let r=t;return n&&n.trap===!1||(r=pG(this,t),r.raw=t),this._handler.on(e,r),this},removeEventListener(e,t){for(var n=this._handler.handlers(e),r=n.length,i,a;--r>=0;)if(a=n[r].type,i=n[r].handler,e===a&&(t===i||t===i.raw)){this._handler.off(a,i);break}return this},addResizeListener(e){let t=this._resizeListeners;return t.includes(e)||t.push(e),this},removeResizeListener(e){var t=this._resizeListeners,n=t.indexOf(e);return n>=0&&t.splice(n,1),this},addSignalListener(e,t){return wG(this,e,SG(this,e),t)},removeSignalListener(e,t){return TG(this,SG(this,e),t)},addDataListener(e,t){return wG(this,e,eG(this,e).values,t)},removeDataListener(e,t){return TG(this,eG(this,e).values,t)},globalCursor(e){if(arguments.length){if(this._globalCursor!==!!e){let t=$W(this,null);this._globalCursor=!!e,t&&$W(this,t)}return this}else return this._globalCursor},preventDefault(e){return arguments.length?(this._preventDefault=e,this):this._preventDefault},timer:fEe,events:BTe,finalize:HTe,hover:VTe,data:MTe,change:tG,insert:NTe,remove:PTe,scale:aEe,initialize:$Te,toImageURL:eEe,toCanvas:nEe,toSVG:rEe,getState:cEe,setState:dEe,_watchPixelRatio:gEe})}));function BG(e,t,n){return tK=t||WG,nK=n||eK,HG(e.trim()).map(UG)}function vEe(e){return nK[e]}function VG(e,t,n,r,i){let a=e.length,o=0,s;for(;t' after between selector: `+e;r=r.map(UG);let i=UG(e.slice(1).trim());return i.between?{between:r,stream:i}:(i.between=r,i)}function bEe(e){let t={source:tK},n=[],r=[0,0],i=0,a=0,o=e.length,s=0,c,l;if(e[o-1]===JG){if(s=e.lastIndexOf(qG),s>=0){try{r=xEe(e.substring(s+1,o-1))}catch{throw`Invalid throttle specification: `+e}e=e.slice(0,s).trim(),o=e.length}else throw`Unmatched right brace: `+e;s=0}if(!o)throw e;if(e[0]===ZG&&(i=++s),c=VG(e,s,YG),c1?(t.type=n[1],i?t.markname=n[0].slice(1):vEe(n[0])?t.marktype=n[0]:t.source=n[0]):t.type=n[0],t.type.slice(-1)===`!`&&(t.consume=!0,t.type=t.type.slice(0,-1)),l!=null&&(t.filter=l),r[0]&&(t.throttle=r[0]),r[1]&&(t.debounce=r[1]),t}function xEe(e){let t=e.split(XG);if(!e.length||t.length>2)throw e;return t.map(t=>{let n=+t;if(n!==n)throw e;return n})}var WG,GG,KG,qG,JG,YG,XG,ZG,QG,$G,eK,tK,nK,rK=o((()=>{WG=`view`,GG=`[`,KG=`]`,qG=`{`,JG=`}`,YG=`:`,XG=`,`,ZG=`@`,QG=`>`,$G=/[[\]{}]/,eK={"*":1,arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1}}));function SEe(e){return gh(e)?e:{type:e||`pad`}}function CEe(e){return gh(e)?e.signal?e:{top:mq(e.top),bottom:mq(e.bottom),left:mq(e.left),right:mq(e.right)}:hq(mq(e))}function iK(e,t,n,r){return n==null?0:(gh(n)&&!H(n)||H(n)&&n.length&&gh(n[0])?e.update[t]=n:e[r||`enter`][t]={value:n},1)}function aK(e,t,n){for(let n in t)iK(e,n,t[n]);for(let t in n)iK(e,t,n[t],`update`)}function oK(e,t,n){for(let r in t)n&&sg(n,r)||(e[r]=ig(e[r]||{},t[r]));return e}function sK(e,t){return t&&(t.enter&&t.enter[e]||t.update&&t.update[e])}function wEe(e,t,n,r,i){let a={},o={},s,c,l,u;for(c in c=`lineBreak`,t===`text`&&i[c]!=null&&!sK(c,e)&&cK(a,c,i[c]),(n==`legend`||String(n).startsWith(`axis`))&&(n=null),u=n===`frame`?i.group:n===`mark`?ig({},i.mark,i[t]):null,u)l=sK(c,e)||(c===`fill`||c===`stroke`)&&(sK(`fill`,e)||sK(`stroke`,e)),l||cK(a,c,u[c]);for(c in Gh(r).forEach(t=>{let n=i.style&&i.style[t];for(let t in n)sK(t,e)||cK(a,t,n[t])}),e=ig({},e),a)u=a[c],u.signal?(s||={})[c]=u:o[c]=u;return e.enter=ig(o,e.enter),s&&(e.update=ig(s,e.update)),e}function cK(e,t,n){e[t]=n&&n.signal?{signal:n.signal}:{value:n}}function lK(e){if(e.gradient!=null)return EEe(e);let t=e.signal?`(${e.signal})`:e.color?TEe(e.color):e.field==null?e.value===void 0?void 0:W(e.value):dK(e.field);return e.scale!=null&&(t=DEe(e,t)),t===void 0&&(t=null),e.exponent!=null&&(t=`pow(${t},${uK(e.exponent)})`),e.mult!=null&&(t+=`*${uK(e.mult)}`),e.offset!=null&&(t+=`+${uK(e.offset)}`),e.round&&(t=`round(${t})`),t}function TEe(e){return e.c?Iq(`hcl`,e.h,e.c,e.l):e.h||e.s?Iq(`hsl`,e.h,e.s,e.l):e.l||e.a?Iq(`lab`,e.l,e.a,e.b):e.r||e.g||e.b?Iq(`rgb`,e.r,e.g,e.b):null}function EEe(e){let t=[e.start,e.stop,e.count].map(e=>e==null?null:W(e));for(;t.length&&xh(t)==null;)t.pop();return t.unshift(Fq(e.gradient)),`gradient(${t.join(`,`)})`}function uK(e){return gh(e)?`(`+lK(e)+`)`:e}function dK(e){return fK(gh(e)?e:{datum:e})}function fK(e){let t,n,r;if(e.signal)t=`datum`,r=e.signal;else if(e.group||e.parent){for(n=Math.max(1,e.level||1),t=`item`;n-->0;)t+=`.mark.group`;e.parent?(r=e.parent,t+=`.datum`):r=e.group}else e.datum?(t=`datum`,r=e.datum):V(`Invalid field reference: `+W(e));return e.signal||(r=gg(r)?rh(r).map(W).join(`][`):fK(r)),t+`[`+r+`]`}function DEe(e,t){let n=Fq(e.scale);return e.range==null?(t!==void 0&&(t=`_scale(${n}, ${t})`),e.band&&(t=(t?t+`+`:``)+`_bandwidth(${n})`+(+e.band==1?``:`*`+uK(e.band)),e.extra&&(t=`(datum.extra ? _scale(${n}, datum.extra.value) : ${t})`)),t??=`0`):t=`lerp(_range(${n}), ${+e.range})`,t}function OEe(e){let t=``;return e.forEach(e=>{let n=lK(e);t+=e.test?`(${e.test})?${n}:`:n}),xh(t)===`:`&&(t+=`null`),t}function pK(e,t,n,r,i,a){let o={};a||={},a.encoders={$encode:o},e=wEe(e,t,n,r,i.config);for(let n in e)o[n]=kEe(e[n],t,a,i);return a}function kEe(e,t,n,r){let i={},a={};for(let t in e)e[t]!=null&&(i[t]=jEe(AEe(e[t]),r,n,a));return{$expr:{marktype:t,channels:i},$fields:Object.keys(a),$output:Object.keys(e)}}function AEe(e){return H(e)?OEe(e):lK(e)}function jEe(e,t,n,r){let i=vW(e,t);return i.$fields.forEach(e=>r[e]=1),ig(n,i.$params),i.$expr}function mK(e,t){V(e+` for "outer" push: `+W(t))}function hK(e,t){let n=e.name;if(e.push===Lq)t.signals[n]||mK(`No prior signal definition`,n),Rq.forEach(t=>{e[t]!==void 0&&mK(`Invalid property `,t)});else{let r=t.addSignal(n,e.value);e.react===!1&&(r.react=!1),e.bind&&t.addBinding(n,e.bind)}}function gK(e,t,n,r){this.id=-1,this.type=e,this.value=t,this.params=n,r&&(this.parent=r)}function _K(e,t,n,r){return new gK(e,t,n,r)}function vK(e,t){return _K(`operator`,e,t)}function yK(e){let t={$ref:e.id};return e.id<0&&(e.refs=e.refs||[]).push(t),t}function bK(e,t){return t?{$field:e,$name:t}:{$field:e}}function xK(e,t){return{$compare:e,$order:t}}function MEe(e,t){let n={$key:e};return t&&(n.$flat=!0),n}function NEe(e){return gh(e)?(e.order===Vq?`-`:`+`)+SK(e.op,e.field):``}function SK(e,t){return(e&&e.signal?`$`+e.signal:e||``)+(e&&t?`_`:``)+(t&&t.signal?`$`+t.signal:t?.replace(/\W+/g,`_`).replace(/^_+|_+$/g,``)||``)}function CK(e){return e&&e.signal}function PEe(e){return e&&e.expr}function wK(e){if(CK(e))return!0;if(gh(e)){for(let t in e)if(wK(e[t]))return!0}return!1}function TK(e,t){return e??t}function EK(e){return e&&e.signal||e}function DK(e,t){return(e.merge?IEe:e.stream?LEe:e.type?REe:V(`Invalid stream specification: `+W(e)))(e,t)}function FEe(e){return e===Hq?Uq:e||Uq}function IEe(e,t){let n=OK({merge:e.merge.map(e=>DK(e,t))},e,t);return t.addStream(n).id}function LEe(e,t){let n=OK({stream:DK(e.stream,t)},e,t);return t.addStream(n).id}function REe(e,t){let n;e.type===Wq?(n=t.event(Wq,e.throttle),e={between:e.between,filter:e.filter}):n=t.event(FEe(e.source),e.type);let r=OK({stream:n},e,t);return Object.keys(r).length===1?n:t.addStream(r).id}function OK(e,t,n){let r=t.between;return r&&(r.length!==2&&V(`Stream "between" parameter must have 2 entries: `+W(t)),e.between=[DK(r[0],n),DK(r[1],n)]),r=t.filter?[].concat(t.filter):[],(t.marktype||t.markname||t.markrole)&&r.push(zEe(t.marktype,t.markname,t.markrole)),t.source===Hq&&r.push(`inScope(event.item)`),r.length&&(e.filter=vW(`(`+r.join(`)&&(`)+`)`,n).$expr),(r=t.throttle)!=null&&(e.throttle=+r),(r=t.debounce)!=null&&(e.debounce=+r),t.consume&&(e.consume=!0),e}function zEe(e,t,n){return`event.item`+(e&&e!==`*`?`&&event.item.mark.marktype==='`+e+`'`:``)+(n?`&&event.item.mark.role==='`+n+`'`:``)+(t?`&&event.item.mark.name==='`+t+`'`:``)}function BEe(e,t,n){let r=e.encode,i={target:n},a=e.events,o=e.update,s=[];a||V(`Signal update missing events specification.`),gg(a)&&(a=BG(a,t.isSubscope()?Hq:Uq)),a=Gh(a).filter(e=>e.signal||e.scale?(s.push(e),0):1),s.length>1&&(s=[HEe(s)]),a.length&&s.push(a.length>1?{merge:a}:a[0]),r!=null&&(o&&V(`Signal encode and update are mutually exclusive.`),o=`encode(item(),`+W(r)+`)`),i.update=gg(o)?vW(o,t):o.expr==null?o.value==null?o.signal==null?V(`Invalid signal update specification.`):{$expr:Gq,$params:{$value:t.signalRef(o.signal)}}:o.value:vW(o.expr,t),e.force&&(i.options={force:!0}),s.forEach(e=>t.addUpdate(ig(VEe(e,t),i)))}function VEe(e,t){return{source:e.signal?t.signalRef(e.signal):e.scale?t.scaleRef(e.scale):DK(e,t)}}function HEe(e){return{signal:`[`+e.map(e=>e.scale?`scale("`+e.scale+`")`:e.signal)+`]`}}function UEe(e,t){let n=t.getSignal(e.name),r=e.update;e.init&&(r?V(`Signals can not include both init and update expressions.`):(r=e.init,n.initonly=!0)),r&&(r=vW(r,t),n.update=r.$expr,n.params=r.$params),e.on&&e.on.forEach(e=>BEe(e,t,n.id))}function WEe(e,t){let n=e.type||`linear`;Jfe(n)||V(`Unrecognized scale type: `+W(n)),t.addScale(e.name,{type:n,domain:void 0})}function GEe(e,t){let n=t.getScale(e.name).params,r;for(r in n.domain=MK(e.domain,e,t),e.range!=null&&(n.range=PK(e,t,n)),e.interpolate!=null&&tDe(e.interpolate,n),e.nice!=null&&(n.nice=eDe(e.nice,t)),e.bins!=null&&(n.bins=$Ee(e.bins,t)),e)sg(n,r)||r===`name`||(n[r]=kK(e[r],t))}function kK(e,t){return gh(e)?e.signal?t.signalRef(e.signal):V(`Unsupported object: `+W(e)):e}function AK(e,t){return e.signal?t.signalRef(e.signal):e.map(e=>kK(e,t))}function jK(e){V(`Can not find data set: `+W(e))}function MK(e,t,n){if(!e){(t.domainMin!=null||t.domainMax!=null)&&V(`No scale domain defined for domainMin/domainMax to override.`);return}return e.signal?n.signalRef(e.signal):(H(e)?KEe:e.fields?JEe:qEe)(e,t,n)}function KEe(e,t,n){return e.map(e=>kK(e,n))}function qEe(e,t,n){let r=n.getData(e.data);return r||jK(e.data),qD(t.type)?r.valuesRef(n,e.field,NK(e.sort,!1)):Zfe(t.type)?r.domainRef(n,e.field):r.extentRef(n,e.field)}function JEe(e,t,n){let r=e.data,i=e.fields.reduce((e,t)=>(t=gg(t)?{data:r,field:t}:H(t)||t.signal?YEe(t,n):t,e.push(t),e),[]);return(qD(t.type)?XEe:Zfe(t.type)?ZEe:QEe)(e,n,i)}function YEe(e,t){let n=`_:vega:_`+xJ++,r=Xq({});if(H(e))r.value={$ingest:e};else if(e.signal){let i=`setdata(`+W(n)+`,`+e.signal+`)`;r.params.input=t.signalRef(i)}return t.addDataPipeline(n,[r,_J({})]),{data:n,field:`data`}}function XEe(e,t,n){let r=NK(e.sort,!0),i,a,o=n.map(e=>{let n=t.getData(e.data);return n||jK(e.data),n.countsRef(t,e.field,r)}),s={groupby:zq,pulse:o};r&&(i=r.op||`count`,a=r.field?SK(i,r.field):`count`,s.ops=[SJ[i]],s.fields=[t.fieldRef(a)],s.as=[a]),i=t.add(qq(s));let c=t.add(Xq({pulse:yK(i)}));return a=t.add(bJ({field:zq,sort:t.sortRef(r),pulse:yK(c)})),yK(a)}function NK(e,t){return e&&(!e.field&&!e.op?gh(e)?e.field=`key`:e={field:`key`}:!e.field&&e.op!==`count`?V(`No field provided for sort aggregate op: `+e.op):t&&e.field&&e.op&&!SJ[e.op]&&V(`Multiple domain scales can not be sorted using `+e.op)),e}function ZEe(e,t,n){let r=n.map(e=>{let n=t.getData(e.data);return n||jK(e.data),n.domainRef(t,e.field)});return yK(t.add(cJ({values:r})))}function QEe(e,t,n){let r=n.map(e=>{let n=t.getData(e.data);return n||jK(e.data),n.extentRef(t,e.field)});return yK(t.add(sJ({extents:r})))}function $Ee(e,t){return e.signal||H(e)?AK(e,t):t.objectProperty(e)}function eDe(e,t){return e.signal?t.signalRef(e.signal):gh(e)?{interval:kK(e.interval),step:kK(e.step)}:kK(e)}function tDe(e,t){t.interpolate=kK(e.type||e),e.gamma!=null&&(t.interpolateGamma=kK(e.gamma))}function PK(e,t,n){let r=t.config.range,i=e.range;if(i.signal)return t.signalRef(i.signal);if(gg(i)){if(r&&sg(r,i))return e=ig({},e,{range:r[i]}),PK(e,t,n);i===`width`?i=[0,{signal:`width`}]:i===`height`?i=qD(e.type)?[0,{signal:`height`}]:[{signal:`height`},0]:V(`Unrecognized scale range value: `+W(i))}else if(i.scheme){n.scheme=H(i.scheme)?AK(i.scheme,t):kK(i.scheme,t),i.extent&&(n.schemeExtent=AK(i.extent,t)),i.count&&(n.schemeCount=kK(i.count,t));return}else if(i.step){n.rangeStep=kK(i.step,t);return}else if(qD(e.type)&&!H(i))return MK(i,e,t);else H(i)||V(`Unsupported range type: `+W(i));return i.map(e=>(H(e)?AK:kK)(e,t))}function nDe(e,t){let n=t.config.projection||{},r={};for(let n in e)n!==`name`&&(r[n]=FK(e[n],n,t));for(let e in n)r[e]??(r[e]=FK(n[e],e,t));t.addProjection(e.name,r)}function FK(e,t,n){return H(e)?e.map(e=>FK(e,t,n)):gh(e)?e.signal?n.signalRef(e.signal):t===`fit`?e:V(`Unsupported parameter object: `+W(e)):e}function IK(e){return e.type=YJ,e.interactive=e.interactive||!1,e}function LK(e,t){let n=(n,r)=>TK(e[n],TK(t[n],r));return n.isVertical=n=>OJ===TK(e.direction,t.direction||(n?t.symbolDirection:t.gradientDirection)),n.gradientLength=()=>TK(e.gradientLength,t.gradientLength||t.gradientWidth),n.gradientThickness=()=>TK(e.gradientThickness,t.gradientThickness||t.gradientHeight),n.entryColumns=()=>TK(e.columns,TK(t.columns,+n.isVertical(!0))),n}function RK(e,t){let n=t&&(t.update&&t.update[e]||t.enter&&t.enter[e]);return n&&n.signal?n:n?n.value:null}function rDe(e,t,n){let r=t.config.style[n];return r&&r[e]}function zK(e,t,n){return`item.anchor === '${kJ}' ? ${e} : item.anchor === '${jJ}' ? ${t} : ${n}`}function iDe(e){let t=e(`tickBand`),n=e(`tickOffset`),r,i;return t?t.signal?(r={signal:`(${t.signal}) === 'extent' ? 1 : 0.5`},i={signal:`(${t.signal}) === 'extent'`},gh(n)||(n={signal:`(${t.signal}) === 'extent' ? 0 : ${n}`})):t===`extent`?(r=1,i=!0,n=0):(r=.5,i=!1):(r=e(`bandPosition`),i=e(`tickExtra`)),{extra:i,band:r,offset:n}}function BK(e,t){return t?e?gh(e)?Object.assign({},e,{offset:BK(e.offset,t)}):{value:e,offset:t}:t:e}function VK(e,t){return t?(e.name=t.name,e.style=t.style||e.style,e.interactive=!!t.interactive,e.encode=oK(e.encode,t,KJ)):e.interactive=!1,e}function aDe(e,t,n,r){let i=LK(e,n),a=i.isVertical(),o=i.gradientThickness(),s=i.gradientLength(),c,l,u,d,f;a?(l=[0,1],u=[0,0],d=o,f=s):(l=[0,0],u=[1,0],d=s,f=o);let p={enter:c={opacity:qJ,x:qJ,y:qJ,width:gq(d),height:gq(f)},update:ig({},c,{opacity:JJ,fill:{gradient:t,start:l,stop:u}}),exit:{opacity:qJ}};return aK(p,{stroke:i(`gradientStrokeColor`),strokeWidth:i(`gradientStrokeWidth`)},{opacity:i(`gradientOpacity`)}),VK({type:XJ,role:Oq,encode:p},r)}function oDe(e,t,n,r,i){let a=LK(e,n),o=a.isVertical(),s=a.gradientThickness(),c=a.gradientLength(),l,u,d,f,p=``;o?(l=`y`,d=`y2`,u=`x`,f=`width`,p=`1-`):(l=`x`,d=`x2`,u=`y`,f=`height`);let m={opacity:qJ,fill:{scale:t,field:IJ}};m[l]={signal:p+`datum.perc`,mult:c},m[u]=qJ,m[d]={signal:p+`datum.perc2`,mult:c},m[f]=gq(s);let h={enter:m,update:ig({},m,{opacity:JJ}),exit:{opacity:qJ}};return aK(h,{stroke:a(`gradientStrokeColor`),strokeWidth:a(`gradientStrokeWidth`)},{opacity:a(`gradientOpacity`)}),VK({type:XJ,role:Eq,key:IJ,from:i,encode:h},r)}function HK(e,t,n,r){let i=LK(e,t),a=i.isVertical(),o=gq(i.gradientThickness()),s=i.gradientLength(),c=i(`labelOverlap`),l,u,d,f,p=``,m={enter:l={opacity:qJ},update:u={opacity:JJ,text:{field:NJ}},exit:{opacity:qJ}};return aK(m,{fill:i(`labelColor`),fillOpacity:i(`labelOpacity`),font:i(`labelFont`),fontSize:i(`labelFontSize`),fontStyle:i(`labelFontStyle`),fontWeight:i(`labelFontWeight`),limit:TK(e.labelLimit,t.gradientLabelLimit)}),a?(l.align={value:`left`},l.baseline=u.baseline={signal:nY},d=`y`,f=`x`,p=`1-`):(l.align=u.align={signal:tY},l.baseline={value:`top`},d=`x`,f=`y`),l[d]=u[d]={signal:p+`datum.perc`,mult:s},l[f]=u[f]=o,o.offset=TK(e.labelOffset,t.gradientLabelOffset)||0,c=c?{separation:i(`labelSeparation`),method:c,order:`datum.index`}:void 0,VK({type:$J,role:kq,style:LJ,key:IJ,from:r,encode:m,overlap:c},n)}function sDe(e,t,n,r,i){let a=LK(e,t),o=n.entries,s=!!(o&&o.interactive),c=o?o.name:void 0,l=a(`clipHeight`),u=a(`symbolOffset`),d={data:`value`},f=`(${i}) ? datum.${PJ} : datum.${WJ}`,p=l?gq(l):{field:WJ},m=`datum.${MJ}`,h=`max(1, ${i})`,g,_,v,y,b;p.mult=.5,g={enter:_={opacity:qJ,x:{signal:f,mult:.5,offset:u},y:p},update:v={opacity:JJ,x:_.x,y:_.y},exit:{opacity:qJ}};let x=null,S=null;e.fill||(x=t.symbolBaseFillColor,S=t.symbolBaseStrokeColor),aK(g,{fill:a(`symbolFillColor`,x),shape:a(`symbolType`),size:a(`symbolSize`),stroke:a(`symbolStrokeColor`,S),strokeDash:a(`symbolDash`),strokeDashOffset:a(`symbolDashOffset`),strokeWidth:a(`symbolStrokeWidth`)},{opacity:a(`symbolOpacity`)}),GJ.forEach(t=>{e[t]&&(v[t]=_[t]={scale:e[t],field:IJ})});let C=VK({type:QJ,role:Aq,key:IJ,from:d,clip:l?!0:void 0,encode:g},n.symbols),w=gq(u);w.offset=a(`labelOffset`),g={enter:_={opacity:qJ,x:{signal:f,offset:w},y:p},update:v={opacity:JJ,text:{field:NJ},x:_.x,y:_.y},exit:{opacity:qJ}},aK(g,{align:a(`labelAlign`),baseline:a(`labelBaseline`),fill:a(`labelColor`),fillOpacity:a(`labelOpacity`),font:a(`labelFont`),fontSize:a(`labelFontSize`),fontStyle:a(`labelFontStyle`),fontWeight:a(`labelFontWeight`),limit:a(`labelLimit`)});let T=VK({type:$J,role:kq,style:LJ,key:IJ,from:d,encode:g},n.labels);return g={enter:{noBound:{value:!l},width:qJ,height:l?gq(l):qJ,opacity:qJ},exit:{opacity:qJ},update:v={opacity:JJ,row:{signal:null},column:{signal:null}}},a.isVertical(!0)?(y=`ceil(item.mark.items.length / ${h})`,v.row.signal=`${m}%${y}`,v.column.signal=`floor(${m} / ${y})`,b={field:[`row`,m]}):(v.row.signal=`floor(${m} / ${h})`,v.column.signal=`${m} % ${h}`,b={field:m}),v.column.signal=`(${i})?${v.column.signal}:${m}`,r={facet:{data:r,name:`value`,groupby:MJ}},IK({role:vq,from:r,encode:oK(g,o,KJ),marks:[C,T],name:c,interactive:s,sort:b})}function cDe(e,t){let n=LK(e,t);return{align:n(`gridAlign`),columns:n.entryColumns(),center:{row:!0,column:!1},padding:{row:n(`rowPadding`),column:n(`columnPadding`)}}}function lDe(e,t,n,r){let i=LK(e,t),a={enter:{opacity:qJ},update:{opacity:JJ,x:{field:{group:`padding`}},y:{field:{group:`padding`}}},exit:{opacity:qJ}};return aK(a,{orient:i(`titleOrient`),_anchor:i(`titleAnchor`),anchor:{signal:lY},angle:{signal:uY},align:{signal:cY},baseline:{signal:dY},text:e.title,fill:i(`titleColor`),fillOpacity:i(`titleOpacity`),font:i(`titleFont`),fontSize:i(`titleFontSize`),fontStyle:i(`titleFontStyle`),fontWeight:i(`titleFontWeight`),limit:i(`titleLimit`),lineHeight:i(`titleLineHeight`)},{align:i(`titleAlign`),baseline:i(`titleBaseline`)}),VK({type:$J,role:jq,style:RJ,from:r,encode:a},n)}function uDe(e,t){let n;return gh(e)&&(e.signal?n=e.signal:e.path?n=`pathShape(`+UK(e.path)+`)`:e.sphere&&(n=`geoShape(`+UK(e.sphere)+`, {type: "Sphere"})`)),n?t.signalRef(n):!!e}function UK(e){return gh(e)&&e.signal?e.signal:W(e)}function WK(e){let t=e.role||``;return t.startsWith(`axis`)||t.startsWith(`legend`)||t.startsWith(`title`)?t:e.type===YJ?vq:t||`mark`}function dDe(e){return{marktype:e.type,name:e.name||void 0,role:e.role||WK(e),zindex:+e.zindex||void 0,aria:e.aria,description:e.description}}function fDe(e,t){return e&&e.signal?t.signalRef(e.signal):e!==!1}function GK(e,t){let n=hx(e.type);n||V(`Unrecognized transform type: `+W(e.type));let r=_K(n.type.toLowerCase(),null,KK(n,e,t));return e.signal&&t.addSignal(e.signal,t.proxy(r)),r.metadata=n.metadata||{},r}function KK(e,t,n){let r={},i=e.params.length;for(let a=0;aqK(e,t,n)):qK(e,i,n)}function qK(e,t,n){let r=e.type;if(CK(t))return hY(r)?V(`Expression references can not be signals.`):gY(r)?n.fieldRef(t):_Y(r)?n.compareRef(t):n.signalRef(t.signal);{let i=e.expr||gY(r);return i&&fY(t)?n.exprRef(t.expr,t.as):i&&pY(t)?bK(t.field,t.as):hY(r)?vW(t,n):mY(r)?yK(n.getData(t).values):gY(r)?bK(t):_Y(r)?n.compareRef(t):t}}function mDe(e,t,n){return gg(t.from)||V(`Lookup "from" parameter must be a string literal.`),n.getData(t.from).lookupRef(n,t.key)}function hDe(e,t,n){let r=t[e.name];return e.array?(H(r)||V(`Expected an array of sub-parameters. Instead: `+W(r)),r.map(t=>JK(e,t,n))):JK(e,r,n)}function JK(e,t,n){let r=e.params.length,i;for(let n=0;ne??`null`).join(`,`)+`),0)`,t);c.update=l.$expr,c.params=l.$params}function tq(e,t){let n=WK(e),r=e.type===YJ,i=e.from&&e.from.facet,a=e.overlap,o=e.layout||n===`scope`||n===`frame`,s,c,l,u,d,f,p,m=n===`mark`||o||i,h=gDe(e.from,r,t);c=t.add(Qq({key:h.key||(e.key?bK(e.key):void 0),pulse:h.pulse,clean:!r}));let g=yK(c);c=l=t.add(Xq({pulse:g})),c=t.add(oJ({markdef:dDe(e),interactive:fDe(e.interactive,t),clip:uDe(e.clip,t),context:{$context:!0},groups:t.lookup(),parent:t.signals.parent?t.signalRef(`parent`):null,index:t.markpath(),pulse:yK(c)}));let _=yK(c);c=u=t.add($q(pK(e.encode,e.type,n,e.style,t,{mod:!1,pulse:_}))),c.params.parent=t.encode(),e.transform&&e.transform.forEach(e=>{let n=GK(e,t),r=n.metadata;(r.generates||r.changes)&&V(`Mark transforms should not generate new data.`),r.nomod||(u.params.mod=!0),n.params.pulse=yK(c),t.add(c=n)}),e.sort&&(c=t.add(vJ({sort:t.compareRef(e.sort),pulse:yK(c)})));let v=yK(c);(i||o)&&(o=t.add(yJ({layout:t.objectProperty(e.layout),legends:t.legends,mark:_,pulse:v})),f=yK(o));let y=t.add(Yq({mark:_,pulse:f||v}));p=yK(y),r&&(m&&(s=t.operators,s.pop(),o&&s.pop()),t.pushState(v,f||p,g),i?_De(e,t,h):m?vDe(e,t,h):t.parse(e),t.popState(),m&&(o&&s.push(o),s.push(y))),a&&(p=yDe(a,p,t));let b=t.add(hJ({pulse:p})),x=t.add(_J({pulse:yK(b)},void 0,t.parent()));e.name!=null&&(d=e.name,t.addData(d,new XK(t,l,b,x)),e.on&&e.on.forEach(e=>{(e.insert||e.remove||e.toggle)&&V(`Marks only support modify triggers.`),eq(e,t,d)}))}function yDe(e,t,n){let r=e.method,i=e.bound,a=e.separation,o={separation:CK(a)?n.signalRef(a.signal):a,method:CK(r)?n.signalRef(r.signal):r,pulse:t};if(e.order&&(o.sort=n.compareRef({field:e.order})),i){let e=i.tolerance;o.boundTolerance=CK(e)?n.signalRef(e.signal):+e,o.boundScale=n.scaleRef(i.scale),o.boundOrient=i.orient}return yK(n.add(lJ(o)))}function bDe(e,t){let n=t.config.legend,r=e.encode||{},i=LK(e,n),a=r.legend||{},o=a.name||void 0,s=a.interactive,c=a.style,l={},u=0,d,f,p;GJ.forEach(t=>e[t]?(l[t]=e[t],u||=e[t]):0),u||V(`Missing valid scale for legend.`);let m=xDe(e,t.scaleType(u)),h={title:e.title!=null,scales:l,type:m,vgrad:m!==`symbol`&&i.isVertical()},g=yK(t.add(Xq(null,[h]))),_={enter:{x:{value:0},y:{value:0}}},v=yK(t.add(iJ(f={type:m,scale:t.scaleRef(u),count:t.objectProperty(i(`tickCount`)),limit:t.property(i(`symbolLimit`)),values:t.objectProperty(e.values),minstep:t.property(e.tickMinStep),formatType:t.property(e.formatType),formatSpecifier:t.property(e.format)})));return m===HJ?(p=[aDe(e,u,n,r.gradient),HK(e,n,r.labels,v)],f.count=f.count||t.signalRef(`max(2,2*floor((${EK(i.gradientLength())})/100))`)):m===UJ?p=[oDe(e,u,n,r.gradient,v),HK(e,n,r.labels,v)]:(d=cDe(e,n),p=[sDe(e,n,r,v,EK(d.columns))],f.size=wDe(e,t,p[0].marks)),p=[IK({role:Dq,from:g,encode:_,marks:p,layout:d,interactive:s})],h.title&&p.push(lDe(e,n,r.title,g)),tq(IK({role:Tq,from:g,encode:oK(CDe(i,e,n),a,KJ),marks:p,aria:i(`aria`),description:i(`description`),zindex:i(`zindex`),name:o,interactive:s,style:c}),t)}function xDe(e,t){let n=e.type||VJ;return!e.type&&SDe(e)===1&&(e.fill||e.stroke)&&(n=KD(t)?HJ:JD(t)?UJ:VJ),n===HJ?JD(t)?UJ:HJ:n}function SDe(e){return GJ.reduce((t,n)=>t+ +!!e[n],0)}function CDe(e,t,n){let r={enter:{},update:{}};return aK(r,{orient:e(`orient`),offset:e(`offset`),padding:e(`padding`),titlePadding:e(`titlePadding`),cornerRadius:e(`cornerRadius`),fill:e(`fillColor`),stroke:e(`strokeColor`),strokeWidth:n.strokeWidth,strokeDash:n.strokeDash,x:e(`legendX`),y:e(`legendY`),format:t.format,formatType:t.formatType}),r}function wDe(e,t,n){return vW(`max(ceil(sqrt(${EK(nq(`size`,e,n))})+${EK(nq(`strokeWidth`,e,n))}),${EK(TDe(n[1].encode,t,LJ))})`,t)}function nq(e,t,n){return t[e]?`scale("${t[e]}",datum)`:RK(e,n[0].encode)}function TDe(e,t,n){return RK(`fontSize`,e)||rDe(`fontSize`,t,n)}function EDe(e,t){e=gg(e)?{text:e}:e;let n=LK(e,t.config.title),r=e.encode||{},i=r.group||{},a=i.name||void 0,o=i.interactive,s=i.style,c=[],l=yK(t.add(Xq(null,[{}])));return c.push(kDe(e,n,DDe(e),l)),e.subtitle&&c.push(ADe(e,n,r.subtitle,l)),tq(IK({role:Mq,from:l,encode:ODe(n,i),marks:c,aria:n(`aria`),description:n(`description`),zindex:n(`zindex`),name:a,interactive:o,style:s}),t)}function DDe(e){let t=e.encode;return t&&t.title||ig({name:e.name,interactive:e.interactive,style:e.style},t)}function ODe(e,t){let n={enter:{},update:{}};return aK(n,{orient:e(`orient`),anchor:e(`anchor`),align:{signal:eY},angle:{signal:vY},limit:e(`limit`),frame:e(`frame`),offset:e(`offset`)||0,padding:e(`subtitlePadding`)}),oK(n,t,KJ)}function kDe(e,t,n,r){let i={value:0},a=e.text,o={enter:{opacity:i},update:{opacity:{value:1}},exit:{opacity:i}};return aK(o,{text:a,align:{signal:`item.mark.group.align`},angle:{signal:`item.mark.group.angle`},limit:{signal:`item.mark.group.limit`},baseline:`top`,dx:t(`dx`),dy:t(`dy`),fill:t(`color`),font:t(`font`),fontSize:t(`fontSize`),fontStyle:t(`fontStyle`),fontWeight:t(`fontWeight`),lineHeight:t(`lineHeight`)},{align:t(`align`),angle:t(`angle`),baseline:t(`baseline`)}),VK({type:$J,role:Nq,style:zJ,from:r,encode:o},n)}function ADe(e,t,n,r){let i={value:0},a=e.subtitle,o={enter:{opacity:i},update:{opacity:{value:1}},exit:{opacity:i}};return aK(o,{text:a,align:{signal:`item.mark.group.align`},angle:{signal:`item.mark.group.angle`},limit:{signal:`item.mark.group.limit`},baseline:`top`,dx:t(`dx`),dy:t(`dy`),fill:t(`subtitleColor`),font:t(`subtitleFont`),fontSize:t(`subtitleFontSize`),fontStyle:t(`subtitleFontStyle`),fontWeight:t(`subtitleFontWeight`),lineHeight:t(`subtitleLineHeight`)},{align:t(`align`),angle:t(`angle`),baseline:t(`baseline`)}),VK({type:$J,role:Pq,style:BJ,from:r,encode:o},n)}function jDe(e,t){let n=[];e.transform&&e.transform.forEach(e=>{n.push(GK(e,t))}),e.on&&e.on.forEach(n=>{eq(n,t,e.name)}),t.addDataPipeline(e.name,MDe(e,t,n))}function MDe(e,t,n){let r=[],i=null,a=!1,o=!1,s,c,l,u,d;for(e.values?CK(e.values)||wK(e.format)?(r.push(iq(t,e)),r.push(i=rq())):r.push(i=rq({$ingest:e.values,$format:e.format})):e.url?wK(e.url)||wK(e.format)?(r.push(iq(t,e)),r.push(i=rq())):r.push(i=rq({$request:e.url,$format:e.format})):e.source&&(i=s=Gh(e.source).map(e=>yK(t.getData(e).output)),r.push(null)),c=0,l=n.length;ce==null?!sK(t,r):(n.update[t]=IY(gq(e),n.update[t]),!1),a=i(e(`titleX`),`x`),o=i(e(`titleY`),`y`);n.enter.auto=o===a?gq(o):xY(t,gq(o),gq(a))}function VDe(e,t){let n=NDe(e,t),r=e.encode||{},i=r.axis||{},a=i.name||void 0,o=i.interactive,s=i.style,c=LK(e,n),l=iDe(c),u={scale:e.scale,ticks:!!c(`ticks`),labels:!!c(`labels`),grid:!!c(`grid`),domain:!!c(`domain`),title:e.title!=null},d=yK(t.add(Xq({},[u]))),f=yK(t.add(Jq({scale:t.scaleRef(e.scale),extra:t.property(l.extra),count:t.objectProperty(e.tickCount),values:t.objectProperty(e.values),minstep:t.property(e.tickMinStep),formatType:t.property(e.formatType),formatSpecifier:t.property(e.format)}))),p=[],m;return u.grid&&p.push(FDe(e,n,r.grid,f,l)),u.ticks&&(m=c(`tickSize`),p.push(LDe(e,n,r.ticks,f,m,l))),u.labels&&(m=u.ticks?m:0,p.push(RDe(e,n,r.labels,f,m,l))),u.domain&&p.push(PDe(e,n,r.domain,d)),u.title&&p.push(zDe(e,n,r.title,d)),tq(IK({role:yq,from:d,encode:oK(HDe(c,e),i,KJ),marks:p,aria:c(`aria`),description:c(`description`),zindex:c(`zindex`),name:a,interactive:o,style:s}),t)}function HDe(e,t){let n={enter:{},update:{}};return aK(n,{orient:e(`orient`),offset:e(`offset`)||0,position:TK(t.position,0),titlePadding:e(`titlePadding`),minExtent:e(`minExtent`),maxExtent:e(`maxExtent`),range:{signal:`abs(span(range("${t.scale}")))`},translate:e(`translate`),format:t.format,formatType:t.formatType}),n}function lq(e,t,n){let r=Gh(e.signals),i=Gh(e.scales);return n||r.forEach(e=>hK(e,t)),Gh(e.projections).forEach(e=>nDe(e,t)),i.forEach(e=>WEe(e,t)),Gh(e.data).forEach(e=>jDe(e,t)),i.forEach(e=>GEe(e,t)),(n||r).forEach(e=>UEe(e,t)),Gh(e.axes).forEach(e=>VDe(e,t)),Gh(e.marks).forEach(e=>tq(e,t)),Gh(e.legends).forEach(e=>bDe(e,t)),e.title&&EDe(e.title,t),t.parseLambdas(),t}function UDe(e,t){let n=t.config,r=yK(t.root=t.add(vK())),i=WDe(e,n);i.forEach(e=>hK(e,t)),t.description=e.description||n.description,t.eventConfig=n.events,t.legends=t.objectProperty(n.legend&&n.legend.layout),t.locale=n.locale;let a=t.add(Xq()),o=t.add($q(pK(LY(e.encode),YJ,_q,e.style,t,{pulse:yK(a)}))),s=t.add(yJ({layout:t.objectProperty(e.layout),legends:t.legends,autosize:t.signalRef(`autosize`),mark:r,pulse:yK(o)}));t.operators.pop(),t.pushState(yK(o),yK(s),null),lq(e,t,i),t.operators.push(s);let c=t.add(Yq({mark:r,pulse:yK(s)}));return c=t.add(hJ({pulse:yK(c)})),c=t.add(_J({pulse:yK(c)})),t.addData(`root`,new XK(t,a,a,c)),t}function uq(e,t){return t&&t.signal?{name:e,update:t.signal}:{name:e,value:t}}function WDe(e,t){let n=n=>TK(e[n],t[n]),r=[uq(`background`,n(`background`)),uq(`autosize`,SEe(n(`autosize`))),uq(`padding`,CEe(n(`padding`))),uq(`width`,n(`width`)||0),uq(`height`,n(`height`)||0)],i=r.reduce((e,t)=>(e[t.name]=t,e),{}),a={};return Gh(e.signals).forEach(e=>{sg(i,e.name)?e=ig(i[e.name],e):r.push(e),a[e.name]=e}),Gh(t.signals).forEach(e=>{!sg(a,e.name)&&!sg(i,e.name)&&r.push(e)}),r}function dq(e,t){this.config=e||{},this.options=t||{},this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.eventConfig=null,this.locale=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._lookup=[],this._markpath=[]}function fq(e){this.config=e.config,this.options=e.options,this.legends=e.legends,this.field=Object.create(e.field),this.signals=Object.create(e.signals),this.lambdas=Object.create(e.lambdas),this.scales=Object.create(e.scales),this.events=Object.create(e.events),this.data=Object.create(e.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++e._nextsub[0],this._nextsub=e._nextsub,this._parent=e._parent.slice(),this._encode=e._encode.slice(),this._lookup=e._lookup.slice(),this._markpath=e._markpath}function pq(e){return(H(e)?GDe:KDe)(e)}function GDe(e){let t=e.length,n=`[`;for(let r=0;r0?`,`:``)+(gh(t)?t.signal||pq(t):W(t))}return n+`]`}function KDe(e){let t=`{`,n=0,r,i;for(r in e)i=e[r],t+=(++n>1?`,`:``)+W(r)+`:`+(gh(i)?i.signal||pq(i):W(i));return t+`}`}function qDe(){let e=`sans-serif`,t=`#4c78a8`,n=`#000`,r=`#888`,i=`#ddd`;return{description:`Vega visualization`,padding:0,autosize:`pad`,background:null,events:{defaults:{allow:[`wheel`]}},group:null,mark:null,arc:{fill:t},area:{fill:t},image:null,line:{stroke:t,strokeWidth:2},path:{stroke:t},rect:{fill:t},rule:{stroke:n},shape:{stroke:t},symbol:{fill:t,size:64},text:{fill:n,font:e,fontSize:11},trail:{fill:t,size:2},style:{"guide-label":{fill:n,font:e,fontSize:10},"guide-title":{fill:n,font:e,fontSize:11,fontWeight:`bold`},"group-title":{fill:n,font:e,fontSize:13,fontWeight:`bold`},"group-subtitle":{fill:n,font:e,fontSize:12},point:{size:30,strokeWidth:2,shape:`circle`},circle:{size:30,strokeWidth:2},square:{size:30,strokeWidth:2,shape:`square`},cell:{fill:`transparent`,stroke:i},view:{fill:`transparent`}},title:{orient:`top`,anchor:`middle`,offset:4,subtitlePadding:3},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domain:!0,domainWidth:1,domainColor:r,grid:!1,gridWidth:1,gridColor:i,labels:!0,labelAngle:0,labelLimit:180,labelOffset:0,labelPadding:2,ticks:!0,tickColor:r,tickOffset:0,tickRound:!0,tickSize:5,tickWidth:1,titlePadding:4},axisBand:{tickOffset:-.5},projection:{type:`mercator`},legend:{orient:`right`,padding:0,gridAlign:`each`,columnPadding:10,rowPadding:2,symbolDirection:`vertical`,gradientDirection:`vertical`,gradientLength:200,gradientThickness:16,gradientStrokeColor:i,gradientStrokeWidth:0,gradientLabelOffset:2,labelAlign:`left`,labelBaseline:`middle`,labelLimit:160,labelOffset:4,labelOverlap:!0,symbolLimit:30,symbolType:`circle`,symbolSize:100,symbolOffset:0,symbolStrokeWidth:1.5,symbolBaseFillColor:`transparent`,symbolBaseStrokeColor:r,titleLimit:180,titleOrient:`top`,titlePadding:5,layout:{offset:18,direction:`horizontal`,left:{direction:`vertical`},right:{direction:`vertical`}}},range:{category:{scheme:`tableau10`},ordinal:{scheme:`blues`},heatmap:{scheme:`yellowgreenblue`},ramp:{scheme:`blues`},diverging:{scheme:`blueorange`,extent:[1,0]},symbol:[`circle`,`square`,`triangle-up`,`cross`,`diamond`,`triangle-right`,`triangle-down`,`triangle-left`]}}}function JDe(e,t,n){return gh(e)||V(`Input Vega specification must be an object.`),t=vh(qDe(),t,e.config),UDe(e,new dq(t,n)).toRuntime()}var mq,hq,gq,_q,vq,yq,bq,xq,Sq,Cq,wq,Tq,Eq,Dq,Oq,kq,Aq,jq,Mq,Nq,Pq,Fq,Iq,Lq,Rq,zq,Bq,Vq,Hq,Uq,Wq,Gq,Kq,qq,Jq,Yq,Xq,Zq,Qq,$q,eJ,tJ,nJ,rJ,iJ,aJ,oJ,sJ,cJ,lJ,uJ,dJ,fJ,pJ,mJ,hJ,gJ,_J,vJ,yJ,bJ,xJ,SJ,CJ,wJ,TJ,EJ,DJ,OJ,kJ,AJ,jJ,MJ,NJ,PJ,FJ,IJ,LJ,RJ,zJ,BJ,VJ,HJ,UJ,WJ,GJ,KJ,qJ,JJ,YJ,XJ,ZJ,QJ,$J,eY,tY,nY,rY,iY,aY,oY,sY,cY,lY,uY,dY,fY,pY,mY,hY,gY,_Y,vY,yY,bY,xY,SY,CY,wY,TY,EY,DY,OY,kY,AY,jY,MY,NY,PY,FY,IY,LY,YDe=o((()=>{Tg(),zW(),rK(),xO(),Bx(),mq=e=>+e||0,hq=e=>({top:e,bottom:e,left:e,right:e}),gq=e=>gh(e)&&!H(e)?ig({},e):{value:e},_q=`frame`,vq=`scope`,yq=`axis`,bq=`axis-domain`,xq=`axis-grid`,Sq=`axis-label`,Cq=`axis-tick`,wq=`axis-title`,Tq=`legend`,Eq=`legend-band`,Dq=`legend-entry`,Oq=`legend-gradient`,kq=`legend-label`,Aq=`legend-symbol`,jq=`legend-title`,Mq=`title`,Nq=`title-text`,Pq=`title-subtitle`,Fq=e=>gg(e)?W(e):e.signal?`(${e.signal})`:dK(e),Iq=(e,t,n,r)=>`(${e}(${[t,n,r].map(lK).join(`,`)})+'')`,Lq=`outer`,Rq=[`value`,`update`,`init`,`react`,`bind`],zq=bK(`key`),Bq=`ascending`,Vq=`descending`,Hq=`scope`,Uq=`view`,Wq=`timer`,Gq={code:`_.$value`,ast:{type:`Identifier`,value:`value`}},Kq=e=>(t,n,r)=>_K(e,n,t||void 0,r),qq=Kq(`aggregate`),Jq=Kq(`axisticks`),Yq=Kq(`bound`),Xq=Kq(`collect`),Zq=Kq(`compare`),Qq=Kq(`datajoin`),$q=Kq(`encode`),eJ=Kq(`expression`),tJ=Kq(`facet`),nJ=Kq(`field`),rJ=Kq(`key`),iJ=Kq(`legendentries`),aJ=Kq(`load`),oJ=Kq(`mark`),sJ=Kq(`multiextent`),cJ=Kq(`multivalues`),lJ=Kq(`overlap`),uJ=Kq(`params`),dJ=Kq(`prefacet`),fJ=Kq(`projection`),pJ=Kq(`proxy`),mJ=Kq(`relay`),hJ=Kq(`render`),gJ=Kq(`scale`),_J=Kq(`sieve`),vJ=Kq(`sortitems`),yJ=Kq(`viewlayout`),bJ=Kq(`values`),xJ=0,SJ={min:`min`,max:`max`,count:`sum`},CJ=`top`,wJ=`left`,TJ=`right`,EJ=`bottom`,DJ=`center`,OJ=`vertical`,kJ=`start`,AJ=`middle`,jJ=`end`,MJ=`index`,NJ=`label`,PJ=`offset`,FJ=`perc`,IJ=`value`,LJ=`guide-label`,RJ=`guide-title`,zJ=`group-title`,BJ=`group-subtitle`,VJ=`symbol`,HJ=`gradient`,UJ=`discrete`,WJ=`size`,GJ=[WJ,`shape`,`fill`,`stroke`,`strokeWidth`,`strokeDash`,`opacity`],KJ={name:1,style:1,interactive:1},qJ={value:0},JJ={value:1},YJ=`group`,XJ=`rect`,ZJ=`rule`,QJ=`symbol`,$J=`text`,eY=zK(W(wJ),W(TJ),W(DJ)),tY=`datum.${FJ}<=0?"${wJ}":datum.${FJ}>=1?"${TJ}":"${DJ}"`,nY=`datum.${FJ}<=0?"${EJ}":datum.${FJ}>=1?"${CJ}":"${AJ}"`,rY=`item.orient === "left"`,iY=`item.orient === "right"`,aY=`(${rY} || ${iY})`,oY=`datum.vgrad && ${aY}`,sY=zK(`"top"`,`"bottom"`,`"middle"`),cY=`datum.vgrad && ${iY} ? (${zK(`"right"`,`"left"`,`"center"`)}) : (${aY} && !(datum.vgrad && ${rY})) ? "left" : ${eY}`,lY=`item._anchor || (${aY} ? "middle" : "start")`,uY=`${oY} ? (${rY} ? -90 : 90) : 0`,dY=`${aY} ? (datum.vgrad ? (${iY} ? "bottom" : "top") : ${sY}) : "top"`,fY=e=>e&&e.expr,pY=e=>e&&e.field,mY=e=>e===`data`,hY=e=>e===`expr`,gY=e=>e===`field`,_Y=e=>e===`compare`,XK.fromEntries=function(e,t){let n=t.length,r=t[n-1],i=t[n-2],a=t[0],o=null,s=1;for(a&&a.type===`load`&&(a=t[1]),e.add(t[0]);se===EJ||e===CJ,bY=(e,t,n)=>CK(e)?DY(e.signal,t,n):e===wJ||e===CJ?t:n,xY=(e,t,n)=>CK(e)?TY(e.signal,t,n):yY(e)?t:n,SY=(e,t,n)=>CK(e)?EY(e.signal,t,n):yY(e)?n:t,CY=(e,t,n)=>CK(e)?OY(e.signal,t,n):e===CJ?{value:t}:{value:n},wY=(e,t,n)=>CK(e)?kY(e.signal,t,n):e===TJ?{value:t}:{value:n},TY=(e,t,n)=>AY(`${e} === '${CJ}' || ${e} === '${EJ}'`,t,n),EY=(e,t,n)=>AY(`${e} !== '${CJ}' && ${e} !== '${EJ}'`,t,n),DY=(e,t,n)=>MY(`${e} === '${wJ}' || ${e} === '${CJ}'`,t,n),OY=(e,t,n)=>MY(`${e} === '${CJ}'`,t,n),kY=(e,t,n)=>MY(`${e} === '${TJ}'`,t,n),AY=(e,t,n)=>(t=t==null?t:gq(t),n=n==null?n:gq(n),jY(t)&&jY(n)?(t=t?t.signal||W(t.value):null,n=n?n.signal||W(n.value):null,{signal:`${e} ? (${t}) : (${n})`}):[ig({test:e},t)].concat(n||[])),jY=e=>e==null||Object.keys(e).length===1,MY=(e,t,n)=>({signal:`${e} ? (${PY(t)}) : (${PY(n)})`}),NY=(e,t,n,r,i)=>({signal:(r==null?``:`${e} === '${wJ}' ? (${PY(r)}) : `)+(n==null?``:`${e} === '${EJ}' ? (${PY(n)}) : `)+(i==null?``:`${e} === '${TJ}' ? (${PY(i)}) : `)+(t==null?``:`${e} === '${CJ}' ? (${PY(t)}) : `)+`(null)`}),PY=e=>CK(e)?e.signal:e==null?null:W(e),FY=(e,t)=>t===0?0:CK(e)?{signal:`(${e.signal}) * ${t}`}:{value:e*t},IY=(e,t)=>{let n=e.signal;return n&&n.endsWith(`(null)`)?{signal:n.slice(0,-6)+t.signal}:e},LY=e=>oK({enter:{x:{value:0},y:{value:0}},update:{width:{signal:`width`},height:{signal:`height`}}},e),dq.prototype=fq.prototype={parse(e){return lq(e,this)},fork(){return new fq(this)},isSubscope(){return this._subid>0},toRuntime(){return this.finish(),{description:this.description,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings,eventConfig:this.eventConfig,locale:this.locale}},id(){return(this._subid?this._subid+`:`:0)+this._id++},add(e){return this.operators.push(e),e.id=this.id(),e.refs&&=(e.refs.forEach(t=>{t.$ref=e.id}),null),e},proxy(e){let t=e instanceof gK?yK(e):e;return this.add(pJ({value:t}))},addStream(e){return this.streams.push(e),e.id=this.id(),e},addUpdate(e){return this.updates.push(e),e},finish(){let e,t;for(e in this.root&&(this.root.root=!0),this.signals)this.signals[e].signal=e;for(e in this.scales)this.scales[e].scale=e;function n(e,t,n){let r,i;e&&(r=e.data||={},i=r[t]||(r[t]=[]),i.push(n))}for(e in this.data){t=this.data[e],n(t.input,e,`input`),n(t.output,e,`output`),n(t.values,e,`values`);for(let r in t.index)n(t.index[r],e,`index:`+r)}return this},pushState(e,t,n){this._encode.push(yK(this.add(_J({pulse:e})))),this._parent.push(t),this._lookup.push(n?yK(this.proxy(n)):null),this._markpath.push(-1)},popState(){this._encode.pop(),this._parent.pop(),this._lookup.pop(),this._markpath.pop()},parent(){return xh(this._parent)},encode(){return xh(this._encode)},lookup(){return xh(this._lookup)},markpath(){let e=this._markpath;return++e[e.length-1]},fieldRef(e,t){if(gg(e))return bK(e,t);e.signal||V(`Unsupported field reference: `+W(e));let n=e.signal,r=this.field[n];if(!r){let e={name:this.signalRef(n)};t&&(e.as=t),this.field[n]=r=yK(this.add(nJ(e)))}return r},compareRef(e){let t=!1,n=e=>CK(e)?(t=!0,this.signalRef(e.signal)):PEe(e)?(t=!0,this.exprRef(e.expr)):e,r=Gh(e.field).map(n),i=Gh(e.order).map(n);return t?yK(this.add(Zq({fields:r,orders:i}))):xK(r,i)},keyRef(e,t){let n=!1,r=e=>CK(e)?(n=!0,yK(i[e.signal])):e,i=this.signals;return e=Gh(e).map(r),n?yK(this.add(rJ({fields:e,flat:t}))):MEe(e,t)},sortRef(e){if(!e)return e;let t=SK(e.op,e.field),n=e.order||Bq;return n.signal?yK(this.add(Zq({fields:t,orders:this.signalRef(n.signal)}))):xK(t,n)},event(e,t){let n=e+`:`+t;if(!this.events[n]){let r=this.id();this.streams.push({id:r,source:e,type:t}),this.events[n]=r}return this.events[n]},hasOwnSignal(e){return sg(this.signals,e)},addSignal(e,t){this.hasOwnSignal(e)&&V(`Duplicate signal name: `+W(e));let n=t instanceof gK?t:this.add(vK(t));return this.signals[e]=n},getSignal(e){return this.signals[e]||V(`Unrecognized signal name: `+W(e)),this.signals[e]},signalRef(e){return this.signals[e]?yK(this.signals[e]):(sg(this.lambdas,e)||(this.lambdas[e]=this.add(vK(null))),yK(this.lambdas[e]))},parseLambdas(){let e=Object.keys(this.lambdas);for(let t=0,n=e.length;tNO,CanvasHandler:()=>JA,CanvasRenderer:()=>YA,DATE:()=>Uv,DAY:()=>`day`,DAYOFYEAR:()=>Wv,Dataflow:()=>px,Debug:()=>4,DisallowedObjectProperties:()=>ph,Error:()=>1,EventStream:()=>ix,Gradient:()=>Fpe,GroupItem:()=>FO,HOURS:()=>Gv,Handler:()=>DA,HybridHandler:()=>Tj,HybridRenderer:()=>wj,Info:()=>3,Item:()=>PO,MILLISECONDS:()=>Jv,MINUTES:()=>Kv,MONTH:()=>Vv,Marks:()=>wA,MultiPulse:()=>ux,None:()=>0,Operator:()=>nx,Parameters:()=>tx,Pulse:()=>ox,QUARTER:()=>Bv,RenderType:()=>jj,Renderer:()=>OA,ResourceLoader:()=>tA,SECONDS:()=>qv,SVGHandler:()=>ZA,SVGRenderer:()=>vj,SVGStringRenderer:()=>Sj,Scenegraph:()=>EA,TIME_UNITS:()=>Yv,Transform:()=>G,View:()=>xG,WEEK:()=>Hv,Warn:()=>2,YEAR:()=>zv,accessor:()=>Jm,accessorFields:()=>Xm,accessorName:()=>Ym,array:()=>Gh,ascending:()=>Qh,bandwidthNRD:()=>Wx,bin:()=>Gx,bootstrapCI:()=>Kx,boundClip:()=>Ghe,boundContext:()=>RO,boundItem:()=>Sk,boundMark:()=>nhe,boundStroke:()=>LO,changeset:()=>ex,clampRange:()=>qh,codegenExpression:()=>wH,compare:()=>Xh,constant:()=>ng,cumulativeLogNormal:()=>nS,cumulativeNormal:()=>Xx,cumulativeUniform:()=>cS,dayofyear:()=>hv,debounce:()=>rg,defaultLocale:()=>pb,definition:()=>hx,densityLogNormal:()=>tS,densityNormal:()=>Yx,densityUniform:()=>sS,detectTimeUnits:()=>Rv,domChild:()=>Tk,domClear:()=>Ek,domCreate:()=>Ck,domFind:()=>wk,dotbin:()=>qx,error:()=>V,expressionFunction:()=>_W,extend:()=>ig,extent:()=>og,extentIndex:()=>Die,falsy:()=>fh,fastmap:()=>lg,field:()=>ah,flush:()=>Aie,font:()=>vk,fontFamily:()=>_k,fontSize:()=>fk,format:()=>Bb,formatLocale:()=>ob,formats:()=>wb,hasOwnProperty:()=>sg,id:()=>sh,identity:()=>ch,inferType:()=>vb,inferTypes:()=>yb,ingest:()=>Jb,inherits:()=>U,inrange:()=>dg,interpolate:()=>ZD,interpolateColors:()=>XD,interpolateRange:()=>Qfe,intersect:()=>Bhe,intersectBoxLine:()=>VO,intersectPath:()=>zO,intersectPoint:()=>BO,intersectRule:()=>sme,isArray:()=>H,isBoolean:()=>fg,isDate:()=>pg,isFunction:()=>Jh,isIterable:()=>Iie,isNumber:()=>mg,isObject:()=>gh,isRegExp:()=>hg,isString:()=>gg,isTuple:()=>Gb,key:()=>_g,lerp:()=>Hie,lineHeight:()=>pk,loader:()=>Vb,locale:()=>fb,logger:()=>mh,lruCache:()=>Wie,markup:()=>kk,merge:()=>Jie,mergeConfig:()=>vh,multiLineOffset:()=>hk,one:()=>uh,pad:()=>Zie,panLinear:()=>Dh,panLog:()=>Oh,panPow:()=>kh,panSymlog:()=>Ah,parse:()=>JDe,parseExpression:()=>SH,parseSelector:()=>BG,path:()=>pw,pathCurves:()=>wO,pathEqual:()=>Khe,pathParse:()=>TO,pathRectangle:()=>qpe,pathRender:()=>EO,pathSymbols:()=>Vpe,pathTrail:()=>Jpe,peek:()=>xh,point:()=>Dk,projection:()=>VL,quantileLogNormal:()=>rS,quantileNormal:()=>Zx,quantileUniform:()=>lS,quantiles:()=>Hx,quantizeInterpolator:()=>$fe,quarter:()=>Uh,quartiles:()=>Ux,random:()=>wS,randomInteger:()=>Wce,randomKDE:()=>$x,randomLCG:()=>Uce,randomLogNormal:()=>iS,randomMixture:()=>aS,randomNormal:()=>Qx,randomUniform:()=>uS,read:()=>Eb,regressionConstant:()=>dS,regressionExp:()=>vS,regressionLinear:()=>gS,regressionLoess:()=>SS,regressionLog:()=>_S,regressionPoly:()=>xS,regressionPow:()=>yS,regressionQuad:()=>bS,renderModule:()=>Pk,repeat:()=>vg,resetDefaultLocale:()=>ace,resetSVGDefIds:()=>Jhe,responseType:()=>Tb,runtimeContext:()=>UW,sampleCurve:()=>CS,sampleLogNormal:()=>eS,sampleNormal:()=>Jx,sampleUniform:()=>oS,scale:()=>WD,sceneEqual:()=>Fk,sceneFromJSON:()=>ihe,scenePickVisit:()=>JO,sceneToJSON:()=>rhe,sceneVisit:()=>qO,sceneZOrder:()=>KO,scheme:()=>QD,serializeXML:()=>dj,setHybridRendererOptions:()=>zhe,setRandom:()=>Vce,span:()=>yg,splitAccessPath:()=>rh,stringValue:()=>W,textMetrics:()=>SA,timeBin:()=>Lv,timeFloor:()=>Dv,timeFormatLocale:()=>db,timeInterval:()=>kv,timeOffset:()=>Mv,timeSequence:()=>Fv,timeUnitSpecifier:()=>pv,timeUnits:()=>fv,toBoolean:()=>bg,toDate:()=>xg,toNumber:()=>Ch,toSet:()=>Cg,toString:()=>Sg,transform:()=>gx,transforms:()=>zx,truncate:()=>oae,truthy:()=>dh,tupleid:()=>Kb,typeParsers:()=>Ib,utcFloor:()=>Ov,utcInterval:()=>Av,utcOffset:()=>Nv,utcSequence:()=>Iv,utcdayofyear:()=>bv,utcquarter:()=>Wh,utcweek:()=>xv,version:()=>zY,visitArray:()=>wg,week:()=>gv,writeConfig:()=>yh,zero:()=>lh,zoomLinear:()=>Mh,zoomLog:()=>Nh,zoomPow:()=>Ph,zoomSymlog:()=>Fh}),RY,zY,BY=o((()=>{Tg(),Tg(),Bx(),Ale(),x_e(),z_e(),Hye(),txe(),ESe(),HSe(),WSe(),gCe(),TCe(),jCe(),jS(),wy(),Hb(),Fj(),xO(),KL(),_Ee(),_b(),zW(),YDe(),ZW(),wU(),rK(),RY=`6.3.1`,ig(zx,$ce,Qge,S_e,Sye,Ybe,DSe,SSe,USe,pCe,_Ce,ECe),zY=RY}));function ZDe(e,t,n){let r;t.x2&&(t.x?(n&&e.x>e.x2&&(r=e.x,e.x=e.x2,e.x2=r),e.width=e.x2-e.x):e.x=e.x2-(e.width||0)),t.xc&&(e.x=e.xc-(e.width||0)/2),t.y2&&(t.y?(n&&e.y>e.y2&&(r=e.y,e.y=e.y2,e.y2=r),e.height=e.y2-e.y):e.y=e.y2-(e.height||0)),t.yc&&(e.y=e.yc-(e.height||0)/2)}function VY(e,t,n,r,i,a){let o=e=>ZY[e.type](o,e);return o.memberDepth=0,o.fn=Object.create(t),o.params=n,o.datum=r,o.event=i,o.item=a,YY.forEach(e=>o.fn[e]=(...t)=>i.vega[e](...t)),o(e)}var HY,UY,WY,GY,KY,qY,JY,YY,XY,ZY,QY,QDe=o((()=>{Tg(),HY={NaN:NaN,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,PI:Math.PI,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2,MIN_VALUE:Number.MIN_VALUE,MAX_VALUE:Number.MAX_VALUE},UY={"*":(e,t)=>e*t,"+":(e,t)=>e+t,"-":(e,t)=>e-t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>ee<=t,">=":(e,t)=>e>=t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,"&":(e,t)=>e&t,"|":(e,t)=>e|t,"^":(e,t)=>e^t,"<<":(e,t)=>e<>":(e,t)=>e>>t,">>>":(e,t)=>e>>>t},WY={"+":e=>+e,"-":e=>-e,"~":e=>~e,"!":e=>!e},GY=Array.prototype.slice,KY=(e,t,n)=>{let r=n?n(t[0]):t[0];return r[e].apply(r,GY.call(t,1))},qY=(e,t=0,n=1,r=0,i=0,a=0,o=0)=>gg(e)?new Date(e):new Date(e,t,n,r,i,a,o),JY={isNaN:Number.isNaN,isFinite:Number.isFinite,abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:Math.atan2,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,pow:Math.pow,random:Math.random,round:Math.round,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,clamp:(e,t,n)=>Math.max(t,Math.min(n,e)),now:Date.now,utc:Date.UTC,datetime:qY,date:e=>new Date(e).getDate(),day:e=>new Date(e).getDay(),year:e=>new Date(e).getFullYear(),month:e=>new Date(e).getMonth(),hours:e=>new Date(e).getHours(),minutes:e=>new Date(e).getMinutes(),seconds:e=>new Date(e).getSeconds(),milliseconds:e=>new Date(e).getMilliseconds(),time:e=>new Date(e).getTime(),timezoneoffset:e=>new Date(e).getTimezoneOffset(),utcdate:e=>new Date(e).getUTCDate(),utcday:e=>new Date(e).getUTCDay(),utcyear:e=>new Date(e).getUTCFullYear(),utcmonth:e=>new Date(e).getUTCMonth(),utchours:e=>new Date(e).getUTCHours(),utcminutes:e=>new Date(e).getUTCMinutes(),utcseconds:e=>new Date(e).getUTCSeconds(),utcmilliseconds:e=>new Date(e).getUTCMilliseconds(),length:e=>e.length,join:function(){return KY(`join`,arguments)},indexof:function(){return KY(`indexOf`,arguments)},lastindexof:function(){return KY(`lastIndexOf`,arguments)},slice:function(){return KY(`slice`,arguments)},reverse:e=>e.slice().reverse(),sort:e=>e.slice().sort(Qh),parseFloat,parseInt,upper:e=>String(e).toUpperCase(),lower:e=>String(e).toLowerCase(),substring:function(){return KY(`substring`,arguments,String)},split:function(){return KY(`split`,arguments,String)},replace:function(){return KY(`replace`,arguments,String)},trim:e=>String(e).trim(),btoa:e=>btoa(e),atob:e=>atob(e),encodeURIComponent:e=>encodeURIComponent(e),regexp:RegExp,test:(e,t)=>RegExp(e).test(t)},YY=[`view`,`item`,`group`,`xy`,`x`,`y`],XY=new Set([Function,eval,setTimeout,setInterval]),typeof setImmediate==`function`&&XY.add(setImmediate),ZY={Literal:(e,t)=>t.value,Identifier:(e,t)=>{let n=t.name;return e.memberDepth>0?n:n===`datum`?e.datum:n===`event`?e.event:n===`item`?e.item:HY[n]||e.params[`$`+n]},MemberExpression:(e,t)=>{let n=!t.computed,r=e(t.object);n&&(e.memberDepth+=1);let i=e(t.property);if(n&&--e.memberDepth,XY.has(r[i])){console.error(`Prevented interpretation of member "${i}" which could lead to insecure code execution`);return}return r[i]},CallExpression:(e,t)=>{let n=t.arguments,r=t.callee.name;return r.startsWith(`_`)&&(r=r.slice(1)),r===`if`?e(n[0])?e(n[1]):e(n[2]):(e.fn[r]||JY[r]).apply(e.fn,n.map(e))},ArrayExpression:(e,t)=>t.elements.map(e),BinaryExpression:(e,t)=>UY[t.operator](e(t.left),e(t.right)),UnaryExpression:(e,t)=>WY[t.operator](e(t.argument)),ConditionalExpression:(e,t)=>e(t.test)?e(t.consequent):e(t.alternate),LogicalExpression:(e,t)=>t.operator===`&&`?e(t.left)&&e(t.right):e(t.left)||e(t.right),ObjectExpression:(e,t)=>t.properties.reduce((t,n)=>{e.memberDepth+=1;let r=e(n.key);--e.memberDepth;let i=e(n.value);return ph.has(r)?console.error(`Prevented interpretation of property "${r}" which could lead to insecure code execution`):XY.has(i)?console.error(`Prevented interpretation of method "${r}" which could lead to insecure code execution`):t[r]=i,t},{})},QY={operator(e,t){let n=t.ast,r=e.functions;return e=>VY(n,r,e)},parameter(e,t){let n=t.ast,r=e.functions;return(e,t)=>VY(n,r,t,e)},event(e,t){let n=t.ast,r=e.functions;return e=>VY(n,r,void 0,void 0,e)},handler(e,t){let n=t.ast,r=e.functions;return(e,t)=>{let i=t.item&&t.item.datum;return VY(n,r,e,i,t)}},encode(e,t){let{marktype:n,channels:r}=t,i=e.functions,a=n===`group`||n===`image`||n===`rect`;return(e,t)=>{let o=e.datum,s=0,c;for(let n in r)c=VY(r[n].ast,i,t,o,void 0,e),e[n]!==c&&(e[n]=c,s=1);return n!==`rule`&&ZDe(e,r,a),s}}}}));function $Y(e){this.type=e}function $De(e){switch(e.type){case FX:return e.elements;case IX:case zX:return[e.left,e.right];case LX:return[e.callee].concat(e.arguments);case RX:return[e.test,e.consequent,e.alternate];case BX:return[e.object,e.property];case VX:return e.properties;case NX:return[e.key,e.value];case HX:return[e.argument];case PX:case MX:case jX:default:return[]}}function eX(e,t){if(!e)throw Error(`ASSERT: `+t)}function tX(e){return e>=48&&e<=57}function nX(e){return`0123456789abcdefABCDEF`.includes(e)}function rX(e){return`01234567`.includes(e)}function eOe(e){return e===32||e===9||e===11||e===12||e===160||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e)}function iX(e){return e===10||e===13||e===8232||e===8233}function aX(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e===92||e>=128&&TZ.test(String.fromCharCode(e))}function oX(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===92||e>=128&&EZ.test(String.fromCharCode(e))}function sX(){for(;J1114111||e!==`}`)&&bX({},pZ,CZ),t<=65535?String.fromCharCode(t):(n=(t-65536>>10)+55296,r=(t-65536&1023)+56320,String.fromCharCode(n,r))}function lX(){var e=WX.charCodeAt(J++),t=String.fromCharCode(e);for(e===92&&(WX.charCodeAt(J)!==117&&bX({},pZ,CZ),++J,e=cX(`u`),(!e||e===`\\`||!aX(e.charCodeAt(0)))&&bX({},pZ,CZ),t=e);J>>=`)return J+=4,{type:$X,value:o,start:e,end:J};if(a=o.substr(0,3),a===`>>>`||a===`<<=`||a===`>>=`)return J+=3,{type:$X,value:a,start:e,end:J};if(i=a.substr(0,2),r===i[1]&&`+-<>&|`.includes(r)||i===`=>`)return J+=2,{type:$X,value:i,start:e,end:J};if(i===`//`&&bX({},pZ,CZ),`<>=!+-*%&|^/`.includes(r))return++J,{type:$X,value:r,start:e,end:J};bX({},pZ,CZ)}function iOe(e){let t=``;for(;J{if(parseInt(t,16)<=1114111)return`x`;bX({},yZ)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,`x`));try{new RegExp(n)}catch{bX({},yZ)}try{return new RegExp(e,t)}catch{return null}}function cOe(){var e=WX[J],t,n,r,i;for(eX(e===`/`,`Regular expression literal must start with a slash`),t=WX[J++],n=!1,r=!1;J=0&&bX({},yZ,n),{value:n,literal:t}}function uOe(){var e,t,n,r;return KX=null,sX(),e=J,t=cOe(),n=lOe(),r=sOe(t.value,n.value),{literal:t.literal+n.literal,value:r,regex:{pattern:t.value,flags:n.value},start:e,end:J}}function dOe(e){return e.type===YX||e.type===XX||e.type===qX||e.type===ZX}function fX(){if(sX(),J>=GX)return{type:JX,start:J,end:J};let e=WX.charCodeAt(J);return aX(e)?rOe():e===40||e===41||e===59?uX():e===39||e===34?oOe():e===46?tX(WX.charCodeAt(J+1))?dX():uX():tX(e)?dX():uX()}function pX(){let e=KX;return J=e.end,KX=fX(),J=e.end,e}function mX(){let e=J;KX=fX(),J=e}function fOe(e){let t=new $Y(nZ);return t.elements=e,t}function hX(e,t,n){let r=new $Y(e===`||`||e===`&&`?cZ:rZ);return r.operator=e,r.left=t,r.right=n,r}function pOe(e,t){let n=new $Y(iZ);return n.callee=e,n.arguments=t,n}function mOe(e,t,n){let r=new $Y(aZ);return r.test=e,r.consequent=t,r.alternate=n,r}function gX(e){let t=new $Y(oZ);return t.name=e,t}function _X(e){let t=new $Y(sZ);return t.value=e.value,t.raw=WX.slice(e.start,e.end),e.regex&&(t.raw===`//`&&(t.raw=`/(?:)/`),t.regex=e.regex),t}function vX(e,t,n){let r=new $Y(lZ);return r.computed=e===`[`,r.object=t,r.property=n,r.computed||(n.member=!0),r}function hOe(e){let t=new $Y(uZ);return t.properties=e,t}function yX(e,t,n){let r=new $Y(dZ);return r.key=t,r.value=n,r.kind=e,r}function gOe(e,t){let n=new $Y(fZ);return n.operator=e,n.argument=t,n.prefix=!0,n}function bX(e,t){var n,r=Array.prototype.slice.call(arguments,2),i=t.replace(/%(\d)/g,(e,t)=>(eX(t`:case`<=`:case`>=`:case`instanceof`:case`in`:t=7;break;case`<<`:case`>>`:case`>>>`:t=8;break;case`+`:case`-`:t=9;break;case`*`:case`/`:case`%`:t=11;break}return t}function DOe(){var e=KX,t,n,r,i,a,o,s,c=DX(),l;if(r=KX,i=OX(r),i===0)return c;for(r.prec=i,pX(),t=[e,KX],o=DX(),a=[c,r,o];(i=OX(KX))>0;){for(;a.length>2&&i<=a[a.length-2].prec;)o=a.pop(),s=a.pop().value,c=a.pop(),t.pop(),n=hX(s,c,o),a.push(n);r=pX(),r.prec=i,a.push(r),t.push(KX),n=DX(),a.push(n)}for(l=a.length-1,n=a[l],t.pop();l>1;)t.pop(),n=hX(a[l-1].value,a[l-2],n),l-=2;return n}function kX(){var e=DOe(),t,n;return CX(`?`)&&(pX(),t=kX(),SX(`:`),n=kX(),e=mOe(e,t,n)),e}function AX(){let e=kX();if(CX(`,`))throw Error(wZ);return e}function OOe(e){WX=e,J=0,GX=WX.length,KX=null,mX();let t=AX();if(KX.type!==JX)throw Error(`Unexpect token after expression.`);return t}var jX,MX,NX,PX,FX,IX,LX,RX,zX,BX,VX,HX,UX,WX,J,GX,KX,qX,JX,YX,XX,ZX,QX,$X,eZ,tZ,nZ,rZ,iZ,aZ,oZ,sZ,cZ,lZ,uZ,dZ,fZ,pZ,mZ,hZ,gZ,_Z,vZ,yZ,bZ,xZ,SZ,CZ,wZ,TZ,EZ,DZ,kOe,AOe=o((()=>{Tg(),jX=`RawCode`,MX=`Literal`,NX=`Property`,PX=`Identifier`,FX=`ArrayExpression`,IX=`BinaryExpression`,LX=`CallExpression`,RX=`ConditionalExpression`,zX=`LogicalExpression`,BX=`MemberExpression`,VX=`ObjectExpression`,HX=`UnaryExpression`,$Y.prototype.visit=function(e){let t,n,r;if(e(this))return 1;for(t=$De(this),n=0,r=t.length;n`,UX[YX]=`Identifier`,UX[XX]=`Keyword`,UX[ZX]=`Null`,UX[QX]=`Numeric`,UX[$X]=`Punctuator`,UX[eZ]=`String`,UX[tZ]=`RegularExpression`,nZ=`ArrayExpression`,rZ=`BinaryExpression`,iZ=`CallExpression`,aZ=`ConditionalExpression`,oZ=`Identifier`,sZ=`Literal`,cZ=`LogicalExpression`,lZ=`MemberExpression`,uZ=`ObjectExpression`,dZ=`Property`,fZ=`UnaryExpression`,pZ=`Unexpected token %0`,mZ=`Unexpected number`,hZ=`Unexpected string`,gZ=`Unexpected identifier`,_Z=`Unexpected reserved word`,vZ=`Unexpected end of input`,yZ=`Invalid regular expression`,bZ=`Invalid regular expression: missing /`,xZ=`Octal literals are not allowed in strict mode.`,SZ=`Duplicate data property in object literal not allowed in strict mode`,CZ=`ILLEGAL`,wZ=`Disabled.`,TZ=RegExp(`[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]`),EZ=RegExp(`[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]`),DZ={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1},kOe={if:1}})),jOe=c({accessPathDepth:()=>sQ,accessPathWithDatum:()=>eQ,accessWithDatumToUnescapedPath:()=>nQ,compile:()=>fLe,contains:()=>RZ,deepEqual:()=>mQ,deleteNestedProperty:()=>QZ,duplicate:()=>N2,entries:()=>F2,every:()=>BZ,fieldIntersection:()=>KZ,flatAccessWithDatum:()=>tQ,getFirstDefined:()=>cQ,hasIntersection:()=>WZ,hasProperty:()=>Y,hash:()=>IZ,internalField:()=>uQ,isBoolean:()=>JZ,isEmpty:()=>qZ,isEqual:()=>NOe,isInternalField:()=>dQ,isNullOrFalse:()=>LZ,isNumeric:()=>pQ,isPrimitive:()=>YZ,keys:()=>$,logicalExpr:()=>ZZ,mergeDeep:()=>VZ,never:()=>NZ,normalize:()=>JMe,normalizeAngle:()=>fQ,omit:()=>FZ,pick:()=>PZ,prefixGenerator:()=>GZ,removePathFromField:()=>oQ,replaceAll:()=>aQ,replacePathInField:()=>iQ,resetIdCounter:()=>FOe,setEqual:()=>UZ,some:()=>zZ,stringify:()=>hQ,titleCase:()=>$Z,unescapeSingleQuoteAndPathDot:()=>rQ,unique:()=>HZ,uniqueId:()=>lQ,vals:()=>P2,varName:()=>XZ,version:()=>DBe});function OZ(e){return Y(e,`or`)}function kZ(e){return Y(e,`and`)}function AZ(e){return Y(e,`not`)}function jZ(e,t){if(AZ(e))jZ(e.not,t);else if(kZ(e))for(let n of e.and)jZ(n,t);else if(OZ(e))for(let n of e.or)jZ(n,t);else t(e)}function MZ(e,t){return AZ(e)?{not:MZ(e.not,t)}:kZ(e)?{and:e.and.map(e=>MZ(e,t))}:OZ(e)?{or:e.or.map(e=>MZ(e,t))}:t(e)}function NZ(e){throw Error(e)}function PZ(e,t){let n={};for(let r of t)sg(e,r)&&(n[r]=e[r]);return n}function FZ(e,t){let n={...e};for(let e of t)delete n[e];return n}function IZ(e){if(mg(e))return e;let t=gg(e)?e:hQ(e);if(t.length<250)return t;let n=0;for(let e=0;et===0?e:`[${e}]`),r=e.map((t,n)=>e.slice(0,n+1).join(``));for(let e of r)t.add(e)}return t}function KZ(e,t){return e===void 0||t===void 0||WZ(GZ(e),GZ(t))}function qZ(e){return $(e).length===0}function JZ(e){return e===!0||e===!1}function YZ(e){return gg(e)||mg(e)||JZ(e)}function XZ(e){let t=e.replace(/\W/g,`_`);return(e.match(/^\d+/)?`_`:``)+t}function ZZ(e,t){return AZ(e)?`!(${ZZ(e.not,t)})`:kZ(e)?`(${e.and.map(e=>ZZ(e,t)).join(`) && (`)})`:OZ(e)?`(${e.or.map(e=>ZZ(e,t)).join(`) || (`)})`:t(e)}function QZ(e,t){if(t.length===0)return!0;let n=t.shift();return n in e&&QZ(e[n],t)&&delete e[n],qZ(e)}function $Z(e){return e.charAt(0).toUpperCase()+e.substr(1)}function eQ(e,t=`datum`){let n=rh(e),r=[];for(let e=1;e<=n.length;e++){let i=`[${n.slice(0,e).map(W).join(`][`)}]`;r.push(`${t}${i}`)}return r.join(` && `)}function tQ(e,t=`datum`){return`${t}[${W(rh(e).join(`.`))}]`}function nQ(e){return`datum['${e.replaceAll(`'`,`\\'`)}']`}function rQ(e){return e.replaceAll(`\\'`,`'`).replaceAll(`\\.`,`.`)}function POe(e){return e.replace(/(\[|\]|\.|'|")/g,`\\$1`)}function iQ(e){return`${rh(e).map(POe).join(`\\.`)}`}function aQ(e,t,n){return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`),`g`),n)}function oQ(e){return`${rh(e).join(`.`)}`}function sQ(e){return e?rh(e).length:0}function cQ(...e){return e.find(e=>e!==void 0)}function lQ(e){let t=++I2;return e?String(e)+t:t}function FOe(){I2=42}function uQ(e){return dQ(e)?e:`__${e}`}function dQ(e){return e.startsWith(`__`)}function fQ(e){if(e!==void 0)return(e%360+360)%360}function pQ(e){return mg(e)?!0:!isNaN(e)&&!isNaN(parseFloat(e))}function mQ(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(e.constructor.name!==t.constructor.name)return!1;let n,r;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!mQ(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let n of e.entries())if(!t.has(n[0]))return!1;for(let n of e.entries())if(!mQ(n[1],t.get(n[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e.entries())if(!t.has(n[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&e.valueOf!==L2.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&e.toString!==L2.toString)return e.toString()===t.toString();let i=Object.keys(e);if(n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!mQ(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function hQ(e){let t=[];return(function e(n){if(n?.toJSON&&typeof n.toJSON==`function`&&(n=n.toJSON()),n===void 0)return;if(typeof n==`number`)return isFinite(n)?`${n}`:`null`;if(typeof n!=`object`)return JSON.stringify(n);let r,i;if(Array.isArray(n)){for(i=`[`,r=0;rHQ(e[t])?XZ(`_${t}_${F2(e[t])}`):XZ(`_${t}_${e[t]}`)).join(``)}`}function zQ(e){return e===!0||VQ(e)&&!e.binned}function BQ(e){return e===`binned`||VQ(e)&&e.binned===!0}function VQ(e){return gh(e)}function HQ(e){return Y(e,`param`)}function UQ(e){switch(e){case R2:case z2:case o4:case n4:case r4:case i4:case d4:case c4:case l4:case u4:case a4:return 6;case f4:return 4;default:return 10}}function WQ(e){return Y(e,`expr`)}function GQ(e,{level:t}={level:0}){let n=$(e||{}),r={};for(let i of n)r[i]=t===0?$Q(e[i]):GQ(e[i],{level:t-1});return r}function KQ(e){let{anchor:t,frame:n,offset:r,orient:i,angle:a,limit:o,color:s,subtitleColor:c,subtitleFont:l,subtitleFontSize:u,subtitleFontStyle:d,subtitleFontWeight:f,subtitleLineHeight:p,subtitlePadding:m,...h}=e,g={...h,...s?{fill:s}:{}},_={...t?{anchor:t}:{},...n?{frame:n}:{},...r?{offset:r}:{},...i?{orient:i}:{},...a===void 0?{}:{angle:a},...o===void 0?{}:{limit:o}},v={...c?{subtitleColor:c}:{},...l?{subtitleFont:l}:{},...u?{subtitleFontSize:u}:{},...d?{subtitleFontStyle:d}:{},...f?{subtitleFontWeight:f}:{},...p?{subtitleLineHeight:p}:{},...m?{subtitlePadding:m}:{}};return{titleMarkConfig:g,subtitleMarkConfig:PZ(e,[`align`,`baseline`,`dx`,`dy`,`limit`]),nonMarkTitleProperties:_,subtitle:v}}function qQ(e){return gg(e)||H(e)&&gg(e[0])}function JQ(e){return Y(e,`signal`)}function YQ(e){return Y(e,`step`)}function XQ(e){return!H(e)&&Y(e,`fields`)&&!Y(e,`data`)}function UOe(e){return!H(e)&&Y(e,`fields`)&&Y(e,`data`)}function ZQ(e){return!H(e)&&Y(e,`field`)&&Y(e,`data`)}function QQ(e){let t=H(e.condition)?e.condition.map(e$):e$(e.condition);return{...$Q(e),condition:t}}function $Q(e){if(WQ(e)){let{expr:t,...n}=e;return{signal:t,...n}}return e}function e$(e){if(WQ(e)){let{expr:t,...n}=e;return{signal:t,...n}}return e}function t$(e){if(WQ(e)){let{expr:t,...n}=e;return{signal:t,...n}}return JQ(e)?e:e===void 0?void 0:{value:e}}function WOe(e){return JQ(e)?e.signal:W(e)}function n$(e){return JQ(e)?e.signal:W(e.value)}function r$(e){return JQ(e)?e.signal:e==null?null:W(e)}function GOe(e,t,n){for(let r of n){let n=o$(r,t.markDef,t.config);n!==void 0&&(e[r]=t$(n))}return e}function i$(e){return[].concat(e.type,e.style??[])}function a$(e,t,n,r={}){let{vgChannel:i,ignoreVgConfig:a}=r;return i&&Y(t,i)?t[i]:t[e]===void 0?a&&(!i||i===e)?void 0:o$(e,t,n,r):t[e]}function o$(e,t,n,{vgChannel:r}={}){let i=s$(e,t,n.style);return cQ(r?i:void 0,i,r?n[t.type][r]:void 0,n[t.type][e],r?n.mark[r]:n.mark[e])}function s$(e,t,n){return c$(e,i$(t),n)}function c$(e,t,n){t=Gh(t);let r;for(let i of t){let t=n[i];Y(t,e)&&(r=t[e])}return r}function l$(e,t){return Gh(e).reduce((e,n)=>(e.field.push(Q(n,t)),e.order.push(n.sort??`ascending`),e),{field:[],order:[]})}function u$(e,t){let n=[...e];return t.forEach(e=>{for(let t of n)if(mQ(t,e))return;n.push(e)}),n}function d$(e,t){return mQ(e,t)||!t?e:e?[...Gh(e),...Gh(t)].join(`, `):t}function f$(e,t){let n=e.value,r=t.value;if(n==null||r===null)return{explicit:e.explicit,value:null};if((qQ(n)||JQ(n))&&(qQ(r)||JQ(r)))return{explicit:e.explicit,value:d$(n,r)};if(qQ(n)||JQ(n))return{explicit:e.explicit,value:n};if(qQ(r)||JQ(r))return{explicit:e.explicit,value:r};if(!qQ(n)&&!JQ(n)&&!qQ(r)&&!JQ(r))return{explicit:e.explicit,value:u$(n,r)};throw Error(`It should never reach here`)}function p$(e){return`Invalid specification ${hQ(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}function m$(e){return`${e==`width`?`Width`:`Height`} "container" only works for single views and layered views.`}function h$(e){return`${e==`width`?`Width`:`Height`} "container" only works well with autosize "fit" or "fit-${e==`width`?`x`:`y`}".`}function g$(e){return e?`Dropping "fit-${e}" because spec has discrete ${TQ(e)}.`:`Dropping "fit" because spec has discrete size.`}function _$(e){return`Unknown field for ${e}. Cannot calculate view size.`}function v$(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`}function KOe(e,t){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").`}function qOe(e){return`The "nearest" transform is not supported for ${e} marks.`}function y$(e){return`Selection not supported for ${e} yet.`}function JOe(e){return`Cannot find a selection named "${e}".`}function YOe(e){return`Lookups can only be performed on selection parameters. "${e}" is a variable parameter.`}function XOe(e){return`Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`}function ZOe(e){return`Unknown repeated value "${e}".`}function b$(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`}function QOe(e){return`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${W(e)}.`}function $Oe(e,t,n,r){return`${e.length?`Multiple `:`No `}matching ${W(t)} encoding found for selection ${W(n.param)}. Using "field": ${W(r)}.`}function eke(e){return`Unrecognized parse "${e}".`}function x$(e,t,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`}function tke(e){return`Ignoring an invalid transform: ${hQ(e)}.`}function S$(e){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`}function nke(e){let{parentProjection:t,projection:n}=e;return`Layer's shared projection ${hQ(t)} is overridden by a child projection ${hQ(n)}.`}function rke(e){return`${e}Offset dropped because ${e} is continuous`}function ike(e,t,n){return`Channel ${e} is a ${t}. Converted to {value: ${hQ(n)}}.`}function C$(e){return`Invalid field type "${e}".`}function ake(e,t){return`Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`}function oke(e){return`Invalid aggregation operator "${e}".`}function w$(e,t){let{fill:n,stroke:r}=t;return`Dropping color ${e} as the plot also has ${n&&r?`fill and stroke`:n?`fill`:`stroke`}.`}function ske(e){return`Position range does not support relative band size for ${e}.`}function T$(e,t){return`Dropping ${hQ(e)} from channel "${t}" since it does not contain any data field, datum, value, or signal.`}function E$(e,t,n){return`${e} dropped as it is incompatible with "${t}".`}function cke(e){return`${e}-encoding is dropped as ${e} is not a valid encoding channel.`}function lke(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`}function uke(e){return`${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function dke(e){return`Facet encoding dropped as ${e.join(` and `)} ${e.length>1?`are`:`is`} also specified.`}function D$(e,t){return`Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${t===`ordinal`?`order`:`magnitude`}.`}function fke(e){return`The ${e} for range marks cannot be an expression`}function pke(e,t){return`Line mark is for continuous lines and thus cannot be used with ${e&&t?`x2 and y2`:e?`x2`:`y2`}. We will use the rule mark (line segments) instead.`}function mke(e,t){return`Specified orient "${e}" overridden with "${t}".`}function hke(e){return`Cannot use the scale property "${e}" with non-color channel.`}function gke(e){return`Cannot use the relative band size with ${e} scale.`}function _ke(e){return`Using unaggregated domain with raw field has no effect (${hQ(e)}).`}function vke(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`}function yke(e){return`Unaggregated domain is currently unsupported for log scale (${hQ(e)}).`}function bke(e){return`Cannot apply size to non-oriented mark "${e}".`}function xke(e,t,n){return`Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.`}function Ske(e,t){return`FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.`}function O$(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`}function k$(e){return`The step for "${e}" is dropped because the ${e===`width`?`x`:`y`} is continuous.`}function Cke(e,t,n,r){return`Conflicting ${t.toString()} property "${e.toString()}" (${hQ(n)} and ${hQ(r)}). Using ${hQ(n)}.`}function wke(e,t,n,r){return`Conflicting ${t.toString()} property "${e.toString()}" (${hQ(n)} and ${hQ(r)}). Using the union of the two domains.`}function Tke(e){return`Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`}function Eke(e){return`Dropping sort property ${hQ(e)} as unioned domains only support boolean or op "count", "min", and "max".`}function Dke(e,t){return`Unioning discrete legend values from ${e} and ${t}.`}function Oke(e){return`Cannot stack "${e}" if there is already "${e}2".`}function kke(e){return`Stack is applied to a non-linear scale (${e}).`}function Ake(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}").`}function A$(e,t){return`Invalid ${e}: ${hQ(t)}.`}function jke(e){return`Dropping day from datetime ${hQ(e)} as day cannot be combined with other units.`}function Mke(e,t){return`${t?`extent `:``}${t&&e?`and `:``}${e?`center `:``}${t&&e?`are `:`is `}not needed when data are aggregated.`}function Nke(e,t,n){return`${e} is not usually used with ${t} for ${n}.`}function Pke(e,t){return`Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`}function Fke(e){return`1D error band does not support ${e}.`}function Ike(e){return`Channel ${e} is required for "binned" bin.`}function Lke(e){return`Channel ${e} should not be used with "binned" bin.`}function Rke(e){return`Domain for ${e} is required for threshold scale.`}function zke(e){return B4=e,B4}function Bke(){return B4=z4,B4}function j$(...e){B4.error(...e)}function X(...e){B4.warn(...e)}function Vke(...e){B4.debug(...e)}function M$(e){if(e&&gh(e)){for(let t of W4)if(Y(e,t))return!0}return!1}function Hke(e){if(pQ(e)&&(e=+e),mg(e))return e>4&&X(A$(`quarter`,e)),e-1;throw Error(A$(`quarter`,e))}function Uke(e){if(pQ(e)&&(e=+e),mg(e))return e-1;{let t=e.toLowerCase(),n=V4.indexOf(t);if(n!==-1)return n;let r=t.substr(0,3),i=ERe.indexOf(r);if(i!==-1)return i;throw Error(A$(`month`,e))}}function Wke(e){if(pQ(e)&&(e=+e),mg(e))return e%7;{let t=e.toLowerCase(),n=H4.indexOf(t);if(n!==-1)return n;let r=t.substr(0,3),i=DRe.indexOf(r);if(i!==-1)return i;throw Error(A$(`day`,e))}}function N$(e,t){let n=[];if(t&&e.day!==void 0&&$(e).length>1&&(X(jke(e)),e=N2(e),delete e.day),e.year===void 0?n.push(2012):n.push(e.year),e.month!==void 0){let r=t?Uke(e.month):e.month;n.push(r)}else if(e.quarter!==void 0){let r=t?Hke(e.quarter):e.quarter;n.push(mg(r)?r*3:`${r}*3`)}else n.push(0);if(e.date!==void 0)n.push(e.date);else if(e.day!==void 0){let r=t?Wke(e.day):e.day;n.push(mg(r)?r+1:`${r}+1`)}else n.push(1);for(let t of[`hours`,`minutes`,`seconds`,`milliseconds`]){let r=e[t];n.push(r===void 0?0:r)}return n}function P$(e){let t=N$(e,!0).join(`, `);return e.utc?`utc(${t})`:`datetime(${t})`}function Gke(e){let t=N$(e,!1).join(`, `);return e.utc?`utc(${t})`:`datetime(${t})`}function Kke(e){let t=N$(e,!0);return e.utc?+new Date(Date.UTC(...t)):+new Date(...t)}function qke(e){return sg(U4,e)}function F$(e){return gh(e)?e.binned:Jke(e)}function Jke(e){return e?.startsWith(`binned`)}function I$(e){return e.startsWith(`utc`)}function Yke(e){return e.substring(3)}function L$(e){return W4.filter(t=>Zke(e,t))}function Xke(e){let t=L$(e);return t[t.length-1]}function Zke(e,t){let n=e.indexOf(t);return!(n<0||n>0&&t===`seconds`&&e.charAt(n-1)===`i`||e.length>n+3&&t===`day`&&e.charAt(n+3)===`o`||n>0&&t===`year`&&e.charAt(n-1)===`f`)}function Qke(e,t,{end:n}={end:!1}){let r=eQ(t),i=I$(e)?`utc`:``;function a(e){return e===`quarter`?`(${i}quarter(${r})-1)`:`${i}${e}(${r})`}let o,s={};for(let t of W4)Zke(e,t)&&(s[t]=a(t),o=t);return n&&(s[o]+=`+1`),Gke(s)}function $ke(e){if(e)return`timeUnitSpecifier(${hQ(L$(e))}, ${hQ(ORe)})`}function eAe(e,t,n){if(!e)return;let r=$ke(e);return`${n||I$(e)?`utc`:`time`}Format(${t}, ${r})`}function R$(e){if(!e)return;let t;return gg(e)?t=Jke(e)?{unit:e.substring(6),binned:!0}:{unit:e}:gh(e)&&(t={...e,...e.unit?{unit:e.unit}:{}}),I$(t.unit)&&(t.utc=!0,t.unit=Yke(t.unit)),t}function tAe(e){let{utc:t,...n}=R$(e);return n.unit?(t?`utc`:``)+$(n).map(e=>XZ(`${e===`unit`?``:`_${e}_`}${n[e]}`)).join(``):`${t?`utc`:``}timeunit${$(n).map(e=>XZ(`_${e}_${n[e]}`)).join(``)}`}function nAe(e,t=e=>e){let n=R$(e),r=Xke(n.unit);if(r&&r!==`day`){let e={year:2001,month:1,date:1,hours:0,minutes:0,seconds:0,milliseconds:0},{step:i,part:a}=iAe(r,n.step);return`${t(P$({...e,[a]:+e[a]+i}))} - ${t(P$(e))}`}}function rAe(e){return sg(kRe,e)}function iAe(e,t=1){if(rAe(e))return{part:e,step:t};switch(e){case`day`:case`dayofyear`:return{part:`date`,step:t};case`quarter`:return{part:`month`,step:t*3};case`week`:return{part:`date`,step:t*7}}}function aAe(e){return Y(e,`param`)}function z$(e){return!!e?.field&&e.equal!==void 0}function B$(e){return!!e?.field&&e.lt!==void 0}function V$(e){return!!e?.field&&e.lte!==void 0}function H$(e){return!!e?.field&&e.gt!==void 0}function U$(e){return!!e?.field&&e.gte!==void 0}function W$(e){return!!(e?.field&&(H(e.range)&&e.range.length===2||JQ(e.range)))}function G$(e){return!!e?.field&&(H(e.oneOf)||H(e.in))}function oAe(e){return!!e?.field&&e.valid!==void 0}function sAe(e){return G$(e)||z$(e)||W$(e)||B$(e)||H$(e)||V$(e)||U$(e)}function K$(e,t){return W1(e,{timeUnit:t,wrapTime:!0})}function cAe(e,t){return e.map(e=>K$(e,t))}function lAe(e,t=!0){let{field:n}=e,{unit:r,binned:i}=R$(e.timeUnit)||{},a=Q(e,{expr:`datum`}),o=r?`time(${i?a:Qke(r,n)})`:a;if(z$(e))return`${o}===${K$(e.equal,r)}`;if(B$(e)){let t=e.lt;return`${o}<${K$(t,r)}`}else if(H$(e)){let t=e.gt;return`${o}>${K$(t,r)}`}else if(V$(e)){let t=e.lte;return`${o}<=${K$(t,r)}`}else if(U$(e)){let t=e.gte;return`${o}>=${K$(t,r)}`}else if(G$(e))return`indexof([${cAe(e.oneOf,r).join(`,`)}], ${o}) !== -1`;else if(oAe(e))return q$(o,e.valid);else if(W$(e)){let{range:n}=GQ(e),i=JQ(n)?{signal:`${n.signal}[0]`}:n[0],a=JQ(n)?{signal:`${n.signal}[1]`}:n[1];if(i!==null&&a!==null&&t)return`inrange(${o}, [${K$(i,r)}, ${K$(a,r)}])`;let s=[];return i!==null&&s.push(`${o} >= ${K$(i,r)}`),a!==null&&s.push(`${o} <= ${K$(a,r)}`),s.length>0?s.join(` && `):`true`}throw Error(`Invalid field predicate: ${hQ(e)}`)}function q$(e,t=!0){return t?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function uAe(e){return sAe(e)&&e.timeUnit?{...e,timeUnit:R$(e.timeUnit)}:e}function dAe(e){return e===`quantitative`||e===`temporal`}function J$(e){return e===`ordinal`||e===`nominal`}function fAe(e){if(e)switch(e=e.toLowerCase(),e){case`q`:case K4:return`quantitative`;case`t`:case J4:return`temporal`;case`o`:case q4:return`ordinal`;case`n`:case Y4:return`nominal`;case X4:return`geojson`}}function pAe(e,t){let n=Q4[e],r=Q4[t];return n===r||n===`ordinal-position`&&r===`time`||r===`ordinal-position`&&n===`time`}function mAe(e){return ARe[e]}function hAe(e){return $4.has(e)}function Y$(e){return MRe.has(e)}function X$(e){return jRe.has(e)}function Z$(e){return e3.has(e)}function Q$(e){return t3.has(e)}function gAe(e){return!gg(e)&&Y(e,`name`)}function _Ae(e){return Y(e,`param`)}function vAe(e){return Y(e,`unionWith`)}function yAe(e){return gh(e)&&`field`in e}function $$(e,t){switch(t){case`type`:case`domain`:case`reverse`:case`range`:return!0;case`scheme`:case`interpolate`:return![`point`,`band`,`identity`].includes(e);case`bins`:return![`point`,`band`,`identity`,`ordinal`].includes(e);case`round`:return Z$(e)||e===`band`||e===`point`;case`padding`:case`rangeMin`:case`rangeMax`:return Z$(e)||[`point`,`band`].includes(e);case`paddingOuter`:case`align`:return[`point`,`band`].includes(e);case`paddingInner`:return e===`band`;case`domainMax`:case`domainMid`:case`domainMin`:case`domainRaw`:case`clamp`:return Z$(e);case`nice`:return Z$(e)||e===`quantize`||e===`threshold`;case`exponent`:return e===`pow`;case`base`:return e===`log`;case`constant`:return e===`symlog`;case`zero`:return X$(e)&&!RZ([`log`,`time`,`utc`,`threshold`,`quantile`],e)}}function bAe(e,t){switch(t){case`interpolate`:case`scheme`:case`domainMid`:return yQ(e)?void 0:hke(t);case`align`:case`type`:case`bins`:case`domain`:case`domainMax`:case`domainMin`:case`domainRaw`:case`range`:case`base`:case`exponent`:case`constant`:case`nice`:case`padding`:case`paddingInner`:case`paddingOuter`:case`rangeMax`:case`rangeMin`:case`reverse`:case`round`:case`clamp`:case`zero`:return}}function xAe(e,t){return RZ([q4,Y4],t)?e===void 0||Y$(e):t===J4?RZ([Z4.TIME,Z4.UTC,void 0],e):t!==K4||hAe(e)||Q$(e)||e===void 0}function SAe(e,t,n=!1){if(!MQ(e))return!1;switch(e){case V2:case H2:case G2:case K2:case Y2:case q2:return Z$(t)?!0:t===`band`||t===`point`&&!n;case t4:return RZ([`linear`,`band`],t);case o4:case d4:case c4:case l4:case u4:case s4:return Z$(t)||Q$(t)||RZ([`band`,`point`,`ordinal`],t);case n4:case r4:case i4:return t!==`band`;case f4:case a4:return t===`ordinal`||Q$(t)}}function CAe(e){return gh(e)&&`value`in e}function e1(e){return[`line`,`area`,`trail`].includes(e)}function t1(e){return[`rect`,`bar`,`image`,`arc`,`tick`].includes(e)}function n1(e){return Y(e,`type`)}function r1(e){return Y(e,`band`)}function wAe(e){return n1(e)?e.type:e}function TAe(e,{isPath:t}){return e===void 0||e===`break-paths-show-path-domains`?t?`break-paths-show-domains`:`filter`:e===null?`show`:e}function i1({markDef:e,config:t,scaleChannel:n,scaleType:r,isCountAggregate:i}){if(!r||!X$(r)||i)return`always-valid`;let a=TAe(a$(`invalid`,e,t),{isPath:e1(e.type)});return t.scale?.invalid?.[n]===void 0?a:`show`}function EAe(e){return e===`break-paths-filter-domains`||e===`break-paths-show-domains`}function DAe({scaleName:e,scale:t,mode:n}){let r=`domain('${e}')`;if(!t||!e)return;let i=`${r}[0]`,a=`peek(${r})`,o=t.domainHasZero();return o===`definitely`?{scale:e,value:0}:o===`maybe`?{signal:`scale('${e}', inrange(0, ${r}) ? 0 : ${n===`zeroOrMin`?i:a})`}:{signal:`scale('${e}', ${n===`zeroOrMin`?i:a})`}}function OAe({scaleChannel:e,channelDef:t,scale:n,scaleName:r,markDef:i,config:a}){let o=n?.get(`type`),s=R1(t),c=i1({scaleChannel:e,markDef:i,config:a,scaleType:o,isCountAggregate:LQ(s?.aggregate)});if(s&&c===`show`){let t=a.scale.invalid?.[e]??`zero-or-min`;return{test:q$(Q(s,{expr:`datum`}),!1),...kAe(t,n,r)}}}function kAe(e,t,n){if(CAe(e)){let{value:t}=e;return JQ(t)?{signal:t.signal}:{value:t}}return DAe({scale:t,scaleName:n,mode:`zeroOrMin`})}function a1(e){let{channel:t,channelDef:n,markDef:r,scale:i,scaleName:a,config:o}=e,s=SQ(t),c=c1(e),l=OAe({scaleChannel:s,channelDef:n,scale:i,scaleName:a,markDef:r,config:o});return l===void 0?c:[l,c]}function AAe(e){let{datum:t}=e;return M$(t)?P$(t):`${hQ(t)}`}function o1(e,t,n,r){let i={};if(t&&(i.scale=t),T1(e)){let{datum:t}=e;M$(t)?i.signal=P$(t):JQ(t)?i.signal=t.signal:WQ(t)?i.signal=t.expr:i.value=t}else i.field=Q(e,n);if(r){let{offset:e,band:t}=r;e&&(i.offset=e),t&&(i.band=t)}return i}function s1({scaleName:e,fieldOrDatumDef:t,fieldOrDatumDef2:n,offset:r,startSuffix:i,endSuffix:a=`end`,bandPosition:o=.5}){let s=!JQ(o)&&0{let r=W1(t,{timeUnit:Z(e)&&!F$(e.timeUnit)?e.timeUnit:void 0,type:n,undefinedIfExprNotRequired:!0});return r===void 0?t:{signal:r}})}function G1(e,t){return zQ(e.bin)?MQ(t)&&[`ordinal`,`nominal`].includes(e.type):(console.warn(`Only call this method for binned field defs.`),!1)}function K1(e){return e?.condition}function pje(e){return sg(nze,e)}function q1(e){return Y(e,`mark`)}function J1(e,t){let n=e?.[t];return n?H(n)?zZ(n,e=>!!e.field):Z(n)||S1(n):!1}function mje(e,t){let n=e?.[t];return n?H(n)?zZ(n,e=>!!e.field):Z(n)||T1(n)||C1(n):!1}function hje(e,t){if(OQ(t)){let n=e[t];if((Z(n)||T1(n))&&(J$(n.type)||Z(n)&&n.timeUnit))return mje(e,DQ(t))}return!1}function gje(e){return zZ(vLe,t=>{if(J1(e,t)){let n=e[t];if(H(n))return zZ(n,e=>!!e.aggregate);{let e=R1(n);return e&&!!e.aggregate}}return!1})}function _je(e,t){let n=[],r=[],i=[],a=[],o={};return X1(e,(s,c)=>{if(Z(s)){let{field:l,aggregate:u,bin:d,timeUnit:f,...p}=s;if(u||f||d){let e=F1(s)?.title,m=Q(s,{forAs:!0}),h={...e?[]:{title:P1(s,t,{allowDisabling:!0})},...p,field:m};if(u){let e;if(FQ(u)?(e=`argmax`,m=Q({op:`argmax`,field:u.argmax},{forAs:!0}),h.field=`${m}.${l}`):PQ(u)?(e=`argmin`,m=Q({op:`argmin`,field:u.argmin},{forAs:!0}),h.field=`${m}.${l}`):u!==`boxplot`&&u!==`errorbar`&&u!==`errorband`&&(e=u),e){let t={op:e,as:m};l&&(t.field=l),a.push(t)}}else if(n.push(m),k1(s)&&zQ(d)){if(r.push({bin:d,field:l,as:m}),n.push(Q(s,{binSuffix:`end`})),G1(s,c)&&n.push(Q(s,{binSuffix:`range`})),OQ(c)){let e={field:`${m}_end`};o[`${c}2`]=e}h.bin=`binned`,xQ(c)||(h.type=K4)}else if(f&&!F$(f)){i.push({timeUnit:f,field:l,as:m});let e=k1(s)&&s.type!==J4&&`time`;e&&(c===p4||c===_4?h.formatType=e:ROe(c)?h.legend={formatType:e,...h.legend}:OQ(c)&&(h.axis={formatType:e,...h.axis}))}o[c]=h}else n.push(l),o[c]=e[c]}else o[c]=e[c]}),{bins:r,timeUnits:i,aggregate:a,groupby:n,encoding:o}}function vje(e,t,n){let r=BOe(t,n);if(!r)return!1;if(r===`binned`){let n=e[t===U2?V2:H2];return!!(Z(n)&&Z(e[t])&&BQ(n.bin))}return!0}function yje(e,t,n,r){let i={};for(let t of $(e))bQ(t)||X(cke(t));for(let a of OLe){if(!e[a])continue;let o=e[a];if(AQ(a)){let e=LOe(a),t=i[e];if(Z(t)&&dAe(t.type)&&Z(o)&&!t.timeUnit){X(rke(e));continue}}if(a===`angle`&&t===`arc`&&!e.theta&&(X(xRe),a=Y2),!vje(e,a,t)){X(E$(a,t));continue}if(a===o4&&t===`line`&&R1(e[a])?.aggregate){X(SRe);continue}if(a===n4&&(n?`fill`in e:`stroke`in e)){X(w$(`encoding`,{fill:`fill`in e,stroke:`stroke`in e}));continue}if(a===h4||a===m4&&!H(o)&&!A1(o)||a===_4&&H(o)){if(o){if(a===m4){let t=e[a];if(JAe(t)){i[a]=t;continue}}i[a]=Gh(o).reduce((e,t)=>(Z(t)?e.push(V1(t,a)):X(T$(t,a)),e),[])}}else{if(a===_4&&o===null)i[a]=null;else if(!Z(o)&&!T1(o)&&!A1(o)&&!x1(o)&&!JQ(o)){X(T$(o,a));continue}i[a]=cje(o,a,r)}}return i}function Y1(e,t){let n={};for(let r of $(e))n[r]=cje(e[r],r,t,{compositeMark:!0});return n}function bje(e){let t=[];for(let n of $(e))if(J1(e,n)){let r=e[n],i=Gh(r);for(let e of i)Z(e)?t.push(e):S1(e)&&t.push(e.condition)}return t}function X1(e,t,n){if(e)for(let r of $(e)){let i=e[r];if(H(i))for(let e of i)t.call(n,e,r);else t.call(n,i,r)}}function xje(e,t,n,r){return e?$(e).reduce((n,i)=>{let a=e[i];return H(a)?a.reduce((e,n)=>t.call(r,e,n,i),n):t.call(r,n,a,i)},n):n}function Sje(e,t){return $(t).reduce((n,r)=>{switch(r){case V2:case H2:case v4:case b4:case y4:case U2:case W2:return n;case G2:case K2:if(e===`line`||e===`area`||e===`trail`){let e=t[r];if(Z(e)){let i=t[r===G2?V2:H2];if(Z(i)&&!i.aggregate&&!e.aggregate){let t=Q(i,{}),r=Q(e,{});t&&r&&t!==r&&n.push(t)}}}return n;case Y2:case X2:case q2:case J2:case t4:case Z2:case Q2:case $2:case e4:case p4:case a4:case s4:case _4:return n;case m4:if(e===`line`||e===`trail`)return n;case h4:case g4:{let e=t[r];if(H(e)||Z(e))for(let t of Gh(e))t.aggregate||n.push(Q(t,{}));return n}case o4:if(e===`trail`)return n;case n4:case r4:case i4:case c4:case l4:case u4:case f4:case d4:{let e=R1(t[r]);return e&&!e.aggregate&&n.push(Q(e,{})),n}}},[])}function Cje(e){let{tooltip:t,...n}=e;if(!t)return{filteredEncoding:n};let r,i;if(H(t)){for(let e of t)e.aggregate?(r||=[],r.push(e)):(i||=[],i.push(e));r&&(n.tooltip=r)}else t.aggregate?n.tooltip=t:i=t;return H(i)&&i.length===1&&(i=i[0]),{customTooltipWithoutAggregatedField:i,filteredEncoding:n}}function Z1(e,t,n,r=!0){if(`tooltip`in n)return{tooltip:n.tooltip};let i=e.map(({fieldPrefix:e,titlePrefix:n})=>{let i=r?` of ${Q1(t)}`:``;return{field:e+t.field,type:t.type,title:JQ(n)?{signal:`${n}"${escape(i)}"`}:n+i}}),a=bje(n).map($Ae);return{tooltip:[...i,...HZ(a,IZ)]}}function Q1(e){let{title:t,field:n}=e;return cQ(t,n)}function $1(e,t,n,r,i){let{scale:a,axis:o}=n;return({partName:s,mark:c,positionPrefix:l,endPositionPrefix:u=void 0,extraEncoding:d={}})=>{let f=Q1(n);return wje(e,s,i,{mark:c,encoding:{[t]:{field:`${l}_${n.field}`,type:n.type,...f===void 0?{}:{title:f},...a===void 0?{}:{scale:a},...o===void 0?{}:{axis:o}},...gg(u)?{[`${t}2`]:{field:`${u}_${n.field}`}}:{},...r,...d}})}}function wje(e,t,n,r){let{clip:i,color:a,opacity:o}=e,s=e.type;return e[t]||e[t]===void 0&&n[t]?[{...r,mark:{...n[t],...i?{clip:i}:{},...a?{color:a}:{},...o?{opacity:o}:{},...n1(r.mark)?r.mark:{type:r.mark},style:`${s}-${String(t)}`,...fg(e[t])?{}:e[t]}}]:[]}function Tje(e,t,n){let{encoding:r}=e,i=t===`vertical`?`y`:`x`,a=r[i],o=r[`${i}2`],s=r[`${i}Error`],c=r[`${i}Error2`];return{continuousAxisChannelDef:e0(a,n),continuousAxisChannelDef2:e0(o,n),continuousAxisChannelDefError:e0(s,n),continuousAxisChannelDefError2:e0(c,n),continuousAxis:i}}function e0(e,t){if(e?.aggregate){let{aggregate:n,...r}=e;return n!==t&&X(Pke(n,t)),r}else return e}function Eje(e,t){let{mark:n,encoding:r}=e,{x:i,y:a}=r;if(n1(n)&&n.orient)return n.orient;if(E1(i)){if(E1(a)){let e=Z(i)&&i.aggregate,n=Z(a)&&a.aggregate;if(!e&&n===t)return`vertical`;if(!n&&e===t)return`horizontal`;if(e===t&&n===t)throw Error(`Both x and y cannot have aggregate`);return U1(a)&&!U1(i)?`horizontal`:`vertical`}return`horizontal`}else if(E1(a))return`vertical`;else throw Error(`Need a valid continuous axis for ${t}s`)}function Dje(e){return mg(e)?`tukey`:e}function Oje(e,{config:t}){e={...e,encoding:Y1(e.encoding,t)};let{mark:n,encoding:r,params:i,projection:a,...o}=e,s=n1(n)?n:{type:n};i&&X(y$(`boxplot`));let c=s.extent??t.boxplot.extent,l=a$(`size`,s,t),u=s.invalid,d=Dje(c),{bins:f,timeUnits:p,transform:m,continuousAxisChannelDef:h,continuousAxis:g,groupby:_,aggregate:v,encodingWithoutContinuousAxis:y,ticksOrient:b,boxOrient:x,customTooltipWithoutAggregatedField:S}=Aje(e,c,t),C=oQ(h.field),{color:w,size:T,...E}=y,D=e=>$1(s,g,h,e,t.boxplot),O=D(E),k=D(y),A=(gh(t.boxplot.box)?t.boxplot.box.color:t.mark.color)||`#4c78a8`,j=D({...E,...T?{size:T}:{},color:{condition:{test:`${nQ(`lower_box_${h.field}`)} >= ${nQ(`upper_box_${h.field}`)}`,...w||{value:A}}}}),M=Z1([{fieldPrefix:d===`min-max`?`upper_whisker_`:`max_`,titlePrefix:`Max`},{fieldPrefix:`upper_box_`,titlePrefix:`Q3`},{fieldPrefix:`mid_box_`,titlePrefix:`Median`},{fieldPrefix:`lower_box_`,titlePrefix:`Q1`},{fieldPrefix:d===`min-max`?`lower_whisker_`:`min_`,titlePrefix:`Min`}],h,y),ee={type:`tick`,color:`black`,opacity:1,orient:b,invalid:u,aria:!1},N=d===`min-max`?M:Z1([{fieldPrefix:`upper_whisker_`,titlePrefix:`Upper Whisker`},{fieldPrefix:`lower_whisker_`,titlePrefix:`Lower Whisker`}],h,y),te=[...O({partName:`rule`,mark:{type:`rule`,invalid:u,aria:!1},positionPrefix:`lower_whisker`,endPositionPrefix:`lower_box`,extraEncoding:N}),...O({partName:`rule`,mark:{type:`rule`,invalid:u,aria:!1},positionPrefix:`upper_box`,endPositionPrefix:`upper_whisker`,extraEncoding:N}),...O({partName:`ticks`,mark:ee,positionPrefix:`lower_whisker`,extraEncoding:N}),...O({partName:`ticks`,mark:ee,positionPrefix:`upper_whisker`,extraEncoding:N})],ne=[...d===`tukey`?[]:te,...k({partName:`box`,mark:{type:`bar`,...l?{size:l}:{},orient:x,invalid:u,ariaRoleDescription:`box`},positionPrefix:`lower_box`,endPositionPrefix:`upper_box`,extraEncoding:M}),...j({partName:`median`,mark:{type:`tick`,invalid:u,...gh(t.boxplot.median)&&t.boxplot.median.color?{color:t.boxplot.median.color}:{},...l?{size:l}:{},orient:b,aria:!1},positionPrefix:`mid_box`,extraEncoding:M})];if(d===`min-max`)return{...o,transform:(o.transform??[]).concat(m),layer:ne};let P=nQ(`lower_box_${h.field}`),re=nQ(`upper_box_${h.field}`),F=`(${re} - ${P})`,ie=`${P} - ${c} * ${F}`,ae=`${re} + ${c} * ${F}`,oe=nQ(h.field),se={joinaggregate:kje(h.field),groupby:_},ce={transform:[{filter:`(${ie} <= ${oe}) && (${oe} <= ${ae})`},{aggregate:[{op:`min`,field:h.field,as:`lower_whisker_${C}`},{op:`max`,field:h.field,as:`upper_whisker_${C}`},{op:`min`,field:`lower_box_${h.field}`,as:`lower_box_${C}`},{op:`max`,field:`upper_box_${h.field}`,as:`upper_box_${C}`},...v],groupby:_}],layer:te},{tooltip:le,...ue}=E,{scale:de,axis:fe}=h,pe=Q1(h),me=wje(s,`outliers`,t.boxplot,{transform:[{filter:`(${oe} < ${ie}) || (${oe} > ${ae})`}],mark:`point`,encoding:{[g]:{field:h.field,type:h.type,...pe===void 0?{}:{title:pe},...de===void 0?{}:{scale:de},...fe===void 0?{}:{axis:fe}},...ue,...w?{color:w}:{},...S?{tooltip:S}:{}}})[0],he,ge=[...f,...p,se];return me?he={transform:ge,layer:[me,ce]}:(he=ce,he.transform.unshift(...ge)),{...o,layer:[he,{transform:m,layer:ne}]}}function kje(e){let t=oQ(e);return[{op:`q1`,field:e,as:`lower_box_${t}`},{op:`q3`,field:e,as:`upper_box_${t}`}]}function Aje(e,t,n){let r=Eje(e,D3),{continuousAxisChannelDef:i,continuousAxis:a}=Tje(e,r,D3),o=i.field,s=oQ(o),c=Dje(t),l=[...kje(o),{op:`median`,field:o,as:`mid_box_${s}`},{op:`min`,field:o,as:(c===`min-max`?`lower_whisker_`:`min_`)+s},{op:`max`,field:o,as:(c===`min-max`?`upper_whisker_`:`max_`)+s}],u=c===`min-max`||c===`tukey`?[]:[{calculate:`${nQ(`upper_box_${s}`)} - ${nQ(`lower_box_${s}`)}`,as:`iqr_${s}`},{calculate:`min(${nQ(`upper_box_${s}`)} + ${nQ(`iqr_${s}`)} * ${t}, ${nQ(`max_${s}`)})`,as:`upper_whisker_${s}`},{calculate:`max(${nQ(`lower_box_${s}`)} - ${nQ(`iqr_${s}`)} * ${t}, ${nQ(`min_${s}`)})`,as:`lower_whisker_${s}`}],{[a]:d,...f}=e.encoding,{customTooltipWithoutAggregatedField:p,filteredEncoding:m}=Cje(f),{bins:h,timeUnits:g,aggregate:_,groupby:v,encoding:y}=_je(m,n),b=r===`vertical`?`horizontal`:`vertical`,x=r;return{bins:h,timeUnits:g,transform:[...h,...g,{aggregate:[..._,...l],groupby:v},...u],groupby:v,aggregate:_,continuousAxisChannelDef:i,continuousAxis:a,encodingWithoutContinuousAxis:y,ticksOrient:b,boxOrient:x,customTooltipWithoutAggregatedField:p}}function jje(e,{config:t}){e={...e,encoding:Y1(e.encoding,t)};let{transform:n,continuousAxisChannelDef:r,continuousAxis:i,encodingWithoutContinuousAxis:a,ticksOrient:o,markDef:s,outerSpec:c,tooltipEncoding:l}=Ije(e,O3,t);delete a.size;let u=$1(s,i,r,a,t.errorbar),d=s.thickness,f=s.size,p={type:`tick`,orient:o,aria:!1,...d===void 0?{}:{thickness:d},...f===void 0?{}:{size:f}},m=[...u({partName:`ticks`,mark:p,positionPrefix:`lower`,extraEncoding:l}),...u({partName:`ticks`,mark:p,positionPrefix:`upper`,extraEncoding:l}),...u({partName:`rule`,mark:{type:`rule`,ariaRoleDescription:`errorbar`,...d===void 0?{}:{size:d}},positionPrefix:`lower`,endPositionPrefix:`upper`,extraEncoding:l})];return{...c,transform:n,...m.length>1?{layer:m}:{...m[0]}}}function Mje(e,t){let{encoding:n}=e;if(Nje(n))return{orient:Eje(e,t),inputType:`raw`};let r=Pje(n),i=Fje(n),a=n.x,o=n.y;if(r){if(i)throw Error(`${t} cannot be both type aggregated-upper-lower and aggregated-error`);let e=n.x2,r=n.y2;if(O1(e)&&O1(r))throw Error(`${t} cannot have both x2 and y2`);if(O1(e)){if(E1(a))return{orient:`horizontal`,inputType:`aggregated-upper-lower`};throw Error(`Both x and x2 have to be quantitative in ${t}`)}else if(O1(r)){if(E1(o))return{orient:`vertical`,inputType:`aggregated-upper-lower`};throw Error(`Both y and y2 have to be quantitative in ${t}`)}throw Error(`No ranged axis`)}else{let e=n.xError,r=n.xError2,i=n.yError,s=n.yError2;if(O1(r)&&!O1(e))throw Error(`${t} cannot have xError2 without xError`);if(O1(s)&&!O1(i))throw Error(`${t} cannot have yError2 without yError`);if(O1(e)&&O1(i))throw Error(`${t} cannot have both xError and yError with both are quantiative`);if(O1(e)){if(E1(a))return{orient:`horizontal`,inputType:`aggregated-error`};throw Error(`All x, xError, and xError2 (if exist) have to be quantitative`)}else if(O1(i)){if(E1(o))return{orient:`vertical`,inputType:`aggregated-error`};throw Error(`All y, yError, and yError2 (if exist) have to be quantitative`)}throw Error(`No ranged axis`)}}function Nje(e){return(O1(e.x)||O1(e.y))&&!O1(e.x2)&&!O1(e.y2)&&!O1(e.xError)&&!O1(e.xError2)&&!O1(e.yError)&&!O1(e.yError2)}function Pje(e){return O1(e.x2)||O1(e.y2)}function Fje(e){return O1(e.xError)||O1(e.xError2)||O1(e.yError)||O1(e.yError2)}function Ije(e,t,n){let{mark:r,encoding:i,params:a,projection:o,...s}=e,c=n1(r)?r:{type:r};a&&X(y$(t));let{orient:l,inputType:u}=Mje(e,t),{continuousAxisChannelDef:d,continuousAxisChannelDef2:f,continuousAxisChannelDefError:p,continuousAxisChannelDefError2:m,continuousAxis:h}=Tje(e,l,t),{errorBarSpecificAggregate:g,postAggregateCalculates:_,tooltipSummary:v,tooltipTitleWithFieldName:y}=Lje(c,d,f,p,m,u,t,n),{[h]:b,[h===`x`?`x2`:`y2`]:x,[h===`x`?`xError`:`yError`]:S,[h===`x`?`xError2`:`yError2`]:C,...w}=i,{bins:T,timeUnits:E,aggregate:D,groupby:O,encoding:k}=_je(w,n),A=[...D,...g],j=u===`raw`?O:[],M=Z1(v,d,k,y);return{transform:[...s.transform??[],...T,...E,...A.length===0?[]:[{aggregate:A,groupby:j}],..._],groupby:j,continuousAxisChannelDef:d,continuousAxis:h,encodingWithoutContinuousAxis:k,ticksOrient:l===`vertical`?`horizontal`:`vertical`,markDef:c,outerSpec:s,tooltipEncoding:M}}function Lje(e,t,n,r,i,a,o,s){let c=[],l=[],u=t.field,d,f=!1;if(a===`raw`){let t=e.center?e.center:e.extent?e.extent===`iqr`?`median`:`mean`:s.errorbar.center,n=e.extent?e.extent:t===`mean`?`stderr`:`iqr`;if(t===`median`!=(n===`iqr`)&&X(Nke(t,n,o)),n===`stderr`||n===`stdev`)c=[{op:n,field:u,as:`extent_${u}`},{op:t,field:u,as:`center_${u}`}],l=[{calculate:`${nQ(`center_${u}`)} + ${nQ(`extent_${u}`)}`,as:`upper_${u}`},{calculate:`${nQ(`center_${u}`)} - ${nQ(`extent_${u}`)}`,as:`lower_${u}`}],d=[{fieldPrefix:`center_`,titlePrefix:$Z(t)},{fieldPrefix:`upper_`,titlePrefix:Rje(t,n,`+`)},{fieldPrefix:`lower_`,titlePrefix:Rje(t,n,`-`)}],f=!0;else{let e,t,r;n===`ci`?(e=`mean`,t=`ci0`,r=`ci1`):(e=`median`,t=`q1`,r=`q3`),c=[{op:t,field:u,as:`lower_${u}`},{op:r,field:u,as:`upper_${u}`},{op:e,field:u,as:`center_${u}`}],d=[{fieldPrefix:`upper_`,titlePrefix:P1({field:u,aggregate:r,type:`quantitative`},s,{allowDisabling:!1})},{fieldPrefix:`lower_`,titlePrefix:P1({field:u,aggregate:t,type:`quantitative`},s,{allowDisabling:!1})},{fieldPrefix:`center_`,titlePrefix:P1({field:u,aggregate:e,type:`quantitative`},s,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&X(Mke(e.center,e.extent)),a===`aggregated-upper-lower`?(d=[],l=[{calculate:nQ(n.field),as:`upper_${u}`},{calculate:nQ(u),as:`lower_${u}`}]):a===`aggregated-error`&&(d=[{fieldPrefix:``,titlePrefix:u}],l=[{calculate:`${nQ(u)} + ${nQ(r.field)}`,as:`upper_${u}`}],i?l.push({calculate:`${nQ(u)} + ${nQ(i.field)}`,as:`lower_${u}`}):l.push({calculate:`${nQ(u)} - ${nQ(r.field)}`,as:`lower_${u}`}));for(let e of l)d.push({fieldPrefix:e.as.substring(0,6),titlePrefix:aQ(aQ(e.calculate,`datum['`,``),`']`,``)})}return{postAggregateCalculates:l,errorBarSpecificAggregate:c,tooltipSummary:d,tooltipTitleWithFieldName:f}}function Rje(e,t,n){return`${$Z(e)} ${n} ${t}`}function zje(e,{config:t}){e={...e,encoding:Y1(e.encoding,t)};let{transform:n,continuousAxisChannelDef:r,continuousAxis:i,encodingWithoutContinuousAxis:a,markDef:o,outerSpec:s,tooltipEncoding:c}=Ije(e,k3,t),l=o,u=$1(l,i,r,a,t.errorband),d=e.encoding.x!==void 0&&e.encoding.y!==void 0,f={type:d?`area`:`rect`},p={type:d?`line`:`rule`},m={...l.interpolate?{interpolate:l.interpolate}:{},...l.tension&&l.interpolate?{tension:l.tension}:{}};return d?(f={...f,...m,ariaRoleDescription:`errorband`},p={...p,...m,aria:!1}):l.interpolate?X(Fke(`interpolate`)):l.tension&&X(Fke(`tension`)),{...s,transform:n,layer:[...u({partName:`band`,mark:f,positionPrefix:`lower`,endPositionPrefix:`upper`,extraEncoding:c}),...u({partName:`borders`,mark:p,positionPrefix:`lower`,extraEncoding:c}),...u({partName:`borders`,mark:p,positionPrefix:`upper`,extraEncoding:c})]}}function t0(e,t,n){let r=new E3(e,t);A3[e]={normalizer:r,parts:n}}function Bje(){return $(A3)}function n0(e){return e===`legend`||!!e?.legend}function r0(e){return n0(e)&&gh(e)}function i0(e){return!!e?.select}function Vje(e){let t=[];for(let n of e||[]){if(i0(n))continue;let{expr:e,bind:r,...i}=n;if(r&&e){let n={...i,bind:r,init:e};t.push(n)}else{let n={...i,...e?{update:e}:{},...r?{bind:r}:{}};t.push(n)}}return t}function Hje(e){return o0(e)||s0(e)||a0(e)}function a0(e){return Y(e,`concat`)}function o0(e){return Y(e,`vconcat`)}function s0(e){return Y(e,`hconcat`)}function Uje({step:e,offsetIsDiscrete:t}){return t?e.for??`offset`:`position`}function c0(e){return Y(e,`step`)}function Wje(e){return Y(e,`view`)||Y(e,`width`)||Y(e,`height`)}function Gje(e,t,n){let r=n[t],i={},{spacing:a,columns:o}=r;a!==void 0&&(i.spacing=a),o!==void 0&&(v1(e)&&!g1(e.facet)||a0(e))&&(i.columns=o),o0(e)&&(i.columns=1);for(let t of hze)if(e[t]!==void 0)if(t===`spacing`){let n=e[t];i[t]=mg(n)?n:{row:n.row??a,column:n.column??a}}else i[t]=e[t];return i}function l0(e,t){return e[t]??e[t===`width`?`continuousWidth`:`continuousHeight`]}function u0(e,t){let n=d0(e,t);return c0(n)?n.step:L3}function d0(e,t){return cQ(e[t]??e[t===`width`?`discreteWidth`:`discreteHeight`],{step:e.step})}function Kje(e={}){return{signals:[{name:`color`,value:gh(e)?{...B3,...e}:B3}],mark:{color:{signal:`color.blue`}},rule:{color:{signal:`color.gray0`}},text:{color:{signal:`color.gray0`}},style:{"guide-label":{fill:{signal:`color.gray0`}},"guide-title":{fill:{signal:`color.gray0`}},"group-title":{fill:{signal:`color.gray0`}},"group-subtitle":{fill:{signal:`color.gray0`}},cell:{stroke:{signal:`color.gray8`}}},axis:{domainColor:{signal:`color.gray13`},gridColor:{signal:`color.gray8`},tickColor:{signal:`color.gray13`}},range:{category:[{signal:`color.blue`},{signal:`color.orange`},{signal:`color.red`},{signal:`color.teal`},{signal:`color.green`},{signal:`color.yellow`},{signal:`color.purple`},{signal:`color.pink`},{signal:`color.brown`},{signal:`color.grey8`}]}}}function qje(e){return{signals:[{name:`fontSize`,value:gh(e)?{...z3,...e}:z3}],text:{fontSize:{signal:`fontSize.text`}},style:{"guide-label":{fontSize:{signal:`fontSize.guideLabel`}},"guide-title":{fontSize:{signal:`fontSize.guideTitle`}},"group-title":{fontSize:{signal:`fontSize.groupTitle`}},"group-subtitle":{fontSize:{signal:`fontSize.groupSubtitle`}}}}}function Jje(e){return{text:{font:e},style:{"guide-label":{font:e},"guide-title":{font:e},"group-title":{font:e},"group-subtitle":{font:e}}}}function Yje(e){let t=$(e||{}),n={};for(let r of t){let t=e[r];n[r]=K1(t)?QQ(t):$Q(t)}return n}function Xje(e){let t=$(e),n={};for(let r of t)n[r]=Yje(e[r]);return n}function Zje(e={}){let{color:t,font:n,fontSize:r,selection:i,...a}=e,o=vh({},N2(gze),n?Jje(n):{},t?Kje(t):{},r?qje(r):{},a||{});i&&yh(o,`selection`,i,!0);let s=FZ(o,_ze);for(let e of[`background`,`lineBreak`,`padding`])o[e]&&(s[e]=$Q(o[e]));for(let e of g3)o[e]&&(s[e]=GQ(o[e]));for(let e of T3)o[e]&&(s[e]=Yje(o[e]));for(let e of N3)o[e]&&(s[e]=GQ(o[e]));if(o.legend&&(s.legend=GQ(o.legend)),o.scale){let{invalid:e,...t}=o.scale,n=GQ(e,{level:1});s.scale={...GQ(t),...$(n).length>0?{invalid:n}:{}}}return o.style&&(s.style=Xje(o.style)),o.title&&(s.title=GQ(o.title)),o.view&&(s.view=GQ(o.view)),s}function Qje(e){e=N2(e);for(let t of yze)delete e[t];if(e.axis)for(let t in e.axis)K1(e.axis[t])&&delete e.axis[t];if(e.legend)for(let t of lze)delete e.legend[t];if(e.mark){for(let t of m3)delete e.mark[t];e.mark.tooltip&&gh(e.mark.tooltip)&&delete e.mark.tooltip}e.params&&(e.signals=(e.signals||[]).concat(Vje(e.params)),delete e.params);for(let t of vze){for(let n of m3)delete e[t][n];let n=bze[t];if(n)for(let r of n)delete e[t][r];eMe(e,t)}for(let t of Bje())delete e[t];$je(e);for(let t in e)gh(e[t])&&qZ(e[t])&&delete e[t];return qZ(e)?void 0:e}function $je(e){let{titleMarkConfig:t,subtitleMarkConfig:n,subtitle:r}=KQ(e.title);qZ(t)||(e.style[`group-title`]={...e.style[`group-title`],...t}),qZ(n)||(e.style[`group-subtitle`]={...e.style[`group-subtitle`],...n}),qZ(r)?delete e.title:e.title=r}function eMe(e,t,n,r){let i=e[t];t===`view`&&(n=`cell`);let a={...i,...e.style[n??t]};qZ(a)||(e.style[n??t]=a),delete e[t]}function f0(e){return Y(e,`layer`)}function tMe(e){return Y(e,`repeat`)}function nMe(e){return!H(e.repeat)&&Y(e.repeat,`layer`)}function rMe(e){return sg(xze,e)}function p0(e){return Z(e)&&w1(e)===`quantitative`&&!e.bin}function iMe(e,t,{orient:n,type:r}){let i=t===`x`?`y`:`radius`,a=t===`x`&&[`bar`,`area`].includes(r),o=e[t],s=e[i];if(Z(o)&&Z(s)){if(p0(o)&&p0(s)){if(o.stack)return t;if(s.stack)return i;let e=Z(o)&&!!o.aggregate;if(e!==(Z(s)&&!!s.aggregate))return e?t:i;if(a){if(n===`vertical`)return i;if(n===`horizontal`)return t}}else if(p0(o))return t;else if(p0(s))return i}else if(p0(o))return a&&n===`vertical`?void 0:t;else if(p0(s))return a&&n===`horizontal`?void 0:i}function aMe(e){switch(e){case`x`:return`y`;case`y`:return`x`;case`theta`:return`radius`;case`radius`:return`theta`}}function oMe(e,t){let n=n1(e)?e:{type:e},r=n.type;if(!Sze.has(r))return null;let i=iMe(t,`x`,n)||iMe(t,`theta`,n);if(!i)return null;let a=t[i],o=Z(a)?Q(a,{}):void 0,s=aMe(i),c=[],l=new Set;if(t[s]){let e=t[s],n=Z(e)?Q(e,{}):void 0;n&&n!==o&&(c.push(s),l.add(n))}let u=s===`x`?`xOffset`:`yOffset`,d=t[u],f=Z(d)?Q(d,{}):void 0;f&&f!==o&&(c.push(u),l.add(f));let p=ULe.reduce((e,n)=>{if(n!==`tooltip`&&J1(t,n)){let r=t[n];for(let t of Gh(r)){let r=R1(t);if(r.aggregate)continue;let i=Q(r,{});(!i||!l.has(i))&&e.push({channel:n,fieldDef:r})}}return e},[]),m;return a.stack===void 0?Cze.has(r)&&(m=`zero`):m=fg(a.stack)?a.stack?`zero`:null:a.stack,!m||!rMe(m)||gje(t)&&p.length===0?null:(a?.scale?.type&&a?.scale?.type!==Z4.LINEAR&&a?.stack&&X(kke(a.scale.type)),O1(t[wQ(i)])?(a.stack!==void 0&&X(Oke(i)),null):(Z(a)&&a.aggregate&&!oRe.has(a.aggregate)&&X(Ake(a.aggregate)),{groupbyChannels:c,groupbyFields:l,fieldChannel:i,impute:a.impute!==null&&e1(r),stackBy:p,offset:m}))}function sMe(e,t,n){let r=GQ(e),i=a$(`orient`,r,n);if(r.orient=dMe(r.type,t,i),i!==void 0&&i!==r.orient&&X(mke(r.orient,i)),r.type===`bar`&&r.orient){let e=a$(`cornerRadiusEnd`,r,n);if(e!==void 0){let n=r.orient===`horizontal`&&t.x2||r.orient===`vertical`&&t.y2?[`cornerRadius`]:ZRe[r.orient];for(let t of n)r[t]=e;r.cornerRadiusEnd!==void 0&&delete r.cornerRadiusEnd}}let a=a$(`opacity`,r,n),o=a$(`fillOpacity`,r,n);return a===void 0&&o===void 0&&(r.opacity=lMe(r.type,t)),a$(`cursor`,r,n)===void 0&&(r.cursor=cMe(r,t,n)),r}function cMe(e,t,n){return t.href||e.href||a$(`href`,e,n)?`pointer`:e.cursor}function lMe(e,t){if(RZ([s3,u3,d3,f3],e)&&!gje(t))return H3}function uMe(e,t,{graticule:n}){if(n)return!1;let r=o$(`filled`,e,t),i=e.type;return cQ(r,i!==s3&&i!==o3&&i!==c3)}function dMe(e,t,n){switch(e){case s3:case d3:case f3:case URe:case HRe:return}let{x:r,y:i,x2:a,y2:o}=t;switch(e){case l3:case a3:if(Z(r)&&(BQ(r.bin)||Z(i)&&i.aggregate&&!r.aggregate))return`vertical`;if(Z(i)&&(BQ(i.bin)||Z(r)&&r.aggregate&&!i.aggregate))return`horizontal`;if(o||a){if(n)return n;if(!a)return(Z(r)&&r.type===K4&&!zQ(r.bin)||D1(r))&&Z(i)&&BQ(i.bin)?`horizontal`:`vertical`;if(!o)return(Z(i)&&i.type===K4&&!zQ(i.bin)||D1(i))&&Z(r)&&BQ(r.bin)?`vertical`:`horizontal`}case c3:if(a&&!(Z(r)&&BQ(r.bin))&&o&&!(Z(i)&&BQ(i.bin)))return;case i3:if(o)return Z(i)&&BQ(i.bin)?`horizontal`:`vertical`;if(a)return Z(r)&&BQ(r.bin)?`vertical`:`horizontal`;if(e===c3){if(r&&!i)return`vertical`;if(i&&!r)return`horizontal`}case o3:case u3:{let t=XAe(r),a=XAe(i);if(n)return n;if(t&&!a)return e===`tick`?`vertical`:`horizontal`;if(!t&&a)return e===`tick`?`horizontal`:`vertical`;if(t&&a)return`vertical`;{let e=k1(r)&&r.type===J4,t=k1(i)&&i.type===J4;if(e&&!t)return`vertical`;if(!e&&t)return`horizontal`}return}}return`vertical`}function fMe(e){let{point:t,line:n,...r}=e;return $(r).length>1?r:r.type}function pMe(e){for(let t of[`line`,`area`,`rule`,`trail`])e[t]&&(e={...e,[t]:FZ(e[t],[`point`,`line`])});return e}function m0(e,t={},n){return e.point===`transparent`?{opacity:0}:e.point?gh(e.point)?e.point:{}:e.point===void 0?t.point||n.shape?gh(t.point)?t.point:{}:void 0:null}function mMe(e,t={}){return e.line?e.line===!0?{}:e.line:e.line===void 0?t.line?t.line===!0?{}:t.line:void 0:null}function hMe(e,t){return t?g1(e)?yMe(e,t):gMe(e,t):e}function h0(e,t){return t?yMe(e,t):e}function g0(e,t,n){let r=t[e];if(WAe(r)){if(r.repeat in n)return{...t,[e]:n[r.repeat]};X(ZOe(r.repeat));return}return t}function gMe(e,t){if(e=g0(`field`,e,t),e!==void 0){if(e===null)return null;if(y1(e)&&h1(e.sort)){let n=g0(`field`,e.sort,t);e={...e,...n?{sort:n}:{}}}return e}}function _Me(e,t){if(Z(e))return gMe(e,t);{let n=g0(`datum`,e,t);return n!==e&&!n.type&&(n.type=`nominal`),n}}function vMe(e,t){if(O1(e)){let n=_Me(e,t);if(n)return n;if(x1(e))return{condition:e.condition}}else{if(C1(e)){let n=_Me(e.condition,t);if(n)return{...e,condition:n};{let{condition:t,...n}=e;return n}}return e}}function yMe(e,t){let n={};for(let r in e)if(Y(e,r)){let i=e[r];if(H(i))n[r]=i.map(e=>vMe(e,t)).filter(e=>e);else{let e=vMe(i,t);e!==void 0&&(n[r]=e)}}return n}function bMe({parentEncoding:e,encoding:t={},layer:n}){let r={};if(e){let i=new Set([...$(e),...$(t)]);for(let a of i){let i=t[a],o=e[a];if(O1(i)){let e={...o,...i};r[a]=e}else C1(i)?r[a]={...i,condition:{...o,...i.condition}}:i||i===null?r[a]=i:(n||A1(o)||JQ(o)||O1(o)||H(o))&&(r[a]=o)}}else r=t;return!r||qZ(r)?void 0:r}function xMe(e){let{parentProjection:t,projection:n}=e;return t&&n&&X(nke({parentProjection:t,projection:n})),n??t}function _0(e){return Y(e,`filter`)}function SMe(e){return Y(e,`stop`)}function CMe(e){return Y(e,`lookup`)}function wMe(e){return Y(e,`data`)}function TMe(e){return Y(e,`param`)}function EMe(e){return Y(e,`pivot`)}function DMe(e){return Y(e,`density`)}function OMe(e){return Y(e,`quantile`)}function kMe(e){return Y(e,`regression`)}function AMe(e){return Y(e,`loess`)}function jMe(e){return Y(e,`sample`)}function MMe(e){return Y(e,`window`)}function NMe(e){return Y(e,`joinaggregate`)}function PMe(e){return Y(e,`flatten`)}function FMe(e){return Y(e,`calculate`)}function IMe(e){return Y(e,`bin`)}function LMe(e){return Y(e,`impute`)}function RMe(e){return Y(e,`timeUnit`)}function zMe(e){return Y(e,`aggregate`)}function BMe(e){return Y(e,`stack`)}function VMe(e){return Y(e,`fold`)}function HMe(e){return Y(e,`extent`)&&!Y(e,`density`)&&!Y(e,`regression`)}function UMe(e){return e.map(e=>_0(e)?{filter:MZ(e.filter,uAe)}:e)}function WMe(e,t){let{transform:n,...r}=e;if(n){let e=n.map(e=>{if(_0(e))return{filter:v0(e,t)};if(IMe(e)&&VQ(e.bin))return{...e,bin:KMe(e.bin)};if(CMe(e)){let{selection:t,...n}=e.from;return t?{...e,from:{param:t,...n}}:e}return e});return{...r,transform:e}}return e}function GMe(e,t){let n=N2(e);if(Z(n)&&VQ(n.bin)&&(n.bin=KMe(n.bin)),j1(n)&&n.scale?.domain?.selection){let{selection:e,...t}=n.scale.domain;n.scale.domain={...t,...e?{param:e}:{}}}if(x1(n))if(H(n.condition))n.condition=n.condition.map(e=>{let{selection:n,param:r,test:i,...a}=e;return r?e:{...a,test:v0(e,t)}});else{let{selection:e,param:r,test:i,...a}=GMe(n.condition,t);n.condition=r?n.condition:{...a,test:v0(n.condition,t)}}return n}function KMe(e){let t=e.extent;if(t?.selection){let{selection:n,...r}=t;return{...e,extent:{...r,param:n}}}return e}function v0(e,t){let n=e=>MZ(e,e=>{let n={param:e,empty:t.emptySelections[e]??!0};return t.selectionPredicates[e]??=[],t.selectionPredicates[e].push(n),n});return e.selection?n(e.selection):MZ(e.test||e.filter,e=>e.selection?n(e.selection):e)}function qMe(e,t){return e.name?{...t,path:(t.path??[]).concat(e.name)}:t}function JMe(e,t){t===void 0&&(t=Zje(e.config));let n=YMe(e,t),{width:r,height:i}=e,a=ZMe(n,{width:r,height:i,autosize:e.autosize},t);return{...n,...a?{autosize:a}:{}}}function YMe(e,t={}){let n={config:t};return Aze.map(Oze.map(kze.map(e,n),n),n)}function XMe(e){return gg(e)?{type:e}:e??{}}function ZMe(e,t,n){let{width:r,height:i}=t,a=q1(e)||f0(e),o={};a?r==`container`&&i==`container`?(o.type=`fit`,o.contains=`padding`):r==`container`?(o.type=`fit-x`,o.contains=`padding`):i==`container`&&(o.type=`fit-y`,o.contains=`padding`):(r==`container`&&(X(m$(`width`)),r=void 0),i==`container`&&(X(m$(`height`)),i=void 0));let s={type:`pad`,...o,...n?XMe(n.autosize):{},...XMe(e.autosize)};if(s.type===`fit`&&!a&&(X(dRe),s.type=`pad`),r==`container`&&!(s.type==`fit`||s.type==`fit-x`)&&X(h$(`width`)),i==`container`&&!(s.type==`fit`||s.type==`fit-y`)&&X(h$(`height`)),!mQ(s,{type:`pad`}))return s}function QMe(e){return[`fit`,`fit-x`,`fit-y`].includes(e)}function $Me(e){return e?`fit-${kQ(e)}`:`fit`}function eNe(e,t){let n={};for(let t of jze)e&&e[t]!==void 0&&(n[t]=$Q(e[t]));return t&&(n.params=e.params),n}function y0(e){return{explicit:!0,value:e}}function b0(e){return{explicit:!1,value:e}}function tNe(e){return(t,n,r,i)=>{let a=e(t.value,n.value);return a>0?t:a<0?n:x0(t,n,r,i)}}function x0(e,t,n,r){return e.explicit&&t.explicit&&X(Cke(n,r,e.value,t.value)),e}function S0(e,t,n,r,i=x0){return e===void 0||e.value===void 0?t:e.explicit&&!t.explicit?e:t.explicit&&!e.explicit?t:mQ(e.value,t.value)?e:i(e,t,n,r)}function C0(e){return Y(e,`url`)}function w0(e){return Y(e,`values`)}function nNe(e){return Y(e,`name`)&&!C0(e)&&!w0(e)&&!T0(e)}function T0(e){return e&&(rNe(e)||iNe(e)||E0(e))}function rNe(e){return Y(e,`sequence`)}function iNe(e){return Y(e,`sphere`)}function E0(e){return Y(e,`graticule`)}function aNe({invalid:e,isPath:t}){switch(TAe(e,{isPath:t})){case`filter`:return{marks:`exclude-invalid-values`,scales:`exclude-invalid-values`};case`break-paths-show-domains`:return{marks:t?`include-invalid-values`:`exclude-invalid-values`,scales:`include-invalid-values`};case`break-paths-filter-domains`:return{marks:t?`include-invalid-values`:`exclude-invalid-values`,scales:`exclude-invalid-values`};case`show`:return{marks:`include-invalid-values`,scales:`include-invalid-values`}}}function oNe(e){let{marks:t,scales:n}=aNe(e);return t===n?G3.Main:n===`include-invalid-values`?G3.PreFilterInvalid:G3.PostFilterInvalid}function D0(e){return e.as!==void 0}function sNe(e){return`${e}_end`}function cNe({timeUnit:e,field:t,reverse:n}){let{unit:r,utc:i}=e,{part:a,step:o}=iAe(Xke(r),e.step);return`${i?`utcOffset`:`timeOffset`}('${a}', ${nQ(t)}, ${n?-o:o})`}function lNe([e,t],n,r){if(n!==void 0&&n!==.5){let i=nQ(e),a=nQ(t);return[{type:`formula`,expr:uNe([cNe({timeUnit:r,field:e,reverse:!0}),i],n+.5),as:`${e}_${Y3}`},{type:`formula`,expr:uNe([i,a],n+.5),as:`${e}_${X3}`}]}return[]}function uNe([e,t],n){return`${1-n} * ${e} + ${n} * ${t}`}function dNe(e){let{signals:t,hasLegend:n,index:r,...i}=e;return i.field=iQ(i.field),i}function O0(e,t=!0,n=ch){if(H(e)){let r=e.map(e=>O0(e,t,n));return t?`[${r.join(`, `)}]`:r}else if(M$(e))return n(t?P$(e):Kke(e));return t?n(hQ(e)):e}function fNe(e,t){for(let n of P2(e.component.selection??{})){let r=n.name,i=`${r}${C6}, ${n.resolve===`global`?`true`:`{unit: ${W0(e)}}`}`;for(let r of T6)r.defined(n)&&(r.signals&&(t=r.signals(e,n,t)),r.modifyExpr&&(i=r.modifyExpr(e,n,i)));t.push({name:r+Gze,on:[{events:{signal:n.name+C6},update:`modify(${W(n.name+S6)}, ${i})`}]})}return k0(t)}function pNe(e,t){if(e.component.selection&&$(e.component.selection).length){let n=W(e.getName(`cell`));t.unshift({name:`facet`,value:{},on:[{events:BG(`pointermove`,`scope`),update:`isTuple(facet) ? facet : group(${n}).datum`}]})}return k0(t)}function mNe(e,t){let n=!1;for(let r of P2(e.component.selection??{})){let i=r.name,a=W(i+S6);if(t.filter(e=>e.name===i).length===0){let e=r.resolve===`global`?`union`:r.resolve,n=r.type===`point`?`, true, true)`:`)`;t.push({name:r.name,update:`${w6}(${a}, ${W(e)}${n}`})}n=!0;for(let n of T6)n.defined(r)&&n.topLevelSignals&&(t=n.topLevelSignals(e,r,t))}return n&&t.filter(e=>e.name===`unit`).length===0&&t.unshift({name:`unit`,value:{},on:[{events:`pointermove`,update:`isTuple(group()) ? group() : unit`}]}),k0(t)}function hNe(e,t){let n=[],r=[],i=W0(e,{escape:!1});for(let a of P2(e.component.selection??{})){let o={name:a.name+S6};if(a.project.hasSelectionId&&(o.transform=[{type:`collect`,sort:{field:F3}}]),a.init){let e=a.project.items.map(dNe);o.values=a.project.hasSelectionId?a.init.map(e=>({unit:i,[F3]:O0(e,!1)[0]})):a.init.map(t=>({unit:i,fields:e,values:O0(t,!1)}))}if([...n,...t].filter(e=>e.name===a.name+S6).length||n.push(o),K0(a)&&t.length){let n=e.lookupDataSource(e.getDataName(G3.Main)),i=t.find(e=>e.name===n),a=i.transform.find(e=>e.type===`filter`&&e.expr.includes(`vlSelectionTest`));if(a){i.transform=i.transform.filter(e=>e!==a);let e={name:i.name+Q3,source:i.name,transform:[a]};r.push(e)}}}return n.concat(t,r)}function gNe(e,t){for(let n of P2(e.component.selection??{}))for(let r of T6)r.defined(n)&&r.marks&&(t=r.marks(e,n,t));return t}function _Ne(e,t){for(let n of e.children)x2(n)&&(t=gNe(n,t));return t}function vNe(e,t,n,r){let i=QNe(e,t.param,t);return{signal:X$(n.get(`type`))&&H(r)&&r[0]>r[1]?`isValid(${i}) && reverse(${i})`:i}}function k0(e){return e.map(e=>(e.on&&!e.on.length&&delete e.on,e))}function A0(e,t){return`domain(${W(e.scaleName(t))})`}function j0(e){return e.parent&&w2(e.parent)&&(!e.parent.parent||j0(e.parent.parent))}function yNe(e,t,n,r){let i=!e.hasProjection,a=n.channel,o=n.signals.visual,s=W(i?e.scaleName(a):e.projectionName()),c=e=>`scale(${s}, ${e})`,l=e.getSizeSignalRef(a===V2?`width`:`height`).signal,u=`${a}(unit)`,d=t.events.reduce((e,t)=>[...e,{events:t.between[0],update:`[${u}, ${u}]`},{events:t,update:`[${o}[0], clamp(${u}, 0, ${l})]`}],[]);if(i){let i=n.signals.data,l=o6.defined(t),u=e.getScaleComponent(a),f=u?u.get(`type`):void 0,p=r?{init:O0(r,!0,c)}:{value:[]};return d.push({events:{signal:t.name+c6},update:X$(f)?`[${c(`${i}[0]`)}, ${c(`${i}[1]`)}]`:`[0, 0]`}),l?[{name:i,on:[]}]:[{name:o,...p,on:d},{name:i,...r?{init:O0(r)}:{},on:[{events:{signal:o},update:`${o}[0] === ${o}[1] ? null : invert(${s}, ${o})`}]}]}else{let e=a===V2?0:1,n=t.name+u6;return[{name:o,...r?{init:`[${n}[0][${e}], ${n}[1][${e}]]`}:{value:[]},on:d}]}}function M0({model:e,channelDef:t,vgChannel:n,invalidValueRef:r,mainRefFn:i}){let a=x1(t)&&t.condition,o=[];a&&(o=Gh(a).map(t=>{let n=i(t);if(UAe(t)){let{param:r,empty:i}=t;return{test:ZNe(e,{param:r,empty:i}),...n}}else return{test:J0(e,t.test),...n}})),r!==void 0&&o.push(r);let s=i(t);return s!==void 0&&o.push(s),o.length>1||o.length===1&&o[0].test?{[n]:o}:o.length===1?{[n]:o[0]}:{}}function N0(e,t=`text`){let n=e.encoding[t];return M0({model:e,channelDef:n,vgChannel:t,mainRefFn:t=>P0(t,e.config),invalidValueRef:void 0})}function P0(e,t,n=`datum`){if(e){if(A1(e))return t$(e.value);if(O1(e)){let{format:r,formatType:i}=L1(e);return d1({fieldOrDatumDef:e,format:r,formatType:i,expr:n,config:t})}}}function bNe(e,t={}){let{encoding:n,markDef:r,config:i,stack:a}=e,o=n.tooltip;if(H(o))return{tooltip:SNe({tooltip:o},a,i,t)};{let s=t.reactiveGeom?`datum.datum`:`datum`;return M0({model:e,channelDef:o,vgChannel:`tooltip`,mainRefFn:e=>{let o=CNe(e,i,s);if(o)return o;if(e===null)return;let c=a$(`tooltip`,r,i);if(c===!0&&(c={content:`encoding`}),gg(c))return{value:c};if(gh(c))return JQ(c)?c:c.content===`encoding`?SNe(n,a,i,t):{signal:s}},invalidValueRef:void 0})}}function xNe(e,t,n,{reactiveGeom:r}={}){let i={...n,...n.tooltipFormat},a=new Set,o=r?`datum.datum`:`datum`,s=[];function c(n,r){let c=SQ(r),l=k1(n)?n:{...n,type:e[c].type},u=Gh(l.title||I1(l,i)).join(`, `).replaceAll(/"/g,`\\"`),d;if(OQ(r)){let t=r===`x`?`x2`:`y2`,n=R1(e[t]);if(BQ(l.bin)&&n){let e=Q(l,{expr:o}),r=Q(n,{expr:o}),{format:s,formatType:c}=L1(l);d=m1(e,r,s,c,i),a.add(t)}}if((OQ(r)||r===Y2||r===q2)&&t&&t.fieldChannel===r&&t.offset===`normalize`){let{format:e,formatType:t}=L1(l);d=d1({fieldOrDatumDef:l,format:e,formatType:t,expr:o,config:i,normalizeStack:!0}).signal}d??=CNe(l,i,o).signal,s.push({channel:r,key:u,value:d})}X1(e,(e,t)=>{Z(e)?c(e,t):S1(e)&&c(e.condition,t)});let l={};for(let{channel:e,key:t,value:n}of s)!a.has(e)&&!l[t]&&(l[t]=n);return l}function SNe(e,t,n,{reactiveGeom:r}={}){let i=xNe(e,t,n,{reactiveGeom:r}),a=F2(i).map(([e,t])=>`"${e}": ${t}`);return a.length>0?{signal:`{${a.join(`, `)}}`}:void 0}function CNe(e,t,n=`datum`){if(Z(e)&&J$(e.type)&&!e.timeUnit&&!L1(e).format&&!L1(e).formatType){let t=`${n}["${e.field}"]`;return{signal:`isValid(${t}) ? isArray(${t}) ? join(${t}, '\\n') : ${t} : ""+${t}`}}return P0(e,t,n)}function wNe(e){let{markDef:t,config:n}=e,r=a$(`aria`,t,n);return r===!1?{}:{...r?{aria:r}:{},...TNe(e),...ENe(e)}}function TNe(e){let{mark:t,markDef:n,config:r}=e;if(r.aria===!1)return{};let i=a$(`ariaRoleDescription`,n,r);return i==null?sg(lRe,t)?{}:{ariaRoleDescription:{value:t}}:{ariaRoleDescription:{value:i}}}function ENe(e){let{encoding:t,markDef:n,config:r,stack:i}=e,a=t.description;if(a)return M0({model:e,channelDef:a,vgChannel:`description`,mainRefFn:t=>P0(t,e.config),invalidValueRef:void 0});let o=a$(`description`,n,r);if(o!=null)return{description:t$(o)};if(r.aria===!1)return{};let s=xNe(t,i,r);if(!qZ(s))return{description:{signal:F2(s).filter(([e])=>!e.startsWith(`_`)).map(([e,t])=>[e,t.replaceAll(`\\n`,` `)]).map(([e,t],n)=>`"${n>0?`; `:``}${e}: " + (${t})`).join(` + `)}}}function F0(e,t,n={}){let{markDef:r,encoding:i,config:a}=t,{vgChannel:o}=n,{defaultRef:s,defaultValue:c}=n,l=i[e];s===void 0&&(c??=a$(e,r,a,{vgChannel:o,ignoreVgConfig:!x1(l)}),c!==void 0&&(s=t$(c)));let u={markDef:r,config:a,scaleName:t.scaleName(e),scale:t.getScaleComponent(e)},d=OAe({...u,scaleChannel:e,channelDef:l});return M0({model:t,channelDef:l,vgChannel:o??e,invalidValueRef:d,mainRefFn:t=>c1({...u,channel:e,channelDef:t,stack:null,defaultRef:s})})}function DNe(e,t={filled:void 0}){let{markDef:n,encoding:r,config:i}=e,{type:a}=n,o=t.filled??a$(`filled`,n,i),s=RZ([`bar`,`point`,`circle`,`square`,`geoshape`],a)?`transparent`:void 0,c=a$(o===!0?`color`:void 0,n,i,{vgChannel:`fill`})??i.mark[o===!0&&`color`]??s,l=a$(o===!1?`color`:void 0,n,i,{vgChannel:`stroke`})??i.mark[o===!1&&`color`],u=o?`fill`:`stroke`,d={...c?{fill:t$(c)}:{},...l?{stroke:t$(l)}:{}};return n.color&&(o?n.fill:n.stroke)&&X(w$(`property`,{fill:`fill`in n,stroke:`stroke`in n})),{...d,...F0(`color`,e,{vgChannel:u,defaultValue:o?c:l}),...F0(`fill`,e,{defaultValue:r.fill?c:void 0}),...F0(`stroke`,e,{defaultValue:r.stroke?l:void 0})}}function ONe(e){let{encoding:t,mark:n}=e,r=t.order;return!e1(n)&&A1(r)?M0({model:e,channelDef:r,vgChannel:`zindex`,mainRefFn:e=>t$(e.value),invalidValueRef:void 0}):{}}function I0({channel:e,markDef:t,encoding:n={},model:r,bandPosition:i}){let a=`${e}Offset`,o=t[a],s=n[a];if((a===`xOffset`||a===`yOffset`)&&s)return{offsetType:`encoding`,offset:c1({channel:a,channelDef:s,markDef:t,config:r?.config,scaleName:r.scaleName(a),scale:r.getScaleComponent(a),stack:null,defaultRef:t$(o),bandPosition:i})};let c=t[a];return c?{offsetType:`visual`,offset:c}:{}}function L0(e,t,{defaultPos:n,vgChannel:r}){let{encoding:i,markDef:a,config:o,stack:s}=t,c=i[e],l=i[wQ(e)],u=t.scaleName(e),d=t.getScaleComponent(e),{offset:f,offsetType:p}=I0({channel:e,markDef:a,encoding:i,model:t,bandPosition:.5}),m=R0({model:t,defaultPos:n,channel:e,scaleName:u,scale:d}),h=!c&&OQ(e)&&(i.latitude||i.longitude)?{field:t.getName(e)}:kNe({channel:e,channelDef:c,channel2Def:l,markDef:a,config:o,scaleName:u,scale:d,stack:s,offset:f,defaultRef:m,bandPosition:p===`encoding`?0:void 0});return h?{[r||e]:h}:void 0}function kNe(e){let{channel:t,channelDef:n,scaleName:r,stack:i,offset:a,markDef:o}=e;if(O1(n)&&i&&t===i.fieldChannel){if(Z(n)){let e=n.bandPosition;if(e===void 0&&o.type===`text`&&(t===`radius`||t===`theta`)&&(e=.5),e!==void 0)return s1({scaleName:r,fieldOrDatumDef:n,startSuffix:`start`,bandPosition:e,offset:a})}return o1(n,r,{suffix:`end`},{offset:a})}return a1(e)}function R0({model:e,defaultPos:t,channel:n,scaleName:r,scale:i}){let{markDef:a,config:o}=e;return()=>{let s=SQ(n),c=CQ(n),l=a$(n,a,o,{vgChannel:c});if(l!==void 0)return l1(n,l);switch(t){case`zeroOrMin`:return ANe({scaleName:r,scale:i,mode:`zeroOrMin`,mainChannel:s,config:o});case`zeroOrMax`:return ANe({scaleName:r,scale:i,mode:{zeroOrMax:{widthSignal:e.width.signal,heightSignal:e.height.signal}},mainChannel:s,config:o});case`mid`:return{...e[TQ(n)],mult:.5}}}}function ANe({mainChannel:e,config:t,...n}){let r=DAe(n),{mode:i}=n;if(r)return r;switch(e){case`radius`:{if(i===`zeroOrMin`)return{value:0};let{widthSignal:e,heightSignal:t}=i.zeroOrMax;return{signal:`min(${e},${t})/2`}}case`theta`:return i===`zeroOrMin`?{value:0}:{signal:`2*PI`};case`x`:return i===`zeroOrMin`?{value:0}:{field:{group:`width`}};case`y`:return i===`zeroOrMin`?{field:{group:`height`}}:{value:0}}}function jNe(e,t,n,r=`middle`){if(e===`radius`||e===`theta`)return CQ(e);let i=e===`x`?`align`:`baseline`,a=a$(i,t,n),o;return JQ(a)?(X(fke(i)),o=void 0):o=a,e===`x`?Bze[o||(r===`top`?`left`:`center`)]:Vze[o||r]}function z0(e,t,{defaultPos:n,defaultPos2:r,range:i}){return i?MNe(e,t,{defaultPos:n,defaultPos2:r}):L0(e,t,{defaultPos:n})}function MNe(e,t,{defaultPos:n,defaultPos2:r}){let{markDef:i,config:a}=t,o=wQ(e),s=TQ(e),c=NNe(t,r,o);return{...L0(e,t,{defaultPos:n,vgChannel:c[s]?jNe(e,i,a):CQ(e)}),...c}}function NNe(e,t,n){let{encoding:r,mark:i,markDef:a,stack:o,config:s}=e,c=SQ(n),l=TQ(n),u=CQ(n),d=r[c],f=e.scaleName(c),p=e.getScaleComponent(c),{offset:m}=n in r||n in a?I0({channel:n,markDef:a,encoding:r,model:e}):I0({channel:c,markDef:a,encoding:r,model:e});if(!d&&(n===`x2`||n===`y2`)&&(r.latitude||r.longitude)){let t=TQ(n),r=e.markDef[t];return r==null?{[u]:{field:e.getName(n)}}:{[t]:{value:r}}}let h=PNe({channel:n,channelDef:d,channel2Def:r[n],markDef:a,config:s,scaleName:f,scale:p,stack:o,offset:m,defaultRef:void 0});return h===void 0?B0(n,a)||B0(n,{[n]:s$(n,a,s.style),[l]:s$(l,a,s.style)})||B0(n,s[i])||B0(n,s.mark)||{[u]:R0({model:e,defaultPos:t,channel:n,scaleName:f,scale:p})()}:{[u]:h}}function PNe({channel:e,channelDef:t,channel2Def:n,markDef:r,config:i,scaleName:a,scale:o,stack:s,offset:c,defaultRef:l}){return O1(t)&&s&&e.charAt(0)===s.fieldChannel.charAt(0)?o1(t,a,{suffix:`start`},{offset:c}):a1({channel:e,channelDef:n,scaleName:a,scale:o,stack:s,markDef:r,config:i,offset:c,defaultRef:l})}function B0(e,t){let n=TQ(e),r=CQ(e);if(t[r]!==void 0)return{[r]:l1(e,t[r])};if(t[e]!==void 0)return{[r]:l1(e,t[e])};if(t[n]){let r=t[n];if(r1(r))X(ske(n));else return{[n]:l1(e,r)}}}function V0(e,t){let{config:n,encoding:r,markDef:i}=e,a=i.type,o=wQ(t),s=TQ(t),c=r[t],l=r[o],u=e.getScaleComponent(t),d=u?u.get(`type`):void 0,f=i.orient,p=r[s]??r.size??a$(`size`,i,n,{vgChannel:s}),m=EQ(t),h=a===`bar`&&(t===`x`?f===`vertical`:f===`horizontal`)||a===`tick`&&(t===`y`?f===`vertical`:f===`horizontal`);return Z(c)&&(zQ(c.bin)||BQ(c.bin)||c.timeUnit&&!l)&&!(p&&!r1(p))&&!r[m]&&!Y$(d)?RNe({fieldDef:c,fieldDef2:l,channel:t,model:e}):(O1(c)&&Y$(d)||h)&&!l?INe(c,t,e):MNe(t,e,{defaultPos:`zeroOrMax`,defaultPos2:`zeroOrMin`})}function FNe(e,t,n,r,i,a,o){if(r1(i))if(n){let e=n.get(`type`);if(e===`band`){let e=`bandwidth('${t}')`;i.band!==1&&(e=`${i.band} * ${e}`);let n=o$(`minBandSize`,{type:o},r);return{signal:n?`max(${r$(n)}, ${e})`:e}}else i.band!==1&&X(gke(e))}else return{mult:i.band,field:{group:e}};else if(JQ(i))return i;else if(i)return{value:i};if(n){let e=n.get(`range`);if(YQ(e)&&mg(e.step))return{value:e.step-2}}if(!a){let{bandPaddingInner:t,barBandPaddingInner:n,rectBandPaddingInner:i,tickBandPaddingInner:a}=r.scale,s=cQ(t,o===`tick`?a:o===`bar`?n:i);if(JQ(s))return{signal:`(1 - (${s.signal})) * ${e}`};if(mg(s))return{signal:`${1-s} * ${e}`}}return{value:u0(r.view,e)-2}}function INe(e,t,n){let{markDef:r,encoding:i,config:a,stack:o}=n,s=r.orient,c=n.scaleName(t),l=n.getScaleComponent(t),u=TQ(t),d=wQ(t),f=EQ(t),p=n.scaleName(f),m=n.getScaleComponent(DQ(t)),h=r.type===`tick`||s===`horizontal`&&t===`y`||s===`vertical`&&t===`x`,g;(i.size||r.size)&&(h?g=F0(`size`,n,{vgChannel:u,defaultRef:t$(r.size)}):X(bke(r.type)));let _=!!g,v=KAe({channel:t,fieldDef:e,markDef:r,config:a,scaleType:(l||m)?.get(`type`),useVlSizeChannel:h});g||={[u]:FNe(u,p||c,m||l,a,v,!!e,r.type)};let y=jNe(t,r,a,(l||m)?.get(`type`)===`band`&&r1(v)&&!_?`top`:`middle`),b=y===`xc`||y===`yc`,{offset:x,offsetType:S}=I0({channel:t,markDef:r,encoding:i,model:n,bandPosition:b?.5:0}),C=(b&&S!==`encoding`&&Z(e)&&e.timeUnit&&!i[d]?b1({fieldDef:e,markDef:r,config:a}):void 0)??(b?S===`encoding`?0:.5:JQ(v)?{signal:`(1-${v})/2`}:r1(v)?(1-v.band)/2:0),w=a1({channel:t,channelDef:e,markDef:r,config:a,scaleName:c,scale:l,stack:o,offset:x,defaultRef:R0({model:n,defaultPos:`mid`,channel:t,scaleName:c,scale:l}),bandPosition:C});if(u)return{[y]:w,...g};{let e=CQ(d),t=g[u],n=x?{...t,offset:x}:t;return{[y]:w,[e]:H(w)?[w[0],{...w[1],offset:n}]:{...w,offset:n}}}}function LNe(e,t,n,r,i,a,o){if(gQ(e))return 0;let s=e===`x`||e===`y2`,c=s?-t/2:t/2;if(JQ(n)||JQ(i)||JQ(r)||a){let e=r$(n),t=r$(i),l=r$(r),u=r$(a),d=a?`(${o} < ${u} ? ${s?``:`-`}0.5 * (${u} - (${o})) : ${c})`:c,f=l?`${l} + `:``,p=e?`(${e} ? -1 : 1) * `:``,m=t?`(${t} + ${d})`:d;return{signal:f+p+m}}else return i||=0,r+(n?-i-c:+i+c)}function RNe({fieldDef:e,fieldDef2:t,channel:n,model:r}){let{config:i,markDef:a,encoding:o}=r,s=r.getScaleComponent(n),c=r.scaleName(n),l=s?s.get(`type`):void 0,u=s.get(`reverse`),d=KAe({channel:n,fieldDef:e,markDef:a,config:i,scaleType:l}),f=(r.component.axes[n]?.[0])?.get(`translate`)??.5,p=OQ(n)?a$(`binSpacing`,a,i)??0:0,m=wQ(n),h=CQ(n),g=CQ(m),_=o$(`minBandSize`,a,i),{offset:v}=I0({channel:n,markDef:a,encoding:o,model:r,bandPosition:0}),{offset:y}=I0({channel:m,markDef:a,encoding:o,model:r,bandPosition:0}),b=jAe({fieldDef:e,scaleName:c}),x=LNe(n,p,u,f,v,_,b),S=LNe(m,p,u,f,y??v,_,b),C=JQ(d)?{signal:`(1-${d.signal})/2`}:r1(d)?(1-d.band)/2:.5,w=b1({fieldDef:e,fieldDef2:t,markDef:a,config:i});if(zQ(e.bin)||e.timeUnit){let t=e.timeUnit&&w!==.5;return{[g]:zNe({fieldDef:e,scaleName:c,bandPosition:C,offset:S,useRectOffsetField:t}),[h]:zNe({fieldDef:e,scaleName:c,bandPosition:JQ(C)?{signal:`1-${C.signal}`}:1-C,offset:x,useRectOffsetField:t})}}else if(BQ(e.bin)){let n=o1(e,c,{},{offset:S});if(Z(t))return{[g]:n,[h]:o1(t,c,{},{offset:x})};if(VQ(e.bin)&&e.bin.step)return{[g]:n,[h]:{signal:`scale("${c}", ${Q(e,{expr:`datum`})} + ${e.bin.step})`,offset:x}}}X(Ike(m))}function zNe({fieldDef:e,scaleName:t,bandPosition:n,offset:r,useRectOffsetField:i}){return s1({scaleName:t,fieldOrDatumDef:e,bandPosition:n,offset:r,...i?{startSuffix:Y3,endSuffix:X3}:{}})}function H0(e,t){let{fill:n=void 0,stroke:r=void 0}=t.color===`include`?DNe(e):{};return{...VNe(e.markDef,t),...BNe(`fill`,n),...BNe(`stroke`,r),...F0(`opacity`,e),...F0(`fillOpacity`,e),...F0(`strokeOpacity`,e),...F0(`strokeWidth`,e),...F0(`strokeDash`,e),...ONe(e),...bNe(e),...N0(e,`href`),...wNe(e)}}function BNe(e,t){return t?{[e]:t}:{}}function VNe(e,t){return cRe.reduce((n,r)=>(!d6.has(r)&&Y(e,r)&&t[r]!==`ignore`&&(n[r]=t$(e[r])),n),{})}function U0(e){let{config:t,markDef:n}=e,r=new Set;if(e.forEachFieldDef((i,a)=>{let o;if(!MQ(a)||!(o=e.getScaleType(a)))return;let s=LQ(i.aggregate);if(EAe(i1({scaleChannel:a,markDef:n,config:t,scaleType:o,isCountAggregate:s}))){let t=e.vgField(a,{expr:`datum`,binSuffix:e.stack?.impute?`mid`:void 0});t&&r.add(t)}}),r.size>0)return{defined:{signal:[...r].map(e=>q$(e,!0)).join(` && `)}}}function HNe(e,t){if(t!==void 0)return{[e]:t$(t)}}function UNe(e,t,n){let r=e.fieldDef(t)?.field;for(let i of P2(e.component.selection??{})){let e=i.project.hasField[r]??i.project.hasChannel[t];if(e&&_6.defined(i)){let t=n.get(`selections`)??[];t.push(i.name),n.set(`selections`,t,!1),e.hasLegend=!0}}}function WNe(e,t,n,r,i){let a=t.name,o=a+v6,s=a+y6,c=n.channel,l=o6.defined(t),u=i.find(e=>e.name===n.signals[l?`data`:`visual`]),d=e.getSizeSignalRef(r).signal,f=e.getScaleComponent(c),p=f?.get(`type`),m=f?.get(`reverse`),h=l?c===V2?m?``:`-`:m?`-`:``:``,g=`${o}.extent_${c}`,_=`${h}${s}.${c} / ${l?`${d}`:`span(${g})`}`,v=`${!l||!f?`panLinear`:p===`log`?`panLog`:p===`symlog`?`panSymlog`:p===`pow`?`panPow`:`panLinear`}(${g}, ${_}${l?p===`pow`?`, ${f.get(`exponent`)??1}`:p===`symlog`?`, ${f.get(`constant`)??1}`:``:``})`;u.on.push({events:{signal:s},update:l?v:`clampRange(${v}, 0, ${d})`})}function GNe(e,t,n,r,i){let a=t.name,o=n.channel,s=o6.defined(t),c=i.find(e=>e.name===n.signals[s?`data`:`visual`]),l=e.getSizeSignalRef(r).signal,u=e.getScaleComponent(o),d=u?.get(`type`),f=s?A0(e,o):c.name,p=a+x6,m=`${a}${b6}.${o}`,h=`${!s||!u?`zoomLinear`:d===`log`?`zoomLog`:d===`symlog`?`zoomSymlog`:d===`pow`?`zoomPow`:`zoomLinear`}(${f}, ${m}, ${p}${s?d===`pow`?`, ${u.get(`exponent`)??1}`:d===`symlog`?`, ${u.get(`constant`)??1}`:``:``})`;c.on.push({events:{signal:p},update:s?h:`clampRange(${h}, 0, ${l})`})}function KNe(e){let t=e.parent;for(;t&&!S2(t);)t=t.parent;return t}function W0(e,{escape:t}={escape:!0}){let n=t?W(e.name):e.name,r=KNe(e);if(r){let{facet:e}=r;for(let t of T4)e[t]&&(n+=` + '__facet_${t}_' + (facet[${W(r.vgField(t))}])`)}return n}function G0(e){return P2(e.component.selection??{}).reduce((e,t)=>e||t.project.hasSelectionId,!1)}function qNe(e,t){(gg(t.select)||!t.select.on)&&delete e.events,(gg(t.select)||!t.select.clear)&&delete e.clear,(gg(t.select)||!t.select.toggle)&&delete e.toggle}function K0(e){return e.events?.find(e=>`type`in e&&e.type===`timer`)}function q0(e){let t=[];return e.type===`Identifier`?[e.name]:e.type===`Literal`?[e.value]:(e.type===`MemberExpression`&&(t.push(...q0(e.object)),t.push(...q0(e.property))),t)}function JNe(e){return e.object.type===`MemberExpression`?JNe(e.object):e.object.name===`datum`}function YNe(e){let t=OOe(e),n=new Set;return t.visit(e=>{e.type===`MemberExpression`&&JNe(e)&&n.add(q0(e).slice(1).join(`.`))}),n}function XNe(e,t){let n={},r=e.config.selection;if(!t||!t.length)return n;let i=0;for(let a of t){let t=XZ(a.name),o=a.select,s=gg(o)?o:o.type,c=gh(o)?N2(o):{type:s},l=r[s];for(let e in l)e===`fields`||e===`encodings`||(e===`mark`&&(c.mark={...l.mark,...c.mark}),(c[e]===void 0||c[e]===!0)&&(c[e]=N2(l[e]??c[e])));let u=n[t]={...c,name:t,type:s,init:a.value,bind:a.bind,events:gg(c.on)?BG(c.on,`scope`):Gh(N2(c.on))};if(K0(u)&&(i++,i>1)){delete n[t];continue}let d=N2(a);for(let t of T6)t.defined(u)&&t.parse&&t.parse(e,u,d)}return i>1&&X(_Re),n}function ZNe(e,t,n,r=`datum`){let i=gg(t)?t:t.param,a=XZ(i),o=W(a+S6),s;try{s=e.getSelectionComponent(a,i)}catch{return`!!${a}`}if(s.project.timeUnit){let t=n??e.component.data.raw,r=s.project.timeUnit.clone();t.parent?r.insertAsParentOf(t):t.parent=r}let c=`${s.project.hasSelectionId?`vlSelectionIdTest(`:`vlSelectionTest(`}${o}, ${r}${s.resolve===`global`?`)`:`, ${W(s.resolve)})`}`,l=`length(data(${o}))`;return t.empty===!1?`${l} && ${c}`:`!${l} || ${c}`}function QNe(e,t,n){let r=XZ(t),i=n.encoding,a=n.field,o;try{o=e.getSelectionComponent(r,t)}catch{return r}if(!i&&!a)a=o.project.items[0].field,o.project.items.length>1&&X(QOe(a));else if(i&&!a){let e=o.project.items.filter(e=>e.channel===i);!e.length||e.length>1?(a=o.project.items[0].field,X($Oe(e,i,n,a))):a=e[0].field}return`${o.name}[${W(iQ(a))}]`}function $Ne(e,t){for(let[n,r]of F2(e.component.selection??{})){let i=e.getName(`lookup_${n}`);e.component.data.outputNodes[i]=r.materialized=new q3(new E6(t,e,{param:n}),i,G3.Lookup,e.component.data.outputNodeRefCounts)}}function J0(e,t,n){return ZZ(t,t=>gg(t)?t:aAe(t)?ZNe(e,t,n):lAe(t))}function ePe(e,t){if(e)return H(e)&&!qQ(e)?e.map(e=>I1(e,t)).join(`, `):e}function Y0(e,t,n,r){e.encode??={},e.encode[t]??={},e.encode[t].update??={},e.encode[t].update[n]=r}function X0(e,t,n,r={header:!1}){let{disable:i,orient:a,scale:o,labelExpr:s,title:c,zindex:l,...u}=e.combine();if(!i){for(let e in u){let n=e,r=tze[n],i=u[n];if(r&&r!==t&&r!==`both`)delete u[n];else if(K1(i)){let{condition:e,...t}=i,r=Gh(e),a=S3[n];if(a){let{vgProp:e,part:i}=a;Y0(u,i,e,[...r.map(e=>{let{test:t,...n}=e;return{test:J0(null,t),...n}}),t]),delete u[n]}else a===null&&(u[n]={signal:r.map(e=>{let{test:t,...n}=e;return`${J0(null,t)} ? ${n$(n)} : `}).join(``)+n$(t)})}else if(JQ(i)){let e=S3[n];if(e){let{vgProp:t,part:r}=e;Y0(u,r,t,i),delete u[n]}}RZ([`labelAlign`,`labelBaseline`],n)&&u[n]===null&&delete u[n]}if(t===`grid`){if(!u.grid)return;if(u.encode){let{grid:e}=u.encode;u.encode={...e?{grid:e}:{}},qZ(u.encode)&&delete u.encode}return{scale:o,orient:a,...u,domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:cQ(l,0)}}else{if(!r.header&&e.mainExtracted)return;if(s!==void 0){let e=s;u.encode?.labels?.update&&JQ(u.encode.labels.update.text)&&(e=aQ(s,`datum.label`,u.encode.labels.update.text.signal)),Y0(u,`labels`,`text`,{signal:e})}if(u.labelAlign===null&&delete u.labelAlign,u.encode){for(let t of C3)e.hasAxisPart(t)||delete u.encode[t];qZ(u.encode)&&delete u.encode}let t=ePe(c,n);return{scale:o,orient:a,grid:!1,...t?{title:t}:{},...u,...n.aria===!1?{aria:!1}:{},zindex:cQ(l,0)}}}}function tPe(e){let{axes:t}=e.component,n=[];for(let r of k4)if(t[r]){for(let i of t[r])if(!i.get(`disable`)&&!i.get(`gridScale`)){let t=r===`x`?`height`:`width`,i=e.getSizeSignalRef(t).signal;t!==i&&n.push({name:t,update:i})}}return n}function nPe(e,t){let{x:n=[],y:r=[]}=e;return[...n.map(e=>X0(e,`grid`,t)),...r.map(e=>X0(e,`grid`,t)),...n.map(e=>X0(e,`main`,t)),...r.map(e=>X0(e,`main`,t))].filter(e=>e)}function rPe(e,t,n,r){return Object.assign.apply(null,[{},...e.map(e=>{if(e===`axisOrient`){let e=n===`x`?`bottom`:`left`,i=t[n===`x`?`axisBottom`:`axisLeft`]||{},a=t[n===`x`?`axisTop`:`axisRight`]||{},o=new Set([...$(i),...$(a)]),s={};for(let t of o.values())s[t]={signal:`${r.signal} === "${e}" ? ${r$(i[t])} : ${r$(a[t])}`};return s}return t[e]})])}function iPe(e,t,n,r){let i=t===`band`?[`axisDiscrete`,`axisBand`]:t===`point`?[`axisDiscrete`,`axisPoint`]:hAe(t)?[`axisQuantitative`]:t===`time`||t===`utc`?[`axisTemporal`]:[],a=e===`x`?`axisX`:`axisY`,o=JQ(n)?`axisOrient`:`axis${$Z(n)}`,s=[...i,...i.map(e=>a+e.substr(4))],c=[`axis`,o,a];return{vlOnlyAxisConfig:rPe(s,r,e,n),vgAxisConfig:rPe(c,r,e,n),axisConfigStyle:aPe([...c,...s],r)}}function aPe(e,t){let n=[{}];for(let r of e){let e=t[r]?.style;if(e){e=Gh(e);for(let r of e)n.push(t.style[r])}}return Object.assign.apply(null,n)}function Z0(e,t,n,r={}){let i=c$(e,n,t);if(i!==void 0)return{configFrom:`style`,configValue:i};for(let t of[`vlOnlyAxisConfig`,`vgAxisConfig`,`axisConfigStyle`])if(r[t]?.[e]!==void 0)return{configFrom:t,configValue:r[t][e]};return{}}function oPe(e,t){return!Y$(e)&&Z(t)&&!zQ(t?.bin)&&!BQ(t?.bin)}function sPe(e,t){let n=t===`x`?`y`:`x`;if(e.getScaleComponent(n))return e.scaleName(n)}function cPe(e,t,n,r,i){let a=t?.labelAngle;if(a!==void 0)return JQ(a)?a:fQ(a);{let{configValue:a}=Z0(`labelAngle`,r,t?.style,i);return a===void 0?n===V2&&RZ([Y4,q4],e.type)&&!(Z(e)&&e.timeUnit)?270:void 0:fQ(a)}}function Q0(e){return`(((${e.signal} % 360) + 360) % 360)`}function lPe(e,t,n,r){if(e!==void 0)if(n===`x`){if(JQ(e)){let n=Q0(e);return{signal:`(45 < ${n} && ${n} < 135) || (225 < ${n} && ${n} < 315) ? "middle" :(${n} <= 45 || 315 <= ${n}) === ${JQ(t)?`(${t.signal} === "top")`:t===`top`} ? "bottom" : "top"`}}if(450;if(a||u){let s=t===`row`?`height`:`width`;return{name:e.getName(`${t}_${n}`),type:`group`,role:`${t}-${n}`,...r.facetFieldDef?{from:{data:e.getName(`${t}_domain`)},sort:CPe(o,t)}:{},...u&&c?{from:{data:e.getName(`facet_domain_${t}`)}}:{},...a?{title:a}:{},...i.sizeSignal?{encode:{update:{[s]:i.sizeSignal}}}:{},...u?{axes:l}:{}}}}return null}function TPe(e,t){return Kze[t][e]}function EPe(e,t){let n={};for(let r of T4){let i=e[r];if(i?.facetFieldDef){let{titleAnchor:e,titleOrient:a}=n2([`titleAnchor`,`titleOrient`],i.facetFieldDef.header,t,r),o=e2(r,a),s=TPe(e,o);s!==void 0&&(n[o]=s)}}return qZ(n)?void 0:n}function DPe(e,t,n,r,i){let a={};for(let o of r){if(!i[o])continue;let r=t2(o,t?.header,e,n);r!==void 0&&(a[i[o]]=r)}return a}function i2(e){return[...a2(e,`width`),...a2(e,`height`),...a2(e,`childWidth`),...a2(e,`childHeight`)]}function a2(e,t){let n=t===`width`?`x`:`y`,r=e.component.layoutSize.get(t);if(r==null||r===`merged`)return[];let i=e.getSizeSignalRef(t).signal;if(r===`step`){let t=e.getScaleComponent(n);if(t){let r=t.get(`type`),a=t.get(`range`);if(Y$(r)&&YQ(a)){let r=e.scaleName(n);return S2(e.parent)&&e.parent.component.resolve.scale[n]===`independent`?[OPe(r,a)]:[OPe(r,a),{name:i,update:kPe(r,t,`domain('${r}').length`)}]}}throw Error(`layout size is step although width/height is not step.`)}else if(r==`container`){let t=i.endsWith(`width`),n=t?`containerSize()[0]`:`containerSize()[1]`,r=`isFinite(${n}) ? ${n} : ${l0(e.config.view,t?`width`:`height`)}`;return[{name:i,init:r,on:[{update:r,events:`window:resize`}]}]}else return[{name:i,value:r}]}function OPe(e,t){let n=`${e}_step`;return JQ(t.step)?{name:n,update:t.step.signal}:{name:n,value:t.step}}function kPe(e,t,n){let r=t.get(`type`),i=t.get(`padding`),a=cQ(t.get(`paddingOuter`),i),o=t.get(`paddingInner`);return o=r===`band`?o===void 0?i:o:1,`bandspace(${n}, ${r$(o)}, ${r$(a)}) * ${e}_step`}function APe(e){return e===`childWidth`?`width`:e===`childHeight`?`height`:e}function jPe(e,t){return $(e).reduce((n,r)=>({...n,...M0({model:t,channelDef:e[r],vgChannel:r,mainRefFn:e=>t$(e.value),invalidValueRef:void 0})}),{})}function MPe(e,t){if(S2(t))return e===`theta`?`independent`:`shared`;if(w2(t))return`shared`;if(C2(t))return OQ(e)||e===`theta`||e===`radius`?`independent`:`shared`;throw Error(`invalid model type for resolve`)}function o2(e,t){let n=e.scale[t],r=OQ(t)?`axis`:`legend`;return n===`independent`?(e[r][t]===`shared`&&X(Tke(t)),`independent`):e[r][t]||`shared`}function NPe(e,{fieldOrDatumDef:t,model:n,channel:r,legendCmpt:i,legendType:a}){if(a!==`symbol`)return;let{markDef:o,encoding:s,config:c,mark:l}=n,u=o.filled&&l!==`trail`,d={...GOe({},n,JRe),...DNe(n,{filled:u})},f=i.get(`symbolOpacity`)??c.legend.symbolOpacity,p=i.get(`symbolFillColor`)??c.legend.symbolFillColor,m=i.get(`symbolStrokeColor`)??c.legend.symbolStrokeColor,h=f===void 0?LPe(s.opacity)??o.opacity:void 0;if(d.fill){if(r===`fill`||u&&r===n4)delete d.fill;else if(Y(d.fill,`field`))p?delete d.fill:(d.fill=t$(c.legend.symbolBaseFillColor??`black`),d.fillOpacity=t$(h??1));else if(H(d.fill)){let e=s2(s.fill??s.color)??o.fill??(u&&o.color);e&&(d.fill=t$(e))}}if(d.stroke){if(r===`stroke`||!u&&r===n4)delete d.stroke;else if(Y(d.stroke,`field`)||m)delete d.stroke;else if(H(d.stroke)){let e=cQ(s2(s.stroke||s.color),o.stroke,u?o.color:void 0);e&&(d.stroke={value:e})}}if(r!==c4){let e=Z(t)&&zPe(n,i,t);e?d.opacity=[{test:e,...t$(h??1)},t$(c.legend.unselectedOpacity)]:h&&(d.opacity=t$(h))}return d={...d,...e},qZ(d)?void 0:d}function PPe(e,{model:t,legendType:n,legendCmpt:r}){if(n!==`gradient`)return;let{config:i,markDef:a,encoding:o}=t,s={},c=(r.get(`gradientOpacity`)??i.legend.gradientOpacity)===void 0?LPe(o.opacity)||a.opacity:void 0;return c&&(s.opacity=t$(c)),s={...s,...e},qZ(s)?void 0:s}function FPe(e,{fieldOrDatumDef:t,model:n,channel:r,legendCmpt:i}){let a=n.legend(r)||{},o=n.config,s=Z(t)?zPe(n,i,t):void 0,c=s?[{test:s,value:1},{value:o.legend.unselectedOpacity}]:void 0,{format:l,formatType:u}=a,d;u1(u)?d=f1({fieldOrDatumDef:t,field:`datum.value`,format:l,formatType:u,config:o}):l===void 0&&u===void 0&&o.customFormatTypes&&(t.type===`quantitative`&&o.numberFormatType?d=f1({fieldOrDatumDef:t,field:`datum.value`,format:o.numberFormat,formatType:o.numberFormatType,config:o}):t.type===`temporal`&&o.timeFormatType&&Z(t)&&t.timeUnit===void 0&&(d=f1({fieldOrDatumDef:t,field:`datum.value`,format:o.timeFormat,formatType:o.timeFormatType,config:o})));let f={...c?{opacity:c}:{},...d?{text:d}:{},...e};return qZ(f)?void 0:f}function IPe(e,{legendCmpt:t}){return t.get(`selections`)?.length?{...e,fill:{value:`transparent`}}:e}function LPe(e){return RPe(e,(e,t)=>Math.max(e,t.value))}function s2(e){return RPe(e,(e,t)=>cQ(e,t.value))}function RPe(e,t){if(YAe(e))return Gh(e.condition).reduce(t,e.value);if(A1(e))return e.value}function zPe(e,t,n){let r=t.get(`selections`);if(!r?.length)return;let i=W(n.field);return r.map(e=>`(!length(data(${W(XZ(e)+S6)})) || (${e}[${i}] && indexof(${e}[${i}], datum.value) >= 0))`).join(` || `)}function BPe(e,t){let n=e.values;if(H(n))return fje(t,n);if(JQ(n))return n}function VPe(e,t,n,r){if(t!==`shape`){let e=s2(n)??r;if(e)return e}switch(e){case`bar`:case`rect`:case`image`:case`square`:return`square`;case`line`:case`trail`:case`rule`:return`stroke`;case`arc`:case`point`:case`circle`:case`tick`:case`geoshape`:case`area`:case`text`:return`circle`}}function HPe(e){let{legend:t}=e;return cQ(t.type,UPe(e))}function UPe({channel:e,timeUnit:t,scaleType:n}){if(yQ(e)){if(RZ([`quarter`,`month`,`day`],t))return`symbol`;if(Z$(n))return`gradient`}return`symbol`}function WPe({legendConfig:e,legendType:t,orient:n,legend:r}){return r.direction??e[t?`gradientDirection`:`symbolDirection`]??GPe(n,t)}function GPe(e,t){switch(e){case`top`:case`bottom`:return`horizontal`;case`left`:case`right`:case`none`:case void 0:return;default:return t===`gradient`?`horizontal`:void 0}}function KPe({legendConfig:e,model:t,direction:n,orient:r,scaleType:i}){let{gradientHorizontalMaxLength:a,gradientHorizontalMinLength:o,gradientVerticalMaxLength:s,gradientVerticalMinLength:c}=e;if(Z$(i))return n===`horizontal`?r===`top`||r===`bottom`?qPe(t,`width`,o,a):o:qPe(t,`height`,c,s)}function qPe(e,t,n,r){return{signal:`clamp(${e.getSizeSignalRef(t).signal}, ${n}, ${r})`}}function JPe(e){if(RZ([`quantile`,`threshold`,`log`,`symlog`],e))return`greedy`}function YPe(e){let t=x2(e)?XPe(e):eFe(e);return e.component.legends=t,t}function XPe(e){let{encoding:t}=e,n={};for(let r of[n4,...P3]){let i=z1(t[r]);!i||!e.getScaleComponent(r)||r===a4&&Z(i)&&i.type===X4||(n[r]=$Pe(e,r))}return n}function ZPe(e,t){let n=e.scaleName(t);if(e.mark===`trail`){if(t===`color`)return{stroke:n};if(t===`size`)return{strokeWidth:n}}return t===`color`?e.markDef.filled?{fill:n}:{stroke:n}:{[t]:n}}function QPe(e,t,n,r){switch(t){case`disable`:return n!==void 0;case`values`:return!!n?.values;case`title`:if(t===`title`&&e===r?.title)return!0}return e===(n||{})[t]}function $Pe(e,t){let n=e.legend(t),{markDef:r,encoding:i,config:a}=e,o=a.legend,s=new qze({},ZPe(e,t));UNe(e,t,s);let c=n===void 0?o.disable:!n;if(s.set(`disable`,c,n!==void 0),c)return s;n||={};let l=e.getScaleComponent(t).get(`type`),u=z1(i[t]),d=Z(u)?R$(u.timeUnit)?.unit:void 0,f=n.orient||a.legend.orient||`right`,p=HPe({legend:n,channel:t,timeUnit:d,scaleType:l}),m=WPe({legend:n,legendType:p,orient:f,legendConfig:o}),h={legend:n,channel:t,model:e,markDef:r,encoding:i,fieldOrDatumDef:u,legendConfig:o,config:a,scaleType:l,orient:f,legendType:p,direction:m};for(let r of j6){if(p===`gradient`&&r.startsWith(`symbol`)||p===`symbol`&&r.startsWith(`gradient`))continue;let i=r in N6?N6[r](h):n[r];if(i!==void 0){let o=QPe(i,r,n,e.fieldDef(t));(o||a.legend[r]===void 0)&&s.set(r,i,o)}}let g=n?.encoding??{},_=s.get(`selections`),v={},y={fieldOrDatumDef:u,model:e,channel:t,legendCmpt:s,legendType:p};for(let t of[`labels`,`legend`,`title`,`symbols`,`gradient`,`entries`]){let n=jPe(g[t]??{},e),r=t in M6?M6[t](n,y):n;r!==void 0&&!qZ(r)&&(v[t]={..._?.length&&Z(u)?{name:`${XZ(u.field)}_legend_${t}`}:{},..._?.length?{interactive:!0}:{},update:_?.length?{...r,cursor:{value:`pointer`}}:r})}return qZ(v)||s.set(`encode`,v,!!n?.encoding),s}function eFe(e){let{legends:t,resolve:n}=e.component;for(let r of e.children){YPe(r);for(let i of $(r.component.legends))n.legend[i]=o2(e.component.resolve,i),n.legend[i]===`shared`&&(t[i]=tFe(t[i],r.component.legends[i]),t[i]||(n.legend[i]=`independent`,delete t[i]))}for(let r of $(t))for(let t of e.children)t.component.legends[r]&&n.legend[r]===`shared`&&delete t.component.legends[r];return t}function tFe(e,t){if(!e)return t.clone();let n=e.getWithExplicit(`orient`),r=t.getWithExplicit(`orient`);if(n.explicit&&r.explicit&&n.value!==r.value)return;let i=!1;for(let n of j6){let r=S0(e.getWithExplicit(n),t.getWithExplicit(n),n,`legend`,(e,t)=>{switch(n){case`symbolType`:return nFe(e,t);case`title`:return f$(e,t);case`type`:return i=!0,b0(`symbol`)}return x0(e,t,n,`legend`)});e.setWithExplicit(n,r)}return i&&(e.implicit?.encode?.gradient&&QZ(e.implicit,[`encode`,`gradient`]),e.explicit?.encode?.gradient&&QZ(e.explicit,[`encode`,`gradient`])),e}function nFe(e,t){return t.value===`circle`?t:e}function rFe(e,t,n,r){if(G1(t,n)){let i=x2(e)?e.axis(n)??e.legend(n)??{}:{},a=Q(t,{expr:`datum`}),o=Q(t,{expr:`datum`,binSuffix:`end`});return{formulaAs:Q(t,{binSuffix:`range`,forAs:!0}),formula:m1(a,o,i.format,i.formatType,r)}}return{}}function iFe(e,t){return`${RQ(e)}_${t}`}function aFe(e,t){return{signal:e.getName(`${t}_bins`),extentSignal:e.getName(`${t}_extent`)}}function c2(e,t,n){let r=iFe(H1(n,void 0)??{},t);return e.getName(`${r}_bins`)}function oFe(e){return`as`in e}function sFe(e,t,n){let r,i;r=oFe(e)?gg(e.as)?[e.as,`${e.as}_end`]:[e.as[0],e.as[1]]:[Q(e,{forAs:!0}),Q(e,{binSuffix:`end`,forAs:!0})];let a={...H1(t,void 0)},o=iFe(a,e.field),{signal:s,extentSignal:c}=aFe(n,o);if(HQ(a.extent)){let e=a.extent;i=QNe(n,e.param,e),delete a.extent}return{key:o,binComponent:{bin:a,field:e.field,as:[r],...s?{signal:s}:{},...c?{extentSignal:c}:{},...i?{span:i}:{}}}}function cFe(e,t,n,r){let i=x2(r)?r.encoding[wQ(t)]:void 0;if(k1(n)&&x2(r)&&qAe(n,i,r.markDef,r.config)){e.add(Q(n,{})),e.add(Q(n,{suffix:`end`}));let{mark:i,markDef:a,config:o}=r,s=b1({fieldDef:n,markDef:a,config:o});t1(i)&&s!==.5&&OQ(t)&&(e.add(Q(n,{suffix:Y3})),e.add(Q(n,{suffix:X3}))),n.bin&&G1(n,t)&&e.add(Q(n,{binSuffix:`range`}))}else if(vQ(t)){let n=_Q(t);e.add(r.getName(n))}else e.add(Q(n));return j1(n)&&yAe(n.scale?.range)&&e.add(n.scale.range.field),e}function lFe(e,t){for(let n of $(t)){let r=t[n];for(let t of $(r))n in e?e[n][t]=new Set([...e[n][t]??[],...r[t]]):e[n]={[t]:r[t]}}}function uFe(e){return e.startsWith(`'`)&&e.endsWith(`'`)||e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function dFe(e,t){let n=eQ(e);return t===`number`?`toNumber(${n})`:t===`boolean`?`toBoolean(${n})`:t===`string`?`toString(${n})`:t===`date`?`toDate(${n})`:t===`flatten`?n:t.startsWith(`date:`)?`timeParse(${n},'${uFe(t.slice(5,t.length))}')`:t.startsWith(`utc:`)?`utcParse(${n},'${uFe(t.slice(4,t.length))}')`:(X(eke(t)),null)}function fFe(e){let t={};return jZ(e.filter,e=>{if(sAe(e)){let n=null;z$(e)?n=$Q(e.equal):V$(e)?n=$Q(e.lte):B$(e)?n=$Q(e.lt):H$(e)?n=$Q(e.gt):U$(e)?n=$Q(e.gte):W$(e)?n=e.range[0]:G$(e)&&(n=(e.oneOf??e.in)[0]),n&&(M$(n)?t[e.field]=`date`:mg(n)?t[e.field]=`number`:gg(n)&&(t[e.field]=`string`)),e.timeUnit&&(t[e.field]=`date`)}}),t}function pFe(e){let t={};function n(e){U1(e)?t[e.field]=`date`:e.type===`quantitative`&&HOe(e.aggregate)?t[e.field]=`number`:sQ(e.field)>1?e.field in t||(t[e.field]=`flatten`):j1(e)&&h1(e.sort)&&sQ(e.sort.field)>1&&(e.sort.field in t||(t[e.sort.field]=`flatten`))}if((x2(e)||S2(e))&&e.forEachFieldDef((t,r)=>{if(k1(t))n(t);else{let i=SQ(r),a=e.fieldDef(i);n({...t,type:a.type})}}),x2(e)){let{mark:n,markDef:r,encoding:i}=e;if(e1(n)&&!e.encoding.order){let e=i[r.orient===`horizontal`?`y`:`x`];Z(e)&&e.type===`quantitative`&&!(e.field in t)&&(t[e.field]=`number`)}}return t}function mFe(e){let t={};if(x2(e)&&e.component.selection)for(let n of $(e.component.selection)){let r=e.component.selection[n];for(let e of r.project.items)!e.channel&&sQ(e.field)>1&&(t[e.field]=`flatten`)}return t}function l2(e){return e instanceof V6||e instanceof z6||e instanceof B6}function u2(e){return`isValid(${e}) && isFinite(+${e})`}function hFe(e){return e.stack.stackBy.reduce((e,t)=>{let n=t.fieldDef,r=Q(n);return r&&e.push(r),e},[])}function gFe(e){return H(e)&&e.every(e=>gg(e))&&e.length>1}function _Fe(e){function t(n){if(!(n instanceof I6)){let r=n.clone();if(r instanceof q3){let t=Y6+r.getSource();r.setSource(t),e.model.component.data.outputNodes[t]=r}else(r instanceof F6||r instanceof q6||r instanceof J6||r instanceof G6)&&r.addDimensions(e.fields);for(let e of n.children.flatMap(t))e.parent=r;return[r]}return n.children.flatMap(t)}return t}function d2(e){if(e instanceof I6)if(e.numChildren()===1&&!(e.children[0]instanceof q3)){let t=e.children[0];(t instanceof F6||t instanceof q6||t instanceof J6||t instanceof G6)&&t.addDimensions(e.fields),t.swapWithParent(),d2(e)}else{let t=e.model.component.data.main;vFe(t);let n=_Fe(e),r=e.children.map(n).flat();for(let e of r)e.parent=t}else e.children.map(d2)}function vFe(e){if(e instanceof q3&&e.type===G3.Main&&e.numChildren()===1){let t=e.children[0];t instanceof I6||(t.swapWithParent(),vFe(e))}}function f2(e){for(let t of e){for(let e of t.children)if(e.parent!==t)return!1;if(!f2(t.children))return!1}return!0}function p2(e,t){let n=!1;for(let r of t)n=e.optimize(r)||n;return n}function yFe(e,t,n){let r=e.sources,i=!1;return i=p2(new Zze,r)||i,i=p2(new Yze(t),r)||i,r=r.filter(e=>e.numChildren()>0),i=p2(new eBe,r)||i,r=r.filter(e=>e.numChildren()>0),n||(i=p2(new Qze,r)||i,i=p2(new rBe(t),r)||i,i=p2(new Xze,r)||i,i=p2(new $ze,r)||i,i=p2(new nBe,r)||i,i=p2(new tBe,r)||i,i=p2(new Jze,r)||i,i=p2(new iBe,r)||i),e.sources=r,i}function bFe(e,t){f2(e.sources);let n=0,r=0;for(let r=0;r({signal:`{data: ${W1(e,{timeUnit:n,type:t})}}`}))}function m2(e,t,n){let r=R$(n)?.unit;return t===`temporal`||r?EFe(e,t,r):[e]}function h2(e,t,n,r){let{encoding:i,markDef:a,mark:o,config:s,stack:c}=n,l=z1(i[r]),{type:u}=l,d=l.timeUnit,f=oNe({invalid:o$(`invalid`,a,s),isPath:e1(o)});if(vAe(t)){let i=h2(e,void 0,n,r);return y0([...m2(t.unionWith,u,d),...i.value])}else if(JQ(t))return y0([t]);else if(t&&t!==`unaggregated`&&!_Ae(t))return y0(m2(t,u,d));if(c&&r===c.fieldChannel){if(c.offset===`normalize`)return b0([[0,1]]);let e=n.requestDataName(f);return b0([{data:e,field:n.vgField(r,{suffix:`start`})},{data:e,field:n.vgField(r,{suffix:`end`})}])}let p=MQ(r)&&Z(l)?OFe(n,r,e):void 0;if(T1(l))return b0(m2([l.datum],u,d));let m=l;if(t===`unaggregated`){let{field:e}=l;return b0([{data:n.requestDataName(f),field:Q({field:e,aggregate:`min`})},{data:n.requestDataName(f),field:Q({field:e,aggregate:`max`})}])}else if(zQ(m.bin)){if(Y$(e))return b0(e===`bin-ordinal`?[]:[{data:JZ(p)?n.requestDataName(f):n.requestDataName(G3.Raw),field:n.vgField(r,G1(m,r)?{binSuffix:`range`}:{}),sort:p===!0||!gh(p)?{field:n.vgField(r,{}),op:`min`}:p}]);{let{bin:e}=m;if(zQ(e)){let t=c2(n,m.field,e);return b0([new Z6(()=>{let e=n.getSignalName(t);return`[${e}.start, ${e}.stop]`})])}else return b0([{data:n.requestDataName(f),field:n.vgField(r,{})}])}}else if(m.timeUnit&&RZ([`time`,`utc`],e)){let e=i[wQ(r)];if(qAe(m,e,a,s)){let t=n.requestDataName(f),i=b1({fieldDef:m,fieldDef2:e,markDef:a,config:s}),c=t1(o)&&i!==.5&&OQ(r);return b0([{data:t,field:n.vgField(r,c?{suffix:Y3}:{})},{data:t,field:n.vgField(r,{suffix:c?X3:`end`})}])}}return b0(p?[{data:JZ(p)?n.requestDataName(f):n.requestDataName(G3.Raw),field:n.vgField(r),sort:p}]:[{data:n.requestDataName(f),field:n.vgField(r)}])}function g2(e,t){let{op:n,field:r,order:i}=e;return{op:n??(t?`sum`:v3),...r?{field:iQ(r)}:{},...i?{order:i}:{}}}function DFe(e,t){let n=e.component.scales[t],r=e.specifiedScales[t].domain,i=e.fieldDef(t)?.bin,a=_Ae(r)?r:void 0,o=VQ(i)&&HQ(i.extent)?i.extent:void 0;(a||o)&&n.set(`selectionExtent`,a??o,!0)}function OFe(e,t,n){if(!Y$(n))return;let r=e.fieldDef(t),i=r.sort;if(HAe(i))return{op:`min`,field:$0(r,t),order:`ascending`};let{stack:a}=e,o=a?new Set([...a.groupbyFields,...a.stackBy.map(e=>e.fieldDef.field)]):void 0;if(h1(i))return g2(i,a&&!o.has(i.field));if(VAe(i)){let{encoding:t,order:n}=i,r=e.fieldDef(t),{aggregate:s,field:c}=r,l=a&&!o.has(c);if(PQ(s)||FQ(s))return g2({field:Q(r),order:n},l);if(IQ(s)||!s)return g2({op:s,field:c,order:n},l)}else if(i===`descending`)return{op:`min`,field:e.vgField(t),order:`descending`};else if(RZ([`ascending`,void 0],i))return!0}function kFe(e,t){let{aggregate:n,type:r}=e;return n?gg(n)&&!sRe.has(n)?{valid:!1,reason:vke(n)}:r===`quantitative`&&t===`log`?{valid:!1,reason:yke(e)}:{valid:!0}:{valid:!1,reason:_ke(e)}}function _2(e,t,n,r){return e.explicit&&t.explicit&&X(wke(n,r,e.value,t.value)),{explicit:e.explicit,value:[...e.value,...t.value]}}function AFe(e){let t=HZ(e.map(e=>{if(ZQ(e)){let{sort:t,...n}=e;return n}return e}),IZ),n=HZ(e.map(e=>{if(ZQ(e)){let t=e.sort;return t!==void 0&&!JZ(t)&&(`op`in t&&t.op===`count`&&delete t.field,t.order===`ascending`&&delete t.order),t}}).filter(e=>e!==void 0),IZ);if(t.length===0)return;if(t.length===1){let t=e[0];if(ZQ(t)&&n.length>0){let e=n[0];if(n.length>1){X(R4);let t=n.filter(e=>gh(e)&&`op`in e&&e.op!==`min`);e=n.every(e=>gh(e)&&`op`in e)&&t.length===1?t[0]:!0}else if(gh(e)&&`field`in e){let n=e.field;t.field===n&&(e=!e.order||{order:e.order})}return{...t,sort:e}}return t}let r=HZ(n.map(e=>JZ(e)||!(`op`in e)||gg(e.op)&&sg(iRe,e.op)?e:(X(Eke(e)),!0)),IZ),i;r.length===1?i=r[0]:r.length>1&&(X(R4),i=!0);let a=HZ(e.map(e=>ZQ(e)?e.data:null),e=>e);return a.length===1&&a[0]!==null?{data:a[0],fields:t.map(e=>e.field),...i?{sort:i}:{}}:{fields:t,...i?{sort:i}:{}}}function v2(e){if(ZQ(e)&&gg(e.field))return e.field;if(XQ(e)){let t;for(let n of e.fields)if(ZQ(n)&&gg(n.field)){if(!t)t=n.field;else if(t!==n.field)return X(CRe),t}return X(wRe),t}else if(UOe(e)){X(TRe);let t=e.fields[0];return gg(t)?t:void 0}}function y2(e,t){return AFe(e.component.scales[t].get(`domains`).map(t=>(ZQ(t)&&(t.data=e.lookupDataSource(t.data)),t)))}function jFe(e,t,n,r){e.encode??={},e.encode[t]??={},e.encode[t].update??={},e.encode[t].update[n]=r}function MFe(e,t){if(x2(e)){let n=e.fieldDef(t);if(n?.field)return n.field}let n=(e.children??[]).map(e=>MFe(e,t)).filter(e=>!!e);if(n.length>0){let e=HZ(n,IZ);return e.length===1?e[0]:void 0}}function NFe(e,t,n){if(t===n)return!0;let r=e.getScaleType(t),i=e.getScaleType(n);return!r||!i?!1:Y$(r)===Y$(i)}function PFe(e,t){return e?`field:${e}`:`channel:${String(t)}`}function FFe(e){if(H(e)){let t=e.filter(YZ);return t.length>0?t:null}if(XQ(e)){let t=[];if(t.push(...e.fields.flatMap(e=>H(e)?e.filter(YZ):[])),t.length>0)return HZ(t,IZ)}return null}function b2(e,t){try{return FFe(y2(e,t))}catch{return null}}function IFe(e,t,n){let r=b2(e,t),i=b2(e,n);return r&&i?HZ([...r,...i],IZ):null}function LFe(e,t,n){t&&t.length>0&&(e.getWithExplicit(`values`)?.explicit||(n&&X(n),e.set(`values`,t,!1)))}function RFe(e,t,n){let r=e.getScaleComponent(t),i=e.getScaleComponent(n);if(!r||!i)return!1;let a=r.getWithExplicit(`domains`),o=i.getWithExplicit(`domains`);if(!(a?.explicit&&o?.explicit))return!1;let s=y2(e,t),c=y2(e,n);return IZ(s)===IZ(c)}function zFe(e){let t=e.component.legends,n={};for(let r of $(t)){let i=PFe(MFe(e,r),r);if(!n[i]){n[i]=[{channel:r,cmpt:t[r].clone()}];continue}let a=!1;for(let o of n[i])if(NFe(e,o.channel,r)&&tFe(o.cmpt,t[r])){let t=e.getScaleType(o.channel),n=e.getScaleType(r);t&&n&&Y$(t)&&Y$(n)&&(RFe(e,o.channel,r)?LFe(o.cmpt,b2(e,o.channel)):LFe(o.cmpt,IFe(e,o.channel,r),Dke(o.channel,r))),a=!0;break}a||n[i].push({channel:r,cmpt:t[r].clone()})}return P2(n).flat().map(t=>BFe(t.cmpt,e.config)).filter(e=>e!==void 0)}function BFe(e,t){let{disable:n,labelExpr:r,selections:i,...a}=e.combine();if(!n){if(t.aria===!1&&a.aria==null&&(a.aria=!1),a.encode?.symbols){let e=a.encode.symbols.update;e.fill&&e.fill.value!==`transparent`&&!e.stroke&&!a.stroke&&(e.stroke={value:`transparent`});for(let t of P3)a[t]&&delete e[t]}if(a.title||delete a.title,r!==void 0){let e=r;a.encode?.labels?.update&&JQ(a.encode.labels.update.text)&&(e=aQ(r,`datum.label`,a.encode.labels.update.text.signal)),jFe(a,`labels`,`text`,{signal:e})}return a}}function VFe(e){return w2(e)||C2(e)?HFe(e):UFe(e)}function HFe(e){return e.children.reduce((e,t)=>e.concat(t.assembleProjections()),UFe(e))}function UFe(e){let t=e.component.projection;if(!t||t.merged)return[];let n=t.combine(),{name:r}=n;if(t.data){let i={signal:`[${t.size.map(e=>e.signal).join(`, `)}]`},a=t.data.reduce((t,n)=>{let r=JQ(n)?n.signal:`data('${e.lookupDataSource(n)}')`;return RZ(t,r)||t.push(r),t},[]);if(a.length<=0)throw Error(`Projection's fit didn't find any data sources`);return[{name:r,size:i,fit:{signal:a.length>1?`[${a.join(`, `)}]`:a[0]},...n}]}else return[{name:r,translate:{signal:`[width / 2, height / 2]`},...n}]}function WFe(e){e.component.projection=x2(e)?GFe(e):JFe(e)}function GFe(e){if(e.hasProjection){let t=GQ(e.specifiedProjection),n=!(t&&(t.scale!=null||t.translate!=null)),r=n?[e.getSizeSignalRef(`width`),e.getSizeSignalRef(`height`)]:void 0,i=n?KFe(e):void 0,a=new Q6(e.projectionName(!0),{...GQ(e.config.projection),...t},r,i);return a.get(`type`)||a.set(`type`,`equalEarth`,!1),a}}function KFe(e){let t=[],{encoding:n}=e;for(let r of[[Q2,Z2],[e4,$2]])(z1(n[r[0]])||z1(n[r[1]]))&&t.push({signal:e.getName(`geojson_${t.length}`)});return e.channelHasField(a4)&&e.typedFieldDef(a4).type===X4&&t.push({signal:e.getName(`geojson_${t.length}`)}),t.length===0&&t.push(e.requestDataName(G3.Main)),t}function qFe(e,t){let n=BZ(aBe,n=>!!(!sg(e.explicit,n)&&!sg(t.explicit,n)||sg(e.explicit,n)&&sg(t.explicit,n)&&mQ(e.get(n),t.get(n))));if(mQ(e.size,t.size)){if(n)return e;if(mQ(e.explicit,{}))return t;if(mQ(t.explicit,{}))return e}return null}function JFe(e){if(e.children.length===0)return;let t;for(let t of e.children)WFe(t);let n=BZ(e.children,e=>{let n=e.component.projection;if(!n)return!0;if(t){let e=qFe(t,n);return e&&(t=e),!!e}else return t=n,!0});if(t&&n){let n=e.projectionName(!0),r=new Q6(n,t.specifiedProjection,t.size,N2(t.data));for(let t of e.children){let e=t.component.projection;e&&(e.isFit&&r.data.push(...t.component.projection.data),t.renameProjection(e.get(`name`),n),e.merged=!0)}return r}}function YFe(e){return w2(e)||C2(e)?e.children.reduce((e,t)=>e.concat(YFe(t)),XFe(e)):XFe(e)}function XFe(e){return $(e.component.scales).reduce((t,n)=>{let r=e.component.scales[n];if(r.merged)return t;let i=r.combine(),{name:a,type:o,selectionExtent:s,domains:c,range:l,reverse:u,...d}=i,f=ZFe(i.range,a,n,e),p=y2(e,n),m=s?vNe(e,s,r,p):null;return t.push({name:a,type:o,...p?{domain:p}:{},...m?{domainRaw:m}:{},range:f,...u===void 0?{}:{reverse:u},...d}),t},[])}function ZFe(e,t,n,r){if(OQ(n)){if(YQ(e))return{step:{signal:`${t}_step`}}}else if(gh(e)&&ZQ(e))return{...e,data:r.lookupDataSource(e.data)};return e}function QFe(e){let t=e.component.scales;for(let n of P4){let r=t[n];if(!r)continue;let i=eIe(n,e);r.setWithExplicit(`range`,i)}}function $Fe(e,t){let n=e.fieldDef(t);if(n?.bin){let{bin:r,field:i}=n,a=TQ(t),o=e.getName(a);if(gh(r)&&r.binned&&r.step!==void 0)return new Z6(()=>{let n=e.scaleName(t),i=`(domain("${n}")[1] - domain("${n}")[0]) / ${r.step}`;return`${e.getSignalName(o)} / (${i})`});if(zQ(r)){let t=c2(e,i,r);return new Z6(()=>{let n=e.getSignalName(t),r=`(${n}.stop - ${n}.start) / ${n}.step`;return`${e.getSignalName(o)} / (${r})`})}}}function eIe(e,t){let n=t.specifiedScales[e],{size:r}=t,i=t.getScaleComponent(e).get(`type`);for(let r of oBe)if(n[r]!==void 0){let a=$$(i,r),o=bAe(e,r);if(!a)X(O$(i,r,e));else if(o)X(o);else switch(r){case`range`:{let r=n.range;if(H(r)){if(OQ(e))return y0(r.map(e=>{if(e===`width`||e===`height`){let n=t.getName(e),r=t.getSignalName.bind(t);return Z6.fromName(r,n)}return e}))}else if(gh(r))return y0({data:t.requestDataName(G3.Main),field:r.field,sort:{op:`min`,field:t.vgField(e)}});return y0(r)}case`scheme`:return y0(tIe(n[r]))}}let a=e===V2||e===`xOffset`?`width`:`height`,o=r[a];if(c0(o)){if(OQ(e))if(Y$(i)){let n=iIe(o,t,e);if(n)return y0({step:n})}else X(k$(a));else if(AQ(e)){let n=e===G2?`x`:`y`;if(t.getScaleComponent(n).get(`type`)===`band`){let e=aIe(o,i);if(e)return y0(e)}}}let{rangeMin:s,rangeMax:c}=n,l=rIe(e,t);return(s!==void 0||c!==void 0)&&$$(i,`rangeMin`)&&H(l)&&l.length===2?y0([s??l[0],c??l[1]]):b0(l)}function tIe(e){return gAe(e)?{scheme:e.name,...FZ(e,[`name`])}:{scheme:e}}function nIe(e,t,n,{center:r}={}){let i=TQ(e),a=t.getName(i),o=t.getSignalName.bind(t);return e===H2&&X$(n)?r?[Z6.fromName(e=>`${o(e)}/2`,a),Z6.fromName(e=>`-${o(e)}/2`,a)]:[Z6.fromName(o,a),0]:r?[Z6.fromName(e=>`-${o(e)}/2`,a),Z6.fromName(e=>`${o(e)}/2`,a)]:[0,Z6.fromName(o,a)]}function rIe(e,t){let{size:n,config:r,mark:i,encoding:a}=t,{type:o}=z1(a[e]),s=t.getScaleComponent(e).get(`type`),{domain:c,domainMid:l}=t.specifiedScales[e];switch(e){case V2:case H2:if(RZ([`point`,`band`],s)){let i=sIe(e,n,r.view);if(c0(i))return{step:iIe(i,t,e)}}return nIe(e,t,s);case G2:case K2:return oIe(e,t,s);case o4:{let a=uIe(i,r),o=dIe(i,n,t,r);return Q$(s)?lIe(a,o,cIe(s,r,c,e)):[a,o]}case Y2:return[0,Math.PI*2];case s4:return[0,360];case q2:return[0,new Z6(()=>`min(${t.getSignalName(S2(t.parent)?`child_width`:`width`)},${t.getSignalName(S2(t.parent)?`child_height`:`height`)})/2`)];case t4:return{step:1e3/r.scale.framesPerSecond};case d4:return[r.scale.minStrokeWidth,r.scale.maxStrokeWidth];case f4:return[[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case a4:return`symbol`;case n4:case r4:case i4:return s===`ordinal`?o===`nominal`?`category`:`ordinal`:l===void 0?i===`rect`||i===`geoshape`?`heatmap`:`ramp`:`diverging`;case c4:case l4:case u4:return[r.scale.minOpacity,r.scale.maxOpacity]}}function iIe(e,t,n){let{encoding:r}=t,i=t.getScaleComponent(n),a=DQ(n),o=r[a];if(Uje({step:e,offsetIsDiscrete:O1(o)&&J$(o.type)})===`offset`&&mje(r,a)){let n=t.getScaleComponent(a),r=`domain('${t.scaleName(a)}').length`;if(n.get(`type`)===`band`){let e=n.get(`paddingInner`)??n.get(`padding`)??0,t=n.get(`paddingOuter`)??n.get(`padding`)??0;r=`bandspace(${r}, ${e}, ${t})`}let o=i.get(`paddingInner`)??i.get(`padding`);return{signal:`${e.step} * ${r} / (1-${WOe(o)})`}}else return e.step}function aIe(e,t){if(Uje({step:e,offsetIsDiscrete:Y$(t)})===`offset`)return{step:e.step}}function oIe(e,t,n){let r=e===G2?`x`:`y`,i=t.getScaleComponent(r);if(!i)return nIe(r,t,n,{center:!0});let a=i.get(`type`),o=t.scaleName(r),{markDef:s,config:c}=t;if(a===`band`){let e=sIe(r,t.size,t.config.view);if(c0(e)){let t=aIe(e,n);if(t)return t}return[0,{signal:`bandwidth('${o}')`}]}else{let n=t.encoding[r];if(Z(n)&&n.timeUnit){let e=nAe(n.timeUnit,e=>`scale('${o}', ${e})`),r=t.config.scale.bandWithNestedOffsetPaddingInner,i=b1({fieldDef:n,markDef:s,config:c})-.5,a=i===0?``:` + ${i}`;if(r){let t=JQ(r)?`${r.signal}/2${a}`:`${r/2+i}`,n=JQ(r)?`(1 - ${r.signal}/2)${a}`:`${1-r/2+i}`;return[{signal:`${t} * (${e})`},{signal:`${n} * (${e})`}]}return[0,{signal:e}]}return NZ(`Cannot use ${e} scale if ${r} scale is not discrete.`)}}function sIe(e,t,n){let r=e===V2?`width`:`height`,i=t[r];return i===void 0?d0(n,r):i}function cIe(e,t,n,r){switch(e){case`quantile`:return t.scale.quantileCount;case`quantize`:return t.scale.quantizeCount;case`threshold`:return n!==void 0&&H(n)?n.length+1:(X(Rke(r)),3)}}function lIe(e,t,n){let r=()=>{let r=r$(t),i=r$(e),a=`(${r} - ${i}) / (${n} - 1)`;return`sequence(${i}, ${r} + ${a}, ${a})`};return JQ(t)?new Z6(r):{signal:r()}}function uIe(e,t){switch(e){case`bar`:case`tick`:return t.scale.minBandSize;case`line`:case`trail`:case`rule`:return t.scale.minStrokeWidth;case`text`:return t.scale.minFontSize;case`point`:case`square`:case`circle`:return t.scale.minSize}throw Error(E$(`size`,e))}function dIe(e,t,n,r){let i={x:$Fe(n,`x`),y:$Fe(n,`y`)};switch(e){case`bar`:case`tick`:{if(r.scale.maxBandSize!==void 0)return r.scale.maxBandSize;let e=fIe(t,i,r.view);return mg(e)?e-1:new Z6(()=>`${e.signal} - 1`)}case`line`:case`trail`:case`rule`:return r.scale.maxStrokeWidth;case`text`:return r.scale.maxFontSize;case`point`:case`square`:case`circle`:{if(r.scale.maxSize)return r.scale.maxSize;let e=fIe(t,i,r.view);return mg(e)?(e8*e)**2:new Z6(()=>`pow(${e8} * ${e.signal}, 2)`)}}throw Error(E$(`size`,e))}function fIe(e,t,n){let r=c0(e.width)?e.width.step:u0(n,`width`),i=c0(e.height)?e.height.step:u0(n,`height`);return t.x||t.y?new Z6(()=>`min(${[t.x?t.x.signal:r,t.y?t.y.signal:i].join(`, `)})`):Math.min(r,i)}function pIe(e,t){x2(e)?mIe(e,t):gIe(e,t)}function mIe(e,t){let n=e.component.scales,{config:r,encoding:i,markDef:a,specifiedScales:o}=e;for(let s of $(n)){let c=o[s],l=n[s],u=e.getScaleComponent(s),d=z1(i[s]),f=c[t],p=u.get(`type`),m=u.get(`padding`),h=u.get(`paddingInner`),g=$$(p,t),_=bAe(s,t);if(f!==void 0&&(g?_&&X(_):X(O$(p,t,s))),g&&_===void 0)if(f!==void 0){let e=d.timeUnit,n=d.type;switch(t){case`domainMax`:case`domainMin`:M$(c[t])||n===`temporal`||e?l.set(t,{signal:W1(c[t],{type:n,timeUnit:e})},!0):l.set(t,c[t],!0);break;default:l.copyKeyFromObject(t,c)}}else{let n=Y(t8,t)?t8[t]({model:e,channel:s,fieldOrDatumDef:d,scaleType:p,scalePadding:m,scalePaddingInner:h,domain:c.domain,domainMin:c.domainMin,domainMax:c.domainMax,markDef:a,config:r,hasNestedOffsetScale:hje(i,s),hasSecondaryRangeChannel:!!i[wQ(s)]}):r.scale[t];n!==void 0&&l.set(t,n,!1)}}}function hIe(e){x2(e)?QFe(e):gIe(e,`range`)}function gIe(e,t){let n=e.component.scales;for(let n of e.children)t===`range`?hIe(n):pIe(n,t);for(let r of $(n)){let i;for(let n of e.children){let e=n.component.scales[r];if(e){let n=e.getWithExplicit(t);i=S0(i,n,t,`scale`,tNe((e,n)=>{switch(t){case`range`:return e.step&&n.step?e.step-n.step:0}return 0}))}}n[r].setWithExplicit(t,i)}}function _Ie(e,t){let n=t.bin;if(zQ(n)){let r=c2(e,t.field,n);return new Z6(()=>e.getSignalName(r))}else if(BQ(n)&&VQ(n)&&n.step!==void 0)return{step:n.step}}function vIe(e,t){if(RZ([n4,r4,i4],e)&&t!==`nominal`)return`hcl`}function yIe(e,t,n,r,i,a){if(!(R1(a)?.bin||H(n)||i!=null||r!=null||RZ([Z4.TIME,Z4.UTC],e)))return OQ(t)?!0:void 0}function bIe(e,t,n,r,i,a){if(OQ(e)){if(Z$(t)){if(n.continuousPadding!==void 0)return n.continuousPadding;let{type:t,orient:o}=i;if(t===`bar`&&!(Z(r)&&(r.bin||r.timeUnit))&&(o===`vertical`&&e===`x`||o===`horizontal`&&e===`y`))return a.continuousBandSize}if(t===Z4.POINT)return n.pointPadding}}function xIe(e,t,n,r,i,a=!1){if(e===void 0){if(OQ(t)){let{bandPaddingInner:e,barBandPaddingInner:t,rectBandPaddingInner:r,tickBandPaddingInner:o,bandWithNestedOffsetPaddingInner:s}=i;return a?s:cQ(e,n===`bar`?t:n===`tick`?o:r)}else if(AQ(t)&&r===Z4.BAND)return i.offsetBandPaddingInner}}function SIe(e,t,n,r,i,a=!1){if(e===void 0){if(OQ(t)){let{bandPaddingOuter:e,bandWithNestedOffsetPaddingOuter:t}=i;if(a)return t;if(n===Z4.BAND)return cQ(e,JQ(r)?{signal:`${r.signal}/2`}:r/2)}else if(AQ(t)){if(n===Z4.POINT)return .5;if(n===Z4.BAND)return i.offsetBandPaddingOuter}}}function CIe(e,t,n,r){if(n===`x`&&r.xReverse!==void 0)return X$(e)&&t===`descending`?JQ(r.xReverse)?{signal:`!${r.xReverse.signal}`}:!r.xReverse:r.xReverse;if(X$(e)&&t===`descending`)return!0}function wIe(e,t,n,r,i,a,o){if(n&&n!==`unaggregated`&&X$(i)){if(H(n)){let e=n[0],t=n[n.length-1];if(mg(e)&&e<=0&&mg(t)&&t>=0)return!0}return!1}if(e===`size`&&t.type===`quantitative`&&!Q$(i))return!0;if(!(Z(t)&&t.bin)&&RZ([...k4,...WLe],e)){let{orient:t,type:n}=r;return RZ([`bar`,`area`,`line`,`trail`],n)&&(t===`horizontal`&&e===`y`||t===`vertical`&&e===`x`)?!1:RZ([`bar`,`area`],n)&&!o?!0:a?.zero}return!1}function TIe(e,t,n,r,i=!1){let a=EIe(t,n,r,i),{type:o}=e;return MQ(t)?o===void 0?a:SAe(t,o)?Z(n)&&!xAe(o,n.type)?(X(Ske(o,a)),a):o:(X(xke(t,o,a)),a):null}function EIe(e,t,n,r){switch(t.type){case`nominal`:case`ordinal`:{if(yQ(e)||NQ(e)===`discrete`)return e===`shape`&&t.type===`ordinal`&&X(D$(e,`ordinal`)),`ordinal`;if(jQ(e))return`band`;if(OQ(e)||AQ(e)){if(RZ([`rect`,`bar`,`image`,`rule`,`tick`],n.type)||r)return`band`}else if(n.type===`arc`&&e in A4)return`band`;let i=n[TQ(e)];return r1(i)||M1(t)&&t.axis?.tickBand?`band`:`point`}case`temporal`:return yQ(e)?`time`:NQ(e)===`discrete`?(X(D$(e,`temporal`)),`ordinal`):Z(t)&&t.timeUnit&&R$(t.timeUnit).utc?`utc`:jQ(e)?`band`:`time`;case`quantitative`:return yQ(e)?Z(t)&&zQ(t.bin)?`bin-ordinal`:`linear`:NQ(e)===`discrete`?(X(D$(e,`quantitative`)),`ordinal`):jQ(e)?`band`:`linear`;case`geojson`:return}throw Error(C$(t.type))}function DIe(e,{ignoreRange:t}={}){OIe(e),xFe(e);for(let t of VRe)pIe(e,t);t||hIe(e)}function OIe(e){x2(e)?e.component.scales=kIe(e):e.component.scales=AIe(e)}function kIe(e){let{encoding:t,mark:n,markDef:r}=e,i={};for(let a of P4){let o=z1(t[a]);if(o&&n===p3&&a===a4&&o.type===X4)continue;let s=o&&o.scale;if(o&&s!==null&&s!==!1){s??={};let n=hje(t,a),c=TIe(s,a,o,r,n);i[a]=new $6(e.scaleName(`${a}`,!0),{value:c,explicit:s.type===c})}}return i}function AIe(e){let t=e.component.scales={},n={},r=e.component.resolve;for(let t of e.children){OIe(t);for(let i of $(t.component.scales))if(r.scale[i]??=MPe(i,e),r.scale[i]===`shared`){let e=n[i],a=t.component.scales[i].getWithExplicit(`type`);e?pAe(e.value,a.value)?n[i]=S0(e,a,`type`,`scale`,sBe):(r.scale[i]=`independent`,delete n[i]):n[i]=a}}for(let r of $(n)){let i=e.scaleName(r,!0),a=n[r];t[r]=new $6(i,a);for(let t of e.children){let e=t.component.scales[r];e&&(t.renameScale(e.get(`name`),i),e.merged=!0)}}return t}function x2(e){return e?.type===`unit`}function S2(e){return e?.type===`facet`}function C2(e){return e?.type===`concat`}function w2(e){return e?.type===`layer`}function jIe(e){let t=0;function n(r,i){if(r instanceof V6&&!r.isGenerator&&!C0(r.data)&&(e.push(i),i={name:null,source:i.name,transform:[]}),r instanceof L6&&(r.parent instanceof V6&&!i.source?(i.format={...i.format,parse:r.assembleFormatParse()},i.transform.push(...r.assembleTransforms(!0))):i.transform.push(...r.assembleTransforms())),r instanceof I6){i.name||=`data_${t++}`,!i.source||i.transform.length>0?(e.push(i),r.data=i.name):r.data=i.source,e.push(...r.assemble());return}switch((r instanceof z6||r instanceof B6||r instanceof K6||r instanceof E6||r instanceof O6||r instanceof u8||r instanceof F6||r instanceof p8||r instanceof J6||r instanceof G6||r instanceof c8||r instanceof s8||r instanceof a8||r instanceof f8||r instanceof m8||r instanceof h8||r instanceof R6||r instanceof _8||r instanceof g8||r instanceof o8)&&i.transform.push(r.assemble()),(r instanceof P6||r instanceof J3||r instanceof d8||r instanceof q6||r instanceof l8)&&i.transform.push(...r.assemble()),r instanceof q3&&(i.source&&i.transform.length===0?r.setSource(i.source):r.parent instanceof q3?r.setSource(i.name):(i.name||=`data_${t++}`,r.setSource(i.name),r.numChildren()===1&&(e.push(i),i={name:null,source:i.name,transform:[]}))),r.numChildren()){case 0:r instanceof q3&&(!i.source||i.transform.length>0)&&e.push(i);break;case 1:n(r.children[0],i);break;default:{i.name||=`data_${t++}`;let a=i.name;!i.source||i.transform.length>0?e.push(i):a=i.source;for(let e of r.children)n(e,{name:null,source:a,transform:[]});break}}}return n}function MIe(e){let t=[],n=jIe(t);for(let t of e.children)n(t,{source:e.name,name:null,transform:[]});return t}function NIe(e,t){let n=[],r=jIe(n),i=0;for(let t of e.sources)t.hasName()||(t.dataName=`source_${i++}`),r(t,t.assemble());for(let e of n)e.transform.length===0&&delete e.transform;let a=0;for(let[e,t]of n.entries())(t.transform??[]).length===0&&!t.source&&n.splice(a++,0,n.splice(e,1)[0]);for(let t of n)for(let n of t.transform??[])n.type===`lookup`&&(n.from=e.outputNodes[n.from].getSource());for(let e of n)e.name in t&&(e.values=t[e.name]);return n}function PIe(e){return e===`top`||e===`left`||JQ(e)?`header`:`footer`}function FIe(e){for(let t of T4)IIe(e,t);RIe(e,`x`),RIe(e,`y`)}function IIe(e,t){let{facet:n,config:r,child:i,component:a}=e;if(e.channelHasField(t)){let o=n[t],s=t2(`title`,null,r,t),c=P1(o,r,{allowDisabling:!0,includeDefault:s===void 0||!!s});i.component.layoutHeaders[t].title&&(c=H(c)?c.join(`, `):c,c+=` / ${i.component.layoutHeaders[t].title}`,i.component.layoutHeaders[t].title=null);let l=t2(`labelOrient`,o.header,r,t),u=o.header!==null&&cQ(o.header?.labels,r.header.labels,!0),d=RZ([`bottom`,`right`],l)?`footer`:`header`;a.layoutHeaders[t]={title:o.header===null?null:c,facetFieldDef:o,[d]:t===`facet`?[]:[LIe(e,t,u)]}}}function LIe(e,t,n){let r=t===`row`?`height`:`width`;return{labels:n,sizeSignal:e.child.component.layoutSize.get(r)?e.child.getSizeSignalRef(r):void 0,axes:[]}}function RIe(e,t){let{child:n}=e;if(n.component.axes[t]){let{layoutHeaders:r,resolve:i}=e.component;if(i.axis[t]=o2(i,t),i.axis[t]===`shared`){let i=t===`x`?`column`:`row`,a=r[i];for(let r of n.component.axes[t]){let t=PIe(r.get(`orient`));a[t]??=[LIe(e,i,!1)];let n=X0(r,`main`,e.config,{header:!0});n&&a[t][0].axes.push(n),r.mainExtracted=!0}}}}function zIe(e){T2(e),E2(e,`width`),E2(e,`height`)}function BIe(e){T2(e);let t=e.layout.columns===1?`width`:`childWidth`,n=e.layout.columns===void 0?`height`:`childHeight`;E2(e,t),E2(e,n)}function T2(e){for(let t of e.children)t.parseLayoutSize()}function E2(e,t){let n=APe(t),r=kQ(n),i=e.component.resolve,a=e.component.layoutSize,o;for(let t of e.children){let a=t.component.layoutSize.getWithExplicit(n),s=i.scale[r]??MPe(r,e);if(s===`independent`&&a.value===`step`){o=void 0;break}if(o){if(s===`independent`&&o.value!==a.value){o=void 0;break}o=S0(o,a,n,``)}else o=a}if(o){for(let r of e.children)e.renameSignal(r.getName(n),e.getName(t)),r.component.layoutSize.set(n,`merged`,!1);a.setWithExplicit(t,o)}else a.setWithExplicit(t,{explicit:!1,value:void 0})}function VIe(e){let{size:t,component:n}=e;for(let r of k4){let i=TQ(r);if(t[i]!=null&&t[i]!=null){let e=t[i];n.layoutSize.set(i,c0(e)?`step`:e,!0)}else{let t=HIe(e,i);n.layoutSize.set(i,t,!1)}}}function HIe(e,t){let n=t===`width`?`x`:`y`,r=e.config,i=e.getScaleComponent(n);if(i){let e=i.get(`type`),n=i.get(`range`);if(Y$(e)){let e=d0(r.view,t);return YQ(n)||c0(e)?`step`:e}else return l0(r.view,t)}else if(e.hasProjection||e.mark===`arc`)return l0(r.view,t);else{let e=d0(r.view,t);return c0(e)?e.step:e}}function D2(e,t,n){return Q(t,{suffix:`by_${Q(e)}`,...n})}function UIe(e,t){let{row:n,column:r}=t;if(n&&r){let t=null;for(let i of[n,r])if(h1(i.sort)){let{field:n,op:r=v3}=i.sort;e=t=new G6(e,{joinaggregate:[{op:r,field:n,as:D2(i,i.sort,{forAs:!0})}],groupby:[Q(i)]})}return t}return null}function WIe(e,t){for(let n of t){let t=n.data;if(e.name&&n.hasName()&&e.name!==n.dataName)continue;let r=e.format?.mesh,i=t.format?.feature;if(r&&i)continue;let a=e.format?.feature;if((a||i)&&a!==i)continue;let o=t.format?.mesh;if(!((r||o)&&r!==o)){if(w0(e)&&w0(t)){if(mQ(e.values,t.values))return n}else if(C0(e)&&C0(t)){if(e.url===t.url)return n}else if(nNe(e)&&e.name===n.dataName)return n}}return null}function GIe(e,t){if(e.data||!e.parent){if(e.data===null){let e=new V6({values:[]});return t.push(e),e}let n=WIe(e.data,t);if(n)return T0(e.data)||(n.data.format=VZ({},e.data.format,n.data.format)),!n.hasName()&&e.data.name&&(n.dataName=e.data.name),n;{let n=new V6(e.data);return t.push(n),n}}else return e.parent.component.data.facetRoot?e.parent.component.data.facetRoot:e.parent.component.data.main}function KIe(e,t,n){let r=0;for(let i of t.transforms){let a,o;if(FMe(i))o=e=new O6(e,i),a=`derived`;else if(_0(i)){let r=fFe(i);o=e=L6.makeWithAncestors(e,{},r,n)??e,e=new E6(e,t,i.filter)}else if(IMe(i))o=e=P6.makeFromTransform(e,i,t),a=`number`;else if(RMe(i))a=`date`,n.getWithExplicit(i.field).value===void 0&&(e=new L6(e,{[i.field]:a}),n.set(i.field,a,!1)),o=e=J3.makeFromTransform(e,i);else if(zMe(i))o=e=F6.makeFromTransform(e,i),a=`number`,G0(t)&&(e=new R6(e));else if(CMe(i))o=e=p8.make(e,t,i,r++),a=`derived`;else if(MMe(i))o=e=new J6(e,i),a=`number`;else if(NMe(i))o=e=new G6(e,i),a=`number`;else if(BMe(i))o=e=q6.makeFromTransform(e,i),a=`derived`;else if(VMe(i))o=e=new c8(e,i),a=`derived`;else if(HMe(i))o=e=new o8(e,i),a=`derived`;else if(PMe(i))o=e=new s8(e,i),a=`derived`;else if(EMe(i))o=e=new g8(e,i),a=`derived`;else if(jMe(i))e=new _8(e,i);else if(LMe(i))o=e=d8.makeFromTransform(e,i),a=`derived`;else if(DMe(i))o=e=new a8(e,i),a=`derived`;else if(OMe(i))o=e=new m8(e,i),a=`derived`;else if(kMe(i))o=e=new h8(e,i),a=`derived`;else if(AMe(i))o=e=new f8(e,i),a=`derived`;else{X(tke(i));continue}if(o&&a!==void 0)for(let e of o.producedFields()??[])n.set(e,a,!1)}return e}function O2(e){let t=GIe(e,e.component.data.sources),{outputNodes:n,outputNodeRefCounts:r}=e.component.data,i=e.data,a=!(i&&(T0(i)||C0(i)||w0(i)))&&e.parent?e.parent.component.data.ancestorParse.clone():new Mze;T0(i)?(rNe(i)?t=new B6(t,i.sequence):E0(i)&&(t=new z6(t,i.graticule)),a.parseNothing=!0):i?.format?.parse===null&&(a.parseNothing=!0),t=L6.makeExplicit(t,e,a)??t,t=new R6(t);let o=e.parent&&w2(e.parent);(x2(e)||S2(e))&&o&&(t=P6.makeFromEncoding(t,e)??t),e.transforms.length>0&&(t=KIe(t,e,a));let s=mFe(e),c=pFe(e);t=L6.makeWithAncestors(t,{},{...s,...c},a)??t,x2(e)&&(t=l8.parseAll(t,e),t=u8.parseAll(t,e)),(x2(e)||S2(e))&&(o||(t=P6.makeFromEncoding(t,e)??t),t=J3.makeFromEncoding(t,e)??t,t=O6.parseAllForSortIndex(t,e));let l=t=k2(G3.Raw,e,t);if(x2(e)){let n=F6.makeFromEncoding(t,e);n&&(t=n,G0(e)&&(t=new R6(t))),t=d8.makeFromEncoding(t,e)??t,t=q6.makeFromEncoding(t,e)??t}let u,d;if(x2(e)){let{markDef:n,mark:r,config:i}=e,{marks:a,scales:o}=d=aNe({invalid:a$(`invalid`,n,i),isPath:e1(r)});a!==o&&o===`include-invalid-values`&&(u=t=k2(G3.PreFilterInvalid,e,t)),a===`exclude-invalid-values`&&(t=K6.make(t,e,d)??t)}let f=t=k2(G3.Main,e,t),p;if(x2(e)&&d){let{marks:n,scales:r}=d;n===`include-invalid-values`&&r===`exclude-invalid-values`&&(t=K6.make(t,e,d)??t,p=t=k2(G3.PostFilterInvalid,e,t))}x2(e)&&$Ne(e,f);let m=null;if(S2(e)){let r=e.getName(`facet`);t=UIe(t,e.facet)??t,m=new I6(t,e,r,f.getSource()),n[r]=m}return{...e.component.data,outputNodes:n,outputNodeRefCounts:r,raw:l,main:f,facetRoot:m,ancestorParse:a,preFilterInvalid:u,postFilterInvalid:p}}function k2(e,t,n){let{outputNodes:r,outputNodeRefCounts:i}=t.component.data,a=t.getDataName(e),o=new q3(n,a,e,i);return r[a]=o,o}function qIe(e){return e===!1||e===null}function JIe(e,t,n){let{encoding:r,config:i}=e,a=z1(r[t])??z1(r[wQ(t)]),{format:o,formatType:s}=e.axis(t)||{};if(u1(s))return{text:f1({fieldOrDatumDef:a,field:`datum.value`,format:o,formatType:s,config:i}),...n};if(o===void 0&&s===void 0&&i.customFormatTypes){if(w1(a)===`quantitative`){if(M1(a)&&a.stack===`normalize`&&i.normalizedNumberFormatType)return{text:f1({fieldOrDatumDef:a,field:`datum.value`,format:i.normalizedNumberFormat,formatType:i.normalizedNumberFormatType,config:i}),...n};if(i.numberFormatType)return{text:f1({fieldOrDatumDef:a,field:`datum.value`,format:i.numberFormat,formatType:i.numberFormatType,config:i}),...n}}if(w1(a)===`temporal`&&i.timeFormatType&&Z(a)&&!a.timeUnit)return{text:f1({fieldOrDatumDef:a,field:`datum.value`,format:i.timeFormat,formatType:i.timeFormatType,config:i}),...n}}return n}function YIe(e){return k4.reduce((t,n)=>(e.component.scales[n]&&(t[n]=[eLe(n,e)]),t),{})}function XIe(e){let{axes:t,resolve:n}=e.component,r={top:0,bottom:0,right:0,left:0};for(let r of e.children){r.parseAxesAndHeaders();for(let i of $(r.component.axes))n.axis[i]=o2(e.component.resolve,i),n.axis[i]===`shared`&&(t[i]=ZIe(t[i],r.component.axes[i]),t[i]||(n.axis[i]=`independent`,delete t[i]))}for(let i of k4){for(let a of e.children)if(a.component.axes[i]){if(n.axis[i]===`independent`){t[i]=(t[i]??[]).concat(a.component.axes[i]);for(let e of a.component.axes[i]){let{value:t,explicit:n}=e.getWithExplicit(`orient`);if(!JQ(t)){if(r[t]>0&&!n){let n=dBe[t];r[t]>r[n]&&e.set(`orient`,n,!1)}r[t]++}}}delete a.component.axes[i]}if(n.axis[i]===`independent`&&t[i]&&t[i].length>1)for(let[e,n]of(t[i]||[]).entries())e>0&&n.get(`grid`)&&!n.explicit.grid&&(n.implicit.grid=!1)}}function ZIe(e,t){if(e){if(e.length!==t.length)return;let n=e.length;for(let r=0;re.clone());return e}function QIe(e,t){for(let n of v8){let r=S0(e.getWithExplicit(n),t.getWithExplicit(n),n,`axis`,(e,t)=>{switch(n){case`title`:return f$(e,t);case`gridScale`:return{explicit:e.explicit,value:cQ(e.value,t.value)}}return x0(e,t,n,`axis`)});e.setWithExplicit(n,r)}return e}function $Ie(e,t,n,r,i){if(t===`disable`)return n!==void 0;switch(n||={},t){case`titleAngle`:case`labelAngle`:return e===(JQ(n.labelAngle)?n.labelAngle:fQ(n.labelAngle));case`values`:return!!n.values;case`encode`:return!!n.encoding||!!n.labelAngle;case`title`:if(e===gPe(r,i))return!0}return e===n[t]}function eLe(e,t){let n=t.axis(e),r=new uBe,i=z1(t.encoding[e]),{mark:a,config:o}=t,s=n?.orient||o[e===`x`?`axisX`:`axisY`]?.orient||o.axis?.orient||pPe(e),c=t.getScaleComponent(e).get(`type`),l=iPe(e,c,s,t.config),u=n===void 0?Z0(`disable`,o.style,n?.style,l).configValue:!n;if(r.set(`disable`,u,n!==void 0),u)return r;n||={};let d=cPe(i,n,e,o.style,l),f=FAe(n.formatType,i,c),p=PAe(i,i.type,n.format,n.formatType,o,!0),m={fieldOrDatumDef:i,axis:n,channel:e,model:t,scaleType:c,orient:s,labelAngle:d,format:p,formatType:f,mark:a,config:o};for(let i of v8){let a=i in D6?D6[i](m):pje(i)?n[i]:void 0,s=a!==void 0,c=$Ie(a,i,n,t,e);if(s&&c)r.set(i,a,c);else{let{configValue:e=void 0,configFrom:t=void 0}=pje(i)&&i!==`values`?Z0(i,o.style,n.style,l):{},u=e!==void 0;s&&!u?r.set(i,a,c):(t!==`vgAxisConfig`||fBe.has(i)&&u||K1(e)||JQ(e))&&r.set(i,e,!1)}}let h=n.encoding??{},g=C3.reduce((n,i)=>{if(!r.hasAxisPart(i))return n;let a=jPe(h[i]??{},t),o=i===`labels`?JIe(t,e,a):a;return o!==void 0&&!qZ(o)&&(n[i]={update:o}),n},{});return qZ(g)||r.set(`encode`,g,!!n.encoding||n.labelAngle!==void 0),r}function tLe({encoding:e,size:t}){for(let n of k4){let r=TQ(n);c0(t[r])&&E1(e[n])&&(delete t[r],X(k$(r)))}return t}function A2(e,t){let{config:n}=e;return{...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`include`,orient:`ignore`,theta:`ignore`}),...L0(`x`,e,{defaultPos:`mid`}),...L0(`y`,e,{defaultPos:`mid`}),...F0(`size`,e),...F0(`angle`,e),...nLe(e,n,t)}}function nLe(e,t,n){return n?{shape:{value:n}}:F0(`shape`,e)}function rLe(e,t,n){if(a$(`align`,e,n)===void 0)return`center`}function iLe(e,t,n){if(a$(`baseline`,e,n)===void 0)return`middle`}function aLe(e){if(RZ([o3,i3,WRe],e.mark)){let t=Sje(e.mark,e.encoding);if(t.length>0)return oLe(e,t)}else if(e.mark===a3){let t=I4.some(t=>a$(t,e.markDef,e.config));if(e.stack&&!e.fieldDef(`size`)&&t)return sLe(e)}return j2(e)}function oLe(e,t){return[{name:e.getName(`pathgroup`),type:`group`,from:{facet:{name:b8+e.requestDataName(G3.Main),data:e.requestDataName(G3.Main),groupby:t}},encode:{update:{width:{field:{group:`width`}},height:{field:{group:`height`}}}},marks:j2(e,{fromPrefix:b8})}]}function sLe(e){let[t]=j2(e,{fromPrefix:x8}),n=e.scaleName(e.stack.fieldChannel),r=(t={})=>e.vgField(e.stack.fieldChannel,t),i=(e,t)=>`${e}(${[r({prefix:`min`,suffix:`start`,expr:t}),r({prefix:`max`,suffix:`start`,expr:t}),r({prefix:`min`,suffix:`end`,expr:t}),r({prefix:`max`,suffix:`end`,expr:t})].map(e=>`scale('${n}',${e})`).join(`,`)})`,a,o;e.stack.fieldChannel===`x`?(a={...PZ(t.encode.update,[`y`,`yc`,`y2`,`height`,...I4]),x:{signal:i(`min`,`datum`)},x2:{signal:i(`max`,`datum`)},clip:{value:!0}},o={x:{field:{group:`x`},mult:-1},height:{field:{group:`height`}}},t.encode.update={...FZ(t.encode.update,[`y`,`yc`,`y2`]),height:{field:{group:`height`}}}):(a={...PZ(t.encode.update,[`x`,`xc`,`x2`,`width`]),y:{signal:i(`min`,`datum`)},y2:{signal:i(`max`,`datum`)},clip:{value:!0}},o={y:{field:{group:`y`},mult:-1},width:{field:{group:`width`}}},t.encode.update={...FZ(t.encode.update,[`x`,`xc`,`x2`]),width:{field:{group:`width`}}});for(let n of I4){let r=o$(n,e.markDef,e.config);t.encode.update[n]?(a[n]=t.encode.update[n],delete t.encode.update[n]):r&&(a[n]=t$(r)),r&&(t.encode.update[n]={value:0})}let s=[];if(e.stack.groupbyChannels?.length>0)for(let t of e.stack.groupbyChannels){let n=e.fieldDef(t),r=Q(n);r&&s.push(r),(n?.bin||n?.timeUnit)&&s.push(Q(n,{binSuffix:`end`}))}return a=[`stroke`,`strokeWidth`,`strokeJoin`,`strokeCap`,`strokeDash`,`strokeDashOffset`,`strokeMiterLimit`,`strokeOpacity`].reduce((n,r)=>{if(t.encode.update[r])return{...n,[r]:t.encode.update[r]};{let t=o$(r,e.markDef,e.config);return t===void 0?n:{...n,[r]:t$(t)}}},a),a.stroke&&(a.strokeForeground={value:!0},a.strokeOffset={value:0}),[{type:`group`,from:{facet:{data:e.requestDataName(G3.Main),name:x8+e.requestDataName(G3.Main),groupby:s,aggregate:{fields:[r({suffix:`start`}),r({suffix:`start`}),r({suffix:`end`}),r({suffix:`end`})],ops:[`min`,`max`,`min`,`max`]}}},encode:{update:a},marks:[{type:`group`,encode:{update:o},marks:[t]}]}]}function cLe(e){let{encoding:t,stack:n,mark:r,markDef:i,config:a}=e,o=t.order;if(!(!H(o)&&A1(o)&&LZ(o.value)||!o&&LZ(a$(`order`,i,a)))){if((H(o)||Z(o))&&!n)return l$(o,{expr:`datum`});if(e1(r)){let e=i.orient===`horizontal`?`y`:`x`,n=t[e];if(Z(n))return{field:e}}}}function j2(e,t={fromPrefix:``}){let{mark:n,markDef:r,encoding:i,config:a}=e,o=cQ(r.clip,lLe(e),uLe(e)),s=i$(r),c=i.key,l=cLe(e),u=dLe(e);u&&Object.values(e.component.selection).some(e=>e.type===`point`&&!e.bind&&e.on!==`pointerover`)&&(e.markDef.cursor??=`pointer`);let d=a$(`aria`,r,a),f=y8[n].postEncodingTransform?y8[n].postEncodingTransform(e):null;return[{name:e.getName(`marks`),type:y8[n].vgMark,...o?{clip:o}:{},...s?{style:s}:{},...c?{key:c.field}:{},...l?{sort:l}:{},...u||{},...d===!1?{aria:d}:{},from:{data:t.fromPrefix+e.requestDataName(G3.Main)},encode:{update:y8[n].encodeEntry(e)},...f?{transform:f}:{}}]}function lLe(e){let t=e.getScaleComponent(`x`),n=e.getScaleComponent(`y`);return t?.get(`selectionExtent`)||n?.get(`selectionExtent`)?!0:void 0}function uLe(e){let t=e.component.projection;return t&&!t.isFit?!0:void 0}function dLe(e){if(!e.component.selection)return null;let t=$(e.component.selection).length,n=t,r=e.parent;for(;r&&n===0;)n=$(r.component.selection).length,r=r.parent;return n?{interactive:t>0||e.mark===`geoshape`||!!e.encoding.tooltip||!!e.markDef.tooltip}:null}function M2(e,t,n,r,i){if(v1(e))return new cBe(e,t,n,i);if(f0(e))return new EBe(e,t,n,r,i);if(q1(e))return new S8(e,t,n,r,i);if(Hje(e))return new lBe(e,t,n,i);throw Error(p$(e))}function fLe(e,t={}){t.logger&&zke(t.logger),t.fieldTitle&&aje(t.fieldTitle);try{let n=Zje(vh(t.config,e.config)),r=JMe(e,n),i=M2(r,null,``,void 0,n);return i.parse(),bFe(i.component.data,i),{spec:mLe(i,pLe(e,r.autosize,n,i),e.datasets,e.usermeta),normalized:r}}finally{t.logger&&Bke(),t.fieldTitle&&oje()}}function pLe(e,t,n,r){let i=r.component.layoutSize.get(`width`),a=r.component.layoutSize.get(`height`);if(t===void 0?(t={type:`pad`},r.hasAxisOrientSignalRef()&&(t.resize=!0)):gg(t)&&(t={type:t}),i&&a&&QMe(t.type)){if(i===`step`&&a===`step`)X(g$()),t.type=`pad`;else if(i===`step`||a===`step`){let e=i===`step`?`width`:`height`;X(g$(kQ(e))),t.type=$Me(e===`width`?`height`:`width`)}}return{...$(t).length===1&&t.type?t.type===`pad`?{}:{autosize:t.type}:{autosize:t},...eNe(n,!1),...eNe(e,!0)}}function mLe(e,t,n={},r){let i=e.config?Qje(e.config):void 0,a=NIe(e.component.data,n),o=e.assembleSelectionData(a),s=e.assembleProjections(),c=e.assembleTitle(),l=e.assembleGroupStyle(),u=e.assembleGroupEncodeEntry(!0),d=e.assembleLayoutSignals();d=d.filter(e=>(e.name===`width`||e.name===`height`)&&e.value!==void 0?(t[e.name]=+e.value,!1):!0);let{params:f,...p}=t;return{$schema:`https://vega.github.io/schema/vega/v6.json`,...e.description?{description:e.description}:{},...p,...c?{title:c}:{},...l?{style:l}:{},...u?{encode:{update:u}}:{},data:o,...s.length>0?{projections:s}:{},...e.assembleGroup([...d,...e.assembleSelectionTopLevelSignals([]),...Vje(f)]),...i?{config:i}:{},...r?{usermeta:r}:{}}}var hLe,N2,$,P2,F2,I2,L2,R2,z2,B2,V2,H2,U2,W2,G2,K2,q2,J2,Y2,X2,Z2,Q2,$2,e4,t4,n4,r4,i4,a4,o4,s4,c4,l4,u4,d4,f4,p4,m4,h4,g4,_4,v4,y4,b4,gLe,x4,S4,_Le,C4,w4,T4,E4,vLe,yLe,bLe,xLe,SLe,CLe,wLe,TLe,ELe,DLe,OLe,kLe,ALe,jLe,MLe,NLe,PLe,FLe,ILe,LLe,RLe,zLe,BLe,VLe,HLe,D4,ULe,O4,k4,A4,WLe,j4,GLe,KLe,qLe,JLe,YLe,XLe,ZLe,QLe,$Le,M4,eRe,N4,P4,F4,tRe,nRe,rRe,iRe,aRe,oRe,sRe,cRe,lRe,I4,uRe,dRe,fRe,pRe,mRe,hRe,gRe,_Re,L4,vRe,yRe,bRe,xRe,SRe,R4,CRe,wRe,TRe,z4,B4,V4,ERe,H4,DRe,U4,W4,ORe,kRe,G4,K4,q4,J4,Y4,X4,Z4,Q4,ARe,$4,e3,t3,jRe,MRe,NRe,PRe,FRe,IRe,LRe,RRe,zRe,BRe,VRe,n3,r3,i3,a3,HRe,o3,s3,URe,c3,l3,u3,WRe,d3,f3,p3,GRe,KRe,qRe,JRe,m3,h3,YRe,XRe,g3,ZRe,_3,QRe,$Re,v3,eze,y3,b3,x3,S3,C3,tze,w3,nze,T3,E3,D3,rze,ize,O3,aze,oze,k3,sze,cze,A3,lze,j3,M3,uze,dze,N3,P3,fze,pze,F3,mze,I3,hze,L3,gze,R3,z3,B3,_ze,vze,yze,bze,V3,xze,Sze,Cze,H3,wze,Tze,Eze,Dze,U3,Oze,kze,Aze,jze,W3,Mze,G3,K3,q3,J3,Y3,X3,Z3,Nze,Pze,Q3,$3,e6,t6,n6,r6,i6,a6,Fze,Ize,Lze,o6,s6,c6,l6,u6,Rze,zze,Bze,Vze,d6,f6,p6,m6,h6,g6,Hze,_6,v6,y6,Uze,b6,x6,Wze,S6,C6,Gze,w6,T6,E6,D6,O6,k6,A6,Kze,j6,qze,M6,N6,P6,F6,I6,L6,R6,z6,B6,V6,H6,U6,W6,Jze,Yze,Xze,Zze,Qze,$ze,eBe,tBe,nBe,rBe,iBe,G6,K6,q6,J6,Y6,X6,Z6,aBe,Q6,$6,oBe,e8,t8,sBe,n8,r8,i8,a8,o8,s8,c8,l8,u8,d8,f8,p8,m8,h8,g8,_8,cBe,lBe,v8,uBe,dBe,fBe,pBe,mBe,hBe,gBe,_Be,vBe,yBe,bBe,xBe,SBe,CBe,wBe,TBe,y8,b8,x8,S8,EBe,DBe,OBe=o((()=>{Tg(),BY(),rK(),AOe(),hLe={version:`6.4.3`},N2=structuredClone,Set.prototype.toJSON=function(){return`Set(${[...this].map(e=>hQ(e)).join(`,`)})`},$=Object.keys,P2=Object.values,F2=Object.entries,I2=42,L2=Object.getPrototypeOf(structuredClone({})),R2=`row`,z2=`column`,B2=`facet`,V2=`x`,H2=`y`,U2=`x2`,W2=`y2`,G2=`xOffset`,K2=`yOffset`,q2=`radius`,J2=`radius2`,Y2=`theta`,X2=`theta2`,Z2=`latitude`,Q2=`longitude`,$2=`latitude2`,e4=`longitude2`,t4=`time`,n4=`color`,r4=`fill`,i4=`stroke`,a4=`shape`,o4=`size`,s4=`angle`,c4=`opacity`,l4=`fillOpacity`,u4=`strokeOpacity`,d4=`strokeWidth`,f4=`strokeDash`,p4=`text`,m4=`order`,h4=`detail`,g4=`key`,_4=`tooltip`,v4=`href`,y4=`url`,b4=`description`,gLe={x:1,y:1,x2:1,y2:1},x4={theta:1,theta2:1,radius:1,radius2:1},S4={longitude:1,longitude2:1,latitude:1,latitude2:1},_Le=$(S4),C4={...gLe,...x4,...S4,xOffset:1,yOffset:1,color:1,fill:1,stroke:1,time:1,opacity:1,fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeDash:1,size:1,angle:1,shape:1,order:1,text:1,detail:1,key:1,tooltip:1,href:1,url:1,description:1},w4={row:1,column:1,facet:1},T4=$(w4),E4={...C4,...w4},vLe=$(E4),{order:yLe,detail:bLe,tooltip:xLe,...SLe}=E4,{row:CLe,column:wLe,facet:TLe,...ELe}=SLe,DLe=[U2,W2,$2,e4,X2,J2],OLe=$(C4),{x:kLe,y:ALe,x2:jLe,y2:MLe,xOffset:NLe,yOffset:PLe,latitude:FLe,longitude:ILe,latitude2:LLe,longitude2:RLe,theta:zLe,theta2:BLe,radius:VLe,radius2:HLe,...D4}=C4,ULe=$(D4),O4={x:1,y:1},k4=$(O4),A4={theta:1,radius:1},WLe=$(A4),j4={xOffset:1,yOffset:1},GLe={time:1},{text:KLe,tooltip:qLe,href:JLe,url:YLe,description:XLe,detail:ZLe,key:QLe,order:$Le,...M4}=D4,eRe=$(M4),N4={...O4,...A4,...j4,...M4},P4=$(N4),F4={arc:`always`,area:`always`,bar:`always`,circle:`always`,geoshape:`always`,image:`always`,line:`always`,rule:`always`,point:`always`,rect:`always`,square:`always`,trail:`always`,text:`always`,tick:`always`},{geoshape:tRe,...nRe}=F4,rRe={argmax:1,argmin:1,average:1,count:1,distinct:1,exponential:1,exponentialb:1,product:1,max:1,mean:1,median:1,min:1,missing:1,q1:1,q3:1,ci0:1,ci1:1,stderr:1,stdev:1,stdevp:1,sum:1,valid:1,values:1,variance:1,variancep:1},iRe={count:1,min:1,max:1},aRe=new Set([`count`,`valid`,`missing`,`distinct`]),oRe=new Set([`count`,`sum`,`distinct`,`valid`,`missing`]),sRe=new Set([`mean`,`average`,`median`,`q1`,`q3`,`min`,`max`]),cRe=$({aria:1,description:1,ariaRole:1,ariaRoleDescription:1,blend:1,opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeOffset:1,strokeMiterLimit:1,startAngle:1,endAngle:1,padAngle:1,innerRadius:1,outerRadius:1,size:1,shape:1,interpolate:1,tension:1,orient:1,align:1,baseline:1,text:1,dir:1,dx:1,dy:1,ellipsis:1,limit:1,radius:1,theta:1,angle:1,font:1,fontSize:1,fontWeight:1,fontStyle:1,lineBreak:1,lineHeight:1,cursor:1,href:1,tooltip:1,cornerRadius:1,cornerRadiusTopLeft:1,cornerRadiusTopRight:1,cornerRadiusBottomLeft:1,cornerRadiusBottomRight:1,aspect:1,width:1,height:1,url:1,smooth:1}),lRe={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},I4=[`cornerRadius`,`cornerRadiusTopLeft`,`cornerRadiusTopRight`,`cornerRadiusBottomLeft`,`cornerRadiusBottomRight`],uRe=` – `,dRe=`Autosize "fit" only works for single views and layered views.`,fRe=`Scale bindings are currently only supported for scales with unbinned, continuous domains.`,pRe=`Sequntial scales are deprecated. The available quantitative scale type values are linear, log, pow, sqrt, symlog, time and utc`,mRe=`Legend bindings are only supported for selections over an individual field or encoding channel.`,hRe=`The same selection must be used to override scale domains in a layered view.`,gRe=`Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.`,_Re=`Multiple timer selections in one unit spec are not supported. Ignoring all but the first.`,L4=`Animation involving facet, layer, or concat is currently unsupported.`,vRe=`Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).`,yRe=`Attempt to add the same child twice.`,bRe=`If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.`,xRe=`Arc marks uses theta channel rather than angle, replacing angle with theta.`,SRe=`Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.`,R4=`Domains that should be unioned has conflicting sort properties. Sort will be set to true.`,CRe=`Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect.`,wRe=`Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect.`,TRe=`Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.`,z4=mh(2),B4=z4,V4=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`],ERe=V4.map(e=>e.substr(0,3)),H4=[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`],DRe=H4.map(e=>e.substr(0,3)),U4={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},W4=$(U4),ORe={"year-month":`%b %Y `,"year-month-date":`%b %d, %Y `},kRe={year:1,month:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},G4={quantitative:`quantitative`,ordinal:`ordinal`,temporal:`temporal`,nominal:`nominal`,geojson:`geojson`},K4=G4.quantitative,q4=G4.ordinal,J4=G4.temporal,Y4=G4.nominal,X4=G4.geojson,Z4={LINEAR:`linear`,LOG:`log`,POW:`pow`,SQRT:`sqrt`,TIME:`time`,UTC:`utc`,POINT:`point`,BAND:`band`},Q4={linear:`numeric`,log:`numeric`,pow:`numeric`,sqrt:`numeric`,symlog:`numeric`,identity:`numeric`,sequential:`numeric`,time:`time`,utc:`time`,ordinal:`ordinal`,"bin-ordinal":`bin-ordinal`,point:`ordinal-position`,band:`ordinal-position`,quantile:`discretizing`,quantize:`discretizing`,threshold:`discretizing`},ARe={linear:0,log:1,pow:1,sqrt:1,symlog:1,identity:1,sequential:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0},$4=new Set([`linear`,`log`,`pow`,`sqrt`,`symlog`]),e3=new Set([...$4,`time`,`utc`]),t3=new Set([`quantile`,`quantize`,`threshold`]),jRe=new Set([...e3,...t3,`sequential`,`identity`]),MRe=new Set([`ordinal`,`bin-ordinal`,`point`,`band`]),NRe={pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,tickBandPaddingInner:.25,bandWithNestedOffsetPaddingInner:.2,bandWithNestedOffsetPaddingOuter:.2,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:4,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4,zero:!0,framesPerSecond:2,animationDuration:5},{type:PRe,domain:FRe,range:IRe,rangeMax:LRe,rangeMin:RRe,scheme:zRe,...BRe}={type:1,domain:1,domainMax:1,domainMin:1,domainMid:1,domainRaw:1,align:1,range:1,rangeMax:1,rangeMin:1,scheme:1,bins:1,reverse:1,round:1,clamp:1,nice:1,base:1,exponent:1,constant:1,interpolate:1,zero:1,padding:1,paddingInner:1,paddingOuter:1},VRe=$(BRe),n3={arc:`arc`,area:`area`,bar:`bar`,image:`image`,line:`line`,point:`point`,rect:`rect`,rule:`rule`,text:`text`,tick:`tick`,trail:`trail`,circle:`circle`,square:`square`,geoshape:`geoshape`},r3=n3.arc,i3=n3.area,a3=n3.bar,HRe=n3.image,o3=n3.line,s3=n3.point,URe=n3.rect,c3=n3.rule,l3=n3.text,u3=n3.tick,WRe=n3.trail,d3=n3.circle,f3=n3.square,p3=n3.geoshape,GRe=new Set($(n3)),KRe=[`stroke`,`strokeWidth`,`strokeDash`,`strokeDashOffset`,`strokeOpacity`,`strokeJoin`,`strokeMiterLimit`],qRe=[`fill`,`fillOpacity`],JRe=[...KRe,...qRe],m3=$({color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1}),h3=[`binSpacing`,`continuousBandSize`,`discreteBandSize`,`minBandSize`],YRe={area:[`line`,`point`],bar:h3,rect:h3,line:[`point`],tick:[`bandSize`,`thickness`,...h3]},XRe={color:`#4c78a8`,invalid:`break-paths-show-path-domains`,timeUnitBandSize:1},g3=$({mark:1,arc:1,area:1,bar:1,circle:1,image:1,line:1,point:1,rect:1,rule:1,square:1,text:1,tick:1,trail:1,geoshape:1}),ZRe={horizontal:[`cornerRadiusTopRight`,`cornerRadiusBottomRight`],vertical:[`cornerRadiusTopLeft`,`cornerRadiusTopRight`]},_3={binSpacing:0,continuousBandSize:5,minBandSize:.25,timeUnitBandPosition:.5},QRe={..._3,binSpacing:1},$Re={..._3,thickness:1},v3=`min`,eze={x:1,y:1,color:1,fill:1,stroke:1,strokeWidth:1,size:1,shape:1,fillOpacity:1,strokeOpacity:1,opacity:1,text:1},y3=(e,t)=>{switch(t.fieldTitle){case`plain`:return e.field;case`functional`:return ije(e);default:return rje(e,t)}},b3=y3,x3={compatible:!0},S3={labelAlign:{part:`labels`,vgProp:`align`},labelBaseline:{part:`labels`,vgProp:`baseline`},labelColor:{part:`labels`,vgProp:`fill`},labelFont:{part:`labels`,vgProp:`font`},labelFontSize:{part:`labels`,vgProp:`fontSize`},labelFontStyle:{part:`labels`,vgProp:`fontStyle`},labelFontWeight:{part:`labels`,vgProp:`fontWeight`},labelOpacity:{part:`labels`,vgProp:`opacity`},labelOffset:null,labelPadding:null,gridColor:{part:`grid`,vgProp:`stroke`},gridDash:{part:`grid`,vgProp:`strokeDash`},gridDashOffset:{part:`grid`,vgProp:`strokeDashOffset`},gridOpacity:{part:`grid`,vgProp:`opacity`},gridWidth:{part:`grid`,vgProp:`strokeWidth`},tickColor:{part:`ticks`,vgProp:`stroke`},tickDash:{part:`ticks`,vgProp:`strokeDash`},tickDashOffset:{part:`ticks`,vgProp:`strokeDashOffset`},tickOpacity:{part:`ticks`,vgProp:`opacity`},tickSize:null,tickWidth:{part:`ticks`,vgProp:`strokeWidth`}},C3=[`domain`,`grid`,`labels`,`ticks`,`title`],tze={grid:`grid`,gridCap:`grid`,gridColor:`grid`,gridDash:`grid`,gridDashOffset:`grid`,gridOpacity:`grid`,gridScale:`grid`,gridWidth:`grid`,orient:`main`,bandPosition:`both`,aria:`main`,description:`main`,domain:`main`,domainCap:`main`,domainColor:`main`,domainDash:`main`,domainDashOffset:`main`,domainOpacity:`main`,domainWidth:`main`,format:`main`,formatType:`main`,labelAlign:`main`,labelAngle:`main`,labelBaseline:`main`,labelBound:`main`,labelColor:`main`,labelFlush:`main`,labelFlushOffset:`main`,labelFont:`main`,labelFontSize:`main`,labelFontStyle:`main`,labelFontWeight:`main`,labelLimit:`main`,labelLineHeight:`main`,labelOffset:`main`,labelOpacity:`main`,labelOverlap:`main`,labelPadding:`main`,labels:`main`,labelSeparation:`main`,maxExtent:`main`,minExtent:`main`,offset:`both`,position:`main`,tickCap:`main`,tickColor:`main`,tickDash:`main`,tickDashOffset:`main`,tickMinStep:`both`,tickOffset:`both`,tickOpacity:`main`,tickRound:`both`,ticks:`main`,tickSize:`main`,tickWidth:`both`,title:`main`,titleAlign:`main`,titleAnchor:`main`,titleAngle:`main`,titleBaseline:`main`,titleColor:`main`,titleFont:`main`,titleFontSize:`main`,titleFontStyle:`main`,titleFontWeight:`main`,titleLimit:`main`,titleLineHeight:`main`,titleOpacity:`main`,titlePadding:`main`,titleX:`main`,titleY:`main`,encode:`both`,scale:`both`,tickBand:`both`,tickCount:`both`,tickExtra:`both`,translate:`both`,values:`both`,zindex:`both`},w3={orient:1,aria:1,bandPosition:1,description:1,domain:1,domainCap:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid:1,gridCap:1,gridColor:1,gridDash:1,gridDashOffset:1,gridOpacity:1,gridWidth:1,labelAlign:1,labelAngle:1,labelBaseline:1,labelBound:1,labelColor:1,labelFlush:1,labelFlushOffset:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelLineHeight:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickBand:1,tickCap:1,tickColor:1,tickCount:1,tickDash:1,tickDashOffset:1,tickExtra:1,tickMinStep:1,tickOffset:1,tickOpacity:1,tickRound:1,ticks:1,tickSize:1,tickWidth:1,title:1,titleAlign:1,titleAnchor:1,titleAngle:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,translate:1,values:1,zindex:1},nze={...w3,style:1,labelExpr:1,encoding:1},T3=$({axis:1,axisBand:1,axisBottom:1,axisDiscrete:1,axisLeft:1,axisPoint:1,axisQuantitative:1,axisRight:1,axisTemporal:1,axisTop:1,axisX:1,axisXBand:1,axisXDiscrete:1,axisXPoint:1,axisXQuantitative:1,axisXTemporal:1,axisY:1,axisYBand:1,axisYDiscrete:1,axisYPoint:1,axisYQuantitative:1,axisYTemporal:1}),E3=class{name;run;constructor(e,t){this.name=e,this.run=t}hasMatchingType(e){return q1(e)?wAe(e.mark)===this.name:!1}},D3=`boxplot`,rze=[`box`,`median`,`outliers`,`rule`,`ticks`],ize=new E3(D3,Oje),O3=`errorbar`,aze=[`ticks`,`rule`],oze=new E3(O3,jje),k3=`errorband`,sze=[`band`,`borders`],cze=new E3(k3,zje),A3={},t0(D3,Oje,rze),t0(O3,jje,aze),t0(k3,zje,sze),lze=[`gradientHorizontalMaxLength`,`gradientHorizontalMinLength`,`gradientVerticalMaxLength`,`gradientVerticalMinLength`,`unselectedOpacity`],j3={titleAlign:`align`,titleAnchor:`anchor`,titleAngle:`angle`,titleBaseline:`baseline`,titleColor:`color`,titleFont:`font`,titleFontSize:`fontSize`,titleFontStyle:`fontStyle`,titleFontWeight:`fontWeight`,titleLimit:`limit`,titleLineHeight:`lineHeight`,titleOrient:`orient`,titlePadding:`offset`},M3={labelAlign:`align`,labelAnchor:`anchor`,labelAngle:`angle`,labelBaseline:`baseline`,labelColor:`color`,labelFont:`font`,labelFontSize:`fontSize`,labelFontStyle:`fontStyle`,labelFontWeight:`fontWeight`,labelLimit:`limit`,labelLineHeight:`lineHeight`,labelOrient:`orient`,labelPadding:`offset`},uze=$(j3),dze=$(M3),N3=$({header:1,headerRow:1,headerColumn:1,headerFacet:1}),P3=[`size`,`shape`,`fill`,`stroke`,`strokeDash`,`strokeWidth`,`opacity`],fze={gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},pze={aria:1,clipHeight:1,columnPadding:1,columns:1,cornerRadius:1,description:1,direction:1,fillColor:1,format:1,formatType:1,gradientLength:1,gradientOpacity:1,gradientStrokeColor:1,gradientStrokeWidth:1,gradientThickness:1,gridAlign:1,labelAlign:1,labelBaseline:1,labelColor:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labelSeparation:1,legendX:1,legendY:1,offset:1,orient:1,padding:1,rowPadding:1,strokeColor:1,symbolDash:1,symbolDashOffset:1,symbolFillColor:1,symbolLimit:1,symbolOffset:1,symbolOpacity:1,symbolSize:1,symbolStrokeColor:1,symbolStrokeWidth:1,symbolType:1,tickCount:1,tickMinStep:1,title:1,titleAlign:1,titleAnchor:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1},F3=`_vgsid_`,mze={point:{on:`click`,fields:[F3],toggle:`event.shiftKey`,resolve:`global`,clear:`dblclick`},interval:{on:`[pointerdown, window:pointerup] > window:pointermove!`,encodings:[`x`,`y`],translate:`[pointerdown, window:pointerup] > window:pointermove!`,zoom:`wheel!`,mark:{fill:`#333`,fillOpacity:.125,stroke:`white`},resolve:`global`,clear:`dblclick`}},I3=20,hze=$({align:1,bounds:1,center:1,columns:1,spacing:1}),L3=20,gze={background:`white`,padding:5,timeFormat:`%b %d, %Y`,countTitle:`Count of Records`,view:{continuousWidth:300,continuousHeight:300,step:L3},mark:XRe,arc:{},area:{},bar:QRe,circle:{},geoshape:{},image:{},line:{},point:{},rect:_3,rule:{color:`black`},square:{},text:{color:`black`},tick:$Re,trail:{},boxplot:{size:14,extent:1.5,box:{},median:{color:`white`},outliers:{},rule:{},ticks:null},errorbar:{center:`mean`,rule:!0,ticks:!1},errorband:{band:{opacity:.3},borders:!1},scale:NRe,projection:{},legend:fze,header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:mze,style:{},title:{},facet:{spacing:I3},concat:{spacing:I3},normalizedNumberFormat:`.0%`},R3=[`#4c78a8`,`#f58518`,`#e45756`,`#72b7b2`,`#54a24b`,`#eeca3b`,`#b279a2`,`#ff9da6`,`#9d755d`,`#bab0ac`],z3={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},B3={blue:R3[0],orange:R3[1],red:R3[2],teal:R3[3],green:R3[4],yellow:R3[5],purple:R3[6],pink:R3[7],brown:R3[8],gray0:`#000`,gray1:`#111`,gray2:`#222`,gray3:`#333`,gray4:`#444`,gray5:`#555`,gray6:`#666`,gray7:`#777`,gray8:`#888`,gray9:`#999`,gray10:`#aaa`,gray11:`#bbb`,gray12:`#ccc`,gray13:`#ddd`,gray14:`#eee`,gray15:`#fff`},_ze=[...g3,...T3,...N3,`background`,`padding`,`legend`,`lineBreak`,`scale`,`style`,`title`,`view`],vze=new Set([`view`,...GRe]),yze=`color.fontSize.background.padding.facet.concat.numberFormat.numberFormatType.normalizedNumberFormat.normalizedNumberFormatType.timeFormat.countTitle.header.axisQuantitative.axisTemporal.axisDiscrete.axisPoint.axisXBand.axisXPoint.axisXDiscrete.axisXQuantitative.axisXTemporal.axisYBand.axisYPoint.axisYDiscrete.axisYQuantitative.axisYTemporal.scale.selection.overlay`.split(`.`),bze={view:[`continuousWidth`,`continuousHeight`,`discreteWidth`,`discreteHeight`,`step`],...YRe},V3=class{map(e,t){return v1(e)?this.mapFacet(e,t):tMe(e)?this.mapRepeat(e,t):s0(e)?this.mapHConcat(e,t):o0(e)?this.mapVConcat(e,t):a0(e)?this.mapConcat(e,t):this.mapLayerOrUnit(e,t)}mapLayerOrUnit(e,t){if(f0(e))return this.mapLayer(e,t);if(q1(e))return this.mapUnit(e,t);throw Error(p$(e))}mapLayer(e,t){return{...e,layer:e.layer.map(e=>this.mapLayerOrUnit(e,t))}}mapHConcat(e,t){return{...e,hconcat:e.hconcat.map(e=>this.map(e,t))}}mapVConcat(e,t){return{...e,vconcat:e.vconcat.map(e=>this.map(e,t))}}mapConcat(e,t){let{concat:n,...r}=e;return{...r,concat:n.map(e=>this.map(e,t))}}mapFacet(e,t){return{...e,spec:this.map(e.spec,t)}}mapRepeat(e,t){return{...e,spec:this.map(e.spec,t)}}},xze={zero:1,center:1,normalize:1},Sze=new Set([r3,a3,i3,c3,s3,d3,f3,o3,l3,u3]),Cze=new Set([a3,i3,r3]),H3=.7,wze=class{name=`path-overlay`;hasMatchingType(e,t){if(q1(e)){let{mark:n,encoding:r}=e,i=n1(n)?n:{type:n};switch(i.type){case`line`:case`rule`:case`trail`:return!!m0(i,t[i.type],r);case`area`:return!!m0(i,t[i.type],r)||!!mMe(i,t[i.type])}}return!1}run(e,t,n){let{config:r}=t,{params:i,projection:a,mark:o,name:s,encoding:c,...l}=e,u=Y1(c,r),d=n1(o)?o:{type:o},f=m0(d,r[d.type],u),p=d.type===`area`&&mMe(d,r[d.type]),m=[{name:s,...i?{params:i}:{},mark:fMe({...d.type===`area`&&a$(`opacity`,d,r)==null&&a$(`fillOpacity`,d,r)==null?{opacity:H3}:{},...d}),encoding:FZ(u,[`shape`])}],h=oMe(sMe(d,u,r),u),g=u;if(h){let{fieldChannel:e,offset:t}=h;g={...u,[e]:{...u[e],...t?{stack:t}:{}}}}return g=FZ(g,[`y2`,`x2`]),p&&m.push({...a?{projection:a}:{},mark:{type:`line`,...PZ(d,[`clip`,`interpolate`,`tension`,`tooltip`]),...p},encoding:g}),f&&m.push({...a?{projection:a}:{},mark:{type:`point`,opacity:1,filled:!0,...PZ(d,[`clip`,`tooltip`]),...f},encoding:g}),n({...l,layer:m},{...t,config:pMe(r)})}},Tze=class{name=`RuleForRangedLine`;hasMatchingType(e){if(q1(e)){let{encoding:t,mark:n}=e;if(n===`line`||n1(n)&&n.type===`line`)for(let e of DLe){let n=t[SQ(e)];if(t[e]&&(Z(n)&&!BQ(n.bin)||T1(n)))return!0}}return!1}run(e,t,n){let{encoding:r,mark:i}=e;return X(pke(!!r.x2,!!r.y2)),n({...e,mark:gh(i)?{...i,type:`rule`}:`rule`},t)}},Eze=class extends V3{nonFacetUnitNormalizers=[ize,oze,cze,new wze,new Tze];map(e,t){if(q1(e)){let n=J1(e.encoding,R2),r=J1(e.encoding,z2),i=J1(e.encoding,B2);if(n||r||i)return this.mapFacetedUnit(e,t)}return super.map(e,t)}mapUnit(e,t){let{parentEncoding:n,parentProjection:r}=t,i=h0(e.encoding,t.repeater),a={...e,...e.name?{name:[t.repeaterPrefix,e.name].filter(e=>e).join(`_`)}:{},...i?{encoding:i}:{}};if(n||r)return this.mapUnitWithParentEncodingOrProjection(a,t);let o=this.mapLayerOrUnit.bind(this);for(let e of this.nonFacetUnitNormalizers)if(e.hasMatchingType(a,t.config))return e.run(a,t,o);return a}mapRepeat(e,t){return nMe(e)?this.mapLayerRepeat(e,t):this.mapNonLayerRepeat(e,t)}mapLayerRepeat(e,t){let{repeat:n,spec:r,...i}=e,{row:a,column:o,layer:s}=n,{repeater:c={},repeaterPrefix:l=``}=t;return a||o?this.mapRepeat({...e,repeat:{...a?{row:a}:{},...o?{column:o}:{}},spec:{repeat:{layer:s},spec:r}},t):{...i,layer:s.map(e=>{let n={...c,layer:e},i=`${(r.name?`${r.name}_`:``)+l}child__layer_${XZ(e)}`,a=this.mapLayerOrUnit(r,{...t,repeater:n,repeaterPrefix:i});return a.name=i,a})}}mapNonLayerRepeat(e,t){let{repeat:n,spec:r,data:i,...a}=e;!H(n)&&e.columns&&(e=FZ(e,[`columns`]),X(b$(`repeat`)));let o=[],{repeater:s={},repeaterPrefix:c=``}=t,l=!H(n)&&n.row||[s?s.row:null],u=!H(n)&&n.column||[s?s.column:null],d=H(n)&&n||[s?s.repeat:null];for(let e of d)for(let i of l)for(let a of u){let l={repeat:e,row:i,column:a,layer:s.layer},u=`${(r.name?`${r.name}_`:``)+c}child__${H(n)?`${XZ(e)}`:(n.row?`row_${XZ(i)}`:``)+(n.column?`column_${XZ(a)}`:``)}`,d=this.map(r,{...t,repeater:l,repeaterPrefix:u});d.name=u,o.push(FZ(d,[`data`]))}let f=H(n)?e.columns:n.column?n.column.length:1;return{data:r.data??i,align:`all`,...a,columns:f,concat:o}}mapFacet(e,t){let{facet:n}=e;return g1(n)&&e.columns&&(e=FZ(e,[`columns`]),X(b$(`facet`))),super.mapFacet(e,t)}mapUnitWithParentEncodingOrProjection(e,t){let{encoding:n,projection:r}=e,{parentEncoding:i,parentProjection:a,config:o}=t,s=xMe({parentProjection:a,projection:r}),c=bMe({parentEncoding:i,encoding:h0(n,t.repeater)});return this.mapUnit({...e,...s?{projection:s}:{},...c?{encoding:c}:{}},{config:o})}mapFacetedUnit(e,t){let{row:n,column:r,facet:i,...a}=e.encoding,{mark:o,width:s,projection:c,height:l,view:u,params:d,encoding:f,...p}=e,{facetMapping:m,layout:h}=this.getFacetMappingAndLayout({row:n,column:r,facet:i},t),g=h0(a,t.repeater);return this.mapFacet({...p,...h,facet:m,spec:{...s?{width:s}:{},...l?{height:l}:{},...u?{view:u}:{},...c?{projection:c}:{},mark:o,encoding:g,...d?{params:d}:{}}},t)}getFacetMappingAndLayout(e,t){let{row:n,column:r,facet:i}=e;if(n||r){i&&X(dke([...n?[R2]:[],...r?[z2]:[]]));let t={},a={};for(let n of[R2,z2]){let r=e[n];if(r){let{align:e,center:i,spacing:o,columns:s,...c}=r;t[n]=c;for(let e of[`align`,`center`,`spacing`])r[e]!==void 0&&(a[e]??={},a[e][n]=r[e])}}return{facetMapping:t,layout:a}}else{let{align:e,center:n,spacing:r,columns:a,...o}=i;return{facetMapping:hMe(o,t.repeater),layout:{...e?{align:e}:{},...n?{center:n}:{},...r?{spacing:r}:{},...a?{columns:a}:{}}}}}mapLayer(e,{parentEncoding:t,parentProjection:n,...r}){let{encoding:i,projection:a,...o}=e,s={...r,parentEncoding:bMe({parentEncoding:t,encoding:i,layer:!0}),parentProjection:xMe({parentProjection:n,projection:a})};return super.mapLayer({...o,...e.name?{name:[s.repeaterPrefix,e.name].filter(e=>e).join(`_`)}:{}},s)}},Dze=class extends V3{map(e,t){return t.emptySelections??={},t.selectionPredicates??={},e=WMe(e,t),super.map(e,t)}mapLayerOrUnit(e,t){if(e=WMe(e,t),e.encoding){let n={};for(let[r,i]of F2(e.encoding))n[r]=GMe(i,t);e={...e,encoding:n}}return super.mapLayerOrUnit(e,t)}mapUnit(e,t){let{selection:n,...r}=e;return n?{...r,params:F2(n).map(([e,n])=>{let{init:r,bind:i,empty:a,...o}=n;o.type===`single`?(o.type=`point`,o.toggle=!1):o.type===`multi`&&(o.type=`point`),t.emptySelections[e]=a!==`none`;for(let n of P2(t.selectionPredicates[e]??{}))n.empty=a!==`none`;return{name:e,value:r,select:o,bind:i}})}:e}},U3=class extends V3{map(e,t){let n=t.selections??[];if(e.params&&!q1(e)){let t=[];for(let r of e.params)i0(r)?n.push(r):t.push(r);e.params=t}return t.selections=n,super.map(e,t)}mapUnit(e,t){let n=t.selections;if(!n||!n.length)return e;let r=(t.path??[]).concat(e.name),i=[];for(let t of n)if(!t.views||!t.views.length)i.push(t);else for(let n of t.views)(gg(n)&&(n===e.name||r.includes(n))||H(n)&&n.map(e=>r.indexOf(e)).every((e,t,n)=>e!==-1&&(t===0||e>n[t-1])))&&i.push(t);return i.length&&(e.params=i),e}};for(let e of[`mapFacet`,`mapRepeat`,`mapHConcat`,`mapVConcat`,`mapLayer`]){let t=U3.prototype[e];U3.prototype[e]=function(e,n){return t.call(this,e,qMe(e,n))}}Oze=new Eze,kze=new Dze,Aze=new U3,jze=[`background`,`padding`],W3=class e{explicit;implicit;constructor(e={},t={}){this.explicit=e,this.implicit=t}clone(){return new e(N2(this.explicit),N2(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(e){return cQ(this.explicit[e],this.implicit[e])}getWithExplicit(e){return this.explicit[e]===void 0?this.implicit[e]===void 0?{explicit:!1,value:void 0}:{explicit:!1,value:this.implicit[e]}:{explicit:!0,value:this.explicit[e]}}setWithExplicit(e,{value:t,explicit:n}){t!==void 0&&this.set(e,t,n)}set(e,t,n){return delete this[n?`implicit`:`explicit`][e],this[n?`explicit`:`implicit`][e]=t,this}copyKeyFromSplit(e,{explicit:t,implicit:n}){t[e]===void 0?n[e]!==void 0&&this.set(e,n[e],!1):this.set(e,t[e],!0)}copyKeyFromObject(e,t){t[e]!==void 0&&this.set(e,t[e],!0)}copyAll(e){for(let t of $(e.combine())){let n=e.getWithExplicit(t);this.setWithExplicit(t,n)}}},Mze=class extends W3{explicit;implicit;parseNothing;constructor(e={},t={},n=!1){super(e,t),this.explicit=e,this.implicit=t,this.parseNothing=n}clone(){let e=super.clone();return e.parseNothing=this.parseNothing,e}},(function(e){e[e.Raw=0]=`Raw`,e[e.Main=1]=`Main`,e[e.Row=2]=`Row`,e[e.Column=3]=`Column`,e[e.Lookup=4]=`Lookup`,e[e.PreFilterInvalid=5]=`PreFilterInvalid`,e[e.PostFilterInvalid=6]=`PostFilterInvalid`})(G3||={}),K3=class{debugName;_children=[];_parent=null;_hash;constructor(e,t){this.debugName=t,e&&(this.parent=e)}clone(){throw Error(`Cannot clone node`)}get parent(){return this._parent}set parent(e){this._parent=e,e&&e.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(e,t){if(this._children.includes(e)){X(yRe);return}t===void 0?this._children.push(e):this._children.splice(t,0,e)}removeChild(e){let t=this._children.indexOf(e);return this._children.splice(t,1),t}remove(){let e=this._parent.removeChild(this);for(let t of this._children)t._parent=this._parent,this._parent.addChild(t,e++)}insertAsParentOf(e){let t=e.parent;t.removeChild(this),this.parent=t,e.parent=this}swapWithParent(){let e=this._parent,t=e.parent;for(let t of this._children)t.parent=e;this._children=[],e.removeChild(this);let n=e.parent.removeChild(e);this._parent=t,t.addChild(this,n),e.parent=this}},q3=class extends K3{type;refCounts;_source;_name;clone(){let e=new this.constructor;return e.debugName=`clone_${this.debugName}`,e._source=this._source,e._name=`clone_${this._name}`,e.type=this.type,e.refCounts=this.refCounts,e.refCounts[e._name]=0,e}constructor(e,t,n,r){super(e,t),this.type=n,this.refCounts=r,this._source=this._name=t,this.refCounts&&!(this._name in this.refCounts)&&(this.refCounts[this._name]=0)}dependentFields(){return new Set}producedFields(){return new Set}hash(){return this._hash===void 0&&(this._hash=`Output ${lQ()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(e){this._source=e}},J3=class e extends K3{timeUnits;clone(){return new e(null,N2(this.timeUnits))}constructor(e,t){super(e),this.timeUnits=t}static makeFromEncoding(t,n){let r=n.reduceFieldDef((e,t,r)=>{let{field:i,timeUnit:a}=t;if(a){let o;if(F$(a)){if(x2(n)){let{mark:e,markDef:r,config:s}=n,c=b1({fieldDef:t,markDef:r,config:s});(t1(e)||c)&&(o={timeUnit:R$(a),field:i})}}else o={as:Q(t,{forAs:!0}),field:i,timeUnit:a};if(x2(n)){let{mark:e,markDef:i,config:a}=n,s=b1({fieldDef:t,markDef:i,config:a});t1(e)&&OQ(r)&&s!==.5&&(o.rectBandPosition=s)}o&&(e[IZ(o)]=o)}return e},{});return qZ(r)?null:new e(t,r)}static makeFromTransform(t,n){let{timeUnit:r,...i}={...n},a=R$(r),o={...i,timeUnit:a};return new e(t,{[IZ(o)]:o})}merge(e){this.timeUnits={...this.timeUnits};for(let t in e.timeUnits)this.timeUnits[t]||(this.timeUnits[t]=e.timeUnits[t]);for(let t of e.children)e.removeChild(t),t.parent=this;e.remove()}removeFormulas(e){let t={};for(let[n,r]of F2(this.timeUnits)){let i=D0(r)?r.as:`${r.field}_end`;e.has(i)||(t[n]=r)}this.timeUnits=t}producedFields(){return new Set(P2(this.timeUnits).map(e=>D0(e)?e.as:sNe(e.field)))}dependentFields(){return new Set(P2(this.timeUnits).map(e=>e.field))}hash(){return`TimeUnit ${IZ(this.timeUnits)}`}assemble(){let e=[];for(let t of P2(this.timeUnits)){let{rectBandPosition:n}=t,r=R$(t.timeUnit);if(D0(t)){let{field:i,as:a}=t,{unit:o,utc:s,...c}=r,l=[a,`${a}_end`];e.push({field:iQ(i),type:`timeunit`,...o?{units:L$(o)}:{},...s?{timezone:`utc`}:{},...c,as:l}),e.push(...lNe(l,n,r))}else if(t){let{field:i}=t,a=rQ(i),o=cNe({timeUnit:r,field:a}),s=sNe(a);e.push({type:`formula`,expr:o,as:s}),e.push(...lNe([a,s],n,r))}}return e}},Y3=`offsetted_rect_start`,X3=`offsetted_rect_end`,Z3=`_tuple_fields`,Nze=class{hasChannel;hasField;hasSelectionId;timeUnit;items;constructor(...e){this.items=e,this.hasChannel={},this.hasField={},this.hasSelectionId=!1}},Pze={defined:()=>!0,parse:(e,t,n)=>{let r=t.name,i=t.project??=new Nze,a={},o={},s=new Set,c=(e,t)=>{let n=t===`visual`?e.channel:e.field,i=XZ(`${r}_${n}`);for(let e=1;s.has(i);e++)i=XZ(`${r}_${n}_${e}`);return s.add(i),{[t]:i}},l=t.type,u=e.config.selection[l],d=n.value===void 0?null:Gh(n.value),{fields:f,encodings:p}=gh(n.select)?n.select:{};if(!f&&!p&&d){for(let e of d)if(gh(e))for(let t of $(e))IOe(t)?(p||=[]).push(t):l===`interval`?(X(gRe),p=u.encodings):(f??=[]).push(t)}!f&&!p&&(p=u.encodings,`fields`in u&&(f=u.fields));for(let t of p??[]){let n=e.fieldDef(t);if(n){let r=n.field;if(n.aggregate){X(KOe(t,n.aggregate));continue}else if(!r){X(v$(t));continue}if(n.timeUnit&&!F$(n.timeUnit)){r=e.vgField(t);let i={timeUnit:n.timeUnit,as:r,field:n.field};o[IZ(i)]=i}if(!a[r]){let o=l===`interval`&&MQ(t)&&X$(e.getScaleComponent(t).get(`type`))?`R`:n.bin?`R-RE`:`E`,s={field:r,channel:t,type:o,index:i.items.length};s.signals={...c(s,`data`),...c(s,`visual`)},i.items.push(a[r]=s),i.hasField[r]=a[r],i.hasSelectionId=i.hasSelectionId||r===F3,vQ(t)?(s.geoChannel=t,s.channel=_Q(t),i.hasChannel[s.channel]=a[r]):i.hasChannel[t]=a[r]}}else X(v$(t))}for(let e of f??[]){if(i.hasField[e])continue;let t={type:`E`,field:e,index:i.items.length};t.signals={...c(t,`data`)},i.items.push(t),i.hasField[e]=t,i.hasSelectionId=i.hasSelectionId||e===F3}d&&(t.init=d.map(e=>i.items.map(t=>gh(e)?e[t.geoChannel||t.channel]===void 0?e[t.field]:e[t.geoChannel||t.channel]:e))),qZ(o)||(i.timeUnit=new J3(null,o))},signals:(e,t,n)=>{let r=t.name+Z3;return n.filter(e=>e.name===r).length>0||t.project.hasSelectionId?n:n.concat({name:r,value:t.project.items.map(dNe)})}},Q3=`_curr`,$3=`anim_value`,e6=`anim_clock`,t6=`eased_anim_clock`,n6=`min_extent`,r6=`max_range_extent`,i6=`last_tick_at`,a6=`is_playing`,Fze=1/60*1e3,Ize=(e,t)=>[{name:t6,update:e6},{name:`${e}_domain`,init:`domain('${t}')`},{name:n6,init:`extent(${e}_domain)[0]`},{name:r6,init:`extent(range('${t}'))[1]`},{name:$3,update:`invert('${t}', ${t6})`}],Lze={defined:e=>e.type===`point`,topLevelSignals:(e,t,n)=>(K0(t)&&(n=n.concat([{name:e6,init:`0`,on:[{events:{type:`timer`,throttle:Fze},update:`${a6} ? (${e6} + (now() - ${i6}) > ${r6} ? 0 : ${e6} + (now() - ${i6})) : ${e6}`}]},{name:i6,init:`now()`,on:[{events:[{signal:e6},{signal:a6}],update:`now()`}]},{name:a6,init:`true`}])),n),signals:(e,t,n)=>{let r=t.name,i=r+Z3,a=t.project,o=`(item().isVoronoi ? datum.datum : datum)`,s=P2(e.component.selection??{}).reduce((e,t)=>t.type===`interval`?e.concat(t.name+s6):e,[]).map(e=>`indexof(item().mark.name, '${e}') < 0`).join(` && `),c=`datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0${s?` && ${s}`:``}`,l=`unit: ${W0(e)}, `;if(t.project.hasSelectionId)l+=`${F3}: ${o}[${W(F3)}]`;else if(K0(t))l+=`fields: ${i}, values: [${$3} ? ${$3} : ${n6}]`;else{let t=a.items.map(t=>e.fieldDef(t.channel)?.bin?`[${o}[${W(e.vgField(t.channel,{}))}], ${o}[${W(e.vgField(t.channel,{binSuffix:`end`}))}]]`:`${o}[${W(t.field)}]`).join(`, `);l+=`fields: ${i}, values: [${t}]`}if(K0(t))return n.concat(Ize(t.name,e.scaleName(t4)),[{name:r+C6,on:[{events:[{signal:t6},{signal:$3}],update:`{${l}}`,force:!0}]}]);{let e=t.events;return n.concat([{name:r+C6,on:e?[{events:e,update:`${c} ? {${l}} : null`,force:!0}]:[]}])}}},o6={defined:e=>e.type===`interval`&&e.resolve===`global`&&e.bind&&e.bind===`scales`,parse:(e,t)=>{let n=t.scales=[];for(let r of t.project.items){let i=r.channel;if(!MQ(i))continue;let a=e.getScaleComponent(i),o=a?a.get(`type`):void 0;if(o==`sequential`&&X(pRe),!a||!X$(o)){X(fRe);continue}a.set(`selectionExtent`,{param:t.name,field:r.field},!0),n.push(r)}},topLevelSignals:(e,t,n)=>{let r=t.scales.filter(e=>n.filter(t=>t.name===e.signals.data).length===0);if(!e.parent||j0(e)||r.length===0)return n;let i=n.find(e=>e.name===t.name),a=i.update;if(a.includes(w6))i.update=`{${r.map(e=>`${W(iQ(e.field))}: ${e.signals.data}`).join(`, `)}}`;else{for(let e of r){let t=`${W(iQ(e.field))}: ${e.signals.data}`;a.includes(t)||(a=`${a.substring(0,a.length-1)}, ${t}}`)}i.update=a}return n.concat(r.map(e=>({name:e.signals.data})))},signals:(e,t,n)=>{if(e.parent&&!j0(e))for(let e of t.scales){let t=n.find(t=>t.name===e.signals.data);t.push=`outer`,delete t.value,delete t.update}return n}},s6=`_brush`,c6=`_scale_trigger`,l6=`geo_interval_init_tick`,u6=`_init`,Rze=`_center`,zze={defined:e=>e.type===`interval`,parse:(e,t,n)=>{if(e.hasProjection){let e={...gh(n.select)?n.select:{}};e.fields=[F3],e.encodings||=n.value?$(n.value):[Q2,Z2],n.select={type:`interval`,...e}}if(t.translate&&!o6.defined(t)){let e=`!event.item || event.item.mark.name !== ${W(t.name+s6)}`;for(let n of t.events){if(!n.between){X(`${n} is not an ordered event stream for interval selections.`);continue}let t=Gh(n.between[0].filter??=[]);t.includes(e)||t.push(e)}}},signals:(e,t,n)=>{let r=t.name,i=r+C6,a=P2(t.project.hasChannel).filter(e=>e.channel===V2||e.channel===H2),o=t.init?t.init[0]:null;if(n.push(...a.reduce((n,r)=>n.concat(yNe(e,t,r,o?.[r.index])),[])),e.hasProjection){let s=W(e.projectionName()),c=e.projectionName()+Rze,{x:l,y:u}=t.project.hasChannel,d=l?.signals.visual,f=u?.signals.visual,p=l?o?.[l.index]:`${c}[0]`,m=u?o?.[u.index]:`${c}[1]`,h=t=>e.getSizeSignalRef(t).signal,g=`[[${d?`${d}[0]`:`0`}, ${f?`${f}[0]`:`0`}],[${d?`${d}[1]`:h(`width`)}, ${f?`${f}[1]`:h(`height`)}]]`;o&&(n.unshift({name:r+u6,init:`[scale(${s}, [${l?p[0]:p}, ${u?m[0]:m}]), scale(${s}, [${l?p[1]:p}, ${u?m[1]:m}])]`}),(!l||!u)&&(n.find(e=>e.name===c)||n.unshift({name:c,update:`invert(${s}, [${h(`width`)}/2, ${h(`height`)}/2])`})));let _=`vlSelectionTuples(${`intersect(${g}, {markname: ${W(e.getName(`marks`))}}, unit.mark)`}, ${`{unit: ${W0(e)}}`})`,v=a.map(e=>e.signals.visual);return n.concat({name:i,on:[{events:[...v.length?[{signal:v.join(` || `)}]:[],...o?[{signal:l6}]:[]],update:_}]})}else{if(!o6.defined(t)){let t=r+c6,i=a.map(t=>{let n=t.channel,{data:r,visual:i}=t.signals,a=W(e.scaleName(n)),o=X$(e.getScaleComponent(n).get(`type`))?`+`:``;return`(!isArray(${r}) || (${o}invert(${a}, ${i})[0] === ${o}${r}[0] && ${o}invert(${a}, ${i})[1] === ${o}${r}[1]))`});i.length&&n.push({name:t,value:{},on:[{events:a.map(t=>({scale:e.scaleName(t.channel)})),update:`${i.join(` && `)} ? ${t} : {}`}]})}let s=a.map(e=>e.signals.data),c=`unit: ${W0(e)}, fields: ${r+Z3}, values`;return n.concat({name:i,...o?{init:`{${c}: ${O0(o)}}`}:{},...s.length?{on:[{events:[{signal:s.join(` || `)}],update:`${s.join(` && `)} ? {${c}: [${s}]} : null`}]}:{}})}},topLevelSignals:(e,t,n)=>(x2(e)&&e.hasProjection&&t.init&&(n.filter(e=>e.name===l6).length||n.unshift({name:l6,value:null,on:[{events:`timer{1}`,update:`${l6} === null ? {} : ${l6}`}]})),n),marks:(e,t,n)=>{let r=t.name,{x:i,y:a}=t.project.hasChannel,o=i?.signals.visual,s=a?.signals.visual,c=`data(${W(t.name+S6)})`;if(o6.defined(t)||!i&&!a)return n;let l={x:i===void 0?{value:0}:{signal:`${o}[0]`},y:a===void 0?{value:0}:{signal:`${s}[0]`},x2:i===void 0?{field:{group:`width`}}:{signal:`${o}[1]`},y2:a===void 0?{field:{group:`height`}}:{signal:`${s}[1]`}};if(t.resolve===`global`)for(let t of $(l))l[t]=[{test:`${c}.length && ${c}[0].unit === ${W0(e)}`,...l[t]},{value:0}];let{fill:u,fillOpacity:d,cursor:f,...p}=t.mark,m=$(p).reduce((e,t)=>(e[t]=[{test:[i!==void 0&&`${o}[0] !== ${o}[1]`,a!==void 0&&`${s}[0] !== ${s}[1]`].filter(e=>e).join(` && `),value:p[t]},{value:null}],e),{}),h=f??(t.translate?`move`:null);return[{name:`${r+s6}_bg`,type:`rect`,clip:!0,encode:{enter:{fill:{value:u},fillOpacity:{value:d}},update:l}},...n,{name:r+s6,type:`rect`,clip:!0,encode:{enter:{...h?{cursor:{value:h}}:{},fill:{value:`transparent`}},update:{...l,...m}}}]}},Bze={left:`x`,center:`xc`,right:`x2`},Vze={top:`y`,middle:`yc`,bottom:`y2`},d6=new Set([`aria`,`width`,`height`]),f6=`voronoi`,p6={defined:e=>e.type===`point`&&e.nearest,parse:(e,t)=>{if(t.events)for(let n of t.events)n.markname=e.getName(f6)},marks:(e,t,n)=>{let{x:r,y:i}=t.project.hasChannel,a=e.mark;if(e1(a))return X(qOe(a)),n;let o={name:e.getName(f6),type:`path`,interactive:!0,aria:!1,from:{data:e.getName(`marks`)},encode:{update:{fill:{value:`transparent`},strokeWidth:{value:.35},stroke:{value:`transparent`},isVoronoi:{value:!0},...bNe(e,{reactiveGeom:!0})}},transform:[{type:`voronoi`,x:{expr:r||!i?`datum.datum.x || 0`:`0`},y:{expr:i||!r?`datum.datum.y || 0`:`0`},size:[e.getSizeSignalRef(`width`),e.getSizeSignalRef(`height`)]}]},s=0,c=!1;return n.forEach((t,n)=>{let r=t.name??``;r===e.component.mark[0].name?s=n:r.includes(f6)&&(c=!0)}),c||n.splice(s+1,0,o),n}},m6={defined:e=>e.type===`point`&&e.resolve===`global`&&e.bind&&e.bind!==`scales`&&!n0(e.bind),parse:(e,t,n)=>qNe(t,n),topLevelSignals:(e,t,n)=>{let r=t.name,i=t.project,a=t.bind,o=t.init?.[0],s=p6.defined(t)?`(item().isVoronoi ? datum.datum : datum)`:`datum`;return i.items.forEach((e,i)=>{let c=XZ(`${r}_${e.field}`);n.filter(e=>e.name===c).length||n.unshift({name:c,...o?{init:O0(o[i])}:{value:null},on:t.events?[{events:t.events,update:`datum && item().mark.marktype !== 'group' ? ${s}[${W(e.field)}] : null`}]:[],bind:a[e.field]??a[e.channel]??a})}),n},signals:(e,t,n)=>{let r=t.name,i=t.project,a=n.find(e=>e.name===r+C6),o=r+Z3,s=i.items.map(e=>XZ(`${r}_${e.field}`)),c=s.map(e=>`${e} !== null`).join(` && `);return s.length&&(a.update=`${c} ? {fields: ${o}, values: [${s.join(`, `)}]} : null`),delete a.value,delete a.on,n}},h6=`_toggle`,g6={defined:e=>e.type===`point`&&!K0(e)&&!!e.toggle,signals:(e,t,n)=>n.concat({name:t.name+h6,value:!1,on:[{events:t.events,update:t.toggle}]}),modifyExpr:(e,t)=>{let n=t.name+C6,r=t.name+h6;return`${r} ? null : ${n}, ${t.resolve===`global`?`${r} ? null : true, `:`${r} ? null : {unit: ${W0(e)}}, `}${r} ? ${n} : null`}},Hze={defined:e=>e.clear!==void 0&&e.clear!==!1&&!K0(e),parse:(e,t)=>{t.clear&&=gg(t.clear)?BG(t.clear,`view`):t.clear},topLevelSignals:(e,t,n)=>{if(m6.defined(t))for(let e of t.project.items){let r=n.findIndex(n=>n.name===XZ(`${t.name}_${e.field}`));r!==-1&&n[r].on.push({events:t.clear,update:`null`})}return n},signals:(e,t,n)=>{function r(e,r){e!==-1&&n[e].on&&n[e].on.push({events:t.clear,update:r})}if(t.type===`interval`)for(let e of t.project.items){let t=n.findIndex(t=>t.name===e.signals.visual);r(t,`[0, 0]`),t===-1&&r(n.findIndex(t=>t.name===e.signals.data),`null`)}else{let e=n.findIndex(e=>e.name===t.name+C6);r(e,`null`),g6.defined(t)&&(e=n.findIndex(e=>e.name===t.name+h6),r(e,`false`))}return n}},_6={defined:e=>{let t=e.resolve===`global`&&e.bind&&n0(e.bind),n=e.project.items.length===1&&e.project.items[0].field!==F3;return t&&!n&&X(mRe),t&&n},parse:(e,t,n)=>{let r=N2(n);if(r.select=gg(r.select)?{type:r.select,toggle:t.toggle}:{...r.select,toggle:t.toggle},qNe(t,r),gh(n.select)&&(n.select.on||n.select.clear)){let e=`event.item && indexof(event.item.mark.role, "legend") < 0`;for(let n of t.events)n.filter=Gh(n.filter??[]),n.filter.includes(e)||n.filter.push(e)}let i=r0(t.bind)?t.bind.legend:`click`;t.bind={legend:{merge:gg(i)?BG(i,`view`):Gh(i)}}},topLevelSignals:(e,t,n)=>{let r=t.name,i=r0(t.bind)&&t.bind.legend,a=e=>t=>{let n=N2(t);return n.markname=e,n};for(let e of t.project.items){if(!e.hasLegend)continue;let o=`${XZ(e.field)}_legend`,s=`${r}_${o}`;if(n.filter(e=>e.name===s).length===0){let e=i.merge.map(a(`${o}_symbols`)).concat(i.merge.map(a(`${o}_labels`))).concat(i.merge.map(a(`${o}_entries`)));n.unshift({name:s,...t.init?{}:{value:null},on:[{events:e,update:`isDefined(datum.value) ? datum.value : item().items[0].items[0].datum.value`,force:!0},{events:i.merge,update:`!event.item || !datum ? null : ${s}`,force:!0}]})}}return n},signals:(e,t,n)=>{let r=t.name,i=t.project,a=n.find(e=>e.name===r+C6),o=r+Z3,s=i.items.filter(e=>e.hasLegend).map(e=>XZ(`${r}_${XZ(e.field)}_legend`)),c=`${s.map(e=>`${e} !== null`).join(` && `)} ? {fields: ${o}, values: [${s.join(`, `)}]} : null`;t.events&&s.length>0?a.on.push({events:s.map(e=>({signal:e})),update:c}):s.length>0&&(a.update=c,delete a.value,delete a.on);let l=n.find(e=>e.name===r+h6),u=r0(t.bind)&&t.bind.legend;return l&&(t.events?l.on.push({...l.on[0],events:u}):l.on[0].events=u),n}},v6=`_translate_anchor`,y6=`_translate_delta`,Uze={defined:e=>e.type===`interval`&&e.translate,signals:(e,t,n)=>{let r=t.name,i=o6.defined(t),a=r+v6,{x:o,y:s}=t.project.hasChannel,c=BG(t.translate,`scope`);return i||(c=c.map(e=>(e.between[0].markname=r+s6,e))),n.push({name:a,value:{},on:[{events:c.map(e=>e.between[0]),update:`{x: x(unit), y: y(unit)${o===void 0?``:`, extent_x: ${i?A0(e,V2):`slice(${o.signals.visual})`}`}${s===void 0?``:`, extent_y: ${i?A0(e,H2):`slice(${s.signals.visual})`}`}}`}]},{name:r+y6,value:{},on:[{events:c,update:`{x: ${a}.x - x(unit), y: ${a}.y - y(unit)}`}]}),o!==void 0&&WNe(e,t,o,`width`,n),s!==void 0&&WNe(e,t,s,`height`,n),n}},b6=`_zoom_anchor`,x6=`_zoom_delta`,Wze={defined:e=>e.type===`interval`&&e.zoom,signals:(e,t,n)=>{let r=t.name,i=o6.defined(t),a=r+x6,{x:o,y:s}=t.project.hasChannel,c=W(e.scaleName(V2)),l=W(e.scaleName(H2)),u=BG(t.zoom,`scope`);return i||(u=u.map(e=>(e.markname=r+s6,e))),n.push({name:r+b6,on:[{events:u,update:i?`{${[c?`x: invert(${c}, x(unit))`:``,l?`y: invert(${l}, y(unit))`:``].filter(e=>e).join(`, `)}}`:`{x: x(unit), y: y(unit)}`}]},{name:a,on:[{events:u,force:!0,update:`pow(1.001, event.deltaY * pow(16, event.deltaMode))`}]}),o!==void 0&&GNe(e,t,o,`width`,n),s!==void 0&&GNe(e,t,s,`height`,n),n}},S6=`_store`,C6=`_tuple`,Gze=`_modify`,w6=`vlSelectionResolve`,T6=[Lze,zze,Pze,g6,m6,o6,_6,Hze,Uze,Wze,p6],E6=class e extends K3{model;filter;expr;_dependentFields;clone(){return new e(null,this.model,N2(this.filter))}constructor(e,t,n){super(e),this.model=t,this.filter=n,this.expr=J0(this.model,this.filter,this),this._dependentFields=YNe(this.expr)}dependentFields(){return this._dependentFields}producedFields(){return new Set}assemble(){return{type:`filter`,expr:this.expr}}hash(){return`Filter ${this.expr}`}},D6={scale:({model:e,channel:t})=>e.scaleName(t),format:({format:e})=>e,formatType:({formatType:e})=>e,grid:({fieldOrDatumDef:e,axis:t,scaleType:n})=>t.grid??oPe(n,e),gridScale:({model:e,channel:t})=>sPe(e,t),labelAlign:({axis:e,labelAngle:t,orient:n,channel:r})=>e.labelAlign||uPe(t,n,r),labelAngle:({labelAngle:e})=>e,labelBaseline:({axis:e,labelAngle:t,orient:n,channel:r})=>e.labelBaseline||lPe(t,n,r),labelFlush:({axis:e,fieldOrDatumDef:t,channel:n})=>e.labelFlush??dPe(t.type,n),labelOverlap:({axis:e,fieldOrDatumDef:t,scaleType:n})=>e.labelOverlap??fPe(t.type,n,Z(t)&&!!t.timeUnit,Z(t)?t.sort:void 0),orient:({orient:e})=>e,tickCount:({channel:e,model:t,axis:n,fieldOrDatumDef:r,scaleType:i})=>{let a=e===`x`?`width`:e===`y`?`height`:void 0,o=a?t.getSizeSignalRef(a):void 0;return n.tickCount??mPe({fieldOrDatumDef:r,scaleType:i,size:o,values:n.values})},tickMinStep:({axis:e,format:t,fieldOrDatumDef:n})=>e.tickMinStep??hPe({format:t,fieldOrDatumDef:n}),title:({axis:e,model:t,channel:n})=>{if(e.title!==void 0)return e.title;let r=gPe(t,n);if(r!==void 0)return r;let i=t.typedFieldDef(n),a=n===`x`?`x2`:`y2`,o=t.fieldDef(a);return u$(i?[GAe(i)]:[],Z(o)?[GAe(o)]:[])},values:({axis:e,fieldOrDatumDef:t})=>_Pe(e,t),zindex:({axis:e,fieldOrDatumDef:t,mark:n})=>e.zindex??vPe(n,t)},O6=class e extends K3{transform;_dependentFields;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t,this._dependentFields=YNe(this.transform.calculate)}static parseAllForSortIndex(t,n){return n.forEachFieldDef((n,r)=>{if(j1(n)&&HAe(n.sort)){let{field:i,timeUnit:a}=n,o=n.sort,s=o.map((e,t)=>`${lAe({field:i,timeUnit:a,equal:e})} ? ${t} : `).join(``)+o.length;t=new e(t,{calculate:s,as:$0(n,r,{forAs:!0})})}}),t}producedFields(){return new Set([this.transform.as])}dependentFields(){return this._dependentFields}assemble(){return{type:`formula`,expr:this.transform.calculate,as:this.transform.as}}hash(){return`Calculate ${IZ(this.transform)}`}},k6=[`row`,`column`],A6=[`header`,`footer`],Kze={column:{start:0,end:1},row:{start:1,end:0}},j6=$({...pze,disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1}),qze=class extends W3{},M6={symbols:NPe,gradient:PPe,labels:FPe,entries:IPe},N6={direction:({direction:e})=>e,format:({fieldOrDatumDef:e,legend:t,config:n})=>{let{format:r,formatType:i}=t;return PAe(e,e.type,r,i,n,!1)},formatType:({legend:e,fieldOrDatumDef:t,scaleType:n})=>{let{formatType:r}=e;return FAe(r,t,n)},gradientLength:e=>{let{legend:t,legendConfig:n}=e;return t.gradientLength??n.gradientLength??KPe(e)},labelOverlap:({legend:e,legendConfig:t,scaleType:n})=>e.labelOverlap??t.labelOverlap??JPe(n),symbolType:({legend:e,markDef:t,channel:n,encoding:r})=>e.symbolType??VPe(t.type,n,r.shape,t.shape),title:({fieldOrDatumDef:e,config:t})=>P1(e,t,{allowDisabling:!0}),type:({legendType:e,scaleType:t,channel:n})=>{if(yQ(n)&&Z$(t)){if(e===`gradient`)return}else if(e===`symbol`)return;return e},values:({fieldOrDatumDef:e,legend:t})=>BPe(t,e)},P6=class e extends K3{bins;clone(){return new e(null,N2(this.bins))}constructor(e,t){super(e),this.bins=t}static makeFromEncoding(t,n){let r=n.reduceFieldDef((e,t,r)=>{if(k1(t)&&zQ(t.bin)){let{key:i,binComponent:a}=sFe(t,t.bin,n);e[i]={...a,...e[i],...rFe(n,t,r,n.config)}}return e},{});return qZ(r)?null:new e(t,r)}static makeFromTransform(t,n,r){let{key:i,binComponent:a}=sFe(n,n.bin,r);return new e(t,{[i]:a})}merge(e,t){for(let n of $(e.bins))n in this.bins?(t(e.bins[n].signal,this.bins[n].signal),this.bins[n].as=HZ([...this.bins[n].as,...e.bins[n].as],IZ)):this.bins[n]=e.bins[n];for(let t of e.children)e.removeChild(t),t.parent=this;e.remove()}producedFields(){return new Set(P2(this.bins).map(e=>e.as).flat(2))}dependentFields(){return new Set(P2(this.bins).map(e=>e.field))}hash(){return`Bin ${IZ(this.bins)}`}assemble(){return P2(this.bins).flatMap(e=>{let t=[],[n,...r]=e.as,{extent:i,...a}=e.bin,o={type:`bin`,field:iQ(e.field),as:n,signal:e.signal,...HQ(i)?{extent:null}:{extent:i},...e.span?{span:{signal:`span(${e.span})`}}:{},...a};!i&&e.extentSignal&&(t.push({type:`extent`,field:iQ(e.field),signal:e.extentSignal}),o.extent={signal:e.extentSignal}),t.push(o);for(let e of r)for(let r=0;r<2;r++)t.push({type:`formula`,expr:Q({field:n[r]},{expr:`datum`}),as:e[r]});return e.formula&&t.push({type:`formula`,expr:e.formula,as:e.formulaAs}),t})}},F6=class e extends K3{dimensions;measures;clone(){return new e(null,new Set(this.dimensions),N2(this.measures))}constructor(e,t,n){super(e),this.dimensions=t,this.measures=n}get groupBy(){return this.dimensions}static makeFromEncoding(t,n){let r=!1;n.forEachFieldDef(e=>{e.aggregate&&(r=!0)});let i={},a=new Set;return!r||(n.forEachFieldDef((e,t)=>{let{aggregate:r,field:o}=e;if(r)if(r===`count`)i[`*`]??={},i[`*`].count=new Set([Q(e,{forAs:!0})]);else{if(PQ(r)||FQ(r)){let e=PQ(r)?`argmin`:`argmax`,t=r[e];i[t]??={},i[t][e]=new Set([Q({op:e,field:t},{forAs:!0})])}else i[o]??={},i[o][r]=new Set([Q(e,{forAs:!0})]);MQ(t)&&n.scaleDomain(t)===`unaggregated`&&(i[o]??={},i[o].min=new Set([Q({field:o,aggregate:`min`},{forAs:!0})]),i[o].max=new Set([Q({field:o,aggregate:`max`},{forAs:!0})]))}else cFe(a,t,e,n)}),a.size+$(i).length===0)?null:new e(t,a,i)}static makeFromTransform(t,n){let r=new Set,i={};for(let e of n.aggregate){let{op:t,field:n,as:r}=e;t&&(t===`count`?(i[`*`]??={},i[`*`].count=new Set([r||Q(e,{forAs:!0})])):(i[n]??={},i[n][t]??=new Set,i[n][t].add(r||Q(e,{forAs:!0}))))}for(let e of n.groupby??[])r.add(e);return r.size+$(i).length===0?null:new e(t,r,i)}merge(e){return UZ(this.dimensions,e.dimensions)?(lFe(this.measures,e.measures),!0):(Vke(`different dimensions, cannot merge`),!1)}addDimensions(e){e.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,...$(this.measures)])}producedFields(){let e=new Set;for(let t of $(this.measures))for(let n of $(this.measures[t])){let r=this.measures[t][n];r.size===0?e.add(`${n}_${t}`):r.forEach(e.add,e)}return e}hash(){return`Aggregate ${IZ({dimensions:this.dimensions,measures:this.measures})}`}assemble(){let e=[],t=[],n=[];for(let r of $(this.measures))for(let i of $(this.measures[r]))for(let a of this.measures[r][i])n.push(a),e.push(i),t.push(r===`*`?null:iQ(r));return{type:`aggregate`,groupby:[...this.dimensions].map(iQ),ops:e,fields:t,as:n}}},I6=class extends K3{model;name;data;column;row;facet;childModel;constructor(e,t,n,r){super(e),this.model=t,this.name=n,this.data=r;for(let e of T4){let n=t.facet[e];if(n){let{bin:r,sort:i}=n;this[e]={name:t.getName(`${e}_domain`),fields:[Q(n),...zQ(r)?[Q(n,{binSuffix:`end`})]:[]],...h1(i)?{sortField:i}:H(i)?{sortIndexField:$0(n,e)}:{}}}}this.childModel=t.child}hash(){let e=`Facet`;for(let t of T4)this[t]&&(e+=` ${t.charAt(0)}:${IZ(this[t])}`);return e}get fields(){let e=[];for(let t of T4)this[t]?.fields&&e.push(...this[t].fields);return e}dependentFields(){let e=new Set(this.fields);for(let t of T4)this[t]&&(this[t].sortField&&e.add(this[t].sortField.field),this[t].sortIndexField&&e.add(this[t].sortIndexField));return e}producedFields(){return new Set}getSource(){return this.name}getChildIndependentFieldsWithStep(){let e={};for(let t of k4){let n=this.childModel.component.scales[t];if(n&&!n.merged){let r=n.get(`type`),i=n.get(`range`);if(Y$(r)&&YQ(i)){let n=v2(y2(this.childModel,t));n?e[t]=n:X(_$(t))}}}return e}assembleRowColumnHeaderData(e,t,n){let r={row:`y`,column:`x`,facet:void 0}[e],i=[],a=[],o=[];r&&n&&n[r]&&(t?(i.push(`distinct_${n[r]}`),a.push(`max`)):(i.push(n[r]),a.push(`distinct`)),o.push(`distinct_${n[r]}`));let{sortField:s,sortIndexField:c}=this[e];if(s){let{op:e=v3,field:t}=s;i.push(t),a.push(e),o.push(Q(s,{forAs:!0}))}else c&&(i.push(c),a.push(`max`),o.push(c));return{name:this[e].name,source:t??this.data,transform:[{type:`aggregate`,groupby:this[e].fields,...i.length?{fields:i,ops:a,as:o}:{}}]}}assembleFacetHeaderData(e){let{columns:t}=this.model.layout,{layoutHeaders:n}=this.model.component,r=[],i={};for(let e of k6){for(let t of A6){let r=n[e]?.[t]??[];for(let t of r)if(t.axes?.length>0){i[e]=!0;break}}if(i[e]){let n=`length(data("${this.facet.name}"))`,i=e===`row`?t?{signal:`ceil(${n} / ${t})`}:1:t?{signal:`min(${n}, ${t})`}:{signal:n};r.push({name:`${this.facet.name}_${e}`,transform:[{type:`sequence`,start:0,stop:i}]})}}let{row:a,column:o}=i;return(a||o)&&r.unshift(this.assembleRowColumnHeaderData(`facet`,null,e)),r}assemble(){let e=[],t=null,n=this.getChildIndependentFieldsWithStep(),{column:r,row:i,facet:a}=this;if(r&&i&&(n.x||n.y)){t=`cross_${this.column.name}_${this.row.name}`;let r=[].concat(n.x??[],n.y??[]),i=r.map(()=>`distinct`);e.push({name:t,source:this.data,transform:[{type:`aggregate`,groupby:this.fields,fields:r,ops:i}]})}for(let r of[z2,R2])this[r]&&e.push(this.assembleRowColumnHeaderData(r,t,n));if(a){let t=this.assembleFacetHeaderData(n);t&&e.push(...t)}return e}},L6=class e extends K3{_parse;clone(){return new e(null,N2(this._parse))}constructor(e,t){super(e),this._parse=t}hash(){return`Parse ${IZ(this._parse)}`}static makeExplicit(e,t,n){let r={},i=t.data;return!T0(i)&&i?.format?.parse&&(r=i.format.parse),this.makeWithAncestors(e,r,{},n)}static makeWithAncestors(t,n,r,i){for(let e of $(r)){let t=i.getWithExplicit(e);t.value!==void 0&&(t.explicit||t.value===r[e]||t.value===`derived`||r[e]===`flatten`?delete r[e]:X(x$(e,r[e],t.value)))}for(let e of $(n)){let t=i.get(e);t!==void 0&&(t===n[e]?delete n[e]:X(x$(e,n[e],t)))}let a=new W3(n,r);i.copyAll(a);let o={};for(let e of $(a.combine())){let t=a.get(e);t!==null&&(o[e]=t)}return $(o).length===0||i.parseNothing?null:new e(t,o)}get parse(){return this._parse}merge(e){this._parse={...this._parse,...e.parse},e.remove()}assembleFormatParse(){let e={};for(let t of $(this._parse)){let n=this._parse[t];sQ(t)===1&&(e[t]=n)}return e}producedFields(){return new Set($(this._parse))}dependentFields(){return new Set($(this._parse))}assembleTransforms(e=!1){return $(this._parse).filter(t=>!e||sQ(t)>1).map(e=>{let t=dFe(e,this._parse[e]);return t?{type:`formula`,expr:t,as:oQ(e)}:null}).filter(e=>e!==null)}},R6=class e extends K3{clone(){return new e(null)}constructor(e){super(e)}dependentFields(){return new Set}producedFields(){return new Set([F3])}hash(){return`Identifier`}assemble(){return{type:`identifier`,as:F3}}},z6=class e extends K3{params;clone(){return new e(null,this.params)}constructor(e,t){super(e),this.params=t}dependentFields(){return new Set}producedFields(){}hash(){return`Graticule ${IZ(this.params)}`}assemble(){return{type:`graticule`,...this.params===!0?{}:this.params}}},B6=class e extends K3{params;clone(){return new e(null,this.params)}constructor(e,t){super(e),this.params=t}dependentFields(){return new Set}producedFields(){return new Set([this.params.as??`data`])}hash(){return`Hash ${IZ(this.params)}`}assemble(){return{type:`sequence`,...this.params}}},V6=class extends K3{_data;_name;_generator;constructor(e){super(null),e??={name:`source`};let t;if(T0(e)||(t=e.format?{...FZ(e.format,[`parse`])}:{}),w0(e))this._data={values:e.values};else if(C0(e)){if(this._data={url:e.url},!t.type){let n=/(?:\.([^.]+))?$/.exec(e.url)[1];RZ([`json`,`csv`,`tsv`,`dsv`,`topojson`],n)||(n=`json`),t.type=n}}else iNe(e)?this._data={values:[{type:`Sphere`}]}:(nNe(e)||T0(e))&&(this._data={});this._generator=T0(e),e.name&&(this._name=e.name),t&&!qZ(t)&&(this._data.format=t)}dependentFields(){return new Set}producedFields(){}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(e){this._name=e}set parent(e){throw Error(`Source nodes have to be roots.`)}remove(){throw Error(`Source nodes are roots and cannot be removed.`)}hash(){throw Error(`Cannot hash sources`)}assemble(){return{name:this._name,...this._data,transform:[]}}},H6=class{#e;constructor(){this.#e=!1}setModified(){this.#e=!0}get modifiedFlag(){return this.#e}},U6=class extends H6{getNodeDepths(e,t,n){n.set(e,t);for(let r of e.children)this.getNodeDepths(r,t+1,n);return n}optimize(e){let t=[...this.getNodeDepths(e,0,new Map).entries()].sort((e,t)=>t[1]-e[1]);for(let e of t)this.run(e[0]);return this.modifiedFlag}},W6=class extends H6{optimize(e){this.run(e);for(let t of e.children)this.optimize(t);return this.modifiedFlag}},Jze=class extends W6{mergeNodes(e,t){let n=t.shift();for(let r of t)e.removeChild(r),r.parent=n,r.remove()}run(e){let t=e.children.map(e=>e.hash()),n={};for(let r=0;r1&&(this.setModified(),this.mergeNodes(e,n[t]))}},Yze=class extends W6{requiresSelectionId;constructor(e){super(),this.requiresSelectionId=e&&G0(e)}run(e){e instanceof R6&&(this.requiresSelectionId&&(l2(e.parent)||e.parent instanceof F6||e.parent instanceof L6)||(this.setModified(),e.remove()))}},Xze=class extends H6{optimize(e){return this.run(e,new Set),this.modifiedFlag}run(e,t){let n=new Set;e instanceof J3&&(n=e.producedFields(),WZ(n,t)&&(this.setModified(),e.removeFormulas(t),e.producedFields.length===0&&e.remove()));for(let r of e.children)this.run(r,new Set([...t,...n]))}},Zze=class extends W6{constructor(){super()}run(e){e instanceof q3&&!e.isRequired()&&(this.setModified(),e.remove())}},Qze=class extends U6{run(e){if(!l2(e)&&!(e.numChildren()>1)){for(let t of e.children)if(t instanceof L6)if(e instanceof L6)this.setModified(),e.merge(t);else{if(KZ(e.producedFields(),t.dependentFields()))continue;this.setModified(),t.swapWithParent()}}}},$ze=class extends U6{run(e){let t=[...e.children],n=e.children.filter(e=>e instanceof L6);if(e.numChildren()>1&&n.length>=1){let r={},i=new Set;for(let e of n){let t=e.parse;for(let e of $(t))e in r?r[e]!==t[e]&&i.add(e):r[e]=t[e]}for(let e of i)delete r[e];if(!qZ(r)){this.setModified();let n=new L6(e,r);for(let i of t){if(i instanceof L6)for(let e of $(r))delete i.parse[e];e.removeChild(i),i.parent=n,i instanceof L6&&$(i.parse).length===0&&i.remove()}}}}},eBe=class extends U6{run(e){e instanceof q3||e.numChildren()>0||e instanceof I6||e instanceof V6||(this.setModified(),e.remove())}},tBe=class extends U6{run(e){let t=e.children.filter(e=>e instanceof J3),n=t.pop();for(let e of t)this.setModified(),n.merge(e)}},nBe=class extends U6{run(e){let t=e.children.filter(e=>e instanceof F6),n={};for(let e of t){let t=IZ(e.groupBy);t in n||(n[t]=[]),n[t].push(e)}for(let t of $(n)){let r=n[t];if(r.length>1){let t=r.pop();for(let n of r)t.merge(n)&&(e.removeChild(n),n.parent=t,n.remove(),this.setModified())}}}},rBe=class extends U6{model;constructor(e){super(),this.model=e}run(e){let t=!(l2(e)||e instanceof E6||e instanceof L6||e instanceof R6),n=[],r=[];for(let i of e.children)i instanceof P6&&(t&&!KZ(e.producedFields(),i.dependentFields())?n.push(i):r.push(i));if(n.length>0){let t=n.pop();for(let e of n)t.merge(e,this.model.renameSignal.bind(this.model));this.setModified(),e instanceof P6?e.merge(t,this.model.renameSignal.bind(this.model)):t.swapWithParent()}if(r.length>1){let e=r.pop();for(let t of r)e.merge(t,this.model.renameSignal.bind(this.model));this.setModified()}}},iBe=class extends U6{run(e){let t=[...e.children];if(!zZ(t,e=>e instanceof q3)||e.numChildren()<=1)return;let n=[],r;for(let i of t)if(i instanceof q3){let t=i;for(;t.numChildren()===1;){let[e]=t.children;if(e instanceof q3)t=e;else break}n.push(...t.children),r?(e.removeChild(i),i.parent=r.parent,r.parent.removeChild(r),r.parent=t,this.setModified()):r=t}else n.push(i);if(n.length){this.setModified();for(let e of n)e.parent.removeChild(e),e.parent=r}}},G6=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t}addDimensions(e){this.transform.groupby=HZ(this.transform.groupby.concat(e),e=>e)}dependentFields(){let e=new Set;return this.transform.groupby&&this.transform.groupby.forEach(e.add,e),this.transform.joinaggregate.map(e=>e.field).filter(e=>e!==void 0).forEach(e.add,e),e}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(e){return e.as??Q(e)}hash(){return`JoinAggregateTransform ${IZ(this.transform)}`}assemble(){let e=[],t=[],n=[];for(let r of this.transform.joinaggregate)t.push(r.op),n.push(this.getDefaultName(r)),e.push(r.field===void 0?null:r.field);let r=this.transform.groupby;return{type:`joinaggregate`,as:n,ops:t,fields:e,...r===void 0?{}:{groupby:r}}}},K6=class e extends K3{filter;clone(){return new e(null,{...this.filter})}constructor(e,t){super(e),this.filter=t}static make(t,n,r){let{config:i,markDef:a}=n,{marks:o,scales:s}=r;if(o===`include-invalid-values`&&s===`include-invalid-values`)return null;let c=n.reduceFieldDef((e,t,r)=>{let o=MQ(r)&&n.getScaleComponent(r);if(o){let n=o.get(`type`),{aggregate:s}=t,c=i1({scaleChannel:r,markDef:a,config:i,scaleType:n,isCountAggregate:LQ(s)});c!==`show`&&c!==`always-valid`&&(e[t.field]=t)}return e},{});return $(c).length?new e(t,c):null}dependentFields(){return new Set($(this.filter))}producedFields(){return new Set}hash(){return`FilterInvalid ${IZ(this.filter)}`}assemble(){let e=$(this.filter).reduce((e,t)=>{let n=this.filter[t],r=Q(n,{expr:`datum`});return n!==null&&(n.type===`temporal`?e.push(`(isDate(${r}) || (${u2(r)}))`):n.type===`quantitative`&&e.push(u2(r))),e},[]);return e.length>0?{type:`filter`,expr:e.join(` && `)}:null}},q6=class e extends K3{_stack;clone(){return new e(null,N2(this._stack))}constructor(e,t){super(e),this._stack=t}static makeFromTransform(t,n){let{stack:r,groupby:i,as:a,offset:o=`zero`}=n,s=[],c=[];if(n.sort!==void 0)for(let e of n.sort)s.push(e.field),c.push(cQ(e.order,`ascending`));let l={field:s,order:c},u;return u=gFe(a)?a:gg(a)?[a,`${a}_end`]:[`${n.stack}_start`,`${n.stack}_end`],new e(t,{dimensionFieldDefs:[],stackField:r,groupby:i,offset:o,sort:l,facetby:[],as:u})}static makeFromEncoding(t,n){let r=n.stack,{encoding:i}=n;if(!r)return null;let{groupbyChannels:a,fieldChannel:o,offset:s,impute:c}=r,l=a.map(e=>{let t=i[e];return R1(t)}).filter(e=>!!e),u=hFe(n),d=n.encoding.order,f;if(H(d)||Z(d))f=l$(d);else{let e=JAe(d)?d.sort:o===`y`?`descending`:`ascending`;f=u.reduce((t,n)=>(t.field.includes(n)||(t.field.push(n),t.order.push(e)),t),{field:[],order:[]})}return new e(t,{dimensionFieldDefs:l,stackField:n.vgField(o),facetby:[],stackby:u,sort:f,offset:s,impute:c,as:[n.vgField(o,{suffix:`start`,forAs:!0}),n.vgField(o,{suffix:`end`,forAs:!0})]})}get stack(){return this._stack}addDimensions(e){this._stack.facetby.push(...e)}dependentFields(){let e=new Set;return e.add(this._stack.stackField),this.getGroupbyFields().forEach(e.add,e),this._stack.facetby.forEach(e.add,e),this._stack.sort.field.forEach(e.add,e),e}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${IZ(this._stack)}`}getGroupbyFields(){let{dimensionFieldDefs:e,impute:t,groupby:n}=this._stack;return e.length>0?e.map(e=>e.bin?t?[Q(e,{binSuffix:`mid`})]:[Q(e,{}),Q(e,{binSuffix:`end`})]:[Q(e)]).flat():n??[]}assemble(){let e=[],{facetby:t,dimensionFieldDefs:n,stackField:r,stackby:i,sort:a,offset:o,impute:s,as:c}=this._stack;if(s)for(let a of n){let{bandPosition:n=.5,bin:o}=a;if(o){let t=Q(a,{expr:`datum`}),r=Q(a,{expr:`datum`,binSuffix:`end`});e.push({type:`formula`,expr:`${u2(t)} ? ${n}*${t}+${1-n}*${r} : ${t}`,as:Q(a,{binSuffix:`mid`,forAs:!0})})}e.push({type:`impute`,field:r,groupby:[...i,...t],key:Q(a,{binSuffix:`mid`}),method:`value`,value:0})}return e.push({type:`stack`,groupby:[...this.getGroupbyFields(),...t],field:r,sort:a,as:c,offset:o}),e}},J6=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t}addDimensions(e){this.transform.groupby=HZ(this.transform.groupby.concat(e),e=>e)}dependentFields(){let e=new Set;return(this.transform.groupby??[]).forEach(e.add,e),(this.transform.sort??[]).forEach(t=>e.add(t.field)),this.transform.window.map(e=>e.field).filter(e=>e!==void 0).forEach(e.add,e),e}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(e){return e.as??Q(e)}hash(){return`WindowTransform ${IZ(this.transform)}`}assemble(){let e=[],t=[],n=[],r=[];for(let i of this.transform.window)t.push(i.op),n.push(this.getDefaultName(i)),r.push(i.param===void 0?null:i.param),e.push(i.field===void 0?null:i.field);let i=this.transform.frame,a=this.transform.groupby;if(i&&i[0]===null&&i[1]===null&&t.every(e=>IQ(e)))return{type:`joinaggregate`,as:n,ops:t,fields:e,...a===void 0?{}:{groupby:a}};let o=[],s=[];if(this.transform.sort!==void 0)for(let e of this.transform.sort)o.push(e.field),s.push(e.order??`ascending`);let c={field:o,order:s},l=this.transform.ignorePeers;return{type:`window`,params:r,as:n,ops:t,fields:e,sort:c,...l===void 0?{}:{ignorePeers:l},...a===void 0?{}:{groupby:a},...i===void 0?{}:{frame:i}}}},Y6=`scale_`,X6=5,Z6=class e{constructor(e){Object.defineProperty(this,"signal",{enumerable:!0,get:e})}signal;static fromName(t,n){return new e(()=>t(n))}},aBe=[`type`,`clipAngle`,`clipExtent`,`center`,`rotate`,`precision`,`reflectX`,`reflectY`,`coefficient`,`distance`,`fraction`,`lobes`,`parallel`,`radius`,`ratio`,`spacing`,`tilt`],Q6=class extends W3{specifiedProjection;size;data;merged=!1;constructor(e,t,n,r){super({...t},{name:e}),this.specifiedProjection=t,this.size=n,this.data=r}get isFit(){return!!this.data}},$6=class extends W3{merged=!1;constructor(e,t){super({},{name:e}),this.setWithExplicit(`type`,t)}domainHasZero(){let e=this.get(`type`);if(RZ([Z4.LOG,Z4.TIME,Z4.UTC],e))return`definitely-not`;let t=this.get(`zero`);if(t===!0||t===void 0&&RZ([Z4.LINEAR,Z4.SQRT,Z4.POW],e))return`definitely`;let n=this.get(`domains`);if(n.length>0){let e=!1,t=!1,r=!1;for(let i of n){if(H(i)){let n=i[0],r=i[i.length-1];if(mg(n)&&mg(r))if(n<=0&&r>=0){e=!0;continue}else{t=!0;continue}}r=!0}if(e)return`definitely`;if(t&&!r)return`definitely-not`}return`maybe`}},oBe=[`range`,`scheme`],e8=.95,t8={bins:({model:e,fieldOrDatumDef:t})=>Z(t)?_Ie(e,t):void 0,interpolate:({channel:e,fieldOrDatumDef:t})=>vIe(e,t.type),nice:({scaleType:e,channel:t,domain:n,domainMin:r,domainMax:i,fieldOrDatumDef:a})=>yIe(e,t,n,r,i,a),padding:({channel:e,scaleType:t,fieldOrDatumDef:n,markDef:r,config:i})=>bIe(e,t,i.scale,n,r,i.bar),paddingInner:({scalePadding:e,channel:t,markDef:n,scaleType:r,config:i,hasNestedOffsetScale:a})=>xIe(e,t,n.type,r,i.scale,a),paddingOuter:({scalePadding:e,channel:t,scaleType:n,scalePaddingInner:r,config:i,hasNestedOffsetScale:a})=>SIe(e,t,n,r,i.scale,a),reverse:({fieldOrDatumDef:e,scaleType:t,channel:n,config:r})=>CIe(t,Z(e)?e.sort:void 0,n,r.scale),zero:({channel:e,fieldOrDatumDef:t,domain:n,markDef:r,scaleType:i,config:a,hasSecondaryRangeChannel:o})=>wIe(e,t,n,r,i,a.scale,o)},sBe=tNe((e,t)=>mAe(e)-mAe(t)),n8=class{nameMap;constructor(){this.nameMap={}}rename(e,t){this.nameMap[e]=t}has(e){return this.nameMap[e]!==void 0}get(e){for(;this.nameMap[e]&&e!==this.nameMap[e];)e=this.nameMap[e];return e}},r8=class{type;parent;config;name;size;title;description;data;transforms;layout;scaleNameMap;projectionNameMap;signalNameMap;component;view;constructor(e,t,n,r,i,a,o){this.type=t,this.parent=n,this.config=i,this.parent=n,this.config=i,this.view=GQ(o),this.name=e.name??r,this.title=qQ(e.title)?{text:e.title}:e.title?GQ(e.title):void 0,this.scaleNameMap=n?n.scaleNameMap:new n8,this.projectionNameMap=n?n.projectionNameMap:new n8,this.signalNameMap=n?n.signalNameMap:new n8,this.data=e.data,this.description=e.description,this.transforms=UMe(e.transform??[]),this.layout=t===`layer`||t===`unit`?{}:Gje(e,t,i),this.component={data:{sources:n?n.component.data.sources:[],outputNodes:n?n.component.data.outputNodes:{},outputNodeRefCounts:n?n.component.data.outputNodeRefCounts:{},isFaceted:v1(e)||n?.component.data.isFaceted&&e.data===void 0},layoutSize:new W3,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:{scale:{},axis:{},legend:{},...a?N2(a):{}},selection:null,scales:null,projection:null,axes:{},legends:{}}}get width(){return this.getSizeSignalRef(`width`)}get height(){return this.getSizeSignalRef(`height`)}parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup()}parseScale(){DIe(this)}parseProjection(){WFe(this)}renameTopLevelLayoutSizeSignal(){this.getName(`width`)!==`width`&&this.renameSignal(this.getName(`width`),`width`),this.getName(`height`)!==`height`&&this.renameSignal(this.getName(`height`),`height`)}parseLegends(){YPe(this)}assembleEncodeFromView(e){let{style:t,...n}=e,r={};for(let e of $(n)){let t=n[e];t!==void 0&&(r[e]=t$(t))}return r}assembleGroupEncodeEntry(e){let t={};return this.view&&(t=this.assembleEncodeFromView(this.view)),!e&&(this.description&&(t.description=t$(this.description)),this.type===`unit`||this.type===`layer`)?{width:this.getSizeSignalRef(`width`),height:this.getSizeSignalRef(`height`),...t}:qZ(t)?void 0:t}assembleLayout(){if(!this.layout)return;let{spacing:e,...t}=this.layout,{component:n,config:r}=this,i=EPe(n.layoutHeaders,r);return{padding:e,...this.assembleDefaultLayout(),...t,...i?{titleBand:i}:{}}}assembleDefaultLayout(){return{}}assembleHeaderMarks(){let{layoutHeaders:e}=this.component,t=[];for(let n of T4)e[n].title&&t.push(yPe(this,n));for(let e of k6)t=t.concat(SPe(this,e));return t}assembleAxes(){return nPe(this.component.axes,this.config)}assembleLegends(){return zFe(this)}assembleProjections(){return VFe(this)}assembleTitle(){let{encoding:e,...t}=this.title??{},n={...KQ(this.config.title).nonMarkTitleProperties,...t,...e?{encode:{update:e}}:{}};if(n.text)return RZ([`unit`,`layer`],this.type)?RZ([`middle`,void 0],n.anchor)&&(n.frame??=`group`):n.anchor??=`start`,qZ(n)?void 0:n}assembleGroup(e=[]){let t={};e=e.concat(this.assembleSignals()),e.length>0&&(t.signals=e);let n=this.assembleLayout();n&&(t.layout=n),t.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());let r=!this.parent||S2(this.parent)?YFe(this):[];r.length>0&&(t.scales=r);let i=this.assembleAxes();i.length>0&&(t.axes=i);let a=this.assembleLegends();return a.length>0&&(t.legends=a),t}getName(e){return XZ((this.name?`${this.name}_`:``)+e)}getDataName(e){return this.getName(G3[e].toLowerCase())}requestDataName(e){let t=this.getDataName(e),n=this.component.data.outputNodeRefCounts;return n[t]=(n[t]||0)+1,t}getSizeSignalRef(e){if(S2(this.parent)){let t=kQ(APe(e)),n=this.component.scales[t];if(n&&!n.merged){let e=n.get(`type`),r=n.get(`range`);if(Y$(e)&&YQ(r)){let e=n.get(`name`),r=v2(y2(this,t));return r?{signal:kPe(e,n,Q({aggregate:`distinct`,field:r},{expr:`datum`}))}:(X(_$(t)),null)}}}return{signal:this.signalNameMap.get(this.getName(e))}}lookupDataSource(e){let t=this.component.data.outputNodes[e];return t?t.getSource():e}getSignalName(e){return this.signalNameMap.get(e)}renameSignal(e,t){this.signalNameMap.rename(e,t)}renameScale(e,t){this.scaleNameMap.rename(e,t)}renameProjection(e,t){this.projectionNameMap.rename(e,t)}scaleName(e,t){if(t)return this.getName(e);if(bQ(e)&&MQ(e)&&this.component.scales[e]||this.scaleNameMap.has(this.getName(e)))return this.scaleNameMap.get(this.getName(e))}projectionName(e){if(e)return this.getName(`projection`);if(this.component.projection&&!this.component.projection.merged||this.projectionNameMap.has(this.getName(`projection`)))return this.projectionNameMap.get(this.getName(`projection`))}getScaleComponent(e){if(!this.component.scales)throw Error(`getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().`);let t=this.component.scales[e];return t&&!t.merged?t:this.parent?this.parent.getScaleComponent(e):void 0}getScaleType(e){let t=this.getScaleComponent(e);return t?t.get(`type`):void 0}getSelectionComponent(e,t){let n=this.component.selection[e];if(!n&&this.parent&&(n=this.parent.getSelectionComponent(e,t)),!n)throw Error(JOe(t));return n}hasAxisOrientSignalRef(){return this.component.axes.x?.some(e=>e.hasOrientSignalRef())||this.component.axes.y?.some(e=>e.hasOrientSignalRef())}},i8=class extends r8{vgField(e,t={}){let n=this.fieldDef(e);if(n)return Q(n,t)}reduceFieldDef(e,t){return xje(this.getMapping(),(t,n,r)=>{let i=R1(n);return i?e(t,i,r):t},t)}forEachFieldDef(e,t){X1(this.getMapping(),(t,n)=>{let r=R1(t);r&&e(r,n)},t)}},a8=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=N2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??`value`,n[1]??`density`];let r=this.transform.resolve??`shared`;this.transform.resolve=r}dependentFields(){return new Set([this.transform.density,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`DensityTransform ${IZ(this.transform)}`}assemble(){let{density:e,...t}=this.transform,n={type:`kde`,field:e,...t};return n.resolve=this.transform.resolve,n}},o8=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=N2(t)}dependentFields(){return new Set([this.transform.extent])}producedFields(){return new Set([])}hash(){return`ExtentTransform ${IZ(this.transform)}`}assemble(){let{extent:e,param:t}=this.transform;return{type:`extent`,field:e,signal:t}}},s8=class e extends K3{transform;clone(){return new e(this.parent,N2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=N2(t);let{flatten:n,as:r=[]}=this.transform;this.transform.as=n.map((e,t)=>r[t]??e)}dependentFields(){return new Set(this.transform.flatten)}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${IZ(this.transform)}`}assemble(){let{flatten:e,as:t}=this.transform;return{type:`flatten`,fields:e,as:t}}},c8=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=N2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??`key`,n[1]??`value`]}dependentFields(){return new Set(this.transform.fold)}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${IZ(this.transform)}`}assemble(){let{fold:e,as:t}=this.transform;return{type:`fold`,fields:e,as:t}}},l8=class e extends K3{fields;geojson;signal;clone(){return new e(null,N2(this.fields),this.geojson,this.signal)}static parseAll(t,n){if(n.component.projection&&!n.component.projection.isFit)return t;let r=0;for(let i of[[Q2,Z2],[e4,$2]]){let a=i.map(e=>{let t=z1(n.encoding[e]);return Z(t)?t.field:T1(t)?{expr:`${t.datum}`}:A1(t)?{expr:`${t.value}`}:void 0});(a[0]||a[1])&&(t=new e(t,a,null,n.getName(`geojson_${r++}`)))}if(n.channelHasField(a4)){let i=n.typedFieldDef(a4);i.type===X4&&(t=new e(t,null,i.field,n.getName(`geojson_${r}`)))}return t}constructor(e,t,n,r){super(e),this.fields=t,this.geojson=n,this.signal=r}dependentFields(){let e=(this.fields??[]).filter(gg);return new Set([...this.geojson?[this.geojson]:[],...e])}producedFields(){return new Set}hash(){return`GeoJSON ${this.geojson} ${this.signal} ${IZ(this.fields)}`}assemble(){return[...this.geojson?[{type:`filter`,expr:`isValid(datum["${this.geojson}"])`}]:[],{type:`geojson`,...this.fields?{fields:this.fields}:{},...this.geojson?{geojson:this.geojson}:{},signal:this.signal}]}},u8=class e extends K3{projection;fields;as;clone(){return new e(null,this.projection,N2(this.fields),N2(this.as))}constructor(e,t,n,r){super(e),this.projection=t,this.fields=n,this.as=r}static parseAll(t,n){if(!n.projectionName())return t;for(let r of[[Q2,Z2],[e4,$2]]){let i=r.map(e=>{let t=z1(n.encoding[e]);return Z(t)?t.field:T1(t)?{expr:`${t.datum}`}:A1(t)?{expr:`${t.value}`}:void 0}),a=r[0]===e4?`2`:``;(i[0]||i[1])&&(t=new e(t,n.projectionName(),i,[n.getName(`x${a}`),n.getName(`y${a}`)]))}return t}dependentFields(){return new Set(this.fields.filter(gg))}producedFields(){return new Set(this.as)}hash(){return`Geopoint ${this.projection} ${IZ(this.fields)} ${IZ(this.as)}`}assemble(){return{type:`geopoint`,projection:this.projection,fields:this.fields,as:this.as}}},d8=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t}dependentFields(){return new Set([this.transform.impute,this.transform.key,...this.transform.groupby??[]])}producedFields(){return new Set([this.transform.impute])}processSequence(e){let{start:t=0,stop:n,step:r}=e;return{signal:`sequence(${[t,n,...r?[r]:[]].join(`,`)})`}}static makeFromTransform(t,n){return new e(t,n)}static makeFromEncoding(t,n){let r=n.encoding,i=r.x,a=r.y;if(Z(i)&&Z(a)){let o=i.impute?i:a.impute?a:void 0;if(o===void 0)return;let s=i.impute?a:a.impute?i:void 0,{method:c,value:l,frame:u,keyvals:d}=o.impute,f=Sje(n.mark,r);return new e(t,{impute:o.field,key:s.field,...c?{method:c}:{},...l===void 0?{}:{value:l},...u?{frame:u}:{},...d===void 0?{}:{keyvals:d},...f.length?{groupby:f}:{}})}return null}hash(){return`Impute ${IZ(this.transform)}`}assemble(){let{impute:e,key:t,keyvals:n,method:r,groupby:i,value:a,frame:o=[null,null]}=this.transform,s={type:`impute`,field:e,key:t,...n?{keyvals:SMe(n)?this.processSequence(n):n}:{},method:`value`,...i?{groupby:i}:{},value:!r||r===`value`?a:null};return r&&r!==`value`?[s,{type:`window`,as:[`imputed_${e}_value`],ops:[r],fields:[e],frame:o,ignorePeers:!1,...i?{groupby:i}:{}},{type:`formula`,expr:`datum.${e} === null ? datum.imputed_${e}_value : datum.${e}`,as:e}]:[s]}},f8=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=N2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??t.on,n[1]??t.loess]}dependentFields(){return new Set([this.transform.loess,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`LoessTransform ${IZ(this.transform)}`}assemble(){let{loess:e,on:t,...n}=this.transform;return{type:`loess`,x:t,y:e,...n}}},p8=class e extends K3{transform;secondary;clone(){return new e(null,N2(this.transform),this.secondary)}constructor(e,t,n){super(e),this.transform=t,this.secondary=n}static make(t,n,r,i){let a=n.component.data.sources,{from:o}=r,s=null;if(wMe(o)){let e=WIe(o.data,a);e||(e=new V6(o.data),a.push(e));let t=n.getName(`lookup_${i}`);s=new q3(e,t,G3.Lookup,n.component.data.outputNodeRefCounts),n.component.data.outputNodes[t]=s}else if(TMe(o)){let e=o.param;r={as:e,...r};let t;try{t=n.getSelectionComponent(XZ(e),e)}catch{throw Error(YOe(e))}if(s=t.materialized,!s)throw Error(XOe(e))}return new e(t,r,s.getSource())}dependentFields(){return new Set([this.transform.lookup])}producedFields(){return new Set(this.transform.as?Gh(this.transform.as):this.transform.from.fields)}hash(){return`Lookup ${IZ({transform:this.transform,secondary:this.secondary})}`}assemble(){let e;if(this.transform.from.fields)e={values:this.transform.from.fields,...this.transform.as?{as:Gh(this.transform.as)}:{}};else{let t=this.transform.as;gg(t)||(X(bRe),t=`_lookup`),e={as:[t]}}return{type:`lookup`,from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup],...e,...this.transform.default?{default:this.transform.default}:{}}}},m8=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=N2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??`prob`,n[1]??`value`]}dependentFields(){return new Set([this.transform.quantile,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`QuantileTransform ${IZ(this.transform)}`}assemble(){let{quantile:e,...t}=this.transform;return{type:`quantile`,field:e,...t}}},h8=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=N2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??t.on,n[1]??t.regression]}dependentFields(){return new Set([this.transform.regression,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`RegressionTransform ${IZ(this.transform)}`}assemble(){let{regression:e,on:t,...n}=this.transform;return{type:`regression`,x:t,y:e,...n}}},g8=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t}addDimensions(e){this.transform.groupby=HZ((this.transform.groupby??[]).concat(e),e=>e)}producedFields(){}dependentFields(){return new Set([this.transform.pivot,this.transform.value,...this.transform.groupby??[]])}hash(){return`PivotTransform ${IZ(this.transform)}`}assemble(){let{pivot:e,value:t,groupby:n,limit:r,op:i}=this.transform;return{type:`pivot`,field:e,value:t,...r===void 0?{}:{limit:r},...i===void 0?{}:{op:i},...n===void 0?{}:{groupby:n}}}},_8=class e extends K3{transform;clone(){return new e(null,N2(this.transform))}constructor(e,t){super(e),this.transform=t}dependentFields(){return new Set}producedFields(){return new Set}hash(){return`SampleTransform ${IZ(this.transform)}`}assemble(){return{type:`sample`,size:this.transform.sample}}},cBe=class e extends i8{facet;child;children;constructor(e,t,n,r){super(e,`facet`,t,n,r,e.resolve),this.child=M2(e.spec,this,this.getName(`child`),void 0,r),this.children=[this.child],this.facet=this.initFacet(e.facet)}initFacet(e){if(!g1(e))return{facet:this.initFacetFieldDef(e,`facet`)};let t=$(e),n={};for(let r of t){if(![R2,z2].includes(r)){X(E$(r,`facet`));break}let t=e[r];if(t.field===void 0){X(T$(t,r));break}n[r]=this.initFacetFieldDef(t,r)}return n}initFacetFieldDef(e,t){let n=V1(e,t);return n.header?n.header=GQ(n.header):n.header===null&&(n.header=null),n}channelHasField(e){return Y(this.facet,e)}fieldDef(e){return this.facet[e]}parseData(){this.component.data=O2(this),this.child.parseData()}parseLayoutSize(){T2(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection,P2(this.component.selection).some(e=>K0(e))&&j$(L4)}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),FIe(this)}assembleSelectionTopLevelSignals(e){return this.child.assembleSelectionTopLevelSignals(e)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(e){return this.child.assembleSelectionData(e)}getHeaderLayoutMixins(){let e={};for(let t of T4)for(let n of A6){let r=this.component.layoutHeaders[t],i=r[n],{facetFieldDef:a}=r;if(a){let n=t2(`titleOrient`,a.header,this.config,t);if([`right`,`bottom`].includes(n)){let r=e2(t,n);e.titleAnchor??={},e.titleAnchor[r]=`end`}}if(i?.[0]){let i=t===`row`?`height`:`width`,a=n===`header`?`headerBand`:`footerBand`;t!==`facet`&&!this.child.component.layoutSize.get(i)&&(e[a]??={},e[a][t]=.5),r.title&&(e.offset??={},e.offset[t===`row`?`rowTitle`:`columnTitle`]=10)}}return e}assembleDefaultLayout(){let{column:e,row:t}=this.facet,n=e?this.columnDistinctSignal():t?1:void 0,r=`all`;return(!t&&this.component.resolve.scale.x===`independent`||!e&&this.component.resolve.scale.y===`independent`)&&(r=`none`),{...this.getHeaderLayoutMixins(),...n?{columns:n}:{},bounds:`full`,align:r}}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(!(this.parent&&this.parent instanceof e))return{signal:`length(data('${this.getName(`column_domain`)}'))`}}assembleGroupStyle(){}assembleGroup(t){return this.parent&&this.parent instanceof e?{...this.channelHasField(`column`)?{encode:{update:{columns:{field:Q(this.facet.column,{prefix:`distinct`})}}}}:{},...super.assembleGroup(t)}:super.assembleGroup(t)}getCardinalityAggregateForChild(){let t=[],n=[],r=[];if(this.child instanceof e){if(this.child.channelHasField(`column`)){let e=Q(this.child.facet.column);t.push(e),n.push(`distinct`),r.push(`distinct_${e}`)}}else for(let e of k4){let i=this.child.component.scales[e];if(i&&!i.merged){let a=i.get(`type`),o=i.get(`range`);if(Y$(a)&&YQ(o)){let i=v2(y2(this.child,e));i?(t.push(i),n.push(`distinct`),r.push(`distinct_${i}`)):X(_$(e))}}}return{fields:t,ops:n,as:r}}assembleFacet(){let{name:e,data:t}=this.component.data.facetRoot,{row:n,column:r}=this.facet,{fields:i,ops:a,as:o}=this.getCardinalityAggregateForChild(),s=[];for(let e of T4){let t=this.facet[e];if(t){s.push(Q(t));let{bin:c,sort:l}=t;if(zQ(c)&&s.push(Q(t,{binSuffix:`end`})),h1(l)){let{field:e,op:s=v3}=l,c=D2(t,l);n&&r?(i.push(c),a.push(`max`),o.push(c)):(i.push(e),a.push(s),o.push(c))}else if(H(l)){let n=$0(t,e);i.push(n),a.push(`max`),o.push(n)}}}let c=!!n&&!!r;return{name:e,data:t,groupby:s,...c||i.length>0?{aggregate:{...c?{cross:c}:{},...i.length?{fields:i,ops:a,as:o}:{}}}:{}}}facetSortFields(e){let{facet:t}=this,n=t[e];return n?h1(n.sort)?[D2(n,n.sort,{expr:`datum`})]:H(n.sort)?[$0(n,e,{expr:`datum`})]:[Q(n,{expr:`datum`})]:[]}facetSortOrder(e){let{facet:t}=this,n=t[e];if(n){let{sort:e}=n;return[(h1(e)?e.order:!H(e)&&e)||`ascending`]}return[]}assembleLabelTitle(){let{facet:e,config:t}=this;if(e.facet)return r2(e.facet,`facet`,t);let n={row:[`top`,`bottom`],column:[`left`,`right`]};for(let r of k6)if(e[r]){let i=t2(`labelOrient`,e[r]?.header,t,r);if(n[r].includes(i))return r2(e[r],r,t)}}assembleMarks(){let{child:e}=this,t=this.component.data.facetRoot,n=MIe(t),r=e.assembleGroupEncodeEntry(!1),i=this.assembleLabelTitle()||e.assembleTitle(),a=e.assembleGroupStyle();return[{name:this.getName(`cell`),type:`group`,...i?{title:i}:{},...a?{style:a}:{},from:{facet:this.assembleFacet()},sort:{field:T4.map(e=>this.facetSortFields(e)).flat(),order:T4.map(e=>this.facetSortOrder(e)).flat()},...n.length>0?{data:n}:{},...r?{encode:{update:r}}:{},...e.assembleGroup(pNe(this,[]))}]}getMapping(){return this.facet}},lBe=class extends r8{children;constructor(e,t,n,r){super(e,`concat`,t,n,r,e.resolve),(e.resolve?.axis?.x===`shared`||e.resolve?.axis?.y===`shared`)&&X(vRe),this.children=this.getChildren(e).map((e,t)=>M2(e,this,this.getName(`concat_${t}`),void 0,r))}parseData(){this.component.data=O2(this);for(let e of this.children)e.parseData()}parseSelections(){this.component.selection={};for(let e of this.children){e.parseSelections();for(let t of $(e.component.selection))this.component.selection[t]=e.component.selection[t]}P2(this.component.selection).some(e=>K0(e))&&j$(L4)}parseMarkGroup(){for(let e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){for(let e of this.children)e.parseAxesAndHeaders()}getChildren(e){return o0(e)?e.vconcat:s0(e)?e.hconcat:e.concat}parseLayoutSize(){BIe(this)}parseAxisGroup(){return null}assembleSelectionTopLevelSignals(e){return this.children.reduce((e,t)=>t.assembleSelectionTopLevelSignals(e),e)}assembleSignals(){return this.children.forEach(e=>e.assembleSignals()),[]}assembleLayoutSignals(){let e=i2(this);for(let t of this.children)e.push(...t.assembleLayoutSignals());return e}assembleSelectionData(e){return this.children.reduce((e,t)=>t.assembleSelectionData(e),e)}assembleMarks(){return this.children.map(e=>{let t=e.assembleTitle(),n=e.assembleGroupStyle(),r=e.assembleGroupEncodeEntry(!1);return{type:`group`,name:e.getName(`group`),...t?{title:t}:{},...n?{style:n}:{},...r?{encode:{update:r}}:{},...e.assembleGroup()}})}assembleGroupStyle(){}assembleDefaultLayout(){let e=this.layout.columns;return{...e==null?{}:{columns:e},bounds:`full`,align:`each`}}},v8=$({disable:1,gridScale:1,scale:1,...w3,labelExpr:1,encode:1}),uBe=class e extends W3{explicit;implicit;mainExtracted;constructor(e={},t={},n=!1){super(),this.explicit=e,this.implicit=t,this.mainExtracted=n}clone(){return new e(N2(this.explicit),N2(this.implicit),this.mainExtracted)}hasAxisPart(e){return e===`axis`?!0:e===`grid`||e===`title`?!!this.get(e):!qIe(this.get(e))}hasOrientSignalRef(){return JQ(this.explicit.orient)}},dBe={bottom:`top`,top:`bottom`,left:`right`,right:`left`},fBe=new Set([`grid`,`translate`,`format`,`formatType`,`orient`,`labelExpr`,`tickCount`,`position`,`tickMinStep`]),pBe={vgMark:`arc`,encodeEntry:e=>({...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`ignore`,orient:`ignore`,theta:`ignore`}),...L0(`x`,e,{defaultPos:`mid`}),...L0(`y`,e,{defaultPos:`mid`}),...V0(e,`radius`),...V0(e,`theta`)})},mBe={vgMark:`area`,encodeEntry:e=>({...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`include`,size:`ignore`,theta:`ignore`}),...z0(`x`,e,{defaultPos:`zeroOrMin`,defaultPos2:`zeroOrMin`,range:e.markDef.orient===`horizontal`}),...z0(`y`,e,{defaultPos:`zeroOrMin`,defaultPos2:`zeroOrMin`,range:e.markDef.orient===`vertical`}),...U0(e)})},hBe={vgMark:`rect`,encodeEntry:e=>({...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...V0(e,`x`),...V0(e,`y`)})},gBe={vgMark:`shape`,encodeEntry:e=>({...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`ignore`,orient:`ignore`,theta:`ignore`})}),postEncodingTransform:e=>{let{encoding:t}=e,n=t.shape;return[{type:`geoshape`,projection:e.projectionName(),...n&&Z(n)&&n.type===X4?{field:Q(n,{expr:`datum`})}:{}}]}},_Be={vgMark:`image`,encodeEntry:e=>({...H0(e,{align:`ignore`,baseline:`ignore`,color:`ignore`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...V0(e,`x`),...V0(e,`y`),...N0(e,`url`)})},vBe={vgMark:`line`,encodeEntry:e=>({...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`ignore`,orient:`ignore`,theta:`ignore`}),...L0(`x`,e,{defaultPos:`mid`}),...L0(`y`,e,{defaultPos:`mid`}),...F0(`size`,e,{vgChannel:`strokeWidth`}),...U0(e)})},yBe={vgMark:`trail`,encodeEntry:e=>({...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`include`,orient:`ignore`,theta:`ignore`}),...L0(`x`,e,{defaultPos:`mid`}),...L0(`y`,e,{defaultPos:`mid`}),...F0(`size`,e),...U0(e)})},bBe={vgMark:`symbol`,encodeEntry:e=>A2(e)},xBe={vgMark:`symbol`,encodeEntry:e=>A2(e,`circle`)},SBe={vgMark:`symbol`,encodeEntry:e=>A2(e,`square`)},CBe={vgMark:`rect`,encodeEntry:e=>({...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...V0(e,`x`),...V0(e,`y`)})},wBe={vgMark:`rule`,encodeEntry:e=>{let{markDef:t}=e,n=t.orient;return!e.encoding.x&&!e.encoding.y&&!e.encoding.latitude&&!e.encoding.longitude?{}:{...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...z0(`x`,e,{defaultPos:n===`horizontal`?`zeroOrMax`:`mid`,defaultPos2:`zeroOrMin`,range:n!==`vertical`}),...z0(`y`,e,{defaultPos:n===`vertical`?`zeroOrMax`:`mid`,defaultPos2:`zeroOrMin`,range:n!==`horizontal`}),...F0(`size`,e,{vgChannel:`strokeWidth`})}}},TBe={vgMark:`text`,encodeEntry:e=>{let{config:t,encoding:n}=e;return{...H0(e,{align:`include`,baseline:`include`,color:`include`,size:`ignore`,orient:`ignore`,theta:`include`}),...L0(`x`,e,{defaultPos:`mid`}),...L0(`y`,e,{defaultPos:`mid`}),...N0(e),...F0(`size`,e,{vgChannel:`fontSize`}),...F0(`angle`,e),...HNe(`align`,rLe(e.markDef,n,t)),...HNe(`baseline`,iLe(e.markDef,n,t)),...L0(`radius`,e,{defaultPos:null}),...L0(`theta`,e,{defaultPos:null})}}},y8={arc:pBe,area:mBe,bar:hBe,circle:xBe,geoshape:gBe,image:_Be,line:vBe,point:bBe,rect:CBe,rule:wBe,square:SBe,text:TBe,tick:{vgMark:`rect`,encodeEntry:e=>{let{config:t,markDef:n}=e,r=n.orient,i=r===`horizontal`?`x`:`y`,a=r===`horizontal`?`y`:`x`,o=r===`horizontal`?`height`:`width`;return{...H0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...V0(e,i),...L0(a,e,{defaultPos:`mid`,vgChannel:a===`y`?`yc`:`xc`}),[o]:t$(a$(`thickness`,n,t))}}},trail:yBe},b8=`faceted_path_`,x8=`stack_group_`,S8=class extends i8{markDef;encoding;specifiedScales={};stack;specifiedAxes={};specifiedLegends={};specifiedProjection={};selection=[];children=[];constructor(e,t,n,r={},i){super(e,`unit`,t,n,i,void 0,Wje(e)?e.view:void 0);let a=n1(e.mark)?{...e.mark}:{type:e.mark},o=a.type;a.filled===void 0&&(a.filled=uMe(a,i,{graticule:e.data&&E0(e.data)}));let s=this.encoding=yje(e.encoding||{},o,a.filled,i);this.markDef=sMe(a,s,i),this.size=tLe({encoding:s,size:Wje(e)?{...r,...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height}}:r}),this.stack=oMe(this.markDef,s),this.specifiedScales=this.initScales(o,s),this.specifiedAxes=this.initAxes(s),this.specifiedLegends=this.initLegends(s),this.specifiedProjection=e.projection,this.selection=(e.params??[]).filter(e=>i0(e)),this.alignStackOrderWithColorDomain()}get hasProjection(){let{encoding:e}=this,t=this.mark===p3,n=e&&_Le.some(t=>O1(e[t]));return t||n}scaleDomain(e){let t=this.specifiedScales[e];return t?t.domain:void 0}axis(e){return this.specifiedAxes[e]}legend(e){return this.specifiedLegends[e]}initScales(e,t){return P4.reduce((e,n)=>{let r=z1(t[n]);return r&&(e[n]=this.initScale(r.scale??{})),e},{})}initScale(e){let{domain:t,range:n}=e,r=GQ(e);return H(t)&&(r.domain=t.map($Q)),H(n)&&(r.range=n.map($Q)),r}initAxes(e){return k4.reduce((t,n)=>{let r=e[n];if(O1(r)||n===V2&&O1(e.x2)||n===H2&&O1(e.y2)){let e=O1(r)?r.axis:void 0;t[n]=e&&this.initAxis({...e})}return t},{})}initAxis(e){let t=$(e),n={};for(let r of t){let t=e[r];n[r]=K1(t)?QQ(t):$Q(t)}return n}initLegends(e){return eRe.reduce((t,n)=>{let r=z1(e[n]);if(r&&zOe(n)){let e=r.legend;t[n]=e&&GQ(e)}return t},{})}alignStackOrderWithColorDomain(){let{color:e,fill:t,order:n,xOffset:r,yOffset:i}=this.encoding,a=t||e,o=Z(a)?a:void 0,s=o?.field,c=o?.scale,l=o?.type,u=c?.domain,d=r||i,f=Z(d)?d:void 0,p=`_${s}_sort_index`;if(!n&&Array.isArray(u)&&typeof s==`string`&&l===`nominal`)if(f&&!f.sort)f.sort=u;else{if(!this.stack)return;let e=`indexof(${W(u)}, datum['${s}'])`,t=this.markDef?.orient===`horizontal`?`ascending`:`descending`;this.transforms.push({calculate:e,as:p}),this.encoding.order={field:p,type:`quantitative`,sort:t}}}parseData(){this.component.data=O2(this)}parseLayoutSize(){VIe(this)}parseSelections(){this.component.selection=XNe(this,this.selection)}parseMarkGroup(){this.component.mark=aLe(this)}parseAxesAndHeaders(){this.component.axes=YIe(this)}assembleSelectionTopLevelSignals(e){return mNe(this,e)}assembleSignals(){return[...tPe(this),...fNe(this,[])]}assembleSelectionData(e){return hNe(this,e)}assembleLayout(){return null}assembleLayoutSignals(){return i2(this)}correctDataNames=e=>(e.from?.data&&(e.from.data=this.lookupDataSource(e.from.data),`time`in this.encoding&&(e.from.data=e.from.data+Q3)),e.from?.facet?.data&&(e.from.facet.data=this.lookupDataSource(e.from.facet.data)),e);assembleMarks(){let e=this.component.mark??[];return(!this.parent||!w2(this.parent))&&(e=gNe(this,e)),e.map(this.correctDataNames)}assembleGroupStyle(){let{style:e}=this.view||{};return e===void 0?this.encoding.x||this.encoding.y?`cell`:`view`:e}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(e){return J1(this.encoding,e)}fieldDef(e){let t=this.encoding[e];return R1(t)}typedFieldDef(e){let t=this.fieldDef(e);return k1(t)?t:null}},EBe=class e extends r8{children;constructor(t,n,r,i,a){super(t,`layer`,n,r,a,t.resolve,t.view);let o={...i,...t.width?{width:t.width}:{},...t.height?{height:t.height}:{}};this.children=t.layer.map((t,n)=>{if(f0(t))return new e(t,this,this.getName(`layer_${n}`),o,a);if(q1(t))return new S8(t,this,this.getName(`layer_${n}`),o,a);throw Error(p$(t))})}parseData(){this.component.data=O2(this);for(let e of this.children)e.parseData()}parseLayoutSize(){zIe(this)}parseSelections(){this.component.selection={};for(let e of this.children){e.parseSelections();for(let t of $(e.component.selection))this.component.selection[t]=e.component.selection[t]}P2(this.component.selection).some(e=>K0(e))&&j$(L4)}parseMarkGroup(){for(let e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){XIe(this)}assembleSelectionTopLevelSignals(e){return this.children.reduce((e,t)=>t.assembleSelectionTopLevelSignals(e),e)}assembleSignals(){return this.children.reduce((e,t)=>e.concat(t.assembleSignals()),tPe(this))}assembleLayoutSignals(){return this.children.reduce((e,t)=>e.concat(t.assembleLayoutSignals()),i2(this))}assembleSelectionData(e){return this.children.reduce((e,t)=>t.assembleSelectionData(e),e)}assembleGroupStyle(){let e=new Set;for(let t of this.children)for(let n of Gh(t.assembleGroupStyle()))e.add(n);let t=Array.from(e);return t.length>1?t:t.length===1?t[0]:void 0}assembleTitle(){let e=super.assembleTitle();if(e)return e;for(let t of this.children)if(e=t.assembleTitle(),e)return e}assembleLayout(){return null}assembleMarks(){return _Ne(this,this.children.flatMap(e=>e.assembleMarks()))}assembleLegends(){return this.children.reduce((e,t)=>e.concat(t.assembleLegends()),zFe(this))}},DBe=hLe.version}));function kBe(e){let[t,n]=/schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(e).slice(1,3);return{library:t,version:n}}var ABe=o((()=>{})),jBe=c({carbong10:()=>uVe,carbong100:()=>fVe,carbong90:()=>dVe,carbonwhite:()=>lVe,dark:()=>NBe,excel:()=>PBe,fivethirtyeight:()=>LBe,ggplot2:()=>RBe,googlecharts:()=>XBe,latimes:()=>HBe,powerbi:()=>aVe,quartz:()=>UBe,urbaninstitute:()=>YBe,version:()=>pVe,vox:()=>WBe});function C8({theme:e,background:t}){let n=[`white`,`g10`].includes(e)?`light`:`dark`,r=d5.gridBg[e],i=d5.textPrimary[e],a=d5.textSecondary[e],o=n===`dark`?sVe:cVe,s=n===`dark`?`#d4bbff`:`#6929c4`;return{background:t,arc:{fill:s},area:{fill:s},path:{stroke:s},rect:{fill:s},shape:{stroke:s},symbol:{stroke:s},circle:{fill:s},view:{fill:r,stroke:r},group:{fill:r},title:{color:i,anchor:`start`,dy:-15,fontSize:16,font:l5,fontWeight:600},axis:{labelColor:a,labelFontSize:12,labelFont:oVe,labelFontWeight:u5,titleColor:i,titleFontWeight:600,titleFontSize:12,grid:!0,gridColor:d5.layerAccent01[e],labelAngle:0},axisX:{titlePadding:10},axisY:{titlePadding:2.5},style:{"guide-label":{font:l5,fill:a,fontWeight:u5},"guide-title":{font:l5,fill:a,fontWeight:u5}},range:{category:o,diverging:[`#750e13`,`#a2191f`,`#da1e28`,`#fa4d56`,`#ff8389`,`#ffb3b8`,`#ffd7d9`,`#fff1f1`,`#e5f6ff`,`#bae6ff`,`#82cfff`,`#33b1ff`,`#1192e8`,`#0072c3`,`#00539a`,`#003a6d`],heatmap:[`#f6f2ff`,`#e8daff`,`#d4bbff`,`#be95ff`,`#a56eff`,`#8a3ffc`,`#6929c4`,`#491d8b`,`#31135e`,`#1c0f30`]}}}var MBe,w8,T8,NBe,E8,PBe,D8,O8,FBe,IBe,k8,A8,LBe,j8,RBe,zBe,BBe,M8,N8,VBe,P8,F8,I8,L8,R8,HBe,z8,B8,UBe,V8,WBe,H8,U8,GBe,W8,G8,KBe,qBe,JBe,K8,YBe,q8,J8,Y8,XBe,X8,Z8,Q8,$8,e5,t5,n5,r5,i5,ZBe,a5,QBe,$Be,eVe,tVe,nVe,rVe,iVe,o5,s5,c5,aVe,l5,oVe,u5,d5,sVe,cVe,lVe,uVe,dVe,fVe,pVe,mVe=o((()=>{MBe={version:`3.0.0`},w8=`#fff`,T8=`#888`,NBe={background:`#333`,view:{stroke:T8},title:{color:w8,subtitleColor:w8},style:{"guide-label":{fill:w8},"guide-title":{fill:w8}},axis:{domainColor:w8,gridColor:T8,tickColor:w8}},E8=`#4572a7`,PBe={background:`#fff`,arc:{fill:E8},area:{fill:E8},line:{stroke:E8,strokeWidth:2},path:{stroke:E8},rect:{fill:E8},shape:{stroke:E8},symbol:{fill:E8,strokeWidth:1.5,size:50},axis:{bandPosition:.5,grid:!0,gridColor:`#000000`,gridOpacity:1,gridWidth:.5,labelPadding:10,tickSize:5,tickWidth:.5},axisBand:{grid:!1,tickExtra:!0},legend:{labelBaseline:`middle`,labelFontSize:11,symbolSize:50,symbolType:`square`},range:{category:[`#4572a7`,`#aa4643`,`#8aa453`,`#71598e`,`#4598ae`,`#d98445`,`#94aace`,`#d09393`,`#b9cc98`,`#a99cbc`]}},D8=`#30a2da`,O8=`#cbcbcb`,FBe=`#999`,IBe=`#333`,k8=`#f0f0f0`,A8=`#333`,LBe={arc:{fill:D8},area:{fill:D8},axis:{domainColor:O8,grid:!0,gridColor:O8,gridWidth:1,labelColor:FBe,labelFontSize:10,titleColor:IBe,tickColor:O8,tickSize:10,titleFontSize:14,titlePadding:10,labelPadding:4},axisBand:{grid:!1},background:k8,group:{fill:k8},legend:{labelColor:A8,labelFontSize:11,padding:1,symbolSize:30,symbolType:`square`,titleColor:A8,titleFontSize:14,titlePadding:10},line:{stroke:D8,strokeWidth:2},path:{stroke:D8,strokeWidth:.5},rect:{fill:D8},range:{category:[`#30a2da`,`#fc4f30`,`#e5ae38`,`#6d904f`,`#8b8b8b`,`#b96db8`,`#ff9e27`,`#56cc60`,`#52d2ca`,`#52689e`,`#545454`,`#9fe4f8`],diverging:[`#cc0020`,`#e77866`,`#f6e7e1`,`#d6e8ed`,`#91bfd9`,`#1d78b5`],heatmap:[`#d6e8ed`,`#cee0e5`,`#91bfd9`,`#549cc6`,`#1d78b5`]},point:{filled:!0,shape:`circle`},shape:{stroke:D8},bar:{binSpacing:2,fill:D8,stroke:null},title:{anchor:`start`,fontSize:24,fontWeight:600,offset:20}},j8=`#000`,RBe={group:{fill:`#e5e5e5`},arc:{fill:j8},area:{fill:j8},line:{stroke:j8},path:{stroke:j8},rect:{fill:j8},shape:{stroke:j8},symbol:{fill:j8,size:40},axis:{domain:!1,grid:!0,gridColor:`#FFFFFF`,gridOpacity:1,labelColor:`#7F7F7F`,labelPadding:4,tickColor:`#7F7F7F`,tickSize:5.67,titleFontSize:16,titleFontWeight:`normal`},legend:{labelBaseline:`middle`,labelFontSize:11,symbolSize:40},range:{category:[`#000000`,`#7F7F7F`,`#1A1A1A`,`#999999`,`#333333`,`#B0B0B0`,`#4D4D4D`,`#C9C9C9`,`#666666`,`#DCDCDC`]}},zBe=22,BBe=`normal`,M8=`Benton Gothic, sans-serif`,N8=11.5,VBe=`normal`,P8=`#82c6df`,F8=`Benton Gothic Bold, sans-serif`,I8=`normal`,L8=13,R8={"category-6":[`#ec8431`,`#829eb1`,`#c89d29`,`#3580b1`,`#adc839`,`#ab7fb4`],"fire-7":[`#fbf2c7`,`#f9e39c`,`#f8d36e`,`#f4bb6a`,`#e68a4f`,`#d15a40`,`#ab4232`],"fireandice-6":[`#e68a4f`,`#f4bb6a`,`#f9e39c`,`#dadfe2`,`#a6b7c6`,`#849eae`]},HBe={background:`#ffffff`,title:{anchor:`start`,color:`#000000`,font:F8,fontSize:zBe,fontWeight:BBe},arc:{fill:P8},area:{fill:P8},line:{stroke:P8,strokeWidth:2},path:{stroke:P8},rect:{fill:P8},shape:{stroke:P8},symbol:{fill:P8,size:30},axis:{labelFont:M8,labelFontSize:N8,labelFontWeight:VBe,titleFont:F8,titleFontSize:L8,titleFontWeight:I8},axisX:{labelAngle:0,labelPadding:4,tickSize:3},axisY:{labelBaseline:`middle`,maxExtent:45,minExtent:45,tickSize:2,titleAlign:`left`,titleAngle:0,titleX:-45,titleY:-11},legend:{labelFont:M8,labelFontSize:N8,symbolType:`square`,titleFont:F8,titleFontSize:L8,titleFontWeight:I8},range:{category:R8[`category-6`],diverging:R8[`fireandice-6`],heatmap:R8[`fire-7`],ordinal:R8[`fire-7`],ramp:R8[`fire-7`]}},z8=`#ab5787`,B8=`#979797`,UBe={background:`#f9f9f9`,arc:{fill:z8},area:{fill:z8},line:{stroke:z8},path:{stroke:z8},rect:{fill:z8},shape:{stroke:z8},symbol:{fill:z8,size:30},axis:{domainColor:B8,domainWidth:.5,gridWidth:.2,labelColor:B8,tickColor:B8,tickWidth:.2,titleColor:B8},axisBand:{grid:!1},axisX:{grid:!0,tickSize:10},axisY:{domain:!1,grid:!0,tickSize:0},legend:{labelFontSize:11,padding:1,symbolSize:30,symbolType:`square`},range:{category:[`#ab5787`,`#51b2e5`,`#703c5c`,`#168dd9`,`#d190b6`,`#00609f`,`#d365ba`,`#154866`,`#666666`,`#c4c4c4`]}},V8=`#3e5c69`,WBe={background:`#fff`,arc:{fill:V8},area:{fill:V8},line:{stroke:V8},path:{stroke:V8},rect:{fill:V8},shape:{stroke:V8},symbol:{fill:V8},axis:{domainWidth:.5,grid:!0,labelPadding:2,tickSize:5,tickWidth:.5,titleFontWeight:`normal`},axisBand:{grid:!1},axisX:{gridWidth:.2},axisY:{gridDash:[3],gridWidth:.4},legend:{labelFontSize:11,padding:1,symbolType:`square`},range:{category:[`#3e5c69`,`#6793a6`,`#182429`,`#0570b0`,`#3690c0`,`#74a9cf`,`#a6bddb`,`#e2ddf2`]}},H8=`#1696d2`,U8=`#000000`,GBe=`#FFFFFF`,W8=`Lato`,G8=`Lato`,KBe=`Lato`,qBe=`#DEDDDD`,JBe=18,K8={"shades-blue":[`#CFE8F3`,`#A2D4EC`,`#73BFE2`,`#46ABDB`,`#1696D2`,`#12719E`,`#0A4C6A`,`#062635`],"six-groups-cat-1":[`#1696d2`,`#ec008b`,`#fdbf11`,`#000000`,`#d2d2d2`,`#55b748`],"six-groups-seq":[`#cfe8f3`,`#a2d4ec`,`#73bfe2`,`#46abdb`,`#1696d2`,`#12719e`],"diverging-colors":[`#ca5800`,`#fdbf11`,`#fdd870`,`#fff2cf`,`#cfe8f3`,`#73bfe2`,`#1696d2`,`#0a4c6a`]},YBe={background:GBe,title:{anchor:`start`,fontSize:JBe,font:W8},axisX:{domain:!0,domainColor:U8,domainWidth:1,grid:!1,labelFontSize:12,labelFont:G8,labelAngle:0,tickColor:U8,tickSize:5,titleFontSize:12,titlePadding:10,titleFont:W8},axisY:{domain:!1,domainWidth:1,grid:!0,gridColor:qBe,gridWidth:1,labelFontSize:12,labelFont:G8,labelPadding:8,ticks:!1,titleFontSize:12,titlePadding:10,titleFont:W8,titleAngle:0,titleY:-10,titleX:18},legend:{labelFontSize:12,labelFont:G8,symbolSize:100,titleFontSize:12,titlePadding:10,titleFont:W8,orient:`right`,offset:10},view:{stroke:`transparent`},range:{category:K8[`six-groups-cat-1`],diverging:K8[`diverging-colors`],heatmap:K8[`diverging-colors`],ordinal:K8[`six-groups-seq`],ramp:K8[`shades-blue`]},area:{fill:H8},rect:{fill:H8},line:{color:H8,stroke:H8,strokeWidth:5},trail:{color:H8,stroke:H8,strokeWidth:0,size:1},path:{stroke:H8,strokeWidth:.5},point:{filled:!0},text:{font:KBe,color:H8,fontSize:11,align:`center`,fontWeight:400,size:11},style:{bar:{fill:H8,stroke:null}},arc:{fill:H8},shape:{stroke:H8},symbol:{fill:H8,size:30}},q8=`#3366CC`,J8=`#ccc`,Y8=`Arial, sans-serif`,XBe={arc:{fill:q8},area:{fill:q8},path:{stroke:q8},rect:{fill:q8},shape:{stroke:q8},symbol:{stroke:q8},circle:{fill:q8},background:`#fff`,padding:{top:10,right:10,bottom:10,left:10},style:{"guide-label":{font:Y8,fontSize:12},"guide-title":{font:Y8,fontSize:12},"group-title":{font:Y8,fontSize:12}},title:{font:Y8,fontSize:14,fontWeight:`bold`,dy:-3,anchor:`start`},axis:{gridColor:J8,tickColor:J8,domain:!1,grid:!0},range:{category:[`#4285F4`,`#DB4437`,`#F4B400`,`#0F9D58`,`#AB47BC`,`#00ACC1`,`#FF7043`,`#9E9D24`,`#5C6BC0`,`#F06292`,`#00796B`,`#C2185B`],heatmap:[`#c6dafc`,`#5e97f6`,`#2a56c6`]}},X8=e=>e*1.3333333333333333,Z8=X8(9),Q8=X8(10),$8=X8(12),e5=`Segoe UI`,t5=`wf_standard-font, helvetica, arial, sans-serif`,n5=`#252423`,r5=`#605E5C`,i5=`transparent`,ZBe=`#C8C6C4`,a5=`#118DFF`,QBe=`#12239E`,$Be=`#E66C37`,eVe=`#6B007B`,tVe=`#E044A7`,nVe=`#744EC2`,rVe=`#D9B300`,iVe=`#D64550`,o5=a5,s5=`#DEEFFF`,c5=[s5,o5],aVe={view:{stroke:i5},background:i5,font:e5,header:{titleFont:t5,titleFontSize:$8,titleColor:n5,labelFont:e5,labelFontSize:Q8,labelColor:r5},axis:{ticks:!1,grid:!1,domain:!1,labelColor:r5,labelFontSize:Z8,titleFont:t5,titleColor:n5,titleFontSize:$8,titleFontWeight:`normal`},axisQuantitative:{tickCount:3,grid:!0,gridColor:ZBe,gridDash:[1,5],labelFlush:!1},axisBand:{tickExtra:!0},axisX:{labelPadding:5},axisY:{labelPadding:10},bar:{fill:a5},line:{stroke:a5,strokeWidth:3,strokeCap:`round`,strokeJoin:`round`},text:{font:e5,fontSize:Z8,fill:r5},arc:{fill:a5},area:{fill:a5,line:!0,opacity:.6},path:{stroke:a5},rect:{fill:a5},point:{fill:a5,filled:!0,size:75},shape:{stroke:a5},symbol:{fill:a5,strokeWidth:1.5,size:50},legend:{titleFont:e5,titleFontWeight:`bold`,titleColor:r5,labelFont:e5,labelFontSize:Q8,labelColor:r5,symbolType:`circle`,symbolSize:75},range:{category:[a5,QBe,$Be,eVe,tVe,nVe,rVe,iVe],diverging:c5,heatmap:c5,ordinal:[s5,`#c7e4ff`,`#b0d9ff`,`#9aceff`,`#83c3ff`,`#6cb9ff`,`#55aeff`,`#3fa3ff`,`#2898ff`,o5]}},l5=`IBM Plex Sans,system-ui,-apple-system,BlinkMacSystemFont,".sfnstext-regular",sans-serif`,oVe=`IBM Plex Sans Condensed, system-ui, -apple-system, BlinkMacSystemFont, ".SFNSText-Regular", sans-serif`,u5=400,d5={textPrimary:{g90:`#f4f4f4`,g100:`#f4f4f4`,white:`#161616`,g10:`#161616`},textSecondary:{g90:`#c6c6c6`,g100:`#c6c6c6`,white:`#525252`,g10:`#525252`},layerAccent01:{white:`#e0e0e0`,g10:`#e0e0e0`,g90:`#525252`,g100:`#393939`},gridBg:{white:`#ffffff`,g10:`#ffffff`,g90:`#161616`,g100:`#161616`}},sVe=[`#8a3ffc`,`#33b1ff`,`#007d79`,`#ff7eb6`,`#fa4d56`,`#fff1f1`,`#6fdc8c`,`#4589ff`,`#d12771`,`#d2a106`,`#08bdba`,`#bae6ff`,`#ba4e00`,`#d4bbff`],cVe=[`#6929c4`,`#1192e8`,`#005d5d`,`#9f1853`,`#fa4d56`,`#570408`,`#198038`,`#002d9c`,`#ee538b`,`#b28600`,`#009d9a`,`#012749`,`#8a3800`,`#a56eff`],lVe=C8({theme:`white`,background:`#ffffff`}),uVe=C8({theme:`g10`,background:`#f4f4f4`}),dVe=C8({theme:`g90`,background:`#262626`}),fVe=C8({theme:`g100`,background:`#161616`}),pVe=MBe.version}));function hVe(e,t,n,r){if(H(e))return`[${e.map(e=>t(gg(e)?e:_Ve(e,n))).join(`, `)}]`;if(gh(e)){let i=``,{title:a,image:o,...s}=e;a&&(i+=`

${t(a)}

`),o&&(i+=``);let c=Object.keys(s);if(c.length>0){i+=``;for(let e of c){let r=s[e];r!==void 0&&(gh(r)&&(r=_Ve(r,n)),i+=``)}i+=`
${t(e)}${t(r)}
`}return i||`{}`}return t(e)}function gVe(e){let t=[];return function(n,r){if(typeof r!=`object`||!r)return r;let i=t.indexOf(this)+1;return t.length=i,t.length>e?`[Object]`:t.indexOf(r)>=0?`[Circular]`:(t.push(r),r)}}function _Ve(e,t){return JSON.stringify(e,gVe(t))}function vVe(e){return String(e).replace(/&/g,`&`).replace(/=0&&e.y>=0&&e.x+t.width<=window.innerWidth&&e.y+t.height<=window.innerHeight}function TVe(e,t,n){return e.clientX>=t.x&&e.clientX<=t.x+n.width&&e.clientY>=t.y&&e.clientY<=t.y+n.height}var EVe,DVe,f5,OVe,kVe,AVe=o((()=>{Tg(),EVe={version:`1.0.0`},DVe=`#vg-tooltip-element { + : v !== v && u === u ? ${r} : `}function jTe(e){let t=this;OTe(e.type)||!e.type?t.operator(e,e.update?t.operatorExpression(e.update):null):t.transform(e,e.type)}function MTe(e){let t=this;if(e.params){let n=t.get(e.id);n||V(`Invalid operator id: `+e.id),t.dataflow.connect(n,n.parameters(t.parseParameters(e.params),e.react,e.initonly))}}function NTe(e,t){t||={};let n=this;for(let r in e){let i=e[r];t[r]=H(i)?i.map(e=>VW(e,n,t)):VW(i,n,t)}return t}function VW(e,t,n){if(!e||!Dh(e))return e;for(let r=0,i=JW.length,a;re&&e.$tupleid?Qb:e);return t.fn[n]||(t.fn[n]=og(r,e.$order,t.expr.codegen))}function zTe(e,t){let n=e.$encode,r={};for(let e in n){let i=n[e];r[e]=ah(t.encodeExpression(i.$expr),i.$fields),r[e].output=i.$output}return r}function BTe(e,t){return t}function VTe(e,t){let n=e.$subflow;return function(e,r,i){let a=t.fork().parse(n),o=a.get(n.operators[0].id),s=a.signals.parent;return s&&s.set(i),o.detachSubflow=()=>t.detach(a),o}}function HTe(){return Qb}function UTe(e){var t=this,n=e.filter==null?void 0:t.eventExpression(e.filter),r=e.stream==null?void 0:t.get(e.stream),i;e.source?r=t.events(e.source,e.type,n):e.merge&&(i=e.merge.map(e=>t.get(e)),r=i[0].merge.apply(i[0],i.slice(1))),e.between&&(i=e.between.map(e=>t.get(e)),r=r.between(i[0],i[1])),e.filter&&(r=r.filter(n)),e.throttle!=null&&(r=r.throttle(+e.throttle)),e.debounce!=null&&(r=r.debounce(+e.debounce)),r??V(`Invalid stream definition: `+JSON.stringify(e)),e.consume&&r.consume(!0),t.stream(e,r)}function WTe(e){var t=this,n=Dh(n=e.source)?n.$ref:n,r=t.get(n),i=null,a=e.update,o=void 0;r||V(`Source not defined: `+e.source),i=e.target&&e.target.$expr?t.eventExpression(e.target.$expr):t.get(e.target),a&&a.$expr&&(a.$params&&(o=t.parseParameters(a.$params)),a=t.handlerExpression(a.$expr)),t.update(e,r,i,a,o)}function GTe(e){var t=this,n={};if(e.signals){var r=n.signals={};Object.keys(t.signals).forEach(n=>{let i=t.signals[n];e.signals(n,i)&&(r[n]=i.value)})}if(e.data){var i=n.data={};Object.keys(t.data).forEach(n=>{let r=t.data[n];e.data(n,r)&&(i[n]=r.input.value)})}return t.subcontext&&e.recurse!==!1&&(n.subcontext=t.subcontext.map(t=>t.getState(e))),n}function KTe(e){var t=this,n=t.dataflow,r=e.data,i=e.signals;Object.keys(i||{}).forEach(e=>{n.update(t.signals[e],i[e],YW)}),Object.keys(r||{}).forEach(e=>{n.pulse(t.data[e].input,n.changeset().remove(Sh).insert(r[e]))}),(e.subcontext||[]).forEach((e,n)=>{let r=t.subcontext[n];r&&r.setState(e)})}function HW(e,t,n,r){return new UW(e,t,n,r)}function UW(e,t,n,r){this.dataflow=e,this.transforms=t,this.events=e.events.bind(e),this.expr=r||qW,this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},n&&(this.functions=Object.create(n),this.functions.context=this)}function WW(e){this.dataflow=e.dataflow,this.transforms=e.transforms,this.events=e.events,this.expr=e.expr,this.signals=Object.create(e.signals),this.scales=Object.create(e.scales),this.nodes=Object.create(e.nodes),this.data=Object.create(e.data),this.fn=Object.create(e.fn),e.functions&&(this.functions=Object.create(e.functions),this.functions.context=this)}var GW,KW,qW,JW,YW,XW=o((()=>{Ag(),Kx(),GW=Og([`rule`]),KW=Og([`group`,`image`,`rect`]),qW={operator:(e,t)=>BW(e,[`_`],t.code),parameter:(e,t)=>BW(e,[`datum`,`_`],t.code),event:(e,t)=>BW(e,[`event`],t.code),handler:(e,t)=>BW(e,[`_`,`event`],`var datum=event.item&&event.item.datum;return ${t.code};`),encode:(e,t)=>{let{marktype:n,channels:r}=t,i=`var o=item,datum=o.datum,m=0,$;`;for(let e in r){let t=`o[`+W(e)+`]`;i+=`$=${r[e].code};if(${t}!==$)${t}=$,m=1;`}return i+=DTe(r,n),i+=`return m;`,BW(e,[`item`,`_`],i)},codegen:{get(e){let t=`[${e.map(W).join(`][`)}]`,n=Function(`_`,`return _${t};`);return n.path=t,n},comparator(e,t){let n,r=Function(`a`,`b`,`var u, v; return `+e.map((e,r)=>{let i=t[r],a,o;return e.path?(a=`a${e.path}`,o=`b${e.path}`):((n||={})[`f`+r]=e,a=`this.f${r}(a)`,o=`this.f${r}(b)`),ATe(a,o,-i,i)}).join(``)+`0;`);return n?r.bind(n):r}}},JW=[{key:`$ref`,parse:PTe},{key:`$key`,parse:ITe},{key:`$expr`,parse:FTe},{key:`$field`,parse:LTe},{key:`$encode`,parse:zTe},{key:`$compare`,parse:RTe},{key:`$context`,parse:BTe},{key:`$subflow`,parse:VTe},{key:`$tupleid`,parse:HTe}],YW={skip:!0},UW.prototype=WW.prototype={fork(){let e=new WW(this);return(this.subcontext||=[]).push(e),e},detach(e){this.subcontext=this.subcontext.filter(t=>t!==e);let t=Object.keys(e.nodes);for(let n of t)e.nodes[n]._targets=null;for(let n of t)e.nodes[n].detach();e.nodes=null},get(e){return this.nodes[e]},set(e,t){return this.nodes[e]=t},add(e,t){let n=this,r=n.dataflow,i=e.value;if(n.set(e.id,t),kTe(e.type)&&i&&(i.$ingest?r.ingest(t,i.$ingest,i.$format):i.$request?r.preload(t,i.$request,i.$format):r.pulse(t,r.changeset().insert(i))),e.root&&(n.root=t),e.parent){let i=n.get(e.parent.$ref);i?(r.connect(i,[t]),t.targets().add(i)):(n.unresolved=n.unresolved||[]).push(()=>{i=n.get(e.parent.$ref),r.connect(i,[t]),t.targets().add(i)})}if(e.signal&&(n.signals[e.signal]=t),e.scale&&(n.scales[e.scale]=t),e.data)for(let r in e.data){let i=n.data[r]||(n.data[r]={});e.data[r].forEach(e=>i[e]=t)}},resolve(){return(this.unresolved||[]).forEach(e=>e()),delete this.unresolved,this},operator(e,t){this.add(e,this.dataflow.add(e.value,t))},transform(e,t){this.add(e,this.dataflow.add(this.transforms[zW(t)]))},stream(e,t){this.set(e.id,t)},update(e,t,n,r,i){this.dataflow.on(t,n,r,i,e.options)},operatorExpression(e){return this.expr.operator(this,e)},parameterExpression(e){return this.expr.parameter(this,e)},eventExpression(e){return this.expr.event(this,e)},handlerExpression(e){return this.expr.handler(this,e)},encodeExpression(e){return this.expr.encode(this,e)},parse:ETe,parseOperator:jTe,parseOperatorParameters:MTe,parseParameters:NTe,parseStream:UTe,parseUpdate:WTe,getState:GTe,setState:KTe}}));function qTe(e){let t=e.container();t&&(t.setAttribute(`role`,`graphics-document`),t.setAttribute(`aria-roleDescription`,`visualization`),ZW(t,e.description()))}function ZW(e,t){e&&(t==null?e.removeAttribute(`aria-label`):e.setAttribute(`aria-label`,t))}function JTe(e){e.add(null,t=>(e._background=t.bg,e._resize=1,t.bg),{bg:e._signals.background})}function YTe(e){let t=e._signals.cursor||(e._signals.cursor=e.add({user:TG,item:null}));e.on(e.events(`view`,`pointermove`),t,(e,n)=>{let r=t.value,i=r?xg(r)?r:r.user:TG,a=n.item&&n.item.cursor||null;return r&&i===r.user&&a==r.item?r:{user:i,item:a}}),e.add(null,function(t){let n=t.cursor,r=this.value;return xg(n)||(r=n.item,n=n.user),QW(e,n&&n!==TG?n:r||n),r},{cursor:t})}function QW(e,t){let n=e.globalCursor()?typeof document<`u`&&document.body:e.container();if(n)return t==null?n.style.removeProperty(`cursor`):n.style.cursor=t}function $W(e,t){var n=e._runtime.data;return fg(n,t)||V(`Unrecognized data set: `+t),n[t]}function XTe(e,t){return arguments.length<2?$W(this,e).values.value:eG.call(this,e,ox().remove(Sh).insert(t))}function eG(e,t){ax(t)||V(`Second argument to changes must be a changeset.`);let n=$W(this,e);return n.modified=!0,this.pulse(n.input,t)}function ZTe(e,t){return eG.call(this,e,ox().insert(t))}function QTe(e,t){return eG.call(this,e,ox().remove(t))}function tG(e){var t=e.padding();return Math.max(0,e._viewWidth+t.left+t.right)}function nG(e){var t=e.padding();return Math.max(0,e._viewHeight+t.top+t.bottom)}function rG(e){var t=e.padding(),n=e._origin;return[t.left+n[0],t.top+n[1]]}function $Te(e){var t=rG(e),n=tG(e),r=nG(e);e._renderer.background(e.background()),e._renderer.resize(n,r,t),e._handler.origin(t),e._resizeListeners.forEach(t=>{try{t(n,r)}catch(t){e.error(t)}})}function eEe(e,t,n){var r=e._renderer,i=r&&r.canvas(),a,o,s;return i&&(s=rG(e),o=t.changedTouches?t.changedTouches[0]:t,a=Dk(o,i),a[0]-=s[0],a[1]-=s[1]),t.dataflow=e,t.item=n,t.vega=tEe(e,n,a),t}function tEe(e,t,n){let r=t?t.mark.marktype===`group`?t:t.mark.group:null;function i(e){var n=r,i;if(e){for(i=t;i;i=i.mark.group)if(i.mark.name===e){n=i;break}}return n&&n.mark&&n.mark.interactive?n:{}}function a(e){if(!e)return n;xg(e)&&(e=i(e));let t=n.slice();for(;e;)t[0]-=e.x||0,t[1]-=e.y||0,e=e.mark&&e.mark.group;return t}return{view:cg(e),item:cg(t||{}),group:i,xy:a,x:e=>a(e)[0],y:e=>a(e)[1]}}function nEe(e){let t=ug({defaults:{}},e),n=(e,t)=>{t.forEach(t=>{H(e[t])&&(e[t]=Og(e[t]))})};return n(t.defaults,[`prevent`,`allow`]),n(t,[`view`,`window`,`selector`]),t}function iG(e,t,n,r){e._eventListeners.push({type:n,sources:ng(t),handler:r})}function rEe(e,t){var n=e._eventConfig.defaults,r=n.prevent,i=n.allow;return r===!1||i===!0?!1:r===!0||i===!1?!0:r?r[t]:i?!i[t]:e.preventDefault()}function aG(e,t,n){let r=e._eventConfig&&e._eventConfig[t];return r===!1||Dh(r)&&!r[n]?(e.warn(`Blocked ${t} ${n} event listener.`),!1):!0}function iEe(e,t,n){var r=this,i=new ux(n),a=function(n,a){r.runAsync(null,()=>{e===EG&&rEe(r,t)&&n.preventDefault(),i.receive(eEe(r,n,a))})},o;if(e===DG)aG(r,`timer`,t)&&r.timer(a,t);else if(e===EG)aG(r,`view`,t)&&r.addEventListener(t,a,kG);else if(e===OG?aG(r,`window`,t)&&typeof window<`u`&&(o=[window]):typeof document<`u`&&aG(r,`selector`,t)&&(o=Array.from(document.querySelectorAll(e))),!o)r.warn(`Can not resolve event source: `+e);else{for(var s=0,c=o.length;s=0;)t[i].stop();for(i=r.length;--i>=0;)for(o=r[i],a=o.sources.length;--a>=0;)o.sources[a].removeEventListener(o.type,o.handler);for(e&&e.call(this,this._handler,null,null,null),i=n.length;--i>=0;)c=n[i].type,s=n[i].handler,this._handler.off(c,s);return this}function lG(e,t,n){let r=document.createElement(e);for(let e in t)r.setAttribute(e,t[e]);return n!=null&&(r.textContent=n),r}function sEe(e,t,n){if(!t)return;let r=n.param,i=n.state;return i||(i=n.state={elements:null,active:!1,set:null,update:t=>{t!=e.signal(r.signal)&&e.runAsync(null,()=>{i.source=!0,e.signal(r.signal,t)})}},r.debounce&&(i.update=lg(r.debounce,i.update))),(r.input==null&&r.element?cEe:uEe)(i,t,r,e),i.active||(e.on(e._signals[r.signal],null,()=>{i.source?i.source=!1:i.set(e.signal(r.signal))}),i.active=!0),i}function cEe(e,t,n,r){let i=n.event||`input`,a=()=>e.update(t.value);r.signal(n.signal,t.value),t.addEventListener(i,a),iG(r,t,i,a),e.set=e=>{t.value=e,t.dispatchEvent(lEe(i))}}function lEe(e){return typeof Event<`u`?new Event(e):{type:e}}function uEe(e,t,n,r){let i=r.signal(n.signal),a=lG(`div`,{class:AG}),o=n.input===`radio`?a:a.appendChild(lG(`label`));o.appendChild(lG(`span`,{class:jG},n.name||n.signal)),t.appendChild(a);let s=dEe;switch(n.input){case`checkbox`:s=fEe;break;case`select`:s=pEe;break;case`radio`:s=mEe;break;case`range`:s=hEe;break}s(e,o,n,i)}function dEe(e,t,n,r){let i=lG(`input`);for(let e in n)e!==`signal`&&e!==`element`&&i.setAttribute(e===`input`?`type`:e,n[e]);i.setAttribute(`name`,n.signal),i.value=r,t.appendChild(i),i.addEventListener(`input`,()=>e.update(i.value)),e.elements=[i],e.set=e=>i.value=e}function fEe(e,t,n,r){let i={type:`checkbox`,name:n.signal};r&&(i.checked=!0);let a=lG(`input`,i);t.appendChild(a),a.addEventListener(`change`,()=>e.update(a.checked)),e.elements=[a],e.set=e=>a.checked=!!e||null}function pEe(e,t,n,r){let i=lG(`select`,{name:n.signal}),a=n.labels||[];n.options.forEach((e,t)=>{let n={value:e};uG(e,r)&&(n.selected=!0),i.appendChild(lG(`option`,n,(a[t]||e)+``))}),t.appendChild(i),i.addEventListener(`change`,()=>{e.update(n.options[i.selectedIndex])}),e.elements=[i],e.set=e=>{for(let t=0,r=n.options.length;t{let s={type:`radio`,name:n.signal,value:t};uG(t,r)&&(s.checked=!0);let c=lG(`input`,s);c.addEventListener(`change`,()=>e.update(t));let l=lG(`label`,{},(a[o]||t)+``);return l.prepend(c),i.appendChild(l),c}),e.set=t=>{let n=e.elements,r=n.length;for(let e=0;e{c.textContent=s.value,e.update(+s.value)};s.addEventListener(`input`,l),s.addEventListener(`change`,l),e.elements=[s],e.set=e=>{s.value=e,c.textContent=e}}function uG(e,t){return e===t||e+``==t+``}function dG(e,t,n,r,i,a){return t||=new r(e.loader()),t.initialize(n,tG(e),nG(e),rG(e),i,a).background(e.background())}function fG(e,t){return t?function(){try{t.apply(this,arguments)}catch(t){e.error(t)}}:null}function gEe(e,t,n,r){let i=new r(e.loader(),fG(e,e.tooltip())).scene(e.scenegraph().root).initialize(n,rG(e),e);return t&&t.handlers().forEach(e=>{i.on(e.type,e.handler)}),i}function _Ee(e,t){let n=this,r=n._renderType,i=n._eventConfig.bind,a=Pk(r);e=n._el=e?pG(n,e,!0):null,qTe(n),a||n.error(`Unrecognized renderer type: `+r);let o=a.handler||JA,s=e?a.renderer:a.headless;return n._renderer=s?dG(n,n._renderer,e,s):null,n._handler=gEe(n,n._handler,e,o),n._redraw=!0,e&&i!==`none`&&(t=t?n._elBind=pG(n,t,!0):e.appendChild(lG(`form`,{class:`vega-bindings`})),n._bind.forEach(e=>{e.param.element&&i!==`container`&&(e.element=pG(n,e.param.element,!!e.param.input))}),n._bind.forEach(e=>{sEe(n,e.element||t,e)})),n}function pG(e,t,n){if(typeof t==`string`)if(typeof document<`u`){if(t=document.querySelector(t),!t)return e.error(`Signal bind element not found: `+t),null}else return e.error(`DOM document instance not found.`),null;if(t&&n)try{t.textContent=``}catch(n){t=null,e.error(n)}return t}function mG(e){return Dh(e)?{top:NG(e.top),bottom:NG(e.bottom),left:NG(e.left),right:NG(e.right)}:PG(NG(e))}async function hG(e,t,n,r){let i=Pk(t),a=i&&i.headless;return a||V(`Unrecognized renderer type: `+t),await e.runAsync(),dG(e,null,null,a,n,r).renderAsync(e._scenegraph.root)}async function vEe(e,t){e!==Aj.Canvas&&e!==Aj.SVG&&e!==Aj.PNG&&V(`Unrecognized image type: `+e);let n=await hG(this,e,t);return e===Aj.SVG?yEe(n.svg(),`image/svg+xml`):n.canvas().toDataURL(`image/png`)}function yEe(e,t){let n=new Blob([e],{type:t});return window.URL.createObjectURL(n)}async function bEe(e,t){return(await hG(this,Aj.Canvas,e,t)).canvas()}async function xEe(e){return(await hG(this,Aj.SVG,e)).svg()}function SEe(e,t,n){return HW(e,Gx,jW,n).parse(t)}function CEe(e){var t=this._runtime.scales;return fg(t,e)||V(`Unrecognized scale or projection: `+e),t[e].value}function gG(e,t){var n=e.autosize(),r=e.padding();return t-(n&&n.contains===LG?r.left+r.right:0)}function _G(e,t){var n=e.autosize(),r=e.padding();return t-(n&&n.contains===LG?r.top+r.bottom:0)}function wEe(e){var t=e._signals,n=t[FG],r=t[IG],i=t[LG];function a(){e._autosize=e._resize=1}e._resizeWidth=e.add(null,t=>{e._width=t.size,e._viewWidth=gG(e,t.size),a()},{size:n}),e._resizeHeight=e.add(null,t=>{e._height=t.size,e._viewHeight=_G(e,t.size),a()},{size:r});let o=e.add(null,a,{pad:i});e._resizeWidth.rank=n.rank+1,e._resizeHeight.rank=r.rank+1,o.rank=i.rank+1}function TEe(e,t,n,r,i,a){this.runAfter(o=>{let s=0;o._autosize=0,o.width()!==n&&(s=1,o.signal(FG,n,RG),o._resizeWidth.skip(!0)),o.height()!==r&&(s=1,o.signal(IG,r,RG),o._resizeHeight.skip(!0)),o._viewWidth!==e&&(o._resize=1,o._viewWidth=e),o._viewHeight!==t&&(o._resize=1,o._viewHeight=t),(o._origin[0]!==i[0]||o._origin[1]!==i[1])&&(o._resize=1,o._origin=i),s&&o.run(`enter`),a&&o.runAfter(e=>e.resize())},!1,1)}function EEe(e){return this._runtime.getState(e||{data:DEe,signals:OEe,recurse:!0})}function DEe(e,t){return t.modified&&H(t.input.value)&&!e.startsWith(`_:vega:_`)}function OEe(e,t){return!(e===`parent`||t instanceof Gx.proxy)}function kEe(e){return this.runAsync(null,t=>{t._trigger=!1,t._runtime.setState(e)},e=>{e._trigger=!0}),this}function AEe(e,t){function n(t){e({timestamp:Date.now(),elapsed:t})}this._timers.push($be(n,t))}function jEe(e,t,n,r){let i=e.element();i&&i.setAttribute(`title`,MEe(r))}function MEe(e){return e==null?``:H(e)?vG(e):Dh(e)&&!vg(e)?NEe(e):e+``}function NEe(e){return Object.keys(e).map(t=>{let n=e[t];return t+`: `+(H(n)?vG(n):yG(n))}).join(` +`)}function vG(e){return`[`+e.map(yG).join(`, `)+`]`}function yG(e){return H(e)?`[…]`:Dh(e)&&!vg(e)?`{…}`:e}function PEe(){if(this.renderer()===`canvas`&&this._renderer._canvas){let e=null,t=()=>{e?.();let n=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);n.addEventListener(`change`,t),e=()=>{n.removeEventListener(`change`,t)},this._renderer._canvas.getContext(`2d`).pixelRatio=window.devicePixelRatio||1,this._redraw=!0,this._resize=1,this.resize().runAsync()};t()}}function bG(e,t){let n=this;if(t||={},yx.call(n),t.loader&&n.loader(t.loader),t.logger&&n.logger(t.logger),t.logLevel!=null&&n.logLevel(t.logLevel),t.locale||e.locale){let r=ug({},e.locale,t.locale);n.locale(vb(r.number,r.time))}n._el=null,n._elBind=null,n._renderType=t.renderer||Aj.Canvas,n._scenegraph=new EA;let r=n._scenegraph.root;n._renderer=null,n._tooltip=t.tooltip||jEe,n._redraw=!0,n._handler=new JA().scene(r),n._globalCursor=!1,n._preventDefault=!1,n._timers=[],n._eventListeners=[],n._resizeListeners=[],n._eventConfig=nEe(e.eventConfig),n.globalCursor(n._eventConfig.globalCursor);let i=SEe(n,e,t.expr);n._runtime=i,n._signals=i.signals,n._bind=(e.bindings||[]).map(e=>({state:null,param:ug({},e)})),i.root&&i.root.set(r),r.source=i.data.root.input,n.pulse(i.data.root.input,n.changeset().insert(r.items)),n._width=n.width(),n._height=n.height(),n._viewWidth=gG(n,n._width),n._viewHeight=_G(n,n._height),n._origin=[0,0],n._resize=0,n._autosize=1,wEe(n),JTe(n),YTe(n),n.description(e.description),t.hover&&n.hover(),t.container&&n.initialize(t.container,t.bind),t.watchPixelRatio&&n._watchPixelRatio()}function xG(e,t){return fg(e._signals,t)?e._signals[t]:V(`Unrecognized signal name: `+W(t))}function SG(e,t){let n=(e._targets||[]).filter(e=>e._update&&e._update.handler===t);return n.length?n[0]:null}function CG(e,t,n,r){let i=SG(n,r);return i||(i=fG(e,()=>r(t,n.value)),i.handler=r,e.on(n,null,i)),e}function wG(e,t,n){let r=SG(t,n);return r&&t._targets.remove(r),e}var TG,EG,DG,OG,kG,AG,jG,MG,NG,PG,FG,IG,LG,RG,FEe=o((()=>{Ag(),Kx(),Pj(),r_(),RW(),XW(),QR(),Cb(),TG=`default`,EG=`view`,DG=`timer`,OG=`window`,kG={trap:!1},AG=`vega-bind`,jG=`vega-bind-name`,MG=`vega-bind-radio`,NG=e=>+e||0,PG=e=>({top:e,bottom:e,left:e,right:e}),FG=`width`,IG=`height`,LG=`padding`,RG={skip:!0},U(bG,yx,{async evaluate(e,t,n){if(await yx.prototype.evaluate.call(this,e,t),this._redraw||this._resize)try{this._renderer&&(this._resize&&(this._resize=0,$Te(this)),await this._renderer.renderAsync(this._scenegraph.root)),this._redraw=!1}catch(e){this.error(e)}return n&&Xb(this,n),this},dirty(e){this._redraw=!0,this._renderer&&this._renderer.dirty(e)},description(e){if(arguments.length){let t=e==null?null:e+``;return t!==this._desc&&ZW(this._el,this._desc=t),this}return this._desc},container(){return this._el},scenegraph(){return this._scenegraph},origin(){return this._origin.slice()},signal(e,t,n){let r=xG(this,e);return arguments.length===1?r.value:this.update(r,t,n)},width(e){return arguments.length?this.signal(`width`,e):this.signal(`width`)},height(e){return arguments.length?this.signal(`height`,e):this.signal(`height`)},padding(e){return arguments.length?this.signal(`padding`,mG(e)):mG(this.signal(`padding`))},autosize(e){return arguments.length?this.signal(`autosize`,e):this.signal(`autosize`)},background(e){return arguments.length?this.signal(`background`,e):this.signal(`background`)},renderer(e){return arguments.length?(Pk(e)||V(`Unrecognized renderer type: `+e),e!==this._renderType&&(this._renderType=e,this._resetRenderer()),this):this._renderType},tooltip(e){return arguments.length?(e!==this._tooltip&&(this._tooltip=e,this._resetRenderer()),this):this._tooltip},loader(e){return arguments.length?(e!==this._loader&&(yx.prototype.loader.call(this,e),this._resetRenderer()),this):this._loader},resize(){return this._autosize=1,this.touch(xG(this,`autosize`))},_resetRenderer(){this._renderer&&(this._renderer=null,this.initialize(this._el,this._elBind))},_resizeView:TEe,addEventListener(e,t,n){let r=t;return n&&n.trap===!1||(r=fG(this,t),r.raw=t),this._handler.on(e,r),this},removeEventListener(e,t){for(var n=this._handler.handlers(e),r=n.length,i,a;--r>=0;)if(a=n[r].type,i=n[r].handler,e===a&&(t===i||t===i.raw)){this._handler.off(a,i);break}return this},addResizeListener(e){let t=this._resizeListeners;return t.includes(e)||t.push(e),this},removeResizeListener(e){var t=this._resizeListeners,n=t.indexOf(e);return n>=0&&t.splice(n,1),this},addSignalListener(e,t){return CG(this,e,xG(this,e),t)},removeSignalListener(e,t){return wG(this,xG(this,e),t)},addDataListener(e,t){return CG(this,e,$W(this,e).values,t)},removeDataListener(e,t){return wG(this,$W(this,e).values,t)},globalCursor(e){if(arguments.length){if(this._globalCursor!==!!e){let t=QW(this,null);this._globalCursor=!!e,t&&QW(this,t)}return this}else return this._globalCursor},preventDefault(e){return arguments.length?(this._preventDefault=e,this):this._preventDefault},timer:AEe,events:iEe,finalize:oEe,hover:aEe,data:XTe,change:eG,insert:ZTe,remove:QTe,scale:CEe,initialize:_Ee,toImageURL:vEe,toCanvas:bEe,toSVG:xEe,getState:EEe,setState:kEe,_watchPixelRatio:PEe})}));function zG(e,t,n){return eK=t||UG,tK=n||$G,VG(e.trim()).map(HG)}function IEe(e){return tK[e]}function BG(e,t,n,r,i){let a=e.length,o=0,s;for(;t' after between selector: `+e;r=r.map(HG);let i=HG(e.slice(1).trim());return i.between?{between:r,stream:i}:(i.between=r,i)}function REe(e){let t={source:eK},n=[],r=[0,0],i=0,a=0,o=e.length,s=0,c,l;if(e[o-1]===qG){if(s=e.lastIndexOf(KG),s>=0){try{r=zEe(e.substring(s+1,o-1))}catch{throw`Invalid throttle specification: `+e}e=e.slice(0,s).trim(),o=e.length}else throw`Unmatched right brace: `+e;s=0}if(!o)throw e;if(e[0]===XG&&(i=++s),c=BG(e,s,JG),c1?(t.type=n[1],i?t.markname=n[0].slice(1):IEe(n[0])?t.marktype=n[0]:t.source=n[0]):t.type=n[0],t.type.slice(-1)===`!`&&(t.consume=!0,t.type=t.type.slice(0,-1)),l!=null&&(t.filter=l),r[0]&&(t.throttle=r[0]),r[1]&&(t.debounce=r[1]),t}function zEe(e){let t=e.split(YG);if(!e.length||t.length>2)throw e;return t.map(t=>{let n=+t;if(n!==n)throw e;return n})}var UG,WG,GG,KG,qG,JG,YG,XG,ZG,QG,$G,eK,tK,nK=o((()=>{UG=`view`,WG=`[`,GG=`]`,KG=`{`,qG=`}`,JG=`:`,YG=`,`,XG=`@`,ZG=`>`,QG=/[[\]{}]/,$G={"*":1,arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1}}));function BEe(e){return Dh(e)?e:{type:e||`pad`}}function VEe(e){return Dh(e)?e.signal?e:{top:pq(e.top),bottom:pq(e.bottom),left:pq(e.left),right:pq(e.right)}:mq(pq(e))}function rK(e,t,n,r){return n==null?0:(Dh(n)&&!H(n)||H(n)&&n.length&&Dh(n[0])?e.update[t]=n:e[r||`enter`][t]={value:n},1)}function iK(e,t,n){for(let n in t)rK(e,n,t[n]);for(let t in n)rK(e,t,n[t],`update`)}function aK(e,t,n){for(let r in t)n&&fg(n,r)||(e[r]=ug(e[r]||{},t[r]));return e}function oK(e,t){return t&&(t.enter&&t.enter[e]||t.update&&t.update[e])}function HEe(e,t,n,r,i){let a={},o={},s,c,l,u;for(c in c=`lineBreak`,t===`text`&&i[c]!=null&&!oK(c,e)&&sK(a,c,i[c]),(n==`legend`||String(n).startsWith(`axis`))&&(n=null),u=n===`frame`?i.group:n===`mark`?ug({},i.mark,i[t]):null,u)l=oK(c,e)||(c===`fill`||c===`stroke`)&&(oK(`fill`,e)||oK(`stroke`,e)),l||sK(a,c,u[c]);for(c in ng(r).forEach(t=>{let n=i.style&&i.style[t];for(let t in n)oK(t,e)||sK(a,t,n[t])}),e=ug({},e),a)u=a[c],u.signal?(s||={})[c]=u:o[c]=u;return e.enter=ug(o,e.enter),s&&(e.update=ug(s,e.update)),e}function sK(e,t,n){e[t]=n&&n.signal?{signal:n.signal}:{value:n}}function cK(e){if(e.gradient!=null)return WEe(e);let t=e.signal?`(${e.signal})`:e.color?UEe(e.color):e.field==null?e.value===void 0?void 0:W(e.value):uK(e.field);return e.scale!=null&&(t=GEe(e,t)),t===void 0&&(t=null),e.exponent!=null&&(t=`pow(${t},${lK(e.exponent)})`),e.mult!=null&&(t+=`*${lK(e.mult)}`),e.offset!=null&&(t+=`+${lK(e.offset)}`),e.round&&(t=`round(${t})`),t}function UEe(e){return e.c?Fq(`hcl`,e.h,e.c,e.l):e.h||e.s?Fq(`hsl`,e.h,e.s,e.l):e.l||e.a?Fq(`lab`,e.l,e.a,e.b):e.r||e.g||e.b?Fq(`rgb`,e.r,e.g,e.b):null}function WEe(e){let t=[e.start,e.stop,e.count].map(e=>e==null?null:W(e));for(;t.length&&Mh(t)==null;)t.pop();return t.unshift(Pq(e.gradient)),`gradient(${t.join(`,`)})`}function lK(e){return Dh(e)?`(`+cK(e)+`)`:e}function uK(e){return dK(Dh(e)?e:{datum:e})}function dK(e){let t,n,r;if(e.signal)t=`datum`,r=e.signal;else if(e.group||e.parent){for(n=Math.max(1,e.level||1),t=`item`;n-->0;)t+=`.mark.group`;e.parent?(r=e.parent,t+=`.datum`):r=e.group}else e.datum?(t=`datum`,r=e.datum):V(`Invalid field reference: `+W(e));return e.signal||(r=xg(r)?mh(r).map(W).join(`][`):dK(r)),t+`[`+r+`]`}function GEe(e,t){let n=Pq(e.scale);return e.range==null?(t!==void 0&&(t=`_scale(${n}, ${t})`),e.band&&(t=(t?t+`+`:``)+`_bandwidth(${n})`+(+e.band==1?``:`*`+lK(e.band)),e.extra&&(t=`(datum.extra ? _scale(${n}, datum.extra.value) : ${t})`)),t??=`0`):t=`lerp(_range(${n}), ${+e.range})`,t}function KEe(e){let t=``;return e.forEach(e=>{let n=cK(e);t+=e.test?`(${e.test})?${n}:`:n}),Mh(t)===`:`&&(t+=`null`),t}function fK(e,t,n,r,i,a){let o={};a||={},a.encoders={$encode:o},e=HEe(e,t,n,r,i.config);for(let n in e)o[n]=qEe(e[n],t,a,i);return a}function qEe(e,t,n,r){let i={},a={};for(let t in e)e[t]!=null&&(i[t]=YEe(JEe(e[t]),r,n,a));return{$expr:{marktype:t,channels:i},$fields:Object.keys(a),$output:Object.keys(e)}}function JEe(e){return H(e)?KEe(e):cK(e)}function YEe(e,t,n,r){let i=_W(e,t);return i.$fields.forEach(e=>r[e]=1),ug(n,i.$params),i.$expr}function pK(e,t){V(e+` for "outer" push: `+W(t))}function mK(e,t){let n=e.name;if(e.push===Iq)t.signals[n]||pK(`No prior signal definition`,n),Lq.forEach(t=>{e[t]!==void 0&&pK(`Invalid property `,t)});else{let r=t.addSignal(n,e.value);e.react===!1&&(r.react=!1),e.bind&&t.addBinding(n,e.bind)}}function hK(e,t,n,r){this.id=-1,this.type=e,this.value=t,this.params=n,r&&(this.parent=r)}function gK(e,t,n,r){return new hK(e,t,n,r)}function _K(e,t){return gK(`operator`,e,t)}function vK(e){let t={$ref:e.id};return e.id<0&&(e.refs=e.refs||[]).push(t),t}function yK(e,t){return t?{$field:e,$name:t}:{$field:e}}function bK(e,t){return{$compare:e,$order:t}}function XEe(e,t){let n={$key:e};return t&&(n.$flat=!0),n}function ZEe(e){return Dh(e)?(e.order===Bq?`-`:`+`)+xK(e.op,e.field):``}function xK(e,t){return(e&&e.signal?`$`+e.signal:e||``)+(e&&t?`_`:``)+(t&&t.signal?`$`+t.signal:t?.replace(/\W+/g,`_`).replace(/^_+|_+$/g,``)||``)}function SK(e){return e&&e.signal}function QEe(e){return e&&e.expr}function CK(e){if(SK(e))return!0;if(Dh(e)){for(let t in e)if(CK(e[t]))return!0}return!1}function wK(e,t){return e??t}function TK(e){return e&&e.signal||e}function EK(e,t){return(e.merge?eDe:e.stream?tDe:e.type?nDe:V(`Invalid stream specification: `+W(e)))(e,t)}function $Ee(e){return e===Vq?Hq:e||Hq}function eDe(e,t){let n=DK({merge:e.merge.map(e=>EK(e,t))},e,t);return t.addStream(n).id}function tDe(e,t){let n=DK({stream:EK(e.stream,t)},e,t);return t.addStream(n).id}function nDe(e,t){let n;e.type===Uq?(n=t.event(Uq,e.throttle),e={between:e.between,filter:e.filter}):n=t.event($Ee(e.source),e.type);let r=DK({stream:n},e,t);return Object.keys(r).length===1?n:t.addStream(r).id}function DK(e,t,n){let r=t.between;return r&&(r.length!==2&&V(`Stream "between" parameter must have 2 entries: `+W(t)),e.between=[EK(r[0],n),EK(r[1],n)]),r=t.filter?[].concat(t.filter):[],(t.marktype||t.markname||t.markrole)&&r.push(rDe(t.marktype,t.markname,t.markrole)),t.source===Vq&&r.push(`inScope(event.item)`),r.length&&(e.filter=_W(`(`+r.join(`)&&(`)+`)`,n).$expr),(r=t.throttle)!=null&&(e.throttle=+r),(r=t.debounce)!=null&&(e.debounce=+r),t.consume&&(e.consume=!0),e}function rDe(e,t,n){return`event.item`+(e&&e!==`*`?`&&event.item.mark.marktype==='`+e+`'`:``)+(n?`&&event.item.mark.role==='`+n+`'`:``)+(t?`&&event.item.mark.name==='`+t+`'`:``)}function iDe(e,t,n){let r=e.encode,i={target:n},a=e.events,o=e.update,s=[];a||V(`Signal update missing events specification.`),xg(a)&&(a=zG(a,t.isSubscope()?Vq:Hq)),a=ng(a).filter(e=>e.signal||e.scale?(s.push(e),0):1),s.length>1&&(s=[oDe(s)]),a.length&&s.push(a.length>1?{merge:a}:a[0]),r!=null&&(o&&V(`Signal encode and update are mutually exclusive.`),o=`encode(item(),`+W(r)+`)`),i.update=xg(o)?_W(o,t):o.expr==null?o.value==null?o.signal==null?V(`Invalid signal update specification.`):{$expr:Wq,$params:{$value:t.signalRef(o.signal)}}:o.value:_W(o.expr,t),e.force&&(i.options={force:!0}),s.forEach(e=>t.addUpdate(ug(aDe(e,t),i)))}function aDe(e,t){return{source:e.signal?t.signalRef(e.signal):e.scale?t.scaleRef(e.scale):EK(e,t)}}function oDe(e){return{signal:`[`+e.map(e=>e.scale?`scale("`+e.scale+`")`:e.signal)+`]`}}function sDe(e,t){let n=t.getSignal(e.name),r=e.update;e.init&&(r?V(`Signals can not include both init and update expressions.`):(r=e.init,n.initonly=!0)),r&&(r=_W(r,t),n.update=r.$expr,n.params=r.$params),e.on&&e.on.forEach(e=>iDe(e,t,n.id))}function cDe(e,t){let n=e.type||`linear`;dpe(n)||V(`Unrecognized scale type: `+W(n)),t.addScale(e.name,{type:n,domain:void 0})}function lDe(e,t){let n=t.getScale(e.name).params,r;for(r in n.domain=jK(e.domain,e,t),e.range!=null&&(n.range=NK(e,t,n)),e.interpolate!=null&&yDe(e.interpolate,n),e.nice!=null&&(n.nice=vDe(e.nice,t)),e.bins!=null&&(n.bins=_De(e.bins,t)),e)fg(n,r)||r===`name`||(n[r]=OK(e[r],t))}function OK(e,t){return Dh(e)?e.signal?t.signalRef(e.signal):V(`Unsupported object: `+W(e)):e}function kK(e,t){return e.signal?t.signalRef(e.signal):e.map(e=>OK(e,t))}function AK(e){V(`Can not find data set: `+W(e))}function jK(e,t,n){if(!e){(t.domainMin!=null||t.domainMax!=null)&&V(`No scale domain defined for domainMin/domainMax to override.`);return}return e.signal?n.signalRef(e.signal):(H(e)?uDe:e.fields?fDe:dDe)(e,t,n)}function uDe(e,t,n){return e.map(e=>OK(e,n))}function dDe(e,t,n){let r=n.getData(e.data);return r||AK(e.data),qD(t.type)?r.valuesRef(n,e.field,MK(e.sort,!1)):mpe(t.type)?r.domainRef(n,e.field):r.extentRef(n,e.field)}function fDe(e,t,n){let r=e.data,i=e.fields.reduce((e,t)=>(t=xg(t)?{data:r,field:t}:H(t)||t.signal?pDe(t,n):t,e.push(t),e),[]);return(qD(t.type)?mDe:mpe(t.type)?hDe:gDe)(e,n,i)}function pDe(e,t){let n=`_:vega:_`+bJ++,r=Yq({});if(H(e))r.value={$ingest:e};else if(e.signal){let i=`setdata(`+W(n)+`,`+e.signal+`)`;r.params.input=t.signalRef(i)}return t.addDataPipeline(n,[r,gJ({})]),{data:n,field:`data`}}function mDe(e,t,n){let r=MK(e.sort,!0),i,a,o=n.map(e=>{let n=t.getData(e.data);return n||AK(e.data),n.countsRef(t,e.field,r)}),s={groupby:Rq,pulse:o};r&&(i=r.op||`count`,a=r.field?xK(i,r.field):`count`,s.ops=[xJ[i]],s.fields=[t.fieldRef(a)],s.as=[a]),i=t.add(Kq(s));let c=t.add(Yq({pulse:vK(i)}));return a=t.add(yJ({field:Rq,sort:t.sortRef(r),pulse:vK(c)})),vK(a)}function MK(e,t){return e&&(!e.field&&!e.op?Dh(e)?e.field=`key`:e={field:`key`}:!e.field&&e.op!==`count`?V(`No field provided for sort aggregate op: `+e.op):t&&e.field&&e.op&&!xJ[e.op]&&V(`Multiple domain scales can not be sorted using `+e.op)),e}function hDe(e,t,n){let r=n.map(e=>{let n=t.getData(e.data);return n||AK(e.data),n.domainRef(t,e.field)});return vK(t.add(sJ({values:r})))}function gDe(e,t,n){let r=n.map(e=>{let n=t.getData(e.data);return n||AK(e.data),n.extentRef(t,e.field)});return vK(t.add(oJ({extents:r})))}function _De(e,t){return e.signal||H(e)?kK(e,t):t.objectProperty(e)}function vDe(e,t){return e.signal?t.signalRef(e.signal):Dh(e)?{interval:OK(e.interval),step:OK(e.step)}:OK(e)}function yDe(e,t){t.interpolate=OK(e.type||e),e.gamma!=null&&(t.interpolateGamma=OK(e.gamma))}function NK(e,t,n){let r=t.config.range,i=e.range;if(i.signal)return t.signalRef(i.signal);if(xg(i)){if(r&&fg(r,i))return e=ug({},e,{range:r[i]}),NK(e,t,n);i===`width`?i=[0,{signal:`width`}]:i===`height`?i=qD(e.type)?[0,{signal:`height`}]:[{signal:`height`},0]:V(`Unrecognized scale range value: `+W(i))}else if(i.scheme){n.scheme=H(i.scheme)?kK(i.scheme,t):OK(i.scheme,t),i.extent&&(n.schemeExtent=kK(i.extent,t)),i.count&&(n.schemeCount=OK(i.count,t));return}else if(i.step){n.rangeStep=OK(i.step,t);return}else if(qD(e.type)&&!H(i))return jK(i,e,t);else H(i)||V(`Unsupported range type: `+W(i));return i.map(e=>(H(e)?kK:OK)(e,t))}function bDe(e,t){let n=t.config.projection||{},r={};for(let n in e)n!==`name`&&(r[n]=PK(e[n],n,t));for(let e in n)r[e]??(r[e]=PK(n[e],e,t));t.addProjection(e.name,r)}function PK(e,t,n){return H(e)?e.map(e=>PK(e,t,n)):Dh(e)?e.signal?n.signalRef(e.signal):t===`fit`?e:V(`Unsupported parameter object: `+W(e)):e}function FK(e){return e.type=JJ,e.interactive=e.interactive||!1,e}function IK(e,t){let n=(n,r)=>wK(e[n],wK(t[n],r));return n.isVertical=n=>DJ===wK(e.direction,t.direction||(n?t.symbolDirection:t.gradientDirection)),n.gradientLength=()=>wK(e.gradientLength,t.gradientLength||t.gradientWidth),n.gradientThickness=()=>wK(e.gradientThickness,t.gradientThickness||t.gradientHeight),n.entryColumns=()=>wK(e.columns,wK(t.columns,+n.isVertical(!0))),n}function LK(e,t){let n=t&&(t.update&&t.update[e]||t.enter&&t.enter[e]);return n&&n.signal?n:n?n.value:null}function xDe(e,t,n){let r=t.config.style[n];return r&&r[e]}function RK(e,t,n){return`item.anchor === '${OJ}' ? ${e} : item.anchor === '${AJ}' ? ${t} : ${n}`}function SDe(e){let t=e(`tickBand`),n=e(`tickOffset`),r,i;return t?t.signal?(r={signal:`(${t.signal}) === 'extent' ? 1 : 0.5`},i={signal:`(${t.signal}) === 'extent'`},Dh(n)||(n={signal:`(${t.signal}) === 'extent' ? 0 : ${n}`})):t===`extent`?(r=1,i=!0,n=0):(r=.5,i=!1):(r=e(`bandPosition`),i=e(`tickExtra`)),{extra:i,band:r,offset:n}}function zK(e,t){return t?e?Dh(e)?Object.assign({},e,{offset:zK(e.offset,t)}):{value:e,offset:t}:t:e}function BK(e,t){return t?(e.name=t.name,e.style=t.style||e.style,e.interactive=!!t.interactive,e.encode=aK(e.encode,t,GJ)):e.interactive=!1,e}function CDe(e,t,n,r){let i=IK(e,n),a=i.isVertical(),o=i.gradientThickness(),s=i.gradientLength(),c,l,u,d,f;a?(l=[0,1],u=[0,0],d=o,f=s):(l=[0,0],u=[1,0],d=s,f=o);let p={enter:c={opacity:KJ,x:KJ,y:KJ,width:hq(d),height:hq(f)},update:ug({},c,{opacity:qJ,fill:{gradient:t,start:l,stop:u}}),exit:{opacity:KJ}};return iK(p,{stroke:i(`gradientStrokeColor`),strokeWidth:i(`gradientStrokeWidth`)},{opacity:i(`gradientOpacity`)}),BK({type:YJ,role:Dq,encode:p},r)}function wDe(e,t,n,r,i){let a=IK(e,n),o=a.isVertical(),s=a.gradientThickness(),c=a.gradientLength(),l,u,d,f,p=``;o?(l=`y`,d=`y2`,u=`x`,f=`width`,p=`1-`):(l=`x`,d=`x2`,u=`y`,f=`height`);let m={opacity:KJ,fill:{scale:t,field:FJ}};m[l]={signal:p+`datum.perc`,mult:c},m[u]=KJ,m[d]={signal:p+`datum.perc2`,mult:c},m[f]=hq(s);let h={enter:m,update:ug({},m,{opacity:qJ}),exit:{opacity:KJ}};return iK(h,{stroke:a(`gradientStrokeColor`),strokeWidth:a(`gradientStrokeWidth`)},{opacity:a(`gradientOpacity`)}),BK({type:YJ,role:Tq,key:FJ,from:i,encode:h},r)}function VK(e,t,n,r){let i=IK(e,t),a=i.isVertical(),o=hq(i.gradientThickness()),s=i.gradientLength(),c=i(`labelOverlap`),l,u,d,f,p=``,m={enter:l={opacity:KJ},update:u={opacity:qJ,text:{field:MJ}},exit:{opacity:KJ}};return iK(m,{fill:i(`labelColor`),fillOpacity:i(`labelOpacity`),font:i(`labelFont`),fontSize:i(`labelFontSize`),fontStyle:i(`labelFontStyle`),fontWeight:i(`labelFontWeight`),limit:wK(e.labelLimit,t.gradientLabelLimit)}),a?(l.align={value:`left`},l.baseline=u.baseline={signal:tY},d=`y`,f=`x`,p=`1-`):(l.align=u.align={signal:eY},l.baseline={value:`top`},d=`x`,f=`y`),l[d]=u[d]={signal:p+`datum.perc`,mult:s},l[f]=u[f]=o,o.offset=wK(e.labelOffset,t.gradientLabelOffset)||0,c=c?{separation:i(`labelSeparation`),method:c,order:`datum.index`}:void 0,BK({type:QJ,role:Oq,style:IJ,key:FJ,from:r,encode:m,overlap:c},n)}function TDe(e,t,n,r,i){let a=IK(e,t),o=n.entries,s=!!(o&&o.interactive),c=o?o.name:void 0,l=a(`clipHeight`),u=a(`symbolOffset`),d={data:`value`},f=`(${i}) ? datum.${NJ} : datum.${UJ}`,p=l?hq(l):{field:UJ},m=`datum.${jJ}`,h=`max(1, ${i})`,g,_,v,y,b;p.mult=.5,g={enter:_={opacity:KJ,x:{signal:f,mult:.5,offset:u},y:p},update:v={opacity:qJ,x:_.x,y:_.y},exit:{opacity:KJ}};let x=null,S=null;e.fill||(x=t.symbolBaseFillColor,S=t.symbolBaseStrokeColor),iK(g,{fill:a(`symbolFillColor`,x),shape:a(`symbolType`),size:a(`symbolSize`),stroke:a(`symbolStrokeColor`,S),strokeDash:a(`symbolDash`),strokeDashOffset:a(`symbolDashOffset`),strokeWidth:a(`symbolStrokeWidth`)},{opacity:a(`symbolOpacity`)}),WJ.forEach(t=>{e[t]&&(v[t]=_[t]={scale:e[t],field:FJ})});let C=BK({type:ZJ,role:kq,key:FJ,from:d,clip:l?!0:void 0,encode:g},n.symbols),w=hq(u);w.offset=a(`labelOffset`),g={enter:_={opacity:KJ,x:{signal:f,offset:w},y:p},update:v={opacity:qJ,text:{field:MJ},x:_.x,y:_.y},exit:{opacity:KJ}},iK(g,{align:a(`labelAlign`),baseline:a(`labelBaseline`),fill:a(`labelColor`),fillOpacity:a(`labelOpacity`),font:a(`labelFont`),fontSize:a(`labelFontSize`),fontStyle:a(`labelFontStyle`),fontWeight:a(`labelFontWeight`),limit:a(`labelLimit`)});let T=BK({type:QJ,role:Oq,style:IJ,key:FJ,from:d,encode:g},n.labels);return g={enter:{noBound:{value:!l},width:KJ,height:l?hq(l):KJ,opacity:KJ},exit:{opacity:KJ},update:v={opacity:qJ,row:{signal:null},column:{signal:null}}},a.isVertical(!0)?(y=`ceil(item.mark.items.length / ${h})`,v.row.signal=`${m}%${y}`,v.column.signal=`floor(${m} / ${y})`,b={field:[`row`,m]}):(v.row.signal=`floor(${m} / ${h})`,v.column.signal=`${m} % ${h}`,b={field:m}),v.column.signal=`(${i})?${v.column.signal}:${m}`,r={facet:{data:r,name:`value`,groupby:jJ}},FK({role:_q,from:r,encode:aK(g,o,GJ),marks:[C,T],name:c,interactive:s,sort:b})}function EDe(e,t){let n=IK(e,t);return{align:n(`gridAlign`),columns:n.entryColumns(),center:{row:!0,column:!1},padding:{row:n(`rowPadding`),column:n(`columnPadding`)}}}function DDe(e,t,n,r){let i=IK(e,t),a={enter:{opacity:KJ},update:{opacity:qJ,x:{field:{group:`padding`}},y:{field:{group:`padding`}}},exit:{opacity:KJ}};return iK(a,{orient:i(`titleOrient`),_anchor:i(`titleAnchor`),anchor:{signal:cY},angle:{signal:lY},align:{signal:sY},baseline:{signal:uY},text:e.title,fill:i(`titleColor`),fillOpacity:i(`titleOpacity`),font:i(`titleFont`),fontSize:i(`titleFontSize`),fontStyle:i(`titleFontStyle`),fontWeight:i(`titleFontWeight`),limit:i(`titleLimit`),lineHeight:i(`titleLineHeight`)},{align:i(`titleAlign`),baseline:i(`titleBaseline`)}),BK({type:QJ,role:Aq,style:LJ,from:r,encode:a},n)}function ODe(e,t){let n;return Dh(e)&&(e.signal?n=e.signal:e.path?n=`pathShape(`+HK(e.path)+`)`:e.sphere&&(n=`geoShape(`+HK(e.sphere)+`, {type: "Sphere"})`)),n?t.signalRef(n):!!e}function HK(e){return Dh(e)&&e.signal?e.signal:W(e)}function UK(e){let t=e.role||``;return t.startsWith(`axis`)||t.startsWith(`legend`)||t.startsWith(`title`)?t:e.type===JJ?_q:t||`mark`}function kDe(e){return{marktype:e.type,name:e.name||void 0,role:e.role||UK(e),zindex:+e.zindex||void 0,aria:e.aria,description:e.description}}function ADe(e,t){return e&&e.signal?t.signalRef(e.signal):e!==!1}function WK(e,t){let n=xx(e.type);n||V(`Unrecognized transform type: `+W(e.type));let r=gK(n.type.toLowerCase(),null,GK(n,e,t));return e.signal&&t.addSignal(e.signal,t.proxy(r)),r.metadata=n.metadata||{},r}function GK(e,t,n){let r={},i=e.params.length;for(let a=0;aKK(e,t,n)):KK(e,i,n)}function KK(e,t,n){let r=e.type;if(SK(t))return mY(r)?V(`Expression references can not be signals.`):hY(r)?n.fieldRef(t):gY(r)?n.compareRef(t):n.signalRef(t.signal);{let i=e.expr||hY(r);return i&&dY(t)?n.exprRef(t.expr,t.as):i&&fY(t)?yK(t.field,t.as):mY(r)?_W(t,n):pY(r)?vK(n.getData(t).values):hY(r)?yK(t):gY(r)?n.compareRef(t):t}}function MDe(e,t,n){return xg(t.from)||V(`Lookup "from" parameter must be a string literal.`),n.getData(t.from).lookupRef(n,t.key)}function NDe(e,t,n){let r=t[e.name];return e.array?(H(r)||V(`Expected an array of sub-parameters. Instead: `+W(r)),r.map(t=>qK(e,t,n))):qK(e,r,n)}function qK(e,t,n){let r=e.params.length,i;for(let n=0;ne??`null`).join(`,`)+`),0)`,t);c.update=l.$expr,c.params=l.$params}function eq(e,t){let n=UK(e),r=e.type===JJ,i=e.from&&e.from.facet,a=e.overlap,o=e.layout||n===`scope`||n===`frame`,s,c,l,u,d,f,p,m=n===`mark`||o||i,h=PDe(e.from,r,t);c=t.add(Zq({key:h.key||(e.key?yK(e.key):void 0),pulse:h.pulse,clean:!r}));let g=vK(c);c=l=t.add(Yq({pulse:g})),c=t.add(aJ({markdef:kDe(e),interactive:ADe(e.interactive,t),clip:ODe(e.clip,t),context:{$context:!0},groups:t.lookup(),parent:t.signals.parent?t.signalRef(`parent`):null,index:t.markpath(),pulse:vK(c)}));let _=vK(c);c=u=t.add(Qq(fK(e.encode,e.type,n,e.style,t,{mod:!1,pulse:_}))),c.params.parent=t.encode(),e.transform&&e.transform.forEach(e=>{let n=WK(e,t),r=n.metadata;(r.generates||r.changes)&&V(`Mark transforms should not generate new data.`),r.nomod||(u.params.mod=!0),n.params.pulse=vK(c),t.add(c=n)}),e.sort&&(c=t.add(_J({sort:t.compareRef(e.sort),pulse:vK(c)})));let v=vK(c);(i||o)&&(o=t.add(vJ({layout:t.objectProperty(e.layout),legends:t.legends,mark:_,pulse:v})),f=vK(o));let y=t.add(Jq({mark:_,pulse:f||v}));p=vK(y),r&&(m&&(s=t.operators,s.pop(),o&&s.pop()),t.pushState(v,f||p,g),i?FDe(e,t,h):m?IDe(e,t,h):t.parse(e),t.popState(),m&&(o&&s.push(o),s.push(y))),a&&(p=LDe(a,p,t));let b=t.add(mJ({pulse:p})),x=t.add(gJ({pulse:vK(b)},void 0,t.parent()));e.name!=null&&(d=e.name,t.addData(d,new YK(t,l,b,x)),e.on&&e.on.forEach(e=>{(e.insert||e.remove||e.toggle)&&V(`Marks only support modify triggers.`),$K(e,t,d)}))}function LDe(e,t,n){let r=e.method,i=e.bound,a=e.separation,o={separation:SK(a)?n.signalRef(a.signal):a,method:SK(r)?n.signalRef(r.signal):r,pulse:t};if(e.order&&(o.sort=n.compareRef({field:e.order})),i){let e=i.tolerance;o.boundTolerance=SK(e)?n.signalRef(e.signal):+e,o.boundScale=n.scaleRef(i.scale),o.boundOrient=i.orient}return vK(n.add(cJ(o)))}function RDe(e,t){let n=t.config.legend,r=e.encode||{},i=IK(e,n),a=r.legend||{},o=a.name||void 0,s=a.interactive,c=a.style,l={},u=0,d,f,p;WJ.forEach(t=>e[t]?(l[t]=e[t],u||=e[t]):0),u||V(`Missing valid scale for legend.`);let m=zDe(e,t.scaleType(u)),h={title:e.title!=null,scales:l,type:m,vgrad:m!==`symbol`&&i.isVertical()},g=vK(t.add(Yq(null,[h]))),_={enter:{x:{value:0},y:{value:0}}},v=vK(t.add(rJ(f={type:m,scale:t.scaleRef(u),count:t.objectProperty(i(`tickCount`)),limit:t.property(i(`symbolLimit`)),values:t.objectProperty(e.values),minstep:t.property(e.tickMinStep),formatType:t.property(e.formatType),formatSpecifier:t.property(e.format)})));return m===VJ?(p=[CDe(e,u,n,r.gradient),VK(e,n,r.labels,v)],f.count=f.count||t.signalRef(`max(2,2*floor((${TK(i.gradientLength())})/100))`)):m===HJ?p=[wDe(e,u,n,r.gradient,v),VK(e,n,r.labels,v)]:(d=EDe(e,n),p=[TDe(e,n,r,v,TK(d.columns))],f.size=HDe(e,t,p[0].marks)),p=[FK({role:Eq,from:g,encode:_,marks:p,layout:d,interactive:s})],h.title&&p.push(DDe(e,n,r.title,g)),eq(FK({role:wq,from:g,encode:aK(VDe(i,e,n),a,GJ),marks:p,aria:i(`aria`),description:i(`description`),zindex:i(`zindex`),name:o,interactive:s,style:c}),t)}function zDe(e,t){let n=e.type||BJ;return!e.type&&BDe(e)===1&&(e.fill||e.stroke)&&(n=KD(t)?VJ:JD(t)?HJ:BJ),n===VJ?JD(t)?HJ:VJ:n}function BDe(e){return WJ.reduce((t,n)=>t+ +!!e[n],0)}function VDe(e,t,n){let r={enter:{},update:{}};return iK(r,{orient:e(`orient`),offset:e(`offset`),padding:e(`padding`),titlePadding:e(`titlePadding`),cornerRadius:e(`cornerRadius`),fill:e(`fillColor`),stroke:e(`strokeColor`),strokeWidth:n.strokeWidth,strokeDash:n.strokeDash,x:e(`legendX`),y:e(`legendY`),format:t.format,formatType:t.formatType}),r}function HDe(e,t,n){return _W(`max(ceil(sqrt(${TK(tq(`size`,e,n))})+${TK(tq(`strokeWidth`,e,n))}),${TK(UDe(n[1].encode,t,IJ))})`,t)}function tq(e,t,n){return t[e]?`scale("${t[e]}",datum)`:LK(e,n[0].encode)}function UDe(e,t,n){return LK(`fontSize`,e)||xDe(`fontSize`,t,n)}function WDe(e,t){e=xg(e)?{text:e}:e;let n=IK(e,t.config.title),r=e.encode||{},i=r.group||{},a=i.name||void 0,o=i.interactive,s=i.style,c=[],l=vK(t.add(Yq(null,[{}])));return c.push(qDe(e,n,GDe(e),l)),e.subtitle&&c.push(JDe(e,n,r.subtitle,l)),eq(FK({role:jq,from:l,encode:KDe(n,i),marks:c,aria:n(`aria`),description:n(`description`),zindex:n(`zindex`),name:a,interactive:o,style:s}),t)}function GDe(e){let t=e.encode;return t&&t.title||ug({name:e.name,interactive:e.interactive,style:e.style},t)}function KDe(e,t){let n={enter:{},update:{}};return iK(n,{orient:e(`orient`),anchor:e(`anchor`),align:{signal:$J},angle:{signal:_Y},limit:e(`limit`),frame:e(`frame`),offset:e(`offset`)||0,padding:e(`subtitlePadding`)}),aK(n,t,GJ)}function qDe(e,t,n,r){let i={value:0},a=e.text,o={enter:{opacity:i},update:{opacity:{value:1}},exit:{opacity:i}};return iK(o,{text:a,align:{signal:`item.mark.group.align`},angle:{signal:`item.mark.group.angle`},limit:{signal:`item.mark.group.limit`},baseline:`top`,dx:t(`dx`),dy:t(`dy`),fill:t(`color`),font:t(`font`),fontSize:t(`fontSize`),fontStyle:t(`fontStyle`),fontWeight:t(`fontWeight`),lineHeight:t(`lineHeight`)},{align:t(`align`),angle:t(`angle`),baseline:t(`baseline`)}),BK({type:QJ,role:Mq,style:RJ,from:r,encode:o},n)}function JDe(e,t,n,r){let i={value:0},a=e.subtitle,o={enter:{opacity:i},update:{opacity:{value:1}},exit:{opacity:i}};return iK(o,{text:a,align:{signal:`item.mark.group.align`},angle:{signal:`item.mark.group.angle`},limit:{signal:`item.mark.group.limit`},baseline:`top`,dx:t(`dx`),dy:t(`dy`),fill:t(`subtitleColor`),font:t(`subtitleFont`),fontSize:t(`subtitleFontSize`),fontStyle:t(`subtitleFontStyle`),fontWeight:t(`subtitleFontWeight`),lineHeight:t(`subtitleLineHeight`)},{align:t(`align`),angle:t(`angle`),baseline:t(`baseline`)}),BK({type:QJ,role:Nq,style:zJ,from:r,encode:o},n)}function YDe(e,t){let n=[];e.transform&&e.transform.forEach(e=>{n.push(WK(e,t))}),e.on&&e.on.forEach(n=>{$K(n,t,e.name)}),t.addDataPipeline(e.name,XDe(e,t,n))}function XDe(e,t,n){let r=[],i=null,a=!1,o=!1,s,c,l,u,d;for(e.values?SK(e.values)||CK(e.format)?(r.push(rq(t,e)),r.push(i=nq())):r.push(i=nq({$ingest:e.values,$format:e.format})):e.url?CK(e.url)||CK(e.format)?(r.push(rq(t,e)),r.push(i=nq())):r.push(i=nq({$request:e.url,$format:e.format})):e.source&&(i=s=ng(e.source).map(e=>vK(t.getData(e).output)),r.push(null)),c=0,l=n.length;ce==null?!oK(t,r):(n.update[t]=FY(hq(e),n.update[t]),!1),a=i(e(`titleX`),`x`),o=i(e(`titleY`),`y`);n.enter.auto=o===a?hq(o):bY(t,hq(o),hq(a))}function aOe(e,t){let n=ZDe(e,t),r=e.encode||{},i=r.axis||{},a=i.name||void 0,o=i.interactive,s=i.style,c=IK(e,n),l=SDe(c),u={scale:e.scale,ticks:!!c(`ticks`),labels:!!c(`labels`),grid:!!c(`grid`),domain:!!c(`domain`),title:e.title!=null},d=vK(t.add(Yq({},[u]))),f=vK(t.add(qq({scale:t.scaleRef(e.scale),extra:t.property(l.extra),count:t.objectProperty(e.tickCount),values:t.objectProperty(e.values),minstep:t.property(e.tickMinStep),formatType:t.property(e.formatType),formatSpecifier:t.property(e.format)}))),p=[],m;return u.grid&&p.push($De(e,n,r.grid,f,l)),u.ticks&&(m=c(`tickSize`),p.push(tOe(e,n,r.ticks,f,m,l))),u.labels&&(m=u.ticks?m:0,p.push(nOe(e,n,r.labels,f,m,l))),u.domain&&p.push(QDe(e,n,r.domain,d)),u.title&&p.push(rOe(e,n,r.title,d)),eq(FK({role:vq,from:d,encode:aK(oOe(c,e),i,GJ),marks:p,aria:c(`aria`),description:c(`description`),zindex:c(`zindex`),name:a,interactive:o,style:s}),t)}function oOe(e,t){let n={enter:{},update:{}};return iK(n,{orient:e(`orient`),offset:e(`offset`)||0,position:wK(t.position,0),titlePadding:e(`titlePadding`),minExtent:e(`minExtent`),maxExtent:e(`maxExtent`),range:{signal:`abs(span(range("${t.scale}")))`},translate:e(`translate`),format:t.format,formatType:t.formatType}),n}function cq(e,t,n){let r=ng(e.signals),i=ng(e.scales);return n||r.forEach(e=>mK(e,t)),ng(e.projections).forEach(e=>bDe(e,t)),i.forEach(e=>cDe(e,t)),ng(e.data).forEach(e=>YDe(e,t)),i.forEach(e=>lDe(e,t)),(n||r).forEach(e=>sDe(e,t)),ng(e.axes).forEach(e=>aOe(e,t)),ng(e.marks).forEach(e=>eq(e,t)),ng(e.legends).forEach(e=>RDe(e,t)),e.title&&WDe(e.title,t),t.parseLambdas(),t}function sOe(e,t){let n=t.config,r=vK(t.root=t.add(_K())),i=cOe(e,n);i.forEach(e=>mK(e,t)),t.description=e.description||n.description,t.eventConfig=n.events,t.legends=t.objectProperty(n.legend&&n.legend.layout),t.locale=n.locale;let a=t.add(Yq()),o=t.add(Qq(fK(IY(e.encode),JJ,gq,e.style,t,{pulse:vK(a)}))),s=t.add(vJ({layout:t.objectProperty(e.layout),legends:t.legends,autosize:t.signalRef(`autosize`),mark:r,pulse:vK(o)}));t.operators.pop(),t.pushState(vK(o),vK(s),null),cq(e,t,i),t.operators.push(s);let c=t.add(Jq({mark:r,pulse:vK(s)}));return c=t.add(mJ({pulse:vK(c)})),c=t.add(gJ({pulse:vK(c)})),t.addData(`root`,new YK(t,a,a,c)),t}function lq(e,t){return t&&t.signal?{name:e,update:t.signal}:{name:e,value:t}}function cOe(e,t){let n=n=>wK(e[n],t[n]),r=[lq(`background`,n(`background`)),lq(`autosize`,BEe(n(`autosize`))),lq(`padding`,VEe(n(`padding`))),lq(`width`,n(`width`)||0),lq(`height`,n(`height`)||0)],i=r.reduce((e,t)=>(e[t.name]=t,e),{}),a={};return ng(e.signals).forEach(e=>{fg(i,e.name)?e=ug(i[e.name],e):r.push(e),a[e.name]=e}),ng(t.signals).forEach(e=>{!fg(a,e.name)&&!fg(i,e.name)&&r.push(e)}),r}function uq(e,t){this.config=e||{},this.options=t||{},this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.eventConfig=null,this.locale=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._lookup=[],this._markpath=[]}function dq(e){this.config=e.config,this.options=e.options,this.legends=e.legends,this.field=Object.create(e.field),this.signals=Object.create(e.signals),this.lambdas=Object.create(e.lambdas),this.scales=Object.create(e.scales),this.events=Object.create(e.events),this.data=Object.create(e.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++e._nextsub[0],this._nextsub=e._nextsub,this._parent=e._parent.slice(),this._encode=e._encode.slice(),this._lookup=e._lookup.slice(),this._markpath=e._markpath}function fq(e){return(H(e)?lOe:uOe)(e)}function lOe(e){let t=e.length,n=`[`;for(let r=0;r0?`,`:``)+(Dh(t)?t.signal||fq(t):W(t))}return n+`]`}function uOe(e){let t=`{`,n=0,r,i;for(r in e)i=e[r],t+=(++n>1?`,`:``)+W(r)+`:`+(Dh(i)?i.signal||fq(i):W(i));return t+`}`}function dOe(){let e=`sans-serif`,t=`#4c78a8`,n=`#000`,r=`#888`,i=`#ddd`;return{description:`Vega visualization`,padding:0,autosize:`pad`,background:null,events:{defaults:{allow:[`wheel`]}},group:null,mark:null,arc:{fill:t},area:{fill:t},image:null,line:{stroke:t,strokeWidth:2},path:{stroke:t},rect:{fill:t},rule:{stroke:n},shape:{stroke:t},symbol:{fill:t,size:64},text:{fill:n,font:e,fontSize:11},trail:{fill:t,size:2},style:{"guide-label":{fill:n,font:e,fontSize:10},"guide-title":{fill:n,font:e,fontSize:11,fontWeight:`bold`},"group-title":{fill:n,font:e,fontSize:13,fontWeight:`bold`},"group-subtitle":{fill:n,font:e,fontSize:12},point:{size:30,strokeWidth:2,shape:`circle`},circle:{size:30,strokeWidth:2},square:{size:30,strokeWidth:2,shape:`square`},cell:{fill:`transparent`,stroke:i},view:{fill:`transparent`}},title:{orient:`top`,anchor:`middle`,offset:4,subtitlePadding:3},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domain:!0,domainWidth:1,domainColor:r,grid:!1,gridWidth:1,gridColor:i,labels:!0,labelAngle:0,labelLimit:180,labelOffset:0,labelPadding:2,ticks:!0,tickColor:r,tickOffset:0,tickRound:!0,tickSize:5,tickWidth:1,titlePadding:4},axisBand:{tickOffset:-.5},projection:{type:`mercator`},legend:{orient:`right`,padding:0,gridAlign:`each`,columnPadding:10,rowPadding:2,symbolDirection:`vertical`,gradientDirection:`vertical`,gradientLength:200,gradientThickness:16,gradientStrokeColor:i,gradientStrokeWidth:0,gradientLabelOffset:2,labelAlign:`left`,labelBaseline:`middle`,labelLimit:160,labelOffset:4,labelOverlap:!0,symbolLimit:30,symbolType:`circle`,symbolSize:100,symbolOffset:0,symbolStrokeWidth:1.5,symbolBaseFillColor:`transparent`,symbolBaseStrokeColor:r,titleLimit:180,titleOrient:`top`,titlePadding:5,layout:{offset:18,direction:`horizontal`,left:{direction:`vertical`},right:{direction:`vertical`}}},range:{category:{scheme:`tableau10`},ordinal:{scheme:`blues`},heatmap:{scheme:`yellowgreenblue`},ramp:{scheme:`blues`},diverging:{scheme:`blueorange`,extent:[1,0]},symbol:[`circle`,`square`,`triangle-up`,`cross`,`diamond`,`triangle-right`,`triangle-down`,`triangle-left`]}}}function fOe(e,t,n){return Dh(e)||V(`Input Vega specification must be an object.`),t=kh(dOe(),t,e.config),sOe(e,new uq(t,n)).toRuntime()}var pq,mq,hq,gq,_q,vq,yq,bq,xq,Sq,Cq,wq,Tq,Eq,Dq,Oq,kq,Aq,jq,Mq,Nq,Pq,Fq,Iq,Lq,Rq,zq,Bq,Vq,Hq,Uq,Wq,Gq,Kq,qq,Jq,Yq,Xq,Zq,Qq,$q,eJ,tJ,nJ,rJ,iJ,aJ,oJ,sJ,cJ,lJ,uJ,dJ,fJ,pJ,mJ,hJ,gJ,_J,vJ,yJ,bJ,xJ,SJ,CJ,wJ,TJ,EJ,DJ,OJ,kJ,AJ,jJ,MJ,NJ,PJ,FJ,IJ,LJ,RJ,zJ,BJ,VJ,HJ,UJ,WJ,GJ,KJ,qJ,JJ,YJ,XJ,ZJ,QJ,$J,eY,tY,nY,rY,iY,aY,oY,sY,cY,lY,uY,dY,fY,pY,mY,hY,gY,_Y,vY,yY,bY,xY,SY,CY,wY,TY,EY,DY,OY,kY,AY,jY,MY,NY,PY,FY,IY,pOe=o((()=>{Ag(),RW(),nK(),xO(),Kx(),pq=e=>+e||0,mq=e=>({top:e,bottom:e,left:e,right:e}),hq=e=>Dh(e)&&!H(e)?ug({},e):{value:e},gq=`frame`,_q=`scope`,vq=`axis`,yq=`axis-domain`,bq=`axis-grid`,xq=`axis-label`,Sq=`axis-tick`,Cq=`axis-title`,wq=`legend`,Tq=`legend-band`,Eq=`legend-entry`,Dq=`legend-gradient`,Oq=`legend-label`,kq=`legend-symbol`,Aq=`legend-title`,jq=`title`,Mq=`title-text`,Nq=`title-subtitle`,Pq=e=>xg(e)?W(e):e.signal?`(${e.signal})`:uK(e),Fq=(e,t,n,r)=>`(${e}(${[t,n,r].map(cK).join(`,`)})+'')`,Iq=`outer`,Lq=[`value`,`update`,`init`,`react`,`bind`],Rq=yK(`key`),zq=`ascending`,Bq=`descending`,Vq=`scope`,Hq=`view`,Uq=`timer`,Wq={code:`_.$value`,ast:{type:`Identifier`,value:`value`}},Gq=e=>(t,n,r)=>gK(e,n,t||void 0,r),Kq=Gq(`aggregate`),qq=Gq(`axisticks`),Jq=Gq(`bound`),Yq=Gq(`collect`),Xq=Gq(`compare`),Zq=Gq(`datajoin`),Qq=Gq(`encode`),$q=Gq(`expression`),eJ=Gq(`facet`),tJ=Gq(`field`),nJ=Gq(`key`),rJ=Gq(`legendentries`),iJ=Gq(`load`),aJ=Gq(`mark`),oJ=Gq(`multiextent`),sJ=Gq(`multivalues`),cJ=Gq(`overlap`),lJ=Gq(`params`),uJ=Gq(`prefacet`),dJ=Gq(`projection`),fJ=Gq(`proxy`),pJ=Gq(`relay`),mJ=Gq(`render`),hJ=Gq(`scale`),gJ=Gq(`sieve`),_J=Gq(`sortitems`),vJ=Gq(`viewlayout`),yJ=Gq(`values`),bJ=0,xJ={min:`min`,max:`max`,count:`sum`},SJ=`top`,CJ=`left`,wJ=`right`,TJ=`bottom`,EJ=`center`,DJ=`vertical`,OJ=`start`,kJ=`middle`,AJ=`end`,jJ=`index`,MJ=`label`,NJ=`offset`,PJ=`perc`,FJ=`value`,IJ=`guide-label`,LJ=`guide-title`,RJ=`group-title`,zJ=`group-subtitle`,BJ=`symbol`,VJ=`gradient`,HJ=`discrete`,UJ=`size`,WJ=[UJ,`shape`,`fill`,`stroke`,`strokeWidth`,`strokeDash`,`opacity`],GJ={name:1,style:1,interactive:1},KJ={value:0},qJ={value:1},JJ=`group`,YJ=`rect`,XJ=`rule`,ZJ=`symbol`,QJ=`text`,$J=RK(W(CJ),W(wJ),W(EJ)),eY=`datum.${PJ}<=0?"${CJ}":datum.${PJ}>=1?"${wJ}":"${EJ}"`,tY=`datum.${PJ}<=0?"${TJ}":datum.${PJ}>=1?"${SJ}":"${kJ}"`,nY=`item.orient === "left"`,rY=`item.orient === "right"`,iY=`(${nY} || ${rY})`,aY=`datum.vgrad && ${iY}`,oY=RK(`"top"`,`"bottom"`,`"middle"`),sY=`datum.vgrad && ${rY} ? (${RK(`"right"`,`"left"`,`"center"`)}) : (${iY} && !(datum.vgrad && ${nY})) ? "left" : ${$J}`,cY=`item._anchor || (${iY} ? "middle" : "start")`,lY=`${aY} ? (${nY} ? -90 : 90) : 0`,uY=`${iY} ? (datum.vgrad ? (${rY} ? "bottom" : "top") : ${oY}) : "top"`,dY=e=>e&&e.expr,fY=e=>e&&e.field,pY=e=>e===`data`,mY=e=>e===`expr`,hY=e=>e===`field`,gY=e=>e===`compare`,YK.fromEntries=function(e,t){let n=t.length,r=t[n-1],i=t[n-2],a=t[0],o=null,s=1;for(a&&a.type===`load`&&(a=t[1]),e.add(t[0]);se===TJ||e===SJ,yY=(e,t,n)=>SK(e)?EY(e.signal,t,n):e===CJ||e===SJ?t:n,bY=(e,t,n)=>SK(e)?wY(e.signal,t,n):vY(e)?t:n,xY=(e,t,n)=>SK(e)?TY(e.signal,t,n):vY(e)?n:t,SY=(e,t,n)=>SK(e)?DY(e.signal,t,n):e===SJ?{value:t}:{value:n},CY=(e,t,n)=>SK(e)?OY(e.signal,t,n):e===wJ?{value:t}:{value:n},wY=(e,t,n)=>kY(`${e} === '${SJ}' || ${e} === '${TJ}'`,t,n),TY=(e,t,n)=>kY(`${e} !== '${SJ}' && ${e} !== '${TJ}'`,t,n),EY=(e,t,n)=>jY(`${e} === '${CJ}' || ${e} === '${SJ}'`,t,n),DY=(e,t,n)=>jY(`${e} === '${SJ}'`,t,n),OY=(e,t,n)=>jY(`${e} === '${wJ}'`,t,n),kY=(e,t,n)=>(t=t==null?t:hq(t),n=n==null?n:hq(n),AY(t)&&AY(n)?(t=t?t.signal||W(t.value):null,n=n?n.signal||W(n.value):null,{signal:`${e} ? (${t}) : (${n})`}):[ug({test:e},t)].concat(n||[])),AY=e=>e==null||Object.keys(e).length===1,jY=(e,t,n)=>({signal:`${e} ? (${NY(t)}) : (${NY(n)})`}),MY=(e,t,n,r,i)=>({signal:(r==null?``:`${e} === '${CJ}' ? (${NY(r)}) : `)+(n==null?``:`${e} === '${TJ}' ? (${NY(n)}) : `)+(i==null?``:`${e} === '${wJ}' ? (${NY(i)}) : `)+(t==null?``:`${e} === '${SJ}' ? (${NY(t)}) : `)+`(null)`}),NY=e=>SK(e)?e.signal:e==null?null:W(e),PY=(e,t)=>t===0?0:SK(e)?{signal:`(${e.signal}) * ${t}`}:{value:e*t},FY=(e,t)=>{let n=e.signal;return n&&n.endsWith(`(null)`)?{signal:n.slice(0,-6)+t.signal}:e},IY=e=>aK({enter:{x:{value:0},y:{value:0}},update:{width:{signal:`width`},height:{signal:`height`}}},e),uq.prototype=dq.prototype={parse(e){return cq(e,this)},fork(){return new dq(this)},isSubscope(){return this._subid>0},toRuntime(){return this.finish(),{description:this.description,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings,eventConfig:this.eventConfig,locale:this.locale}},id(){return(this._subid?this._subid+`:`:0)+this._id++},add(e){return this.operators.push(e),e.id=this.id(),e.refs&&=(e.refs.forEach(t=>{t.$ref=e.id}),null),e},proxy(e){let t=e instanceof hK?vK(e):e;return this.add(fJ({value:t}))},addStream(e){return this.streams.push(e),e.id=this.id(),e},addUpdate(e){return this.updates.push(e),e},finish(){let e,t;for(e in this.root&&(this.root.root=!0),this.signals)this.signals[e].signal=e;for(e in this.scales)this.scales[e].scale=e;function n(e,t,n){let r,i;e&&(r=e.data||={},i=r[t]||(r[t]=[]),i.push(n))}for(e in this.data){t=this.data[e],n(t.input,e,`input`),n(t.output,e,`output`),n(t.values,e,`values`);for(let r in t.index)n(t.index[r],e,`index:`+r)}return this},pushState(e,t,n){this._encode.push(vK(this.add(gJ({pulse:e})))),this._parent.push(t),this._lookup.push(n?vK(this.proxy(n)):null),this._markpath.push(-1)},popState(){this._encode.pop(),this._parent.pop(),this._lookup.pop(),this._markpath.pop()},parent(){return Mh(this._parent)},encode(){return Mh(this._encode)},lookup(){return Mh(this._lookup)},markpath(){let e=this._markpath;return++e[e.length-1]},fieldRef(e,t){if(xg(e))return yK(e,t);e.signal||V(`Unsupported field reference: `+W(e));let n=e.signal,r=this.field[n];if(!r){let e={name:this.signalRef(n)};t&&(e.as=t),this.field[n]=r=vK(this.add(tJ(e)))}return r},compareRef(e){let t=!1,n=e=>SK(e)?(t=!0,this.signalRef(e.signal)):QEe(e)?(t=!0,this.exprRef(e.expr)):e,r=ng(e.field).map(n),i=ng(e.order).map(n);return t?vK(this.add(Xq({fields:r,orders:i}))):bK(r,i)},keyRef(e,t){let n=!1,r=e=>SK(e)?(n=!0,vK(i[e.signal])):e,i=this.signals;return e=ng(e).map(r),n?vK(this.add(nJ({fields:e,flat:t}))):XEe(e,t)},sortRef(e){if(!e)return e;let t=xK(e.op,e.field),n=e.order||zq;return n.signal?vK(this.add(Xq({fields:t,orders:this.signalRef(n.signal)}))):bK(t,n)},event(e,t){let n=e+`:`+t;if(!this.events[n]){let r=this.id();this.streams.push({id:r,source:e,type:t}),this.events[n]=r}return this.events[n]},hasOwnSignal(e){return fg(this.signals,e)},addSignal(e,t){this.hasOwnSignal(e)&&V(`Duplicate signal name: `+W(e));let n=t instanceof hK?t:this.add(_K(t));return this.signals[e]=n},getSignal(e){return this.signals[e]||V(`Unrecognized signal name: `+W(e)),this.signals[e]},signalRef(e){return this.signals[e]?vK(this.signals[e]):(fg(this.lambdas,e)||(this.lambdas[e]=this.add(_K(null))),vK(this.lambdas[e]))},parseLambdas(){let e=Object.keys(this.lambdas);for(let t=0,n=e.length;tNO,CanvasHandler:()=>JA,CanvasRenderer:()=>YA,DATE:()=>Yv,DAY:()=>`day`,DAYOFYEAR:()=>Xv,Dataflow:()=>yx,Debug:()=>4,DisallowedObjectProperties:()=>wh,Error:()=>1,EventStream:()=>ux,Gradient:()=>Qpe,GroupItem:()=>FO,HOURS:()=>Zv,Handler:()=>DA,HybridHandler:()=>wj,HybridRenderer:()=>Cj,Info:()=>3,Item:()=>PO,MILLISECONDS:()=>ey,MINUTES:()=>Qv,MONTH:()=>qv,Marks:()=>wA,MultiPulse:()=>gx,None:()=>0,Operator:()=>cx,Parameters:()=>sx,Pulse:()=>fx,QUARTER:()=>Kv,RenderType:()=>Aj,Renderer:()=>OA,ResourceLoader:()=>tA,SECONDS:()=>$v,SVGHandler:()=>XA,SVGRenderer:()=>_j,SVGStringRenderer:()=>xj,Scenegraph:()=>EA,TIME_UNITS:()=>ty,Transform:()=>G,View:()=>bG,WEEK:()=>Jv,Warn:()=>2,YEAR:()=>Gv,accessor:()=>ah,accessorFields:()=>sh,accessorName:()=>oh,array:()=>ng,ascending:()=>sg,bandwidthNRD:()=>Xx,bin:()=>Zx,bootstrapCI:()=>Qx,boundClip:()=>cge,boundContext:()=>RO,boundItem:()=>Sk,boundMark:()=>yhe,boundStroke:()=>LO,changeset:()=>ox,clampRange:()=>Oie,codegenExpression:()=>CH,compare:()=>og,constant:()=>cg,cumulativeLogNormal:()=>cS,cumulativeNormal:()=>nS,cumulativeUniform:()=>mS,dayofyear:()=>xv,debounce:()=>lg,defaultLocale:()=>yb,definition:()=>xx,densityLogNormal:()=>sS,densityNormal:()=>tS,densityUniform:()=>pS,detectTimeUnits:()=>Wv,domChild:()=>Tk,domClear:()=>Ek,domCreate:()=>Ck,domFind:()=>wk,dotbin:()=>$x,error:()=>V,expressionFunction:()=>gW,extend:()=>ug,extent:()=>dg,extentIndex:()=>zie,falsy:()=>Ch,fastmap:()=>mg,field:()=>gh,flush:()=>Hie,font:()=>vk,fontFamily:()=>_k,fontSize:()=>fk,format:()=>Kb,formatLocale:()=>fb,formats:()=>Ab,hasOwnProperty:()=>fg,id:()=>vh,identity:()=>yh,inferType:()=>wb,inferTypes:()=>Tb,ingest:()=>ex,inherits:()=>U,inrange:()=>gg,interpolate:()=>ZD,interpolateColors:()=>XD,interpolateRange:()=>hpe,intersect:()=>rge,intersectBoxLine:()=>VO,intersectPath:()=>zO,intersectPoint:()=>BO,intersectRule:()=>wme,isArray:()=>H,isBoolean:()=>_g,isDate:()=>vg,isFunction:()=>ig,isIterable:()=>Jie,isNumber:()=>yg,isObject:()=>Dh,isRegExp:()=>bg,isString:()=>xg,isTuple:()=>Zb,key:()=>Sg,lerp:()=>eae,lineHeight:()=>pk,loader:()=>qb,locale:()=>vb,logger:()=>Th,lruCache:()=>nae,markup:()=>kk,merge:()=>oae,mergeConfig:()=>kh,multiLineOffset:()=>hk,one:()=>xh,pad:()=>lae,panLinear:()=>Rh,panLog:()=>zh,panPow:()=>Bh,panSymlog:()=>Vh,parse:()=>fOe,parseExpression:()=>xH,parseSelector:()=>zG,path:()=>yw,pathCurves:()=>wO,pathEqual:()=>lge,pathParse:()=>TO,pathRectangle:()=>ume,pathRender:()=>EO,pathSymbols:()=>ime,pathTrail:()=>dme,peek:()=>Mh,point:()=>Dk,projection:()=>BL,quantileLogNormal:()=>lS,quantileNormal:()=>rS,quantileUniform:()=>hS,quantiles:()=>Jx,quantizeInterpolator:()=>gpe,quarter:()=>eg,quartiles:()=>Yx,random:()=>AS,randomInteger:()=>tle,randomKDE:()=>aS,randomLCG:()=>ele,randomLogNormal:()=>uS,randomMixture:()=>dS,randomNormal:()=>iS,randomUniform:()=>gS,read:()=>Mb,regressionConstant:()=>_S,regressionExp:()=>wS,regressionLinear:()=>SS,regressionLoess:()=>OS,regressionLog:()=>CS,regressionPoly:()=>DS,regressionPow:()=>TS,regressionQuad:()=>ES,renderModule:()=>Pk,repeat:()=>Cg,resetDefaultLocale:()=>gce,resetSVGDefIds:()=>dge,responseType:()=>jb,runtimeContext:()=>HW,sampleCurve:()=>kS,sampleLogNormal:()=>oS,sampleNormal:()=>eS,sampleUniform:()=>fS,scale:()=>WD,sceneEqual:()=>Fk,sceneFromJSON:()=>xhe,scenePickVisit:()=>JO,sceneToJSON:()=>bhe,sceneVisit:()=>qO,sceneZOrder:()=>KO,scheme:()=>QD,serializeXML:()=>uj,setHybridRendererOptions:()=>nge,setRandom:()=>Qce,span:()=>wg,splitAccessPath:()=>mh,stringValue:()=>W,textMetrics:()=>SA,timeBin:()=>Uv,timeFloor:()=>Nv,timeFormatLocale:()=>_b,timeInterval:()=>Fv,timeOffset:()=>Rv,timeSequence:()=>Vv,timeUnitSpecifier:()=>yv,timeUnits:()=>vv,toBoolean:()=>Tg,toDate:()=>Eg,toNumber:()=>Ph,toSet:()=>Og,toString:()=>Dg,transform:()=>Sx,transforms:()=>Gx,truncate:()=>vae,truthy:()=>Sh,tupleid:()=>Qb,typeParsers:()=>Hb,utcFloor:()=>Pv,utcInterval:()=>Iv,utcOffset:()=>zv,utcSequence:()=>Hv,utcdayofyear:()=>Ev,utcquarter:()=>tg,utcweek:()=>Dv,version:()=>RY,visitArray:()=>kg,week:()=>Sv,writeConfig:()=>Ah,zero:()=>bh,zoomLinear:()=>Uh,zoomLog:()=>Wh,zoomPow:()=>Gh,zoomSymlog:()=>Kh}),LY,RY,zY=o((()=>{Ag(),Ag(),Kx(),Vle(),z_e(),rve(),obe(),yxe(),WSe(),oCe(),cCe(),PCe(),UCe(),YCe(),LS(),Ay(),Jb(),Pj(),xO(),GL(),FEe(),Cb(),RW(),pOe(),XW(),CU(),nK(),LY=`6.3.1`,ug(Gx,ule,g_e,B_e,Bye,pxe,GSe,BSe,sCe,jCe,FCe,WCe),RY=LY}));function hOe(e,t,n){let r;t.x2&&(t.x?(n&&e.x>e.x2&&(r=e.x,e.x=e.x2,e.x2=r),e.width=e.x2-e.x):e.x=e.x2-(e.width||0)),t.xc&&(e.x=e.xc-(e.width||0)/2),t.y2&&(t.y?(n&&e.y>e.y2&&(r=e.y,e.y=e.y2,e.y2=r),e.height=e.y2-e.y):e.y=e.y2-(e.height||0)),t.yc&&(e.y=e.yc-(e.height||0)/2)}function BY(e,t,n,r,i,a){let o=e=>XY[e.type](o,e);return o.memberDepth=0,o.fn=Object.create(t),o.params=n,o.datum=r,o.event=i,o.item=a,JY.forEach(e=>o.fn[e]=(...t)=>i.vega[e](...t)),o(e)}var VY,HY,UY,WY,GY,KY,qY,JY,YY,XY,ZY,gOe=o((()=>{Ag(),VY={NaN:NaN,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,PI:Math.PI,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2,MIN_VALUE:Number.MIN_VALUE,MAX_VALUE:Number.MAX_VALUE},HY={"*":(e,t)=>e*t,"+":(e,t)=>e+t,"-":(e,t)=>e-t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>ee<=t,">=":(e,t)=>e>=t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,"&":(e,t)=>e&t,"|":(e,t)=>e|t,"^":(e,t)=>e^t,"<<":(e,t)=>e<>":(e,t)=>e>>t,">>>":(e,t)=>e>>>t},UY={"+":e=>+e,"-":e=>-e,"~":e=>~e,"!":e=>!e},WY=Array.prototype.slice,GY=(e,t,n)=>{let r=n?n(t[0]):t[0];return r[e].apply(r,WY.call(t,1))},KY=(e,t=0,n=1,r=0,i=0,a=0,o=0)=>xg(e)?new Date(e):new Date(e,t,n,r,i,a,o),qY={isNaN:Number.isNaN,isFinite:Number.isFinite,abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:Math.atan2,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,pow:Math.pow,random:Math.random,round:Math.round,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,clamp:(e,t,n)=>Math.max(t,Math.min(n,e)),now:Date.now,utc:Date.UTC,datetime:KY,date:e=>new Date(e).getDate(),day:e=>new Date(e).getDay(),year:e=>new Date(e).getFullYear(),month:e=>new Date(e).getMonth(),hours:e=>new Date(e).getHours(),minutes:e=>new Date(e).getMinutes(),seconds:e=>new Date(e).getSeconds(),milliseconds:e=>new Date(e).getMilliseconds(),time:e=>new Date(e).getTime(),timezoneoffset:e=>new Date(e).getTimezoneOffset(),utcdate:e=>new Date(e).getUTCDate(),utcday:e=>new Date(e).getUTCDay(),utcyear:e=>new Date(e).getUTCFullYear(),utcmonth:e=>new Date(e).getUTCMonth(),utchours:e=>new Date(e).getUTCHours(),utcminutes:e=>new Date(e).getUTCMinutes(),utcseconds:e=>new Date(e).getUTCSeconds(),utcmilliseconds:e=>new Date(e).getUTCMilliseconds(),length:e=>e.length,join:function(){return GY(`join`,arguments)},indexof:function(){return GY(`indexOf`,arguments)},lastindexof:function(){return GY(`lastIndexOf`,arguments)},slice:function(){return GY(`slice`,arguments)},reverse:e=>e.slice().reverse(),sort:e=>e.slice().sort(sg),parseFloat,parseInt,upper:e=>String(e).toUpperCase(),lower:e=>String(e).toLowerCase(),substring:function(){return GY(`substring`,arguments,String)},split:function(){return GY(`split`,arguments,String)},replace:function(){return GY(`replace`,arguments,String)},trim:e=>String(e).trim(),btoa:e=>btoa(e),atob:e=>atob(e),encodeURIComponent:e=>encodeURIComponent(e),regexp:RegExp,test:(e,t)=>RegExp(e).test(t)},JY=[`view`,`item`,`group`,`xy`,`x`,`y`],YY=new Set([Function,eval,setTimeout,setInterval]),typeof setImmediate==`function`&&YY.add(setImmediate),XY={Literal:(e,t)=>t.value,Identifier:(e,t)=>{let n=t.name;return e.memberDepth>0?n:n===`datum`?e.datum:n===`event`?e.event:n===`item`?e.item:VY[n]||e.params[`$`+n]},MemberExpression:(e,t)=>{let n=!t.computed,r=e(t.object);n&&(e.memberDepth+=1);let i=e(t.property);if(n&&--e.memberDepth,YY.has(r[i])){console.error(`Prevented interpretation of member "${i}" which could lead to insecure code execution`);return}return r[i]},CallExpression:(e,t)=>{let n=t.arguments,r=t.callee.name;return r.startsWith(`_`)&&(r=r.slice(1)),r===`if`?e(n[0])?e(n[1]):e(n[2]):(e.fn[r]||qY[r]).apply(e.fn,n.map(e))},ArrayExpression:(e,t)=>t.elements.map(e),BinaryExpression:(e,t)=>HY[t.operator](e(t.left),e(t.right)),UnaryExpression:(e,t)=>UY[t.operator](e(t.argument)),ConditionalExpression:(e,t)=>e(t.test)?e(t.consequent):e(t.alternate),LogicalExpression:(e,t)=>t.operator===`&&`?e(t.left)&&e(t.right):e(t.left)||e(t.right),ObjectExpression:(e,t)=>t.properties.reduce((t,n)=>{e.memberDepth+=1;let r=e(n.key);--e.memberDepth;let i=e(n.value);return wh.has(r)?console.error(`Prevented interpretation of property "${r}" which could lead to insecure code execution`):YY.has(i)?console.error(`Prevented interpretation of method "${r}" which could lead to insecure code execution`):t[r]=i,t},{})},ZY={operator(e,t){let n=t.ast,r=e.functions;return e=>BY(n,r,e)},parameter(e,t){let n=t.ast,r=e.functions;return(e,t)=>BY(n,r,t,e)},event(e,t){let n=t.ast,r=e.functions;return e=>BY(n,r,void 0,void 0,e)},handler(e,t){let n=t.ast,r=e.functions;return(e,t)=>{let i=t.item&&t.item.datum;return BY(n,r,e,i,t)}},encode(e,t){let{marktype:n,channels:r}=t,i=e.functions,a=n===`group`||n===`image`||n===`rect`;return(e,t)=>{let o=e.datum,s=0,c;for(let n in r)c=BY(r[n].ast,i,t,o,void 0,e),e[n]!==c&&(e[n]=c,s=1);return n!==`rule`&&hOe(e,r,a),s}}}}));function QY(e){this.type=e}function _Oe(e){switch(e.type){case PX:return e.elements;case FX:case RX:return[e.left,e.right];case IX:return[e.callee].concat(e.arguments);case LX:return[e.test,e.consequent,e.alternate];case zX:return[e.object,e.property];case BX:return e.properties;case MX:return[e.key,e.value];case VX:return[e.argument];case NX:case jX:case AX:default:return[]}}function $Y(e,t){if(!e)throw Error(`ASSERT: `+t)}function eX(e){return e>=48&&e<=57}function tX(e){return`0123456789abcdefABCDEF`.includes(e)}function nX(e){return`01234567`.includes(e)}function vOe(e){return e===32||e===9||e===11||e===12||e===160||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e)}function rX(e){return e===10||e===13||e===8232||e===8233}function iX(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e===92||e>=128&&wZ.test(String.fromCharCode(e))}function aX(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===92||e>=128&&TZ.test(String.fromCharCode(e))}function oX(){for(;J1114111||e!==`}`)&&yX({},fZ,SZ),t<=65535?String.fromCharCode(t):(n=(t-65536>>10)+55296,r=(t-65536&1023)+56320,String.fromCharCode(n,r))}function cX(){var e=UX.charCodeAt(J++),t=String.fromCharCode(e);for(e===92&&(UX.charCodeAt(J)!==117&&yX({},fZ,SZ),++J,e=sX(`u`),(!e||e===`\\`||!iX(e.charCodeAt(0)))&&yX({},fZ,SZ),t=e);J>>=`)return J+=4,{type:QX,value:o,start:e,end:J};if(a=o.substr(0,3),a===`>>>`||a===`<<=`||a===`>>=`)return J+=3,{type:QX,value:a,start:e,end:J};if(i=a.substr(0,2),r===i[1]&&`+-<>&|`.includes(r)||i===`=>`)return J+=2,{type:QX,value:i,start:e,end:J};if(i===`//`&&yX({},fZ,SZ),`<>=!+-*%&|^/`.includes(r))return++J,{type:QX,value:r,start:e,end:J};yX({},fZ,SZ)}function SOe(e){let t=``;for(;J{if(parseInt(t,16)<=1114111)return`x`;yX({},vZ)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,`x`));try{new RegExp(n)}catch{yX({},vZ)}try{return new RegExp(e,t)}catch{return null}}function EOe(){var e=UX[J],t,n,r,i;for($Y(e===`/`,`Regular expression literal must start with a slash`),t=UX[J++],n=!1,r=!1;J=0&&yX({},vZ,n),{value:n,literal:t}}function OOe(){var e,t,n,r;return GX=null,oX(),e=J,t=EOe(),n=DOe(),r=TOe(t.value,n.value),{literal:t.literal+n.literal,value:r,regex:{pattern:t.value,flags:n.value},start:e,end:J}}function kOe(e){return e.type===JX||e.type===YX||e.type===KX||e.type===XX}function dX(){if(oX(),J>=WX)return{type:qX,start:J,end:J};let e=UX.charCodeAt(J);return iX(e)?xOe():e===40||e===41||e===59?lX():e===39||e===34?wOe():e===46?eX(UX.charCodeAt(J+1))?uX():lX():eX(e)?uX():lX()}function fX(){let e=GX;return J=e.end,GX=dX(),J=e.end,e}function pX(){let e=J;GX=dX(),J=e}function AOe(e){let t=new QY(tZ);return t.elements=e,t}function mX(e,t,n){let r=new QY(e===`||`||e===`&&`?sZ:nZ);return r.operator=e,r.left=t,r.right=n,r}function jOe(e,t){let n=new QY(rZ);return n.callee=e,n.arguments=t,n}function MOe(e,t,n){let r=new QY(iZ);return r.test=e,r.consequent=t,r.alternate=n,r}function hX(e){let t=new QY(aZ);return t.name=e,t}function gX(e){let t=new QY(oZ);return t.value=e.value,t.raw=UX.slice(e.start,e.end),e.regex&&(t.raw===`//`&&(t.raw=`/(?:)/`),t.regex=e.regex),t}function _X(e,t,n){let r=new QY(cZ);return r.computed=e===`[`,r.object=t,r.property=n,r.computed||(n.member=!0),r}function NOe(e){let t=new QY(lZ);return t.properties=e,t}function vX(e,t,n){let r=new QY(uZ);return r.key=t,r.value=n,r.kind=e,r}function POe(e,t){let n=new QY(dZ);return n.operator=e,n.argument=t,n.prefix=!0,n}function yX(e,t){var n,r=Array.prototype.slice.call(arguments,2),i=t.replace(/%(\d)/g,(e,t)=>($Y(t`:case`<=`:case`>=`:case`instanceof`:case`in`:t=7;break;case`<<`:case`>>`:case`>>>`:t=8;break;case`+`:case`-`:t=9;break;case`*`:case`/`:case`%`:t=11;break}return t}function GOe(){var e=GX,t,n,r,i,a,o,s,c=EX(),l;if(r=GX,i=DX(r),i===0)return c;for(r.prec=i,fX(),t=[e,GX],o=EX(),a=[c,r,o];(i=DX(GX))>0;){for(;a.length>2&&i<=a[a.length-2].prec;)o=a.pop(),s=a.pop().value,c=a.pop(),t.pop(),n=mX(s,c,o),a.push(n);r=fX(),r.prec=i,a.push(r),t.push(GX),n=EX(),a.push(n)}for(l=a.length-1,n=a[l],t.pop();l>1;)t.pop(),n=mX(a[l-1].value,a[l-2],n),l-=2;return n}function OX(){var e=GOe(),t,n;return SX(`?`)&&(fX(),t=OX(),xX(`:`),n=OX(),e=MOe(e,t,n)),e}function kX(){let e=OX();if(SX(`,`))throw Error(CZ);return e}function KOe(e){UX=e,J=0,WX=UX.length,GX=null,pX();let t=kX();if(GX.type!==qX)throw Error(`Unexpect token after expression.`);return t}var AX,jX,MX,NX,PX,FX,IX,LX,RX,zX,BX,VX,HX,UX,J,WX,GX,KX,qX,JX,YX,XX,ZX,QX,$X,eZ,tZ,nZ,rZ,iZ,aZ,oZ,sZ,cZ,lZ,uZ,dZ,fZ,pZ,mZ,hZ,gZ,_Z,vZ,yZ,bZ,xZ,SZ,CZ,wZ,TZ,EZ,DZ,qOe=o((()=>{Ag(),AX=`RawCode`,jX=`Literal`,MX=`Property`,NX=`Identifier`,PX=`ArrayExpression`,FX=`BinaryExpression`,IX=`CallExpression`,LX=`ConditionalExpression`,RX=`LogicalExpression`,zX=`MemberExpression`,BX=`ObjectExpression`,VX=`UnaryExpression`,QY.prototype.visit=function(e){let t,n,r;if(e(this))return 1;for(t=_Oe(this),n=0,r=t.length;n`,HX[JX]=`Identifier`,HX[YX]=`Keyword`,HX[XX]=`Null`,HX[ZX]=`Numeric`,HX[QX]=`Punctuator`,HX[$X]=`String`,HX[eZ]=`RegularExpression`,tZ=`ArrayExpression`,nZ=`BinaryExpression`,rZ=`CallExpression`,iZ=`ConditionalExpression`,aZ=`Identifier`,oZ=`Literal`,sZ=`LogicalExpression`,cZ=`MemberExpression`,lZ=`ObjectExpression`,uZ=`Property`,dZ=`UnaryExpression`,fZ=`Unexpected token %0`,pZ=`Unexpected number`,mZ=`Unexpected string`,hZ=`Unexpected identifier`,gZ=`Unexpected reserved word`,_Z=`Unexpected end of input`,vZ=`Invalid regular expression`,yZ=`Invalid regular expression: missing /`,bZ=`Octal literals are not allowed in strict mode.`,xZ=`Duplicate data property in object literal not allowed in strict mode`,SZ=`ILLEGAL`,CZ=`Disabled.`,wZ=RegExp(`[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]`),TZ=RegExp(`[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]`),EZ={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1},DZ={if:1}})),JOe=c({accessPathDepth:()=>sQ,accessPathWithDatum:()=>eQ,accessWithDatumToUnescapedPath:()=>nQ,compile:()=>HLe,contains:()=>RZ,deepEqual:()=>mQ,deleteNestedProperty:()=>QZ,duplicate:()=>b2,entries:()=>S2,every:()=>BZ,fieldIntersection:()=>KZ,flatAccessWithDatum:()=>tQ,getFirstDefined:()=>cQ,hasIntersection:()=>WZ,hasProperty:()=>Y,hash:()=>IZ,internalField:()=>uQ,isBoolean:()=>JZ,isEmpty:()=>qZ,isEqual:()=>XOe,isInternalField:()=>dQ,isNullOrFalse:()=>LZ,isNumeric:()=>pQ,isPrimitive:()=>YZ,keys:()=>$,logicalExpr:()=>ZZ,mergeDeep:()=>VZ,never:()=>NZ,normalize:()=>wNe,normalizeAngle:()=>fQ,omit:()=>FZ,pick:()=>PZ,prefixGenerator:()=>GZ,removePathFromField:()=>oQ,replaceAll:()=>aQ,replacePathInField:()=>iQ,resetIdCounter:()=>QOe,setEqual:()=>UZ,some:()=>zZ,stringify:()=>hQ,titleCase:()=>$Z,unescapeSingleQuoteAndPathDot:()=>rQ,unique:()=>HZ,uniqueId:()=>lQ,vals:()=>x2,varName:()=>XZ,version:()=>iVe});function OZ(e){return Y(e,`or`)}function kZ(e){return Y(e,`and`)}function AZ(e){return Y(e,`not`)}function jZ(e,t){if(AZ(e))jZ(e.not,t);else if(kZ(e))for(let n of e.and)jZ(n,t);else if(OZ(e))for(let n of e.or)jZ(n,t);else t(e)}function MZ(e,t){return AZ(e)?{not:MZ(e.not,t)}:kZ(e)?{and:e.and.map(e=>MZ(e,t))}:OZ(e)?{or:e.or.map(e=>MZ(e,t))}:t(e)}function NZ(e){throw Error(e)}function PZ(e,t){let n={};for(let r of t)fg(e,r)&&(n[r]=e[r]);return n}function FZ(e,t){let n={...e};for(let e of t)delete n[e];return n}function IZ(e){if(yg(e))return e;let t=xg(e)?e:hQ(e);if(t.length<250)return t;let n=0;for(let e=0;et===0?e:`[${e}]`),r=e.map((t,n)=>e.slice(0,n+1).join(``));for(let e of r)t.add(e)}return t}function KZ(e,t){return e===void 0||t===void 0||WZ(GZ(e),GZ(t))}function qZ(e){return $(e).length===0}function JZ(e){return e===!0||e===!1}function YZ(e){return xg(e)||yg(e)||JZ(e)}function XZ(e){let t=e.replace(/\W/g,`_`);return(e.match(/^\d+/)?`_`:``)+t}function ZZ(e,t){return AZ(e)?`!(${ZZ(e.not,t)})`:kZ(e)?`(${e.and.map(e=>ZZ(e,t)).join(`) && (`)})`:OZ(e)?`(${e.or.map(e=>ZZ(e,t)).join(`) || (`)})`:t(e)}function QZ(e,t){if(t.length===0)return!0;let n=t.shift();return n in e&&QZ(e[n],t)&&delete e[n],qZ(e)}function $Z(e){return e.charAt(0).toUpperCase()+e.substr(1)}function eQ(e,t=`datum`){let n=mh(e),r=[];for(let e=1;e<=n.length;e++){let i=`[${n.slice(0,e).map(W).join(`][`)}]`;r.push(`${t}${i}`)}return r.join(` && `)}function tQ(e,t=`datum`){return`${t}[${W(mh(e).join(`.`))}]`}function nQ(e){return`datum['${e.replaceAll(`'`,`\\'`)}']`}function rQ(e){return e.replaceAll(`\\'`,`'`).replaceAll(`\\.`,`.`)}function ZOe(e){return e.replace(/(\[|\]|\.|'|")/g,`\\$1`)}function iQ(e){return`${mh(e).map(ZOe).join(`\\.`)}`}function aQ(e,t,n){return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`),`g`),n)}function oQ(e){return`${mh(e).join(`.`)}`}function sQ(e){return e?mh(e).length:0}function cQ(...e){return e.find(e=>e!==void 0)}function lQ(e){let t=++C2;return e?String(e)+t:t}function QOe(){C2=42}function uQ(e){return dQ(e)?e:`__${e}`}function dQ(e){return e.startsWith(`__`)}function fQ(e){if(e!==void 0)return(e%360+360)%360}function pQ(e){return yg(e)?!0:!isNaN(e)&&!isNaN(parseFloat(e))}function mQ(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(e.constructor.name!==t.constructor.name)return!1;let n,r;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!mQ(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let n of e.entries())if(!t.has(n[0]))return!1;for(let n of e.entries())if(!mQ(n[1],t.get(n[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e.entries())if(!t.has(n[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&e.valueOf!==w2.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&e.toString!==w2.toString)return e.toString()===t.toString();let i=Object.keys(e);if(n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!mQ(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function hQ(e){let t=[];return(function e(n){if(n?.toJSON&&typeof n.toJSON==`function`&&(n=n.toJSON()),n===void 0)return;if(typeof n==`number`)return isFinite(n)?`${n}`:`null`;if(typeof n!=`object`)return JSON.stringify(n);let r,i;if(Array.isArray(n)){for(i=`[`,r=0;rHQ(e[t])?XZ(`_${t}_${S2(e[t])}`):XZ(`_${t}_${e[t]}`)).join(``)}`}function zQ(e){return e===!0||VQ(e)&&!e.binned}function BQ(e){return e===`binned`||VQ(e)&&e.binned===!0}function VQ(e){return Dh(e)}function HQ(e){return Y(e,`param`)}function UQ(e){switch(e){case T2:case E2:case q2:case U2:case W2:case G2:case Q2:case Y2:case X2:case Z2:case K2:return 6;case $2:return 4;default:return 10}}function WQ(e){return Y(e,`expr`)}function GQ(e,{level:t}={level:0}){let n=$(e||{}),r={};for(let i of n)r[i]=t===0?$Q(e[i]):GQ(e[i],{level:t-1});return r}function KQ(e){let{anchor:t,frame:n,offset:r,orient:i,angle:a,limit:o,color:s,subtitleColor:c,subtitleFont:l,subtitleFontSize:u,subtitleFontStyle:d,subtitleFontWeight:f,subtitleLineHeight:p,subtitlePadding:m,...h}=e,g={...h,...s?{fill:s}:{}},_={...t?{anchor:t}:{},...n?{frame:n}:{},...r?{offset:r}:{},...i?{orient:i}:{},...a===void 0?{}:{angle:a},...o===void 0?{}:{limit:o}},v={...c?{subtitleColor:c}:{},...l?{subtitleFont:l}:{},...u?{subtitleFontSize:u}:{},...d?{subtitleFontStyle:d}:{},...f?{subtitleFontWeight:f}:{},...p?{subtitleLineHeight:p}:{},...m?{subtitlePadding:m}:{}};return{titleMarkConfig:g,subtitleMarkConfig:PZ(e,[`align`,`baseline`,`dx`,`dy`,`limit`]),nonMarkTitleProperties:_,subtitle:v}}function qQ(e){return xg(e)||H(e)&&xg(e[0])}function JQ(e){return Y(e,`signal`)}function YQ(e){return Y(e,`step`)}function XQ(e){return!H(e)&&Y(e,`fields`)&&!Y(e,`data`)}function oke(e){return!H(e)&&Y(e,`fields`)&&Y(e,`data`)}function ZQ(e){return!H(e)&&Y(e,`field`)&&Y(e,`data`)}function QQ(e){let t=H(e.condition)?e.condition.map(e$):e$(e.condition);return{...$Q(e),condition:t}}function $Q(e){if(WQ(e)){let{expr:t,...n}=e;return{signal:t,...n}}return e}function e$(e){if(WQ(e)){let{expr:t,...n}=e;return{signal:t,...n}}return e}function t$(e){if(WQ(e)){let{expr:t,...n}=e;return{signal:t,...n}}return JQ(e)?e:e===void 0?void 0:{value:e}}function ske(e){return JQ(e)?e.signal:W(e)}function n$(e){return JQ(e)?e.signal:W(e.value)}function r$(e){return JQ(e)?e.signal:e==null?null:W(e)}function cke(e,t,n){for(let r of n){let n=o$(r,t.markDef,t.config);n!==void 0&&(e[r]=t$(n))}return e}function i$(e){return[].concat(e.type,e.style??[])}function a$(e,t,n,r={}){let{vgChannel:i,ignoreVgConfig:a}=r;return i&&Y(t,i)?t[i]:t[e]===void 0?a&&(!i||i===e)?void 0:o$(e,t,n,r):t[e]}function o$(e,t,n,{vgChannel:r}={}){let i=s$(e,t,n.style);return cQ(r?i:void 0,i,r?n[t.type][r]:void 0,n[t.type][e],r?n.mark[r]:n.mark[e])}function s$(e,t,n){return c$(e,i$(t),n)}function c$(e,t,n){t=ng(t);let r;for(let i of t){let t=n[i];Y(t,e)&&(r=t[e])}return r}function l$(e,t){return ng(e).reduce((e,n)=>(e.field.push(Q(n,t)),e.order.push(n.sort??`ascending`),e),{field:[],order:[]})}function u$(e,t){let n=[...e];return t.forEach(e=>{for(let t of n)if(mQ(t,e))return;n.push(e)}),n}function d$(e,t){return mQ(e,t)||!t?e:e?[...ng(e),...ng(t)].join(`, `):t}function lke(e,t){let n=e.value,r=t.value;if(n==null||r===null)return{explicit:e.explicit,value:null};if((qQ(n)||JQ(n))&&(qQ(r)||JQ(r)))return{explicit:e.explicit,value:d$(n,r)};if(qQ(n)||JQ(n))return{explicit:e.explicit,value:n};if(qQ(r)||JQ(r))return{explicit:e.explicit,value:r};if(!qQ(n)&&!JQ(n)&&!qQ(r)&&!JQ(r))return{explicit:e.explicit,value:u$(n,r)};throw Error(`It should never reach here`)}function f$(e){return`Invalid specification ${hQ(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}function uke(e){return`${e==`width`?`Width`:`Height`} "container" only works for single views and layered views.`}function dke(e){return`${e==`width`?`Width`:`Height`} "container" only works well with autosize "fit" or "fit-${e==`width`?`x`:`y`}".`}function fke(e){return e?`Dropping "fit-${e}" because spec has discrete ${TQ(e)}.`:`Dropping "fit" because spec has discrete size.`}function p$(e){return`Unknown field for ${e}. Cannot calculate view size.`}function pke(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`}function mke(e,t){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").`}function hke(e){return`The "nearest" transform is not supported for ${e} marks.`}function gke(e){return`Selection not supported for ${e} yet.`}function _ke(e){return`Cannot find a selection named "${e}".`}function vke(e){return`Lookups can only be performed on selection parameters. "${e}" is a variable parameter.`}function yke(e){return`Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`}function bke(e){return`Unknown repeated value "${e}".`}function xke(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`}function Ske(e){return`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${W(e)}.`}function Cke(e,t,n,r){return`${e.length?`Multiple `:`No `}matching ${W(t)} encoding found for selection ${W(n.param)}. Using "field": ${W(r)}.`}function wke(e){return`Unrecognized parse "${e}".`}function Tke(e,t,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`}function Eke(e){return`Ignoring an invalid transform: ${hQ(e)}.`}function Dke(e){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`}function Oke(e){let{parentProjection:t,projection:n}=e;return`Layer's shared projection ${hQ(t)} is overridden by a child projection ${hQ(n)}.`}function kke(e){return`${e}Offset dropped because ${e} is continuous`}function Ake(e,t,n){return`Channel ${e} is a ${t}. Converted to {value: ${hQ(n)}}.`}function jke(e){return`Invalid field type "${e}".`}function Mke(e,t){return`Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`}function Nke(e){return`Invalid aggregation operator "${e}".`}function Pke(e,t){let{fill:n,stroke:r}=t;return`Dropping color ${e} as the plot also has ${n&&r?`fill and stroke`:n?`fill`:`stroke`}.`}function Fke(e){return`Position range does not support relative band size for ${e}.`}function m$(e,t){return`Dropping ${hQ(e)} from channel "${t}" since it does not contain any data field, datum, value, or signal.`}function h$(e,t,n){return`${e} dropped as it is incompatible with "${t}".`}function Ike(e){return`${e}-encoding is dropped as ${e} is not a valid encoding channel.`}function Lke(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`}function Rke(e){return`${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function zke(e){return`Facet encoding dropped as ${e.join(` and `)} ${e.length>1?`are`:`is`} also specified.`}function g$(e,t){return`Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${t===`ordinal`?`order`:`magnitude`}.`}function Bke(e){return`The ${e} for range marks cannot be an expression`}function Vke(e,t){return`Line mark is for continuous lines and thus cannot be used with ${e&&t?`x2 and y2`:e?`x2`:`y2`}. We will use the rule mark (line segments) instead.`}function Hke(e,t){return`Specified orient "${e}" overridden with "${t}".`}function Uke(e){return`Cannot use the scale property "${e}" with non-color channel.`}function Wke(e){return`Cannot use the relative band size with ${e} scale.`}function Gke(e){return`Using unaggregated domain with raw field has no effect (${hQ(e)}).`}function Kke(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`}function qke(e){return`Unaggregated domain is currently unsupported for log scale (${hQ(e)}).`}function Jke(e){return`Cannot apply size to non-oriented mark "${e}".`}function Yke(e,t,n){return`Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.`}function Xke(e,t){return`FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.`}function Zke(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`}function Qke(e){return`The step for "${e}" is dropped because the ${e===`width`?`x`:`y`} is continuous.`}function $ke(e,t,n,r){return`Conflicting ${t.toString()} property "${e.toString()}" (${hQ(n)} and ${hQ(r)}). Using ${hQ(n)}.`}function eAe(e,t,n,r){return`Conflicting ${t.toString()} property "${e.toString()}" (${hQ(n)} and ${hQ(r)}). Using the union of the two domains.`}function tAe(e){return`Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`}function nAe(e){return`Dropping sort property ${hQ(e)} as unioned domains only support boolean or op "count", "min", and "max".`}function rAe(e,t){return`Unioning discrete legend values from ${e} and ${t}.`}function iAe(e){return`Cannot stack "${e}" if there is already "${e}2".`}function aAe(e){return`Stack is applied to a non-linear scale (${e}).`}function oAe(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}").`}function _$(e,t){return`Invalid ${e}: ${hQ(t)}.`}function sAe(e){return`Dropping day from datetime ${hQ(e)} as day cannot be combined with other units.`}function cAe(e,t){return`${t?`extent `:``}${t&&e?`and `:``}${e?`center `:``}${t&&e?`are `:`is `}not needed when data are aggregated.`}function lAe(e,t,n){return`${e} is not usually used with ${t} for ${n}.`}function uAe(e,t){return`Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`}function dAe(e){return`1D error band does not support ${e}.`}function fAe(e){return`Channel ${e} is required for "binned" bin.`}function pAe(e){return`Channel ${e} should not be used with "binned" bin.`}function mAe(e){return`Domain for ${e} is required for threshold scale.`}function hAe(e){return D4=e,D4}function gAe(){return D4=E4,D4}function v$(...e){D4.error(...e)}function X(...e){D4.warn(...e)}function _Ae(...e){D4.debug(...e)}function y$(e){if(e&&Dh(e)){for(let t of j4)if(Y(e,t))return!0}return!1}function vAe(e){if(pQ(e)&&(e=+e),yg(e))return e>4&&X(_$(`quarter`,e)),e-1;throw Error(_$(`quarter`,e))}function yAe(e){if(pQ(e)&&(e=+e),yg(e))return e-1;{let t=e.toLowerCase(),n=O4.indexOf(t);if(n!==-1)return n;let r=t.substr(0,3),i=nze.indexOf(r);if(i!==-1)return i;throw Error(_$(`month`,e))}}function bAe(e){if(pQ(e)&&(e=+e),yg(e))return e%7;{let t=e.toLowerCase(),n=k4.indexOf(t);if(n!==-1)return n;let r=t.substr(0,3),i=rze.indexOf(r);if(i!==-1)return i;throw Error(_$(`day`,e))}}function b$(e,t){let n=[];if(t&&e.day!==void 0&&$(e).length>1&&(X(sAe(e)),e=b2(e),delete e.day),e.year===void 0?n.push(2012):n.push(e.year),e.month!==void 0){let r=t?yAe(e.month):e.month;n.push(r)}else if(e.quarter!==void 0){let r=t?vAe(e.quarter):e.quarter;n.push(yg(r)?r*3:`${r}*3`)}else n.push(0);if(e.date!==void 0)n.push(e.date);else if(e.day!==void 0){let r=t?bAe(e.day):e.day;n.push(yg(r)?r+1:`${r}+1`)}else n.push(1);for(let t of[`hours`,`minutes`,`seconds`,`milliseconds`]){let r=e[t];n.push(r===void 0?0:r)}return n}function x$(e){let t=b$(e,!0).join(`, `);return e.utc?`utc(${t})`:`datetime(${t})`}function xAe(e){let t=b$(e,!1).join(`, `);return e.utc?`utc(${t})`:`datetime(${t})`}function SAe(e){let t=b$(e,!0);return e.utc?+new Date(Date.UTC(...t)):+new Date(...t)}function CAe(e){return fg(A4,e)}function S$(e){return Dh(e)?e.binned:wAe(e)}function wAe(e){return e?.startsWith(`binned`)}function C$(e){return e.startsWith(`utc`)}function TAe(e){return e.substring(3)}function w$(e){return j4.filter(t=>DAe(e,t))}function EAe(e){let t=w$(e);return t[t.length-1]}function DAe(e,t){let n=e.indexOf(t);return!(n<0||n>0&&t===`seconds`&&e.charAt(n-1)===`i`||e.length>n+3&&t===`day`&&e.charAt(n+3)===`o`||n>0&&t===`year`&&e.charAt(n-1)===`f`)}function OAe(e,t,{end:n}={end:!1}){let r=eQ(t),i=C$(e)?`utc`:``;function a(e){return e===`quarter`?`(${i}quarter(${r})-1)`:`${i}${e}(${r})`}let o,s={};for(let t of j4)DAe(e,t)&&(s[t]=a(t),o=t);return n&&(s[o]+=`+1`),xAe(s)}function kAe(e){if(e)return`timeUnitSpecifier(${hQ(w$(e))}, ${hQ(ize)})`}function AAe(e,t,n){if(!e)return;let r=kAe(e);return`${n||C$(e)?`utc`:`time`}Format(${t}, ${r})`}function T$(e){if(!e)return;let t;return xg(e)?t=wAe(e)?{unit:e.substring(6),binned:!0}:{unit:e}:Dh(e)&&(t={...e,...e.unit?{unit:e.unit}:{}}),C$(t.unit)&&(t.utc=!0,t.unit=TAe(t.unit)),t}function jAe(e){let{utc:t,...n}=T$(e);return n.unit?(t?`utc`:``)+$(n).map(e=>XZ(`${e===`unit`?``:`_${e}_`}${n[e]}`)).join(``):`${t?`utc`:``}timeunit${$(n).map(e=>XZ(`_${e}_${n[e]}`)).join(``)}`}function MAe(e,t=e=>e){let n=T$(e),r=EAe(n.unit);if(r&&r!==`day`){let e={year:2001,month:1,date:1,hours:0,minutes:0,seconds:0,milliseconds:0},{step:i,part:a}=PAe(r,n.step);return`${t(x$({...e,[a]:+e[a]+i}))} - ${t(x$(e))}`}}function NAe(e){return fg(aze,e)}function PAe(e,t=1){if(NAe(e))return{part:e,step:t};switch(e){case`day`:case`dayofyear`:return{part:`date`,step:t};case`quarter`:return{part:`month`,step:t*3};case`week`:return{part:`date`,step:t*7}}}function FAe(e){return Y(e,`param`)}function E$(e){return!!e?.field&&e.equal!==void 0}function D$(e){return!!e?.field&&e.lt!==void 0}function O$(e){return!!e?.field&&e.lte!==void 0}function k$(e){return!!e?.field&&e.gt!==void 0}function A$(e){return!!e?.field&&e.gte!==void 0}function j$(e){return!!(e?.field&&(H(e.range)&&e.range.length===2||JQ(e.range)))}function M$(e){return!!e?.field&&(H(e.oneOf)||H(e.in))}function IAe(e){return!!e?.field&&e.valid!==void 0}function LAe(e){return M$(e)||E$(e)||j$(e)||D$(e)||k$(e)||O$(e)||A$(e)}function N$(e,t){return j1(e,{timeUnit:t,wrapTime:!0})}function RAe(e,t){return e.map(e=>N$(e,t))}function zAe(e,t=!0){let{field:n}=e,{unit:r,binned:i}=T$(e.timeUnit)||{},a=Q(e,{expr:`datum`}),o=r?`time(${i?a:OAe(r,n)})`:a;if(E$(e))return`${o}===${N$(e.equal,r)}`;if(D$(e)){let t=e.lt;return`${o}<${N$(t,r)}`}else if(k$(e)){let t=e.gt;return`${o}>${N$(t,r)}`}else if(O$(e)){let t=e.lte;return`${o}<=${N$(t,r)}`}else if(A$(e)){let t=e.gte;return`${o}>=${N$(t,r)}`}else if(M$(e))return`indexof([${RAe(e.oneOf,r).join(`,`)}], ${o}) !== -1`;else if(IAe(e))return P$(o,e.valid);else if(j$(e)){let{range:n}=GQ(e),i=JQ(n)?{signal:`${n.signal}[0]`}:n[0],a=JQ(n)?{signal:`${n.signal}[1]`}:n[1];if(i!==null&&a!==null&&t)return`inrange(${o}, [${N$(i,r)}, ${N$(a,r)}])`;let s=[];return i!==null&&s.push(`${o} >= ${N$(i,r)}`),a!==null&&s.push(`${o} <= ${N$(a,r)}`),s.length>0?s.join(` && `):`true`}throw Error(`Invalid field predicate: ${hQ(e)}`)}function P$(e,t=!0){return t?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function BAe(e){return LAe(e)&&e.timeUnit?{...e,timeUnit:T$(e.timeUnit)}:e}function VAe(e){return e===`quantitative`||e===`temporal`}function F$(e){return e===`ordinal`||e===`nominal`}function HAe(e){if(e)switch(e=e.toLowerCase(),e){case`q`:case N4:return`quantitative`;case`t`:case F4:return`temporal`;case`o`:case P4:return`ordinal`;case`n`:case I4:return`nominal`;case L4:return`geojson`}}function UAe(e,t){let n=z4[e],r=z4[t];return n===r||n===`ordinal-position`&&r===`time`||r===`ordinal-position`&&n===`time`}function WAe(e){return oze[e]}function GAe(e){return B4.has(e)}function I$(e){return cze.has(e)}function L$(e){return sze.has(e)}function R$(e){return V4.has(e)}function z$(e){return H4.has(e)}function KAe(e){return!xg(e)&&Y(e,`name`)}function qAe(e){return Y(e,`param`)}function JAe(e){return Y(e,`unionWith`)}function YAe(e){return Dh(e)&&`field`in e}function B$(e,t){switch(t){case`type`:case`domain`:case`reverse`:case`range`:return!0;case`scheme`:case`interpolate`:return![`point`,`band`,`identity`].includes(e);case`bins`:return![`point`,`band`,`identity`,`ordinal`].includes(e);case`round`:return R$(e)||e===`band`||e===`point`;case`padding`:case`rangeMin`:case`rangeMax`:return R$(e)||[`point`,`band`].includes(e);case`paddingOuter`:case`align`:return[`point`,`band`].includes(e);case`paddingInner`:return e===`band`;case`domainMax`:case`domainMid`:case`domainMin`:case`domainRaw`:case`clamp`:return R$(e);case`nice`:return R$(e)||e===`quantize`||e===`threshold`;case`exponent`:return e===`pow`;case`base`:return e===`log`;case`constant`:return e===`symlog`;case`zero`:return L$(e)&&!RZ([`log`,`time`,`utc`,`threshold`,`quantile`],e)}}function XAe(e,t){switch(t){case`interpolate`:case`scheme`:case`domainMid`:return yQ(e)?void 0:Uke(t);case`align`:case`type`:case`bins`:case`domain`:case`domainMax`:case`domainMin`:case`domainRaw`:case`range`:case`base`:case`exponent`:case`constant`:case`nice`:case`padding`:case`paddingInner`:case`paddingOuter`:case`rangeMax`:case`rangeMin`:case`reverse`:case`round`:case`clamp`:case`zero`:return}}function ZAe(e,t){return RZ([P4,I4],t)?e===void 0||I$(e):t===F4?RZ([R4.TIME,R4.UTC,void 0],e):t!==N4||GAe(e)||z$(e)||e===void 0}function QAe(e,t,n=!1){if(!MQ(e))return!1;switch(e){case O2:case k2:case M2:case N2:case I2:case P2:return R$(t)?!0:t===`band`||t===`point`&&!n;case H2:return RZ([`linear`,`band`],t);case q2:case Q2:case Y2:case X2:case Z2:case J2:return R$(t)||z$(t)||RZ([`band`,`point`,`ordinal`],t);case U2:case W2:case G2:return t!==`band`;case $2:case K2:return t===`ordinal`||z$(t)}}function $Ae(e){return Dh(e)&&`value`in e}function V$(e){return[`line`,`area`,`trail`].includes(e)}function H$(e){return[`rect`,`bar`,`image`,`arc`,`tick`].includes(e)}function U$(e){return Y(e,`type`)}function W$(e){return Y(e,`band`)}function eje(e){return U$(e)?e.type:e}function tje(e,{isPath:t}){return e===void 0||e===`break-paths-show-path-domains`?t?`break-paths-show-domains`:`filter`:e===null?`show`:e}function G$({markDef:e,config:t,scaleChannel:n,scaleType:r,isCountAggregate:i}){if(!r||!L$(r)||i)return`always-valid`;let a=tje(a$(`invalid`,e,t),{isPath:V$(e.type)});return t.scale?.invalid?.[n]===void 0?a:`show`}function nje(e){return e===`break-paths-filter-domains`||e===`break-paths-show-domains`}function rje({scaleName:e,scale:t,mode:n}){let r=`domain('${e}')`;if(!t||!e)return;let i=`${r}[0]`,a=`peek(${r})`,o=t.domainHasZero();return o===`definitely`?{scale:e,value:0}:o===`maybe`?{signal:`scale('${e}', inrange(0, ${r}) ? 0 : ${n===`zeroOrMin`?i:a})`}:{signal:`scale('${e}', ${n===`zeroOrMin`?i:a})`}}function ije({scaleChannel:e,channelDef:t,scale:n,scaleName:r,markDef:i,config:a}){let o=n?.get(`type`),s=T1(t),c=G$({scaleChannel:e,markDef:i,config:a,scaleType:o,isCountAggregate:LQ(s?.aggregate)});if(s&&c===`show`){let t=a.scale.invalid?.[e]??`zero-or-min`;return{test:P$(Q(s,{expr:`datum`}),!1),...aje(t,n,r)}}}function aje(e,t,n){if($Ae(e)){let{value:t}=e;return JQ(t)?{signal:t.signal}:{value:t}}return rje({scale:t,scaleName:n,mode:`zeroOrMin`})}function K$(e){let{channel:t,channelDef:n,markDef:r,scale:i,scaleName:a,config:o}=e,s=SQ(t),c=Y$(e),l=ije({scaleChannel:s,channelDef:n,scale:i,scaleName:a,markDef:r,config:o});return l===void 0?c:[l,c]}function oje(e){let{datum:t}=e;return y$(t)?x$(t):`${hQ(t)}`}function q$(e,t,n,r){let i={};if(t&&(i.scale=t),f1(e)){let{datum:t}=e;y$(t)?i.signal=x$(t):JQ(t)?i.signal=t.signal:WQ(t)?i.signal=t.expr:i.value=t}else i.field=Q(e,n);if(r){let{offset:e,band:t}=r;e&&(i.offset=e),t&&(i.band=t)}return i}function J$({scaleName:e,fieldOrDatumDef:t,fieldOrDatumDef2:n,offset:r,startSuffix:i,endSuffix:a=`end`,bandPosition:o=.5}){let s=!JQ(o)&&0{let r=j1(t,{timeUnit:Z(e)&&!S$(e.timeUnit)?e.timeUnit:void 0,type:n,undefinedIfExprNotRequired:!0});return r===void 0?t:{signal:r}})}function M1(e,t){return zQ(e.bin)?MQ(t)&&[`ordinal`,`nominal`].includes(e.type):(console.warn(`Only call this method for binned field defs.`),!1)}function N1(e){return e?.condition}function Uje(e){return fg(Mze,e)}function P1(e){return Y(e,`mark`)}function F1(e,t){let n=e?.[t];return n?H(n)?zZ(n,e=>!!e.field):Z(n)||l1(n):!1}function Wje(e,t){let n=e?.[t];return n?H(n)?zZ(n,e=>!!e.field):Z(n)||f1(n)||u1(n):!1}function Gje(e,t){if(OQ(t)){let n=e[t];if((Z(n)||f1(n))&&(F$(n.type)||Z(n)&&n.timeUnit))return Wje(e,DQ(t))}return!1}function Kje(e){return zZ(JLe,t=>{if(F1(e,t)){let n=e[t];if(H(n))return zZ(n,e=>!!e.aggregate);{let e=T1(n);return e&&!!e.aggregate}}return!1})}function qje(e,t){let n=[],r=[],i=[],a=[],o={};return L1(e,(s,c)=>{if(Z(s)){let{field:l,aggregate:u,bin:d,timeUnit:f,...p}=s;if(u||f||d){let e=S1(s)?.title,m=Q(s,{forAs:!0}),h={...e?[]:{title:x1(s,t,{allowDisabling:!0})},...p,field:m};if(u){let e;if(FQ(u)?(e=`argmax`,m=Q({op:`argmax`,field:u.argmax},{forAs:!0}),h.field=`${m}.${l}`):PQ(u)?(e=`argmin`,m=Q({op:`argmin`,field:u.argmin},{forAs:!0}),h.field=`${m}.${l}`):u!==`boxplot`&&u!==`errorbar`&&u!==`errorband`&&(e=u),e){let t={op:e,as:m};l&&(t.field=l),a.push(t)}}else if(n.push(m),g1(s)&&zQ(d)){if(r.push({bin:d,field:l,as:m}),n.push(Q(s,{binSuffix:`end`})),M1(s,c)&&n.push(Q(s,{binSuffix:`range`})),OQ(c)){let e={field:`${m}_end`};o[`${c}2`]=e}h.bin=`binned`,xQ(c)||(h.type=N4)}else if(f&&!S$(f)){i.push({timeUnit:f,field:l,as:m});let e=g1(s)&&s.type!==F4&&`time`;e&&(c===e4||c===i4?h.formatType=e:tke(c)?h.legend={formatType:e,...h.legend}:OQ(c)&&(h.axis={formatType:e,...h.axis}))}o[c]=h}else n.push(l),o[c]=e[c]}else o[c]=e[c]}),{bins:r,timeUnits:i,aggregate:a,groupby:n,encoding:o}}function Jje(e,t,n){let r=rke(t,n);if(!r)return!1;if(r===`binned`){let n=e[t===A2?O2:k2];return!!(Z(n)&&Z(e[t])&&BQ(n.bin))}return!0}function Yje(e,t,n,r){let i={};for(let t of $(e))bQ(t)||X(Ike(t));for(let a of iRe){if(!e[a])continue;let o=e[a];if(AQ(a)){let e=eke(a),t=i[e];if(Z(t)&&VAe(t.type)&&Z(o)&&!t.timeUnit){X(kke(e));continue}}if(a===`angle`&&t===`arc`&&!e.theta&&(X(ZRe),a=I2),!Jje(e,a,t)){X(h$(a,t));continue}if(a===q2&&t===`line`&&T1(e[a])?.aggregate){X(QRe);continue}if(a===U2&&(n?`fill`in e:`stroke`in e)){X(Pke(`encoding`,{fill:`fill`in e,stroke:`stroke`in e}));continue}if(a===n4||a===t4&&!H(o)&&!_1(o)||a===i4&&H(o)){if(o){if(a===t4){let t=e[a];if(wje(t)){i[a]=t;continue}}i[a]=ng(o).reduce((e,t)=>(Z(t)?e.push(O1(t,a)):X(m$(t,a)),e),[])}}else{if(a===i4&&o===null)i[a]=null;else if(!Z(o)&&!f1(o)&&!_1(o)&&!c1(o)&&!JQ(o)){X(m$(o,a));continue}i[a]=Rje(o,a,r)}}return i}function I1(e,t){let n={};for(let r of $(e))n[r]=Rje(e[r],r,t,{compositeMark:!0});return n}function Xje(e){let t=[];for(let n of $(e))if(F1(e,n)){let r=e[n],i=ng(r);for(let e of i)Z(e)?t.push(e):l1(e)&&t.push(e.condition)}return t}function L1(e,t,n){if(e)for(let r of $(e)){let i=e[r];if(H(i))for(let e of i)t.call(n,e,r);else t.call(n,i,r)}}function Zje(e,t,n,r){return e?$(e).reduce((n,i)=>{let a=e[i];return H(a)?a.reduce((e,n)=>t.call(r,e,n,i),n):t.call(r,n,a,i)},n):n}function Qje(e,t){return $(t).reduce((n,r)=>{switch(r){case O2:case k2:case a4:case s4:case o4:case A2:case j2:return n;case M2:case N2:if(e===`line`||e===`area`||e===`trail`){let e=t[r];if(Z(e)){let i=t[r===M2?O2:k2];if(Z(i)&&!i.aggregate&&!e.aggregate){let t=Q(i,{}),r=Q(e,{});t&&r&&t!==r&&n.push(t)}}}return n;case I2:case L2:case P2:case F2:case H2:case R2:case z2:case B2:case V2:case e4:case K2:case J2:case i4:return n;case t4:if(e===`line`||e===`trail`)return n;case n4:case r4:{let e=t[r];if(H(e)||Z(e))for(let t of ng(e))t.aggregate||n.push(Q(t,{}));return n}case q2:if(e===`trail`)return n;case U2:case W2:case G2:case Y2:case X2:case Z2:case $2:case Q2:{let e=T1(t[r]);return e&&!e.aggregate&&n.push(Q(e,{})),n}}},[])}function $je(e){let{tooltip:t,...n}=e;if(!t)return{filteredEncoding:n};let r,i;if(H(t)){for(let e of t)e.aggregate?(r||=[],r.push(e)):(i||=[],i.push(e));r&&(n.tooltip=r)}else t.aggregate?n.tooltip=t:i=t;return H(i)&&i.length===1&&(i=i[0]),{customTooltipWithoutAggregatedField:i,filteredEncoding:n}}function R1(e,t,n,r=!0){if(`tooltip`in n)return{tooltip:n.tooltip};let i=e.map(({fieldPrefix:e,titlePrefix:n})=>{let i=r?` of ${z1(t)}`:``;return{field:e+t.field,type:t.type,title:JQ(n)?{signal:`${n}"${escape(i)}"`}:n+i}}),a=Xje(n).map(kje);return{tooltip:[...i,...HZ(a,IZ)]}}function z1(e){let{title:t,field:n}=e;return cQ(t,n)}function B1(e,t,n,r,i){let{scale:a,axis:o}=n;return({partName:s,mark:c,positionPrefix:l,endPositionPrefix:u=void 0,extraEncoding:d={}})=>{let f=z1(n);return eMe(e,s,i,{mark:c,encoding:{[t]:{field:`${l}_${n.field}`,type:n.type,...f===void 0?{}:{title:f},...a===void 0?{}:{scale:a},...o===void 0?{}:{axis:o}},...xg(u)?{[`${t}2`]:{field:`${u}_${n.field}`}}:{},...r,...d}})}}function eMe(e,t,n,r){let{clip:i,color:a,opacity:o}=e,s=e.type;return e[t]||e[t]===void 0&&n[t]?[{...r,mark:{...n[t],...i?{clip:i}:{},...a?{color:a}:{},...o?{opacity:o}:{},...U$(r.mark)?r.mark:{type:r.mark},style:`${s}-${String(t)}`,..._g(e[t])?{}:e[t]}}]:[]}function tMe(e,t,n){let{encoding:r}=e,i=t===`vertical`?`y`:`x`,a=r[i],o=r[`${i}2`],s=r[`${i}Error`],c=r[`${i}Error2`];return{continuousAxisChannelDef:V1(a,n),continuousAxisChannelDef2:V1(o,n),continuousAxisChannelDefError:V1(s,n),continuousAxisChannelDefError2:V1(c,n),continuousAxis:i}}function V1(e,t){if(e?.aggregate){let{aggregate:n,...r}=e;return n!==t&&X(uAe(n,t)),r}else return e}function nMe(e,t){let{mark:n,encoding:r}=e,{x:i,y:a}=r;if(U$(n)&&n.orient)return n.orient;if(p1(i)){if(p1(a)){let e=Z(i)&&i.aggregate,n=Z(a)&&a.aggregate;if(!e&&n===t)return`vertical`;if(!n&&e===t)return`horizontal`;if(e===t&&n===t)throw Error(`Both x and y cannot have aggregate`);return A1(a)&&!A1(i)?`horizontal`:`vertical`}return`horizontal`}else if(p1(a))return`vertical`;else throw Error(`Need a valid continuous axis for ${t}s`)}function rMe(e){return yg(e)?`tukey`:e}function iMe(e,{config:t}){e={...e,encoding:I1(e.encoding,t)};let{mark:n,encoding:r,params:i,projection:a,...o}=e,s=U$(n)?n:{type:n};i&&X(gke(`boxplot`));let c=s.extent??t.boxplot.extent,l=a$(`size`,s,t),u=s.invalid,d=rMe(c),{bins:f,timeUnits:p,transform:m,continuousAxisChannelDef:h,continuousAxis:g,groupby:_,aggregate:v,encodingWithoutContinuousAxis:y,ticksOrient:b,boxOrient:x,customTooltipWithoutAggregatedField:S}=oMe(e,c,t),C=oQ(h.field),{color:w,size:T,...E}=y,D=e=>B1(s,g,h,e,t.boxplot),O=D(E),k=D(y),A=(Dh(t.boxplot.box)?t.boxplot.box.color:t.mark.color)||`#4c78a8`,j=D({...E,...T?{size:T}:{},color:{condition:{test:`${nQ(`lower_box_${h.field}`)} >= ${nQ(`upper_box_${h.field}`)}`,...w||{value:A}}}}),M=R1([{fieldPrefix:d===`min-max`?`upper_whisker_`:`max_`,titlePrefix:`Max`},{fieldPrefix:`upper_box_`,titlePrefix:`Q3`},{fieldPrefix:`mid_box_`,titlePrefix:`Median`},{fieldPrefix:`lower_box_`,titlePrefix:`Q1`},{fieldPrefix:d===`min-max`?`lower_whisker_`:`min_`,titlePrefix:`Min`}],h,y),ee={type:`tick`,color:`black`,opacity:1,orient:b,invalid:u,aria:!1},N=d===`min-max`?M:R1([{fieldPrefix:`upper_whisker_`,titlePrefix:`Upper Whisker`},{fieldPrefix:`lower_whisker_`,titlePrefix:`Lower Whisker`}],h,y),te=[...O({partName:`rule`,mark:{type:`rule`,invalid:u,aria:!1},positionPrefix:`lower_whisker`,endPositionPrefix:`lower_box`,extraEncoding:N}),...O({partName:`rule`,mark:{type:`rule`,invalid:u,aria:!1},positionPrefix:`upper_box`,endPositionPrefix:`upper_whisker`,extraEncoding:N}),...O({partName:`ticks`,mark:ee,positionPrefix:`lower_whisker`,extraEncoding:N}),...O({partName:`ticks`,mark:ee,positionPrefix:`upper_whisker`,extraEncoding:N})],ne=[...d===`tukey`?[]:te,...k({partName:`box`,mark:{type:`bar`,...l?{size:l}:{},orient:x,invalid:u,ariaRoleDescription:`box`},positionPrefix:`lower_box`,endPositionPrefix:`upper_box`,extraEncoding:M}),...j({partName:`median`,mark:{type:`tick`,invalid:u,...Dh(t.boxplot.median)&&t.boxplot.median.color?{color:t.boxplot.median.color}:{},...l?{size:l}:{},orient:b,aria:!1},positionPrefix:`mid_box`,extraEncoding:M})];if(d===`min-max`)return{...o,transform:(o.transform??[]).concat(m),layer:ne};let P=nQ(`lower_box_${h.field}`),re=nQ(`upper_box_${h.field}`),F=`(${re} - ${P})`,ie=`${P} - ${c} * ${F}`,ae=`${re} + ${c} * ${F}`,oe=nQ(h.field),se={joinaggregate:aMe(h.field),groupby:_},ce={transform:[{filter:`(${ie} <= ${oe}) && (${oe} <= ${ae})`},{aggregate:[{op:`min`,field:h.field,as:`lower_whisker_${C}`},{op:`max`,field:h.field,as:`upper_whisker_${C}`},{op:`min`,field:`lower_box_${h.field}`,as:`lower_box_${C}`},{op:`max`,field:`upper_box_${h.field}`,as:`upper_box_${C}`},...v],groupby:_}],layer:te},{tooltip:le,...ue}=E,{scale:de,axis:fe}=h,pe=z1(h),me=eMe(s,`outliers`,t.boxplot,{transform:[{filter:`(${oe} < ${ie}) || (${oe} > ${ae})`}],mark:`point`,encoding:{[g]:{field:h.field,type:h.type,...pe===void 0?{}:{title:pe},...de===void 0?{}:{scale:de},...fe===void 0?{}:{axis:fe}},...ue,...w?{color:w}:{},...S?{tooltip:S}:{}}})[0],he,ge=[...f,...p,se];return me?he={transform:ge,layer:[me,ce]}:(he=ce,he.transform.unshift(...ge)),{...o,layer:[he,{transform:m,layer:ne}]}}function aMe(e){let t=oQ(e);return[{op:`q1`,field:e,as:`lower_box_${t}`},{op:`q3`,field:e,as:`upper_box_${t}`}]}function oMe(e,t,n){let r=nMe(e,m3),{continuousAxisChannelDef:i,continuousAxis:a}=tMe(e,r,m3),o=i.field,s=oQ(o),c=rMe(t),l=[...aMe(o),{op:`median`,field:o,as:`mid_box_${s}`},{op:`min`,field:o,as:(c===`min-max`?`lower_whisker_`:`min_`)+s},{op:`max`,field:o,as:(c===`min-max`?`upper_whisker_`:`max_`)+s}],u=c===`min-max`||c===`tukey`?[]:[{calculate:`${nQ(`upper_box_${s}`)} - ${nQ(`lower_box_${s}`)}`,as:`iqr_${s}`},{calculate:`min(${nQ(`upper_box_${s}`)} + ${nQ(`iqr_${s}`)} * ${t}, ${nQ(`max_${s}`)})`,as:`upper_whisker_${s}`},{calculate:`max(${nQ(`lower_box_${s}`)} - ${nQ(`iqr_${s}`)} * ${t}, ${nQ(`min_${s}`)})`,as:`lower_whisker_${s}`}],{[a]:d,...f}=e.encoding,{customTooltipWithoutAggregatedField:p,filteredEncoding:m}=$je(f),{bins:h,timeUnits:g,aggregate:_,groupby:v,encoding:y}=qje(m,n),b=r===`vertical`?`horizontal`:`vertical`,x=r;return{bins:h,timeUnits:g,transform:[...h,...g,{aggregate:[..._,...l],groupby:v},...u],groupby:v,aggregate:_,continuousAxisChannelDef:i,continuousAxis:a,encodingWithoutContinuousAxis:y,ticksOrient:b,boxOrient:x,customTooltipWithoutAggregatedField:p}}function sMe(e,{config:t}){e={...e,encoding:I1(e.encoding,t)};let{transform:n,continuousAxisChannelDef:r,continuousAxis:i,encodingWithoutContinuousAxis:a,ticksOrient:o,markDef:s,outerSpec:c,tooltipEncoding:l}=fMe(e,h3,t);delete a.size;let u=B1(s,i,r,a,t.errorbar),d=s.thickness,f=s.size,p={type:`tick`,orient:o,aria:!1,...d===void 0?{}:{thickness:d},...f===void 0?{}:{size:f}},m=[...u({partName:`ticks`,mark:p,positionPrefix:`lower`,extraEncoding:l}),...u({partName:`ticks`,mark:p,positionPrefix:`upper`,extraEncoding:l}),...u({partName:`rule`,mark:{type:`rule`,ariaRoleDescription:`errorbar`,...d===void 0?{}:{size:d}},positionPrefix:`lower`,endPositionPrefix:`upper`,extraEncoding:l})];return{...c,transform:n,...m.length>1?{layer:m}:{...m[0]}}}function cMe(e,t){let{encoding:n}=e;if(lMe(n))return{orient:nMe(e,t),inputType:`raw`};let r=uMe(n),i=dMe(n),a=n.x,o=n.y;if(r){if(i)throw Error(`${t} cannot be both type aggregated-upper-lower and aggregated-error`);let e=n.x2,r=n.y2;if(h1(e)&&h1(r))throw Error(`${t} cannot have both x2 and y2`);if(h1(e)){if(p1(a))return{orient:`horizontal`,inputType:`aggregated-upper-lower`};throw Error(`Both x and x2 have to be quantitative in ${t}`)}else if(h1(r)){if(p1(o))return{orient:`vertical`,inputType:`aggregated-upper-lower`};throw Error(`Both y and y2 have to be quantitative in ${t}`)}throw Error(`No ranged axis`)}else{let e=n.xError,r=n.xError2,i=n.yError,s=n.yError2;if(h1(r)&&!h1(e))throw Error(`${t} cannot have xError2 without xError`);if(h1(s)&&!h1(i))throw Error(`${t} cannot have yError2 without yError`);if(h1(e)&&h1(i))throw Error(`${t} cannot have both xError and yError with both are quantiative`);if(h1(e)){if(p1(a))return{orient:`horizontal`,inputType:`aggregated-error`};throw Error(`All x, xError, and xError2 (if exist) have to be quantitative`)}else if(h1(i)){if(p1(o))return{orient:`vertical`,inputType:`aggregated-error`};throw Error(`All y, yError, and yError2 (if exist) have to be quantitative`)}throw Error(`No ranged axis`)}}function lMe(e){return(h1(e.x)||h1(e.y))&&!h1(e.x2)&&!h1(e.y2)&&!h1(e.xError)&&!h1(e.xError2)&&!h1(e.yError)&&!h1(e.yError2)}function uMe(e){return h1(e.x2)||h1(e.y2)}function dMe(e){return h1(e.xError)||h1(e.xError2)||h1(e.yError)||h1(e.yError2)}function fMe(e,t,n){let{mark:r,encoding:i,params:a,projection:o,...s}=e,c=U$(r)?r:{type:r};a&&X(gke(t));let{orient:l,inputType:u}=cMe(e,t),{continuousAxisChannelDef:d,continuousAxisChannelDef2:f,continuousAxisChannelDefError:p,continuousAxisChannelDefError2:m,continuousAxis:h}=tMe(e,l,t),{errorBarSpecificAggregate:g,postAggregateCalculates:_,tooltipSummary:v,tooltipTitleWithFieldName:y}=pMe(c,d,f,p,m,u,t,n),{[h]:b,[h===`x`?`x2`:`y2`]:x,[h===`x`?`xError`:`yError`]:S,[h===`x`?`xError2`:`yError2`]:C,...w}=i,{bins:T,timeUnits:E,aggregate:D,groupby:O,encoding:k}=qje(w,n),A=[...D,...g],j=u===`raw`?O:[],M=R1(v,d,k,y);return{transform:[...s.transform??[],...T,...E,...A.length===0?[]:[{aggregate:A,groupby:j}],..._],groupby:j,continuousAxisChannelDef:d,continuousAxis:h,encodingWithoutContinuousAxis:k,ticksOrient:l===`vertical`?`horizontal`:`vertical`,markDef:c,outerSpec:s,tooltipEncoding:M}}function pMe(e,t,n,r,i,a,o,s){let c=[],l=[],u=t.field,d,f=!1;if(a===`raw`){let t=e.center?e.center:e.extent?e.extent===`iqr`?`median`:`mean`:s.errorbar.center,n=e.extent?e.extent:t===`mean`?`stderr`:`iqr`;if(t===`median`!=(n===`iqr`)&&X(lAe(t,n,o)),n===`stderr`||n===`stdev`)c=[{op:n,field:u,as:`extent_${u}`},{op:t,field:u,as:`center_${u}`}],l=[{calculate:`${nQ(`center_${u}`)} + ${nQ(`extent_${u}`)}`,as:`upper_${u}`},{calculate:`${nQ(`center_${u}`)} - ${nQ(`extent_${u}`)}`,as:`lower_${u}`}],d=[{fieldPrefix:`center_`,titlePrefix:$Z(t)},{fieldPrefix:`upper_`,titlePrefix:mMe(t,n,`+`)},{fieldPrefix:`lower_`,titlePrefix:mMe(t,n,`-`)}],f=!0;else{let e,t,r;n===`ci`?(e=`mean`,t=`ci0`,r=`ci1`):(e=`median`,t=`q1`,r=`q3`),c=[{op:t,field:u,as:`lower_${u}`},{op:r,field:u,as:`upper_${u}`},{op:e,field:u,as:`center_${u}`}],d=[{fieldPrefix:`upper_`,titlePrefix:x1({field:u,aggregate:r,type:`quantitative`},s,{allowDisabling:!1})},{fieldPrefix:`lower_`,titlePrefix:x1({field:u,aggregate:t,type:`quantitative`},s,{allowDisabling:!1})},{fieldPrefix:`center_`,titlePrefix:x1({field:u,aggregate:e,type:`quantitative`},s,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&X(cAe(e.center,e.extent)),a===`aggregated-upper-lower`?(d=[],l=[{calculate:nQ(n.field),as:`upper_${u}`},{calculate:nQ(u),as:`lower_${u}`}]):a===`aggregated-error`&&(d=[{fieldPrefix:``,titlePrefix:u}],l=[{calculate:`${nQ(u)} + ${nQ(r.field)}`,as:`upper_${u}`}],i?l.push({calculate:`${nQ(u)} + ${nQ(i.field)}`,as:`lower_${u}`}):l.push({calculate:`${nQ(u)} - ${nQ(r.field)}`,as:`lower_${u}`}));for(let e of l)d.push({fieldPrefix:e.as.substring(0,6),titlePrefix:aQ(aQ(e.calculate,`datum['`,``),`']`,``)})}return{postAggregateCalculates:l,errorBarSpecificAggregate:c,tooltipSummary:d,tooltipTitleWithFieldName:f}}function mMe(e,t,n){return`${$Z(e)} ${n} ${t}`}function hMe(e,{config:t}){e={...e,encoding:I1(e.encoding,t)};let{transform:n,continuousAxisChannelDef:r,continuousAxis:i,encodingWithoutContinuousAxis:a,markDef:o,outerSpec:s,tooltipEncoding:c}=fMe(e,g3,t),l=o,u=B1(l,i,r,a,t.errorband),d=e.encoding.x!==void 0&&e.encoding.y!==void 0,f={type:d?`area`:`rect`},p={type:d?`line`:`rule`},m={...l.interpolate?{interpolate:l.interpolate}:{},...l.tension&&l.interpolate?{tension:l.tension}:{}};return d?(f={...f,...m,ariaRoleDescription:`errorband`},p={...p,...m,aria:!1}):l.interpolate?X(dAe(`interpolate`)):l.tension&&X(dAe(`tension`)),{...s,transform:n,layer:[...u({partName:`band`,mark:f,positionPrefix:`lower`,endPositionPrefix:`upper`,extraEncoding:c}),...u({partName:`borders`,mark:p,positionPrefix:`lower`,extraEncoding:c}),...u({partName:`borders`,mark:p,positionPrefix:`upper`,extraEncoding:c})]}}function H1(e,t,n){let r=new p3(e,t);_3[e]={normalizer:r,parts:n}}function gMe(){return $(_3)}function U1(e){return e===`legend`||!!e?.legend}function W1(e){return U1(e)&&Dh(e)}function G1(e){return!!e?.select}function _Me(e){let t=[];for(let n of e||[]){if(G1(n))continue;let{expr:e,bind:r,...i}=n;if(r&&e){let n={...i,bind:r,init:e};t.push(n)}else{let n={...i,...e?{update:e}:{},...r?{bind:r}:{}};t.push(n)}}return t}function vMe(e){return q1(e)||J1(e)||K1(e)}function K1(e){return Y(e,`concat`)}function q1(e){return Y(e,`vconcat`)}function J1(e){return Y(e,`hconcat`)}function yMe({step:e,offsetIsDiscrete:t}){return t?e.for??`offset`:`position`}function Y1(e){return Y(e,`step`)}function bMe(e){return Y(e,`view`)||Y(e,`width`)||Y(e,`height`)}function xMe(e,t,n){let r=n[t],i={},{spacing:a,columns:o}=r;a!==void 0&&(i.spacing=a),o!==void 0&&(a1(e)&&!r1(e.facet)||K1(e))&&(i.columns=o),q1(e)&&(i.columns=1);for(let t of Gze)if(e[t]!==void 0)if(t===`spacing`){let n=e[t];i[t]=yg(n)?n:{row:n.row??a,column:n.column??a}}else i[t]=e[t];return i}function X1(e,t){return e[t]??e[t===`width`?`continuousWidth`:`continuousHeight`]}function Z1(e,t){let n=Q1(e,t);return Y1(n)?n.step:w3}function Q1(e,t){return cQ(e[t]??e[t===`width`?`discreteWidth`:`discreteHeight`],{step:e.step})}function SMe(e={}){return{signals:[{name:`color`,value:Dh(e)?{...D3,...e}:D3}],mark:{color:{signal:`color.blue`}},rule:{color:{signal:`color.gray0`}},text:{color:{signal:`color.gray0`}},style:{"guide-label":{fill:{signal:`color.gray0`}},"guide-title":{fill:{signal:`color.gray0`}},"group-title":{fill:{signal:`color.gray0`}},"group-subtitle":{fill:{signal:`color.gray0`}},cell:{stroke:{signal:`color.gray8`}}},axis:{domainColor:{signal:`color.gray13`},gridColor:{signal:`color.gray8`},tickColor:{signal:`color.gray13`}},range:{category:[{signal:`color.blue`},{signal:`color.orange`},{signal:`color.red`},{signal:`color.teal`},{signal:`color.green`},{signal:`color.yellow`},{signal:`color.purple`},{signal:`color.pink`},{signal:`color.brown`},{signal:`color.grey8`}]}}}function CMe(e){return{signals:[{name:`fontSize`,value:Dh(e)?{...E3,...e}:E3}],text:{fontSize:{signal:`fontSize.text`}},style:{"guide-label":{fontSize:{signal:`fontSize.guideLabel`}},"guide-title":{fontSize:{signal:`fontSize.guideTitle`}},"group-title":{fontSize:{signal:`fontSize.groupTitle`}},"group-subtitle":{fontSize:{signal:`fontSize.groupSubtitle`}}}}}function wMe(e){return{text:{font:e},style:{"guide-label":{font:e},"guide-title":{font:e},"group-title":{font:e},"group-subtitle":{font:e}}}}function TMe(e){let t=$(e||{}),n={};for(let r of t){let t=e[r];n[r]=N1(t)?QQ(t):$Q(t)}return n}function EMe(e){let t=$(e),n={};for(let r of t)n[r]=TMe(e[r]);return n}function DMe(e={}){let{color:t,font:n,fontSize:r,selection:i,...a}=e,o=kh({},b2(Kze),n?wMe(n):{},t?SMe(t):{},r?CMe(r):{},a||{});i&&Ah(o,`selection`,i,!0);let s=FZ(o,qze);for(let e of[`background`,`lineBreak`,`padding`])o[e]&&(s[e]=$Q(o[e]));for(let e of r3)o[e]&&(s[e]=GQ(o[e]));for(let e of f3)o[e]&&(s[e]=TMe(o[e]));for(let e of b3)o[e]&&(s[e]=GQ(o[e]));if(o.legend&&(s.legend=GQ(o.legend)),o.scale){let{invalid:e,...t}=o.scale,n=GQ(e,{level:1});s.scale={...GQ(t),...$(n).length>0?{invalid:n}:{}}}return o.style&&(s.style=EMe(o.style)),o.title&&(s.title=GQ(o.title)),o.view&&(s.view=GQ(o.view)),s}function OMe(e){e=b2(e);for(let t of Yze)delete e[t];if(e.axis)for(let t in e.axis)N1(e.axis[t])&&delete e.axis[t];if(e.legend)for(let t of zze)delete e.legend[t];if(e.mark){for(let t of t3)delete e.mark[t];e.mark.tooltip&&Dh(e.mark.tooltip)&&delete e.mark.tooltip}e.params&&(e.signals=(e.signals||[]).concat(_Me(e.params)),delete e.params);for(let t of Jze){for(let n of t3)delete e[t][n];let n=Xze[t];if(n)for(let r of n)delete e[t][r];AMe(e,t)}for(let t of gMe())delete e[t];kMe(e);for(let t in e)Dh(e[t])&&qZ(e[t])&&delete e[t];return qZ(e)?void 0:e}function kMe(e){let{titleMarkConfig:t,subtitleMarkConfig:n,subtitle:r}=KQ(e.title);qZ(t)||(e.style[`group-title`]={...e.style[`group-title`],...t}),qZ(n)||(e.style[`group-subtitle`]={...e.style[`group-subtitle`],...n}),qZ(r)?delete e.title:e.title=r}function AMe(e,t,n,r){let i=e[t];t===`view`&&(n=`cell`);let a={...i,...e.style[n??t]};qZ(a)||(e.style[n??t]=a),delete e[t]}function $1(e){return Y(e,`layer`)}function jMe(e){return Y(e,`repeat`)}function MMe(e){return!H(e.repeat)&&Y(e.repeat,`layer`)}function NMe(e){return fg(Zze,e)}function e0(e){return Z(e)&&d1(e)===`quantitative`&&!e.bin}function PMe(e,t,{orient:n,type:r}){let i=t===`x`?`y`:`radius`,a=t===`x`&&[`bar`,`area`].includes(r),o=e[t],s=e[i];if(Z(o)&&Z(s)){if(e0(o)&&e0(s)){if(o.stack)return t;if(s.stack)return i;let e=Z(o)&&!!o.aggregate;if(e!==(Z(s)&&!!s.aggregate))return e?t:i;if(a){if(n===`vertical`)return i;if(n===`horizontal`)return t}}else if(e0(o))return t;else if(e0(s))return i}else if(e0(o))return a&&n===`vertical`?void 0:t;else if(e0(s))return a&&n===`horizontal`?void 0:i}function FMe(e){switch(e){case`x`:return`y`;case`y`:return`x`;case`theta`:return`radius`;case`radius`:return`theta`}}function IMe(e,t){let n=U$(e)?e:{type:e},r=n.type;if(!Qze.has(r))return null;let i=PMe(t,`x`,n)||PMe(t,`theta`,n);if(!i)return null;let a=t[i],o=Z(a)?Q(a,{}):void 0,s=FMe(i),c=[],l=new Set;if(t[s]){let e=t[s],n=Z(e)?Q(e,{}):void 0;n&&n!==o&&(c.push(s),l.add(n))}let u=s===`x`?`xOffset`:`yOffset`,d=t[u],f=Z(d)?Q(d,{}):void 0;f&&f!==o&&(c.push(u),l.add(f));let p=yRe.reduce((e,n)=>{if(n!==`tooltip`&&F1(t,n)){let r=t[n];for(let t of ng(r)){let r=T1(t);if(r.aggregate)continue;let i=Q(r,{});(!i||!l.has(i))&&e.push({channel:n,fieldDef:r})}}return e},[]),m;return a.stack===void 0?$ze.has(r)&&(m=`zero`):m=_g(a.stack)?a.stack?`zero`:null:a.stack,!m||!NMe(m)||Kje(t)&&p.length===0?null:(a?.scale?.type&&a?.scale?.type!==R4.LINEAR&&a?.stack&&X(aAe(a.scale.type)),h1(t[wQ(i)])?(a.stack!==void 0&&X(iAe(i)),null):(Z(a)&&a.aggregate&&!IRe.has(a.aggregate)&&X(oAe(a.aggregate)),{groupbyChannels:c,groupbyFields:l,fieldChannel:i,impute:a.impute!==null&&V$(r),stackBy:p,offset:m}))}function LMe(e,t,n){let r=GQ(e),i=a$(`orient`,r,n);if(r.orient=VMe(r.type,t,i),i!==void 0&&i!==r.orient&&X(Hke(r.orient,i)),r.type===`bar`&&r.orient){let e=a$(`cornerRadiusEnd`,r,n);if(e!==void 0){let n=r.orient===`horizontal`&&t.x2||r.orient===`vertical`&&t.y2?[`cornerRadius`]:Dze[r.orient];for(let t of n)r[t]=e;r.cornerRadiusEnd!==void 0&&delete r.cornerRadiusEnd}}let a=a$(`opacity`,r,n),o=a$(`fillOpacity`,r,n);return a===void 0&&o===void 0&&(r.opacity=zMe(r.type,t)),a$(`cursor`,r,n)===void 0&&(r.cursor=RMe(r,t,n)),r}function RMe(e,t,n){return t.href||e.href||a$(`href`,e,n)?`pointer`:e.cursor}function zMe(e,t){if(RZ([J4,Z4,Q4,$4],e)&&!Kje(t))return k3}function BMe(e,t,{graticule:n}){if(n)return!1;let r=o$(`filled`,e,t),i=e.type;return cQ(r,i!==J4&&i!==q4&&i!==Y4)}function VMe(e,t,n){switch(e){case J4:case Q4:case $4:case yze:case vze:return}let{x:r,y:i,x2:a,y2:o}=t;switch(e){case X4:case K4:if(Z(r)&&(BQ(r.bin)||Z(i)&&i.aggregate&&!r.aggregate))return`vertical`;if(Z(i)&&(BQ(i.bin)||Z(r)&&r.aggregate&&!i.aggregate))return`horizontal`;if(o||a){if(n)return n;if(!a)return(Z(r)&&r.type===N4&&!zQ(r.bin)||m1(r))&&Z(i)&&BQ(i.bin)?`horizontal`:`vertical`;if(!o)return(Z(i)&&i.type===N4&&!zQ(i.bin)||m1(i))&&Z(r)&&BQ(r.bin)?`vertical`:`horizontal`}case Y4:if(a&&!(Z(r)&&BQ(r.bin))&&o&&!(Z(i)&&BQ(i.bin)))return;case G4:if(o)return Z(i)&&BQ(i.bin)?`horizontal`:`vertical`;if(a)return Z(r)&&BQ(r.bin)?`vertical`:`horizontal`;if(e===Y4){if(r&&!i)return`vertical`;if(i&&!r)return`horizontal`}case q4:case Z4:{let t=Eje(r),a=Eje(i);if(n)return n;if(t&&!a)return e===`tick`?`vertical`:`horizontal`;if(!t&&a)return e===`tick`?`horizontal`:`vertical`;if(t&&a)return`vertical`;{let e=g1(r)&&r.type===F4,t=g1(i)&&i.type===F4;if(e&&!t)return`vertical`;if(!e&&t)return`horizontal`}return}}return`vertical`}function HMe(e){let{point:t,line:n,...r}=e;return $(r).length>1?r:r.type}function UMe(e){for(let t of[`line`,`area`,`rule`,`trail`])e[t]&&(e={...e,[t]:FZ(e[t],[`point`,`line`])});return e}function t0(e,t={},n){return e.point===`transparent`?{opacity:0}:e.point?Dh(e.point)?e.point:{}:e.point===void 0?t.point||n.shape?Dh(t.point)?t.point:{}:void 0:null}function WMe(e,t={}){return e.line?e.line===!0?{}:e.line:e.line===void 0?t.line?t.line===!0?{}:t.line:void 0:null}function GMe(e,t){return t?r1(e)?YMe(e,t):KMe(e,t):e}function n0(e,t){return t?YMe(e,t):e}function r0(e,t,n){let r=t[e];if(bje(r)){if(r.repeat in n)return{...t,[e]:n[r.repeat]};X(bke(r.repeat));return}return t}function KMe(e,t){if(e=r0(`field`,e,t),e!==void 0){if(e===null)return null;if(o1(e)&&n1(e.sort)){let n=r0(`field`,e.sort,t);e={...e,...n?{sort:n}:{}}}return e}}function qMe(e,t){if(Z(e))return KMe(e,t);{let n=r0(`datum`,e,t);return n!==e&&!n.type&&(n.type=`nominal`),n}}function JMe(e,t){if(h1(e)){let n=qMe(e,t);if(n)return n;if(c1(e))return{condition:e.condition}}else{if(u1(e)){let n=qMe(e.condition,t);if(n)return{...e,condition:n};{let{condition:t,...n}=e;return n}}return e}}function YMe(e,t){let n={};for(let r in e)if(Y(e,r)){let i=e[r];if(H(i))n[r]=i.map(e=>JMe(e,t)).filter(e=>e);else{let e=JMe(i,t);e!==void 0&&(n[r]=e)}}return n}function XMe({parentEncoding:e,encoding:t={},layer:n}){let r={};if(e){let i=new Set([...$(e),...$(t)]);for(let a of i){let i=t[a],o=e[a];if(h1(i)){let e={...o,...i};r[a]=e}else u1(i)?r[a]={...i,condition:{...o,...i.condition}}:i||i===null?r[a]=i:(n||_1(o)||JQ(o)||h1(o)||H(o))&&(r[a]=o)}}else r=t;return!r||qZ(r)?void 0:r}function ZMe(e){let{parentProjection:t,projection:n}=e;return t&&n&&X(Oke({parentProjection:t,projection:n})),n??t}function i0(e){return Y(e,`filter`)}function QMe(e){return Y(e,`stop`)}function $Me(e){return Y(e,`lookup`)}function eNe(e){return Y(e,`data`)}function tNe(e){return Y(e,`param`)}function nNe(e){return Y(e,`pivot`)}function rNe(e){return Y(e,`density`)}function iNe(e){return Y(e,`quantile`)}function aNe(e){return Y(e,`regression`)}function oNe(e){return Y(e,`loess`)}function sNe(e){return Y(e,`sample`)}function cNe(e){return Y(e,`window`)}function lNe(e){return Y(e,`joinaggregate`)}function uNe(e){return Y(e,`flatten`)}function dNe(e){return Y(e,`calculate`)}function fNe(e){return Y(e,`bin`)}function pNe(e){return Y(e,`impute`)}function mNe(e){return Y(e,`timeUnit`)}function hNe(e){return Y(e,`aggregate`)}function gNe(e){return Y(e,`stack`)}function _Ne(e){return Y(e,`fold`)}function vNe(e){return Y(e,`extent`)&&!Y(e,`density`)&&!Y(e,`regression`)}function yNe(e){return e.map(e=>i0(e)?{filter:MZ(e.filter,BAe)}:e)}function bNe(e,t){let{transform:n,...r}=e;if(n){let e=n.map(e=>{if(i0(e))return{filter:a0(e,t)};if(fNe(e)&&VQ(e.bin))return{...e,bin:SNe(e.bin)};if($Me(e)){let{selection:t,...n}=e.from;return t?{...e,from:{param:t,...n}}:e}return e});return{...r,transform:e}}return e}function xNe(e,t){let n=b2(e);if(Z(n)&&VQ(n.bin)&&(n.bin=SNe(n.bin)),v1(n)&&n.scale?.domain?.selection){let{selection:e,...t}=n.scale.domain;n.scale.domain={...t,...e?{param:e}:{}}}if(c1(n))if(H(n.condition))n.condition=n.condition.map(e=>{let{selection:n,param:r,test:i,...a}=e;return r?e:{...a,test:a0(e,t)}});else{let{selection:e,param:r,test:i,...a}=xNe(n.condition,t);n.condition=r?n.condition:{...a,test:a0(n.condition,t)}}return n}function SNe(e){let t=e.extent;if(t?.selection){let{selection:n,...r}=t;return{...e,extent:{...r,param:n}}}return e}function a0(e,t){let n=e=>MZ(e,e=>{let n={param:e,empty:t.emptySelections[e]??!0};return t.selectionPredicates[e]??=[],t.selectionPredicates[e].push(n),n});return e.selection?n(e.selection):MZ(e.test||e.filter,e=>e.selection?n(e.selection):e)}function CNe(e,t){return e.name?{...t,path:(t.path??[]).concat(e.name)}:t}function wNe(e,t){t===void 0&&(t=DMe(e.config));let n=TNe(e,t),{width:r,height:i}=e,a=DNe(n,{width:r,height:i,autosize:e.autosize},t);return{...n,...a?{autosize:a}:{}}}function TNe(e,t={}){let n={config:t};return oBe.map(iBe.map(aBe.map(e,n),n),n)}function ENe(e){return xg(e)?{type:e}:e??{}}function DNe(e,t,n){let{width:r,height:i}=t,a=P1(e)||$1(e),o={};a?r==`container`&&i==`container`?(o.type=`fit`,o.contains=`padding`):r==`container`?(o.type=`fit-x`,o.contains=`padding`):i==`container`&&(o.type=`fit-y`,o.contains=`padding`):(r==`container`&&(X(uke(`width`)),r=void 0),i==`container`&&(X(uke(`height`)),i=void 0));let s={type:`pad`,...o,...n?ENe(n.autosize):{},...ENe(e.autosize)};if(s.type===`fit`&&!a&&(X(VRe),s.type=`pad`),r==`container`&&!(s.type==`fit`||s.type==`fit-x`)&&X(dke(`width`)),i==`container`&&!(s.type==`fit`||s.type==`fit-y`)&&X(dke(`height`)),!mQ(s,{type:`pad`}))return s}function ONe(e){return[`fit`,`fit-x`,`fit-y`].includes(e)}function kNe(e){return e?`fit-${kQ(e)}`:`fit`}function ANe(e,t){let n={};for(let t of sBe)e&&e[t]!==void 0&&(n[t]=$Q(e[t]));return t&&(n.params=e.params),n}function o0(e){return{explicit:!0,value:e}}function s0(e){return{explicit:!1,value:e}}function jNe(e){return(t,n,r,i)=>{let a=e(t.value,n.value);return a>0?t:a<0?n:c0(t,n,r,i)}}function c0(e,t,n,r){return e.explicit&&t.explicit&&X($ke(n,r,e.value,t.value)),e}function l0(e,t,n,r,i=c0){return e===void 0||e.value===void 0?t:e.explicit&&!t.explicit?e:t.explicit&&!e.explicit?t:mQ(e.value,t.value)?e:i(e,t,n,r)}function u0(e){return Y(e,`url`)}function d0(e){return Y(e,`values`)}function MNe(e){return Y(e,`name`)&&!u0(e)&&!d0(e)&&!f0(e)}function f0(e){return e&&(NNe(e)||PNe(e)||p0(e))}function NNe(e){return Y(e,`sequence`)}function PNe(e){return Y(e,`sphere`)}function p0(e){return Y(e,`graticule`)}function FNe({invalid:e,isPath:t}){switch(tje(e,{isPath:t})){case`filter`:return{marks:`exclude-invalid-values`,scales:`exclude-invalid-values`};case`break-paths-show-domains`:return{marks:t?`include-invalid-values`:`exclude-invalid-values`,scales:`include-invalid-values`};case`break-paths-filter-domains`:return{marks:t?`include-invalid-values`:`exclude-invalid-values`,scales:`exclude-invalid-values`};case`show`:return{marks:`include-invalid-values`,scales:`include-invalid-values`}}}function INe(e){let{marks:t,scales:n}=FNe(e);return t===n?M3.Main:n===`include-invalid-values`?M3.PreFilterInvalid:M3.PostFilterInvalid}function m0(e){return e.as!==void 0}function LNe(e){return`${e}_end`}function RNe({timeUnit:e,field:t,reverse:n}){let{unit:r,utc:i}=e,{part:a,step:o}=PAe(EAe(r),e.step);return`${i?`utcOffset`:`timeOffset`}('${a}', ${nQ(t)}, ${n?-o:o})`}function zNe([e,t],n,r){if(n!==void 0&&n!==.5){let i=nQ(e),a=nQ(t);return[{type:`formula`,expr:BNe([RNe({timeUnit:r,field:e,reverse:!0}),i],n+.5),as:`${e}_${I3}`},{type:`formula`,expr:BNe([i,a],n+.5),as:`${e}_${L3}`}]}return[]}function BNe([e,t],n){return`${1-n} * ${e} + ${n} * ${t}`}function VNe(e){let{signals:t,hasLegend:n,index:r,...i}=e;return i.field=iQ(i.field),i}function h0(e,t=!0,n=yh){if(H(e)){let r=e.map(e=>h0(e,t,n));return t?`[${r.join(`, `)}]`:r}else if(y$(e))return n(t?x$(e):SAe(e));return t?n(hQ(e)):e}function HNe(e,t){for(let n of x2(e.component.selection??{})){let r=n.name,i=`${r}${l6}, ${n.resolve===`global`?`true`:`{unit: ${j0(e)}}`}`;for(let r of d6)r.defined(n)&&(r.signals&&(t=r.signals(e,n,t)),r.modifyExpr&&(i=r.modifyExpr(e,n,i)));t.push({name:r+SBe,on:[{events:{signal:n.name+l6},update:`modify(${W(n.name+c6)}, ${i})`}]})}return g0(t)}function UNe(e,t){if(e.component.selection&&$(e.component.selection).length){let n=W(e.getName(`cell`));t.unshift({name:`facet`,value:{},on:[{events:zG(`pointermove`,`scope`),update:`isTuple(facet) ? facet : group(${n}).datum`}]})}return g0(t)}function WNe(e,t){let n=!1;for(let r of x2(e.component.selection??{})){let i=r.name,a=W(i+c6);if(t.filter(e=>e.name===i).length===0){let e=r.resolve===`global`?`union`:r.resolve,n=r.type===`point`?`, true, true)`:`)`;t.push({name:r.name,update:`${u6}(${a}, ${W(e)}${n}`})}n=!0;for(let n of d6)n.defined(r)&&n.topLevelSignals&&(t=n.topLevelSignals(e,r,t))}return n&&t.filter(e=>e.name===`unit`).length===0&&t.unshift({name:`unit`,value:{},on:[{events:`pointermove`,update:`isTuple(group()) ? group() : unit`}]}),g0(t)}function GNe(e,t){let n=[],r=[],i=j0(e,{escape:!1});for(let a of x2(e.component.selection??{})){let o={name:a.name+c6};if(a.project.hasSelectionId&&(o.transform=[{type:`collect`,sort:{field:S3}}]),a.init){let e=a.project.items.map(VNe);o.values=a.project.hasSelectionId?a.init.map(e=>({unit:i,[S3]:h0(e,!1)[0]})):a.init.map(t=>({unit:i,fields:e,values:h0(t,!1)}))}if([...n,...t].filter(e=>e.name===a.name+c6).length||n.push(o),N0(a)&&t.length){let n=e.lookupDataSource(e.getDataName(M3.Main)),i=t.find(e=>e.name===n),a=i.transform.find(e=>e.type===`filter`&&e.expr.includes(`vlSelectionTest`));if(a){i.transform=i.transform.filter(e=>e!==a);let e={name:i.name+z3,source:i.name,transform:[a]};r.push(e)}}}return n.concat(t,r)}function KNe(e,t){for(let n of x2(e.component.selection??{}))for(let r of d6)r.defined(n)&&r.marks&&(t=r.marks(e,n,t));return t}function qNe(e,t){for(let n of e.children)c2(n)&&(t=KNe(n,t));return t}function JNe(e,t,n,r){let i=OPe(e,t.param,t);return{signal:L$(n.get(`type`))&&H(r)&&r[0]>r[1]?`isValid(${i}) && reverse(${i})`:i}}function g0(e){return e.map(e=>(e.on&&!e.on.length&&delete e.on,e))}function _0(e,t){return`domain(${W(e.scaleName(t))})`}function v0(e){return e.parent&&d2(e.parent)&&(!e.parent.parent||v0(e.parent.parent))}function YNe(e,t,n,r){let i=!e.hasProjection,a=n.channel,o=n.signals.visual,s=W(i?e.scaleName(a):e.projectionName()),c=e=>`scale(${s}, ${e})`,l=e.getSizeSignalRef(a===O2?`width`:`height`).signal,u=`${a}(unit)`,d=t.events.reduce((e,t)=>[...e,{events:t.between[0],update:`[${u}, ${u}]`},{events:t,update:`[${o}[0], clamp(${u}, 0, ${l})]`}],[]);if(i){let i=n.signals.data,l=q3.defined(t),u=e.getScaleComponent(a),f=u?u.get(`type`):void 0,p=r?{init:h0(r,!0,c)}:{value:[]};return d.push({events:{signal:t.name+Y3},update:L$(f)?`[${c(`${i}[0]`)}, ${c(`${i}[1]`)}]`:`[0, 0]`}),l?[{name:i,on:[]}]:[{name:o,...p,on:d},{name:i,...r?{init:h0(r)}:{},on:[{events:{signal:o},update:`${o}[0] === ${o}[1] ? null : invert(${s}, ${o})`}]}]}else{let e=a===O2?0:1,n=t.name+Z3;return[{name:o,...r?{init:`[${n}[0][${e}], ${n}[1][${e}]]`}:{value:[]},on:d}]}}function y0({model:e,channelDef:t,vgChannel:n,invalidValueRef:r,mainRefFn:i}){let a=c1(t)&&t.condition,o=[];a&&(o=ng(a).map(t=>{let n=i(t);if(yje(t)){let{param:r,empty:i}=t;return{test:DPe(e,{param:r,empty:i}),...n}}else return{test:F0(e,t.test),...n}})),r!==void 0&&o.push(r);let s=i(t);return s!==void 0&&o.push(s),o.length>1||o.length===1&&o[0].test?{[n]:o}:o.length===1?{[n]:o[0]}:{}}function b0(e,t=`text`){let n=e.encoding[t];return y0({model:e,channelDef:n,vgChannel:t,mainRefFn:t=>x0(t,e.config),invalidValueRef:void 0})}function x0(e,t,n=`datum`){if(e){if(_1(e))return t$(e.value);if(h1(e)){let{format:r,formatType:i}=w1(e);return Q$({fieldOrDatumDef:e,format:r,formatType:i,expr:n,config:t})}}}function XNe(e,t={}){let{encoding:n,markDef:r,config:i,stack:a}=e,o=n.tooltip;if(H(o))return{tooltip:QNe({tooltip:o},a,i,t)};{let s=t.reactiveGeom?`datum.datum`:`datum`;return y0({model:e,channelDef:o,vgChannel:`tooltip`,mainRefFn:e=>{let o=$Ne(e,i,s);if(o)return o;if(e===null)return;let c=a$(`tooltip`,r,i);if(c===!0&&(c={content:`encoding`}),xg(c))return{value:c};if(Dh(c))return JQ(c)?c:c.content===`encoding`?QNe(n,a,i,t):{signal:s}},invalidValueRef:void 0})}}function ZNe(e,t,n,{reactiveGeom:r}={}){let i={...n,...n.tooltipFormat},a=new Set,o=r?`datum.datum`:`datum`,s=[];function c(n,r){let c=SQ(r),l=g1(n)?n:{...n,type:e[c].type},u=ng(l.title||C1(l,i)).join(`, `).replaceAll(/"/g,`\\"`),d;if(OQ(r)){let t=r===`x`?`x2`:`y2`,n=T1(e[t]);if(BQ(l.bin)&&n){let e=Q(l,{expr:o}),r=Q(n,{expr:o}),{format:s,formatType:c}=w1(l);d=t1(e,r,s,c,i),a.add(t)}}if((OQ(r)||r===I2||r===P2)&&t&&t.fieldChannel===r&&t.offset===`normalize`){let{format:e,formatType:t}=w1(l);d=Q$({fieldOrDatumDef:l,format:e,formatType:t,expr:o,config:i,normalizeStack:!0}).signal}d??=$Ne(l,i,o).signal,s.push({channel:r,key:u,value:d})}L1(e,(e,t)=>{Z(e)?c(e,t):l1(e)&&c(e.condition,t)});let l={};for(let{channel:e,key:t,value:n}of s)!a.has(e)&&!l[t]&&(l[t]=n);return l}function QNe(e,t,n,{reactiveGeom:r}={}){let i=ZNe(e,t,n,{reactiveGeom:r}),a=S2(i).map(([e,t])=>`"${e}": ${t}`);return a.length>0?{signal:`{${a.join(`, `)}}`}:void 0}function $Ne(e,t,n=`datum`){if(Z(e)&&F$(e.type)&&!e.timeUnit&&!w1(e).format&&!w1(e).formatType){let t=`${n}["${e.field}"]`;return{signal:`isValid(${t}) ? isArray(${t}) ? join(${t}, '\\n') : ${t} : ""+${t}`}}return x0(e,t,n)}function ePe(e){let{markDef:t,config:n}=e,r=a$(`aria`,t,n);return r===!1?{}:{...r?{aria:r}:{},...tPe(e),...nPe(e)}}function tPe(e){let{mark:t,markDef:n,config:r}=e;if(r.aria===!1)return{};let i=a$(`ariaRoleDescription`,n,r);return i==null?fg(zRe,t)?{}:{ariaRoleDescription:{value:t}}:{ariaRoleDescription:{value:i}}}function nPe(e){let{encoding:t,markDef:n,config:r,stack:i}=e,a=t.description;if(a)return y0({model:e,channelDef:a,vgChannel:`description`,mainRefFn:t=>x0(t,e.config),invalidValueRef:void 0});let o=a$(`description`,n,r);if(o!=null)return{description:t$(o)};if(r.aria===!1)return{};let s=ZNe(t,i,r);if(!qZ(s))return{description:{signal:S2(s).filter(([e])=>!e.startsWith(`_`)).map(([e,t])=>[e,t.replaceAll(`\\n`,` `)]).map(([e,t],n)=>`"${n>0?`; `:``}${e}: " + (${t})`).join(` + `)}}}function S0(e,t,n={}){let{markDef:r,encoding:i,config:a}=t,{vgChannel:o}=n,{defaultRef:s,defaultValue:c}=n,l=i[e];s===void 0&&(c??=a$(e,r,a,{vgChannel:o,ignoreVgConfig:!c1(l)}),c!==void 0&&(s=t$(c)));let u={markDef:r,config:a,scaleName:t.scaleName(e),scale:t.getScaleComponent(e)},d=ije({...u,scaleChannel:e,channelDef:l});return y0({model:t,channelDef:l,vgChannel:o??e,invalidValueRef:d,mainRefFn:t=>Y$({...u,channel:e,channelDef:t,stack:null,defaultRef:s})})}function rPe(e,t={filled:void 0}){let{markDef:n,encoding:r,config:i}=e,{type:a}=n,o=t.filled??a$(`filled`,n,i),s=RZ([`bar`,`point`,`circle`,`square`,`geoshape`],a)?`transparent`:void 0,c=a$(o===!0?`color`:void 0,n,i,{vgChannel:`fill`})??i.mark[o===!0&&`color`]??s,l=a$(o===!1?`color`:void 0,n,i,{vgChannel:`stroke`})??i.mark[o===!1&&`color`],u=o?`fill`:`stroke`,d={...c?{fill:t$(c)}:{},...l?{stroke:t$(l)}:{}};return n.color&&(o?n.fill:n.stroke)&&X(Pke(`property`,{fill:`fill`in n,stroke:`stroke`in n})),{...d,...S0(`color`,e,{vgChannel:u,defaultValue:o?c:l}),...S0(`fill`,e,{defaultValue:r.fill?c:void 0}),...S0(`stroke`,e,{defaultValue:r.stroke?l:void 0})}}function iPe(e){let{encoding:t,mark:n}=e,r=t.order;return!V$(n)&&_1(r)?y0({model:e,channelDef:r,vgChannel:`zindex`,mainRefFn:e=>t$(e.value),invalidValueRef:void 0}):{}}function C0({channel:e,markDef:t,encoding:n={},model:r,bandPosition:i}){let a=`${e}Offset`,o=t[a],s=n[a];if((a===`xOffset`||a===`yOffset`)&&s)return{offsetType:`encoding`,offset:Y$({channel:a,channelDef:s,markDef:t,config:r?.config,scaleName:r.scaleName(a),scale:r.getScaleComponent(a),stack:null,defaultRef:t$(o),bandPosition:i})};let c=t[a];return c?{offsetType:`visual`,offset:c}:{}}function w0(e,t,{defaultPos:n,vgChannel:r}){let{encoding:i,markDef:a,config:o,stack:s}=t,c=i[e],l=i[wQ(e)],u=t.scaleName(e),d=t.getScaleComponent(e),{offset:f,offsetType:p}=C0({channel:e,markDef:a,encoding:i,model:t,bandPosition:.5}),m=T0({model:t,defaultPos:n,channel:e,scaleName:u,scale:d}),h=!c&&OQ(e)&&(i.latitude||i.longitude)?{field:t.getName(e)}:aPe({channel:e,channelDef:c,channel2Def:l,markDef:a,config:o,scaleName:u,scale:d,stack:s,offset:f,defaultRef:m,bandPosition:p===`encoding`?0:void 0});return h?{[r||e]:h}:void 0}function aPe(e){let{channel:t,channelDef:n,scaleName:r,stack:i,offset:a,markDef:o}=e;if(h1(n)&&i&&t===i.fieldChannel){if(Z(n)){let e=n.bandPosition;if(e===void 0&&o.type===`text`&&(t===`radius`||t===`theta`)&&(e=.5),e!==void 0)return J$({scaleName:r,fieldOrDatumDef:n,startSuffix:`start`,bandPosition:e,offset:a})}return q$(n,r,{suffix:`end`},{offset:a})}return K$(e)}function T0({model:e,defaultPos:t,channel:n,scaleName:r,scale:i}){let{markDef:a,config:o}=e;return()=>{let s=SQ(n),c=CQ(n),l=a$(n,a,o,{vgChannel:c});if(l!==void 0)return X$(n,l);switch(t){case`zeroOrMin`:return oPe({scaleName:r,scale:i,mode:`zeroOrMin`,mainChannel:s,config:o});case`zeroOrMax`:return oPe({scaleName:r,scale:i,mode:{zeroOrMax:{widthSignal:e.width.signal,heightSignal:e.height.signal}},mainChannel:s,config:o});case`mid`:return{...e[TQ(n)],mult:.5}}}}function oPe({mainChannel:e,config:t,...n}){let r=rje(n),{mode:i}=n;if(r)return r;switch(e){case`radius`:{if(i===`zeroOrMin`)return{value:0};let{widthSignal:e,heightSignal:t}=i.zeroOrMax;return{signal:`min(${e},${t})/2`}}case`theta`:return i===`zeroOrMin`?{value:0}:{signal:`2*PI`};case`x`:return i===`zeroOrMin`?{value:0}:{field:{group:`width`}};case`y`:return i===`zeroOrMin`?{field:{group:`height`}}:{value:0}}}function sPe(e,t,n,r=`middle`){if(e===`radius`||e===`theta`)return CQ(e);let i=e===`x`?`align`:`baseline`,a=a$(i,t,n),o;return JQ(a)?(X(Bke(i)),o=void 0):o=a,e===`x`?gBe[o||(r===`top`?`left`:`center`)]:_Be[o||r]}function E0(e,t,{defaultPos:n,defaultPos2:r,range:i}){return i?cPe(e,t,{defaultPos:n,defaultPos2:r}):w0(e,t,{defaultPos:n})}function cPe(e,t,{defaultPos:n,defaultPos2:r}){let{markDef:i,config:a}=t,o=wQ(e),s=TQ(e),c=lPe(t,r,o);return{...w0(e,t,{defaultPos:n,vgChannel:c[s]?sPe(e,i,a):CQ(e)}),...c}}function lPe(e,t,n){let{encoding:r,mark:i,markDef:a,stack:o,config:s}=e,c=SQ(n),l=TQ(n),u=CQ(n),d=r[c],f=e.scaleName(c),p=e.getScaleComponent(c),{offset:m}=n in r||n in a?C0({channel:n,markDef:a,encoding:r,model:e}):C0({channel:c,markDef:a,encoding:r,model:e});if(!d&&(n===`x2`||n===`y2`)&&(r.latitude||r.longitude)){let t=TQ(n),r=e.markDef[t];return r==null?{[u]:{field:e.getName(n)}}:{[t]:{value:r}}}let h=uPe({channel:n,channelDef:d,channel2Def:r[n],markDef:a,config:s,scaleName:f,scale:p,stack:o,offset:m,defaultRef:void 0});return h===void 0?D0(n,a)||D0(n,{[n]:s$(n,a,s.style),[l]:s$(l,a,s.style)})||D0(n,s[i])||D0(n,s.mark)||{[u]:T0({model:e,defaultPos:t,channel:n,scaleName:f,scale:p})()}:{[u]:h}}function uPe({channel:e,channelDef:t,channel2Def:n,markDef:r,config:i,scaleName:a,scale:o,stack:s,offset:c,defaultRef:l}){return h1(t)&&s&&e.charAt(0)===s.fieldChannel.charAt(0)?q$(t,a,{suffix:`start`},{offset:c}):K$({channel:e,channelDef:n,scaleName:a,scale:o,stack:s,markDef:r,config:i,offset:c,defaultRef:l})}function D0(e,t){let n=TQ(e),r=CQ(e);if(t[r]!==void 0)return{[r]:X$(e,t[r])};if(t[e]!==void 0)return{[r]:X$(e,t[e])};if(t[n]){let r=t[n];if(W$(r))X(Fke(n));else return{[n]:X$(e,r)}}}function O0(e,t){let{config:n,encoding:r,markDef:i}=e,a=i.type,o=wQ(t),s=TQ(t),c=r[t],l=r[o],u=e.getScaleComponent(t),d=u?u.get(`type`):void 0,f=i.orient,p=r[s]??r.size??a$(`size`,i,n,{vgChannel:s}),m=EQ(t),h=a===`bar`&&(t===`x`?f===`vertical`:f===`horizontal`)||a===`tick`&&(t===`y`?f===`vertical`:f===`horizontal`);return Z(c)&&(zQ(c.bin)||BQ(c.bin)||c.timeUnit&&!l)&&!(p&&!W$(p))&&!r[m]&&!I$(d)?mPe({fieldDef:c,fieldDef2:l,channel:t,model:e}):(h1(c)&&I$(d)||h)&&!l?fPe(c,t,e):cPe(t,e,{defaultPos:`zeroOrMax`,defaultPos2:`zeroOrMin`})}function dPe(e,t,n,r,i,a,o){if(W$(i))if(n){let e=n.get(`type`);if(e===`band`){let e=`bandwidth('${t}')`;i.band!==1&&(e=`${i.band} * ${e}`);let n=o$(`minBandSize`,{type:o},r);return{signal:n?`max(${r$(n)}, ${e})`:e}}else i.band!==1&&X(Wke(e))}else return{mult:i.band,field:{group:e}};else if(JQ(i))return i;else if(i)return{value:i};if(n){let e=n.get(`range`);if(YQ(e)&&yg(e.step))return{value:e.step-2}}if(!a){let{bandPaddingInner:t,barBandPaddingInner:n,rectBandPaddingInner:i,tickBandPaddingInner:a}=r.scale,s=cQ(t,o===`tick`?a:o===`bar`?n:i);if(JQ(s))return{signal:`(1 - (${s.signal})) * ${e}`};if(yg(s))return{signal:`${1-s} * ${e}`}}return{value:Z1(r.view,e)-2}}function fPe(e,t,n){let{markDef:r,encoding:i,config:a,stack:o}=n,s=r.orient,c=n.scaleName(t),l=n.getScaleComponent(t),u=TQ(t),d=wQ(t),f=EQ(t),p=n.scaleName(f),m=n.getScaleComponent(DQ(t)),h=r.type===`tick`||s===`horizontal`&&t===`y`||s===`vertical`&&t===`x`,g;(i.size||r.size)&&(h?g=S0(`size`,n,{vgChannel:u,defaultRef:t$(r.size)}):X(Jke(r.type)));let _=!!g,v=Sje({channel:t,fieldDef:e,markDef:r,config:a,scaleType:(l||m)?.get(`type`),useVlSizeChannel:h});g||={[u]:dPe(u,p||c,m||l,a,v,!!e,r.type)};let y=sPe(t,r,a,(l||m)?.get(`type`)===`band`&&W$(v)&&!_?`top`:`middle`),b=y===`xc`||y===`yc`,{offset:x,offsetType:S}=C0({channel:t,markDef:r,encoding:i,model:n,bandPosition:b?.5:0}),C=(b&&S!==`encoding`&&Z(e)&&e.timeUnit&&!i[d]?s1({fieldDef:e,markDef:r,config:a}):void 0)??(b?S===`encoding`?0:.5:JQ(v)?{signal:`(1-${v})/2`}:W$(v)?(1-v.band)/2:0),w=K$({channel:t,channelDef:e,markDef:r,config:a,scaleName:c,scale:l,stack:o,offset:x,defaultRef:T0({model:n,defaultPos:`mid`,channel:t,scaleName:c,scale:l}),bandPosition:C});if(u)return{[y]:w,...g};{let e=CQ(d),t=g[u],n=x?{...t,offset:x}:t;return{[y]:w,[e]:H(w)?[w[0],{...w[1],offset:n}]:{...w,offset:n}}}}function pPe(e,t,n,r,i,a,o){if(gQ(e))return 0;let s=e===`x`||e===`y2`,c=s?-t/2:t/2;if(JQ(n)||JQ(i)||JQ(r)||a){let e=r$(n),t=r$(i),l=r$(r),u=r$(a),d=a?`(${o} < ${u} ? ${s?``:`-`}0.5 * (${u} - (${o})) : ${c})`:c,f=l?`${l} + `:``,p=e?`(${e} ? -1 : 1) * `:``,m=t?`(${t} + ${d})`:d;return{signal:f+p+m}}else return i||=0,r+(n?-i-c:+i+c)}function mPe({fieldDef:e,fieldDef2:t,channel:n,model:r}){let{config:i,markDef:a,encoding:o}=r,s=r.getScaleComponent(n),c=r.scaleName(n),l=s?s.get(`type`):void 0,u=s.get(`reverse`),d=Sje({channel:n,fieldDef:e,markDef:a,config:i,scaleType:l}),f=(r.component.axes[n]?.[0])?.get(`translate`)??.5,p=OQ(n)?a$(`binSpacing`,a,i)??0:0,m=wQ(n),h=CQ(n),g=CQ(m),_=o$(`minBandSize`,a,i),{offset:v}=C0({channel:n,markDef:a,encoding:o,model:r,bandPosition:0}),{offset:y}=C0({channel:m,markDef:a,encoding:o,model:r,bandPosition:0}),b=sje({fieldDef:e,scaleName:c}),x=pPe(n,p,u,f,v,_,b),S=pPe(m,p,u,f,y??v,_,b),C=JQ(d)?{signal:`(1-${d.signal})/2`}:W$(d)?(1-d.band)/2:.5,w=s1({fieldDef:e,fieldDef2:t,markDef:a,config:i});if(zQ(e.bin)||e.timeUnit){let t=e.timeUnit&&w!==.5;return{[g]:hPe({fieldDef:e,scaleName:c,bandPosition:C,offset:S,useRectOffsetField:t}),[h]:hPe({fieldDef:e,scaleName:c,bandPosition:JQ(C)?{signal:`1-${C.signal}`}:1-C,offset:x,useRectOffsetField:t})}}else if(BQ(e.bin)){let n=q$(e,c,{},{offset:S});if(Z(t))return{[g]:n,[h]:q$(t,c,{},{offset:x})};if(VQ(e.bin)&&e.bin.step)return{[g]:n,[h]:{signal:`scale("${c}", ${Q(e,{expr:`datum`})} + ${e.bin.step})`,offset:x}}}X(fAe(m))}function hPe({fieldDef:e,scaleName:t,bandPosition:n,offset:r,useRectOffsetField:i}){return J$({scaleName:t,fieldOrDatumDef:e,bandPosition:n,offset:r,...i?{startSuffix:I3,endSuffix:L3}:{}})}function k0(e,t){let{fill:n=void 0,stroke:r=void 0}=t.color===`include`?rPe(e):{};return{..._Pe(e.markDef,t),...gPe(`fill`,n),...gPe(`stroke`,r),...S0(`opacity`,e),...S0(`fillOpacity`,e),...S0(`strokeOpacity`,e),...S0(`strokeWidth`,e),...S0(`strokeDash`,e),...iPe(e),...XNe(e),...b0(e,`href`),...ePe(e)}}function gPe(e,t){return t?{[e]:t}:{}}function _Pe(e,t){return RRe.reduce((n,r)=>(!vBe.has(r)&&Y(e,r)&&t[r]!==`ignore`&&(n[r]=t$(e[r])),n),{})}function A0(e){let{config:t,markDef:n}=e,r=new Set;if(e.forEachFieldDef((i,a)=>{let o;if(!MQ(a)||!(o=e.getScaleType(a)))return;let s=LQ(i.aggregate);if(nje(G$({scaleChannel:a,markDef:n,config:t,scaleType:o,isCountAggregate:s}))){let t=e.vgField(a,{expr:`datum`,binSuffix:e.stack?.impute?`mid`:void 0});t&&r.add(t)}}),r.size>0)return{defined:{signal:[...r].map(e=>P$(e,!0)).join(` && `)}}}function vPe(e,t){if(t!==void 0)return{[e]:t$(t)}}function yPe(e,t,n){let r=e.fieldDef(t)?.field;for(let i of x2(e.component.selection??{})){let e=i.project.hasField[r]??i.project.hasChannel[t];if(e&&r6.defined(i)){let t=n.get(`selections`)??[];t.push(i.name),n.set(`selections`,t,!1),e.hasLegend=!0}}}function bPe(e,t,n,r,i){let a=t.name,o=a+i6,s=a+a6,c=n.channel,l=q3.defined(t),u=i.find(e=>e.name===n.signals[l?`data`:`visual`]),d=e.getSizeSignalRef(r).signal,f=e.getScaleComponent(c),p=f?.get(`type`),m=f?.get(`reverse`),h=l?c===O2?m?``:`-`:m?`-`:``:``,g=`${o}.extent_${c}`,_=`${h}${s}.${c} / ${l?`${d}`:`span(${g})`}`,v=`${!l||!f?`panLinear`:p===`log`?`panLog`:p===`symlog`?`panSymlog`:p===`pow`?`panPow`:`panLinear`}(${g}, ${_}${l?p===`pow`?`, ${f.get(`exponent`)??1}`:p===`symlog`?`, ${f.get(`constant`)??1}`:``:``})`;u.on.push({events:{signal:s},update:l?v:`clampRange(${v}, 0, ${d})`})}function xPe(e,t,n,r,i){let a=t.name,o=n.channel,s=q3.defined(t),c=i.find(e=>e.name===n.signals[s?`data`:`visual`]),l=e.getSizeSignalRef(r).signal,u=e.getScaleComponent(o),d=u?.get(`type`),f=s?_0(e,o):c.name,p=a+s6,m=`${a}${o6}.${o}`,h=`${!s||!u?`zoomLinear`:d===`log`?`zoomLog`:d===`symlog`?`zoomSymlog`:d===`pow`?`zoomPow`:`zoomLinear`}(${f}, ${m}, ${p}${s?d===`pow`?`, ${u.get(`exponent`)??1}`:d===`symlog`?`, ${u.get(`constant`)??1}`:``:``})`;c.on.push({events:{signal:p},update:s?h:`clampRange(${h}, 0, ${l})`})}function SPe(e){let t=e.parent;for(;t&&!l2(t);)t=t.parent;return t}function j0(e,{escape:t}={escape:!0}){let n=t?W(e.name):e.name,r=SPe(e);if(r){let{facet:e}=r;for(let t of f4)e[t]&&(n+=` + '__facet_${t}_' + (facet[${W(r.vgField(t))}])`)}return n}function M0(e){return x2(e.component.selection??{}).reduce((e,t)=>e||t.project.hasSelectionId,!1)}function CPe(e,t){(xg(t.select)||!t.select.on)&&delete e.events,(xg(t.select)||!t.select.clear)&&delete e.clear,(xg(t.select)||!t.select.toggle)&&delete e.toggle}function N0(e){return e.events?.find(e=>`type`in e&&e.type===`timer`)}function P0(e){let t=[];return e.type===`Identifier`?[e.name]:e.type===`Literal`?[e.value]:(e.type===`MemberExpression`&&(t.push(...P0(e.object)),t.push(...P0(e.property))),t)}function wPe(e){return e.object.type===`MemberExpression`?wPe(e.object):e.object.name===`datum`}function TPe(e){let t=KOe(e),n=new Set;return t.visit(e=>{e.type===`MemberExpression`&&wPe(e)&&n.add(P0(e).slice(1).join(`.`))}),n}function EPe(e,t){let n={},r=e.config.selection;if(!t||!t.length)return n;let i=0;for(let a of t){let t=XZ(a.name),o=a.select,s=xg(o)?o:o.type,c=Dh(o)?b2(o):{type:s},l=r[s];for(let e in l)e===`fields`||e===`encodings`||(e===`mark`&&(c.mark={...l.mark,...c.mark}),(c[e]===void 0||c[e]===!0)&&(c[e]=b2(l[e]??c[e])));let u=n[t]={...c,name:t,type:s,init:a.value,bind:a.bind,events:xg(c.on)?zG(c.on,`scope`):ng(b2(c.on))};if(N0(u)&&(i++,i>1)){delete n[t];continue}let d=b2(a);for(let t of d6)t.defined(u)&&t.parse&&t.parse(e,u,d)}return i>1&&X(qRe),n}function DPe(e,t,n,r=`datum`){let i=xg(t)?t:t.param,a=XZ(i),o=W(a+c6),s;try{s=e.getSelectionComponent(a,i)}catch{return`!!${a}`}if(s.project.timeUnit){let t=n??e.component.data.raw,r=s.project.timeUnit.clone();t.parent?r.insertAsParentOf(t):t.parent=r}let c=`${s.project.hasSelectionId?`vlSelectionIdTest(`:`vlSelectionTest(`}${o}, ${r}${s.resolve===`global`?`)`:`, ${W(s.resolve)})`}`,l=`length(data(${o}))`;return t.empty===!1?`${l} && ${c}`:`!${l} || ${c}`}function OPe(e,t,n){let r=XZ(t),i=n.encoding,a=n.field,o;try{o=e.getSelectionComponent(r,t)}catch{return r}if(!i&&!a)a=o.project.items[0].field,o.project.items.length>1&&X(Ske(a));else if(i&&!a){let e=o.project.items.filter(e=>e.channel===i);!e.length||e.length>1?(a=o.project.items[0].field,X(Cke(e,i,n,a))):a=e[0].field}return`${o.name}[${W(iQ(a))}]`}function kPe(e,t){for(let[n,r]of S2(e.component.selection??{})){let i=e.getName(`lookup_${n}`);e.component.data.outputNodes[i]=r.materialized=new P3(new f6(t,e,{param:n}),i,M3.Lookup,e.component.data.outputNodeRefCounts)}}function F0(e,t,n){return ZZ(t,t=>xg(t)?t:FAe(t)?DPe(e,t,n):zAe(t))}function APe(e,t){if(e)return H(e)&&!qQ(e)?e.map(e=>C1(e,t)).join(`, `):e}function I0(e,t,n,r){e.encode??={},e.encode[t]??={},e.encode[t].update??={},e.encode[t].update[n]=r}function L0(e,t,n,r={header:!1}){let{disable:i,orient:a,scale:o,labelExpr:s,title:c,zindex:l,...u}=e.combine();if(!i){for(let e in u){let n=e,r=jze[n],i=u[n];if(r&&r!==t&&r!==`both`)delete u[n];else if(N1(i)){let{condition:e,...t}=i,r=ng(e),a=l3[n];if(a){let{vgProp:e,part:i}=a;I0(u,i,e,[...r.map(e=>{let{test:t,...n}=e;return{test:F0(null,t),...n}}),t]),delete u[n]}else a===null&&(u[n]={signal:r.map(e=>{let{test:t,...n}=e;return`${F0(null,t)} ? ${n$(n)} : `}).join(``)+n$(t)})}else if(JQ(i)){let e=l3[n];if(e){let{vgProp:t,part:r}=e;I0(u,r,t,i),delete u[n]}}RZ([`labelAlign`,`labelBaseline`],n)&&u[n]===null&&delete u[n]}if(t===`grid`){if(!u.grid)return;if(u.encode){let{grid:e}=u.encode;u.encode={...e?{grid:e}:{}},qZ(u.encode)&&delete u.encode}return{scale:o,orient:a,...u,domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:cQ(l,0)}}else{if(!r.header&&e.mainExtracted)return;if(s!==void 0){let e=s;u.encode?.labels?.update&&JQ(u.encode.labels.update.text)&&(e=aQ(s,`datum.label`,u.encode.labels.update.text.signal)),I0(u,`labels`,`text`,{signal:e})}if(u.labelAlign===null&&delete u.labelAlign,u.encode){for(let t of u3)e.hasAxisPart(t)||delete u.encode[t];qZ(u.encode)&&delete u.encode}let t=APe(c,n);return{scale:o,orient:a,grid:!1,...t?{title:t}:{},...u,...n.aria===!1?{aria:!1}:{},zindex:cQ(l,0)}}}}function jPe(e){let{axes:t}=e.component,n=[];for(let r of g4)if(t[r]){for(let i of t[r])if(!i.get(`disable`)&&!i.get(`gridScale`)){let t=r===`x`?`height`:`width`,i=e.getSizeSignalRef(t).signal;t!==i&&n.push({name:t,update:i})}}return n}function MPe(e,t){let{x:n=[],y:r=[]}=e;return[...n.map(e=>L0(e,`grid`,t)),...r.map(e=>L0(e,`grid`,t)),...n.map(e=>L0(e,`main`,t)),...r.map(e=>L0(e,`main`,t))].filter(e=>e)}function NPe(e,t,n,r){return Object.assign.apply(null,[{},...e.map(e=>{if(e===`axisOrient`){let e=n===`x`?`bottom`:`left`,i=t[n===`x`?`axisBottom`:`axisLeft`]||{},a=t[n===`x`?`axisTop`:`axisRight`]||{},o=new Set([...$(i),...$(a)]),s={};for(let t of o.values())s[t]={signal:`${r.signal} === "${e}" ? ${r$(i[t])} : ${r$(a[t])}`};return s}return t[e]})])}function PPe(e,t,n,r){let i=t===`band`?[`axisDiscrete`,`axisBand`]:t===`point`?[`axisDiscrete`,`axisPoint`]:GAe(t)?[`axisQuantitative`]:t===`time`||t===`utc`?[`axisTemporal`]:[],a=e===`x`?`axisX`:`axisY`,o=JQ(n)?`axisOrient`:`axis${$Z(n)}`,s=[...i,...i.map(e=>a+e.substr(4))],c=[`axis`,o,a];return{vlOnlyAxisConfig:NPe(s,r,e,n),vgAxisConfig:NPe(c,r,e,n),axisConfigStyle:FPe([...c,...s],r)}}function FPe(e,t){let n=[{}];for(let r of e){let e=t[r]?.style;if(e){e=ng(e);for(let r of e)n.push(t.style[r])}}return Object.assign.apply(null,n)}function R0(e,t,n,r={}){let i=c$(e,n,t);if(i!==void 0)return{configFrom:`style`,configValue:i};for(let t of[`vlOnlyAxisConfig`,`vgAxisConfig`,`axisConfigStyle`])if(r[t]?.[e]!==void 0)return{configFrom:t,configValue:r[t][e]};return{}}function IPe(e,t){return!I$(e)&&Z(t)&&!zQ(t?.bin)&&!BQ(t?.bin)}function LPe(e,t){let n=t===`x`?`y`:`x`;if(e.getScaleComponent(n))return e.scaleName(n)}function RPe(e,t,n,r,i){let a=t?.labelAngle;if(a!==void 0)return JQ(a)?a:fQ(a);{let{configValue:a}=R0(`labelAngle`,r,t?.style,i);return a===void 0?n===O2&&RZ([I4,P4],e.type)&&!(Z(e)&&e.timeUnit)?270:void 0:fQ(a)}}function z0(e){return`(((${e.signal} % 360) + 360) % 360)`}function zPe(e,t,n,r){if(e!==void 0)if(n===`x`){if(JQ(e)){let n=z0(e);return{signal:`(45 < ${n} && ${n} < 135) || (225 < ${n} && ${n} < 315) ? "middle" :(${n} <= 45 || 315 <= ${n}) === ${JQ(t)?`(${t.signal} === "top")`:t===`top`} ? "bottom" : "top"`}}if(450;if(a||u){let s=t===`row`?`height`:`width`;return{name:e.getName(`${t}_${n}`),type:`group`,role:`${t}-${n}`,...r.facetFieldDef?{from:{data:e.getName(`${t}_domain`)},sort:$Pe(o,t)}:{},...u&&c?{from:{data:e.getName(`facet_domain_${t}`)}}:{},...a?{title:a}:{},...i.sizeSignal?{encode:{update:{[s]:i.sizeSignal}}}:{},...u?{axes:l}:{}}}}return null}function tFe(e,t){return CBe[t][e]}function nFe(e,t){let n={};for(let r of f4){let i=e[r];if(i?.facetFieldDef){let{titleAnchor:e,titleOrient:a}=U0([`titleAnchor`,`titleOrient`],i.facetFieldDef.header,t,r),o=V0(r,a),s=tFe(e,o);s!==void 0&&(n[o]=s)}}return qZ(n)?void 0:n}function rFe(e,t,n,r,i){let a={};for(let o of r){if(!i[o])continue;let r=H0(o,t?.header,e,n);r!==void 0&&(a[i[o]]=r)}return a}function G0(e){return[...K0(e,`width`),...K0(e,`height`),...K0(e,`childWidth`),...K0(e,`childHeight`)]}function K0(e,t){let n=t===`width`?`x`:`y`,r=e.component.layoutSize.get(t);if(r==null||r===`merged`)return[];let i=e.getSizeSignalRef(t).signal;if(r===`step`){let t=e.getScaleComponent(n);if(t){let r=t.get(`type`),a=t.get(`range`);if(I$(r)&&YQ(a)){let r=e.scaleName(n);return l2(e.parent)&&e.parent.component.resolve.scale[n]===`independent`?[iFe(r,a)]:[iFe(r,a),{name:i,update:aFe(r,t,`domain('${r}').length`)}]}}throw Error(`layout size is step although width/height is not step.`)}else if(r==`container`){let t=i.endsWith(`width`),n=t?`containerSize()[0]`:`containerSize()[1]`,r=`isFinite(${n}) ? ${n} : ${X1(e.config.view,t?`width`:`height`)}`;return[{name:i,init:r,on:[{update:r,events:`window:resize`}]}]}else return[{name:i,value:r}]}function iFe(e,t){let n=`${e}_step`;return JQ(t.step)?{name:n,update:t.step.signal}:{name:n,value:t.step}}function aFe(e,t,n){let r=t.get(`type`),i=t.get(`padding`),a=cQ(t.get(`paddingOuter`),i),o=t.get(`paddingInner`);return o=r===`band`?o===void 0?i:o:1,`bandspace(${n}, ${r$(o)}, ${r$(a)}) * ${e}_step`}function oFe(e){return e===`childWidth`?`width`:e===`childHeight`?`height`:e}function sFe(e,t){return $(e).reduce((n,r)=>({...n,...y0({model:t,channelDef:e[r],vgChannel:r,mainRefFn:e=>t$(e.value),invalidValueRef:void 0})}),{})}function cFe(e,t){if(l2(t))return e===`theta`?`independent`:`shared`;if(d2(t))return`shared`;if(u2(t))return OQ(e)||e===`theta`||e===`radius`?`independent`:`shared`;throw Error(`invalid model type for resolve`)}function q0(e,t){let n=e.scale[t],r=OQ(t)?`axis`:`legend`;return n===`independent`?(e[r][t]===`shared`&&X(tAe(t)),`independent`):e[r][t]||`shared`}function lFe(e,{fieldOrDatumDef:t,model:n,channel:r,legendCmpt:i,legendType:a}){if(a!==`symbol`)return;let{markDef:o,encoding:s,config:c,mark:l}=n,u=o.filled&&l!==`trail`,d={...cke({},n,wze),...rPe(n,{filled:u})},f=i.get(`symbolOpacity`)??c.legend.symbolOpacity,p=i.get(`symbolFillColor`)??c.legend.symbolFillColor,m=i.get(`symbolStrokeColor`)??c.legend.symbolStrokeColor,h=f===void 0?pFe(s.opacity)??o.opacity:void 0;if(d.fill){if(r===`fill`||u&&r===U2)delete d.fill;else if(Y(d.fill,`field`))p?delete d.fill:(d.fill=t$(c.legend.symbolBaseFillColor??`black`),d.fillOpacity=t$(h??1));else if(H(d.fill)){let e=J0(s.fill??s.color)??o.fill??(u&&o.color);e&&(d.fill=t$(e))}}if(d.stroke){if(r===`stroke`||!u&&r===U2)delete d.stroke;else if(Y(d.stroke,`field`)||m)delete d.stroke;else if(H(d.stroke)){let e=cQ(J0(s.stroke||s.color),o.stroke,u?o.color:void 0);e&&(d.stroke={value:e})}}if(r!==Y2){let e=Z(t)&&hFe(n,i,t);e?d.opacity=[{test:e,...t$(h??1)},t$(c.legend.unselectedOpacity)]:h&&(d.opacity=t$(h))}return d={...d,...e},qZ(d)?void 0:d}function uFe(e,{model:t,legendType:n,legendCmpt:r}){if(n!==`gradient`)return;let{config:i,markDef:a,encoding:o}=t,s={},c=(r.get(`gradientOpacity`)??i.legend.gradientOpacity)===void 0?pFe(o.opacity)||a.opacity:void 0;return c&&(s.opacity=t$(c)),s={...s,...e},qZ(s)?void 0:s}function dFe(e,{fieldOrDatumDef:t,model:n,channel:r,legendCmpt:i}){let a=n.legend(r)||{},o=n.config,s=Z(t)?hFe(n,i,t):void 0,c=s?[{test:s,value:1},{value:o.legend.unselectedOpacity}]:void 0,{format:l,formatType:u}=a,d;Z$(u)?d=$$({fieldOrDatumDef:t,field:`datum.value`,format:l,formatType:u,config:o}):l===void 0&&u===void 0&&o.customFormatTypes&&(t.type===`quantitative`&&o.numberFormatType?d=$$({fieldOrDatumDef:t,field:`datum.value`,format:o.numberFormat,formatType:o.numberFormatType,config:o}):t.type===`temporal`&&o.timeFormatType&&Z(t)&&t.timeUnit===void 0&&(d=$$({fieldOrDatumDef:t,field:`datum.value`,format:o.timeFormat,formatType:o.timeFormatType,config:o})));let f={...c?{opacity:c}:{},...d?{text:d}:{},...e};return qZ(f)?void 0:f}function fFe(e,{legendCmpt:t}){return t.get(`selections`)?.length?{...e,fill:{value:`transparent`}}:e}function pFe(e){return mFe(e,(e,t)=>Math.max(e,t.value))}function J0(e){return mFe(e,(e,t)=>cQ(e,t.value))}function mFe(e,t){if(Tje(e))return ng(e.condition).reduce(t,e.value);if(_1(e))return e.value}function hFe(e,t,n){let r=t.get(`selections`);if(!r?.length)return;let i=W(n.field);return r.map(e=>`(!length(data(${W(XZ(e)+c6)})) || (${e}[${i}] && indexof(${e}[${i}], datum.value) >= 0))`).join(` || `)}function gFe(e,t){let n=e.values;if(H(n))return Hje(t,n);if(JQ(n))return n}function _Fe(e,t,n,r){if(t!==`shape`){let e=J0(n)??r;if(e)return e}switch(e){case`bar`:case`rect`:case`image`:case`square`:return`square`;case`line`:case`trail`:case`rule`:return`stroke`;case`arc`:case`point`:case`circle`:case`tick`:case`geoshape`:case`area`:case`text`:return`circle`}}function vFe(e){let{legend:t}=e;return cQ(t.type,yFe(e))}function yFe({channel:e,timeUnit:t,scaleType:n}){if(yQ(e)){if(RZ([`quarter`,`month`,`day`],t))return`symbol`;if(R$(n))return`gradient`}return`symbol`}function bFe({legendConfig:e,legendType:t,orient:n,legend:r}){return r.direction??e[t?`gradientDirection`:`symbolDirection`]??xFe(n,t)}function xFe(e,t){switch(e){case`top`:case`bottom`:return`horizontal`;case`left`:case`right`:case`none`:case void 0:return;default:return t===`gradient`?`horizontal`:void 0}}function SFe({legendConfig:e,model:t,direction:n,orient:r,scaleType:i}){let{gradientHorizontalMaxLength:a,gradientHorizontalMinLength:o,gradientVerticalMaxLength:s,gradientVerticalMinLength:c}=e;if(R$(i))return n===`horizontal`?r===`top`||r===`bottom`?CFe(t,`width`,o,a):o:CFe(t,`height`,c,s)}function CFe(e,t,n,r){return{signal:`clamp(${e.getSizeSignalRef(t).signal}, ${n}, ${r})`}}function wFe(e){if(RZ([`quantile`,`threshold`,`log`,`symlog`],e))return`greedy`}function TFe(e){let t=c2(e)?EFe(e):AFe(e);return e.component.legends=t,t}function EFe(e){let{encoding:t}=e,n={};for(let r of[U2,...x3]){let i=E1(t[r]);!i||!e.getScaleComponent(r)||r===K2&&Z(i)&&i.type===L4||(n[r]=kFe(e,r))}return n}function DFe(e,t){let n=e.scaleName(t);if(e.mark===`trail`){if(t===`color`)return{stroke:n};if(t===`size`)return{strokeWidth:n}}return t===`color`?e.markDef.filled?{fill:n}:{stroke:n}:{[t]:n}}function OFe(e,t,n,r){switch(t){case`disable`:return n!==void 0;case`values`:return!!n?.values;case`title`:if(t===`title`&&e===r?.title)return!0}return e===(n||{})[t]}function kFe(e,t){let n=e.legend(t),{markDef:r,encoding:i,config:a}=e,o=a.legend,s=new wBe({},DFe(e,t));yPe(e,t,s);let c=n===void 0?o.disable:!n;if(s.set(`disable`,c,n!==void 0),c)return s;n||={};let l=e.getScaleComponent(t).get(`type`),u=E1(i[t]),d=Z(u)?T$(u.timeUnit)?.unit:void 0,f=n.orient||a.legend.orient||`right`,p=vFe({legend:n,channel:t,timeUnit:d,scaleType:l}),m=bFe({legend:n,legendType:p,orient:f,legendConfig:o}),h={legend:n,channel:t,model:e,markDef:r,encoding:i,fieldOrDatumDef:u,legendConfig:o,config:a,scaleType:l,orient:f,legendType:p,direction:m};for(let r of _6){if(p===`gradient`&&r.startsWith(`symbol`)||p===`symbol`&&r.startsWith(`gradient`))continue;let i=r in y6?y6[r](h):n[r];if(i!==void 0){let o=OFe(i,r,n,e.fieldDef(t));(o||a.legend[r]===void 0)&&s.set(r,i,o)}}let g=n?.encoding??{},_=s.get(`selections`),v={},y={fieldOrDatumDef:u,model:e,channel:t,legendCmpt:s,legendType:p};for(let t of[`labels`,`legend`,`title`,`symbols`,`gradient`,`entries`]){let n=sFe(g[t]??{},e),r=t in v6?v6[t](n,y):n;r!==void 0&&!qZ(r)&&(v[t]={..._?.length&&Z(u)?{name:`${XZ(u.field)}_legend_${t}`}:{},..._?.length?{interactive:!0}:{},update:_?.length?{...r,cursor:{value:`pointer`}}:r})}return qZ(v)||s.set(`encode`,v,!!n?.encoding),s}function AFe(e){let{legends:t,resolve:n}=e.component;for(let r of e.children){TFe(r);for(let i of $(r.component.legends))n.legend[i]=q0(e.component.resolve,i),n.legend[i]===`shared`&&(t[i]=jFe(t[i],r.component.legends[i]),t[i]||(n.legend[i]=`independent`,delete t[i]))}for(let r of $(t))for(let t of e.children)t.component.legends[r]&&n.legend[r]===`shared`&&delete t.component.legends[r];return t}function jFe(e,t){if(!e)return t.clone();let n=e.getWithExplicit(`orient`),r=t.getWithExplicit(`orient`);if(n.explicit&&r.explicit&&n.value!==r.value)return;let i=!1;for(let n of _6){let r=l0(e.getWithExplicit(n),t.getWithExplicit(n),n,`legend`,(e,t)=>{switch(n){case`symbolType`:return MFe(e,t);case`title`:return lke(e,t);case`type`:return i=!0,s0(`symbol`)}return c0(e,t,n,`legend`)});e.setWithExplicit(n,r)}return i&&(e.implicit?.encode?.gradient&&QZ(e.implicit,[`encode`,`gradient`]),e.explicit?.encode?.gradient&&QZ(e.explicit,[`encode`,`gradient`])),e}function MFe(e,t){return t.value===`circle`?t:e}function NFe(e,t,n,r){if(M1(t,n)){let i=c2(e)?e.axis(n)??e.legend(n)??{}:{},a=Q(t,{expr:`datum`}),o=Q(t,{expr:`datum`,binSuffix:`end`});return{formulaAs:Q(t,{binSuffix:`range`,forAs:!0}),formula:t1(a,o,i.format,i.formatType,r)}}return{}}function PFe(e,t){return`${RQ(e)}_${t}`}function FFe(e,t){return{signal:e.getName(`${t}_bins`),extentSignal:e.getName(`${t}_extent`)}}function Y0(e,t,n){let r=PFe(k1(n,void 0)??{},t);return e.getName(`${r}_bins`)}function IFe(e){return`as`in e}function LFe(e,t,n){let r,i;r=IFe(e)?xg(e.as)?[e.as,`${e.as}_end`]:[e.as[0],e.as[1]]:[Q(e,{forAs:!0}),Q(e,{binSuffix:`end`,forAs:!0})];let a={...k1(t,void 0)},o=PFe(a,e.field),{signal:s,extentSignal:c}=FFe(n,o);if(HQ(a.extent)){let e=a.extent;i=OPe(n,e.param,e),delete a.extent}return{key:o,binComponent:{bin:a,field:e.field,as:[r],...s?{signal:s}:{},...c?{extentSignal:c}:{},...i?{span:i}:{}}}}function RFe(e,t,n,r){let i=c2(r)?r.encoding[wQ(t)]:void 0;if(g1(n)&&c2(r)&&Cje(n,i,r.markDef,r.config)){e.add(Q(n,{})),e.add(Q(n,{suffix:`end`}));let{mark:i,markDef:a,config:o}=r,s=s1({fieldDef:n,markDef:a,config:o});H$(i)&&s!==.5&&OQ(t)&&(e.add(Q(n,{suffix:I3})),e.add(Q(n,{suffix:L3}))),n.bin&&M1(n,t)&&e.add(Q(n,{binSuffix:`range`}))}else if(vQ(t)){let n=_Q(t);e.add(r.getName(n))}else e.add(Q(n));return v1(n)&&YAe(n.scale?.range)&&e.add(n.scale.range.field),e}function zFe(e,t){for(let n of $(t)){let r=t[n];for(let t of $(r))n in e?e[n][t]=new Set([...e[n][t]??[],...r[t]]):e[n]={[t]:r[t]}}}function BFe(e){return e.startsWith(`'`)&&e.endsWith(`'`)||e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function VFe(e,t){let n=eQ(e);return t===`number`?`toNumber(${n})`:t===`boolean`?`toBoolean(${n})`:t===`string`?`toString(${n})`:t===`date`?`toDate(${n})`:t===`flatten`?n:t.startsWith(`date:`)?`timeParse(${n},'${BFe(t.slice(5,t.length))}')`:t.startsWith(`utc:`)?`utcParse(${n},'${BFe(t.slice(4,t.length))}')`:(X(wke(t)),null)}function HFe(e){let t={};return jZ(e.filter,e=>{if(LAe(e)){let n=null;E$(e)?n=$Q(e.equal):O$(e)?n=$Q(e.lte):D$(e)?n=$Q(e.lt):k$(e)?n=$Q(e.gt):A$(e)?n=$Q(e.gte):j$(e)?n=e.range[0]:M$(e)&&(n=(e.oneOf??e.in)[0]),n&&(y$(n)?t[e.field]=`date`:yg(n)?t[e.field]=`number`:xg(n)&&(t[e.field]=`string`)),e.timeUnit&&(t[e.field]=`date`)}}),t}function UFe(e){let t={};function n(e){A1(e)?t[e.field]=`date`:e.type===`quantitative`&&ake(e.aggregate)?t[e.field]=`number`:sQ(e.field)>1?e.field in t||(t[e.field]=`flatten`):v1(e)&&n1(e.sort)&&sQ(e.sort.field)>1&&(e.sort.field in t||(t[e.sort.field]=`flatten`))}if((c2(e)||l2(e))&&e.forEachFieldDef((t,r)=>{if(g1(t))n(t);else{let i=SQ(r),a=e.fieldDef(i);n({...t,type:a.type})}}),c2(e)){let{mark:n,markDef:r,encoding:i}=e;if(V$(n)&&!e.encoding.order){let e=i[r.orient===`horizontal`?`y`:`x`];Z(e)&&e.type===`quantitative`&&!(e.field in t)&&(t[e.field]=`number`)}}return t}function WFe(e){let t={};if(c2(e)&&e.component.selection)for(let n of $(e.component.selection)){let r=e.component.selection[n];for(let e of r.project.items)!e.channel&&sQ(e.field)>1&&(t[e.field]=`flatten`)}return t}function X0(e){return e instanceof D6||e instanceof T6||e instanceof E6}function Z0(e){return`isValid(${e}) && isFinite(+${e})`}function GFe(e){return e.stack.stackBy.reduce((e,t)=>{let n=t.fieldDef,r=Q(n);return r&&e.push(r),e},[])}function KFe(e){return H(e)&&e.every(e=>xg(e))&&e.length>1}function qFe(e){function t(n){if(!(n instanceof S6)){let r=n.clone();if(r instanceof P3){let t=F6+r.getSource();r.setSource(t),e.model.component.data.outputNodes[t]=r}else(r instanceof x6||r instanceof N6||r instanceof P6||r instanceof j6)&&r.addDimensions(e.fields);for(let e of n.children.flatMap(t))e.parent=r;return[r]}return n.children.flatMap(t)}return t}function Q0(e){if(e instanceof S6)if(e.numChildren()===1&&!(e.children[0]instanceof P3)){let t=e.children[0];(t instanceof x6||t instanceof N6||t instanceof P6||t instanceof j6)&&t.addDimensions(e.fields),t.swapWithParent(),Q0(e)}else{let t=e.model.component.data.main;JFe(t);let n=qFe(e),r=e.children.map(n).flat();for(let e of r)e.parent=t}else e.children.map(Q0)}function JFe(e){if(e instanceof P3&&e.type===M3.Main&&e.numChildren()===1){let t=e.children[0];t instanceof S6||(t.swapWithParent(),JFe(e))}}function $0(e){for(let t of e){for(let e of t.children)if(e.parent!==t)return!1;if(!$0(t.children))return!1}return!0}function e2(e,t){let n=!1;for(let r of t)n=e.optimize(r)||n;return n}function YFe(e,t,n){let r=e.sources,i=!1;return i=e2(new OBe,r)||i,i=e2(new EBe(t),r)||i,r=r.filter(e=>e.numChildren()>0),i=e2(new jBe,r)||i,r=r.filter(e=>e.numChildren()>0),n||(i=e2(new kBe,r)||i,i=e2(new PBe(t),r)||i,i=e2(new DBe,r)||i,i=e2(new ABe,r)||i,i=e2(new NBe,r)||i,i=e2(new MBe,r)||i,i=e2(new TBe,r)||i,i=e2(new FBe,r)||i),e.sources=r,i}function XFe(e,t){$0(e.sources);let n=0,r=0;for(let r=0;r({signal:`{data: ${j1(e,{timeUnit:n,type:t})}}`}))}function t2(e,t,n){let r=T$(n)?.unit;return t===`temporal`||r?nIe(e,t,r):[e]}function n2(e,t,n,r){let{encoding:i,markDef:a,mark:o,config:s,stack:c}=n,l=E1(i[r]),{type:u}=l,d=l.timeUnit,f=INe({invalid:o$(`invalid`,a,s),isPath:V$(o)});if(JAe(t)){let i=n2(e,void 0,n,r);return o0([...t2(t.unionWith,u,d),...i.value])}else if(JQ(t))return o0([t]);else if(t&&t!==`unaggregated`&&!qAe(t))return o0(t2(t,u,d));if(c&&r===c.fieldChannel){if(c.offset===`normalize`)return s0([[0,1]]);let e=n.requestDataName(f);return s0([{data:e,field:n.vgField(r,{suffix:`start`})},{data:e,field:n.vgField(r,{suffix:`end`})}])}let p=MQ(r)&&Z(l)?iIe(n,r,e):void 0;if(f1(l))return s0(t2([l.datum],u,d));let m=l;if(t===`unaggregated`){let{field:e}=l;return s0([{data:n.requestDataName(f),field:Q({field:e,aggregate:`min`})},{data:n.requestDataName(f),field:Q({field:e,aggregate:`max`})}])}else if(zQ(m.bin)){if(I$(e))return s0(e===`bin-ordinal`?[]:[{data:JZ(p)?n.requestDataName(f):n.requestDataName(M3.Raw),field:n.vgField(r,M1(m,r)?{binSuffix:`range`}:{}),sort:p===!0||!Dh(p)?{field:n.vgField(r,{}),op:`min`}:p}]);{let{bin:e}=m;if(zQ(e)){let t=Y0(n,m.field,e);return s0([new L6(()=>{let e=n.getSignalName(t);return`[${e}.start, ${e}.stop]`})])}else return s0([{data:n.requestDataName(f),field:n.vgField(r,{})}])}}else if(m.timeUnit&&RZ([`time`,`utc`],e)){let e=i[wQ(r)];if(Cje(m,e,a,s)){let t=n.requestDataName(f),i=s1({fieldDef:m,fieldDef2:e,markDef:a,config:s}),c=H$(o)&&i!==.5&&OQ(r);return s0([{data:t,field:n.vgField(r,c?{suffix:I3}:{})},{data:t,field:n.vgField(r,{suffix:c?L3:`end`})}])}}return s0(p?[{data:JZ(p)?n.requestDataName(f):n.requestDataName(M3.Raw),field:n.vgField(r),sort:p}]:[{data:n.requestDataName(f),field:n.vgField(r)}])}function r2(e,t){let{op:n,field:r,order:i}=e;return{op:n??(t?`sum`:a3),...r?{field:iQ(r)}:{},...i?{order:i}:{}}}function rIe(e,t){let n=e.component.scales[t],r=e.specifiedScales[t].domain,i=e.fieldDef(t)?.bin,a=qAe(r)?r:void 0,o=VQ(i)&&HQ(i.extent)?i.extent:void 0;(a||o)&&n.set(`selectionExtent`,a??o,!0)}function iIe(e,t,n){if(!I$(n))return;let r=e.fieldDef(t),i=r.sort;if(vje(i))return{op:`min`,field:B0(r,t),order:`ascending`};let{stack:a}=e,o=a?new Set([...a.groupbyFields,...a.stackBy.map(e=>e.fieldDef.field)]):void 0;if(n1(i))return r2(i,a&&!o.has(i.field));if(_je(i)){let{encoding:t,order:n}=i,r=e.fieldDef(t),{aggregate:s,field:c}=r,l=a&&!o.has(c);if(PQ(s)||FQ(s))return r2({field:Q(r),order:n},l);if(IQ(s)||!s)return r2({op:s,field:c,order:n},l)}else if(i===`descending`)return{op:`min`,field:e.vgField(t),order:`descending`};else if(RZ([`ascending`,void 0],i))return!0}function aIe(e,t){let{aggregate:n,type:r}=e;return n?xg(n)&&!LRe.has(n)?{valid:!1,reason:Kke(n)}:r===`quantitative`&&t===`log`?{valid:!1,reason:qke(e)}:{valid:!0}:{valid:!1,reason:Gke(e)}}function i2(e,t,n,r){return e.explicit&&t.explicit&&X(eAe(n,r,e.value,t.value)),{explicit:e.explicit,value:[...e.value,...t.value]}}function oIe(e){let t=HZ(e.map(e=>{if(ZQ(e)){let{sort:t,...n}=e;return n}return e}),IZ),n=HZ(e.map(e=>{if(ZQ(e)){let t=e.sort;return t!==void 0&&!JZ(t)&&(`op`in t&&t.op===`count`&&delete t.field,t.order===`ascending`&&delete t.order),t}}).filter(e=>e!==void 0),IZ);if(t.length===0)return;if(t.length===1){let t=e[0];if(ZQ(t)&&n.length>0){let e=n[0];if(n.length>1){X(T4);let t=n.filter(e=>Dh(e)&&`op`in e&&e.op!==`min`);e=n.every(e=>Dh(e)&&`op`in e)&&t.length===1?t[0]:!0}else if(Dh(e)&&`field`in e){let n=e.field;t.field===n&&(e=!e.order||{order:e.order})}return{...t,sort:e}}return t}let r=HZ(n.map(e=>JZ(e)||!(`op`in e)||xg(e.op)&&fg(PRe,e.op)?e:(X(nAe(e)),!0)),IZ),i;r.length===1?i=r[0]:r.length>1&&(X(T4),i=!0);let a=HZ(e.map(e=>ZQ(e)?e.data:null),e=>e);return a.length===1&&a[0]!==null?{data:a[0],fields:t.map(e=>e.field),...i?{sort:i}:{}}:{fields:t,...i?{sort:i}:{}}}function a2(e){if(ZQ(e)&&xg(e.field))return e.field;if(XQ(e)){let t;for(let n of e.fields)if(ZQ(n)&&xg(n.field)){if(!t)t=n.field;else if(t!==n.field)return X($Re),t}return X(eze),t}else if(oke(e)){X(tze);let t=e.fields[0];return xg(t)?t:void 0}}function o2(e,t){return oIe(e.component.scales[t].get(`domains`).map(t=>(ZQ(t)&&(t.data=e.lookupDataSource(t.data)),t)))}function sIe(e,t,n,r){e.encode??={},e.encode[t]??={},e.encode[t].update??={},e.encode[t].update[n]=r}function cIe(e,t){if(c2(e)){let n=e.fieldDef(t);if(n?.field)return n.field}let n=(e.children??[]).map(e=>cIe(e,t)).filter(e=>!!e);if(n.length>0){let e=HZ(n,IZ);return e.length===1?e[0]:void 0}}function lIe(e,t,n){if(t===n)return!0;let r=e.getScaleType(t),i=e.getScaleType(n);return!r||!i?!1:I$(r)===I$(i)}function uIe(e,t){return e?`field:${e}`:`channel:${String(t)}`}function dIe(e){if(H(e)){let t=e.filter(YZ);return t.length>0?t:null}if(XQ(e)){let t=[];if(t.push(...e.fields.flatMap(e=>H(e)?e.filter(YZ):[])),t.length>0)return HZ(t,IZ)}return null}function s2(e,t){try{return dIe(o2(e,t))}catch{return null}}function fIe(e,t,n){let r=s2(e,t),i=s2(e,n);return r&&i?HZ([...r,...i],IZ):null}function pIe(e,t,n){t&&t.length>0&&(e.getWithExplicit(`values`)?.explicit||(n&&X(n),e.set(`values`,t,!1)))}function mIe(e,t,n){let r=e.getScaleComponent(t),i=e.getScaleComponent(n);if(!r||!i)return!1;let a=r.getWithExplicit(`domains`),o=i.getWithExplicit(`domains`);if(!(a?.explicit&&o?.explicit))return!1;let s=o2(e,t),c=o2(e,n);return IZ(s)===IZ(c)}function hIe(e){let t=e.component.legends,n={};for(let r of $(t)){let i=uIe(cIe(e,r),r);if(!n[i]){n[i]=[{channel:r,cmpt:t[r].clone()}];continue}let a=!1;for(let o of n[i])if(lIe(e,o.channel,r)&&jFe(o.cmpt,t[r])){let t=e.getScaleType(o.channel),n=e.getScaleType(r);t&&n&&I$(t)&&I$(n)&&(mIe(e,o.channel,r)?pIe(o.cmpt,s2(e,o.channel)):pIe(o.cmpt,fIe(e,o.channel,r),rAe(o.channel,r))),a=!0;break}a||n[i].push({channel:r,cmpt:t[r].clone()})}return x2(n).flat().map(t=>gIe(t.cmpt,e.config)).filter(e=>e!==void 0)}function gIe(e,t){let{disable:n,labelExpr:r,selections:i,...a}=e.combine();if(!n){if(t.aria===!1&&a.aria==null&&(a.aria=!1),a.encode?.symbols){let e=a.encode.symbols.update;e.fill&&e.fill.value!==`transparent`&&!e.stroke&&!a.stroke&&(e.stroke={value:`transparent`});for(let t of x3)a[t]&&delete e[t]}if(a.title||delete a.title,r!==void 0){let e=r;a.encode?.labels?.update&&JQ(a.encode.labels.update.text)&&(e=aQ(r,`datum.label`,a.encode.labels.update.text.signal)),sIe(a,`labels`,`text`,{signal:e})}return a}}function _Ie(e){return d2(e)||u2(e)?vIe(e):yIe(e)}function vIe(e){return e.children.reduce((e,t)=>e.concat(t.assembleProjections()),yIe(e))}function yIe(e){let t=e.component.projection;if(!t||t.merged)return[];let n=t.combine(),{name:r}=n;if(t.data){let i={signal:`[${t.size.map(e=>e.signal).join(`, `)}]`},a=t.data.reduce((t,n)=>{let r=JQ(n)?n.signal:`data('${e.lookupDataSource(n)}')`;return RZ(t,r)||t.push(r),t},[]);if(a.length<=0)throw Error(`Projection's fit didn't find any data sources`);return[{name:r,size:i,fit:{signal:a.length>1?`[${a.join(`, `)}]`:a[0]},...n}]}else return[{name:r,translate:{signal:`[width / 2, height / 2]`},...n}]}function bIe(e){e.component.projection=c2(e)?xIe(e):wIe(e)}function xIe(e){if(e.hasProjection){let t=GQ(e.specifiedProjection),n=!(t&&(t.scale!=null||t.translate!=null)),r=n?[e.getSizeSignalRef(`width`),e.getSizeSignalRef(`height`)]:void 0,i=n?SIe(e):void 0,a=new R6(e.projectionName(!0),{...GQ(e.config.projection),...t},r,i);return a.get(`type`)||a.set(`type`,`equalEarth`,!1),a}}function SIe(e){let t=[],{encoding:n}=e;for(let r of[[z2,R2],[V2,B2]])(E1(n[r[0]])||E1(n[r[1]]))&&t.push({signal:e.getName(`geojson_${t.length}`)});return e.channelHasField(K2)&&e.typedFieldDef(K2).type===L4&&t.push({signal:e.getName(`geojson_${t.length}`)}),t.length===0&&t.push(e.requestDataName(M3.Main)),t}function CIe(e,t){let n=BZ(IBe,n=>!!(!fg(e.explicit,n)&&!fg(t.explicit,n)||fg(e.explicit,n)&&fg(t.explicit,n)&&mQ(e.get(n),t.get(n))));if(mQ(e.size,t.size)){if(n)return e;if(mQ(e.explicit,{}))return t;if(mQ(t.explicit,{}))return e}return null}function wIe(e){if(e.children.length===0)return;let t;for(let t of e.children)bIe(t);let n=BZ(e.children,e=>{let n=e.component.projection;if(!n)return!0;if(t){let e=CIe(t,n);return e&&(t=e),!!e}else return t=n,!0});if(t&&n){let n=e.projectionName(!0),r=new R6(n,t.specifiedProjection,t.size,b2(t.data));for(let t of e.children){let e=t.component.projection;e&&(e.isFit&&r.data.push(...t.component.projection.data),t.renameProjection(e.get(`name`),n),e.merged=!0)}return r}}function TIe(e){return d2(e)||u2(e)?e.children.reduce((e,t)=>e.concat(TIe(t)),EIe(e)):EIe(e)}function EIe(e){return $(e.component.scales).reduce((t,n)=>{let r=e.component.scales[n];if(r.merged)return t;let i=r.combine(),{name:a,type:o,selectionExtent:s,domains:c,range:l,reverse:u,...d}=i,f=DIe(i.range,a,n,e),p=o2(e,n),m=s?JNe(e,s,r,p):null;return t.push({name:a,type:o,...p?{domain:p}:{},...m?{domainRaw:m}:{},range:f,...u===void 0?{}:{reverse:u},...d}),t},[])}function DIe(e,t,n,r){if(OQ(n)){if(YQ(e))return{step:{signal:`${t}_step`}}}else if(Dh(e)&&ZQ(e))return{...e,data:r.lookupDataSource(e.data)};return e}function OIe(e){let t=e.component.scales;for(let n of x4){let r=t[n];if(!r)continue;let i=AIe(n,e);r.setWithExplicit(`range`,i)}}function kIe(e,t){let n=e.fieldDef(t);if(n?.bin){let{bin:r,field:i}=n,a=TQ(t),o=e.getName(a);if(Dh(r)&&r.binned&&r.step!==void 0)return new L6(()=>{let n=e.scaleName(t),i=`(domain("${n}")[1] - domain("${n}")[0]) / ${r.step}`;return`${e.getSignalName(o)} / (${i})`});if(zQ(r)){let t=Y0(e,i,r);return new L6(()=>{let n=e.getSignalName(t),r=`(${n}.stop - ${n}.start) / ${n}.step`;return`${e.getSignalName(o)} / (${r})`})}}}function AIe(e,t){let n=t.specifiedScales[e],{size:r}=t,i=t.getScaleComponent(e).get(`type`);for(let r of LBe)if(n[r]!==void 0){let a=B$(i,r),o=XAe(e,r);if(!a)X(Zke(i,r,e));else if(o)X(o);else switch(r){case`range`:{let r=n.range;if(H(r)){if(OQ(e))return o0(r.map(e=>{if(e===`width`||e===`height`){let n=t.getName(e),r=t.getSignalName.bind(t);return L6.fromName(r,n)}return e}))}else if(Dh(r))return o0({data:t.requestDataName(M3.Main),field:r.field,sort:{op:`min`,field:t.vgField(e)}});return o0(r)}case`scheme`:return o0(jIe(n[r]))}}let a=e===O2||e===`xOffset`?`width`:`height`,o=r[a];if(Y1(o)){if(OQ(e))if(I$(i)){let n=PIe(o,t,e);if(n)return o0({step:n})}else X(Qke(a));else if(AQ(e)){let n=e===M2?`x`:`y`;if(t.getScaleComponent(n).get(`type`)===`band`){let e=FIe(o,i);if(e)return o0(e)}}}let{rangeMin:s,rangeMax:c}=n,l=NIe(e,t);return(s!==void 0||c!==void 0)&&B$(i,`rangeMin`)&&H(l)&&l.length===2?o0([s??l[0],c??l[1]]):s0(l)}function jIe(e){return KAe(e)?{scheme:e.name,...FZ(e,[`name`])}:{scheme:e}}function MIe(e,t,n,{center:r}={}){let i=TQ(e),a=t.getName(i),o=t.getSignalName.bind(t);return e===k2&&L$(n)?r?[L6.fromName(e=>`${o(e)}/2`,a),L6.fromName(e=>`-${o(e)}/2`,a)]:[L6.fromName(o,a),0]:r?[L6.fromName(e=>`-${o(e)}/2`,a),L6.fromName(e=>`${o(e)}/2`,a)]:[0,L6.fromName(o,a)]}function NIe(e,t){let{size:n,config:r,mark:i,encoding:a}=t,{type:o}=E1(a[e]),s=t.getScaleComponent(e).get(`type`),{domain:c,domainMid:l}=t.specifiedScales[e];switch(e){case O2:case k2:if(RZ([`point`,`band`],s)){let i=LIe(e,n,r.view);if(Y1(i))return{step:PIe(i,t,e)}}return MIe(e,t,s);case M2:case N2:return IIe(e,t,s);case q2:{let a=BIe(i,r),o=VIe(i,n,t,r);return z$(s)?zIe(a,o,RIe(s,r,c,e)):[a,o]}case I2:return[0,Math.PI*2];case J2:return[0,360];case P2:return[0,new L6(()=>`min(${t.getSignalName(l2(t.parent)?`child_width`:`width`)},${t.getSignalName(l2(t.parent)?`child_height`:`height`)})/2`)];case H2:return{step:1e3/r.scale.framesPerSecond};case Q2:return[r.scale.minStrokeWidth,r.scale.maxStrokeWidth];case $2:return[[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case K2:return`symbol`;case U2:case W2:case G2:return s===`ordinal`?o===`nominal`?`category`:`ordinal`:l===void 0?i===`rect`||i===`geoshape`?`heatmap`:`ramp`:`diverging`;case Y2:case X2:case Z2:return[r.scale.minOpacity,r.scale.maxOpacity]}}function PIe(e,t,n){let{encoding:r}=t,i=t.getScaleComponent(n),a=DQ(n),o=r[a];if(yMe({step:e,offsetIsDiscrete:h1(o)&&F$(o.type)})===`offset`&&Wje(r,a)){let n=t.getScaleComponent(a),r=`domain('${t.scaleName(a)}').length`;if(n.get(`type`)===`band`){let e=n.get(`paddingInner`)??n.get(`padding`)??0,t=n.get(`paddingOuter`)??n.get(`padding`)??0;r=`bandspace(${r}, ${e}, ${t})`}let o=i.get(`paddingInner`)??i.get(`padding`);return{signal:`${e.step} * ${r} / (1-${ske(o)})`}}else return e.step}function FIe(e,t){if(yMe({step:e,offsetIsDiscrete:I$(t)})===`offset`)return{step:e.step}}function IIe(e,t,n){let r=e===M2?`x`:`y`,i=t.getScaleComponent(r);if(!i)return MIe(r,t,n,{center:!0});let a=i.get(`type`),o=t.scaleName(r),{markDef:s,config:c}=t;if(a===`band`){let e=LIe(r,t.size,t.config.view);if(Y1(e)){let t=FIe(e,n);if(t)return t}return[0,{signal:`bandwidth('${o}')`}]}else{let n=t.encoding[r];if(Z(n)&&n.timeUnit){let e=MAe(n.timeUnit,e=>`scale('${o}', ${e})`),r=t.config.scale.bandWithNestedOffsetPaddingInner,i=s1({fieldDef:n,markDef:s,config:c})-.5,a=i===0?``:` + ${i}`;if(r){let t=JQ(r)?`${r.signal}/2${a}`:`${r/2+i}`,n=JQ(r)?`(1 - ${r.signal}/2)${a}`:`${1-r/2+i}`;return[{signal:`${t} * (${e})`},{signal:`${n} * (${e})`}]}return[0,{signal:e}]}return NZ(`Cannot use ${e} scale if ${r} scale is not discrete.`)}}function LIe(e,t,n){let r=e===O2?`width`:`height`,i=t[r];return i===void 0?Q1(n,r):i}function RIe(e,t,n,r){switch(e){case`quantile`:return t.scale.quantileCount;case`quantize`:return t.scale.quantizeCount;case`threshold`:return n!==void 0&&H(n)?n.length+1:(X(mAe(r)),3)}}function zIe(e,t,n){let r=()=>{let r=r$(t),i=r$(e),a=`(${r} - ${i}) / (${n} - 1)`;return`sequence(${i}, ${r} + ${a}, ${a})`};return JQ(t)?new L6(r):{signal:r()}}function BIe(e,t){switch(e){case`bar`:case`tick`:return t.scale.minBandSize;case`line`:case`trail`:case`rule`:return t.scale.minStrokeWidth;case`text`:return t.scale.minFontSize;case`point`:case`square`:case`circle`:return t.scale.minSize}throw Error(h$(`size`,e))}function VIe(e,t,n,r){let i={x:kIe(n,`x`),y:kIe(n,`y`)};switch(e){case`bar`:case`tick`:{if(r.scale.maxBandSize!==void 0)return r.scale.maxBandSize;let e=HIe(t,i,r.view);return yg(e)?e-1:new L6(()=>`${e.signal} - 1`)}case`line`:case`trail`:case`rule`:return r.scale.maxStrokeWidth;case`text`:return r.scale.maxFontSize;case`point`:case`square`:case`circle`:{if(r.scale.maxSize)return r.scale.maxSize;let e=HIe(t,i,r.view);return yg(e)?(B6*e)**2:new L6(()=>`pow(${B6} * ${e.signal}, 2)`)}}throw Error(h$(`size`,e))}function HIe(e,t,n){let r=Y1(e.width)?e.width.step:Z1(n,`width`),i=Y1(e.height)?e.height.step:Z1(n,`height`);return t.x||t.y?new L6(()=>`min(${[t.x?t.x.signal:r,t.y?t.y.signal:i].join(`, `)})`):Math.min(r,i)}function UIe(e,t){c2(e)?WIe(e,t):KIe(e,t)}function WIe(e,t){let n=e.component.scales,{config:r,encoding:i,markDef:a,specifiedScales:o}=e;for(let s of $(n)){let c=o[s],l=n[s],u=e.getScaleComponent(s),d=E1(i[s]),f=c[t],p=u.get(`type`),m=u.get(`padding`),h=u.get(`paddingInner`),g=B$(p,t),_=XAe(s,t);if(f!==void 0&&(g?_&&X(_):X(Zke(p,t,s))),g&&_===void 0)if(f!==void 0){let e=d.timeUnit,n=d.type;switch(t){case`domainMax`:case`domainMin`:y$(c[t])||n===`temporal`||e?l.set(t,{signal:j1(c[t],{type:n,timeUnit:e})},!0):l.set(t,c[t],!0);break;default:l.copyKeyFromObject(t,c)}}else{let n=Y(V6,t)?V6[t]({model:e,channel:s,fieldOrDatumDef:d,scaleType:p,scalePadding:m,scalePaddingInner:h,domain:c.domain,domainMin:c.domainMin,domainMax:c.domainMax,markDef:a,config:r,hasNestedOffsetScale:Gje(i,s),hasSecondaryRangeChannel:!!i[wQ(s)]}):r.scale[t];n!==void 0&&l.set(t,n,!1)}}}function GIe(e){c2(e)?OIe(e):KIe(e,`range`)}function KIe(e,t){let n=e.component.scales;for(let n of e.children)t===`range`?GIe(n):UIe(n,t);for(let r of $(n)){let i;for(let n of e.children){let e=n.component.scales[r];if(e){let n=e.getWithExplicit(t);i=l0(i,n,t,`scale`,jNe((e,n)=>{switch(t){case`range`:return e.step&&n.step?e.step-n.step:0}return 0}))}}n[r].setWithExplicit(t,i)}}function qIe(e,t){let n=t.bin;if(zQ(n)){let r=Y0(e,t.field,n);return new L6(()=>e.getSignalName(r))}else if(BQ(n)&&VQ(n)&&n.step!==void 0)return{step:n.step}}function JIe(e,t){if(RZ([U2,W2,G2],e)&&t!==`nominal`)return`hcl`}function YIe(e,t,n,r,i,a){if(!(T1(a)?.bin||H(n)||i!=null||r!=null||RZ([R4.TIME,R4.UTC],e)))return OQ(t)?!0:void 0}function XIe(e,t,n,r,i,a){if(OQ(e)){if(R$(t)){if(n.continuousPadding!==void 0)return n.continuousPadding;let{type:t,orient:o}=i;if(t===`bar`&&!(Z(r)&&(r.bin||r.timeUnit))&&(o===`vertical`&&e===`x`||o===`horizontal`&&e===`y`))return a.continuousBandSize}if(t===R4.POINT)return n.pointPadding}}function ZIe(e,t,n,r,i,a=!1){if(e===void 0){if(OQ(t)){let{bandPaddingInner:e,barBandPaddingInner:t,rectBandPaddingInner:r,tickBandPaddingInner:o,bandWithNestedOffsetPaddingInner:s}=i;return a?s:cQ(e,n===`bar`?t:n===`tick`?o:r)}else if(AQ(t)&&r===R4.BAND)return i.offsetBandPaddingInner}}function QIe(e,t,n,r,i,a=!1){if(e===void 0){if(OQ(t)){let{bandPaddingOuter:e,bandWithNestedOffsetPaddingOuter:t}=i;if(a)return t;if(n===R4.BAND)return cQ(e,JQ(r)?{signal:`${r.signal}/2`}:r/2)}else if(AQ(t)){if(n===R4.POINT)return .5;if(n===R4.BAND)return i.offsetBandPaddingOuter}}}function $Ie(e,t,n,r){if(n===`x`&&r.xReverse!==void 0)return L$(e)&&t===`descending`?JQ(r.xReverse)?{signal:`!${r.xReverse.signal}`}:!r.xReverse:r.xReverse;if(L$(e)&&t===`descending`)return!0}function eLe(e,t,n,r,i,a,o){if(n&&n!==`unaggregated`&&L$(i)){if(H(n)){let e=n[0],t=n[n.length-1];if(yg(e)&&e<=0&&yg(t)&&t>=0)return!0}return!1}if(e===`size`&&t.type===`quantitative`&&!z$(i))return!0;if(!(Z(t)&&t.bin)&&RZ([...g4,...bRe],e)){let{orient:t,type:n}=r;return RZ([`bar`,`area`,`line`,`trail`],n)&&(t===`horizontal`&&e===`y`||t===`vertical`&&e===`x`)?!1:RZ([`bar`,`area`],n)&&!o?!0:a?.zero}return!1}function tLe(e,t,n,r,i=!1){let a=nLe(t,n,r,i),{type:o}=e;return MQ(t)?o===void 0?a:QAe(t,o)?Z(n)&&!ZAe(o,n.type)?(X(Xke(o,a)),a):o:(X(Yke(t,o,a)),a):null}function nLe(e,t,n,r){switch(t.type){case`nominal`:case`ordinal`:{if(yQ(e)||NQ(e)===`discrete`)return e===`shape`&&t.type===`ordinal`&&X(g$(e,`ordinal`)),`ordinal`;if(jQ(e))return`band`;if(OQ(e)||AQ(e)){if(RZ([`rect`,`bar`,`image`,`rule`,`tick`],n.type)||r)return`band`}else if(n.type===`arc`&&e in _4)return`band`;let i=n[TQ(e)];return W$(i)||y1(t)&&t.axis?.tickBand?`band`:`point`}case`temporal`:return yQ(e)?`time`:NQ(e)===`discrete`?(X(g$(e,`temporal`)),`ordinal`):Z(t)&&t.timeUnit&&T$(t.timeUnit).utc?`utc`:jQ(e)?`band`:`time`;case`quantitative`:return yQ(e)?Z(t)&&zQ(t.bin)?`bin-ordinal`:`linear`:NQ(e)===`discrete`?(X(g$(e,`quantitative`)),`ordinal`):jQ(e)?`band`:`linear`;case`geojson`:return}throw Error(jke(t.type))}function rLe(e,{ignoreRange:t}={}){iLe(e),ZFe(e);for(let t of _ze)UIe(e,t);t||GIe(e)}function iLe(e){c2(e)?e.component.scales=aLe(e):e.component.scales=oLe(e)}function aLe(e){let{encoding:t,mark:n,markDef:r}=e,i={};for(let a of x4){let o=E1(t[a]);if(o&&n===e3&&a===K2&&o.type===L4)continue;let s=o&&o.scale;if(o&&s!==null&&s!==!1){s??={};let n=Gje(t,a),c=tLe(s,a,o,r,n);i[a]=new z6(e.scaleName(`${a}`,!0),{value:c,explicit:s.type===c})}}return i}function oLe(e){let t=e.component.scales={},n={},r=e.component.resolve;for(let t of e.children){iLe(t);for(let i of $(t.component.scales))if(r.scale[i]??=cFe(i,e),r.scale[i]===`shared`){let e=n[i],a=t.component.scales[i].getWithExplicit(`type`);e?UAe(e.value,a.value)?n[i]=l0(e,a,`type`,`scale`,RBe):(r.scale[i]=`independent`,delete n[i]):n[i]=a}}for(let r of $(n)){let i=e.scaleName(r,!0),a=n[r];t[r]=new z6(i,a);for(let t of e.children){let e=t.component.scales[r];e&&(t.renameScale(e.get(`name`),i),e.merged=!0)}}return t}function c2(e){return e?.type===`unit`}function l2(e){return e?.type===`facet`}function u2(e){return e?.type===`concat`}function d2(e){return e?.type===`layer`}function sLe(e){let t=0;function n(r,i){if(r instanceof D6&&!r.isGenerator&&!u0(r.data)&&(e.push(i),i={name:null,source:i.name,transform:[]}),r instanceof C6&&(r.parent instanceof D6&&!i.source?(i.format={...i.format,parse:r.assembleFormatParse()},i.transform.push(...r.assembleTransforms(!0))):i.transform.push(...r.assembleTransforms())),r instanceof S6){i.name||=`data_${t++}`,!i.source||i.transform.length>0?(e.push(i),r.data=i.name):r.data=i.source,e.push(...r.assemble());return}switch((r instanceof T6||r instanceof E6||r instanceof M6||r instanceof f6||r instanceof m6||r instanceof X6||r instanceof x6||r instanceof $6||r instanceof P6||r instanceof j6||r instanceof J6||r instanceof q6||r instanceof G6||r instanceof Q6||r instanceof e8||r instanceof t8||r instanceof w6||r instanceof r8||r instanceof n8||r instanceof K6)&&i.transform.push(r.assemble()),(r instanceof b6||r instanceof F3||r instanceof Z6||r instanceof N6||r instanceof Y6)&&i.transform.push(...r.assemble()),r instanceof P3&&(i.source&&i.transform.length===0?r.setSource(i.source):r.parent instanceof P3?r.setSource(i.name):(i.name||=`data_${t++}`,r.setSource(i.name),r.numChildren()===1&&(e.push(i),i={name:null,source:i.name,transform:[]}))),r.numChildren()){case 0:r instanceof P3&&(!i.source||i.transform.length>0)&&e.push(i);break;case 1:n(r.children[0],i);break;default:{i.name||=`data_${t++}`;let a=i.name;!i.source||i.transform.length>0?e.push(i):a=i.source;for(let e of r.children)n(e,{name:null,source:a,transform:[]});break}}}return n}function cLe(e){let t=[],n=sLe(t);for(let t of e.children)n(t,{source:e.name,name:null,transform:[]});return t}function lLe(e,t){let n=[],r=sLe(n),i=0;for(let t of e.sources)t.hasName()||(t.dataName=`source_${i++}`),r(t,t.assemble());for(let e of n)e.transform.length===0&&delete e.transform;let a=0;for(let[e,t]of n.entries())(t.transform??[]).length===0&&!t.source&&n.splice(a++,0,n.splice(e,1)[0]);for(let t of n)for(let n of t.transform??[])n.type===`lookup`&&(n.from=e.outputNodes[n.from].getSource());for(let e of n)e.name in t&&(e.values=t[e.name]);return n}function uLe(e){return e===`top`||e===`left`||JQ(e)?`header`:`footer`}function dLe(e){for(let t of f4)fLe(e,t);mLe(e,`x`),mLe(e,`y`)}function fLe(e,t){let{facet:n,config:r,child:i,component:a}=e;if(e.channelHasField(t)){let o=n[t],s=H0(`title`,null,r,t),c=x1(o,r,{allowDisabling:!0,includeDefault:s===void 0||!!s});i.component.layoutHeaders[t].title&&(c=H(c)?c.join(`, `):c,c+=` / ${i.component.layoutHeaders[t].title}`,i.component.layoutHeaders[t].title=null);let l=H0(`labelOrient`,o.header,r,t),u=o.header!==null&&cQ(o.header?.labels,r.header.labels,!0),d=RZ([`bottom`,`right`],l)?`footer`:`header`;a.layoutHeaders[t]={title:o.header===null?null:c,facetFieldDef:o,[d]:t===`facet`?[]:[pLe(e,t,u)]}}}function pLe(e,t,n){let r=t===`row`?`height`:`width`;return{labels:n,sizeSignal:e.child.component.layoutSize.get(r)?e.child.getSizeSignalRef(r):void 0,axes:[]}}function mLe(e,t){let{child:n}=e;if(n.component.axes[t]){let{layoutHeaders:r,resolve:i}=e.component;if(i.axis[t]=q0(i,t),i.axis[t]===`shared`){let i=t===`x`?`column`:`row`,a=r[i];for(let r of n.component.axes[t]){let t=uLe(r.get(`orient`));a[t]??=[pLe(e,i,!1)];let n=L0(r,`main`,e.config,{header:!0});n&&a[t][0].axes.push(n),r.mainExtracted=!0}}}}function hLe(e){f2(e),p2(e,`width`),p2(e,`height`)}function gLe(e){f2(e);let t=e.layout.columns===1?`width`:`childWidth`,n=e.layout.columns===void 0?`height`:`childHeight`;p2(e,t),p2(e,n)}function f2(e){for(let t of e.children)t.parseLayoutSize()}function p2(e,t){let n=oFe(t),r=kQ(n),i=e.component.resolve,a=e.component.layoutSize,o;for(let t of e.children){let a=t.component.layoutSize.getWithExplicit(n),s=i.scale[r]??cFe(r,e);if(s===`independent`&&a.value===`step`){o=void 0;break}if(o){if(s===`independent`&&o.value!==a.value){o=void 0;break}o=l0(o,a,n,``)}else o=a}if(o){for(let r of e.children)e.renameSignal(r.getName(n),e.getName(t)),r.component.layoutSize.set(n,`merged`,!1);a.setWithExplicit(t,o)}else a.setWithExplicit(t,{explicit:!1,value:void 0})}function _Le(e){let{size:t,component:n}=e;for(let r of g4){let i=TQ(r);if(t[i]!=null&&t[i]!=null){let e=t[i];n.layoutSize.set(i,Y1(e)?`step`:e,!0)}else{let t=vLe(e,i);n.layoutSize.set(i,t,!1)}}}function vLe(e,t){let n=t===`width`?`x`:`y`,r=e.config,i=e.getScaleComponent(n);if(i){let e=i.get(`type`),n=i.get(`range`);if(I$(e)){let e=Q1(r.view,t);return YQ(n)||Y1(e)?`step`:e}else return X1(r.view,t)}else if(e.hasProjection||e.mark===`arc`)return X1(r.view,t);else{let e=Q1(r.view,t);return Y1(e)?e.step:e}}function m2(e,t,n){return Q(t,{suffix:`by_${Q(e)}`,...n})}function yLe(e,t){let{row:n,column:r}=t;if(n&&r){let t=null;for(let i of[n,r])if(n1(i.sort)){let{field:n,op:r=a3}=i.sort;e=t=new j6(e,{joinaggregate:[{op:r,field:n,as:m2(i,i.sort,{forAs:!0})}],groupby:[Q(i)]})}return t}return null}function bLe(e,t){for(let n of t){let t=n.data;if(e.name&&n.hasName()&&e.name!==n.dataName)continue;let r=e.format?.mesh,i=t.format?.feature;if(r&&i)continue;let a=e.format?.feature;if((a||i)&&a!==i)continue;let o=t.format?.mesh;if(!((r||o)&&r!==o)){if(d0(e)&&d0(t)){if(mQ(e.values,t.values))return n}else if(u0(e)&&u0(t)){if(e.url===t.url)return n}else if(MNe(e)&&e.name===n.dataName)return n}}return null}function xLe(e,t){if(e.data||!e.parent){if(e.data===null){let e=new D6({values:[]});return t.push(e),e}let n=bLe(e.data,t);if(n)return f0(e.data)||(n.data.format=VZ({},e.data.format,n.data.format)),!n.hasName()&&e.data.name&&(n.dataName=e.data.name),n;{let n=new D6(e.data);return t.push(n),n}}else return e.parent.component.data.facetRoot?e.parent.component.data.facetRoot:e.parent.component.data.main}function SLe(e,t,n){let r=0;for(let i of t.transforms){let a,o;if(dNe(i))o=e=new m6(e,i),a=`derived`;else if(i0(i)){let r=HFe(i);o=e=C6.makeWithAncestors(e,{},r,n)??e,e=new f6(e,t,i.filter)}else if(fNe(i))o=e=b6.makeFromTransform(e,i,t),a=`number`;else if(mNe(i))a=`date`,n.getWithExplicit(i.field).value===void 0&&(e=new C6(e,{[i.field]:a}),n.set(i.field,a,!1)),o=e=F3.makeFromTransform(e,i);else if(hNe(i))o=e=x6.makeFromTransform(e,i),a=`number`,M0(t)&&(e=new w6(e));else if($Me(i))o=e=$6.make(e,t,i,r++),a=`derived`;else if(cNe(i))o=e=new P6(e,i),a=`number`;else if(lNe(i))o=e=new j6(e,i),a=`number`;else if(gNe(i))o=e=N6.makeFromTransform(e,i),a=`derived`;else if(_Ne(i))o=e=new J6(e,i),a=`derived`;else if(vNe(i))o=e=new K6(e,i),a=`derived`;else if(uNe(i))o=e=new q6(e,i),a=`derived`;else if(nNe(i))o=e=new n8(e,i),a=`derived`;else if(sNe(i))e=new r8(e,i);else if(pNe(i))o=e=Z6.makeFromTransform(e,i),a=`derived`;else if(rNe(i))o=e=new G6(e,i),a=`derived`;else if(iNe(i))o=e=new e8(e,i),a=`derived`;else if(aNe(i))o=e=new t8(e,i),a=`derived`;else if(oNe(i))o=e=new Q6(e,i),a=`derived`;else{X(Eke(i));continue}if(o&&a!==void 0)for(let e of o.producedFields()??[])n.set(e,a,!1)}return e}function h2(e){let t=xLe(e,e.component.data.sources),{outputNodes:n,outputNodeRefCounts:r}=e.component.data,i=e.data,a=!(i&&(f0(i)||u0(i)||d0(i)))&&e.parent?e.parent.component.data.ancestorParse.clone():new cBe;f0(i)?(NNe(i)?t=new E6(t,i.sequence):p0(i)&&(t=new T6(t,i.graticule)),a.parseNothing=!0):i?.format?.parse===null&&(a.parseNothing=!0),t=C6.makeExplicit(t,e,a)??t,t=new w6(t);let o=e.parent&&d2(e.parent);(c2(e)||l2(e))&&o&&(t=b6.makeFromEncoding(t,e)??t),e.transforms.length>0&&(t=SLe(t,e,a));let s=WFe(e),c=UFe(e);t=C6.makeWithAncestors(t,{},{...s,...c},a)??t,c2(e)&&(t=Y6.parseAll(t,e),t=X6.parseAll(t,e)),(c2(e)||l2(e))&&(o||(t=b6.makeFromEncoding(t,e)??t),t=F3.makeFromEncoding(t,e)??t,t=m6.parseAllForSortIndex(t,e));let l=t=g2(M3.Raw,e,t);if(c2(e)){let n=x6.makeFromEncoding(t,e);n&&(t=n,M0(e)&&(t=new w6(t))),t=Z6.makeFromEncoding(t,e)??t,t=N6.makeFromEncoding(t,e)??t}let u,d;if(c2(e)){let{markDef:n,mark:r,config:i}=e,{marks:a,scales:o}=d=FNe({invalid:a$(`invalid`,n,i),isPath:V$(r)});a!==o&&o===`include-invalid-values`&&(u=t=g2(M3.PreFilterInvalid,e,t)),a===`exclude-invalid-values`&&(t=M6.make(t,e,d)??t)}let f=t=g2(M3.Main,e,t),p;if(c2(e)&&d){let{marks:n,scales:r}=d;n===`include-invalid-values`&&r===`exclude-invalid-values`&&(t=M6.make(t,e,d)??t,p=t=g2(M3.PostFilterInvalid,e,t))}c2(e)&&kPe(e,f);let m=null;if(l2(e)){let r=e.getName(`facet`);t=yLe(t,e.facet)??t,m=new S6(t,e,r,f.getSource()),n[r]=m}return{...e.component.data,outputNodes:n,outputNodeRefCounts:r,raw:l,main:f,facetRoot:m,ancestorParse:a,preFilterInvalid:u,postFilterInvalid:p}}function g2(e,t,n){let{outputNodes:r,outputNodeRefCounts:i}=t.component.data,a=t.getDataName(e),o=new P3(n,a,e,i);return r[a]=o,o}function CLe(e){return e===!1||e===null}function wLe(e,t,n){let{encoding:r,config:i}=e,a=E1(r[t])??E1(r[wQ(t)]),{format:o,formatType:s}=e.axis(t)||{};if(Z$(s))return{text:$$({fieldOrDatumDef:a,field:`datum.value`,format:o,formatType:s,config:i}),...n};if(o===void 0&&s===void 0&&i.customFormatTypes){if(d1(a)===`quantitative`){if(y1(a)&&a.stack===`normalize`&&i.normalizedNumberFormatType)return{text:$$({fieldOrDatumDef:a,field:`datum.value`,format:i.normalizedNumberFormat,formatType:i.normalizedNumberFormatType,config:i}),...n};if(i.numberFormatType)return{text:$$({fieldOrDatumDef:a,field:`datum.value`,format:i.numberFormat,formatType:i.numberFormatType,config:i}),...n}}if(d1(a)===`temporal`&&i.timeFormatType&&Z(a)&&!a.timeUnit)return{text:$$({fieldOrDatumDef:a,field:`datum.value`,format:i.timeFormat,formatType:i.timeFormatType,config:i}),...n}}return n}function TLe(e){return g4.reduce((t,n)=>(e.component.scales[n]&&(t[n]=[ALe(n,e)]),t),{})}function ELe(e){let{axes:t,resolve:n}=e.component,r={top:0,bottom:0,right:0,left:0};for(let r of e.children){r.parseAxesAndHeaders();for(let i of $(r.component.axes))n.axis[i]=q0(e.component.resolve,i),n.axis[i]===`shared`&&(t[i]=DLe(t[i],r.component.axes[i]),t[i]||(n.axis[i]=`independent`,delete t[i]))}for(let i of g4){for(let a of e.children)if(a.component.axes[i]){if(n.axis[i]===`independent`){t[i]=(t[i]??[]).concat(a.component.axes[i]);for(let e of a.component.axes[i]){let{value:t,explicit:n}=e.getWithExplicit(`orient`);if(!JQ(t)){if(r[t]>0&&!n){let n=HBe[t];r[t]>r[n]&&e.set(`orient`,n,!1)}r[t]++}}}delete a.component.axes[i]}if(n.axis[i]===`independent`&&t[i]&&t[i].length>1)for(let[e,n]of(t[i]||[]).entries())e>0&&n.get(`grid`)&&!n.explicit.grid&&(n.implicit.grid=!1)}}function DLe(e,t){if(e){if(e.length!==t.length)return;let n=e.length;for(let r=0;re.clone());return e}function OLe(e,t){for(let n of i8){let r=l0(e.getWithExplicit(n),t.getWithExplicit(n),n,`axis`,(e,t)=>{switch(n){case`title`:return lke(e,t);case`gridScale`:return{explicit:e.explicit,value:cQ(e.value,t.value)}}return c0(e,t,n,`axis`)});e.setWithExplicit(n,r)}return e}function kLe(e,t,n,r,i){if(t===`disable`)return n!==void 0;switch(n||={},t){case`titleAngle`:case`labelAngle`:return e===(JQ(n.labelAngle)?n.labelAngle:fQ(n.labelAngle));case`values`:return!!n.values;case`encode`:return!!n.encoding||!!n.labelAngle;case`title`:if(e===KPe(r,i))return!0}return e===n[t]}function ALe(e,t){let n=t.axis(e),r=new VBe,i=E1(t.encoding[e]),{mark:a,config:o}=t,s=n?.orient||o[e===`x`?`axisX`:`axisY`]?.orient||o.axis?.orient||UPe(e),c=t.getScaleComponent(e).get(`type`),l=PPe(e,c,s,t.config),u=n===void 0?R0(`disable`,o.style,n?.style,l).configValue:!n;if(r.set(`disable`,u,n!==void 0),u)return r;n||={};let d=RPe(i,n,e,o.style,l),f=dje(n.formatType,i,c),p=uje(i,i.type,n.format,n.formatType,o,!0),m={fieldOrDatumDef:i,axis:n,channel:e,model:t,scaleType:c,orient:s,labelAngle:d,format:p,formatType:f,mark:a,config:o};for(let i of i8){let a=i in p6?p6[i](m):Uje(i)?n[i]:void 0,s=a!==void 0,c=kLe(a,i,n,t,e);if(s&&c)r.set(i,a,c);else{let{configValue:e=void 0,configFrom:t=void 0}=Uje(i)&&i!==`values`?R0(i,o.style,n.style,l):{},u=e!==void 0;s&&!u?r.set(i,a,c):(t!==`vgAxisConfig`||UBe.has(i)&&u||N1(e)||JQ(e))&&r.set(i,e,!1)}}let h=n.encoding??{},g=u3.reduce((n,i)=>{if(!r.hasAxisPart(i))return n;let a=sFe(h[i]??{},t),o=i===`labels`?wLe(t,e,a):a;return o!==void 0&&!qZ(o)&&(n[i]={update:o}),n},{});return qZ(g)||r.set(`encode`,g,!!n.encoding||n.labelAngle!==void 0),r}function jLe({encoding:e,size:t}){for(let n of g4){let r=TQ(n);Y1(t[r])&&p1(e[n])&&(delete t[r],X(Qke(r)))}return t}function _2(e,t){let{config:n}=e;return{...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`include`,orient:`ignore`,theta:`ignore`}),...w0(`x`,e,{defaultPos:`mid`}),...w0(`y`,e,{defaultPos:`mid`}),...S0(`size`,e),...S0(`angle`,e),...MLe(e,n,t)}}function MLe(e,t,n){return n?{shape:{value:n}}:S0(`shape`,e)}function NLe(e,t,n){if(a$(`align`,e,n)===void 0)return`center`}function PLe(e,t,n){if(a$(`baseline`,e,n)===void 0)return`middle`}function FLe(e){if(RZ([q4,G4,bze],e.mark)){let t=Qje(e.mark,e.encoding);if(t.length>0)return ILe(e,t)}else if(e.mark===K4){let t=C4.some(t=>a$(t,e.markDef,e.config));if(e.stack&&!e.fieldDef(`size`)&&t)return LLe(e)}return v2(e)}function ILe(e,t){return[{name:e.getName(`pathgroup`),type:`group`,from:{facet:{name:o8+e.requestDataName(M3.Main),data:e.requestDataName(M3.Main),groupby:t}},encode:{update:{width:{field:{group:`width`}},height:{field:{group:`height`}}}},marks:v2(e,{fromPrefix:o8})}]}function LLe(e){let[t]=v2(e,{fromPrefix:s8}),n=e.scaleName(e.stack.fieldChannel),r=(t={})=>e.vgField(e.stack.fieldChannel,t),i=(e,t)=>`${e}(${[r({prefix:`min`,suffix:`start`,expr:t}),r({prefix:`max`,suffix:`start`,expr:t}),r({prefix:`min`,suffix:`end`,expr:t}),r({prefix:`max`,suffix:`end`,expr:t})].map(e=>`scale('${n}',${e})`).join(`,`)})`,a,o;e.stack.fieldChannel===`x`?(a={...PZ(t.encode.update,[`y`,`yc`,`y2`,`height`,...C4]),x:{signal:i(`min`,`datum`)},x2:{signal:i(`max`,`datum`)},clip:{value:!0}},o={x:{field:{group:`x`},mult:-1},height:{field:{group:`height`}}},t.encode.update={...FZ(t.encode.update,[`y`,`yc`,`y2`]),height:{field:{group:`height`}}}):(a={...PZ(t.encode.update,[`x`,`xc`,`x2`,`width`]),y:{signal:i(`min`,`datum`)},y2:{signal:i(`max`,`datum`)},clip:{value:!0}},o={y:{field:{group:`y`},mult:-1},width:{field:{group:`width`}}},t.encode.update={...FZ(t.encode.update,[`x`,`xc`,`x2`]),width:{field:{group:`width`}}});for(let n of C4){let r=o$(n,e.markDef,e.config);t.encode.update[n]?(a[n]=t.encode.update[n],delete t.encode.update[n]):r&&(a[n]=t$(r)),r&&(t.encode.update[n]={value:0})}let s=[];if(e.stack.groupbyChannels?.length>0)for(let t of e.stack.groupbyChannels){let n=e.fieldDef(t),r=Q(n);r&&s.push(r),(n?.bin||n?.timeUnit)&&s.push(Q(n,{binSuffix:`end`}))}return a=[`stroke`,`strokeWidth`,`strokeJoin`,`strokeCap`,`strokeDash`,`strokeDashOffset`,`strokeMiterLimit`,`strokeOpacity`].reduce((n,r)=>{if(t.encode.update[r])return{...n,[r]:t.encode.update[r]};{let t=o$(r,e.markDef,e.config);return t===void 0?n:{...n,[r]:t$(t)}}},a),a.stroke&&(a.strokeForeground={value:!0},a.strokeOffset={value:0}),[{type:`group`,from:{facet:{data:e.requestDataName(M3.Main),name:s8+e.requestDataName(M3.Main),groupby:s,aggregate:{fields:[r({suffix:`start`}),r({suffix:`start`}),r({suffix:`end`}),r({suffix:`end`})],ops:[`min`,`max`,`min`,`max`]}}},encode:{update:a},marks:[{type:`group`,encode:{update:o},marks:[t]}]}]}function RLe(e){let{encoding:t,stack:n,mark:r,markDef:i,config:a}=e,o=t.order;if(!(!H(o)&&_1(o)&&LZ(o.value)||!o&&LZ(a$(`order`,i,a)))){if((H(o)||Z(o))&&!n)return l$(o,{expr:`datum`});if(V$(r)){let e=i.orient===`horizontal`?`y`:`x`,n=t[e];if(Z(n))return{field:e}}}}function v2(e,t={fromPrefix:``}){let{mark:n,markDef:r,encoding:i,config:a}=e,o=cQ(r.clip,zLe(e),BLe(e)),s=i$(r),c=i.key,l=RLe(e),u=VLe(e);u&&Object.values(e.component.selection).some(e=>e.type===`point`&&!e.bind&&e.on!==`pointerover`)&&(e.markDef.cursor??=`pointer`);let d=a$(`aria`,r,a),f=a8[n].postEncodingTransform?a8[n].postEncodingTransform(e):null;return[{name:e.getName(`marks`),type:a8[n].vgMark,...o?{clip:o}:{},...s?{style:s}:{},...c?{key:c.field}:{},...l?{sort:l}:{},...u||{},...d===!1?{aria:d}:{},from:{data:t.fromPrefix+e.requestDataName(M3.Main)},encode:{update:a8[n].encodeEntry(e)},...f?{transform:f}:{}}]}function zLe(e){let t=e.getScaleComponent(`x`),n=e.getScaleComponent(`y`);return t?.get(`selectionExtent`)||n?.get(`selectionExtent`)?!0:void 0}function BLe(e){let t=e.component.projection;return t&&!t.isFit?!0:void 0}function VLe(e){if(!e.component.selection)return null;let t=$(e.component.selection).length,n=t,r=e.parent;for(;r&&n===0;)n=$(r.component.selection).length,r=r.parent;return n?{interactive:t>0||e.mark===`geoshape`||!!e.encoding.tooltip||!!e.markDef.tooltip}:null}function y2(e,t,n,r,i){if(a1(e))return new zBe(e,t,n,i);if($1(e))return new rVe(e,t,n,r,i);if(P1(e))return new c8(e,t,n,r,i);if(vMe(e))return new BBe(e,t,n,i);throw Error(f$(e))}function HLe(e,t={}){t.logger&&hAe(t.logger),t.fieldTitle&&Fje(t.fieldTitle);try{let n=DMe(kh(t.config,e.config)),r=wNe(e,n),i=y2(r,null,``,void 0,n);return i.parse(),XFe(i.component.data,i),{spec:WLe(i,ULe(e,r.autosize,n,i),e.datasets,e.usermeta),normalized:r}}finally{t.logger&&gAe(),t.fieldTitle&&Ije()}}function ULe(e,t,n,r){let i=r.component.layoutSize.get(`width`),a=r.component.layoutSize.get(`height`);if(t===void 0?(t={type:`pad`},r.hasAxisOrientSignalRef()&&(t.resize=!0)):xg(t)&&(t={type:t}),i&&a&&ONe(t.type)){if(i===`step`&&a===`step`)X(fke()),t.type=`pad`;else if(i===`step`||a===`step`){let e=i===`step`?`width`:`height`;X(fke(kQ(e))),t.type=kNe(e===`width`?`height`:`width`)}}return{...$(t).length===1&&t.type?t.type===`pad`?{}:{autosize:t.type}:{autosize:t},...ANe(n,!1),...ANe(e,!0)}}function WLe(e,t,n={},r){let i=e.config?OMe(e.config):void 0,a=lLe(e.component.data,n),o=e.assembleSelectionData(a),s=e.assembleProjections(),c=e.assembleTitle(),l=e.assembleGroupStyle(),u=e.assembleGroupEncodeEntry(!0),d=e.assembleLayoutSignals();d=d.filter(e=>(e.name===`width`||e.name===`height`)&&e.value!==void 0?(t[e.name]=+e.value,!1):!0);let{params:f,...p}=t;return{$schema:`https://vega.github.io/schema/vega/v6.json`,...e.description?{description:e.description}:{},...p,...c?{title:c}:{},...l?{style:l}:{},...u?{encode:{update:u}}:{},data:o,...s.length>0?{projections:s}:{},...e.assembleGroup([...d,...e.assembleSelectionTopLevelSignals([]),..._Me(f)]),...i?{config:i}:{},...r?{usermeta:r}:{}}}var GLe,b2,$,x2,S2,C2,w2,T2,E2,D2,O2,k2,A2,j2,M2,N2,P2,F2,I2,L2,R2,z2,B2,V2,H2,U2,W2,G2,K2,q2,J2,Y2,X2,Z2,Q2,$2,e4,t4,n4,r4,i4,a4,o4,s4,KLe,c4,l4,qLe,u4,d4,f4,p4,JLe,YLe,XLe,ZLe,QLe,$Le,eRe,tRe,nRe,rRe,iRe,aRe,oRe,sRe,cRe,lRe,uRe,dRe,fRe,pRe,mRe,hRe,gRe,_Re,vRe,m4,yRe,h4,g4,_4,bRe,v4,xRe,SRe,CRe,wRe,TRe,ERe,DRe,ORe,kRe,y4,ARe,b4,x4,S4,jRe,MRe,NRe,PRe,FRe,IRe,LRe,RRe,zRe,C4,BRe,VRe,HRe,URe,WRe,GRe,KRe,qRe,w4,JRe,YRe,XRe,ZRe,QRe,T4,$Re,eze,tze,E4,D4,O4,nze,k4,rze,A4,j4,ize,aze,M4,N4,P4,F4,I4,L4,R4,z4,oze,B4,V4,H4,sze,cze,lze,uze,dze,fze,pze,mze,hze,gze,_ze,U4,W4,G4,K4,vze,q4,J4,yze,Y4,X4,Z4,bze,Q4,$4,e3,xze,Sze,Cze,wze,t3,n3,Tze,Eze,r3,Dze,i3,Oze,kze,a3,Aze,o3,s3,c3,l3,u3,jze,d3,Mze,f3,p3,m3,Nze,Pze,h3,Fze,Ize,g3,Lze,Rze,_3,zze,v3,y3,Bze,Vze,b3,x3,Hze,Uze,S3,Wze,C3,Gze,w3,Kze,T3,E3,D3,qze,Jze,Yze,Xze,O3,Zze,Qze,$ze,k3,eBe,tBe,nBe,rBe,A3,iBe,aBe,oBe,sBe,j3,cBe,M3,N3,P3,F3,I3,L3,R3,lBe,uBe,z3,B3,V3,H3,U3,W3,G3,K3,dBe,fBe,pBe,q3,J3,Y3,X3,Z3,mBe,hBe,gBe,_Be,vBe,Q3,$3,e6,t6,n6,yBe,r6,i6,a6,bBe,o6,s6,xBe,c6,l6,SBe,u6,d6,f6,p6,m6,h6,g6,CBe,_6,wBe,v6,y6,b6,x6,S6,C6,w6,T6,E6,D6,O6,k6,A6,TBe,EBe,DBe,OBe,kBe,ABe,jBe,MBe,NBe,PBe,FBe,j6,M6,N6,P6,F6,I6,L6,IBe,R6,z6,LBe,B6,V6,RBe,H6,U6,W6,G6,K6,q6,J6,Y6,X6,Z6,Q6,$6,e8,t8,n8,r8,zBe,BBe,i8,VBe,HBe,UBe,WBe,GBe,KBe,qBe,JBe,YBe,XBe,ZBe,QBe,$Be,eVe,tVe,nVe,a8,o8,s8,c8,rVe,iVe,aVe=o((()=>{Ag(),zY(),nK(),qOe(),GLe={version:`6.4.3`},b2=structuredClone,Set.prototype.toJSON=function(){return`Set(${[...this].map(e=>hQ(e)).join(`,`)})`},$=Object.keys,x2=Object.values,S2=Object.entries,C2=42,w2=Object.getPrototypeOf(structuredClone({})),T2=`row`,E2=`column`,D2=`facet`,O2=`x`,k2=`y`,A2=`x2`,j2=`y2`,M2=`xOffset`,N2=`yOffset`,P2=`radius`,F2=`radius2`,I2=`theta`,L2=`theta2`,R2=`latitude`,z2=`longitude`,B2=`latitude2`,V2=`longitude2`,H2=`time`,U2=`color`,W2=`fill`,G2=`stroke`,K2=`shape`,q2=`size`,J2=`angle`,Y2=`opacity`,X2=`fillOpacity`,Z2=`strokeOpacity`,Q2=`strokeWidth`,$2=`strokeDash`,e4=`text`,t4=`order`,n4=`detail`,r4=`key`,i4=`tooltip`,a4=`href`,o4=`url`,s4=`description`,KLe={x:1,y:1,x2:1,y2:1},c4={theta:1,theta2:1,radius:1,radius2:1},l4={longitude:1,longitude2:1,latitude:1,latitude2:1},qLe=$(l4),u4={...KLe,...c4,...l4,xOffset:1,yOffset:1,color:1,fill:1,stroke:1,time:1,opacity:1,fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeDash:1,size:1,angle:1,shape:1,order:1,text:1,detail:1,key:1,tooltip:1,href:1,url:1,description:1},d4={row:1,column:1,facet:1},f4=$(d4),p4={...u4,...d4},JLe=$(p4),{order:YLe,detail:XLe,tooltip:ZLe,...QLe}=p4,{row:$Le,column:eRe,facet:tRe,...nRe}=QLe,rRe=[A2,j2,B2,V2,L2,F2],iRe=$(u4),{x:aRe,y:oRe,x2:sRe,y2:cRe,xOffset:lRe,yOffset:uRe,latitude:dRe,longitude:fRe,latitude2:pRe,longitude2:mRe,theta:hRe,theta2:gRe,radius:_Re,radius2:vRe,...m4}=u4,yRe=$(m4),h4={x:1,y:1},g4=$(h4),_4={theta:1,radius:1},bRe=$(_4),v4={xOffset:1,yOffset:1},xRe={time:1},{text:SRe,tooltip:CRe,href:wRe,url:TRe,description:ERe,detail:DRe,key:ORe,order:kRe,...y4}=m4,ARe=$(y4),b4={...h4,..._4,...v4,...y4},x4=$(b4),S4={arc:`always`,area:`always`,bar:`always`,circle:`always`,geoshape:`always`,image:`always`,line:`always`,rule:`always`,point:`always`,rect:`always`,square:`always`,trail:`always`,text:`always`,tick:`always`},{geoshape:jRe,...MRe}=S4,NRe={argmax:1,argmin:1,average:1,count:1,distinct:1,exponential:1,exponentialb:1,product:1,max:1,mean:1,median:1,min:1,missing:1,q1:1,q3:1,ci0:1,ci1:1,stderr:1,stdev:1,stdevp:1,sum:1,valid:1,values:1,variance:1,variancep:1},PRe={count:1,min:1,max:1},FRe=new Set([`count`,`valid`,`missing`,`distinct`]),IRe=new Set([`count`,`sum`,`distinct`,`valid`,`missing`]),LRe=new Set([`mean`,`average`,`median`,`q1`,`q3`,`min`,`max`]),RRe=$({aria:1,description:1,ariaRole:1,ariaRoleDescription:1,blend:1,opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeOffset:1,strokeMiterLimit:1,startAngle:1,endAngle:1,padAngle:1,innerRadius:1,outerRadius:1,size:1,shape:1,interpolate:1,tension:1,orient:1,align:1,baseline:1,text:1,dir:1,dx:1,dy:1,ellipsis:1,limit:1,radius:1,theta:1,angle:1,font:1,fontSize:1,fontWeight:1,fontStyle:1,lineBreak:1,lineHeight:1,cursor:1,href:1,tooltip:1,cornerRadius:1,cornerRadiusTopLeft:1,cornerRadiusTopRight:1,cornerRadiusBottomLeft:1,cornerRadiusBottomRight:1,aspect:1,width:1,height:1,url:1,smooth:1}),zRe={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},C4=[`cornerRadius`,`cornerRadiusTopLeft`,`cornerRadiusTopRight`,`cornerRadiusBottomLeft`,`cornerRadiusBottomRight`],BRe=` – `,VRe=`Autosize "fit" only works for single views and layered views.`,HRe=`Scale bindings are currently only supported for scales with unbinned, continuous domains.`,URe=`Sequntial scales are deprecated. The available quantitative scale type values are linear, log, pow, sqrt, symlog, time and utc`,WRe=`Legend bindings are only supported for selections over an individual field or encoding channel.`,GRe=`The same selection must be used to override scale domains in a layered view.`,KRe=`Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.`,qRe=`Multiple timer selections in one unit spec are not supported. Ignoring all but the first.`,w4=`Animation involving facet, layer, or concat is currently unsupported.`,JRe=`Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).`,YRe=`Attempt to add the same child twice.`,XRe=`If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.`,ZRe=`Arc marks uses theta channel rather than angle, replacing angle with theta.`,QRe=`Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.`,T4=`Domains that should be unioned has conflicting sort properties. Sort will be set to true.`,$Re=`Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect.`,eze=`Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect.`,tze=`Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.`,E4=Th(2),D4=E4,O4=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`],nze=O4.map(e=>e.substr(0,3)),k4=[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`],rze=k4.map(e=>e.substr(0,3)),A4={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},j4=$(A4),ize={"year-month":`%b %Y `,"year-month-date":`%b %d, %Y `},aze={year:1,month:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},M4={quantitative:`quantitative`,ordinal:`ordinal`,temporal:`temporal`,nominal:`nominal`,geojson:`geojson`},N4=M4.quantitative,P4=M4.ordinal,F4=M4.temporal,I4=M4.nominal,L4=M4.geojson,R4={LINEAR:`linear`,LOG:`log`,POW:`pow`,SQRT:`sqrt`,TIME:`time`,UTC:`utc`,POINT:`point`,BAND:`band`},z4={linear:`numeric`,log:`numeric`,pow:`numeric`,sqrt:`numeric`,symlog:`numeric`,identity:`numeric`,sequential:`numeric`,time:`time`,utc:`time`,ordinal:`ordinal`,"bin-ordinal":`bin-ordinal`,point:`ordinal-position`,band:`ordinal-position`,quantile:`discretizing`,quantize:`discretizing`,threshold:`discretizing`},oze={linear:0,log:1,pow:1,sqrt:1,symlog:1,identity:1,sequential:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0},B4=new Set([`linear`,`log`,`pow`,`sqrt`,`symlog`]),V4=new Set([...B4,`time`,`utc`]),H4=new Set([`quantile`,`quantize`,`threshold`]),sze=new Set([...V4,...H4,`sequential`,`identity`]),cze=new Set([`ordinal`,`bin-ordinal`,`point`,`band`]),lze={pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,tickBandPaddingInner:.25,bandWithNestedOffsetPaddingInner:.2,bandWithNestedOffsetPaddingOuter:.2,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:4,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4,zero:!0,framesPerSecond:2,animationDuration:5},{type:uze,domain:dze,range:fze,rangeMax:pze,rangeMin:mze,scheme:hze,...gze}={type:1,domain:1,domainMax:1,domainMin:1,domainMid:1,domainRaw:1,align:1,range:1,rangeMax:1,rangeMin:1,scheme:1,bins:1,reverse:1,round:1,clamp:1,nice:1,base:1,exponent:1,constant:1,interpolate:1,zero:1,padding:1,paddingInner:1,paddingOuter:1},_ze=$(gze),U4={arc:`arc`,area:`area`,bar:`bar`,image:`image`,line:`line`,point:`point`,rect:`rect`,rule:`rule`,text:`text`,tick:`tick`,trail:`trail`,circle:`circle`,square:`square`,geoshape:`geoshape`},W4=U4.arc,G4=U4.area,K4=U4.bar,vze=U4.image,q4=U4.line,J4=U4.point,yze=U4.rect,Y4=U4.rule,X4=U4.text,Z4=U4.tick,bze=U4.trail,Q4=U4.circle,$4=U4.square,e3=U4.geoshape,xze=new Set($(U4)),Sze=[`stroke`,`strokeWidth`,`strokeDash`,`strokeDashOffset`,`strokeOpacity`,`strokeJoin`,`strokeMiterLimit`],Cze=[`fill`,`fillOpacity`],wze=[...Sze,...Cze],t3=$({color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1}),n3=[`binSpacing`,`continuousBandSize`,`discreteBandSize`,`minBandSize`],Tze={area:[`line`,`point`],bar:n3,rect:n3,line:[`point`],tick:[`bandSize`,`thickness`,...n3]},Eze={color:`#4c78a8`,invalid:`break-paths-show-path-domains`,timeUnitBandSize:1},r3=$({mark:1,arc:1,area:1,bar:1,circle:1,image:1,line:1,point:1,rect:1,rule:1,square:1,text:1,tick:1,trail:1,geoshape:1}),Dze={horizontal:[`cornerRadiusTopRight`,`cornerRadiusBottomRight`],vertical:[`cornerRadiusTopLeft`,`cornerRadiusTopRight`]},i3={binSpacing:0,continuousBandSize:5,minBandSize:.25,timeUnitBandPosition:.5},Oze={...i3,binSpacing:1},kze={...i3,thickness:1},a3=`min`,Aze={x:1,y:1,color:1,fill:1,stroke:1,strokeWidth:1,size:1,shape:1,fillOpacity:1,strokeOpacity:1,opacity:1,text:1},o3=(e,t)=>{switch(t.fieldTitle){case`plain`:return e.field;case`functional`:return Pje(e);default:return Nje(e,t)}},s3=o3,c3={compatible:!0},l3={labelAlign:{part:`labels`,vgProp:`align`},labelBaseline:{part:`labels`,vgProp:`baseline`},labelColor:{part:`labels`,vgProp:`fill`},labelFont:{part:`labels`,vgProp:`font`},labelFontSize:{part:`labels`,vgProp:`fontSize`},labelFontStyle:{part:`labels`,vgProp:`fontStyle`},labelFontWeight:{part:`labels`,vgProp:`fontWeight`},labelOpacity:{part:`labels`,vgProp:`opacity`},labelOffset:null,labelPadding:null,gridColor:{part:`grid`,vgProp:`stroke`},gridDash:{part:`grid`,vgProp:`strokeDash`},gridDashOffset:{part:`grid`,vgProp:`strokeDashOffset`},gridOpacity:{part:`grid`,vgProp:`opacity`},gridWidth:{part:`grid`,vgProp:`strokeWidth`},tickColor:{part:`ticks`,vgProp:`stroke`},tickDash:{part:`ticks`,vgProp:`strokeDash`},tickDashOffset:{part:`ticks`,vgProp:`strokeDashOffset`},tickOpacity:{part:`ticks`,vgProp:`opacity`},tickSize:null,tickWidth:{part:`ticks`,vgProp:`strokeWidth`}},u3=[`domain`,`grid`,`labels`,`ticks`,`title`],jze={grid:`grid`,gridCap:`grid`,gridColor:`grid`,gridDash:`grid`,gridDashOffset:`grid`,gridOpacity:`grid`,gridScale:`grid`,gridWidth:`grid`,orient:`main`,bandPosition:`both`,aria:`main`,description:`main`,domain:`main`,domainCap:`main`,domainColor:`main`,domainDash:`main`,domainDashOffset:`main`,domainOpacity:`main`,domainWidth:`main`,format:`main`,formatType:`main`,labelAlign:`main`,labelAngle:`main`,labelBaseline:`main`,labelBound:`main`,labelColor:`main`,labelFlush:`main`,labelFlushOffset:`main`,labelFont:`main`,labelFontSize:`main`,labelFontStyle:`main`,labelFontWeight:`main`,labelLimit:`main`,labelLineHeight:`main`,labelOffset:`main`,labelOpacity:`main`,labelOverlap:`main`,labelPadding:`main`,labels:`main`,labelSeparation:`main`,maxExtent:`main`,minExtent:`main`,offset:`both`,position:`main`,tickCap:`main`,tickColor:`main`,tickDash:`main`,tickDashOffset:`main`,tickMinStep:`both`,tickOffset:`both`,tickOpacity:`main`,tickRound:`both`,ticks:`main`,tickSize:`main`,tickWidth:`both`,title:`main`,titleAlign:`main`,titleAnchor:`main`,titleAngle:`main`,titleBaseline:`main`,titleColor:`main`,titleFont:`main`,titleFontSize:`main`,titleFontStyle:`main`,titleFontWeight:`main`,titleLimit:`main`,titleLineHeight:`main`,titleOpacity:`main`,titlePadding:`main`,titleX:`main`,titleY:`main`,encode:`both`,scale:`both`,tickBand:`both`,tickCount:`both`,tickExtra:`both`,translate:`both`,values:`both`,zindex:`both`},d3={orient:1,aria:1,bandPosition:1,description:1,domain:1,domainCap:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid:1,gridCap:1,gridColor:1,gridDash:1,gridDashOffset:1,gridOpacity:1,gridWidth:1,labelAlign:1,labelAngle:1,labelBaseline:1,labelBound:1,labelColor:1,labelFlush:1,labelFlushOffset:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelLineHeight:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickBand:1,tickCap:1,tickColor:1,tickCount:1,tickDash:1,tickDashOffset:1,tickExtra:1,tickMinStep:1,tickOffset:1,tickOpacity:1,tickRound:1,ticks:1,tickSize:1,tickWidth:1,title:1,titleAlign:1,titleAnchor:1,titleAngle:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,translate:1,values:1,zindex:1},Mze={...d3,style:1,labelExpr:1,encoding:1},f3=$({axis:1,axisBand:1,axisBottom:1,axisDiscrete:1,axisLeft:1,axisPoint:1,axisQuantitative:1,axisRight:1,axisTemporal:1,axisTop:1,axisX:1,axisXBand:1,axisXDiscrete:1,axisXPoint:1,axisXQuantitative:1,axisXTemporal:1,axisY:1,axisYBand:1,axisYDiscrete:1,axisYPoint:1,axisYQuantitative:1,axisYTemporal:1}),p3=class{name;run;constructor(e,t){this.name=e,this.run=t}hasMatchingType(e){return P1(e)?eje(e.mark)===this.name:!1}},m3=`boxplot`,Nze=[`box`,`median`,`outliers`,`rule`,`ticks`],Pze=new p3(m3,iMe),h3=`errorbar`,Fze=[`ticks`,`rule`],Ize=new p3(h3,sMe),g3=`errorband`,Lze=[`band`,`borders`],Rze=new p3(g3,hMe),_3={},H1(m3,iMe,Nze),H1(h3,sMe,Fze),H1(g3,hMe,Lze),zze=[`gradientHorizontalMaxLength`,`gradientHorizontalMinLength`,`gradientVerticalMaxLength`,`gradientVerticalMinLength`,`unselectedOpacity`],v3={titleAlign:`align`,titleAnchor:`anchor`,titleAngle:`angle`,titleBaseline:`baseline`,titleColor:`color`,titleFont:`font`,titleFontSize:`fontSize`,titleFontStyle:`fontStyle`,titleFontWeight:`fontWeight`,titleLimit:`limit`,titleLineHeight:`lineHeight`,titleOrient:`orient`,titlePadding:`offset`},y3={labelAlign:`align`,labelAnchor:`anchor`,labelAngle:`angle`,labelBaseline:`baseline`,labelColor:`color`,labelFont:`font`,labelFontSize:`fontSize`,labelFontStyle:`fontStyle`,labelFontWeight:`fontWeight`,labelLimit:`limit`,labelLineHeight:`lineHeight`,labelOrient:`orient`,labelPadding:`offset`},Bze=$(v3),Vze=$(y3),b3=$({header:1,headerRow:1,headerColumn:1,headerFacet:1}),x3=[`size`,`shape`,`fill`,`stroke`,`strokeDash`,`strokeWidth`,`opacity`],Hze={gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},Uze={aria:1,clipHeight:1,columnPadding:1,columns:1,cornerRadius:1,description:1,direction:1,fillColor:1,format:1,formatType:1,gradientLength:1,gradientOpacity:1,gradientStrokeColor:1,gradientStrokeWidth:1,gradientThickness:1,gridAlign:1,labelAlign:1,labelBaseline:1,labelColor:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labelSeparation:1,legendX:1,legendY:1,offset:1,orient:1,padding:1,rowPadding:1,strokeColor:1,symbolDash:1,symbolDashOffset:1,symbolFillColor:1,symbolLimit:1,symbolOffset:1,symbolOpacity:1,symbolSize:1,symbolStrokeColor:1,symbolStrokeWidth:1,symbolType:1,tickCount:1,tickMinStep:1,title:1,titleAlign:1,titleAnchor:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1},S3=`_vgsid_`,Wze={point:{on:`click`,fields:[S3],toggle:`event.shiftKey`,resolve:`global`,clear:`dblclick`},interval:{on:`[pointerdown, window:pointerup] > window:pointermove!`,encodings:[`x`,`y`],translate:`[pointerdown, window:pointerup] > window:pointermove!`,zoom:`wheel!`,mark:{fill:`#333`,fillOpacity:.125,stroke:`white`},resolve:`global`,clear:`dblclick`}},C3=20,Gze=$({align:1,bounds:1,center:1,columns:1,spacing:1}),w3=20,Kze={background:`white`,padding:5,timeFormat:`%b %d, %Y`,countTitle:`Count of Records`,view:{continuousWidth:300,continuousHeight:300,step:w3},mark:Eze,arc:{},area:{},bar:Oze,circle:{},geoshape:{},image:{},line:{},point:{},rect:i3,rule:{color:`black`},square:{},text:{color:`black`},tick:kze,trail:{},boxplot:{size:14,extent:1.5,box:{},median:{color:`white`},outliers:{},rule:{},ticks:null},errorbar:{center:`mean`,rule:!0,ticks:!1},errorband:{band:{opacity:.3},borders:!1},scale:lze,projection:{},legend:Hze,header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:Wze,style:{},title:{},facet:{spacing:C3},concat:{spacing:C3},normalizedNumberFormat:`.0%`},T3=[`#4c78a8`,`#f58518`,`#e45756`,`#72b7b2`,`#54a24b`,`#eeca3b`,`#b279a2`,`#ff9da6`,`#9d755d`,`#bab0ac`],E3={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},D3={blue:T3[0],orange:T3[1],red:T3[2],teal:T3[3],green:T3[4],yellow:T3[5],purple:T3[6],pink:T3[7],brown:T3[8],gray0:`#000`,gray1:`#111`,gray2:`#222`,gray3:`#333`,gray4:`#444`,gray5:`#555`,gray6:`#666`,gray7:`#777`,gray8:`#888`,gray9:`#999`,gray10:`#aaa`,gray11:`#bbb`,gray12:`#ccc`,gray13:`#ddd`,gray14:`#eee`,gray15:`#fff`},qze=[...r3,...f3,...b3,`background`,`padding`,`legend`,`lineBreak`,`scale`,`style`,`title`,`view`],Jze=new Set([`view`,...xze]),Yze=`color.fontSize.background.padding.facet.concat.numberFormat.numberFormatType.normalizedNumberFormat.normalizedNumberFormatType.timeFormat.countTitle.header.axisQuantitative.axisTemporal.axisDiscrete.axisPoint.axisXBand.axisXPoint.axisXDiscrete.axisXQuantitative.axisXTemporal.axisYBand.axisYPoint.axisYDiscrete.axisYQuantitative.axisYTemporal.scale.selection.overlay`.split(`.`),Xze={view:[`continuousWidth`,`continuousHeight`,`discreteWidth`,`discreteHeight`,`step`],...Tze},O3=class{map(e,t){return a1(e)?this.mapFacet(e,t):jMe(e)?this.mapRepeat(e,t):J1(e)?this.mapHConcat(e,t):q1(e)?this.mapVConcat(e,t):K1(e)?this.mapConcat(e,t):this.mapLayerOrUnit(e,t)}mapLayerOrUnit(e,t){if($1(e))return this.mapLayer(e,t);if(P1(e))return this.mapUnit(e,t);throw Error(f$(e))}mapLayer(e,t){return{...e,layer:e.layer.map(e=>this.mapLayerOrUnit(e,t))}}mapHConcat(e,t){return{...e,hconcat:e.hconcat.map(e=>this.map(e,t))}}mapVConcat(e,t){return{...e,vconcat:e.vconcat.map(e=>this.map(e,t))}}mapConcat(e,t){let{concat:n,...r}=e;return{...r,concat:n.map(e=>this.map(e,t))}}mapFacet(e,t){return{...e,spec:this.map(e.spec,t)}}mapRepeat(e,t){return{...e,spec:this.map(e.spec,t)}}},Zze={zero:1,center:1,normalize:1},Qze=new Set([W4,K4,G4,Y4,J4,Q4,$4,q4,X4,Z4]),$ze=new Set([K4,G4,W4]),k3=.7,eBe=class{name=`path-overlay`;hasMatchingType(e,t){if(P1(e)){let{mark:n,encoding:r}=e,i=U$(n)?n:{type:n};switch(i.type){case`line`:case`rule`:case`trail`:return!!t0(i,t[i.type],r);case`area`:return!!t0(i,t[i.type],r)||!!WMe(i,t[i.type])}}return!1}run(e,t,n){let{config:r}=t,{params:i,projection:a,mark:o,name:s,encoding:c,...l}=e,u=I1(c,r),d=U$(o)?o:{type:o},f=t0(d,r[d.type],u),p=d.type===`area`&&WMe(d,r[d.type]),m=[{name:s,...i?{params:i}:{},mark:HMe({...d.type===`area`&&a$(`opacity`,d,r)==null&&a$(`fillOpacity`,d,r)==null?{opacity:k3}:{},...d}),encoding:FZ(u,[`shape`])}],h=IMe(LMe(d,u,r),u),g=u;if(h){let{fieldChannel:e,offset:t}=h;g={...u,[e]:{...u[e],...t?{stack:t}:{}}}}return g=FZ(g,[`y2`,`x2`]),p&&m.push({...a?{projection:a}:{},mark:{type:`line`,...PZ(d,[`clip`,`interpolate`,`tension`,`tooltip`]),...p},encoding:g}),f&&m.push({...a?{projection:a}:{},mark:{type:`point`,opacity:1,filled:!0,...PZ(d,[`clip`,`tooltip`]),...f},encoding:g}),n({...l,layer:m},{...t,config:UMe(r)})}},tBe=class{name=`RuleForRangedLine`;hasMatchingType(e){if(P1(e)){let{encoding:t,mark:n}=e;if(n===`line`||U$(n)&&n.type===`line`)for(let e of rRe){let n=t[SQ(e)];if(t[e]&&(Z(n)&&!BQ(n.bin)||f1(n)))return!0}}return!1}run(e,t,n){let{encoding:r,mark:i}=e;return X(Vke(!!r.x2,!!r.y2)),n({...e,mark:Dh(i)?{...i,type:`rule`}:`rule`},t)}},nBe=class extends O3{nonFacetUnitNormalizers=[Pze,Ize,Rze,new eBe,new tBe];map(e,t){if(P1(e)){let n=F1(e.encoding,T2),r=F1(e.encoding,E2),i=F1(e.encoding,D2);if(n||r||i)return this.mapFacetedUnit(e,t)}return super.map(e,t)}mapUnit(e,t){let{parentEncoding:n,parentProjection:r}=t,i=n0(e.encoding,t.repeater),a={...e,...e.name?{name:[t.repeaterPrefix,e.name].filter(e=>e).join(`_`)}:{},...i?{encoding:i}:{}};if(n||r)return this.mapUnitWithParentEncodingOrProjection(a,t);let o=this.mapLayerOrUnit.bind(this);for(let e of this.nonFacetUnitNormalizers)if(e.hasMatchingType(a,t.config))return e.run(a,t,o);return a}mapRepeat(e,t){return MMe(e)?this.mapLayerRepeat(e,t):this.mapNonLayerRepeat(e,t)}mapLayerRepeat(e,t){let{repeat:n,spec:r,...i}=e,{row:a,column:o,layer:s}=n,{repeater:c={},repeaterPrefix:l=``}=t;return a||o?this.mapRepeat({...e,repeat:{...a?{row:a}:{},...o?{column:o}:{}},spec:{repeat:{layer:s},spec:r}},t):{...i,layer:s.map(e=>{let n={...c,layer:e},i=`${(r.name?`${r.name}_`:``)+l}child__layer_${XZ(e)}`,a=this.mapLayerOrUnit(r,{...t,repeater:n,repeaterPrefix:i});return a.name=i,a})}}mapNonLayerRepeat(e,t){let{repeat:n,spec:r,data:i,...a}=e;!H(n)&&e.columns&&(e=FZ(e,[`columns`]),X(xke(`repeat`)));let o=[],{repeater:s={},repeaterPrefix:c=``}=t,l=!H(n)&&n.row||[s?s.row:null],u=!H(n)&&n.column||[s?s.column:null],d=H(n)&&n||[s?s.repeat:null];for(let e of d)for(let i of l)for(let a of u){let l={repeat:e,row:i,column:a,layer:s.layer},u=`${(r.name?`${r.name}_`:``)+c}child__${H(n)?`${XZ(e)}`:(n.row?`row_${XZ(i)}`:``)+(n.column?`column_${XZ(a)}`:``)}`,d=this.map(r,{...t,repeater:l,repeaterPrefix:u});d.name=u,o.push(FZ(d,[`data`]))}let f=H(n)?e.columns:n.column?n.column.length:1;return{data:r.data??i,align:`all`,...a,columns:f,concat:o}}mapFacet(e,t){let{facet:n}=e;return r1(n)&&e.columns&&(e=FZ(e,[`columns`]),X(xke(`facet`))),super.mapFacet(e,t)}mapUnitWithParentEncodingOrProjection(e,t){let{encoding:n,projection:r}=e,{parentEncoding:i,parentProjection:a,config:o}=t,s=ZMe({parentProjection:a,projection:r}),c=XMe({parentEncoding:i,encoding:n0(n,t.repeater)});return this.mapUnit({...e,...s?{projection:s}:{},...c?{encoding:c}:{}},{config:o})}mapFacetedUnit(e,t){let{row:n,column:r,facet:i,...a}=e.encoding,{mark:o,width:s,projection:c,height:l,view:u,params:d,encoding:f,...p}=e,{facetMapping:m,layout:h}=this.getFacetMappingAndLayout({row:n,column:r,facet:i},t),g=n0(a,t.repeater);return this.mapFacet({...p,...h,facet:m,spec:{...s?{width:s}:{},...l?{height:l}:{},...u?{view:u}:{},...c?{projection:c}:{},mark:o,encoding:g,...d?{params:d}:{}}},t)}getFacetMappingAndLayout(e,t){let{row:n,column:r,facet:i}=e;if(n||r){i&&X(zke([...n?[T2]:[],...r?[E2]:[]]));let t={},a={};for(let n of[T2,E2]){let r=e[n];if(r){let{align:e,center:i,spacing:o,columns:s,...c}=r;t[n]=c;for(let e of[`align`,`center`,`spacing`])r[e]!==void 0&&(a[e]??={},a[e][n]=r[e])}}return{facetMapping:t,layout:a}}else{let{align:e,center:n,spacing:r,columns:a,...o}=i;return{facetMapping:GMe(o,t.repeater),layout:{...e?{align:e}:{},...n?{center:n}:{},...r?{spacing:r}:{},...a?{columns:a}:{}}}}}mapLayer(e,{parentEncoding:t,parentProjection:n,...r}){let{encoding:i,projection:a,...o}=e,s={...r,parentEncoding:XMe({parentEncoding:t,encoding:i,layer:!0}),parentProjection:ZMe({parentProjection:n,projection:a})};return super.mapLayer({...o,...e.name?{name:[s.repeaterPrefix,e.name].filter(e=>e).join(`_`)}:{}},s)}},rBe=class extends O3{map(e,t){return t.emptySelections??={},t.selectionPredicates??={},e=bNe(e,t),super.map(e,t)}mapLayerOrUnit(e,t){if(e=bNe(e,t),e.encoding){let n={};for(let[r,i]of S2(e.encoding))n[r]=xNe(i,t);e={...e,encoding:n}}return super.mapLayerOrUnit(e,t)}mapUnit(e,t){let{selection:n,...r}=e;return n?{...r,params:S2(n).map(([e,n])=>{let{init:r,bind:i,empty:a,...o}=n;o.type===`single`?(o.type=`point`,o.toggle=!1):o.type===`multi`&&(o.type=`point`),t.emptySelections[e]=a!==`none`;for(let n of x2(t.selectionPredicates[e]??{}))n.empty=a!==`none`;return{name:e,value:r,select:o,bind:i}})}:e}},A3=class extends O3{map(e,t){let n=t.selections??[];if(e.params&&!P1(e)){let t=[];for(let r of e.params)G1(r)?n.push(r):t.push(r);e.params=t}return t.selections=n,super.map(e,t)}mapUnit(e,t){let n=t.selections;if(!n||!n.length)return e;let r=(t.path??[]).concat(e.name),i=[];for(let t of n)if(!t.views||!t.views.length)i.push(t);else for(let n of t.views)(xg(n)&&(n===e.name||r.includes(n))||H(n)&&n.map(e=>r.indexOf(e)).every((e,t,n)=>e!==-1&&(t===0||e>n[t-1])))&&i.push(t);return i.length&&(e.params=i),e}};for(let e of[`mapFacet`,`mapRepeat`,`mapHConcat`,`mapVConcat`,`mapLayer`]){let t=A3.prototype[e];A3.prototype[e]=function(e,n){return t.call(this,e,CNe(e,n))}}iBe=new nBe,aBe=new rBe,oBe=new A3,sBe=[`background`,`padding`],j3=class e{explicit;implicit;constructor(e={},t={}){this.explicit=e,this.implicit=t}clone(){return new e(b2(this.explicit),b2(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(e){return cQ(this.explicit[e],this.implicit[e])}getWithExplicit(e){return this.explicit[e]===void 0?this.implicit[e]===void 0?{explicit:!1,value:void 0}:{explicit:!1,value:this.implicit[e]}:{explicit:!0,value:this.explicit[e]}}setWithExplicit(e,{value:t,explicit:n}){t!==void 0&&this.set(e,t,n)}set(e,t,n){return delete this[n?`implicit`:`explicit`][e],this[n?`explicit`:`implicit`][e]=t,this}copyKeyFromSplit(e,{explicit:t,implicit:n}){t[e]===void 0?n[e]!==void 0&&this.set(e,n[e],!1):this.set(e,t[e],!0)}copyKeyFromObject(e,t){t[e]!==void 0&&this.set(e,t[e],!0)}copyAll(e){for(let t of $(e.combine())){let n=e.getWithExplicit(t);this.setWithExplicit(t,n)}}},cBe=class extends j3{explicit;implicit;parseNothing;constructor(e={},t={},n=!1){super(e,t),this.explicit=e,this.implicit=t,this.parseNothing=n}clone(){let e=super.clone();return e.parseNothing=this.parseNothing,e}},(function(e){e[e.Raw=0]=`Raw`,e[e.Main=1]=`Main`,e[e.Row=2]=`Row`,e[e.Column=3]=`Column`,e[e.Lookup=4]=`Lookup`,e[e.PreFilterInvalid=5]=`PreFilterInvalid`,e[e.PostFilterInvalid=6]=`PostFilterInvalid`})(M3||={}),N3=class{debugName;_children=[];_parent=null;_hash;constructor(e,t){this.debugName=t,e&&(this.parent=e)}clone(){throw Error(`Cannot clone node`)}get parent(){return this._parent}set parent(e){this._parent=e,e&&e.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(e,t){if(this._children.includes(e)){X(YRe);return}t===void 0?this._children.push(e):this._children.splice(t,0,e)}removeChild(e){let t=this._children.indexOf(e);return this._children.splice(t,1),t}remove(){let e=this._parent.removeChild(this);for(let t of this._children)t._parent=this._parent,this._parent.addChild(t,e++)}insertAsParentOf(e){let t=e.parent;t.removeChild(this),this.parent=t,e.parent=this}swapWithParent(){let e=this._parent,t=e.parent;for(let t of this._children)t.parent=e;this._children=[],e.removeChild(this);let n=e.parent.removeChild(e);this._parent=t,t.addChild(this,n),e.parent=this}},P3=class extends N3{type;refCounts;_source;_name;clone(){let e=new this.constructor;return e.debugName=`clone_${this.debugName}`,e._source=this._source,e._name=`clone_${this._name}`,e.type=this.type,e.refCounts=this.refCounts,e.refCounts[e._name]=0,e}constructor(e,t,n,r){super(e,t),this.type=n,this.refCounts=r,this._source=this._name=t,this.refCounts&&!(this._name in this.refCounts)&&(this.refCounts[this._name]=0)}dependentFields(){return new Set}producedFields(){return new Set}hash(){return this._hash===void 0&&(this._hash=`Output ${lQ()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(e){this._source=e}},F3=class e extends N3{timeUnits;clone(){return new e(null,b2(this.timeUnits))}constructor(e,t){super(e),this.timeUnits=t}static makeFromEncoding(t,n){let r=n.reduceFieldDef((e,t,r)=>{let{field:i,timeUnit:a}=t;if(a){let o;if(S$(a)){if(c2(n)){let{mark:e,markDef:r,config:s}=n,c=s1({fieldDef:t,markDef:r,config:s});(H$(e)||c)&&(o={timeUnit:T$(a),field:i})}}else o={as:Q(t,{forAs:!0}),field:i,timeUnit:a};if(c2(n)){let{mark:e,markDef:i,config:a}=n,s=s1({fieldDef:t,markDef:i,config:a});H$(e)&&OQ(r)&&s!==.5&&(o.rectBandPosition=s)}o&&(e[IZ(o)]=o)}return e},{});return qZ(r)?null:new e(t,r)}static makeFromTransform(t,n){let{timeUnit:r,...i}={...n},a=T$(r),o={...i,timeUnit:a};return new e(t,{[IZ(o)]:o})}merge(e){this.timeUnits={...this.timeUnits};for(let t in e.timeUnits)this.timeUnits[t]||(this.timeUnits[t]=e.timeUnits[t]);for(let t of e.children)e.removeChild(t),t.parent=this;e.remove()}removeFormulas(e){let t={};for(let[n,r]of S2(this.timeUnits)){let i=m0(r)?r.as:`${r.field}_end`;e.has(i)||(t[n]=r)}this.timeUnits=t}producedFields(){return new Set(x2(this.timeUnits).map(e=>m0(e)?e.as:LNe(e.field)))}dependentFields(){return new Set(x2(this.timeUnits).map(e=>e.field))}hash(){return`TimeUnit ${IZ(this.timeUnits)}`}assemble(){let e=[];for(let t of x2(this.timeUnits)){let{rectBandPosition:n}=t,r=T$(t.timeUnit);if(m0(t)){let{field:i,as:a}=t,{unit:o,utc:s,...c}=r,l=[a,`${a}_end`];e.push({field:iQ(i),type:`timeunit`,...o?{units:w$(o)}:{},...s?{timezone:`utc`}:{},...c,as:l}),e.push(...zNe(l,n,r))}else if(t){let{field:i}=t,a=rQ(i),o=RNe({timeUnit:r,field:a}),s=LNe(a);e.push({type:`formula`,expr:o,as:s}),e.push(...zNe([a,s],n,r))}}return e}},I3=`offsetted_rect_start`,L3=`offsetted_rect_end`,R3=`_tuple_fields`,lBe=class{hasChannel;hasField;hasSelectionId;timeUnit;items;constructor(...e){this.items=e,this.hasChannel={},this.hasField={},this.hasSelectionId=!1}},uBe={defined:()=>!0,parse:(e,t,n)=>{let r=t.name,i=t.project??=new lBe,a={},o={},s=new Set,c=(e,t)=>{let n=t===`visual`?e.channel:e.field,i=XZ(`${r}_${n}`);for(let e=1;s.has(i);e++)i=XZ(`${r}_${n}_${e}`);return s.add(i),{[t]:i}},l=t.type,u=e.config.selection[l],d=n.value===void 0?null:ng(n.value),{fields:f,encodings:p}=Dh(n.select)?n.select:{};if(!f&&!p&&d){for(let e of d)if(Dh(e))for(let t of $(e))$Oe(t)?(p||=[]).push(t):l===`interval`?(X(KRe),p=u.encodings):(f??=[]).push(t)}!f&&!p&&(p=u.encodings,`fields`in u&&(f=u.fields));for(let t of p??[]){let n=e.fieldDef(t);if(n){let r=n.field;if(n.aggregate){X(mke(t,n.aggregate));continue}else if(!r){X(pke(t));continue}if(n.timeUnit&&!S$(n.timeUnit)){r=e.vgField(t);let i={timeUnit:n.timeUnit,as:r,field:n.field};o[IZ(i)]=i}if(!a[r]){let o=l===`interval`&&MQ(t)&&L$(e.getScaleComponent(t).get(`type`))?`R`:n.bin?`R-RE`:`E`,s={field:r,channel:t,type:o,index:i.items.length};s.signals={...c(s,`data`),...c(s,`visual`)},i.items.push(a[r]=s),i.hasField[r]=a[r],i.hasSelectionId=i.hasSelectionId||r===S3,vQ(t)?(s.geoChannel=t,s.channel=_Q(t),i.hasChannel[s.channel]=a[r]):i.hasChannel[t]=a[r]}}else X(pke(t))}for(let e of f??[]){if(i.hasField[e])continue;let t={type:`E`,field:e,index:i.items.length};t.signals={...c(t,`data`)},i.items.push(t),i.hasField[e]=t,i.hasSelectionId=i.hasSelectionId||e===S3}d&&(t.init=d.map(e=>i.items.map(t=>Dh(e)?e[t.geoChannel||t.channel]===void 0?e[t.field]:e[t.geoChannel||t.channel]:e))),qZ(o)||(i.timeUnit=new F3(null,o))},signals:(e,t,n)=>{let r=t.name+R3;return n.filter(e=>e.name===r).length>0||t.project.hasSelectionId?n:n.concat({name:r,value:t.project.items.map(VNe)})}},z3=`_curr`,B3=`anim_value`,V3=`anim_clock`,H3=`eased_anim_clock`,U3=`min_extent`,W3=`max_range_extent`,G3=`last_tick_at`,K3=`is_playing`,dBe=1/60*1e3,fBe=(e,t)=>[{name:H3,update:V3},{name:`${e}_domain`,init:`domain('${t}')`},{name:U3,init:`extent(${e}_domain)[0]`},{name:W3,init:`extent(range('${t}'))[1]`},{name:B3,update:`invert('${t}', ${H3})`}],pBe={defined:e=>e.type===`point`,topLevelSignals:(e,t,n)=>(N0(t)&&(n=n.concat([{name:V3,init:`0`,on:[{events:{type:`timer`,throttle:dBe},update:`${K3} ? (${V3} + (now() - ${G3}) > ${W3} ? 0 : ${V3} + (now() - ${G3})) : ${V3}`}]},{name:G3,init:`now()`,on:[{events:[{signal:V3},{signal:K3}],update:`now()`}]},{name:K3,init:`true`}])),n),signals:(e,t,n)=>{let r=t.name,i=r+R3,a=t.project,o=`(item().isVoronoi ? datum.datum : datum)`,s=x2(e.component.selection??{}).reduce((e,t)=>t.type===`interval`?e.concat(t.name+J3):e,[]).map(e=>`indexof(item().mark.name, '${e}') < 0`).join(` && `),c=`datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0${s?` && ${s}`:``}`,l=`unit: ${j0(e)}, `;if(t.project.hasSelectionId)l+=`${S3}: ${o}[${W(S3)}]`;else if(N0(t))l+=`fields: ${i}, values: [${B3} ? ${B3} : ${U3}]`;else{let t=a.items.map(t=>e.fieldDef(t.channel)?.bin?`[${o}[${W(e.vgField(t.channel,{}))}], ${o}[${W(e.vgField(t.channel,{binSuffix:`end`}))}]]`:`${o}[${W(t.field)}]`).join(`, `);l+=`fields: ${i}, values: [${t}]`}if(N0(t))return n.concat(fBe(t.name,e.scaleName(H2)),[{name:r+l6,on:[{events:[{signal:H3},{signal:B3}],update:`{${l}}`,force:!0}]}]);{let e=t.events;return n.concat([{name:r+l6,on:e?[{events:e,update:`${c} ? {${l}} : null`,force:!0}]:[]}])}}},q3={defined:e=>e.type===`interval`&&e.resolve===`global`&&e.bind&&e.bind===`scales`,parse:(e,t)=>{let n=t.scales=[];for(let r of t.project.items){let i=r.channel;if(!MQ(i))continue;let a=e.getScaleComponent(i),o=a?a.get(`type`):void 0;if(o==`sequential`&&X(URe),!a||!L$(o)){X(HRe);continue}a.set(`selectionExtent`,{param:t.name,field:r.field},!0),n.push(r)}},topLevelSignals:(e,t,n)=>{let r=t.scales.filter(e=>n.filter(t=>t.name===e.signals.data).length===0);if(!e.parent||v0(e)||r.length===0)return n;let i=n.find(e=>e.name===t.name),a=i.update;if(a.includes(u6))i.update=`{${r.map(e=>`${W(iQ(e.field))}: ${e.signals.data}`).join(`, `)}}`;else{for(let e of r){let t=`${W(iQ(e.field))}: ${e.signals.data}`;a.includes(t)||(a=`${a.substring(0,a.length-1)}, ${t}}`)}i.update=a}return n.concat(r.map(e=>({name:e.signals.data})))},signals:(e,t,n)=>{if(e.parent&&!v0(e))for(let e of t.scales){let t=n.find(t=>t.name===e.signals.data);t.push=`outer`,delete t.value,delete t.update}return n}},J3=`_brush`,Y3=`_scale_trigger`,X3=`geo_interval_init_tick`,Z3=`_init`,mBe=`_center`,hBe={defined:e=>e.type===`interval`,parse:(e,t,n)=>{if(e.hasProjection){let e={...Dh(n.select)?n.select:{}};e.fields=[S3],e.encodings||=n.value?$(n.value):[z2,R2],n.select={type:`interval`,...e}}if(t.translate&&!q3.defined(t)){let e=`!event.item || event.item.mark.name !== ${W(t.name+J3)}`;for(let n of t.events){if(!n.between){X(`${n} is not an ordered event stream for interval selections.`);continue}let t=ng(n.between[0].filter??=[]);t.includes(e)||t.push(e)}}},signals:(e,t,n)=>{let r=t.name,i=r+l6,a=x2(t.project.hasChannel).filter(e=>e.channel===O2||e.channel===k2),o=t.init?t.init[0]:null;if(n.push(...a.reduce((n,r)=>n.concat(YNe(e,t,r,o?.[r.index])),[])),e.hasProjection){let s=W(e.projectionName()),c=e.projectionName()+mBe,{x:l,y:u}=t.project.hasChannel,d=l?.signals.visual,f=u?.signals.visual,p=l?o?.[l.index]:`${c}[0]`,m=u?o?.[u.index]:`${c}[1]`,h=t=>e.getSizeSignalRef(t).signal,g=`[[${d?`${d}[0]`:`0`}, ${f?`${f}[0]`:`0`}],[${d?`${d}[1]`:h(`width`)}, ${f?`${f}[1]`:h(`height`)}]]`;o&&(n.unshift({name:r+Z3,init:`[scale(${s}, [${l?p[0]:p}, ${u?m[0]:m}]), scale(${s}, [${l?p[1]:p}, ${u?m[1]:m}])]`}),(!l||!u)&&(n.find(e=>e.name===c)||n.unshift({name:c,update:`invert(${s}, [${h(`width`)}/2, ${h(`height`)}/2])`})));let _=`vlSelectionTuples(${`intersect(${g}, {markname: ${W(e.getName(`marks`))}}, unit.mark)`}, ${`{unit: ${j0(e)}}`})`,v=a.map(e=>e.signals.visual);return n.concat({name:i,on:[{events:[...v.length?[{signal:v.join(` || `)}]:[],...o?[{signal:X3}]:[]],update:_}]})}else{if(!q3.defined(t)){let t=r+Y3,i=a.map(t=>{let n=t.channel,{data:r,visual:i}=t.signals,a=W(e.scaleName(n)),o=L$(e.getScaleComponent(n).get(`type`))?`+`:``;return`(!isArray(${r}) || (${o}invert(${a}, ${i})[0] === ${o}${r}[0] && ${o}invert(${a}, ${i})[1] === ${o}${r}[1]))`});i.length&&n.push({name:t,value:{},on:[{events:a.map(t=>({scale:e.scaleName(t.channel)})),update:`${i.join(` && `)} ? ${t} : {}`}]})}let s=a.map(e=>e.signals.data),c=`unit: ${j0(e)}, fields: ${r+R3}, values`;return n.concat({name:i,...o?{init:`{${c}: ${h0(o)}}`}:{},...s.length?{on:[{events:[{signal:s.join(` || `)}],update:`${s.join(` && `)} ? {${c}: [${s}]} : null`}]}:{}})}},topLevelSignals:(e,t,n)=>(c2(e)&&e.hasProjection&&t.init&&(n.filter(e=>e.name===X3).length||n.unshift({name:X3,value:null,on:[{events:`timer{1}`,update:`${X3} === null ? {} : ${X3}`}]})),n),marks:(e,t,n)=>{let r=t.name,{x:i,y:a}=t.project.hasChannel,o=i?.signals.visual,s=a?.signals.visual,c=`data(${W(t.name+c6)})`;if(q3.defined(t)||!i&&!a)return n;let l={x:i===void 0?{value:0}:{signal:`${o}[0]`},y:a===void 0?{value:0}:{signal:`${s}[0]`},x2:i===void 0?{field:{group:`width`}}:{signal:`${o}[1]`},y2:a===void 0?{field:{group:`height`}}:{signal:`${s}[1]`}};if(t.resolve===`global`)for(let t of $(l))l[t]=[{test:`${c}.length && ${c}[0].unit === ${j0(e)}`,...l[t]},{value:0}];let{fill:u,fillOpacity:d,cursor:f,...p}=t.mark,m=$(p).reduce((e,t)=>(e[t]=[{test:[i!==void 0&&`${o}[0] !== ${o}[1]`,a!==void 0&&`${s}[0] !== ${s}[1]`].filter(e=>e).join(` && `),value:p[t]},{value:null}],e),{}),h=f??(t.translate?`move`:null);return[{name:`${r+J3}_bg`,type:`rect`,clip:!0,encode:{enter:{fill:{value:u},fillOpacity:{value:d}},update:l}},...n,{name:r+J3,type:`rect`,clip:!0,encode:{enter:{...h?{cursor:{value:h}}:{},fill:{value:`transparent`}},update:{...l,...m}}}]}},gBe={left:`x`,center:`xc`,right:`x2`},_Be={top:`y`,middle:`yc`,bottom:`y2`},vBe=new Set([`aria`,`width`,`height`]),Q3=`voronoi`,$3={defined:e=>e.type===`point`&&e.nearest,parse:(e,t)=>{if(t.events)for(let n of t.events)n.markname=e.getName(Q3)},marks:(e,t,n)=>{let{x:r,y:i}=t.project.hasChannel,a=e.mark;if(V$(a))return X(hke(a)),n;let o={name:e.getName(Q3),type:`path`,interactive:!0,aria:!1,from:{data:e.getName(`marks`)},encode:{update:{fill:{value:`transparent`},strokeWidth:{value:.35},stroke:{value:`transparent`},isVoronoi:{value:!0},...XNe(e,{reactiveGeom:!0})}},transform:[{type:`voronoi`,x:{expr:r||!i?`datum.datum.x || 0`:`0`},y:{expr:i||!r?`datum.datum.y || 0`:`0`},size:[e.getSizeSignalRef(`width`),e.getSizeSignalRef(`height`)]}]},s=0,c=!1;return n.forEach((t,n)=>{let r=t.name??``;r===e.component.mark[0].name?s=n:r.includes(Q3)&&(c=!0)}),c||n.splice(s+1,0,o),n}},e6={defined:e=>e.type===`point`&&e.resolve===`global`&&e.bind&&e.bind!==`scales`&&!U1(e.bind),parse:(e,t,n)=>CPe(t,n),topLevelSignals:(e,t,n)=>{let r=t.name,i=t.project,a=t.bind,o=t.init?.[0],s=$3.defined(t)?`(item().isVoronoi ? datum.datum : datum)`:`datum`;return i.items.forEach((e,i)=>{let c=XZ(`${r}_${e.field}`);n.filter(e=>e.name===c).length||n.unshift({name:c,...o?{init:h0(o[i])}:{value:null},on:t.events?[{events:t.events,update:`datum && item().mark.marktype !== 'group' ? ${s}[${W(e.field)}] : null`}]:[],bind:a[e.field]??a[e.channel]??a})}),n},signals:(e,t,n)=>{let r=t.name,i=t.project,a=n.find(e=>e.name===r+l6),o=r+R3,s=i.items.map(e=>XZ(`${r}_${e.field}`)),c=s.map(e=>`${e} !== null`).join(` && `);return s.length&&(a.update=`${c} ? {fields: ${o}, values: [${s.join(`, `)}]} : null`),delete a.value,delete a.on,n}},t6=`_toggle`,n6={defined:e=>e.type===`point`&&!N0(e)&&!!e.toggle,signals:(e,t,n)=>n.concat({name:t.name+t6,value:!1,on:[{events:t.events,update:t.toggle}]}),modifyExpr:(e,t)=>{let n=t.name+l6,r=t.name+t6;return`${r} ? null : ${n}, ${t.resolve===`global`?`${r} ? null : true, `:`${r} ? null : {unit: ${j0(e)}}, `}${r} ? ${n} : null`}},yBe={defined:e=>e.clear!==void 0&&e.clear!==!1&&!N0(e),parse:(e,t)=>{t.clear&&=xg(t.clear)?zG(t.clear,`view`):t.clear},topLevelSignals:(e,t,n)=>{if(e6.defined(t))for(let e of t.project.items){let r=n.findIndex(n=>n.name===XZ(`${t.name}_${e.field}`));r!==-1&&n[r].on.push({events:t.clear,update:`null`})}return n},signals:(e,t,n)=>{function r(e,r){e!==-1&&n[e].on&&n[e].on.push({events:t.clear,update:r})}if(t.type===`interval`)for(let e of t.project.items){let t=n.findIndex(t=>t.name===e.signals.visual);r(t,`[0, 0]`),t===-1&&r(n.findIndex(t=>t.name===e.signals.data),`null`)}else{let e=n.findIndex(e=>e.name===t.name+l6);r(e,`null`),n6.defined(t)&&(e=n.findIndex(e=>e.name===t.name+t6),r(e,`false`))}return n}},r6={defined:e=>{let t=e.resolve===`global`&&e.bind&&U1(e.bind),n=e.project.items.length===1&&e.project.items[0].field!==S3;return t&&!n&&X(WRe),t&&n},parse:(e,t,n)=>{let r=b2(n);if(r.select=xg(r.select)?{type:r.select,toggle:t.toggle}:{...r.select,toggle:t.toggle},CPe(t,r),Dh(n.select)&&(n.select.on||n.select.clear)){let e=`event.item && indexof(event.item.mark.role, "legend") < 0`;for(let n of t.events)n.filter=ng(n.filter??[]),n.filter.includes(e)||n.filter.push(e)}let i=W1(t.bind)?t.bind.legend:`click`;t.bind={legend:{merge:xg(i)?zG(i,`view`):ng(i)}}},topLevelSignals:(e,t,n)=>{let r=t.name,i=W1(t.bind)&&t.bind.legend,a=e=>t=>{let n=b2(t);return n.markname=e,n};for(let e of t.project.items){if(!e.hasLegend)continue;let o=`${XZ(e.field)}_legend`,s=`${r}_${o}`;if(n.filter(e=>e.name===s).length===0){let e=i.merge.map(a(`${o}_symbols`)).concat(i.merge.map(a(`${o}_labels`))).concat(i.merge.map(a(`${o}_entries`)));n.unshift({name:s,...t.init?{}:{value:null},on:[{events:e,update:`isDefined(datum.value) ? datum.value : item().items[0].items[0].datum.value`,force:!0},{events:i.merge,update:`!event.item || !datum ? null : ${s}`,force:!0}]})}}return n},signals:(e,t,n)=>{let r=t.name,i=t.project,a=n.find(e=>e.name===r+l6),o=r+R3,s=i.items.filter(e=>e.hasLegend).map(e=>XZ(`${r}_${XZ(e.field)}_legend`)),c=`${s.map(e=>`${e} !== null`).join(` && `)} ? {fields: ${o}, values: [${s.join(`, `)}]} : null`;t.events&&s.length>0?a.on.push({events:s.map(e=>({signal:e})),update:c}):s.length>0&&(a.update=c,delete a.value,delete a.on);let l=n.find(e=>e.name===r+t6),u=W1(t.bind)&&t.bind.legend;return l&&(t.events?l.on.push({...l.on[0],events:u}):l.on[0].events=u),n}},i6=`_translate_anchor`,a6=`_translate_delta`,bBe={defined:e=>e.type===`interval`&&e.translate,signals:(e,t,n)=>{let r=t.name,i=q3.defined(t),a=r+i6,{x:o,y:s}=t.project.hasChannel,c=zG(t.translate,`scope`);return i||(c=c.map(e=>(e.between[0].markname=r+J3,e))),n.push({name:a,value:{},on:[{events:c.map(e=>e.between[0]),update:`{x: x(unit), y: y(unit)${o===void 0?``:`, extent_x: ${i?_0(e,O2):`slice(${o.signals.visual})`}`}${s===void 0?``:`, extent_y: ${i?_0(e,k2):`slice(${s.signals.visual})`}`}}`}]},{name:r+a6,value:{},on:[{events:c,update:`{x: ${a}.x - x(unit), y: ${a}.y - y(unit)}`}]}),o!==void 0&&bPe(e,t,o,`width`,n),s!==void 0&&bPe(e,t,s,`height`,n),n}},o6=`_zoom_anchor`,s6=`_zoom_delta`,xBe={defined:e=>e.type===`interval`&&e.zoom,signals:(e,t,n)=>{let r=t.name,i=q3.defined(t),a=r+s6,{x:o,y:s}=t.project.hasChannel,c=W(e.scaleName(O2)),l=W(e.scaleName(k2)),u=zG(t.zoom,`scope`);return i||(u=u.map(e=>(e.markname=r+J3,e))),n.push({name:r+o6,on:[{events:u,update:i?`{${[c?`x: invert(${c}, x(unit))`:``,l?`y: invert(${l}, y(unit))`:``].filter(e=>e).join(`, `)}}`:`{x: x(unit), y: y(unit)}`}]},{name:a,on:[{events:u,force:!0,update:`pow(1.001, event.deltaY * pow(16, event.deltaMode))`}]}),o!==void 0&&xPe(e,t,o,`width`,n),s!==void 0&&xPe(e,t,s,`height`,n),n}},c6=`_store`,l6=`_tuple`,SBe=`_modify`,u6=`vlSelectionResolve`,d6=[pBe,hBe,uBe,n6,e6,q3,r6,yBe,bBe,xBe,$3],f6=class e extends N3{model;filter;expr;_dependentFields;clone(){return new e(null,this.model,b2(this.filter))}constructor(e,t,n){super(e),this.model=t,this.filter=n,this.expr=F0(this.model,this.filter,this),this._dependentFields=TPe(this.expr)}dependentFields(){return this._dependentFields}producedFields(){return new Set}assemble(){return{type:`filter`,expr:this.expr}}hash(){return`Filter ${this.expr}`}},p6={scale:({model:e,channel:t})=>e.scaleName(t),format:({format:e})=>e,formatType:({formatType:e})=>e,grid:({fieldOrDatumDef:e,axis:t,scaleType:n})=>t.grid??IPe(n,e),gridScale:({model:e,channel:t})=>LPe(e,t),labelAlign:({axis:e,labelAngle:t,orient:n,channel:r})=>e.labelAlign||BPe(t,n,r),labelAngle:({labelAngle:e})=>e,labelBaseline:({axis:e,labelAngle:t,orient:n,channel:r})=>e.labelBaseline||zPe(t,n,r),labelFlush:({axis:e,fieldOrDatumDef:t,channel:n})=>e.labelFlush??VPe(t.type,n),labelOverlap:({axis:e,fieldOrDatumDef:t,scaleType:n})=>e.labelOverlap??HPe(t.type,n,Z(t)&&!!t.timeUnit,Z(t)?t.sort:void 0),orient:({orient:e})=>e,tickCount:({channel:e,model:t,axis:n,fieldOrDatumDef:r,scaleType:i})=>{let a=e===`x`?`width`:e===`y`?`height`:void 0,o=a?t.getSizeSignalRef(a):void 0;return n.tickCount??WPe({fieldOrDatumDef:r,scaleType:i,size:o,values:n.values})},tickMinStep:({axis:e,format:t,fieldOrDatumDef:n})=>e.tickMinStep??GPe({format:t,fieldOrDatumDef:n}),title:({axis:e,model:t,channel:n})=>{if(e.title!==void 0)return e.title;let r=KPe(t,n);if(r!==void 0)return r;let i=t.typedFieldDef(n),a=n===`x`?`x2`:`y2`,o=t.fieldDef(a);return u$(i?[xje(i)]:[],Z(o)?[xje(o)]:[])},values:({axis:e,fieldOrDatumDef:t})=>qPe(e,t),zindex:({axis:e,fieldOrDatumDef:t,mark:n})=>e.zindex??JPe(n,t)},m6=class e extends N3{transform;_dependentFields;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t,this._dependentFields=TPe(this.transform.calculate)}static parseAllForSortIndex(t,n){return n.forEachFieldDef((n,r)=>{if(v1(n)&&vje(n.sort)){let{field:i,timeUnit:a}=n,o=n.sort,s=o.map((e,t)=>`${zAe({field:i,timeUnit:a,equal:e})} ? ${t} : `).join(``)+o.length;t=new e(t,{calculate:s,as:B0(n,r,{forAs:!0})})}}),t}producedFields(){return new Set([this.transform.as])}dependentFields(){return this._dependentFields}assemble(){return{type:`formula`,expr:this.transform.calculate,as:this.transform.as}}hash(){return`Calculate ${IZ(this.transform)}`}},h6=[`row`,`column`],g6=[`header`,`footer`],CBe={column:{start:0,end:1},row:{start:1,end:0}},_6=$({...Uze,disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1}),wBe=class extends j3{},v6={symbols:lFe,gradient:uFe,labels:dFe,entries:fFe},y6={direction:({direction:e})=>e,format:({fieldOrDatumDef:e,legend:t,config:n})=>{let{format:r,formatType:i}=t;return uje(e,e.type,r,i,n,!1)},formatType:({legend:e,fieldOrDatumDef:t,scaleType:n})=>{let{formatType:r}=e;return dje(r,t,n)},gradientLength:e=>{let{legend:t,legendConfig:n}=e;return t.gradientLength??n.gradientLength??SFe(e)},labelOverlap:({legend:e,legendConfig:t,scaleType:n})=>e.labelOverlap??t.labelOverlap??wFe(n),symbolType:({legend:e,markDef:t,channel:n,encoding:r})=>e.symbolType??_Fe(t.type,n,r.shape,t.shape),title:({fieldOrDatumDef:e,config:t})=>x1(e,t,{allowDisabling:!0}),type:({legendType:e,scaleType:t,channel:n})=>{if(yQ(n)&&R$(t)){if(e===`gradient`)return}else if(e===`symbol`)return;return e},values:({fieldOrDatumDef:e,legend:t})=>gFe(t,e)},b6=class e extends N3{bins;clone(){return new e(null,b2(this.bins))}constructor(e,t){super(e),this.bins=t}static makeFromEncoding(t,n){let r=n.reduceFieldDef((e,t,r)=>{if(g1(t)&&zQ(t.bin)){let{key:i,binComponent:a}=LFe(t,t.bin,n);e[i]={...a,...e[i],...NFe(n,t,r,n.config)}}return e},{});return qZ(r)?null:new e(t,r)}static makeFromTransform(t,n,r){let{key:i,binComponent:a}=LFe(n,n.bin,r);return new e(t,{[i]:a})}merge(e,t){for(let n of $(e.bins))n in this.bins?(t(e.bins[n].signal,this.bins[n].signal),this.bins[n].as=HZ([...this.bins[n].as,...e.bins[n].as],IZ)):this.bins[n]=e.bins[n];for(let t of e.children)e.removeChild(t),t.parent=this;e.remove()}producedFields(){return new Set(x2(this.bins).map(e=>e.as).flat(2))}dependentFields(){return new Set(x2(this.bins).map(e=>e.field))}hash(){return`Bin ${IZ(this.bins)}`}assemble(){return x2(this.bins).flatMap(e=>{let t=[],[n,...r]=e.as,{extent:i,...a}=e.bin,o={type:`bin`,field:iQ(e.field),as:n,signal:e.signal,...HQ(i)?{extent:null}:{extent:i},...e.span?{span:{signal:`span(${e.span})`}}:{},...a};!i&&e.extentSignal&&(t.push({type:`extent`,field:iQ(e.field),signal:e.extentSignal}),o.extent={signal:e.extentSignal}),t.push(o);for(let e of r)for(let r=0;r<2;r++)t.push({type:`formula`,expr:Q({field:n[r]},{expr:`datum`}),as:e[r]});return e.formula&&t.push({type:`formula`,expr:e.formula,as:e.formulaAs}),t})}},x6=class e extends N3{dimensions;measures;clone(){return new e(null,new Set(this.dimensions),b2(this.measures))}constructor(e,t,n){super(e),this.dimensions=t,this.measures=n}get groupBy(){return this.dimensions}static makeFromEncoding(t,n){let r=!1;n.forEachFieldDef(e=>{e.aggregate&&(r=!0)});let i={},a=new Set;return!r||(n.forEachFieldDef((e,t)=>{let{aggregate:r,field:o}=e;if(r)if(r===`count`)i[`*`]??={},i[`*`].count=new Set([Q(e,{forAs:!0})]);else{if(PQ(r)||FQ(r)){let e=PQ(r)?`argmin`:`argmax`,t=r[e];i[t]??={},i[t][e]=new Set([Q({op:e,field:t},{forAs:!0})])}else i[o]??={},i[o][r]=new Set([Q(e,{forAs:!0})]);MQ(t)&&n.scaleDomain(t)===`unaggregated`&&(i[o]??={},i[o].min=new Set([Q({field:o,aggregate:`min`},{forAs:!0})]),i[o].max=new Set([Q({field:o,aggregate:`max`},{forAs:!0})]))}else RFe(a,t,e,n)}),a.size+$(i).length===0)?null:new e(t,a,i)}static makeFromTransform(t,n){let r=new Set,i={};for(let e of n.aggregate){let{op:t,field:n,as:r}=e;t&&(t===`count`?(i[`*`]??={},i[`*`].count=new Set([r||Q(e,{forAs:!0})])):(i[n]??={},i[n][t]??=new Set,i[n][t].add(r||Q(e,{forAs:!0}))))}for(let e of n.groupby??[])r.add(e);return r.size+$(i).length===0?null:new e(t,r,i)}merge(e){return UZ(this.dimensions,e.dimensions)?(zFe(this.measures,e.measures),!0):(_Ae(`different dimensions, cannot merge`),!1)}addDimensions(e){e.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,...$(this.measures)])}producedFields(){let e=new Set;for(let t of $(this.measures))for(let n of $(this.measures[t])){let r=this.measures[t][n];r.size===0?e.add(`${n}_${t}`):r.forEach(e.add,e)}return e}hash(){return`Aggregate ${IZ({dimensions:this.dimensions,measures:this.measures})}`}assemble(){let e=[],t=[],n=[];for(let r of $(this.measures))for(let i of $(this.measures[r]))for(let a of this.measures[r][i])n.push(a),e.push(i),t.push(r===`*`?null:iQ(r));return{type:`aggregate`,groupby:[...this.dimensions].map(iQ),ops:e,fields:t,as:n}}},S6=class extends N3{model;name;data;column;row;facet;childModel;constructor(e,t,n,r){super(e),this.model=t,this.name=n,this.data=r;for(let e of f4){let n=t.facet[e];if(n){let{bin:r,sort:i}=n;this[e]={name:t.getName(`${e}_domain`),fields:[Q(n),...zQ(r)?[Q(n,{binSuffix:`end`})]:[]],...n1(i)?{sortField:i}:H(i)?{sortIndexField:B0(n,e)}:{}}}}this.childModel=t.child}hash(){let e=`Facet`;for(let t of f4)this[t]&&(e+=` ${t.charAt(0)}:${IZ(this[t])}`);return e}get fields(){let e=[];for(let t of f4)this[t]?.fields&&e.push(...this[t].fields);return e}dependentFields(){let e=new Set(this.fields);for(let t of f4)this[t]&&(this[t].sortField&&e.add(this[t].sortField.field),this[t].sortIndexField&&e.add(this[t].sortIndexField));return e}producedFields(){return new Set}getSource(){return this.name}getChildIndependentFieldsWithStep(){let e={};for(let t of g4){let n=this.childModel.component.scales[t];if(n&&!n.merged){let r=n.get(`type`),i=n.get(`range`);if(I$(r)&&YQ(i)){let n=a2(o2(this.childModel,t));n?e[t]=n:X(p$(t))}}}return e}assembleRowColumnHeaderData(e,t,n){let r={row:`y`,column:`x`,facet:void 0}[e],i=[],a=[],o=[];r&&n&&n[r]&&(t?(i.push(`distinct_${n[r]}`),a.push(`max`)):(i.push(n[r]),a.push(`distinct`)),o.push(`distinct_${n[r]}`));let{sortField:s,sortIndexField:c}=this[e];if(s){let{op:e=a3,field:t}=s;i.push(t),a.push(e),o.push(Q(s,{forAs:!0}))}else c&&(i.push(c),a.push(`max`),o.push(c));return{name:this[e].name,source:t??this.data,transform:[{type:`aggregate`,groupby:this[e].fields,...i.length?{fields:i,ops:a,as:o}:{}}]}}assembleFacetHeaderData(e){let{columns:t}=this.model.layout,{layoutHeaders:n}=this.model.component,r=[],i={};for(let e of h6){for(let t of g6){let r=n[e]?.[t]??[];for(let t of r)if(t.axes?.length>0){i[e]=!0;break}}if(i[e]){let n=`length(data("${this.facet.name}"))`,i=e===`row`?t?{signal:`ceil(${n} / ${t})`}:1:t?{signal:`min(${n}, ${t})`}:{signal:n};r.push({name:`${this.facet.name}_${e}`,transform:[{type:`sequence`,start:0,stop:i}]})}}let{row:a,column:o}=i;return(a||o)&&r.unshift(this.assembleRowColumnHeaderData(`facet`,null,e)),r}assemble(){let e=[],t=null,n=this.getChildIndependentFieldsWithStep(),{column:r,row:i,facet:a}=this;if(r&&i&&(n.x||n.y)){t=`cross_${this.column.name}_${this.row.name}`;let r=[].concat(n.x??[],n.y??[]),i=r.map(()=>`distinct`);e.push({name:t,source:this.data,transform:[{type:`aggregate`,groupby:this.fields,fields:r,ops:i}]})}for(let r of[E2,T2])this[r]&&e.push(this.assembleRowColumnHeaderData(r,t,n));if(a){let t=this.assembleFacetHeaderData(n);t&&e.push(...t)}return e}},C6=class e extends N3{_parse;clone(){return new e(null,b2(this._parse))}constructor(e,t){super(e),this._parse=t}hash(){return`Parse ${IZ(this._parse)}`}static makeExplicit(e,t,n){let r={},i=t.data;return!f0(i)&&i?.format?.parse&&(r=i.format.parse),this.makeWithAncestors(e,r,{},n)}static makeWithAncestors(t,n,r,i){for(let e of $(r)){let t=i.getWithExplicit(e);t.value!==void 0&&(t.explicit||t.value===r[e]||t.value===`derived`||r[e]===`flatten`?delete r[e]:X(Tke(e,r[e],t.value)))}for(let e of $(n)){let t=i.get(e);t!==void 0&&(t===n[e]?delete n[e]:X(Tke(e,n[e],t)))}let a=new j3(n,r);i.copyAll(a);let o={};for(let e of $(a.combine())){let t=a.get(e);t!==null&&(o[e]=t)}return $(o).length===0||i.parseNothing?null:new e(t,o)}get parse(){return this._parse}merge(e){this._parse={...this._parse,...e.parse},e.remove()}assembleFormatParse(){let e={};for(let t of $(this._parse)){let n=this._parse[t];sQ(t)===1&&(e[t]=n)}return e}producedFields(){return new Set($(this._parse))}dependentFields(){return new Set($(this._parse))}assembleTransforms(e=!1){return $(this._parse).filter(t=>!e||sQ(t)>1).map(e=>{let t=VFe(e,this._parse[e]);return t?{type:`formula`,expr:t,as:oQ(e)}:null}).filter(e=>e!==null)}},w6=class e extends N3{clone(){return new e(null)}constructor(e){super(e)}dependentFields(){return new Set}producedFields(){return new Set([S3])}hash(){return`Identifier`}assemble(){return{type:`identifier`,as:S3}}},T6=class e extends N3{params;clone(){return new e(null,this.params)}constructor(e,t){super(e),this.params=t}dependentFields(){return new Set}producedFields(){}hash(){return`Graticule ${IZ(this.params)}`}assemble(){return{type:`graticule`,...this.params===!0?{}:this.params}}},E6=class e extends N3{params;clone(){return new e(null,this.params)}constructor(e,t){super(e),this.params=t}dependentFields(){return new Set}producedFields(){return new Set([this.params.as??`data`])}hash(){return`Hash ${IZ(this.params)}`}assemble(){return{type:`sequence`,...this.params}}},D6=class extends N3{_data;_name;_generator;constructor(e){super(null),e??={name:`source`};let t;if(f0(e)||(t=e.format?{...FZ(e.format,[`parse`])}:{}),d0(e))this._data={values:e.values};else if(u0(e)){if(this._data={url:e.url},!t.type){let n=/(?:\.([^.]+))?$/.exec(e.url)[1];RZ([`json`,`csv`,`tsv`,`dsv`,`topojson`],n)||(n=`json`),t.type=n}}else PNe(e)?this._data={values:[{type:`Sphere`}]}:(MNe(e)||f0(e))&&(this._data={});this._generator=f0(e),e.name&&(this._name=e.name),t&&!qZ(t)&&(this._data.format=t)}dependentFields(){return new Set}producedFields(){}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(e){this._name=e}set parent(e){throw Error(`Source nodes have to be roots.`)}remove(){throw Error(`Source nodes are roots and cannot be removed.`)}hash(){throw Error(`Cannot hash sources`)}assemble(){return{name:this._name,...this._data,transform:[]}}},O6=class{#e;constructor(){this.#e=!1}setModified(){this.#e=!0}get modifiedFlag(){return this.#e}},k6=class extends O6{getNodeDepths(e,t,n){n.set(e,t);for(let r of e.children)this.getNodeDepths(r,t+1,n);return n}optimize(e){let t=[...this.getNodeDepths(e,0,new Map).entries()].sort((e,t)=>t[1]-e[1]);for(let e of t)this.run(e[0]);return this.modifiedFlag}},A6=class extends O6{optimize(e){this.run(e);for(let t of e.children)this.optimize(t);return this.modifiedFlag}},TBe=class extends A6{mergeNodes(e,t){let n=t.shift();for(let r of t)e.removeChild(r),r.parent=n,r.remove()}run(e){let t=e.children.map(e=>e.hash()),n={};for(let r=0;r1&&(this.setModified(),this.mergeNodes(e,n[t]))}},EBe=class extends A6{requiresSelectionId;constructor(e){super(),this.requiresSelectionId=e&&M0(e)}run(e){e instanceof w6&&(this.requiresSelectionId&&(X0(e.parent)||e.parent instanceof x6||e.parent instanceof C6)||(this.setModified(),e.remove()))}},DBe=class extends O6{optimize(e){return this.run(e,new Set),this.modifiedFlag}run(e,t){let n=new Set;e instanceof F3&&(n=e.producedFields(),WZ(n,t)&&(this.setModified(),e.removeFormulas(t),e.producedFields.length===0&&e.remove()));for(let r of e.children)this.run(r,new Set([...t,...n]))}},OBe=class extends A6{constructor(){super()}run(e){e instanceof P3&&!e.isRequired()&&(this.setModified(),e.remove())}},kBe=class extends k6{run(e){if(!X0(e)&&!(e.numChildren()>1)){for(let t of e.children)if(t instanceof C6)if(e instanceof C6)this.setModified(),e.merge(t);else{if(KZ(e.producedFields(),t.dependentFields()))continue;this.setModified(),t.swapWithParent()}}}},ABe=class extends k6{run(e){let t=[...e.children],n=e.children.filter(e=>e instanceof C6);if(e.numChildren()>1&&n.length>=1){let r={},i=new Set;for(let e of n){let t=e.parse;for(let e of $(t))e in r?r[e]!==t[e]&&i.add(e):r[e]=t[e]}for(let e of i)delete r[e];if(!qZ(r)){this.setModified();let n=new C6(e,r);for(let i of t){if(i instanceof C6)for(let e of $(r))delete i.parse[e];e.removeChild(i),i.parent=n,i instanceof C6&&$(i.parse).length===0&&i.remove()}}}}},jBe=class extends k6{run(e){e instanceof P3||e.numChildren()>0||e instanceof S6||e instanceof D6||(this.setModified(),e.remove())}},MBe=class extends k6{run(e){let t=e.children.filter(e=>e instanceof F3),n=t.pop();for(let e of t)this.setModified(),n.merge(e)}},NBe=class extends k6{run(e){let t=e.children.filter(e=>e instanceof x6),n={};for(let e of t){let t=IZ(e.groupBy);t in n||(n[t]=[]),n[t].push(e)}for(let t of $(n)){let r=n[t];if(r.length>1){let t=r.pop();for(let n of r)t.merge(n)&&(e.removeChild(n),n.parent=t,n.remove(),this.setModified())}}}},PBe=class extends k6{model;constructor(e){super(),this.model=e}run(e){let t=!(X0(e)||e instanceof f6||e instanceof C6||e instanceof w6),n=[],r=[];for(let i of e.children)i instanceof b6&&(t&&!KZ(e.producedFields(),i.dependentFields())?n.push(i):r.push(i));if(n.length>0){let t=n.pop();for(let e of n)t.merge(e,this.model.renameSignal.bind(this.model));this.setModified(),e instanceof b6?e.merge(t,this.model.renameSignal.bind(this.model)):t.swapWithParent()}if(r.length>1){let e=r.pop();for(let t of r)e.merge(t,this.model.renameSignal.bind(this.model));this.setModified()}}},FBe=class extends k6{run(e){let t=[...e.children];if(!zZ(t,e=>e instanceof P3)||e.numChildren()<=1)return;let n=[],r;for(let i of t)if(i instanceof P3){let t=i;for(;t.numChildren()===1;){let[e]=t.children;if(e instanceof P3)t=e;else break}n.push(...t.children),r?(e.removeChild(i),i.parent=r.parent,r.parent.removeChild(r),r.parent=t,this.setModified()):r=t}else n.push(i);if(n.length){this.setModified();for(let e of n)e.parent.removeChild(e),e.parent=r}}},j6=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t}addDimensions(e){this.transform.groupby=HZ(this.transform.groupby.concat(e),e=>e)}dependentFields(){let e=new Set;return this.transform.groupby&&this.transform.groupby.forEach(e.add,e),this.transform.joinaggregate.map(e=>e.field).filter(e=>e!==void 0).forEach(e.add,e),e}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(e){return e.as??Q(e)}hash(){return`JoinAggregateTransform ${IZ(this.transform)}`}assemble(){let e=[],t=[],n=[];for(let r of this.transform.joinaggregate)t.push(r.op),n.push(this.getDefaultName(r)),e.push(r.field===void 0?null:r.field);let r=this.transform.groupby;return{type:`joinaggregate`,as:n,ops:t,fields:e,...r===void 0?{}:{groupby:r}}}},M6=class e extends N3{filter;clone(){return new e(null,{...this.filter})}constructor(e,t){super(e),this.filter=t}static make(t,n,r){let{config:i,markDef:a}=n,{marks:o,scales:s}=r;if(o===`include-invalid-values`&&s===`include-invalid-values`)return null;let c=n.reduceFieldDef((e,t,r)=>{let o=MQ(r)&&n.getScaleComponent(r);if(o){let n=o.get(`type`),{aggregate:s}=t,c=G$({scaleChannel:r,markDef:a,config:i,scaleType:n,isCountAggregate:LQ(s)});c!==`show`&&c!==`always-valid`&&(e[t.field]=t)}return e},{});return $(c).length?new e(t,c):null}dependentFields(){return new Set($(this.filter))}producedFields(){return new Set}hash(){return`FilterInvalid ${IZ(this.filter)}`}assemble(){let e=$(this.filter).reduce((e,t)=>{let n=this.filter[t],r=Q(n,{expr:`datum`});return n!==null&&(n.type===`temporal`?e.push(`(isDate(${r}) || (${Z0(r)}))`):n.type===`quantitative`&&e.push(Z0(r))),e},[]);return e.length>0?{type:`filter`,expr:e.join(` && `)}:null}},N6=class e extends N3{_stack;clone(){return new e(null,b2(this._stack))}constructor(e,t){super(e),this._stack=t}static makeFromTransform(t,n){let{stack:r,groupby:i,as:a,offset:o=`zero`}=n,s=[],c=[];if(n.sort!==void 0)for(let e of n.sort)s.push(e.field),c.push(cQ(e.order,`ascending`));let l={field:s,order:c},u;return u=KFe(a)?a:xg(a)?[a,`${a}_end`]:[`${n.stack}_start`,`${n.stack}_end`],new e(t,{dimensionFieldDefs:[],stackField:r,groupby:i,offset:o,sort:l,facetby:[],as:u})}static makeFromEncoding(t,n){let r=n.stack,{encoding:i}=n;if(!r)return null;let{groupbyChannels:a,fieldChannel:o,offset:s,impute:c}=r,l=a.map(e=>{let t=i[e];return T1(t)}).filter(e=>!!e),u=GFe(n),d=n.encoding.order,f;if(H(d)||Z(d))f=l$(d);else{let e=wje(d)?d.sort:o===`y`?`descending`:`ascending`;f=u.reduce((t,n)=>(t.field.includes(n)||(t.field.push(n),t.order.push(e)),t),{field:[],order:[]})}return new e(t,{dimensionFieldDefs:l,stackField:n.vgField(o),facetby:[],stackby:u,sort:f,offset:s,impute:c,as:[n.vgField(o,{suffix:`start`,forAs:!0}),n.vgField(o,{suffix:`end`,forAs:!0})]})}get stack(){return this._stack}addDimensions(e){this._stack.facetby.push(...e)}dependentFields(){let e=new Set;return e.add(this._stack.stackField),this.getGroupbyFields().forEach(e.add,e),this._stack.facetby.forEach(e.add,e),this._stack.sort.field.forEach(e.add,e),e}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${IZ(this._stack)}`}getGroupbyFields(){let{dimensionFieldDefs:e,impute:t,groupby:n}=this._stack;return e.length>0?e.map(e=>e.bin?t?[Q(e,{binSuffix:`mid`})]:[Q(e,{}),Q(e,{binSuffix:`end`})]:[Q(e)]).flat():n??[]}assemble(){let e=[],{facetby:t,dimensionFieldDefs:n,stackField:r,stackby:i,sort:a,offset:o,impute:s,as:c}=this._stack;if(s)for(let a of n){let{bandPosition:n=.5,bin:o}=a;if(o){let t=Q(a,{expr:`datum`}),r=Q(a,{expr:`datum`,binSuffix:`end`});e.push({type:`formula`,expr:`${Z0(t)} ? ${n}*${t}+${1-n}*${r} : ${t}`,as:Q(a,{binSuffix:`mid`,forAs:!0})})}e.push({type:`impute`,field:r,groupby:[...i,...t],key:Q(a,{binSuffix:`mid`}),method:`value`,value:0})}return e.push({type:`stack`,groupby:[...this.getGroupbyFields(),...t],field:r,sort:a,as:c,offset:o}),e}},P6=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t}addDimensions(e){this.transform.groupby=HZ(this.transform.groupby.concat(e),e=>e)}dependentFields(){let e=new Set;return(this.transform.groupby??[]).forEach(e.add,e),(this.transform.sort??[]).forEach(t=>e.add(t.field)),this.transform.window.map(e=>e.field).filter(e=>e!==void 0).forEach(e.add,e),e}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(e){return e.as??Q(e)}hash(){return`WindowTransform ${IZ(this.transform)}`}assemble(){let e=[],t=[],n=[],r=[];for(let i of this.transform.window)t.push(i.op),n.push(this.getDefaultName(i)),r.push(i.param===void 0?null:i.param),e.push(i.field===void 0?null:i.field);let i=this.transform.frame,a=this.transform.groupby;if(i&&i[0]===null&&i[1]===null&&t.every(e=>IQ(e)))return{type:`joinaggregate`,as:n,ops:t,fields:e,...a===void 0?{}:{groupby:a}};let o=[],s=[];if(this.transform.sort!==void 0)for(let e of this.transform.sort)o.push(e.field),s.push(e.order??`ascending`);let c={field:o,order:s},l=this.transform.ignorePeers;return{type:`window`,params:r,as:n,ops:t,fields:e,sort:c,...l===void 0?{}:{ignorePeers:l},...a===void 0?{}:{groupby:a},...i===void 0?{}:{frame:i}}}},F6=`scale_`,I6=5,L6=class e{constructor(e){Object.defineProperty(this,"signal",{enumerable:!0,get:e})}signal;static fromName(t,n){return new e(()=>t(n))}},IBe=[`type`,`clipAngle`,`clipExtent`,`center`,`rotate`,`precision`,`reflectX`,`reflectY`,`coefficient`,`distance`,`fraction`,`lobes`,`parallel`,`radius`,`ratio`,`spacing`,`tilt`],R6=class extends j3{specifiedProjection;size;data;merged=!1;constructor(e,t,n,r){super({...t},{name:e}),this.specifiedProjection=t,this.size=n,this.data=r}get isFit(){return!!this.data}},z6=class extends j3{merged=!1;constructor(e,t){super({},{name:e}),this.setWithExplicit(`type`,t)}domainHasZero(){let e=this.get(`type`);if(RZ([R4.LOG,R4.TIME,R4.UTC],e))return`definitely-not`;let t=this.get(`zero`);if(t===!0||t===void 0&&RZ([R4.LINEAR,R4.SQRT,R4.POW],e))return`definitely`;let n=this.get(`domains`);if(n.length>0){let e=!1,t=!1,r=!1;for(let i of n){if(H(i)){let n=i[0],r=i[i.length-1];if(yg(n)&&yg(r))if(n<=0&&r>=0){e=!0;continue}else{t=!0;continue}}r=!0}if(e)return`definitely`;if(t&&!r)return`definitely-not`}return`maybe`}},LBe=[`range`,`scheme`],B6=.95,V6={bins:({model:e,fieldOrDatumDef:t})=>Z(t)?qIe(e,t):void 0,interpolate:({channel:e,fieldOrDatumDef:t})=>JIe(e,t.type),nice:({scaleType:e,channel:t,domain:n,domainMin:r,domainMax:i,fieldOrDatumDef:a})=>YIe(e,t,n,r,i,a),padding:({channel:e,scaleType:t,fieldOrDatumDef:n,markDef:r,config:i})=>XIe(e,t,i.scale,n,r,i.bar),paddingInner:({scalePadding:e,channel:t,markDef:n,scaleType:r,config:i,hasNestedOffsetScale:a})=>ZIe(e,t,n.type,r,i.scale,a),paddingOuter:({scalePadding:e,channel:t,scaleType:n,scalePaddingInner:r,config:i,hasNestedOffsetScale:a})=>QIe(e,t,n,r,i.scale,a),reverse:({fieldOrDatumDef:e,scaleType:t,channel:n,config:r})=>$Ie(t,Z(e)?e.sort:void 0,n,r.scale),zero:({channel:e,fieldOrDatumDef:t,domain:n,markDef:r,scaleType:i,config:a,hasSecondaryRangeChannel:o})=>eLe(e,t,n,r,i,a.scale,o)},RBe=jNe((e,t)=>WAe(e)-WAe(t)),H6=class{nameMap;constructor(){this.nameMap={}}rename(e,t){this.nameMap[e]=t}has(e){return this.nameMap[e]!==void 0}get(e){for(;this.nameMap[e]&&e!==this.nameMap[e];)e=this.nameMap[e];return e}},U6=class{type;parent;config;name;size;title;description;data;transforms;layout;scaleNameMap;projectionNameMap;signalNameMap;component;view;constructor(e,t,n,r,i,a,o){this.type=t,this.parent=n,this.config=i,this.parent=n,this.config=i,this.view=GQ(o),this.name=e.name??r,this.title=qQ(e.title)?{text:e.title}:e.title?GQ(e.title):void 0,this.scaleNameMap=n?n.scaleNameMap:new H6,this.projectionNameMap=n?n.projectionNameMap:new H6,this.signalNameMap=n?n.signalNameMap:new H6,this.data=e.data,this.description=e.description,this.transforms=yNe(e.transform??[]),this.layout=t===`layer`||t===`unit`?{}:xMe(e,t,i),this.component={data:{sources:n?n.component.data.sources:[],outputNodes:n?n.component.data.outputNodes:{},outputNodeRefCounts:n?n.component.data.outputNodeRefCounts:{},isFaceted:a1(e)||n?.component.data.isFaceted&&e.data===void 0},layoutSize:new j3,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:{scale:{},axis:{},legend:{},...a?b2(a):{}},selection:null,scales:null,projection:null,axes:{},legends:{}}}get width(){return this.getSizeSignalRef(`width`)}get height(){return this.getSizeSignalRef(`height`)}parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup()}parseScale(){rLe(this)}parseProjection(){bIe(this)}renameTopLevelLayoutSizeSignal(){this.getName(`width`)!==`width`&&this.renameSignal(this.getName(`width`),`width`),this.getName(`height`)!==`height`&&this.renameSignal(this.getName(`height`),`height`)}parseLegends(){TFe(this)}assembleEncodeFromView(e){let{style:t,...n}=e,r={};for(let e of $(n)){let t=n[e];t!==void 0&&(r[e]=t$(t))}return r}assembleGroupEncodeEntry(e){let t={};return this.view&&(t=this.assembleEncodeFromView(this.view)),!e&&(this.description&&(t.description=t$(this.description)),this.type===`unit`||this.type===`layer`)?{width:this.getSizeSignalRef(`width`),height:this.getSizeSignalRef(`height`),...t}:qZ(t)?void 0:t}assembleLayout(){if(!this.layout)return;let{spacing:e,...t}=this.layout,{component:n,config:r}=this,i=nFe(n.layoutHeaders,r);return{padding:e,...this.assembleDefaultLayout(),...t,...i?{titleBand:i}:{}}}assembleDefaultLayout(){return{}}assembleHeaderMarks(){let{layoutHeaders:e}=this.component,t=[];for(let n of f4)e[n].title&&t.push(YPe(this,n));for(let e of h6)t=t.concat(QPe(this,e));return t}assembleAxes(){return MPe(this.component.axes,this.config)}assembleLegends(){return hIe(this)}assembleProjections(){return _Ie(this)}assembleTitle(){let{encoding:e,...t}=this.title??{},n={...KQ(this.config.title).nonMarkTitleProperties,...t,...e?{encode:{update:e}}:{}};if(n.text)return RZ([`unit`,`layer`],this.type)?RZ([`middle`,void 0],n.anchor)&&(n.frame??=`group`):n.anchor??=`start`,qZ(n)?void 0:n}assembleGroup(e=[]){let t={};e=e.concat(this.assembleSignals()),e.length>0&&(t.signals=e);let n=this.assembleLayout();n&&(t.layout=n),t.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());let r=!this.parent||l2(this.parent)?TIe(this):[];r.length>0&&(t.scales=r);let i=this.assembleAxes();i.length>0&&(t.axes=i);let a=this.assembleLegends();return a.length>0&&(t.legends=a),t}getName(e){return XZ((this.name?`${this.name}_`:``)+e)}getDataName(e){return this.getName(M3[e].toLowerCase())}requestDataName(e){let t=this.getDataName(e),n=this.component.data.outputNodeRefCounts;return n[t]=(n[t]||0)+1,t}getSizeSignalRef(e){if(l2(this.parent)){let t=kQ(oFe(e)),n=this.component.scales[t];if(n&&!n.merged){let e=n.get(`type`),r=n.get(`range`);if(I$(e)&&YQ(r)){let e=n.get(`name`),r=a2(o2(this,t));return r?{signal:aFe(e,n,Q({aggregate:`distinct`,field:r},{expr:`datum`}))}:(X(p$(t)),null)}}}return{signal:this.signalNameMap.get(this.getName(e))}}lookupDataSource(e){let t=this.component.data.outputNodes[e];return t?t.getSource():e}getSignalName(e){return this.signalNameMap.get(e)}renameSignal(e,t){this.signalNameMap.rename(e,t)}renameScale(e,t){this.scaleNameMap.rename(e,t)}renameProjection(e,t){this.projectionNameMap.rename(e,t)}scaleName(e,t){if(t)return this.getName(e);if(bQ(e)&&MQ(e)&&this.component.scales[e]||this.scaleNameMap.has(this.getName(e)))return this.scaleNameMap.get(this.getName(e))}projectionName(e){if(e)return this.getName(`projection`);if(this.component.projection&&!this.component.projection.merged||this.projectionNameMap.has(this.getName(`projection`)))return this.projectionNameMap.get(this.getName(`projection`))}getScaleComponent(e){if(!this.component.scales)throw Error(`getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().`);let t=this.component.scales[e];return t&&!t.merged?t:this.parent?this.parent.getScaleComponent(e):void 0}getScaleType(e){let t=this.getScaleComponent(e);return t?t.get(`type`):void 0}getSelectionComponent(e,t){let n=this.component.selection[e];if(!n&&this.parent&&(n=this.parent.getSelectionComponent(e,t)),!n)throw Error(_ke(t));return n}hasAxisOrientSignalRef(){return this.component.axes.x?.some(e=>e.hasOrientSignalRef())||this.component.axes.y?.some(e=>e.hasOrientSignalRef())}},W6=class extends U6{vgField(e,t={}){let n=this.fieldDef(e);if(n)return Q(n,t)}reduceFieldDef(e,t){return Zje(this.getMapping(),(t,n,r)=>{let i=T1(n);return i?e(t,i,r):t},t)}forEachFieldDef(e,t){L1(this.getMapping(),(t,n)=>{let r=T1(t);r&&e(r,n)},t)}},G6=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=b2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??`value`,n[1]??`density`];let r=this.transform.resolve??`shared`;this.transform.resolve=r}dependentFields(){return new Set([this.transform.density,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`DensityTransform ${IZ(this.transform)}`}assemble(){let{density:e,...t}=this.transform,n={type:`kde`,field:e,...t};return n.resolve=this.transform.resolve,n}},K6=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=b2(t)}dependentFields(){return new Set([this.transform.extent])}producedFields(){return new Set([])}hash(){return`ExtentTransform ${IZ(this.transform)}`}assemble(){let{extent:e,param:t}=this.transform;return{type:`extent`,field:e,signal:t}}},q6=class e extends N3{transform;clone(){return new e(this.parent,b2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=b2(t);let{flatten:n,as:r=[]}=this.transform;this.transform.as=n.map((e,t)=>r[t]??e)}dependentFields(){return new Set(this.transform.flatten)}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${IZ(this.transform)}`}assemble(){let{flatten:e,as:t}=this.transform;return{type:`flatten`,fields:e,as:t}}},J6=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=b2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??`key`,n[1]??`value`]}dependentFields(){return new Set(this.transform.fold)}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${IZ(this.transform)}`}assemble(){let{fold:e,as:t}=this.transform;return{type:`fold`,fields:e,as:t}}},Y6=class e extends N3{fields;geojson;signal;clone(){return new e(null,b2(this.fields),this.geojson,this.signal)}static parseAll(t,n){if(n.component.projection&&!n.component.projection.isFit)return t;let r=0;for(let i of[[z2,R2],[V2,B2]]){let a=i.map(e=>{let t=E1(n.encoding[e]);return Z(t)?t.field:f1(t)?{expr:`${t.datum}`}:_1(t)?{expr:`${t.value}`}:void 0});(a[0]||a[1])&&(t=new e(t,a,null,n.getName(`geojson_${r++}`)))}if(n.channelHasField(K2)){let i=n.typedFieldDef(K2);i.type===L4&&(t=new e(t,null,i.field,n.getName(`geojson_${r}`)))}return t}constructor(e,t,n,r){super(e),this.fields=t,this.geojson=n,this.signal=r}dependentFields(){let e=(this.fields??[]).filter(xg);return new Set([...this.geojson?[this.geojson]:[],...e])}producedFields(){return new Set}hash(){return`GeoJSON ${this.geojson} ${this.signal} ${IZ(this.fields)}`}assemble(){return[...this.geojson?[{type:`filter`,expr:`isValid(datum["${this.geojson}"])`}]:[],{type:`geojson`,...this.fields?{fields:this.fields}:{},...this.geojson?{geojson:this.geojson}:{},signal:this.signal}]}},X6=class e extends N3{projection;fields;as;clone(){return new e(null,this.projection,b2(this.fields),b2(this.as))}constructor(e,t,n,r){super(e),this.projection=t,this.fields=n,this.as=r}static parseAll(t,n){if(!n.projectionName())return t;for(let r of[[z2,R2],[V2,B2]]){let i=r.map(e=>{let t=E1(n.encoding[e]);return Z(t)?t.field:f1(t)?{expr:`${t.datum}`}:_1(t)?{expr:`${t.value}`}:void 0}),a=r[0]===V2?`2`:``;(i[0]||i[1])&&(t=new e(t,n.projectionName(),i,[n.getName(`x${a}`),n.getName(`y${a}`)]))}return t}dependentFields(){return new Set(this.fields.filter(xg))}producedFields(){return new Set(this.as)}hash(){return`Geopoint ${this.projection} ${IZ(this.fields)} ${IZ(this.as)}`}assemble(){return{type:`geopoint`,projection:this.projection,fields:this.fields,as:this.as}}},Z6=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t}dependentFields(){return new Set([this.transform.impute,this.transform.key,...this.transform.groupby??[]])}producedFields(){return new Set([this.transform.impute])}processSequence(e){let{start:t=0,stop:n,step:r}=e;return{signal:`sequence(${[t,n,...r?[r]:[]].join(`,`)})`}}static makeFromTransform(t,n){return new e(t,n)}static makeFromEncoding(t,n){let r=n.encoding,i=r.x,a=r.y;if(Z(i)&&Z(a)){let o=i.impute?i:a.impute?a:void 0;if(o===void 0)return;let s=i.impute?a:a.impute?i:void 0,{method:c,value:l,frame:u,keyvals:d}=o.impute,f=Qje(n.mark,r);return new e(t,{impute:o.field,key:s.field,...c?{method:c}:{},...l===void 0?{}:{value:l},...u?{frame:u}:{},...d===void 0?{}:{keyvals:d},...f.length?{groupby:f}:{}})}return null}hash(){return`Impute ${IZ(this.transform)}`}assemble(){let{impute:e,key:t,keyvals:n,method:r,groupby:i,value:a,frame:o=[null,null]}=this.transform,s={type:`impute`,field:e,key:t,...n?{keyvals:QMe(n)?this.processSequence(n):n}:{},method:`value`,...i?{groupby:i}:{},value:!r||r===`value`?a:null};return r&&r!==`value`?[s,{type:`window`,as:[`imputed_${e}_value`],ops:[r],fields:[e],frame:o,ignorePeers:!1,...i?{groupby:i}:{}},{type:`formula`,expr:`datum.${e} === null ? datum.imputed_${e}_value : datum.${e}`,as:e}]:[s]}},Q6=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=b2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??t.on,n[1]??t.loess]}dependentFields(){return new Set([this.transform.loess,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`LoessTransform ${IZ(this.transform)}`}assemble(){let{loess:e,on:t,...n}=this.transform;return{type:`loess`,x:t,y:e,...n}}},$6=class e extends N3{transform;secondary;clone(){return new e(null,b2(this.transform),this.secondary)}constructor(e,t,n){super(e),this.transform=t,this.secondary=n}static make(t,n,r,i){let a=n.component.data.sources,{from:o}=r,s=null;if(eNe(o)){let e=bLe(o.data,a);e||(e=new D6(o.data),a.push(e));let t=n.getName(`lookup_${i}`);s=new P3(e,t,M3.Lookup,n.component.data.outputNodeRefCounts),n.component.data.outputNodes[t]=s}else if(tNe(o)){let e=o.param;r={as:e,...r};let t;try{t=n.getSelectionComponent(XZ(e),e)}catch{throw Error(vke(e))}if(s=t.materialized,!s)throw Error(yke(e))}return new e(t,r,s.getSource())}dependentFields(){return new Set([this.transform.lookup])}producedFields(){return new Set(this.transform.as?ng(this.transform.as):this.transform.from.fields)}hash(){return`Lookup ${IZ({transform:this.transform,secondary:this.secondary})}`}assemble(){let e;if(this.transform.from.fields)e={values:this.transform.from.fields,...this.transform.as?{as:ng(this.transform.as)}:{}};else{let t=this.transform.as;xg(t)||(X(XRe),t=`_lookup`),e={as:[t]}}return{type:`lookup`,from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup],...e,...this.transform.default?{default:this.transform.default}:{}}}},e8=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=b2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??`prob`,n[1]??`value`]}dependentFields(){return new Set([this.transform.quantile,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`QuantileTransform ${IZ(this.transform)}`}assemble(){let{quantile:e,...t}=this.transform;return{type:`quantile`,field:e,...t}}},t8=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=b2(t);let n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??t.on,n[1]??t.regression]}dependentFields(){return new Set([this.transform.regression,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`RegressionTransform ${IZ(this.transform)}`}assemble(){let{regression:e,on:t,...n}=this.transform;return{type:`regression`,x:t,y:e,...n}}},n8=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t}addDimensions(e){this.transform.groupby=HZ((this.transform.groupby??[]).concat(e),e=>e)}producedFields(){}dependentFields(){return new Set([this.transform.pivot,this.transform.value,...this.transform.groupby??[]])}hash(){return`PivotTransform ${IZ(this.transform)}`}assemble(){let{pivot:e,value:t,groupby:n,limit:r,op:i}=this.transform;return{type:`pivot`,field:e,value:t,...r===void 0?{}:{limit:r},...i===void 0?{}:{op:i},...n===void 0?{}:{groupby:n}}}},r8=class e extends N3{transform;clone(){return new e(null,b2(this.transform))}constructor(e,t){super(e),this.transform=t}dependentFields(){return new Set}producedFields(){return new Set}hash(){return`SampleTransform ${IZ(this.transform)}`}assemble(){return{type:`sample`,size:this.transform.sample}}},zBe=class e extends W6{facet;child;children;constructor(e,t,n,r){super(e,`facet`,t,n,r,e.resolve),this.child=y2(e.spec,this,this.getName(`child`),void 0,r),this.children=[this.child],this.facet=this.initFacet(e.facet)}initFacet(e){if(!r1(e))return{facet:this.initFacetFieldDef(e,`facet`)};let t=$(e),n={};for(let r of t){if(![T2,E2].includes(r)){X(h$(r,`facet`));break}let t=e[r];if(t.field===void 0){X(m$(t,r));break}n[r]=this.initFacetFieldDef(t,r)}return n}initFacetFieldDef(e,t){let n=O1(e,t);return n.header?n.header=GQ(n.header):n.header===null&&(n.header=null),n}channelHasField(e){return Y(this.facet,e)}fieldDef(e){return this.facet[e]}parseData(){this.component.data=h2(this),this.child.parseData()}parseLayoutSize(){f2(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection,x2(this.component.selection).some(e=>N0(e))&&v$(w4)}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),dLe(this)}assembleSelectionTopLevelSignals(e){return this.child.assembleSelectionTopLevelSignals(e)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(e){return this.child.assembleSelectionData(e)}getHeaderLayoutMixins(){let e={};for(let t of f4)for(let n of g6){let r=this.component.layoutHeaders[t],i=r[n],{facetFieldDef:a}=r;if(a){let n=H0(`titleOrient`,a.header,this.config,t);if([`right`,`bottom`].includes(n)){let r=V0(t,n);e.titleAnchor??={},e.titleAnchor[r]=`end`}}if(i?.[0]){let i=t===`row`?`height`:`width`,a=n===`header`?`headerBand`:`footerBand`;t!==`facet`&&!this.child.component.layoutSize.get(i)&&(e[a]??={},e[a][t]=.5),r.title&&(e.offset??={},e.offset[t===`row`?`rowTitle`:`columnTitle`]=10)}}return e}assembleDefaultLayout(){let{column:e,row:t}=this.facet,n=e?this.columnDistinctSignal():t?1:void 0,r=`all`;return(!t&&this.component.resolve.scale.x===`independent`||!e&&this.component.resolve.scale.y===`independent`)&&(r=`none`),{...this.getHeaderLayoutMixins(),...n?{columns:n}:{},bounds:`full`,align:r}}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(!(this.parent&&this.parent instanceof e))return{signal:`length(data('${this.getName(`column_domain`)}'))`}}assembleGroupStyle(){}assembleGroup(t){return this.parent&&this.parent instanceof e?{...this.channelHasField(`column`)?{encode:{update:{columns:{field:Q(this.facet.column,{prefix:`distinct`})}}}}:{},...super.assembleGroup(t)}:super.assembleGroup(t)}getCardinalityAggregateForChild(){let t=[],n=[],r=[];if(this.child instanceof e){if(this.child.channelHasField(`column`)){let e=Q(this.child.facet.column);t.push(e),n.push(`distinct`),r.push(`distinct_${e}`)}}else for(let e of g4){let i=this.child.component.scales[e];if(i&&!i.merged){let a=i.get(`type`),o=i.get(`range`);if(I$(a)&&YQ(o)){let i=a2(o2(this.child,e));i?(t.push(i),n.push(`distinct`),r.push(`distinct_${i}`)):X(p$(e))}}}return{fields:t,ops:n,as:r}}assembleFacet(){let{name:e,data:t}=this.component.data.facetRoot,{row:n,column:r}=this.facet,{fields:i,ops:a,as:o}=this.getCardinalityAggregateForChild(),s=[];for(let e of f4){let t=this.facet[e];if(t){s.push(Q(t));let{bin:c,sort:l}=t;if(zQ(c)&&s.push(Q(t,{binSuffix:`end`})),n1(l)){let{field:e,op:s=a3}=l,c=m2(t,l);n&&r?(i.push(c),a.push(`max`),o.push(c)):(i.push(e),a.push(s),o.push(c))}else if(H(l)){let n=B0(t,e);i.push(n),a.push(`max`),o.push(n)}}}let c=!!n&&!!r;return{name:e,data:t,groupby:s,...c||i.length>0?{aggregate:{...c?{cross:c}:{},...i.length?{fields:i,ops:a,as:o}:{}}}:{}}}facetSortFields(e){let{facet:t}=this,n=t[e];return n?n1(n.sort)?[m2(n,n.sort,{expr:`datum`})]:H(n.sort)?[B0(n,e,{expr:`datum`})]:[Q(n,{expr:`datum`})]:[]}facetSortOrder(e){let{facet:t}=this,n=t[e];if(n){let{sort:e}=n;return[(n1(e)?e.order:!H(e)&&e)||`ascending`]}return[]}assembleLabelTitle(){let{facet:e,config:t}=this;if(e.facet)return W0(e.facet,`facet`,t);let n={row:[`top`,`bottom`],column:[`left`,`right`]};for(let r of h6)if(e[r]){let i=H0(`labelOrient`,e[r]?.header,t,r);if(n[r].includes(i))return W0(e[r],r,t)}}assembleMarks(){let{child:e}=this,t=this.component.data.facetRoot,n=cLe(t),r=e.assembleGroupEncodeEntry(!1),i=this.assembleLabelTitle()||e.assembleTitle(),a=e.assembleGroupStyle();return[{name:this.getName(`cell`),type:`group`,...i?{title:i}:{},...a?{style:a}:{},from:{facet:this.assembleFacet()},sort:{field:f4.map(e=>this.facetSortFields(e)).flat(),order:f4.map(e=>this.facetSortOrder(e)).flat()},...n.length>0?{data:n}:{},...r?{encode:{update:r}}:{},...e.assembleGroup(UNe(this,[]))}]}getMapping(){return this.facet}},BBe=class extends U6{children;constructor(e,t,n,r){super(e,`concat`,t,n,r,e.resolve),(e.resolve?.axis?.x===`shared`||e.resolve?.axis?.y===`shared`)&&X(JRe),this.children=this.getChildren(e).map((e,t)=>y2(e,this,this.getName(`concat_${t}`),void 0,r))}parseData(){this.component.data=h2(this);for(let e of this.children)e.parseData()}parseSelections(){this.component.selection={};for(let e of this.children){e.parseSelections();for(let t of $(e.component.selection))this.component.selection[t]=e.component.selection[t]}x2(this.component.selection).some(e=>N0(e))&&v$(w4)}parseMarkGroup(){for(let e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){for(let e of this.children)e.parseAxesAndHeaders()}getChildren(e){return q1(e)?e.vconcat:J1(e)?e.hconcat:e.concat}parseLayoutSize(){gLe(this)}parseAxisGroup(){return null}assembleSelectionTopLevelSignals(e){return this.children.reduce((e,t)=>t.assembleSelectionTopLevelSignals(e),e)}assembleSignals(){return this.children.forEach(e=>e.assembleSignals()),[]}assembleLayoutSignals(){let e=G0(this);for(let t of this.children)e.push(...t.assembleLayoutSignals());return e}assembleSelectionData(e){return this.children.reduce((e,t)=>t.assembleSelectionData(e),e)}assembleMarks(){return this.children.map(e=>{let t=e.assembleTitle(),n=e.assembleGroupStyle(),r=e.assembleGroupEncodeEntry(!1);return{type:`group`,name:e.getName(`group`),...t?{title:t}:{},...n?{style:n}:{},...r?{encode:{update:r}}:{},...e.assembleGroup()}})}assembleGroupStyle(){}assembleDefaultLayout(){let e=this.layout.columns;return{...e==null?{}:{columns:e},bounds:`full`,align:`each`}}},i8=$({disable:1,gridScale:1,scale:1,...d3,labelExpr:1,encode:1}),VBe=class e extends j3{explicit;implicit;mainExtracted;constructor(e={},t={},n=!1){super(),this.explicit=e,this.implicit=t,this.mainExtracted=n}clone(){return new e(b2(this.explicit),b2(this.implicit),this.mainExtracted)}hasAxisPart(e){return e===`axis`?!0:e===`grid`||e===`title`?!!this.get(e):!CLe(this.get(e))}hasOrientSignalRef(){return JQ(this.explicit.orient)}},HBe={bottom:`top`,top:`bottom`,left:`right`,right:`left`},UBe=new Set([`grid`,`translate`,`format`,`formatType`,`orient`,`labelExpr`,`tickCount`,`position`,`tickMinStep`]),WBe={vgMark:`arc`,encodeEntry:e=>({...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`ignore`,orient:`ignore`,theta:`ignore`}),...w0(`x`,e,{defaultPos:`mid`}),...w0(`y`,e,{defaultPos:`mid`}),...O0(e,`radius`),...O0(e,`theta`)})},GBe={vgMark:`area`,encodeEntry:e=>({...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`include`,size:`ignore`,theta:`ignore`}),...E0(`x`,e,{defaultPos:`zeroOrMin`,defaultPos2:`zeroOrMin`,range:e.markDef.orient===`horizontal`}),...E0(`y`,e,{defaultPos:`zeroOrMin`,defaultPos2:`zeroOrMin`,range:e.markDef.orient===`vertical`}),...A0(e)})},KBe={vgMark:`rect`,encodeEntry:e=>({...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...O0(e,`x`),...O0(e,`y`)})},qBe={vgMark:`shape`,encodeEntry:e=>({...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`ignore`,orient:`ignore`,theta:`ignore`})}),postEncodingTransform:e=>{let{encoding:t}=e,n=t.shape;return[{type:`geoshape`,projection:e.projectionName(),...n&&Z(n)&&n.type===L4?{field:Q(n,{expr:`datum`})}:{}}]}},JBe={vgMark:`image`,encodeEntry:e=>({...k0(e,{align:`ignore`,baseline:`ignore`,color:`ignore`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...O0(e,`x`),...O0(e,`y`),...b0(e,`url`)})},YBe={vgMark:`line`,encodeEntry:e=>({...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`ignore`,orient:`ignore`,theta:`ignore`}),...w0(`x`,e,{defaultPos:`mid`}),...w0(`y`,e,{defaultPos:`mid`}),...S0(`size`,e,{vgChannel:`strokeWidth`}),...A0(e)})},XBe={vgMark:`trail`,encodeEntry:e=>({...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,size:`include`,orient:`ignore`,theta:`ignore`}),...w0(`x`,e,{defaultPos:`mid`}),...w0(`y`,e,{defaultPos:`mid`}),...S0(`size`,e),...A0(e)})},ZBe={vgMark:`symbol`,encodeEntry:e=>_2(e)},QBe={vgMark:`symbol`,encodeEntry:e=>_2(e,`circle`)},$Be={vgMark:`symbol`,encodeEntry:e=>_2(e,`square`)},eVe={vgMark:`rect`,encodeEntry:e=>({...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...O0(e,`x`),...O0(e,`y`)})},tVe={vgMark:`rule`,encodeEntry:e=>{let{markDef:t}=e,n=t.orient;return!e.encoding.x&&!e.encoding.y&&!e.encoding.latitude&&!e.encoding.longitude?{}:{...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...E0(`x`,e,{defaultPos:n===`horizontal`?`zeroOrMax`:`mid`,defaultPos2:`zeroOrMin`,range:n!==`vertical`}),...E0(`y`,e,{defaultPos:n===`vertical`?`zeroOrMax`:`mid`,defaultPos2:`zeroOrMin`,range:n!==`horizontal`}),...S0(`size`,e,{vgChannel:`strokeWidth`})}}},nVe={vgMark:`text`,encodeEntry:e=>{let{config:t,encoding:n}=e;return{...k0(e,{align:`include`,baseline:`include`,color:`include`,size:`ignore`,orient:`ignore`,theta:`include`}),...w0(`x`,e,{defaultPos:`mid`}),...w0(`y`,e,{defaultPos:`mid`}),...b0(e),...S0(`size`,e,{vgChannel:`fontSize`}),...S0(`angle`,e),...vPe(`align`,NLe(e.markDef,n,t)),...vPe(`baseline`,PLe(e.markDef,n,t)),...w0(`radius`,e,{defaultPos:null}),...w0(`theta`,e,{defaultPos:null})}}},a8={arc:WBe,area:GBe,bar:KBe,circle:QBe,geoshape:qBe,image:JBe,line:YBe,point:ZBe,rect:eVe,rule:tVe,square:$Be,text:nVe,tick:{vgMark:`rect`,encodeEntry:e=>{let{config:t,markDef:n}=e,r=n.orient,i=r===`horizontal`?`x`:`y`,a=r===`horizontal`?`y`:`x`,o=r===`horizontal`?`height`:`width`;return{...k0(e,{align:`ignore`,baseline:`ignore`,color:`include`,orient:`ignore`,size:`ignore`,theta:`ignore`}),...O0(e,i),...w0(a,e,{defaultPos:`mid`,vgChannel:a===`y`?`yc`:`xc`}),[o]:t$(a$(`thickness`,n,t))}}},trail:XBe},o8=`faceted_path_`,s8=`stack_group_`,c8=class extends W6{markDef;encoding;specifiedScales={};stack;specifiedAxes={};specifiedLegends={};specifiedProjection={};selection=[];children=[];constructor(e,t,n,r={},i){super(e,`unit`,t,n,i,void 0,bMe(e)?e.view:void 0);let a=U$(e.mark)?{...e.mark}:{type:e.mark},o=a.type;a.filled===void 0&&(a.filled=BMe(a,i,{graticule:e.data&&p0(e.data)}));let s=this.encoding=Yje(e.encoding||{},o,a.filled,i);this.markDef=LMe(a,s,i),this.size=jLe({encoding:s,size:bMe(e)?{...r,...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height}}:r}),this.stack=IMe(this.markDef,s),this.specifiedScales=this.initScales(o,s),this.specifiedAxes=this.initAxes(s),this.specifiedLegends=this.initLegends(s),this.specifiedProjection=e.projection,this.selection=(e.params??[]).filter(e=>G1(e)),this.alignStackOrderWithColorDomain()}get hasProjection(){let{encoding:e}=this,t=this.mark===e3,n=e&&qLe.some(t=>h1(e[t]));return t||n}scaleDomain(e){let t=this.specifiedScales[e];return t?t.domain:void 0}axis(e){return this.specifiedAxes[e]}legend(e){return this.specifiedLegends[e]}initScales(e,t){return x4.reduce((e,n)=>{let r=E1(t[n]);return r&&(e[n]=this.initScale(r.scale??{})),e},{})}initScale(e){let{domain:t,range:n}=e,r=GQ(e);return H(t)&&(r.domain=t.map($Q)),H(n)&&(r.range=n.map($Q)),r}initAxes(e){return g4.reduce((t,n)=>{let r=e[n];if(h1(r)||n===O2&&h1(e.x2)||n===k2&&h1(e.y2)){let e=h1(r)?r.axis:void 0;t[n]=e&&this.initAxis({...e})}return t},{})}initAxis(e){let t=$(e),n={};for(let r of t){let t=e[r];n[r]=N1(t)?QQ(t):$Q(t)}return n}initLegends(e){return ARe.reduce((t,n)=>{let r=E1(e[n]);if(r&&nke(n)){let e=r.legend;t[n]=e&&GQ(e)}return t},{})}alignStackOrderWithColorDomain(){let{color:e,fill:t,order:n,xOffset:r,yOffset:i}=this.encoding,a=t||e,o=Z(a)?a:void 0,s=o?.field,c=o?.scale,l=o?.type,u=c?.domain,d=r||i,f=Z(d)?d:void 0,p=`_${s}_sort_index`;if(!n&&Array.isArray(u)&&typeof s==`string`&&l===`nominal`)if(f&&!f.sort)f.sort=u;else{if(!this.stack)return;let e=`indexof(${W(u)}, datum['${s}'])`,t=this.markDef?.orient===`horizontal`?`ascending`:`descending`;this.transforms.push({calculate:e,as:p}),this.encoding.order={field:p,type:`quantitative`,sort:t}}}parseData(){this.component.data=h2(this)}parseLayoutSize(){_Le(this)}parseSelections(){this.component.selection=EPe(this,this.selection)}parseMarkGroup(){this.component.mark=FLe(this)}parseAxesAndHeaders(){this.component.axes=TLe(this)}assembleSelectionTopLevelSignals(e){return WNe(this,e)}assembleSignals(){return[...jPe(this),...HNe(this,[])]}assembleSelectionData(e){return GNe(this,e)}assembleLayout(){return null}assembleLayoutSignals(){return G0(this)}correctDataNames=e=>(e.from?.data&&(e.from.data=this.lookupDataSource(e.from.data),`time`in this.encoding&&(e.from.data=e.from.data+z3)),e.from?.facet?.data&&(e.from.facet.data=this.lookupDataSource(e.from.facet.data)),e);assembleMarks(){let e=this.component.mark??[];return(!this.parent||!d2(this.parent))&&(e=KNe(this,e)),e.map(this.correctDataNames)}assembleGroupStyle(){let{style:e}=this.view||{};return e===void 0?this.encoding.x||this.encoding.y?`cell`:`view`:e}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(e){return F1(this.encoding,e)}fieldDef(e){let t=this.encoding[e];return T1(t)}typedFieldDef(e){let t=this.fieldDef(e);return g1(t)?t:null}},rVe=class e extends U6{children;constructor(t,n,r,i,a){super(t,`layer`,n,r,a,t.resolve,t.view);let o={...i,...t.width?{width:t.width}:{},...t.height?{height:t.height}:{}};this.children=t.layer.map((t,n)=>{if($1(t))return new e(t,this,this.getName(`layer_${n}`),o,a);if(P1(t))return new c8(t,this,this.getName(`layer_${n}`),o,a);throw Error(f$(t))})}parseData(){this.component.data=h2(this);for(let e of this.children)e.parseData()}parseLayoutSize(){hLe(this)}parseSelections(){this.component.selection={};for(let e of this.children){e.parseSelections();for(let t of $(e.component.selection))this.component.selection[t]=e.component.selection[t]}x2(this.component.selection).some(e=>N0(e))&&v$(w4)}parseMarkGroup(){for(let e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){ELe(this)}assembleSelectionTopLevelSignals(e){return this.children.reduce((e,t)=>t.assembleSelectionTopLevelSignals(e),e)}assembleSignals(){return this.children.reduce((e,t)=>e.concat(t.assembleSignals()),jPe(this))}assembleLayoutSignals(){return this.children.reduce((e,t)=>e.concat(t.assembleLayoutSignals()),G0(this))}assembleSelectionData(e){return this.children.reduce((e,t)=>t.assembleSelectionData(e),e)}assembleGroupStyle(){let e=new Set;for(let t of this.children)for(let n of ng(t.assembleGroupStyle()))e.add(n);let t=Array.from(e);return t.length>1?t:t.length===1?t[0]:void 0}assembleTitle(){let e=super.assembleTitle();if(e)return e;for(let t of this.children)if(e=t.assembleTitle(),e)return e}assembleLayout(){return null}assembleMarks(){return qNe(this,this.children.flatMap(e=>e.assembleMarks()))}assembleLegends(){return this.children.reduce((e,t)=>e.concat(t.assembleLegends()),hIe(this))}},iVe=GLe.version}));function oVe(e){let[t,n]=/schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(e).slice(1,3);return{library:t,version:n}}var sVe=o((()=>{})),cVe=c({carbong10:()=>VVe,carbong100:()=>UVe,carbong90:()=>HVe,carbonwhite:()=>BVe,dark:()=>uVe,excel:()=>dVe,fivethirtyeight:()=>mVe,ggplot2:()=>hVe,googlecharts:()=>DVe,latimes:()=>yVe,powerbi:()=>IVe,quartz:()=>bVe,urbaninstitute:()=>EVe,version:()=>WVe,vox:()=>xVe});function l8({theme:e,background:t}){let n=[`white`,`g10`].includes(e)?`light`:`dark`,r=Z8.gridBg[e],i=Z8.textPrimary[e],a=Z8.textSecondary[e],o=n===`dark`?RVe:zVe,s=n===`dark`?`#d4bbff`:`#6929c4`;return{background:t,arc:{fill:s},area:{fill:s},path:{stroke:s},rect:{fill:s},shape:{stroke:s},symbol:{stroke:s},circle:{fill:s},view:{fill:r,stroke:r},group:{fill:r},title:{color:i,anchor:`start`,dy:-15,fontSize:16,font:Y8,fontWeight:600},axis:{labelColor:a,labelFontSize:12,labelFont:LVe,labelFontWeight:X8,titleColor:i,titleFontWeight:600,titleFontSize:12,grid:!0,gridColor:Z8.layerAccent01[e],labelAngle:0},axisX:{titlePadding:10},axisY:{titlePadding:2.5},style:{"guide-label":{font:Y8,fill:a,fontWeight:X8},"guide-title":{font:Y8,fill:a,fontWeight:X8}},range:{category:o,diverging:[`#750e13`,`#a2191f`,`#da1e28`,`#fa4d56`,`#ff8389`,`#ffb3b8`,`#ffd7d9`,`#fff1f1`,`#e5f6ff`,`#bae6ff`,`#82cfff`,`#33b1ff`,`#1192e8`,`#0072c3`,`#00539a`,`#003a6d`],heatmap:[`#f6f2ff`,`#e8daff`,`#d4bbff`,`#be95ff`,`#a56eff`,`#8a3ffc`,`#6929c4`,`#491d8b`,`#31135e`,`#1c0f30`]}}}var lVe,u8,d8,uVe,f8,dVe,p8,m8,fVe,pVe,h8,g8,mVe,_8,hVe,gVe,_Ve,v8,y8,vVe,b8,x8,S8,C8,w8,yVe,T8,E8,bVe,D8,xVe,O8,k8,SVe,A8,j8,CVe,wVe,TVe,M8,EVe,N8,P8,F8,DVe,I8,L8,R8,z8,B8,V8,H8,U8,W8,OVe,G8,kVe,AVe,jVe,MVe,NVe,PVe,FVe,K8,q8,J8,IVe,Y8,LVe,X8,Z8,RVe,zVe,BVe,VVe,HVe,UVe,WVe,GVe=o((()=>{lVe={version:`3.0.0`},u8=`#fff`,d8=`#888`,uVe={background:`#333`,view:{stroke:d8},title:{color:u8,subtitleColor:u8},style:{"guide-label":{fill:u8},"guide-title":{fill:u8}},axis:{domainColor:u8,gridColor:d8,tickColor:u8}},f8=`#4572a7`,dVe={background:`#fff`,arc:{fill:f8},area:{fill:f8},line:{stroke:f8,strokeWidth:2},path:{stroke:f8},rect:{fill:f8},shape:{stroke:f8},symbol:{fill:f8,strokeWidth:1.5,size:50},axis:{bandPosition:.5,grid:!0,gridColor:`#000000`,gridOpacity:1,gridWidth:.5,labelPadding:10,tickSize:5,tickWidth:.5},axisBand:{grid:!1,tickExtra:!0},legend:{labelBaseline:`middle`,labelFontSize:11,symbolSize:50,symbolType:`square`},range:{category:[`#4572a7`,`#aa4643`,`#8aa453`,`#71598e`,`#4598ae`,`#d98445`,`#94aace`,`#d09393`,`#b9cc98`,`#a99cbc`]}},p8=`#30a2da`,m8=`#cbcbcb`,fVe=`#999`,pVe=`#333`,h8=`#f0f0f0`,g8=`#333`,mVe={arc:{fill:p8},area:{fill:p8},axis:{domainColor:m8,grid:!0,gridColor:m8,gridWidth:1,labelColor:fVe,labelFontSize:10,titleColor:pVe,tickColor:m8,tickSize:10,titleFontSize:14,titlePadding:10,labelPadding:4},axisBand:{grid:!1},background:h8,group:{fill:h8},legend:{labelColor:g8,labelFontSize:11,padding:1,symbolSize:30,symbolType:`square`,titleColor:g8,titleFontSize:14,titlePadding:10},line:{stroke:p8,strokeWidth:2},path:{stroke:p8,strokeWidth:.5},rect:{fill:p8},range:{category:[`#30a2da`,`#fc4f30`,`#e5ae38`,`#6d904f`,`#8b8b8b`,`#b96db8`,`#ff9e27`,`#56cc60`,`#52d2ca`,`#52689e`,`#545454`,`#9fe4f8`],diverging:[`#cc0020`,`#e77866`,`#f6e7e1`,`#d6e8ed`,`#91bfd9`,`#1d78b5`],heatmap:[`#d6e8ed`,`#cee0e5`,`#91bfd9`,`#549cc6`,`#1d78b5`]},point:{filled:!0,shape:`circle`},shape:{stroke:p8},bar:{binSpacing:2,fill:p8,stroke:null},title:{anchor:`start`,fontSize:24,fontWeight:600,offset:20}},_8=`#000`,hVe={group:{fill:`#e5e5e5`},arc:{fill:_8},area:{fill:_8},line:{stroke:_8},path:{stroke:_8},rect:{fill:_8},shape:{stroke:_8},symbol:{fill:_8,size:40},axis:{domain:!1,grid:!0,gridColor:`#FFFFFF`,gridOpacity:1,labelColor:`#7F7F7F`,labelPadding:4,tickColor:`#7F7F7F`,tickSize:5.67,titleFontSize:16,titleFontWeight:`normal`},legend:{labelBaseline:`middle`,labelFontSize:11,symbolSize:40},range:{category:[`#000000`,`#7F7F7F`,`#1A1A1A`,`#999999`,`#333333`,`#B0B0B0`,`#4D4D4D`,`#C9C9C9`,`#666666`,`#DCDCDC`]}},gVe=22,_Ve=`normal`,v8=`Benton Gothic, sans-serif`,y8=11.5,vVe=`normal`,b8=`#82c6df`,x8=`Benton Gothic Bold, sans-serif`,S8=`normal`,C8=13,w8={"category-6":[`#ec8431`,`#829eb1`,`#c89d29`,`#3580b1`,`#adc839`,`#ab7fb4`],"fire-7":[`#fbf2c7`,`#f9e39c`,`#f8d36e`,`#f4bb6a`,`#e68a4f`,`#d15a40`,`#ab4232`],"fireandice-6":[`#e68a4f`,`#f4bb6a`,`#f9e39c`,`#dadfe2`,`#a6b7c6`,`#849eae`]},yVe={background:`#ffffff`,title:{anchor:`start`,color:`#000000`,font:x8,fontSize:gVe,fontWeight:_Ve},arc:{fill:b8},area:{fill:b8},line:{stroke:b8,strokeWidth:2},path:{stroke:b8},rect:{fill:b8},shape:{stroke:b8},symbol:{fill:b8,size:30},axis:{labelFont:v8,labelFontSize:y8,labelFontWeight:vVe,titleFont:x8,titleFontSize:C8,titleFontWeight:S8},axisX:{labelAngle:0,labelPadding:4,tickSize:3},axisY:{labelBaseline:`middle`,maxExtent:45,minExtent:45,tickSize:2,titleAlign:`left`,titleAngle:0,titleX:-45,titleY:-11},legend:{labelFont:v8,labelFontSize:y8,symbolType:`square`,titleFont:x8,titleFontSize:C8,titleFontWeight:S8},range:{category:w8[`category-6`],diverging:w8[`fireandice-6`],heatmap:w8[`fire-7`],ordinal:w8[`fire-7`],ramp:w8[`fire-7`]}},T8=`#ab5787`,E8=`#979797`,bVe={background:`#f9f9f9`,arc:{fill:T8},area:{fill:T8},line:{stroke:T8},path:{stroke:T8},rect:{fill:T8},shape:{stroke:T8},symbol:{fill:T8,size:30},axis:{domainColor:E8,domainWidth:.5,gridWidth:.2,labelColor:E8,tickColor:E8,tickWidth:.2,titleColor:E8},axisBand:{grid:!1},axisX:{grid:!0,tickSize:10},axisY:{domain:!1,grid:!0,tickSize:0},legend:{labelFontSize:11,padding:1,symbolSize:30,symbolType:`square`},range:{category:[`#ab5787`,`#51b2e5`,`#703c5c`,`#168dd9`,`#d190b6`,`#00609f`,`#d365ba`,`#154866`,`#666666`,`#c4c4c4`]}},D8=`#3e5c69`,xVe={background:`#fff`,arc:{fill:D8},area:{fill:D8},line:{stroke:D8},path:{stroke:D8},rect:{fill:D8},shape:{stroke:D8},symbol:{fill:D8},axis:{domainWidth:.5,grid:!0,labelPadding:2,tickSize:5,tickWidth:.5,titleFontWeight:`normal`},axisBand:{grid:!1},axisX:{gridWidth:.2},axisY:{gridDash:[3],gridWidth:.4},legend:{labelFontSize:11,padding:1,symbolType:`square`},range:{category:[`#3e5c69`,`#6793a6`,`#182429`,`#0570b0`,`#3690c0`,`#74a9cf`,`#a6bddb`,`#e2ddf2`]}},O8=`#1696d2`,k8=`#000000`,SVe=`#FFFFFF`,A8=`Lato`,j8=`Lato`,CVe=`Lato`,wVe=`#DEDDDD`,TVe=18,M8={"shades-blue":[`#CFE8F3`,`#A2D4EC`,`#73BFE2`,`#46ABDB`,`#1696D2`,`#12719E`,`#0A4C6A`,`#062635`],"six-groups-cat-1":[`#1696d2`,`#ec008b`,`#fdbf11`,`#000000`,`#d2d2d2`,`#55b748`],"six-groups-seq":[`#cfe8f3`,`#a2d4ec`,`#73bfe2`,`#46abdb`,`#1696d2`,`#12719e`],"diverging-colors":[`#ca5800`,`#fdbf11`,`#fdd870`,`#fff2cf`,`#cfe8f3`,`#73bfe2`,`#1696d2`,`#0a4c6a`]},EVe={background:SVe,title:{anchor:`start`,fontSize:TVe,font:A8},axisX:{domain:!0,domainColor:k8,domainWidth:1,grid:!1,labelFontSize:12,labelFont:j8,labelAngle:0,tickColor:k8,tickSize:5,titleFontSize:12,titlePadding:10,titleFont:A8},axisY:{domain:!1,domainWidth:1,grid:!0,gridColor:wVe,gridWidth:1,labelFontSize:12,labelFont:j8,labelPadding:8,ticks:!1,titleFontSize:12,titlePadding:10,titleFont:A8,titleAngle:0,titleY:-10,titleX:18},legend:{labelFontSize:12,labelFont:j8,symbolSize:100,titleFontSize:12,titlePadding:10,titleFont:A8,orient:`right`,offset:10},view:{stroke:`transparent`},range:{category:M8[`six-groups-cat-1`],diverging:M8[`diverging-colors`],heatmap:M8[`diverging-colors`],ordinal:M8[`six-groups-seq`],ramp:M8[`shades-blue`]},area:{fill:O8},rect:{fill:O8},line:{color:O8,stroke:O8,strokeWidth:5},trail:{color:O8,stroke:O8,strokeWidth:0,size:1},path:{stroke:O8,strokeWidth:.5},point:{filled:!0},text:{font:CVe,color:O8,fontSize:11,align:`center`,fontWeight:400,size:11},style:{bar:{fill:O8,stroke:null}},arc:{fill:O8},shape:{stroke:O8},symbol:{fill:O8,size:30}},N8=`#3366CC`,P8=`#ccc`,F8=`Arial, sans-serif`,DVe={arc:{fill:N8},area:{fill:N8},path:{stroke:N8},rect:{fill:N8},shape:{stroke:N8},symbol:{stroke:N8},circle:{fill:N8},background:`#fff`,padding:{top:10,right:10,bottom:10,left:10},style:{"guide-label":{font:F8,fontSize:12},"guide-title":{font:F8,fontSize:12},"group-title":{font:F8,fontSize:12}},title:{font:F8,fontSize:14,fontWeight:`bold`,dy:-3,anchor:`start`},axis:{gridColor:P8,tickColor:P8,domain:!1,grid:!0},range:{category:[`#4285F4`,`#DB4437`,`#F4B400`,`#0F9D58`,`#AB47BC`,`#00ACC1`,`#FF7043`,`#9E9D24`,`#5C6BC0`,`#F06292`,`#00796B`,`#C2185B`],heatmap:[`#c6dafc`,`#5e97f6`,`#2a56c6`]}},I8=e=>e*1.3333333333333333,L8=I8(9),R8=I8(10),z8=I8(12),B8=`Segoe UI`,V8=`wf_standard-font, helvetica, arial, sans-serif`,H8=`#252423`,U8=`#605E5C`,W8=`transparent`,OVe=`#C8C6C4`,G8=`#118DFF`,kVe=`#12239E`,AVe=`#E66C37`,jVe=`#6B007B`,MVe=`#E044A7`,NVe=`#744EC2`,PVe=`#D9B300`,FVe=`#D64550`,K8=G8,q8=`#DEEFFF`,J8=[q8,K8],IVe={view:{stroke:W8},background:W8,font:B8,header:{titleFont:V8,titleFontSize:z8,titleColor:H8,labelFont:B8,labelFontSize:R8,labelColor:U8},axis:{ticks:!1,grid:!1,domain:!1,labelColor:U8,labelFontSize:L8,titleFont:V8,titleColor:H8,titleFontSize:z8,titleFontWeight:`normal`},axisQuantitative:{tickCount:3,grid:!0,gridColor:OVe,gridDash:[1,5],labelFlush:!1},axisBand:{tickExtra:!0},axisX:{labelPadding:5},axisY:{labelPadding:10},bar:{fill:G8},line:{stroke:G8,strokeWidth:3,strokeCap:`round`,strokeJoin:`round`},text:{font:B8,fontSize:L8,fill:U8},arc:{fill:G8},area:{fill:G8,line:!0,opacity:.6},path:{stroke:G8},rect:{fill:G8},point:{fill:G8,filled:!0,size:75},shape:{stroke:G8},symbol:{fill:G8,strokeWidth:1.5,size:50},legend:{titleFont:B8,titleFontWeight:`bold`,titleColor:U8,labelFont:B8,labelFontSize:R8,labelColor:U8,symbolType:`circle`,symbolSize:75},range:{category:[G8,kVe,AVe,jVe,MVe,NVe,PVe,FVe],diverging:J8,heatmap:J8,ordinal:[q8,`#c7e4ff`,`#b0d9ff`,`#9aceff`,`#83c3ff`,`#6cb9ff`,`#55aeff`,`#3fa3ff`,`#2898ff`,K8]}},Y8=`IBM Plex Sans,system-ui,-apple-system,BlinkMacSystemFont,".sfnstext-regular",sans-serif`,LVe=`IBM Plex Sans Condensed, system-ui, -apple-system, BlinkMacSystemFont, ".SFNSText-Regular", sans-serif`,X8=400,Z8={textPrimary:{g90:`#f4f4f4`,g100:`#f4f4f4`,white:`#161616`,g10:`#161616`},textSecondary:{g90:`#c6c6c6`,g100:`#c6c6c6`,white:`#525252`,g10:`#525252`},layerAccent01:{white:`#e0e0e0`,g10:`#e0e0e0`,g90:`#525252`,g100:`#393939`},gridBg:{white:`#ffffff`,g10:`#ffffff`,g90:`#161616`,g100:`#161616`}},RVe=[`#8a3ffc`,`#33b1ff`,`#007d79`,`#ff7eb6`,`#fa4d56`,`#fff1f1`,`#6fdc8c`,`#4589ff`,`#d12771`,`#d2a106`,`#08bdba`,`#bae6ff`,`#ba4e00`,`#d4bbff`],zVe=[`#6929c4`,`#1192e8`,`#005d5d`,`#9f1853`,`#fa4d56`,`#570408`,`#198038`,`#002d9c`,`#ee538b`,`#b28600`,`#009d9a`,`#012749`,`#8a3800`,`#a56eff`],BVe=l8({theme:`white`,background:`#ffffff`}),VVe=l8({theme:`g10`,background:`#f4f4f4`}),HVe=l8({theme:`g90`,background:`#262626`}),UVe=l8({theme:`g100`,background:`#161616`}),WVe=lVe.version}));function KVe(e,t,n,r){if(H(e))return`[${e.map(e=>t(xg(e)?e:JVe(e,n))).join(`, `)}]`;if(Dh(e)){let i=``,{title:a,image:o,...s}=e;a&&(i+=`

${t(a)}

`),o&&(i+=``);let c=Object.keys(s);if(c.length>0){i+=``;for(let e of c){let r=s[e];r!==void 0&&(Dh(r)&&(r=JVe(r,n)),i+=``)}i+=`
${t(e)}${t(r)}
`}return i||`{}`}return t(e)}function qVe(e){let t=[];return function(n,r){if(typeof r!=`object`||!r)return r;let i=t.indexOf(this)+1;return t.length=i,t.length>e?`[Object]`:t.indexOf(r)>=0?`[Circular]`:(t.push(r),r)}}function JVe(e,t){return JSON.stringify(e,qVe(t))}function YVe(e){return String(e).replace(/&/g,`&`).replace(/=0&&e.y>=0&&e.x+t.width<=window.innerWidth&&e.y+t.height<=window.innerHeight}function nHe(e,t,n){return e.clientX>=t.x&&e.clientX<=t.x+n.width&&e.clientY>=t.y&&e.clientY<=t.y+n.height}var rHe,iHe,Q8,aHe,oHe,sHe=o((()=>{Ag(),rHe={version:`1.0.0`},iHe=`#vg-tooltip-element { visibility: hidden; padding: 8px; position: fixed; @@ -255,8 +255,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`

An error #vg-tooltip-element.dark-theme td.key { color: #bfbfbf; } -`,f5=`vg-tooltip-element`,OVe={offsetX:10,offsetY:10,id:f5,styleId:`vega-tooltip-style`,theme:`light`,disableDefaultStyle:!1,sanitize:vVe,maxDepth:2,formatTooltip:hVe,baseURL:``,anchor:`cursor`,position:[`top`,`bottom`,`left`,`right`,`top-left`,`top-right`,`bottom-left`,`bottom-right`]},kVe=class{call;options;el;constructor(e){this.options={...OVe,...e};let t=this.options.id;if(this.el=null,this.call=this.tooltipHandler.bind(this),!this.options.disableDefaultStyle&&!document.getElementById(this.options.styleId)){let e=document.createElement(`style`);e.setAttribute(`id`,this.options.styleId),e.innerHTML=yVe(t);let n=document.head;n.childNodes.length>0?n.insertBefore(e,n.childNodes[0]):n.appendChild(e)}}tooltipHandler(e,t,n,r){if(this.el=document.getElementById(this.options.id),this.el||(this.el=document.createElement(`div`),this.el.setAttribute(`id`,this.options.id),this.el.classList.add(`vg-tooltip`),(document.fullscreenElement??document.body).appendChild(this.el)),r==null||r===``){this.el.classList.remove(`visible`,`${this.options.theme}-theme`);return}this.el.innerHTML=this.options.formatTooltip(r,this.options.sanitize,this.options.maxDepth,this.options.baseURL),this.el.classList.add(`visible`,`${this.options.theme}-theme`);let{x:i,y:a}=this.options.anchor===`mark`?xVe(e,t,n,this.el.getBoundingClientRect(),this.options):bVe(t,this.el.getBoundingClientRect(),this.options);this.el.style.top=`${a}px`,this.el.style.left=`${i}px`}},EVe.version}));function p5(e,t){return mHe.call(e,t)}function m5(e){if(Array.isArray(e)){for(var t=Array(e.length),n=0;n=48&&r<=57){t++;continue}return!1}return!0}function _5(e){return e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function jVe(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function v5(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t0&&s[l-1]==`constructor`))throw TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&d===void 0&&(c[f]===void 0?d=s.slice(0,l).join(`/`):l==u-1&&(d=t.path),d!==void 0&&p(t,0,e,d)),l++,Array.isArray(c)){if(f===`-`)f=c.length;else if(n&&!g5(f))throw new N5(`Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index`,`OPERATION_PATH_ILLEGAL_ARRAY_INDEX`,a,t,e);else g5(f)&&(f=~~f);if(l>=u){if(n&&t.op===`add`&&f>c.length)throw new N5(`The specified index MUST NOT be greater than the number of elements in the array`,`OPERATION_VALUE_OUT_OF_BOUNDS`,a,t,e);var o=gHe[t.op].call(t,c,f,e);if(o.test===!1)throw new N5(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}}else if(l>=u){var o=P5[t.op].call(t,c,f,e);if(o.test===!1)throw new N5(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}if(c=c[f],n&&l0)throw new N5('Operation `path` property must start with "/"',`OPERATION_PATH_INVALID`,t,e,n);if((e.op===`move`||e.op===`copy`)&&typeof e.from!=`string`)throw new N5("Operation `from` property is not present (applicable in `move` and `copy` operations)",`OPERATION_FROM_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&e.value===void 0)throw new N5("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&v5(e.value))throw new N5("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED`,t,e,n);if(n){if(e.op==`add`){var i=e.path.split(`/`).length,a=r.split(`/`).length;if(i!==a+1&&i!==a)throw new N5("Cannot perform an `add` operation at the desired path",`OPERATION_PATH_CANNOT_ADD`,t,e,n)}else if(e.op===`replace`||e.op===`remove`||e.op===`_get`){if(e.path!==r)throw new N5(`Cannot perform the operation at a path that does not exist`,`OPERATION_PATH_UNRESOLVABLE`,t,e,n)}else if(e.op===`move`||e.op===`copy`){var o=PVe([{op:`_get`,path:e.from,value:void 0}],n);if(o&&o.name===`OPERATION_PATH_UNRESOLVABLE`)throw new N5(`Cannot perform the operation from a path that does not exist`,`OPERATION_FROM_UNRESOLVABLE`,t,e,n)}}}function PVe(e,t,n){try{if(!Array.isArray(e))throw new N5(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);if(t)x5(h5(t),h5(e),n||!0);else{n||=S5;for(var r=0;r0&&(e.patches=[],e.callback&&e.callback(r)),r}function T5(e,t,n,r,i){if(t!==e){typeof t.toJSON==`function`&&(t=t.toJSON());for(var a=m5(t),o=m5(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(p5(t,l)&&!(t[l]===void 0&&u!==void 0&&Array.isArray(t)===!1)){var d=t[l];typeof u==`object`&&u&&typeof d==`object`&&d&&Array.isArray(u)===Array.isArray(d)?T5(u,d,n,r+`/`+_5(l),i):u!==d&&(i&&n.push({op:`test`,path:r+`/`+_5(l),value:h5(u)}),n.push({op:`replace`,path:r+`/`+_5(l),value:h5(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:`test`,path:r+`/`+_5(l),value:h5(u)}),n.push({op:`remove`,path:r+`/`+_5(l)}),s=!0):(i&&n.push({op:`test`,path:r,value:e}),n.push({op:`replace`,path:r,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}return I5=e,I5}function E5(){if(xHe)return L5;xHe=1;let e=Object.freeze({loose:!0}),t=Object.freeze({});return L5=n=>n?typeof n==`object`?n:e:t,L5}function D5(){return SHe?z5:(SHe=1,z5={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},z5)}function O5(){return CHe?B5:(CHe=1,B5=typeof process==`object`&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{},B5)}function k5(){return wHe?R5.exports:(wHe=1,(function(e,t){let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=D5(),a=O5();t=e.exports={};let o=t.re=[],s=t.safeRe=[],c=t.src=[],l=t.safeSrc=[],u=t.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})(R5,R5.exports),R5.exports)}function UVe(){if(THe)return V5;THe=1;let e=/^[0-9]+$/,t=(t,n)=>{let r=e.test(t),i=e.test(n);return r&&i&&(t=+t,n=+n),t===n?0:r&&!i?-1:i&&!r?1:tt(n,e)},V5}function A5(){if(EHe)return H5;EHe=1;let e=O5(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:n}=D5(),{safeRe:r,t:i}=k5(),a=E5(),{compareIdentifiers:o}=UVe();class s{constructor(o,c){if(c=a(c),o instanceof s){if(o.loose===!!c.loose&&o.includePrerelease===!!c.includePrerelease)return o;o=o.version}else if(typeof o!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof o}".`);if(o.length>t)throw TypeError(`version is longer than ${t} characters`);e(`SemVer`,o,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=o.trim().match(c.loose?r[i.LOOSE]:r[i.FULL]);if(!l)throw TypeError(`Invalid Version: ${o}`);if(this.raw=o,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>n||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>n||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>n||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),o(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}return H5=s,H5}function j5(){if(DHe)return U5;DHe=1;let e=A5();return U5=(t,n,r)=>new e(t,r).compare(new e(n,r)),U5}function WVe(){if(OHe)return W5;OHe=1;let e=j5();return W5=(t,n,r)=>e(t,n,r)===0,W5}function GVe(){if(kHe)return G5;kHe=1;let e=j5();return G5=(t,n,r)=>e(t,n,r)!==0,G5}function KVe(){if(AHe)return K5;AHe=1;let e=j5();return K5=(t,n,r)=>e(t,n,r)>0,K5}function qVe(){if(jHe)return q5;jHe=1;let e=j5();return q5=(t,n,r)=>e(t,n,r)>=0,q5}function JVe(){if(MHe)return J5;MHe=1;let e=j5();return J5=(t,n,r)=>e(t,n,r)<0,J5}function YVe(){if(NHe)return Y5;NHe=1;let e=j5();return Y5=(t,n,r)=>e(t,n,r)<=0,Y5}function XVe(){if(PHe)return X5;PHe=1;let e=WVe(),t=GVe(),n=KVe(),r=qVe(),i=JVe(),a=YVe();return X5=(o,s,c,l)=>{switch(s){case`===`:return typeof o==`object`&&(o=o.version),typeof c==`object`&&(c=c.version),o===c;case`!==`:return typeof o==`object`&&(o=o.version),typeof c==`object`&&(c=c.version),o!==c;case``:case`=`:case`==`:return e(o,c,l);case`!=`:return t(o,c,l);case`>`:return n(o,c,l);case`>=`:return r(o,c,l);case`<`:return i(o,c,l);case`<=`:return a(o,c,l);default:throw TypeError(`Invalid operator: ${s}`)}},X5}function ZVe(){if(FHe)return Z5;FHe=1;let e=Symbol(`SemVer ANY`);class t{static get ANY(){return e}constructor(r,i){if(i=n(i),r instanceof t){if(r.loose===!!i.loose)return r;r=r.value}r=r.trim().split(/\s+/).join(` `),o(`comparator`,r,i),this.options=i,this.loose=!!i.loose,this.parse(r),this.semver===e?this.value=``:this.value=this.operator+this.semver.version,o(`comp`,this)}parse(t){let n=this.options.loose?r[i.COMPARATORLOOSE]:r[i.COMPARATOR],a=t.match(n);if(!a)throw TypeError(`Invalid comparator: ${t}`);this.operator=a[1]===void 0?``:a[1],this.operator===`=`&&(this.operator=``),a[2]?this.semver=new s(a[2],this.options.loose):this.semver=e}toString(){return this.value}test(t){if(o(`Comparator.test`,t,this.options.loose),this.semver===e||t===e)return!0;if(typeof t==`string`)try{t=new s(t,this.options)}catch{return!1}return a(t,this.operator,this.semver,this.options)}intersects(e,r){if(!(e instanceof t))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``||new c(e.value,r).test(this.value):e.operator===``?e.value===``||new c(this.value,r).test(e.semver):(r=n(r),r.includePrerelease&&(this.value===`<0.0.0-0`||e.value===`<0.0.0-0`)||!r.includePrerelease&&(this.value.startsWith(`<0.0.0`)||e.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&e.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&e.operator.startsWith(`<`)||this.semver.version===e.semver.version&&this.operator.includes(`=`)&&e.operator.includes(`=`)||a(this.semver,`<`,e.semver,r)&&this.operator.startsWith(`>`)&&e.operator.startsWith(`<`)||a(this.semver,`>`,e.semver,r)&&this.operator.startsWith(`<`)&&e.operator.startsWith(`>`)))}}Z5=t;let n=E5(),{safeRe:r,t:i}=k5(),a=XVe(),o=O5(),s=A5(),c=QVe();return Z5}function QVe(){if(IHe)return Q5;IHe=1;let e=/\s+/g;class t{constructor(n,a){if(a=r(a),n instanceof t)return n.loose===!!a.loose&&n.includePrerelease===!!a.includePrerelease?n:new t(n.raw,a);if(n instanceof i)return this.raw=n.value,this.set=[[n]],this.formatted=void 0,this;if(this.options=a,this.loose=!!a.loose,this.includePrerelease=!!a.includePrerelease,this.raw=n.trim().replace(e,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!m(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&h(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&f)|(this.options.loose&&p))+`:`+e,r=n.get(t);if(r)return r;let o=this.options.loose,h=o?s[c.HYPHENRANGELOOSE]:s[c.HYPHENRANGE];e=e.replace(h,D(this.options.includePrerelease)),a(`hyphen replace`,e),e=e.replace(s[c.COMPARATORTRIM],l),a(`comparator trim`,e),e=e.replace(s[c.TILDETRIM],u),a(`tilde trim`,e),e=e.replace(s[c.CARETTRIM],d),a(`caret trim`,e);let g=e.split(` `).map(e=>_(e,this.options)).join(` `).split(/\s+/).map(e=>E(e,this.options));o&&(g=g.filter(e=>(a(`loose invalid filter`,e,this.options),!!e.match(s[c.COMPARATORLOOSE])))),a(`range list`,g);let v=new Map,y=g.map(e=>new i(e,this.options));for(let e of y){if(m(e))return[e];v.set(e.value,e)}v.size>1&&v.has(``)&&v.delete(``);let b=[...v.values()];return n.set(t,b),b}intersects(e,n){if(!(e instanceof t))throw TypeError(`a Range is required`);return this.set.some(t=>g(t,n)&&e.set.some(e=>g(e,n)&&t.every(t=>e.every(e=>t.intersects(e,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new o(e,this.options)}catch{return!1}for(let t=0;te.value===`<0.0.0-0`,h=e=>e.value===``,g=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},_=(e,t)=>(a(`comp`,e,t),e=x(e,t),a(`caret`,e),e=y(e,t),a(`tildes`,e),e=C(e,t),a(`xrange`,e),e=T(e,t),a(`stars`,e),e),v=e=>!e||e.toLowerCase()===`x`||e===`*`,y=(e,t)=>e.trim().split(/\s+/).map(e=>b(e,t)).join(` `),b=(e,t)=>{let n=t.loose?s[c.TILDELOOSE]:s[c.TILDE];return e.replace(n,(t,n,r,i,o)=>{a(`tilde`,e,t,n,r,i,o);let s;return v(n)?s=``:v(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:v(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:o?(a(`replaceTilde pr`,o),s=`>=${n}.${r}.${i}-${o} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,a(`tilde return`,s),s})},x=(e,t)=>e.trim().split(/\s+/).map(e=>S(e,t)).join(` `),S=(e,t)=>{a(`caret`,e,t);let n=t.loose?s[c.CARETLOOSE]:s[c.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,o,s)=>{a(`caret`,e,t,n,i,o,s);let c;return v(n)?c=``:v(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:v(o)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(a(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${o}-${s} <${n}.${i}.${+o+1}-0`:`>=${n}.${i}.${o}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${o}-${s} <${+n+1}.0.0-0`):(a(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${o}${r} <${n}.${i}.${+o+1}-0`:`>=${n}.${i}.${o}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${o} <${+n+1}.0.0-0`),a(`caret return`,c),c})},C=(e,t)=>(a(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>w(e,t)).join(` `)),w=(e,t)=>{e=e.trim();let n=t.loose?s[c.XRANGELOOSE]:s[c.XRANGE];return e.replace(n,(n,r,i,o,s,c)=>{a(`xRange`,e,n,r,i,o,s,c);let l=v(i),u=l||v(o),d=u||v(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(o=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,o=0,s=0):(o=+o+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:o=+o+1),r===`<`&&(c=`-0`),n=`${r+i}.${o}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${o}.0${c} <${i}.${+o+1}.0-0`),a(`xRange return`,n),n})},T=(e,t)=>(a(`replaceStars`,e,t),e.trim().replace(s[c.STAR],``)),E=(e,t)=>(a(`replaceGTE0`,e,t),e.trim().replace(s[t.includePrerelease?c.GTE0PRE:c.GTE0],``)),D=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=v(r)?``:v(i)?`>=${r}.0.0${e?`-0`:``}`:v(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=v(l)?``:v(u)?`<${+l+1}.0.0-0`:v(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),O=(e,t,n)=>{for(let n=0;n0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0};return Q5}function $Ve(){if(LHe)return $5;LHe=1;let e=QVe();return $5=(t,n,r)=>{try{n=new e(n,r)}catch{return!1}return n.test(t)},$5}function eHe(e,t,n){let r=e.open(t),{origin:i}=new URL(t),a=40;function o(t){t.source===r&&(a=0,e.removeEventListener(`message`,o,!1))}e.addEventListener(`message`,o,!1);function s(){a<=0||(r.postMessage(n,i),setTimeout(s,250),--a)}setTimeout(s,250)}function tHe(e,...t){for(let n of t)nHe(e,n);return e}function nHe(e,t){for(let n of Object.keys(t))yh(e,n,t[n],!0)}function rHe(e){return typeof e==`function`}function iHe(e,t,n,r){let i=`${t}

`,a=`
${n}`,o=window.open(``);o.document.write(i+e+a),o.document.title=`${i7[r]} JSON Source`}function aHe(e,t,n){if(e.$schema){let r=kBe(e.$schema);n&&n!==r.library&&t.warn(`The given visualization spec is written in ${i7[r.library]}, but mode argument sets ${i7[n]??n}.`);let i=r.library;return e7(a7[i],`^${r.version.slice(1)}`)||t.warn(`The input spec uses ${i7[i]} ${r.version}, but the current version of ${i7[i]} is v${a7[i]}.`),i}return`mark`in e||`encoding`in e||`layer`in e||`hconcat`in e||`vconcat`in e||`facet`in e||`repeat`in e?`vega-lite`:`marks`in e||`signals`in e||`scales`in e||`axes`in e?`vega`:n??`vega`}function oHe(e){return!!(e&&`load`in e)}function sHe(e){return oHe(e)?e:t7.loader(e)}function cHe(e){let t=e.usermeta?.embedOptions??{};return gg(t.defaultStyle)&&(t.defaultStyle=!1),t}async function lHe(e,t,n={}){let r,i;gg(t)?(i=sHe(n.loader),r=JSON.parse(await i.load(t))):r=t;let a=cHe(r),o=a.loader;(!i||o)&&(i=sHe(n.loader??o));let s=await uHe(a,i),c=await uHe(n,i),l={...tHe(c,s),config:vh(c.config??{},s.config??{})};return await fHe(e,r,l,i)}async function uHe(e,t){let n=gg(e.config)?JSON.parse(await t.load(e.config)):e.config??{},r=gg(e.patch)?JSON.parse(await t.load(e.patch)):e.patch;return{...e,...r?{patch:r}:{},...n?{config:n}:{}}}function dHe(e){let t=e.getRootNode?e.getRootNode():document;return t instanceof ShadowRoot?{root:t,rootContainer:t}:{root:document,rootContainer:document.head??document.body}}async function fHe(e,t,n={},r){let i=n.theme?vh(jBe[n.theme],n.config??{}):n.config,a=fg(n.actions)?n.actions:tHe({},zHe,n.actions??{}),o={...BHe,...n.i18n},s=n.renderer??`svg`,c=n.logger??mh(t7.Warn);n.logLevel!==void 0&&c.level(n.logLevel);let l=n.downloadFileName??`visualization`,u=typeof e==`string`?document.querySelector(e):e;if(!u)throw Error(`${e} does not exist`);if(n.defaultStyle!==!1){let e=`vega-embed-style`,{root:t,rootContainer:r}=dHe(u);if(!t.getElementById(e)){let t=document.createElement(`style`);t.id=e,t.innerHTML=n.defaultStyle===void 0||n.defaultStyle===!0?RHe.toString():n.defaultStyle,r.appendChild(t)}}let d=aHe(t,c,n.mode),f=VHe[d](t,c,i);if(d===`vega-lite`&&f.$schema){let e=kBe(f.$schema);e7(a7.vega,`^${e.version.slice(1)}`)||c.warn(`The compiled spec uses Vega ${e.version}, but current version is v${a7.vega}.`)}u.classList.add(`vega-embed`),a&&u.classList.add(`has-actions`),u.innerHTML=``;let p=u;if(a){let e=document.createElement(`div`);e.classList.add(UHe),u.appendChild(e),p=e}let m=n.patch;if(m&&(f=m instanceof Function?m(f):x5(f,m,!0,!1).newDocument),n.formatLocale&&t7.formatLocale(n.formatLocale),n.timeFormatLocale&&t7.timeFormatLocale(n.timeFormatLocale),n.expressionFunctions)for(let e in n.expressionFunctions){let t=n.expressionFunctions[e];`fn`in t?t7.expressionFunction(e,t.fn,t.visitor):t instanceof Function&&t7.expressionFunction(e,t)}let{ast:h}=n,g=t7.parse(f,d===`vega-lite`?{}:i,{ast:h}),_=new(n.viewClass||t7.View)(g,{loader:r,logger:c,renderer:s,...h?{expr:t7.expressionInterpreter??n.expr??QY}:{}});if(_.addSignalListener(`autosize`,(e,t)=>{let{type:n}=t;n==`fit-x`?(p.classList.add(`fit-x`),p.classList.remove(`fit-y`)):n==`fit-y`?(p.classList.remove(`fit-x`),p.classList.add(`fit-y`)):n==`fit`?p.classList.add(`fit-x`,`fit-y`):p.classList.remove(`fit-x`,`fit-y`)}),n.tooltip!==!1){let{loader:e,tooltip:t}=n,r=e&&!oHe(e)?e?.baseURL:void 0,i=rHe(t)?t:new kVe({baseURL:r,...t===!0?{}:t}).call;_.tooltip(i)}let{hover:v}=n;if(v===void 0&&(v=d===`vega`),v){let{hoverSet:e,updateSet:t}=typeof v==`boolean`?{}:v;_.hover(e,t)}n&&(n.width!=null&&_.width(n.width),n.height!=null&&_.height(n.height),n.padding!=null&&_.padding(n.padding)),await _.initialize(p,n.bind).runAsync();let y;if(a!==!1){let e=u;if(n.defaultStyle!==!1||n.forceActionsMenu){let t=document.createElement(`details`);t.title=o.CLICK_TO_VIEW_ACTIONS,u.append(t),e=t;let n=document.createElement(`summary`);n.innerHTML=HHe,t.append(n),y=e=>{t.contains(e.target)||t.removeAttribute(`open`)},document.addEventListener(`click`,y)}let r=document.createElement(`div`);if(e.append(r),r.classList.add(`vega-actions`),a===!0||a.export!==!1){for(let e of[`svg`,`png`])if(a===!0||a.export===!0||a.export[e]){let t=o[`${e.toUpperCase()}_ACTION`],i=document.createElement(`a`),a=gh(n.scaleFactor)?n.scaleFactor[e]:n.scaleFactor;i.text=t,i.href=`#`,i.target=`_blank`,i.download=`${l}.${e}`,i.addEventListener(`mousedown`,async function(t){t.preventDefault();let n=await _.toImageURL(e,a);this.href=n}),r.append(i)}}if(a===!0||a.source!==!1){let e=document.createElement(`a`);e.text=o.SOURCE_ACTION,e.href=`#`,e.addEventListener(`click`,function(e){iHe(Km(t),n.sourceHeader??``,n.sourceFooter??``,d),e.preventDefault()}),r.append(e)}if(d===`vega-lite`&&(a===!0||a.compiled!==!1)){let e=document.createElement(`a`);e.text=o.COMPILED_ACTION,e.href=`#`,e.addEventListener(`click`,function(e){iHe(Km(f),n.sourceHeader??``,n.sourceFooter??``,`vega`),e.preventDefault()}),r.append(e)}if(a===!0||a.editor!==!1){let e=n.editorUrl??`https://vega.github.io/editor/`,a=document.createElement(`a`);a.text=o.EDITOR_ACTION,a.href=`#`,a.addEventListener(`click`,function(n){eHe(window,e,{config:i,mode:m?`vega`:d,renderer:s,spec:Km(m?f:t)}),n.preventDefault()}),r.append(a)}}function b(){y&&document.removeEventListener(`click`,y),_.finalize()}return{view:_,spec:t,vgSpec:f,finalize:b,embedOptions:n}}var pHe,mHe,M5,N5,hHe,P5,gHe,_He,F5,vHe,yHe,I5,bHe,L5,xHe,R5,z5,SHe,B5,CHe,wHe,V5,THe,H5,EHe,U5,DHe,W5,OHe,G5,kHe,K5,AHe,q5,jHe,J5,MHe,Y5,NHe,X5,PHe,Z5,FHe,Q5,IHe,$5,LHe,e7,RHe,t7,n7,r7,zHe,BHe,i7,a7,VHe,HHe,UHe,WHe=o((()=>{pie(),BY(),QDe(),OBe(),ABe(),mVe(),AVe(),pHe=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),mHe=Object.prototype.hasOwnProperty,M5=function(e){pHe(t,e);function t(t,n,r,i,a){var o=this.constructor,s=e.call(this,MVe(t,{name:n,index:r,operation:i,tree:a}))||this;return s.name=n,s.index=r,s.operation=i,s.tree=a,Object.setPrototypeOf(s,o.prototype),s.message=MVe(t,{name:n,index:r,operation:i,tree:a}),s}return t}(Error),N5=M5,hHe=h5,P5={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=y5(n,this.path);r&&=h5(r);var i=b5(n,{op:`remove`,path:this.from}).removed;return b5(n,{op:`add`,path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=y5(n,this.from);return b5(n,{op:`add`,path:this.path,value:h5(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:C5(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},gHe={add:function(e,t,n){return g5(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){return{newDocument:n,removed:e.splice(t,1)[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:P5.move,copy:P5.copy,test:P5.test,_get:P5._get},_He=Object.freeze({__proto__:null,JsonPatchError:N5,_areEquals:C5,applyOperation:b5,applyPatch:x5,applyReducer:NVe,deepClone:hHe,getValueByPointer:y5,validate:PVe,validator:S5}),F5=new WeakMap,vHe=function(){function e(e){this.observers=new Map,this.obj=e}return e}(),yHe=function(){function e(e,t){this.callback=e,this.observer=t}return e}(),Object.assign({},_He,Object.freeze({__proto__:null,compare:BVe,generate:w5,observe:zVe,unobserve:RVe}),{JsonPatchError:M5,deepClone:h5,escapePathComponent:_5,unescapePathComponent:jVe}),R5={exports:{}},e7=VVe($Ve()),RHe=`.vega-embed { +`,Q8=`vg-tooltip-element`,aHe={offsetX:10,offsetY:10,id:Q8,styleId:`vega-tooltip-style`,theme:`light`,disableDefaultStyle:!1,sanitize:YVe,maxDepth:2,formatTooltip:KVe,baseURL:``,anchor:`cursor`,position:[`top`,`bottom`,`left`,`right`,`top-left`,`top-right`,`bottom-left`,`bottom-right`]},oHe=class{call;options;el;constructor(e){this.options={...aHe,...e};let t=this.options.id;if(this.el=null,this.call=this.tooltipHandler.bind(this),!this.options.disableDefaultStyle&&!document.getElementById(this.options.styleId)){let e=document.createElement(`style`);e.setAttribute(`id`,this.options.styleId),e.innerHTML=XVe(t);let n=document.head;n.childNodes.length>0?n.insertBefore(e,n.childNodes[0]):n.appendChild(e)}}tooltipHandler(e,t,n,r){if(this.el=document.getElementById(this.options.id),this.el||(this.el=document.createElement(`div`),this.el.setAttribute(`id`,this.options.id),this.el.classList.add(`vg-tooltip`),(document.fullscreenElement??document.body).appendChild(this.el)),r==null||r===``){this.el.classList.remove(`visible`,`${this.options.theme}-theme`);return}this.el.innerHTML=this.options.formatTooltip(r,this.options.sanitize,this.options.maxDepth,this.options.baseURL),this.el.classList.add(`visible`,`${this.options.theme}-theme`);let{x:i,y:a}=this.options.anchor===`mark`?QVe(e,t,n,this.el.getBoundingClientRect(),this.options):ZVe(t,this.el.getBoundingClientRect(),this.options);this.el.style.top=`${a}px`,this.el.style.left=`${i}px`}},rHe.version}));function $8(e,t){return GHe.call(e,t)}function e5(e){if(Array.isArray(e)){for(var t=Array(e.length),n=0;n=48&&r<=57){t++;continue}return!1}return!0}function r5(e){return e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function cHe(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function i5(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t0&&s[l-1]==`constructor`))throw TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&d===void 0&&(c[f]===void 0?d=s.slice(0,l).join(`/`):l==u-1&&(d=t.path),d!==void 0&&p(t,0,e,d)),l++,Array.isArray(c)){if(f===`-`)f=c.length;else if(n&&!n5(f))throw new y5(`Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index`,`OPERATION_PATH_ILLEGAL_ARRAY_INDEX`,a,t,e);else n5(f)&&(f=~~f);if(l>=u){if(n&&t.op===`add`&&f>c.length)throw new y5(`The specified index MUST NOT be greater than the number of elements in the array`,`OPERATION_VALUE_OUT_OF_BOUNDS`,a,t,e);var o=qHe[t.op].call(t,c,f,e);if(o.test===!1)throw new y5(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}}else if(l>=u){var o=b5[t.op].call(t,c,f,e);if(o.test===!1)throw new y5(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}if(c=c[f],n&&l0)throw new y5('Operation `path` property must start with "/"',`OPERATION_PATH_INVALID`,t,e,n);if((e.op===`move`||e.op===`copy`)&&typeof e.from!=`string`)throw new y5("Operation `from` property is not present (applicable in `move` and `copy` operations)",`OPERATION_FROM_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&e.value===void 0)throw new y5("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&i5(e.value))throw new y5("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED`,t,e,n);if(n){if(e.op==`add`){var i=e.path.split(`/`).length,a=r.split(`/`).length;if(i!==a+1&&i!==a)throw new y5("Cannot perform an `add` operation at the desired path",`OPERATION_PATH_CANNOT_ADD`,t,e,n)}else if(e.op===`replace`||e.op===`remove`||e.op===`_get`){if(e.path!==r)throw new y5(`Cannot perform the operation at a path that does not exist`,`OPERATION_PATH_UNRESOLVABLE`,t,e,n)}else if(e.op===`move`||e.op===`copy`){var o=dHe([{op:`_get`,path:e.from,value:void 0}],n);if(o&&o.name===`OPERATION_PATH_UNRESOLVABLE`)throw new y5(`Cannot perform the operation from a path that does not exist`,`OPERATION_FROM_UNRESOLVABLE`,t,e,n)}}}function dHe(e,t,n){try{if(!Array.isArray(e))throw new y5(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);if(t)s5(t5(t),t5(e),n||!0);else{n||=c5;for(var r=0;r0&&(e.patches=[],e.callback&&e.callback(r)),r}function d5(e,t,n,r,i){if(t!==e){typeof t.toJSON==`function`&&(t=t.toJSON());for(var a=e5(t),o=e5(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if($8(t,l)&&!(t[l]===void 0&&u!==void 0&&Array.isArray(t)===!1)){var d=t[l];typeof u==`object`&&u&&typeof d==`object`&&d&&Array.isArray(u)===Array.isArray(d)?d5(u,d,n,r+`/`+r5(l),i):u!==d&&(i&&n.push({op:`test`,path:r+`/`+r5(l),value:t5(u)}),n.push({op:`replace`,path:r+`/`+r5(l),value:t5(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:`test`,path:r+`/`+r5(l),value:t5(u)}),n.push({op:`remove`,path:r+`/`+r5(l)}),s=!0):(i&&n.push({op:`test`,path:r,value:e}),n.push({op:`replace`,path:r,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}return S5=e,S5}function f5(){if(QHe)return C5;QHe=1;let e=Object.freeze({loose:!0}),t=Object.freeze({});return C5=n=>n?typeof n==`object`?n:e:t,C5}function p5(){return $He?T5:($He=1,T5={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},T5)}function m5(){return eUe?E5:(eUe=1,E5=typeof process==`object`&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{},E5)}function h5(){return tUe?w5.exports:(tUe=1,(function(e,t){let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=p5(),a=m5();t=e.exports={};let o=t.re=[],s=t.safeRe=[],c=t.src=[],l=t.safeSrc=[],u=t.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})(w5,w5.exports),w5.exports)}function bHe(){if(nUe)return D5;nUe=1;let e=/^[0-9]+$/,t=(t,n)=>{let r=e.test(t),i=e.test(n);return r&&i&&(t=+t,n=+n),t===n?0:r&&!i?-1:i&&!r?1:tt(n,e)},D5}function g5(){if(rUe)return O5;rUe=1;let e=m5(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:n}=p5(),{safeRe:r,t:i}=h5(),a=f5(),{compareIdentifiers:o}=bHe();class s{constructor(o,c){if(c=a(c),o instanceof s){if(o.loose===!!c.loose&&o.includePrerelease===!!c.includePrerelease)return o;o=o.version}else if(typeof o!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof o}".`);if(o.length>t)throw TypeError(`version is longer than ${t} characters`);e(`SemVer`,o,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=o.trim().match(c.loose?r[i.LOOSE]:r[i.FULL]);if(!l)throw TypeError(`Invalid Version: ${o}`);if(this.raw=o,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>n||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>n||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>n||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),o(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}return O5=s,O5}function _5(){if(iUe)return k5;iUe=1;let e=g5();return k5=(t,n,r)=>new e(t,r).compare(new e(n,r)),k5}function xHe(){if(aUe)return A5;aUe=1;let e=_5();return A5=(t,n,r)=>e(t,n,r)===0,A5}function SHe(){if(oUe)return j5;oUe=1;let e=_5();return j5=(t,n,r)=>e(t,n,r)!==0,j5}function CHe(){if(sUe)return M5;sUe=1;let e=_5();return M5=(t,n,r)=>e(t,n,r)>0,M5}function wHe(){if(cUe)return N5;cUe=1;let e=_5();return N5=(t,n,r)=>e(t,n,r)>=0,N5}function THe(){if(lUe)return P5;lUe=1;let e=_5();return P5=(t,n,r)=>e(t,n,r)<0,P5}function EHe(){if(uUe)return F5;uUe=1;let e=_5();return F5=(t,n,r)=>e(t,n,r)<=0,F5}function DHe(){if(dUe)return I5;dUe=1;let e=xHe(),t=SHe(),n=CHe(),r=wHe(),i=THe(),a=EHe();return I5=(o,s,c,l)=>{switch(s){case`===`:return typeof o==`object`&&(o=o.version),typeof c==`object`&&(c=c.version),o===c;case`!==`:return typeof o==`object`&&(o=o.version),typeof c==`object`&&(c=c.version),o!==c;case``:case`=`:case`==`:return e(o,c,l);case`!=`:return t(o,c,l);case`>`:return n(o,c,l);case`>=`:return r(o,c,l);case`<`:return i(o,c,l);case`<=`:return a(o,c,l);default:throw TypeError(`Invalid operator: ${s}`)}},I5}function OHe(){if(fUe)return L5;fUe=1;let e=Symbol(`SemVer ANY`);class t{static get ANY(){return e}constructor(r,i){if(i=n(i),r instanceof t){if(r.loose===!!i.loose)return r;r=r.value}r=r.trim().split(/\s+/).join(` `),o(`comparator`,r,i),this.options=i,this.loose=!!i.loose,this.parse(r),this.semver===e?this.value=``:this.value=this.operator+this.semver.version,o(`comp`,this)}parse(t){let n=this.options.loose?r[i.COMPARATORLOOSE]:r[i.COMPARATOR],a=t.match(n);if(!a)throw TypeError(`Invalid comparator: ${t}`);this.operator=a[1]===void 0?``:a[1],this.operator===`=`&&(this.operator=``),a[2]?this.semver=new s(a[2],this.options.loose):this.semver=e}toString(){return this.value}test(t){if(o(`Comparator.test`,t,this.options.loose),this.semver===e||t===e)return!0;if(typeof t==`string`)try{t=new s(t,this.options)}catch{return!1}return a(t,this.operator,this.semver,this.options)}intersects(e,r){if(!(e instanceof t))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``||new c(e.value,r).test(this.value):e.operator===``?e.value===``||new c(this.value,r).test(e.semver):(r=n(r),r.includePrerelease&&(this.value===`<0.0.0-0`||e.value===`<0.0.0-0`)||!r.includePrerelease&&(this.value.startsWith(`<0.0.0`)||e.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&e.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&e.operator.startsWith(`<`)||this.semver.version===e.semver.version&&this.operator.includes(`=`)&&e.operator.includes(`=`)||a(this.semver,`<`,e.semver,r)&&this.operator.startsWith(`>`)&&e.operator.startsWith(`<`)||a(this.semver,`>`,e.semver,r)&&this.operator.startsWith(`<`)&&e.operator.startsWith(`>`)))}}L5=t;let n=f5(),{safeRe:r,t:i}=h5(),a=DHe(),o=m5(),s=g5(),c=kHe();return L5}function kHe(){if(pUe)return R5;pUe=1;let e=/\s+/g;class t{constructor(n,a){if(a=r(a),n instanceof t)return n.loose===!!a.loose&&n.includePrerelease===!!a.includePrerelease?n:new t(n.raw,a);if(n instanceof i)return this.raw=n.value,this.set=[[n]],this.formatted=void 0,this;if(this.options=a,this.loose=!!a.loose,this.includePrerelease=!!a.includePrerelease,this.raw=n.trim().replace(e,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!m(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&h(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&f)|(this.options.loose&&p))+`:`+e,r=n.get(t);if(r)return r;let o=this.options.loose,h=o?s[c.HYPHENRANGELOOSE]:s[c.HYPHENRANGE];e=e.replace(h,D(this.options.includePrerelease)),a(`hyphen replace`,e),e=e.replace(s[c.COMPARATORTRIM],l),a(`comparator trim`,e),e=e.replace(s[c.TILDETRIM],u),a(`tilde trim`,e),e=e.replace(s[c.CARETTRIM],d),a(`caret trim`,e);let g=e.split(` `).map(e=>_(e,this.options)).join(` `).split(/\s+/).map(e=>E(e,this.options));o&&(g=g.filter(e=>(a(`loose invalid filter`,e,this.options),!!e.match(s[c.COMPARATORLOOSE])))),a(`range list`,g);let v=new Map,y=g.map(e=>new i(e,this.options));for(let e of y){if(m(e))return[e];v.set(e.value,e)}v.size>1&&v.has(``)&&v.delete(``);let b=[...v.values()];return n.set(t,b),b}intersects(e,n){if(!(e instanceof t))throw TypeError(`a Range is required`);return this.set.some(t=>g(t,n)&&e.set.some(e=>g(e,n)&&t.every(t=>e.every(e=>t.intersects(e,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new o(e,this.options)}catch{return!1}for(let t=0;te.value===`<0.0.0-0`,h=e=>e.value===``,g=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},_=(e,t)=>(a(`comp`,e,t),e=x(e,t),a(`caret`,e),e=y(e,t),a(`tildes`,e),e=C(e,t),a(`xrange`,e),e=T(e,t),a(`stars`,e),e),v=e=>!e||e.toLowerCase()===`x`||e===`*`,y=(e,t)=>e.trim().split(/\s+/).map(e=>b(e,t)).join(` `),b=(e,t)=>{let n=t.loose?s[c.TILDELOOSE]:s[c.TILDE];return e.replace(n,(t,n,r,i,o)=>{a(`tilde`,e,t,n,r,i,o);let s;return v(n)?s=``:v(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:v(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:o?(a(`replaceTilde pr`,o),s=`>=${n}.${r}.${i}-${o} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,a(`tilde return`,s),s})},x=(e,t)=>e.trim().split(/\s+/).map(e=>S(e,t)).join(` `),S=(e,t)=>{a(`caret`,e,t);let n=t.loose?s[c.CARETLOOSE]:s[c.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,o,s)=>{a(`caret`,e,t,n,i,o,s);let c;return v(n)?c=``:v(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:v(o)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(a(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${o}-${s} <${n}.${i}.${+o+1}-0`:`>=${n}.${i}.${o}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${o}-${s} <${+n+1}.0.0-0`):(a(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${o}${r} <${n}.${i}.${+o+1}-0`:`>=${n}.${i}.${o}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${o} <${+n+1}.0.0-0`),a(`caret return`,c),c})},C=(e,t)=>(a(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>w(e,t)).join(` `)),w=(e,t)=>{e=e.trim();let n=t.loose?s[c.XRANGELOOSE]:s[c.XRANGE];return e.replace(n,(n,r,i,o,s,c)=>{a(`xRange`,e,n,r,i,o,s,c);let l=v(i),u=l||v(o),d=u||v(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(o=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,o=0,s=0):(o=+o+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:o=+o+1),r===`<`&&(c=`-0`),n=`${r+i}.${o}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${o}.0${c} <${i}.${+o+1}.0-0`),a(`xRange return`,n),n})},T=(e,t)=>(a(`replaceStars`,e,t),e.trim().replace(s[c.STAR],``)),E=(e,t)=>(a(`replaceGTE0`,e,t),e.trim().replace(s[t.includePrerelease?c.GTE0PRE:c.GTE0],``)),D=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=v(r)?``:v(i)?`>=${r}.0.0${e?`-0`:``}`:v(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=v(l)?``:v(u)?`<${+l+1}.0.0-0`:v(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),O=(e,t,n)=>{for(let n=0;n0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0};return R5}function AHe(){if(mUe)return z5;mUe=1;let e=kHe();return z5=(t,n,r)=>{try{n=new e(n,r)}catch{return!1}return n.test(t)},z5}function jHe(e,t,n){let r=e.open(t),{origin:i}=new URL(t),a=40;function o(t){t.source===r&&(a=0,e.removeEventListener(`message`,o,!1))}e.addEventListener(`message`,o,!1);function s(){a<=0||(r.postMessage(n,i),setTimeout(s,250),--a)}setTimeout(s,250)}function MHe(e,...t){for(let n of t)NHe(e,n);return e}function NHe(e,t){for(let n of Object.keys(t))Ah(e,n,t[n],!0)}function PHe(e){return typeof e==`function`}function FHe(e,t,n,r){let i=`${t}
`,a=`
${n}`,o=window.open(``);o.document.write(i+e+a),o.document.title=`${W5[r]} JSON Source`}function IHe(e,t,n){if(e.$schema){let r=oVe(e.$schema);n&&n!==r.library&&t.warn(`The given visualization spec is written in ${W5[r.library]}, but mode argument sets ${W5[n]??n}.`);let i=r.library;return B5(G5[i],`^${r.version.slice(1)}`)||t.warn(`The input spec uses ${W5[i]} ${r.version}, but the current version of ${W5[i]} is v${G5[i]}.`),i}return`mark`in e||`encoding`in e||`layer`in e||`hconcat`in e||`vconcat`in e||`facet`in e||`repeat`in e?`vega-lite`:`marks`in e||`signals`in e||`scales`in e||`axes`in e?`vega`:n??`vega`}function LHe(e){return!!(e&&`load`in e)}function RHe(e){return LHe(e)?e:V5.loader(e)}function zHe(e){let t=e.usermeta?.embedOptions??{};return xg(t.defaultStyle)&&(t.defaultStyle=!1),t}async function BHe(e,t,n={}){let r,i;xg(t)?(i=RHe(n.loader),r=JSON.parse(await i.load(t))):r=t;let a=zHe(r),o=a.loader;(!i||o)&&(i=RHe(n.loader??o));let s=await VHe(a,i),c=await VHe(n,i),l={...MHe(c,s),config:kh(c.config??{},s.config??{})};return await UHe(e,r,l,i)}async function VHe(e,t){let n=xg(e.config)?JSON.parse(await t.load(e.config)):e.config??{},r=xg(e.patch)?JSON.parse(await t.load(e.patch)):e.patch;return{...e,...r?{patch:r}:{},...n?{config:n}:{}}}function HHe(e){let t=e.getRootNode?e.getRootNode():document;return t instanceof ShadowRoot?{root:t,rootContainer:t}:{root:document,rootContainer:document.head??document.body}}async function UHe(e,t,n={},r){let i=n.theme?kh(cVe[n.theme],n.config??{}):n.config,a=_g(n.actions)?n.actions:MHe({},gUe,n.actions??{}),o={..._Ue,...n.i18n},s=n.renderer??`svg`,c=n.logger??Th(V5.Warn);n.logLevel!==void 0&&c.level(n.logLevel);let l=n.downloadFileName??`visualization`,u=typeof e==`string`?document.querySelector(e):e;if(!u)throw Error(`${e} does not exist`);if(n.defaultStyle!==!1){let e=`vega-embed-style`,{root:t,rootContainer:r}=HHe(u);if(!t.getElementById(e)){let t=document.createElement(`style`);t.id=e,t.innerHTML=n.defaultStyle===void 0||n.defaultStyle===!0?hUe.toString():n.defaultStyle,r.appendChild(t)}}let d=IHe(t,c,n.mode),f=vUe[d](t,c,i);if(d===`vega-lite`&&f.$schema){let e=oVe(f.$schema);B5(G5.vega,`^${e.version.slice(1)}`)||c.warn(`The compiled spec uses Vega ${e.version}, but current version is v${G5.vega}.`)}u.classList.add(`vega-embed`),a&&u.classList.add(`has-actions`),u.innerHTML=``;let p=u;if(a){let e=document.createElement(`div`);e.classList.add(bUe),u.appendChild(e),p=e}let m=n.patch;if(m&&(f=m instanceof Function?m(f):s5(f,m,!0,!1).newDocument),n.formatLocale&&V5.formatLocale(n.formatLocale),n.timeFormatLocale&&V5.timeFormatLocale(n.timeFormatLocale),n.expressionFunctions)for(let e in n.expressionFunctions){let t=n.expressionFunctions[e];`fn`in t?V5.expressionFunction(e,t.fn,t.visitor):t instanceof Function&&V5.expressionFunction(e,t)}let{ast:h}=n,g=V5.parse(f,d===`vega-lite`?{}:i,{ast:h}),_=new(n.viewClass||V5.View)(g,{loader:r,logger:c,renderer:s,...h?{expr:V5.expressionInterpreter??n.expr??ZY}:{}});if(_.addSignalListener(`autosize`,(e,t)=>{let{type:n}=t;n==`fit-x`?(p.classList.add(`fit-x`),p.classList.remove(`fit-y`)):n==`fit-y`?(p.classList.remove(`fit-x`),p.classList.add(`fit-y`)):n==`fit`?p.classList.add(`fit-x`,`fit-y`):p.classList.remove(`fit-x`,`fit-y`)}),n.tooltip!==!1){let{loader:e,tooltip:t}=n,r=e&&!LHe(e)?e?.baseURL:void 0,i=PHe(t)?t:new oHe({baseURL:r,...t===!0?{}:t}).call;_.tooltip(i)}let{hover:v}=n;if(v===void 0&&(v=d===`vega`),v){let{hoverSet:e,updateSet:t}=typeof v==`boolean`?{}:v;_.hover(e,t)}n&&(n.width!=null&&_.width(n.width),n.height!=null&&_.height(n.height),n.padding!=null&&_.padding(n.padding)),await _.initialize(p,n.bind).runAsync();let y;if(a!==!1){let e=u;if(n.defaultStyle!==!1||n.forceActionsMenu){let t=document.createElement(`details`);t.title=o.CLICK_TO_VIEW_ACTIONS,u.append(t),e=t;let n=document.createElement(`summary`);n.innerHTML=yUe,t.append(n),y=e=>{t.contains(e.target)||t.removeAttribute(`open`)},document.addEventListener(`click`,y)}let r=document.createElement(`div`);if(e.append(r),r.classList.add(`vega-actions`),a===!0||a.export!==!1){for(let e of[`svg`,`png`])if(a===!0||a.export===!0||a.export[e]){let t=o[`${e.toUpperCase()}_ACTION`],i=document.createElement(`a`),a=Dh(n.scaleFactor)?n.scaleFactor[e]:n.scaleFactor;i.text=t,i.href=`#`,i.target=`_blank`,i.download=`${l}.${e}`,i.addEventListener(`mousedown`,async function(t){t.preventDefault();let n=await _.toImageURL(e,a);this.href=n}),r.append(i)}}if(a===!0||a.source!==!1){let e=document.createElement(`a`);e.text=o.SOURCE_ACTION,e.href=`#`,e.addEventListener(`click`,function(e){FHe(rh(t),n.sourceHeader??``,n.sourceFooter??``,d),e.preventDefault()}),r.append(e)}if(d===`vega-lite`&&(a===!0||a.compiled!==!1)){let e=document.createElement(`a`);e.text=o.COMPILED_ACTION,e.href=`#`,e.addEventListener(`click`,function(e){FHe(rh(f),n.sourceHeader??``,n.sourceFooter??``,`vega`),e.preventDefault()}),r.append(e)}if(a===!0||a.editor!==!1){let e=n.editorUrl??`https://vega.github.io/editor/`,a=document.createElement(`a`);a.text=o.EDITOR_ACTION,a.href=`#`,a.addEventListener(`click`,function(n){jHe(window,e,{config:i,mode:m?`vega`:d,renderer:s,spec:rh(m?f:t)}),n.preventDefault()}),r.append(a)}}function b(){y&&document.removeEventListener(`click`,y),_.finalize()}return{view:_,spec:t,vgSpec:f,finalize:b,embedOptions:n}}var WHe,GHe,v5,y5,KHe,b5,qHe,JHe,x5,YHe,XHe,S5,ZHe,C5,QHe,w5,T5,$He,E5,eUe,tUe,D5,nUe,O5,rUe,k5,iUe,A5,aUe,j5,oUe,M5,sUe,N5,cUe,P5,lUe,F5,uUe,I5,dUe,L5,fUe,R5,pUe,z5,mUe,B5,hUe,V5,H5,U5,gUe,_Ue,W5,G5,vUe,yUe,bUe,xUe=o((()=>{yie(),zY(),gOe(),aVe(),sVe(),GVe(),sHe(),WHe=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),GHe=Object.prototype.hasOwnProperty,v5=function(e){WHe(t,e);function t(t,n,r,i,a){var o=this.constructor,s=e.call(this,lHe(t,{name:n,index:r,operation:i,tree:a}))||this;return s.name=n,s.index=r,s.operation=i,s.tree=a,Object.setPrototypeOf(s,o.prototype),s.message=lHe(t,{name:n,index:r,operation:i,tree:a}),s}return t}(Error),y5=v5,KHe=t5,b5={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=a5(n,this.path);r&&=t5(r);var i=o5(n,{op:`remove`,path:this.from}).removed;return o5(n,{op:`add`,path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=a5(n,this.from);return o5(n,{op:`add`,path:this.path,value:t5(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:l5(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},qHe={add:function(e,t,n){return n5(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){return{newDocument:n,removed:e.splice(t,1)[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:b5.move,copy:b5.copy,test:b5.test,_get:b5._get},JHe=Object.freeze({__proto__:null,JsonPatchError:y5,_areEquals:l5,applyOperation:o5,applyPatch:s5,applyReducer:uHe,deepClone:KHe,getValueByPointer:a5,validate:dHe,validator:c5}),x5=new WeakMap,YHe=function(){function e(e){this.observers=new Map,this.obj=e}return e}(),XHe=function(){function e(e,t){this.callback=e,this.observer=t}return e}(),Object.assign({},JHe,Object.freeze({__proto__:null,compare:_He,generate:u5,observe:gHe,unobserve:hHe}),{JsonPatchError:v5,deepClone:t5,escapePathComponent:r5,unescapePathComponent:cHe}),w5={exports:{}},B5=vHe(AHe()),hUe=`.vega-embed { position: relative; display: inline-block; box-sizing: border-box; @@ -374,14 +374,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`

An error transform: scale(1); } } -`,{version:`7.1.0`}.version,t7=XDe,n7=jOe,r7=typeof window<`u`?window:void 0,n7===void 0&&r7?.vl?.compile&&(n7=r7.vl),zHe={export:{svg:!0,png:!0},source:!0,compiled:!0,editor:!0},BHe={CLICK_TO_VIEW_ACTIONS:`Click to view actions`,COMPILED_ACTION:`View Compiled Vega`,EDITOR_ACTION:`Open in Vega Editor`,PNG_ACTION:`Save as PNG`,SOURCE_ACTION:`View Source`,SVG_ACTION:`Save as SVG`},i7={vega:`Vega`,"vega-lite":`Vega-Lite`},a7={vega:t7.version,"vega-lite":n7?n7.version:`not available`},VHe={vega:e=>e,"vega-lite":(e,t,n)=>n7.compile(e,{config:n,logger:t}).spec},HHe=` +`,{version:`7.1.0`}.version,V5=mOe,H5=JOe,U5=typeof window<`u`?window:void 0,H5===void 0&&U5?.vl?.compile&&(H5=U5.vl),gUe={export:{svg:!0,png:!0},source:!0,compiled:!0,editor:!0},_Ue={CLICK_TO_VIEW_ACTIONS:`Click to view actions`,COMPILED_ACTION:`View Compiled Vega`,EDITOR_ACTION:`Open in Vega Editor`,PNG_ACTION:`Save as PNG`,SOURCE_ACTION:`View Source`,SVG_ACTION:`Save as SVG`},W5={vega:`Vega`,"vega-lite":`Vega-Lite`},G5={vega:V5.version,"vega-lite":H5?H5.version:`not available`},vUe={vega:e=>e,"vega-lite":(e,t,n)=>H5.compile(e,{config:n,logger:t}).spec},yUe=` -`,UHe=`chart-wrapper`})),GHe=c({default:()=>KHe});function KHe({spec:e,label:t}){let n=(0,o7.useRef)(null),r=(0,o7.useRef)(null),[i,a]=(0,o7.useState)(``);return(0,o7.useEffect)(()=>{let t=!1;a(``),r.current?.finalize(),r.current=null;let i=n.current;if(i)return i.replaceChildren(),lHe(i,e,{mode:`vega-lite`,actions:!1,renderer:`svg`,tooltip:!0,hover:!0}).then(e=>{t?e.finalize():r.current=e}).catch(()=>{t||a(`This chart could not be rendered.`)}),()=>{t=!0,r.current?.finalize(),r.current=null,i.replaceChildren()}},[e]),(0,s7.jsxs)(`div`,{className:`cg-vega-frame`,role:`img`,"aria-label":t,children:[(0,s7.jsx)(`div`,{ref:n,className:`cg-vega-host`}),i&&(0,s7.jsx)(`div`,{className:`cg-ch-empty`,children:i})]})}var o7,s7,qHe=o((()=>{o7=u(f(),1),WHe(),s7=Op()}));qHe();var JHe={week:`Weekly`,month:`Monthly`,quarter:`Quarterly`,year:`Yearly`},YHe=[6,12,24,36],c7=72,l7=18;function XHe(){let e={stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`};return(0,B.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,"aria-hidden":!0,children:[(0,B.jsx)(`path`,{d:`M2.5 11.5h4v-4h4v-3h3`,...e}),(0,B.jsx)(`path`,{d:`M2.5 13.5h11`,...e,opacity:`0.45`})]})}function ZHe(e){let t={server:[],snapshot:[],refused:[]};for(let n of e){let e=Im(n);e===`server`?t.server.push(n):e===`snapshot`?t.snapshot.push(n):t.refused.push({field:n,why:qre(n)})}return t}function QHe(e){let t=e.length+1,n=new Set(e.map(e=>e.id));for(;n.has(`tsr_${t}`);)t+=1;return`tsr_${t}`}function $He({scope:e,pids:t,fields:n,rows:r,display:i,onDisplay:a,locked:o,onSheet:s}){let c=(0,L.useMemo)(()=>ZHe(n),[n]),l=(0,L.useMemo)(()=>[...c.server,...c.snapshot],[c.server,c.snapshot]),u=(0,L.useMemo)(()=>new Set(c.snapshot.map(e=>e.key)),[c.snapshot]),d=id.includes(i?.tsBucket??``)?i.tsBucket:Om,f=typeof i?.tsSpan?.lastN==`number`?i.tsSpan.lastN:12,p=(0,L.useMemo)(()=>{let e=(i?.tsFields??[]).filter(e=>l.some(t=>t.key===e));return e.length?e:l.slice(0,1).map(e=>e.key)},[i?.tsFields,l]),m=(0,L.useMemo)(()=>p.filter(e=>!u.has(e)),[p,u]),h=(0,L.useMemo)(()=>p.filter(e=>u.has(e)),[p,u]),g=(0,L.useMemo)(()=>i?.tsRows??[],[i?.tsRows]),_=(0,L.useMemo)(()=>i?.tsDeltas??[],[i?.tsDeltas]),v=i?.tsStyles,y=i?.tsGridlines!==!1,b=i?.tsSparkline===!0,[x,S]=(0,L.useState)(null),[C,w]=(0,L.useState)(`idle`),[T,E]=(0,L.useState)(0),[D,O]=(0,L.useState)(new Set),k=(0,L.useRef)(0),A=Gd();(0,L.useEffect)(()=>{if(A)return;if(!m.length||!t.length){S(null),w(`idle`);return}let n=++k.current;w(`loading`),nf(km({pids:t,bucket:d,span:{lastN:f},fields:m}),e).then(({payload:e,status:t})=>{if(n===k.current){if(!e){S(null),E(t),w(`error`);return}S(e),w(`idle`)}})},[A,e,t,d,f,m]);let j=(0,L.useMemo)(()=>Fm(x),[x]),M=(0,L.useMemo)(()=>{if(!h.length||!j.columns.length)return j;let e=new Map(n.map(e=>[e.key,e])),t=h.map(t=>e.get(t)).filter(e=>!!e).map(e=>Jre(e,r??[],j.columns,x?.meta?.today));return{...j,rows:[...j.rows,...t],empty:!1}},[j,h,n,r,x?.meta?.today]),ee=(0,L.useMemo)(()=>iie(M,{customRows:g,deltas:_,bucket:d,today:x?.meta?.today}),[M,g,_,d,x?.meta?.today]);(0,L.useEffect)(()=>{s?.(ee)},[ee,s]);let N=(0,L.useCallback)(e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),te=e=>{e.length&&a?.({tsFields:e.slice(0,12)})},ne=e=>a?.({tsRows:e.length?e.slice(0,12):void 0}),P=e=>{let t=_.includes(e)?_.filter(t=>t!==e):[..._,e];a?.({tsDeltas:t.length?t:void 0})},re=(e,t)=>{let n={...v??{}},r={...Bm(v,e),...t},i={};r.bold&&(i.bold=!0),r.line&&(i.line=!0),i.bold||i.line?n[e]=i:delete n[e],a?.({tsStyles:Object.keys(n).length?n:void 0})};if(A)return(0,B.jsx)(`div`,{className:`cg-mode-empty`,children:`The time-series view runs in the web app. Open Loopable in a browser tab to see it.`});if(!l.length)return(0,B.jsx)(`div`,{className:`cg-mode-empty`,children:`This table has no number fields to plot. A time series needs either a metric with a period, or a numeric column to snapshot — add one from a column menu, then pick it here.`});let F=l.filter(e=>!p.includes(e.key)),ie=ee.columns.length+2+ +!!b,ae=h.length>0&&ee.columns.length===0&&C!==`loading`;return(0,B.jsxs)(`div`,{className:`cg-ts`,children:[(0,B.jsxs)(`div`,{className:`cg-ts-bar`,children:[(0,B.jsxs)(`label`,{className:`cg-ts-ctl`,children:[(0,B.jsx)(`span`,{className:`cg-ts-ctl-k`,children:`Period`}),(0,B.jsx)(`select`,{className:`cg-select`,value:d,onChange:e=>a?.({tsBucket:e.target.value}),disabled:!a,children:id.map(e=>(0,B.jsx)(`option`,{value:e,children:JHe[e]},e))})]}),(0,B.jsxs)(`label`,{className:`cg-ts-ctl`,children:[(0,B.jsx)(`span`,{className:`cg-ts-ctl-k`,children:`Span`}),(0,B.jsx)(`select`,{className:`cg-select`,value:String(f),onChange:e=>a?.({tsSpan:{lastN:Number(e.target.value)}}),disabled:!a,children:YHe.map(e=>(0,B.jsxs)(`option`,{value:e,children:[`Last `,e]},e))})]}),(0,B.jsx)(mm,{label:_.length?`Compare · ${_.length}`:`Compare`,icon:(0,B.jsx)(XHe,{}),active:_.length>0,children:()=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Compare each period with`}),(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`Each choice adds a sub-row under every metric. A comparison that cannot be answered for a metric says so in the footnotes rather than printing a number.`}),ad.map(e=>(0,B.jsxs)(`label`,{className:`cg-check-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:_.includes(e),disabled:!a,onChange:()=>P(e)}),(0,B.jsx)(`span`,{className:`cg-check-label`,children:Rm[e]})]},e))]})}),(0,B.jsxs)(`span`,{className:`cg-ts-group`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-tog`+(y?` is-on`:``),"aria-pressed":y,disabled:!a,onClick:()=>a?.({tsGridlines:!y&&void 0}),children:`Gridlines`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-tog`+(b?` is-on`:``),"aria-pressed":b,disabled:!a,onClick:()=>a?.({tsSparkline:!b||void 0}),children:`Trend`})]}),(0,B.jsx)(`span`,{className:`cg-ts-pool`,children:o?`This record`:`${ee.pool.toLocaleString()} ${ee.pool===1?`customer`:`customers`}`})]}),C===`error`&&(0,B.jsx)(`div`,{className:`cg-ts-note cg-ts-error`,children:T===400?`That span is too wide to bucket. Choose a shorter span or a larger period.`:T===403?`None of these records are in your book.`:`The time series could not be loaded. Nothing is shown rather than a guess.`}),ae&&(0,B.jsxs)(`div`,{className:`cg-ts-note`,children:[h.length===1?`That column has`:`Those columns have`,` no period of its own, so `,h.length===1?`it is`:`they are`,` shown as a snapshot across the periods on the sheet — and this sheet has no periods yet. Add one metric with a period and `,h.length===1?`it`:`they`,` will appear beside it.`]}),c.refused.length>0&&(0,B.jsxs)(`details`,{className:`cg-ts-refused`,children:[(0,B.jsx)(`summary`,{className:`cg-ts-refsum`,children:c.refused.length===1?`1 column has no period of its own`:`${c.refused.length} columns have no period of their own`}),(0,B.jsx)(`div`,{className:`cg-ts-reflist`,children:c.refused.map(({field:e,why:t})=>(0,B.jsx)(`span`,{className:`cg-ts-refchip`,title:t,children:e.label},e.key))})]}),C===`loading`&&!x&&(0,B.jsx)(`div`,{className:`cg-ts-note`,children:(0,B.jsx)(`span`,{className:`lp-spin`,role:`status`,"aria-label":`Loading`})}),x&&(0,B.jsx)(`div`,{className:`cg-ts-scroll`,children:(0,B.jsxs)(`table`,{className:`cg-ts-table`+(y?``:` is-nogrid`),children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{className:`cg-ts-stick`,children:`Metric`}),ee.columns.map(e=>(0,B.jsxs)(`th`,{className:e.partial?`is-partial`:void 0,children:[e.label,e.partial&&(0,B.jsx)(`span`,{className:`cg-ts-partial`,children:` · partial`})]},e.key)),(0,B.jsx)(`th`,{className:`cg-ts-total`,children:`Total`}),b&&(0,B.jsx)(`th`,{className:`cg-ts-sparkhead`,children:`Trend`})]})}),(0,B.jsxs)(`tbody`,{children:[ee.rows.map(e=>(0,B.jsx)(tUe,{row:e,sheet:ee,style:Bm(v,e.id),styles:v,sparkline:b,charted:D.has(e.id),editable:!!a,metricRow:M.rows.find(t=>t.field===e.id),onToggleChart:()=>N(e.id),onStyle:t=>re(e.id,t),onRemove:()=>{e.kind===`metric`?te(p.filter(t=>t!==e.id)):ne(g.filter(t=>t.id!==e.id))},onEditRow:t=>ne(g.map(n=>n.id===e.id?{...n,...t}:n))},e.id)),a&&(0,B.jsx)(`tr`,{className:`cg-ts-addrow`,children:(0,B.jsx)(`th`,{className:`cg-ts-stick`,colSpan:ie,children:(0,B.jsxs)(`span`,{className:`cg-ts-addbar`,children:[(0,B.jsx)(Kp,{fields:F,value:void 0,onChange:e=>te([...p,e]),className:`cg-select cg-ts-addsel`,ariaLabel:`Add a metric row`,disabled:!F.length||p.length>=12,placeholder:F.length?p.length>=12?`At the 12-metric limit`:`+ Add metric`:`Every metric is on the sheet`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-tog`,disabled:g.length>=12,onClick:()=>ne([...g,{id:QHe(g),kind:`note`,label:``}]),children:`+ Note`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-tog`,disabled:g.length>=12,onClick:()=>ne([...g,{id:QHe(g),kind:`formula`,label:``,expr:``}]),children:`+ Formula`})]})})})]})]})}),x&&ee.empty&&(0,B.jsx)(`div`,{className:`cg-ts-note`,children:`No metrics returned a series for this span.`}),ee.notes.length>0&&(0,B.jsx)(`ul`,{className:`cg-ts-notes`,children:ee.notes.map(e=>(0,B.jsx)(`li`,{children:e},e))})]})}function eUe({style:e,editable:t,onStyle:n,onRemove:r,label:i}){return t?(0,B.jsxs)(`span`,{className:`cg-ts-rowtools`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-rowtool`+(e.bold?` is-on`:``),"aria-pressed":!!e.bold,"aria-label":`Bold ${i}`,title:`Bold`,onClick:()=>n({bold:!e.bold||void 0}),children:`B`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-rowtool`+(e.line?` is-on`:``),"aria-pressed":!!e.line,"aria-label":`Rule above ${i}`,title:`Rule above`,onClick:()=>n({line:!e.line||void 0}),children:`―`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-rowtool`,"aria-label":`Remove ${i}`,title:`Remove row`,onClick:r,children:`×`})]}):null}function tUe({row:e,sheet:t,style:n,styles:r,sparkline:i,charted:a,editable:o,metricRow:s,onToggleChart:c,onStyle:l,onRemove:u,onEditRow:d}){let f=(0,L.useMemo)(()=>{if(!a||!s)return null;let n=Hm(s,t.columns);return n.points.length?Gm({spec:{id:e.id,kind:`line`,agg:e.agg??`sum`},model:n,yTitle:e.label,formatValue:e=>e.toLocaleString(void 0,{maximumFractionDigits:2})}):null},[a,s,t.columns,e.id,e.agg,e.label]),p=t.columns.length+2+ +!!i,m=(n.line?`is-ruled`:``)+(n.bold?` is-bold`:``)||void 0;return e.kind===`note`?(0,B.jsx)(`tr`,{className:`cg-ts-noterow `+(m??``),children:(0,B.jsx)(`th`,{className:`cg-ts-stick`,colSpan:p,children:(0,B.jsxs)(`span`,{className:`cg-ts-rowhead`,children:[o?(0,B.jsx)(`input`,{className:`cg-ts-rowinput`,value:e.label,maxLength:120,placeholder:`Note — type a heading for this section`,"aria-label":`Note row label`,onChange:e=>d({label:e.target.value})}):(0,B.jsx)(`span`,{className:`cg-ts-rowlabel`,children:e.label}),(0,B.jsx)(eUe,{style:n,editable:o,onStyle:l,onRemove:u,label:e.label||`note row`})]})})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`tr`,{className:m,children:[(0,B.jsx)(`th`,{scope:`row`,className:`cg-ts-stick`,children:(0,B.jsxs)(`span`,{className:`cg-ts-rowhead`,children:[(0,B.jsxs)(`span`,{className:`cg-ts-rowmain`,children:[e.kind===`formula`?o?(0,B.jsx)(`input`,{className:`cg-ts-rowinput`,value:e.label,maxLength:120,placeholder:`Formula row name`,"aria-label":`Formula row label`,onChange:e=>d({label:e.target.value})}):(0,B.jsx)(`span`,{className:`cg-ts-rowlabel`,children:e.label}):(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-rowbtn`,onClick:c,"aria-pressed":a,title:a?`Show as a row of numbers`:`Show as a line`,children:e.label}),e.sublabel&&(0,B.jsx)(`span`,{className:`cg-ts-rowsub`,children:e.sublabel}),e.kind===`formula`&&(o?(0,B.jsx)(`input`,{className:`cg-ts-rowinput cg-ts-rowexpr`,value:e.expr??``,maxLength:200,spellCheck:!1,placeholder:`= [Sales] - [Returns]`,"aria-label":`Formula`,onChange:e=>d({expr:e.target.value})}):(0,B.jsx)(`span`,{className:`cg-ts-rowsub`,children:e.expr}))]}),(0,B.jsx)(eUe,{style:n,editable:o,onStyle:l,onRemove:u,label:e.label||`row`})]})}),e.cells.map((n,i)=>{let a=t.columns[i],o=Bm(r,e.id,a?.key);return(0,B.jsx)(`td`,{className:(n.partial?`is-partial`:``)+(o.bold?` is-bold`:``)||void 0,children:Hre(n.value,jm)},a?.key??i)}),(0,B.jsx)(`td`,{className:`cg-ts-total`,children:e.total==null?``:jm(e.total)}),i&&(0,B.jsx)(`td`,{className:`cg-ts-spark`,children:(0,B.jsx)(rUe,{values:e.cells.map(e=>e.value),label:e.label})})]}),e.deltas.map(e=>(0,B.jsx)(nUe,{delta:e,sparkline:i},e.kind)),a&&(0,B.jsx)(`tr`,{className:`cg-ts-chartrow`,children:(0,B.jsx)(`td`,{colSpan:p,children:f?(0,B.jsx)(KHe,{spec:f,label:`${e.label} over time`}):(0,B.jsx)(`div`,{className:`cg-ts-note`,children:`Nothing to plot — every period for this metric is unanswered.`})})})]})}function nUe({delta:e,sparkline:t}){return(0,B.jsxs)(`tr`,{className:`cg-ts-delta`,children:[(0,B.jsx)(`th`,{scope:`row`,className:`cg-ts-stick`,children:e.label}),e.values.map((t,n)=>(0,B.jsx)(`td`,{className:t==null?void 0:t>=0?`is-up`:`is-down`,children:e.percent?Pm(t):t==null?`—`:`${t>0?`+`:``}${jm(t)}`},n)),(0,B.jsx)(`td`,{className:`cg-ts-total`}),t&&(0,B.jsx)(`td`,{className:`cg-ts-spark`})]})}function rUe({values:e,label:t}){let n=(0,L.useMemo)(()=>nie(e,c7,l7),[e]);if(!n.length)return(0,B.jsx)(`span`,{className:`cg-ts-sparkempty`,children:`—`});let r=e.filter(e=>e!=null).length;return(0,B.jsx)(`svg`,{className:`cg-ts-sparksvg`,width:c7,height:l7,viewBox:`0 0 ${c7} ${l7}`,role:`img`,"aria-label":`${t}: trend over ${r} of ${e.length} periods`,children:n.map((e,t)=>(0,B.jsx)(`polyline`,{points:rie(e),fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinejoin:`round`,strokeLinecap:`round`},t))})}function u7(e){return!Number.isFinite(e)||e<0?`—`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function iUe(e){let t=[];return e.by&&t.push(e.by),e.ts&&t.push(e.ts.slice(0,16).replace(`T`,` `)),t.join(` · `)}function aUe({pid:e,docs:t,docPayload:n,onAdd:r,onFetch:i,onDelete:a}){let o=(0,L.useRef)(null),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(!1),d=(0,L.useRef)(null),[f,p]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(!(!n||d.current==null)&&!(n.pid!==e||n.docId!==d.current)){d.current=null;try{let e=atob(n.data_b64),t=new Uint8Array(e.length);for(let n=0;nURL.revokeObjectURL(r),0)}catch{c(`That file could not be decoded. Nothing was downloaded.`)}}},[n,e]);let m=e=>{if(c(null),!e)return;if(e.size>5242880){c(`${e.name} is ${u7(e.size)}. The limit is ${u7(Nd)}, so it was not uploaded.`),o.current&&(o.current.value=``);return}u(!0);let t=new FileReader;t.onerror=()=>{u(!1),c(`${e.name} could not be read.`)},t.onload=()=>{u(!1);let n=String(t.result??``),i=n.indexOf(`,`);if(i<0){c(`${e.name} could not be encoded.`);return}r({name:e.name,mime:e.type||`application/octet-stream`,size:e.size,data_b64:n.slice(i+1)}),o.current&&(o.current.value=``)},t.readAsDataURL(e)};return(0,B.jsxs)(`section`,{className:`cg-detail-section cg-docs`,children:[(0,B.jsx)(`div`,{className:`cg-detail-section-title`,children:`Documents`}),t.length===0?(0,B.jsx)(`div`,{className:`cg-docs-empty`,children:`No documents on this customer yet.`}):(0,B.jsx)(`ul`,{className:`cg-docs-list`,children:t.map(e=>(0,B.jsxs)(`li`,{className:`cg-docs-row`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn cg-docs-name`,title:`Download ${e.name}`,onClick:()=>{c(null),d.current=e.id,i(e.id)},children:e.name}),(0,B.jsxs)(`span`,{className:`cg-docs-meta`,children:[u7(e.size),iUe(e)?` · ${iUe(e)}`:``]}),e.canDelete!==!1&&(0,B.jsx)(`button`,{type:`button`,className:`cg-docs-del`+(f===e.id?` is-armed`:``),"aria-label":f===e.id?`Delete ${e.name}?`:`Delete ${e.name}`,onClick:()=>{if(f!==e.id){p(e.id);return}p(null),a(e.id)},children:f===e.id?`Delete?`:`×`})]},e.id))}),(0,B.jsxs)(`div`,{className:`cg-docs-add`,children:[(0,B.jsx)(`input`,{ref:o,type:`file`,className:`cg-docs-file`,"aria-label":`Add a document`,disabled:l,onChange:e=>m(e.target.files?.[0])}),(0,B.jsxs)(`span`,{className:`cg-docs-cap`,children:[`Up to `,u7(Nd),` per file.`]})]}),s&&(0,B.jsx)(`div`,{className:`cg-docs-error`,children:s})]})}var oUe=`application/x-cg-field`;function sUe(e,t){let n=new Set(t),r=new Set,i=[];for(let t of e??[])!n.has(t)||r.has(t)||(r.add(t),i.push(t));for(let e of t)r.has(e)||(r.add(e),i.push(e));return i}function cUe(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0||r===i)return e;let a=[...e];return a.splice(r,1),a.splice(i,0,t),a}function lUe(e,t,n){let r=e.indexOf(t),i=r+n;if(r<0||i<0||i>=e.length)return e;let a=[...e];return a.splice(r,1),a.splice(i,0,t),a}var uUe=class extends Error{status;constructor(e,t){super(e),this.name=`RecordCommentsError`,this.status=t}};async function d7(e){let t=null;try{t=await e.json()}catch{}if(e.status===401&&Hd(Id),!e.ok)throw new uUe(t?.error?.message||`The server answered ${e.status}.`,e.status);return t}async function dUe(e,t){let n=await d7(await fetch(`${Pd}/customers/${e}/comments`,{credentials:Fd,signal:t}));return Array.isArray(n.comments)?n.comments:[]}async function fUe(e,t){return(await d7(await fetch(`${Pd}/customers/${e}/comments`,{method:`POST`,credentials:Fd,headers:{"Content-Type":`application/json`},body:JSON.stringify({body:t})}))).comment}async function pUe(e,t){await d7(await fetch(`${Pd}/customers/${e}/comments/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:Fd}))}function mUe(e){return{pid:e,comments:[],draft:``,loading:!0,posting:!1,error:``}}function hUe(e,t){if(t.type===`record`)return mUe(t.pid);if(t.pid!==e.pid)return e;switch(t.type){case`loaded`:return{...e,comments:t.comments,loading:!1,error:``};case`load-failed`:return{...e,loading:!1,error:t.error};case`draft`:return{...e,draft:t.draft};case`posting`:return{...e,posting:!0,error:``};case`posted`:return{...e,comments:[...e.comments,t.comment],draft:``,posting:!1};case`post-failed`:return{...e,posting:!1,error:t.error};case`deleted`:return{...e,comments:e.comments.filter(e=>e.id!==t.commentId)};case`delete-failed`:return{...e,error:t.error}}}function gUe(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`?`}function _Ue(e){let t=new Date(e);return Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t):e}function vUe({pid:e,viewer:t}){let[n,r]=(0,L.useReducer)(hUe,e,mUe),{comments:i,draft:a,loading:o,posting:s,error:c}=n,l=(0,L.useRef)(null);(0,L.useEffect)(()=>{let t=new AbortController;return r({type:`record`,pid:e}),dUe(e,t.signal).then(t=>r({type:`loaded`,pid:e,comments:t})).catch(t=>{t instanceof DOMException&&t.name===`AbortError`||r({type:`load-failed`,pid:e,error:t instanceof Error?t.message:`Comments could not be loaded.`})}),()=>t.abort()},[e]);let u=async t=>{t.preventDefault();let n=a.trim();if(!n||s)return;let i=e;r({type:`posting`,pid:i});try{let t=await fUe(i,n);r({type:`posted`,pid:i,comment:t}),i===e&&l.current?.focus()}catch(e){r({type:`post-failed`,pid:i,error:e instanceof Error?e.message:`That comment was not saved.`})}},d=async t=>{let n=e;try{await pUe(n,t.id),r({type:`deleted`,pid:n,commentId:t.id})}catch(e){r({type:`delete-failed`,pid:n,error:e instanceof Error?e.message:`That comment was not deleted.`})}};return(0,B.jsxs)(`aside`,{className:`cg-record-comments`,"aria-label":`Record comments`,children:[(0,B.jsxs)(`div`,{className:`cg-record-comments-head`,children:[(0,B.jsx)(`h2`,{children:`Comments`}),(0,B.jsx)(`span`,{children:i.length.toLocaleString()})]}),(0,B.jsxs)(`div`,{className:`cg-record-comment-feed`,"aria-live":`polite`,children:[o&&(0,B.jsx)(`div`,{className:`cg-record-comment-state`,children:(0,B.jsx)(`span`,{className:`lp-spin`,role:`status`,"aria-label":`Loading`})}),!o&&i.length===0&&!c&&(0,B.jsx)(`div`,{className:`cg-record-comment-state`,children:`No comments yet. Add context for the team here.`}),i.map(e=>{let n=t?.isAdmin===!0||t?.name?.trim().toLowerCase()===e.authorKey.toLowerCase();return(0,B.jsxs)(`article`,{className:`cg-record-comment`,children:[(0,B.jsx)(`div`,{className:`cg-record-comment-avatar`,"aria-hidden":!0,children:gUe(e.author)}),(0,B.jsxs)(`div`,{className:`cg-record-comment-content`,children:[(0,B.jsxs)(`div`,{className:`cg-record-comment-meta`,children:[(0,B.jsx)(`strong`,{children:e.author}),(0,B.jsx)(`time`,{dateTime:e.createdAt,children:_Ue(e.createdAt)}),n&&(0,B.jsx)(`button`,{type:`button`,className:`cg-record-comment-delete`,"aria-label":`Delete comment by ${e.author}`,title:`Delete comment`,onClick:()=>void d(e),children:`×`})]}),(0,B.jsx)(`p`,{children:e.body})]})]},e.id)}),c&&(0,B.jsx)(`div`,{className:`cg-record-comment-error`,children:c})]}),(0,B.jsxs)(`form`,{className:`cg-record-comment-compose`,onSubmit:e=>void u(e),children:[(0,B.jsx)(`label`,{htmlFor:`cg-comment-${e}`,children:`Add a comment`}),(0,B.jsx)(`textarea`,{ref:l,id:`cg-comment-${e}`,value:a,maxLength:4e3,placeholder:`Share an update or leave context…`,onChange:t=>r({type:`draft`,pid:e,draft:t.target.value}),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,B.jsxs)(`div`,{className:`cg-record-comment-compose-foot`,children:[(0,B.jsx)(`span`,{children:`Ctrl/⌘ + Enter to post`}),(0,B.jsx)(`button`,{type:`submit`,disabled:s||!a.trim(),children:s?`Posting…`:`Comment`})]})]})]})}function yUe(e,t){let n=t.trim();if(!n)return null;if(e.type===`url`)return/^https?:\/\//i.test(n)?n:/^[\w-]+(\.[\w-]+)+/.test(n)?`https://${n}`:null;if(e.type===`email`)return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?`mailto:${n}`:null;if(e.type===`phone`){let e=n.replace(/[\s().-]/g,``);return/^\+?\d{5,}$/.test(e)?`tel:${e}`:null}return null}function bUe({value:e,...t}){let n=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{e.style.height=`auto`;let t=window.getComputedStyle(e),n=t.boxSizing===`border-box`?(parseFloat(t.borderTopWidth)||0)+(parseFloat(t.borderBottomWidth)||0):0;e.style.height=`${e.scrollHeight+n}px`};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),(0,B.jsx)(`textarea`,{ref:n,value:e,...t})}function xUe({name:e,avatars:t}){let n=t?.[e];if(n&&n.startsWith(`data:image/`))return(0,B.jsx)(`img`,{className:`cg-detail-avatar`,src:n,alt:``,"aria-hidden":!0});let r=sp(e);return(0,B.jsx)(`span`,{className:`cg-detail-avatar cg-detail-avatar--initials`,style:{background:r.bg,color:r.fg},"aria-hidden":!0,children:zre(e)})}function SUe(){return(0,B.jsx)(`svg`,{width:`10`,height:`14`,viewBox:`0 0 10 14`,"aria-hidden":!0,focusable:`false`,children:[3,7,11].map(e=>[3,7].map(t=>(0,B.jsx)(`circle`,{cx:t,cy:e,r:`1.15`,fill:`currentColor`},`${t}-${e}`)))})}function CUe({fields:e,record:t,titleKey:n,positionLabel:r,canPrev:i,canNext:a,onPrev:o,onNext:s,onClose:c,onNotesChange:l,onNotesCommit:u,viewer:d,docs:f,docPayload:p,onDocAdd:m,onDocFetch:h,onDocDelete:g,recordLayout:_,onRecordLayout:v,scope:y,userOptions:b,userAvatars:x}){let S=(0,L.useRef)(null),C=(0,L.useId)(),w=(0,L.useId)(),T=String(t[n]??`Untitled`),E=!Gd(),D=e.filter(e=>e.source===`overlay`),O=D.filter(e=>!ed(e.type)&&e.type!==`checkbox`&&e.type!==`rating`),k=D.filter(e=>e.type===`checkbox`),A=D.filter(e=>e.type===`rating`),j=D.filter(e=>ed(e.type)),M=e.filter(e=>e.source!==`overlay`&&e.key!==n),ee=new Map(e.map(e=>[e.key,e])),N=[...O,...k,...A,...j,...M].map(e=>e.key),[te,ne]=(0,L.useState)(null);(0,L.useEffect)(()=>{ne(e=>e&&JSON.stringify(e)===JSON.stringify(_??[])?null:e)},[_]);let P=sUe(te??_,N),re=(0,L.useRef)(null),[F,ie]=(0,L.useState)(null),[ae,oe]=(0,L.useState)(null),se=(0,L.useRef)(new Map),ce=(0,L.useRef)(null);(0,L.useLayoutEffect)(()=>{let e=ce.current;e&&(ce.current=null,se.current.get(e)?.focus())});let[le,ue]=(0,L.useState)(null),de=le&&P.includes(le)?le:P[0],fe=e=>{e!==P&&(ne(e),v?.(e))},[pe,me]=(0,L.useState)(`fields`),he=y!=null,ge=he?pe:`fields`,[_e,ve]=(0,L.useState)({mode:`timeseries`}),ye=(0,L.useMemo)(()=>[Number(t.pid)],[t.pid]),be=(0,L.useMemo)(()=>[t],[t]),xe=(e,t)=>(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-grip`,ref:t=>{se.current.set(e.key,t)},draggable:!0,tabIndex:e.key===de?0:-1,onFocus:()=>ue(e.key),"aria-label":`Reorder ${e.label}, position ${t+1} of ${P.length}`,title:`Drag to reorder — or press the arrow keys`,onDragStart:t=>{re.current=e.key,ie(e.key),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(oUe,e.key);let n=t.currentTarget.parentElement;n&&t.dataTransfer.setDragImage(n,14,n.clientHeight/2)},onDragEnd:()=>{re.current=null,ie(null),oe(null)},onKeyDown:t=>{if(t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=lUe(P,e.key,t.key===`ArrowUp`?-1:1);n!==P&&(ce.current=e.key,fe(n))},children:(0,B.jsx)(SUe,{})}),Se=(e,n)=>{let r=`cg-ov-${e.key}`,i=See(e,d),a=e.type===`user`&&!b?.length,o=i&&!a,s=o&&!ed(e.type)&&e.type!==`checkbox`&&e.type!==`rating`&&e.type!==`date`&&e.type!==`int`&&e.type!==`currency`&&e.type!==`pct`,c=o&&!s,f=`cg-detail-field`+(s?` cg-detail-field--edit`:``)+(c?` cg-detail-field--control`:``)+(ae===e.key?` is-dropzone`:``)+(F===e.key?` is-dragging`:``),p;if(s){let n=String(t[e.key]??``),i=yUe(e,n);p=(0,B.jsxs)(`div`,{className:`cg-detail-editwrap`,children:[(0,B.jsx)(bUe,{id:r,className:`cg-detail-textarea`,value:n,placeholder:`Add ${e.label.toLowerCase()}…`,onChange:t=>l(e.key,t.target.value),onBlur:t=>u(e.key,t.target.value)}),i&&(0,B.jsx)(`a`,{className:`cg-detail-action`,href:i,target:e.type===`url`?`_blank`:void 0,rel:e.type===`url`?`noopener noreferrer`:void 0,children:e.type===`url`?`Open link`:e.type===`email`?`Send email`:`Call`})]})}else if(e.source===`overlay`&&e.type===`checkbox`)p=(0,B.jsx)(`input`,{id:r,type:`checkbox`,className:`cg-detail-checkbox`,checked:gp(t[e.key]),disabled:!o,onChange:t=>u(e.key,t.target.checked?`1`:``)});else if(c&&e.type===`rating`){let n=rd(e),i=Dm(e,t[e.key]);p=(0,B.jsx)(`span`,{className:`cg-detail-value cg-detail-value--live`,role:`group`,"aria-labelledby":`${r}-lbl`,children:(0,B.jsx)(`span`,{className:`cg-detail-stars`,children:Array.from({length:n},(e,t)=>t+1).map(n=>(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-star`,"aria-pressed":n<=i,"aria-label":n===i?`Clear ${e.label}`:`${n} star${n===1?``:`s`}`,title:n===i?`Click again to clear`:void 0,onClick:()=>u(e.key,Rre(e,t[e.key],n)),children:(0,B.jsx)(xm,{on:n<=i})},n))})})}else if(c&&(e.type===`select`||e.type===`user`)){let n=Sm(t[e.key]),i=Tm(e,b,n);p=(0,B.jsxs)(`span`,{className:`cg-detail-value cg-detail-value--live cg-detail-pickslot`,children:[e.type===`user`&&n!==``&&(0,B.jsx)(xUe,{name:n,avatars:x}),(0,B.jsxs)(`select`,{id:r,className:`cg-detail-select`,value:n,onChange:t=>u(e.key,t.target.value),children:[(0,B.jsx)(`option`,{value:``,children:e.type===`user`?`Unassigned`:`None`}),i.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]})}else if(c&&e.type===`multiselect`){let n=t[e.key],i=wm(n),a=Tm(e,b,n);p=(0,B.jsx)(`span`,{className:`cg-detail-value cg-detail-value--live`,role:`group`,"aria-labelledby":`${r}-lbl`,children:a.length===0?(0,B.jsx)(`span`,{className:`cg-detail-nochoice`,children:`No choices yet. Add them from the column menu.`}):(0,B.jsx)(`span`,{className:`cg-detail-chips`,children:a.map(t=>{let r=i.includes(t.value);return(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-chip`+(r?` is-on`:``),"aria-pressed":r,title:t.stale?`No longer a choice on this field`:void 0,onClick:()=>u(e.key,Ire(n,t.value)),children:t.label},t.value)})})})}else if(c&&e.type===`date`){let n=t[e.key],i=Mre(n);p=i===null?(0,B.jsxs)(`span`,{className:`cg-detail-value cg-detail-value--live cg-detail-pickslot`,children:[(0,B.jsx)(`input`,{id:r,type:`text`,className:`cg-detail-input`,value:Sm(n),title:`This value is not a date the picker can read — it is shown as stored.`,onChange:t=>l(e.key,t.target.value),onBlur:t=>u(e.key,t.target.value)}),(0,B.jsx)(`span`,{className:`cg-detail-hint`,children:`not a recognised date`})]}):(0,B.jsx)(`span`,{className:`cg-detail-value cg-detail-value--live`,children:(0,B.jsx)(`input`,{id:r,type:`date`,className:`cg-detail-input`,value:i,onChange:t=>u(e.key,Pre(n,t.target.value))})})}else if(c&&(e.type===`int`||e.type===`currency`||e.type===`pct`)){let n=e.type===`currency`?`$`:e.type===`pct`?`%`:``;p=(0,B.jsxs)(`span`,{className:`cg-detail-value cg-detail-value--live cg-detail-pickslot`,children:[e.type===`currency`&&(0,B.jsx)(`span`,{className:`cg-detail-unit`,children:n}),(0,B.jsx)(`input`,{id:r,type:`number`,className:`cg-detail-input cg-detail-input--num`,value:Em(t[e.key]),step:e.type===`int`?1:`any`,placeholder:`—`,onChange:t=>l(e.key,t.target.value),onBlur:n=>{let r=Lre(n.target.value);r===null?l(e.key,Em(t[e.key])):u(e.key,r)}}),e.type===`pct`&&(0,B.jsx)(`span`,{className:`cg-detail-unit`,children:n})]})}else if(e.source===`overlay`&&e.type===`rating`)p=(0,B.jsx)(`span`,{className:`cg-detail-value`,title:a?void 0:`You do not have permission to edit this field`,children:(0,B.jsx)(jre,{value:Dm(e,t[e.key]),max:rd(e)})});else{let n=e.source===`overlay`?a?`No assignable people were supplied for this workspace`:`You do not have permission to edit this field`:void 0,r=e.type===`user`&&Sm(t[e.key])!==``;p=(0,B.jsxs)(`span`,{className:`cg-detail-value`+(r?` cg-detail-pickslot`:``),title:n,children:[r&&(0,B.jsx)(xUe,{name:Sm(t[e.key]),avatars:x}),yp(e,t[e.key])||`—`]})}let m=c&&(e.type===`rating`||e.type===`multiselect`),h=!m&&(s||c||e.source===`overlay`&&e.type===`checkbox`);return(0,B.jsxs)(`div`,{className:f,onDragOver:t=>{re.current&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,ae!==e.key&&oe(e.key))},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||oe(t=>t===e.key?null:t)},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`application/x-cg-field`)||re.current;oe(null),n&&fe(cUe(P,n,e.key))},children:[xe(e,n),h?(0,B.jsx)(`label`,{className:`cg-detail-label`,htmlFor:r,children:e.label}):(0,B.jsx)(`span`,{className:`cg-detail-label`,id:m?`${r}-lbl`:void 0,children:e.label}),p]},e.key)};return Mp({panelRef:S,onDismiss:c,dismissOnOutside:!0,initialFocus:`[data-overlay-autofocus]`,trapFocus:!0}),(0,B.jsx)(Np,{children:(0,B.jsx)(`div`,{className:`cg-record-backdrop`,children:(0,B.jsxs)(`div`,{className:`cg-record-modal`+(E?``:` cg-record-modal--single`),ref:S,role:`dialog`,"aria-modal":`true`,"aria-labelledby":C,"data-overlay-kind":`record-detail`,tabIndex:-1,children:[(0,B.jsxs)(`div`,{className:`cg-detail-header`,children:[(0,B.jsxs)(`div`,{className:`cg-detail-nav`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-navbtn`,onClick:o,disabled:!i,"aria-label":`Previous record`,title:`Previous record`,children:`‹`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-navbtn`,onClick:s,disabled:!a,"aria-label":`Next record`,title:`Next record`,children:`›`}),(0,B.jsx)(`span`,{className:`cg-detail-pos`,children:r})]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-close`,"data-overlay-autofocus":!0,onClick:c,"aria-label":`Close panel`,title:`Close`,children:`×`})]}),(0,B.jsxs)(`div`,{className:`cg-record-layout`,children:[(0,B.jsxs)(`main`,{className:`cg-record-main`,children:[(0,B.jsx)(`div`,{className:`cg-detail-titlewrap`,children:(0,B.jsx)(`div`,{className:`cg-detail-title`,id:C,title:T,children:T})}),he&&(0,B.jsx)(`div`,{className:`cg-record-tabs`,role:`tablist`,"aria-label":`Record view`,children:[`fields`,`insights`].map(e=>(0,B.jsx)(`button`,{type:`button`,role:`tab`,id:`${w}-${e}`,"aria-selected":ge===e,"aria-controls":`${w}-panel`,className:`cg-record-tab`+(ge===e?` is-on`:``),onClick:()=>me(e),children:e===`fields`?`Fields`:`Insights`},e))}),(0,B.jsx)(`div`,{className:`cg-detail-body`,id:`${w}-panel`,role:he?`tabpanel`:void 0,"aria-labelledby":he?`${w}-${ge}`:void 0,children:ge===`insights`&&y?(0,B.jsx)(`div`,{className:`cg-record-insights`,children:(0,B.jsx)($He,{scope:y,pids:ye,fields:e,rows:be,display:_e,onDisplay:e=>ve(t=>({...t,...e})),locked:!0})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`section`,{className:`cg-detail-section cg-detail-fieldlist`,children:P.map((e,t)=>{let n=ee.get(e);return n?Se(n,t):null})}),m&&h&&g&&(0,B.jsx)(aUe,{pid:Number(t.pid),docs:f??[],docPayload:p,onAdd:m,onFetch:h,onDelete:g})]})})]}),E&&(0,B.jsx)(vUe,{pid:Number(t.pid),viewer:d},Number(t.pid))]})]})})})}var wUe=[`csv`,`xlsx`,`pdf`,`json`],TUe={csv:`CSV`,xlsx:`Excel`,pdf:`PDF`,json:`JSON`};function EUe(e,t,n){let r=(e.trim()||`export`).replace(/[\\/:*?"<>|]/g,`_`);return t?`${r} - ${t}.${n}`:`${r}.${n}`}function DUe(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function OUe(e,t){let n=[e.map(e=>DUe(e.label)).join(`,`)];for(let r of t)n.push(e.map(e=>DUe(yp(e,r[e.key]))).join(`,`));return n.join(`\r +`,bUe=`chart-wrapper`})),SUe=c({default:()=>CUe});function CUe({spec:e,label:t}){let n=(0,K5.useRef)(null),r=(0,K5.useRef)(null),[i,a]=(0,K5.useState)(``);return(0,K5.useEffect)(()=>{let t=!1;a(``),r.current?.finalize(),r.current=null;let i=n.current;if(i)return i.replaceChildren(),BHe(i,e,{mode:`vega-lite`,actions:!1,renderer:`svg`,tooltip:!0,hover:!0}).then(e=>{t?e.finalize():r.current=e}).catch(()=>{t||a(`This chart could not be rendered.`)}),()=>{t=!0,r.current?.finalize(),r.current=null,i.replaceChildren()}},[e]),(0,q5.jsxs)(`div`,{className:`cg-vega-frame`,role:`img`,"aria-label":t,children:[(0,q5.jsx)(`div`,{ref:n,className:`cg-vega-host`}),i&&(0,q5.jsx)(`div`,{className:`cg-ch-empty`,children:i})]})}var K5,q5,wUe=o((()=>{K5=u(f(),1),xUe(),q5=Rp()}));wUe();var TUe={week:`Weekly`,month:`Monthly`,quarter:`Quarterly`,year:`Yearly`},EUe=[6,12,24,36],J5=72,Y5=18;function DUe(){let e={stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`};return(0,B.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,"aria-hidden":!0,children:[(0,B.jsx)(`path`,{d:`M2.5 11.5h4v-4h4v-3h3`,...e}),(0,B.jsx)(`path`,{d:`M2.5 13.5h11`,...e,opacity:`0.45`})]})}function OUe(e){let t={server:[],snapshot:[],refused:[]};for(let n of e){let e=qm(n);e===`server`?t.server.push(n):e===`snapshot`?t.snapshot.push(n):t.refused.push({field:n,why:$re(n)})}return t}function kUe(e){let t=e.length+1,n=new Set(e.map(e=>e.id));for(;n.has(`tsr_${t}`);)t+=1;return`tsr_${t}`}function AUe({scope:e,pids:t,fields:n,rows:r,display:i,onDisplay:a,locked:o,onSheet:s}){let c=(0,L.useMemo)(()=>OUe(n),[n]),l=(0,L.useMemo)(()=>[...c.server,...c.snapshot],[c.server,c.snapshot]),u=(0,L.useMemo)(()=>new Set(c.snapshot.map(e=>e.key)),[c.snapshot]),d=rd.includes(i?.tsBucket??``)?i.tsBucket:zm,f=typeof i?.tsSpan?.lastN==`number`?i.tsSpan.lastN:12,p=(0,L.useMemo)(()=>{let e=(i?.tsFields??[]).filter(e=>l.some(t=>t.key===e));return e.length?e:l.slice(0,1).map(e=>e.key)},[i?.tsFields,l]),m=(0,L.useMemo)(()=>p.filter(e=>!u.has(e)),[p,u]),h=(0,L.useMemo)(()=>p.filter(e=>u.has(e)),[p,u]),g=(0,L.useMemo)(()=>i?.tsRows??[],[i?.tsRows]),_=(0,L.useMemo)(()=>i?.tsDeltas??[],[i?.tsDeltas]),v=i?.tsStyles,y=i?.tsGridlines!==!1,b=i?.tsSparkline===!0,[x,S]=(0,L.useState)(null),[C,w]=(0,L.useState)(`idle`),[T,E]=(0,L.useState)(0),[D,O]=(0,L.useState)(new Set),k=(0,L.useRef)(0),A=Xd();(0,L.useEffect)(()=>{if(A)return;if(!m.length||!t.length){S(null),w(`idle`);return}let n=++k.current;w(`loading`),cf(Bm({pids:t,bucket:d,span:{lastN:f},fields:m}),e).then(({payload:e,status:t})=>{if(n===k.current){if(!e){S(null),E(t),w(`error`);return}S(e),w(`idle`)}})},[A,e,t,d,f,m]);let j=(0,L.useMemo)(()=>Km(x),[x]),M=(0,L.useMemo)(()=>{if(!h.length||!j.columns.length)return j;let e=new Map(n.map(e=>[e.key,e])),t=h.map(t=>e.get(t)).filter(e=>!!e).map(e=>eie(e,r??[],j.columns,x?.meta?.today));return{...j,rows:[...j.rows,...t],empty:!1}},[j,h,n,r,x?.meta?.today]),ee=(0,L.useMemo)(()=>uie(M,{customRows:g,deltas:_,bucket:d,today:x?.meta?.today}),[M,g,_,d,x?.meta?.today]);(0,L.useEffect)(()=>{s?.(ee)},[ee,s]);let N=(0,L.useCallback)(e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),te=e=>{e.length&&a?.({tsFields:e.slice(0,12)})},ne=e=>a?.({tsRows:e.length?e.slice(0,12):void 0}),P=e=>{let t=_.includes(e)?_.filter(t=>t!==e):[..._,e];a?.({tsDeltas:t.length?t:void 0})},re=(e,t)=>{let n={...v??{}},r={...Zm(v,e),...t},i={};r.bold&&(i.bold=!0),r.line&&(i.line=!0),i.bold||i.line?n[e]=i:delete n[e],a?.({tsStyles:Object.keys(n).length?n:void 0})};if(A)return(0,B.jsx)(`div`,{className:`cg-mode-empty`,children:`The time-series view runs in the web app. Open Loopable in a browser tab to see it.`});if(!l.length)return(0,B.jsx)(`div`,{className:`cg-mode-empty`,children:`This table has no number fields to plot. A time series needs either a metric with a period, or a numeric column to snapshot — add one from a column menu, then pick it here.`});let F=l.filter(e=>!p.includes(e.key)),ie=ee.columns.length+2+ +!!b,ae=h.length>0&&ee.columns.length===0&&C!==`loading`;return(0,B.jsxs)(`div`,{className:`cg-ts`,children:[(0,B.jsxs)(`div`,{className:`cg-ts-bar`,children:[(0,B.jsxs)(`label`,{className:`cg-ts-ctl`,children:[(0,B.jsx)(`span`,{className:`cg-ts-ctl-k`,children:`Period`}),(0,B.jsx)(`select`,{className:`cg-select`,value:d,onChange:e=>a?.({tsBucket:e.target.value}),disabled:!a,children:rd.map(e=>(0,B.jsx)(`option`,{value:e,children:TUe[e]},e))})]}),(0,B.jsxs)(`label`,{className:`cg-ts-ctl`,children:[(0,B.jsx)(`span`,{className:`cg-ts-ctl-k`,children:`Span`}),(0,B.jsx)(`select`,{className:`cg-select`,value:String(f),onChange:e=>a?.({tsSpan:{lastN:Number(e.target.value)}}),disabled:!a,children:EUe.map(e=>(0,B.jsxs)(`option`,{value:e,children:[`Last `,e]},e))})]}),(0,B.jsx)(Tm,{label:_.length?`Compare · ${_.length}`:`Compare`,icon:(0,B.jsx)(DUe,{}),active:_.length>0,children:()=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Compare each period with`}),(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`Each choice adds a sub-row under every metric. A comparison that cannot be answered for a metric says so in the footnotes rather than printing a number.`}),od.map(e=>(0,B.jsxs)(`label`,{className:`cg-check-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:_.includes(e),disabled:!a,onChange:()=>P(e)}),(0,B.jsx)(`span`,{className:`cg-check-label`,children:Ym[e]})]},e))]})}),(0,B.jsxs)(`span`,{className:`cg-ts-group`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-tog`+(y?` is-on`:``),"aria-pressed":y,disabled:!a,onClick:()=>a?.({tsGridlines:!y&&void 0}),children:`Gridlines`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-tog`+(b?` is-on`:``),"aria-pressed":b,disabled:!a,onClick:()=>a?.({tsSparkline:!b||void 0}),children:`Trend`})]}),(0,B.jsx)(`span`,{className:`cg-ts-pool`,children:o?`This record`:`${ee.pool.toLocaleString()} ${ee.pool===1?`customer`:`customers`}`})]}),C===`error`&&(0,B.jsx)(`div`,{className:`cg-ts-note cg-ts-error`,children:T===400?`That span is too wide to bucket. Choose a shorter span or a larger period.`:T===403?`None of these records are in your book.`:`The time series could not be loaded. Nothing is shown rather than a guess.`}),ae&&(0,B.jsxs)(`div`,{className:`cg-ts-note`,children:[h.length===1?`That column has`:`Those columns have`,` no period of its own, so `,h.length===1?`it is`:`they are`,` shown as a snapshot across the periods on the sheet — and this sheet has no periods yet. Add one metric with a period and `,h.length===1?`it`:`they`,` will appear beside it.`]}),c.refused.length>0&&(0,B.jsxs)(`details`,{className:`cg-ts-refused`,children:[(0,B.jsx)(`summary`,{className:`cg-ts-refsum`,children:c.refused.length===1?`1 column has no period of its own`:`${c.refused.length} columns have no period of their own`}),(0,B.jsx)(`div`,{className:`cg-ts-reflist`,children:c.refused.map(({field:e,why:t})=>(0,B.jsx)(`span`,{className:`cg-ts-refchip`,title:t,children:e.label},e.key))})]}),C===`loading`&&!x&&(0,B.jsx)(`div`,{className:`cg-ts-note`,children:(0,B.jsx)(`span`,{className:`lp-spin`,role:`status`,"aria-label":`Loading`})}),x&&(0,B.jsx)(`div`,{className:`cg-ts-scroll`,children:(0,B.jsxs)(`table`,{className:`cg-ts-table`+(y?``:` is-nogrid`),children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{className:`cg-ts-stick`,children:`Metric`}),ee.columns.map(e=>(0,B.jsxs)(`th`,{className:e.partial?`is-partial`:void 0,children:[e.label,e.partial&&(0,B.jsx)(`span`,{className:`cg-ts-partial`,children:` · partial`})]},e.key)),(0,B.jsx)(`th`,{className:`cg-ts-total`,children:`Total`}),b&&(0,B.jsx)(`th`,{className:`cg-ts-sparkhead`,children:`Trend`})]})}),(0,B.jsxs)(`tbody`,{children:[ee.rows.map(e=>(0,B.jsx)(MUe,{row:e,sheet:ee,style:Zm(v,e.id),styles:v,sparkline:b,charted:D.has(e.id),editable:!!a,metricRow:M.rows.find(t=>t.field===e.id),onToggleChart:()=>N(e.id),onStyle:t=>re(e.id,t),onRemove:()=>{e.kind===`metric`?te(p.filter(t=>t!==e.id)):ne(g.filter(t=>t.id!==e.id))},onEditRow:t=>ne(g.map(n=>n.id===e.id?{...n,...t}:n))},e.id)),a&&(0,B.jsx)(`tr`,{className:`cg-ts-addrow`,children:(0,B.jsx)(`th`,{className:`cg-ts-stick`,colSpan:ie,children:(0,B.jsxs)(`span`,{className:`cg-ts-addbar`,children:[(0,B.jsx)(rm,{fields:F,value:void 0,onChange:e=>te([...p,e]),className:`cg-select cg-ts-addsel`,ariaLabel:`Add a metric row`,disabled:!F.length||p.length>=12,placeholder:F.length?p.length>=12?`At the 12-metric limit`:`+ Add metric`:`Every metric is on the sheet`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-tog`,disabled:g.length>=12,onClick:()=>ne([...g,{id:kUe(g),kind:`note`,label:``}]),children:`+ Note`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-tog`,disabled:g.length>=12,onClick:()=>ne([...g,{id:kUe(g),kind:`formula`,label:``,expr:``}]),children:`+ Formula`})]})})})]})]})}),x&&ee.empty&&(0,B.jsx)(`div`,{className:`cg-ts-note`,children:`No metrics returned a series for this span.`}),ee.notes.length>0&&(0,B.jsx)(`ul`,{className:`cg-ts-notes`,children:ee.notes.map(e=>(0,B.jsx)(`li`,{children:e},e))})]})}function jUe({style:e,editable:t,onStyle:n,onRemove:r,label:i}){return t?(0,B.jsxs)(`span`,{className:`cg-ts-rowtools`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-rowtool`+(e.bold?` is-on`:``),"aria-pressed":!!e.bold,"aria-label":`Bold ${i}`,title:`Bold`,onClick:()=>n({bold:!e.bold||void 0}),children:`B`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-rowtool`+(e.line?` is-on`:``),"aria-pressed":!!e.line,"aria-label":`Rule above ${i}`,title:`Rule above`,onClick:()=>n({line:!e.line||void 0}),children:`―`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-rowtool`,"aria-label":`Remove ${i}`,title:`Remove row`,onClick:r,children:`×`})]}):null}function MUe({row:e,sheet:t,style:n,styles:r,sparkline:i,charted:a,editable:o,metricRow:s,onToggleChart:c,onStyle:l,onRemove:u,onEditRow:d}){let f=(0,L.useMemo)(()=>{if(!a||!s)return null;let n=$m(s,t.columns);return n.points.length?nh({spec:{id:e.id,kind:`line`,agg:e.agg??`sum`},model:n,yTitle:e.label,formatValue:e=>e.toLocaleString(void 0,{maximumFractionDigits:2})}):null},[a,s,t.columns,e.id,e.agg,e.label]),p=t.columns.length+2+ +!!i,m=(n.line?`is-ruled`:``)+(n.bold?` is-bold`:``)||void 0;return e.kind===`note`?(0,B.jsx)(`tr`,{className:`cg-ts-noterow `+(m??``),children:(0,B.jsx)(`th`,{className:`cg-ts-stick`,colSpan:p,children:(0,B.jsxs)(`span`,{className:`cg-ts-rowhead`,children:[o?(0,B.jsx)(`input`,{className:`cg-ts-rowinput`,value:e.label,maxLength:120,placeholder:`Note — type a heading for this section`,"aria-label":`Note row label`,onChange:e=>d({label:e.target.value})}):(0,B.jsx)(`span`,{className:`cg-ts-rowlabel`,children:e.label}),(0,B.jsx)(jUe,{style:n,editable:o,onStyle:l,onRemove:u,label:e.label||`note row`})]})})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`tr`,{className:m,children:[(0,B.jsx)(`th`,{scope:`row`,className:`cg-ts-stick`,children:(0,B.jsxs)(`span`,{className:`cg-ts-rowhead`,children:[(0,B.jsxs)(`span`,{className:`cg-ts-rowmain`,children:[e.kind===`formula`?o?(0,B.jsx)(`input`,{className:`cg-ts-rowinput`,value:e.label,maxLength:120,placeholder:`Formula row name`,"aria-label":`Formula row label`,onChange:e=>d({label:e.target.value})}):(0,B.jsx)(`span`,{className:`cg-ts-rowlabel`,children:e.label}):(0,B.jsx)(`button`,{type:`button`,className:`cg-ts-rowbtn`,onClick:c,"aria-pressed":a,title:a?`Show as a row of numbers`:`Show as a line`,children:e.label}),e.sublabel&&(0,B.jsx)(`span`,{className:`cg-ts-rowsub`,children:e.sublabel}),e.kind===`formula`&&(o?(0,B.jsx)(`input`,{className:`cg-ts-rowinput cg-ts-rowexpr`,value:e.expr??``,maxLength:200,spellCheck:!1,placeholder:`= [Sales] - [Returns]`,"aria-label":`Formula`,onChange:e=>d({expr:e.target.value})}):(0,B.jsx)(`span`,{className:`cg-ts-rowsub`,children:e.expr}))]}),(0,B.jsx)(jUe,{style:n,editable:o,onStyle:l,onRemove:u,label:e.label||`row`})]})}),e.cells.map((n,i)=>{let a=t.columns[i],o=Zm(r,e.id,a?.key);return(0,B.jsx)(`td`,{className:(n.partial?`is-partial`:``)+(o.bold?` is-bold`:``)||void 0,children:Jre(n.value,Hm)},a?.key??i)}),(0,B.jsx)(`td`,{className:`cg-ts-total`,children:e.total==null?``:Hm(e.total)}),i&&(0,B.jsx)(`td`,{className:`cg-ts-spark`,children:(0,B.jsx)(PUe,{values:e.cells.map(e=>e.value),label:e.label})})]}),e.deltas.map(e=>(0,B.jsx)(NUe,{delta:e,sparkline:i},e.kind)),a&&(0,B.jsx)(`tr`,{className:`cg-ts-chartrow`,children:(0,B.jsx)(`td`,{colSpan:p,children:f?(0,B.jsx)(CUe,{spec:f,label:`${e.label} over time`}):(0,B.jsx)(`div`,{className:`cg-ts-note`,children:`Nothing to plot — every period for this metric is unanswered.`})})})]})}function NUe({delta:e,sparkline:t}){return(0,B.jsxs)(`tr`,{className:`cg-ts-delta`,children:[(0,B.jsx)(`th`,{scope:`row`,className:`cg-ts-stick`,children:e.label}),e.values.map((t,n)=>(0,B.jsx)(`td`,{className:t==null?void 0:t>=0?`is-up`:`is-down`,children:e.percent?Gm(t):t==null?`—`:`${t>0?`+`:``}${Hm(t)}`},n)),(0,B.jsx)(`td`,{className:`cg-ts-total`}),t&&(0,B.jsx)(`td`,{className:`cg-ts-spark`})]})}function PUe({values:e,label:t}){let n=(0,L.useMemo)(()=>cie(e,J5,Y5),[e]);if(!n.length)return(0,B.jsx)(`span`,{className:`cg-ts-sparkempty`,children:`—`});let r=e.filter(e=>e!=null).length;return(0,B.jsx)(`svg`,{className:`cg-ts-sparksvg`,width:J5,height:Y5,viewBox:`0 0 ${J5} ${Y5}`,role:`img`,"aria-label":`${t}: trend over ${r} of ${e.length} periods`,children:n.map((e,t)=>(0,B.jsx)(`polyline`,{points:lie(e),fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinejoin:`round`,strokeLinecap:`round`},t))})}function X5(e){return!Number.isFinite(e)||e<0?`—`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function FUe(e){let t=[];return e.by&&t.push(e.by),e.ts&&t.push(e.ts.slice(0,16).replace(`T`,` `)),t.join(` · `)}function IUe({pid:e,docs:t,docPayload:n,onAdd:r,onFetch:i,onDelete:a}){let o=(0,L.useRef)(null),[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(!1),d=(0,L.useRef)(null),[f,p]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(!(!n||d.current==null)&&!(n.pid!==e||n.docId!==d.current)){d.current=null;try{let e=atob(n.data_b64),t=new Uint8Array(e.length);for(let n=0;nURL.revokeObjectURL(r),0)}catch{c(`That file could not be decoded. Nothing was downloaded.`)}}},[n,e]);let m=e=>{if(c(null),!e)return;if(e.size>5242880){c(`${e.name} is ${X5(e.size)}. The limit is ${X5(Ld)}, so it was not uploaded.`),o.current&&(o.current.value=``);return}u(!0);let t=new FileReader;t.onerror=()=>{u(!1),c(`${e.name} could not be read.`)},t.onload=()=>{u(!1);let n=String(t.result??``),i=n.indexOf(`,`);if(i<0){c(`${e.name} could not be encoded.`);return}r({name:e.name,mime:e.type||`application/octet-stream`,size:e.size,data_b64:n.slice(i+1)}),o.current&&(o.current.value=``)},t.readAsDataURL(e)};return(0,B.jsxs)(`section`,{className:`cg-detail-section cg-docs`,children:[(0,B.jsx)(`div`,{className:`cg-detail-section-title`,children:`Documents`}),t.length===0?(0,B.jsx)(`div`,{className:`cg-docs-empty`,children:`No documents on this customer yet.`}):(0,B.jsx)(`ul`,{className:`cg-docs-list`,children:t.map(e=>(0,B.jsxs)(`li`,{className:`cg-docs-row`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn cg-docs-name`,title:`Download ${e.name}`,onClick:()=>{c(null),d.current=e.id,i(e.id)},children:e.name}),(0,B.jsxs)(`span`,{className:`cg-docs-meta`,children:[X5(e.size),FUe(e)?` · ${FUe(e)}`:``]}),e.canDelete!==!1&&(0,B.jsx)(`button`,{type:`button`,className:`cg-docs-del`+(f===e.id?` is-armed`:``),"aria-label":f===e.id?`Delete ${e.name}?`:`Delete ${e.name}`,onClick:()=>{if(f!==e.id){p(e.id);return}p(null),a(e.id)},children:f===e.id?`Delete?`:`×`})]},e.id))}),(0,B.jsxs)(`div`,{className:`cg-docs-add`,children:[(0,B.jsx)(`input`,{ref:o,type:`file`,className:`cg-docs-file`,"aria-label":`Add a document`,disabled:l,onChange:e=>m(e.target.files?.[0])}),(0,B.jsxs)(`span`,{className:`cg-docs-cap`,children:[`Up to `,X5(Ld),` per file.`]})]}),s&&(0,B.jsx)(`div`,{className:`cg-docs-error`,children:s})]})}var LUe=`application/x-cg-field`;function RUe(e,t){let n=new Set(t),r=new Set,i=[];for(let t of e??[])!n.has(t)||r.has(t)||(r.add(t),i.push(t));for(let e of t)r.has(e)||(r.add(e),i.push(e));return i}function zUe(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0||r===i)return e;let a=[...e];return a.splice(r,1),a.splice(i,0,t),a}function BUe(e,t,n){let r=e.indexOf(t),i=r+n;if(r<0||i<0||i>=e.length)return e;let a=[...e];return a.splice(r,1),a.splice(i,0,t),a}var VUe=class extends Error{status;constructor(e,t){super(e),this.name=`RecordCommentsError`,this.status=t}};async function Z5(e){let t=null;try{t=await e.json()}catch{}if(e.status===401&&qd(Bd),!e.ok)throw new VUe(t?.error?.message||`The server answered ${e.status}.`,e.status);return t}async function HUe(e,t){let n=await Z5(await fetch(`${Rd}/customers/${e}/comments`,{credentials:zd,signal:t}));return Array.isArray(n.comments)?n.comments:[]}async function UUe(e,t){return(await Z5(await fetch(`${Rd}/customers/${e}/comments`,{method:`POST`,credentials:zd,headers:{"Content-Type":`application/json`},body:JSON.stringify({body:t})}))).comment}async function WUe(e,t){await Z5(await fetch(`${Rd}/customers/${e}/comments/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:zd}))}function GUe(e){return{pid:e,comments:[],draft:``,loading:!0,posting:!1,error:``}}function KUe(e,t){if(t.type===`record`)return GUe(t.pid);if(t.pid!==e.pid)return e;switch(t.type){case`loaded`:return{...e,comments:t.comments,loading:!1,error:``};case`load-failed`:return{...e,loading:!1,error:t.error};case`draft`:return{...e,draft:t.draft};case`posting`:return{...e,posting:!0,error:``};case`posted`:return{...e,comments:[...e.comments,t.comment],draft:``,posting:!1};case`post-failed`:return{...e,posting:!1,error:t.error};case`deleted`:return{...e,comments:e.comments.filter(e=>e.id!==t.commentId)};case`delete-failed`:return{...e,error:t.error}}}function qUe(e){return e.trim().split(/\s+/).slice(0,2).map(e=>e[0]?.toUpperCase()).join(``)||`?`}function JUe(e){let t=new Date(e);return Number.isFinite(t.getTime())?new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t):e}function YUe({pid:e,viewer:t}){let[n,r]=(0,L.useReducer)(KUe,e,GUe),{comments:i,draft:a,loading:o,posting:s,error:c}=n,l=(0,L.useRef)(null);(0,L.useEffect)(()=>{let t=new AbortController;return r({type:`record`,pid:e}),HUe(e,t.signal).then(t=>r({type:`loaded`,pid:e,comments:t})).catch(t=>{t instanceof DOMException&&t.name===`AbortError`||r({type:`load-failed`,pid:e,error:t instanceof Error?t.message:`Comments could not be loaded.`})}),()=>t.abort()},[e]);let u=async t=>{t.preventDefault();let n=a.trim();if(!n||s)return;let i=e;r({type:`posting`,pid:i});try{let t=await UUe(i,n);r({type:`posted`,pid:i,comment:t}),i===e&&l.current?.focus()}catch(e){r({type:`post-failed`,pid:i,error:e instanceof Error?e.message:`That comment was not saved.`})}},d=async t=>{let n=e;try{await WUe(n,t.id),r({type:`deleted`,pid:n,commentId:t.id})}catch(e){r({type:`delete-failed`,pid:n,error:e instanceof Error?e.message:`That comment was not deleted.`})}};return(0,B.jsxs)(`aside`,{className:`cg-record-comments`,"aria-label":`Record comments`,children:[(0,B.jsxs)(`div`,{className:`cg-record-comments-head`,children:[(0,B.jsx)(`h2`,{children:`Comments`}),(0,B.jsx)(`span`,{children:i.length.toLocaleString()})]}),(0,B.jsxs)(`div`,{className:`cg-record-comment-feed`,"aria-live":`polite`,children:[o&&(0,B.jsx)(`div`,{className:`cg-record-comment-state`,children:(0,B.jsx)(`span`,{className:`lp-spin`,role:`status`,"aria-label":`Loading`})}),!o&&i.length===0&&!c&&(0,B.jsx)(`div`,{className:`cg-record-comment-state`,children:`No comments yet. Add context for the team here.`}),i.map(e=>{let n=t?.isAdmin===!0||t?.name?.trim().toLowerCase()===e.authorKey.toLowerCase();return(0,B.jsxs)(`article`,{className:`cg-record-comment`,children:[(0,B.jsx)(`div`,{className:`cg-record-comment-avatar`,"aria-hidden":!0,children:qUe(e.author)}),(0,B.jsxs)(`div`,{className:`cg-record-comment-content`,children:[(0,B.jsxs)(`div`,{className:`cg-record-comment-meta`,children:[(0,B.jsx)(`strong`,{children:e.author}),(0,B.jsx)(`time`,{dateTime:e.createdAt,children:JUe(e.createdAt)}),n&&(0,B.jsx)(`button`,{type:`button`,className:`cg-record-comment-delete`,"aria-label":`Delete comment by ${e.author}`,title:`Delete comment`,onClick:()=>void d(e),children:`×`})]}),(0,B.jsx)(`p`,{children:e.body})]})]},e.id)}),c&&(0,B.jsx)(`div`,{className:`cg-record-comment-error`,children:c})]}),(0,B.jsxs)(`form`,{className:`cg-record-comment-compose`,onSubmit:e=>void u(e),children:[(0,B.jsx)(`label`,{htmlFor:`cg-comment-${e}`,children:`Add a comment`}),(0,B.jsx)(`textarea`,{ref:l,id:`cg-comment-${e}`,value:a,maxLength:4e3,placeholder:`Share an update or leave context…`,onChange:t=>r({type:`draft`,pid:e,draft:t.target.value}),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,B.jsxs)(`div`,{className:`cg-record-comment-compose-foot`,children:[(0,B.jsx)(`span`,{children:`Ctrl/⌘ + Enter to post`}),(0,B.jsx)(`button`,{type:`submit`,disabled:s||!a.trim(),children:s?`Posting…`:`Comment`})]})]})]})}function XUe(e,t){let n=t.trim();if(!n)return null;if(e.type===`url`)return/^https?:\/\//i.test(n)?n:/^[\w-]+(\.[\w-]+)+/.test(n)?`https://${n}`:null;if(e.type===`email`)return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?`mailto:${n}`:null;if(e.type===`phone`){let e=n.replace(/[\s().-]/g,``);return/^\+?\d{5,}$/.test(e)?`tel:${e}`:null}return null}function ZUe({value:e,...t}){let n=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{e.style.height=`auto`;let t=window.getComputedStyle(e),n=t.boxSizing===`border-box`?(parseFloat(t.borderTopWidth)||0)+(parseFloat(t.borderBottomWidth)||0):0;e.style.height=`${e.scrollHeight+n}px`};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),(0,B.jsx)(`textarea`,{ref:n,value:e,...t})}function QUe({name:e,avatars:t}){let n=t?.[e];if(n&&n.startsWith(`data:image/`))return(0,B.jsx)(`img`,{className:`cg-detail-avatar`,src:n,alt:``,"aria-hidden":!0});let r=hp(e);return(0,B.jsx)(`span`,{className:`cg-detail-avatar cg-detail-avatar--initials`,style:{background:r.bg,color:r.fg},"aria-hidden":!0,children:Gre(e)})}function $Ue(){return(0,B.jsx)(`svg`,{width:`10`,height:`14`,viewBox:`0 0 10 14`,"aria-hidden":!0,focusable:`false`,children:[3,7,11].map(e=>[3,7].map(t=>(0,B.jsx)(`circle`,{cx:t,cy:e,r:`1.15`,fill:`currentColor`},`${t}-${e}`)))})}function eWe({fields:e,record:t,titleKey:n,positionLabel:r,canPrev:i,canNext:a,onPrev:o,onNext:s,onClose:c,onNotesChange:l,onNotesCommit:u,viewer:d,docs:f,docPayload:p,onDocAdd:m,onDocFetch:h,onDocDelete:g,recordLayout:_,onRecordLayout:v,scope:y,userOptions:b,userAvatars:x}){let S=(0,L.useRef)(null),C=(0,L.useId)(),w=(0,L.useId)(),T=String(t[n]??`Untitled`),E=!Xd(),D=e.filter(e=>e.source===`overlay`),O=D.filter(e=>!$u(e.type)&&e.type!==`checkbox`&&e.type!==`rating`),k=D.filter(e=>e.type===`checkbox`),A=D.filter(e=>e.type===`rating`),j=D.filter(e=>$u(e.type)),M=e.filter(e=>e.source!==`overlay`&&e.key!==n),ee=new Map(e.map(e=>[e.key,e])),N=[...O,...k,...A,...j,...M].map(e=>e.key),[te,ne]=(0,L.useState)(null);(0,L.useEffect)(()=>{ne(e=>e&&JSON.stringify(e)===JSON.stringify(_??[])?null:e)},[_]);let P=RUe(te??_,N),re=(0,L.useRef)(null),[F,ie]=(0,L.useState)(null),[ae,oe]=(0,L.useState)(null),se=(0,L.useRef)(new Map),ce=(0,L.useRef)(null);(0,L.useLayoutEffect)(()=>{let e=ce.current;e&&(ce.current=null,se.current.get(e)?.focus())});let[le,ue]=(0,L.useState)(null),de=le&&P.includes(le)?le:P[0],fe=e=>{e!==P&&(ne(e),v?.(e))},[pe,me]=(0,L.useState)(`fields`),he=y!=null,ge=he?pe:`fields`,[_e,ve]=(0,L.useState)({mode:`timeseries`}),ye=(0,L.useMemo)(()=>[Number(t.pid)],[t.pid]),be=(0,L.useMemo)(()=>[t],[t]),xe=(e,t)=>(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-grip`,ref:t=>{se.current.set(e.key,t)},draggable:!0,tabIndex:e.key===de?0:-1,onFocus:()=>ue(e.key),"aria-label":`Reorder ${e.label}, position ${t+1} of ${P.length}`,title:`Drag to reorder — or press the arrow keys`,onDragStart:t=>{re.current=e.key,ie(e.key),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(LUe,e.key);let n=t.currentTarget.parentElement;n&&t.dataTransfer.setDragImage(n,14,n.clientHeight/2)},onDragEnd:()=>{re.current=null,ie(null),oe(null)},onKeyDown:t=>{if(t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=BUe(P,e.key,t.key===`ArrowUp`?-1:1);n!==P&&(ce.current=e.key,fe(n))},children:(0,B.jsx)($Ue,{})}),Se=(e,n)=>{let r=`cg-ov-${e.key}`,i=jee(e,d),a=e.type===`user`&&!b?.length,o=i&&!a,s=o&&!$u(e.type)&&e.type!==`checkbox`&&e.type!==`rating`&&e.type!==`date`&&e.type!==`int`&&e.type!==`currency`&&e.type!==`pct`,c=o&&!s,f=`cg-detail-field`+(s?` cg-detail-field--edit`:``)+(c?` cg-detail-field--control`:``)+(ae===e.key?` is-dropzone`:``)+(F===e.key?` is-dragging`:``),p;if(s){let n=String(t[e.key]??``),i=XUe(e,n);p=(0,B.jsxs)(`div`,{className:`cg-detail-editwrap`,children:[(0,B.jsx)(ZUe,{id:r,className:`cg-detail-textarea`,value:n,placeholder:`Add ${e.label.toLowerCase()}…`,onChange:t=>l(e.key,t.target.value),onBlur:t=>u(e.key,t.target.value)}),i&&(0,B.jsx)(`a`,{className:`cg-detail-action`,href:i,target:e.type===`url`?`_blank`:void 0,rel:e.type===`url`?`noopener noreferrer`:void 0,children:e.type===`url`?`Open link`:e.type===`email`?`Send email`:`Call`})]})}else if(e.source===`overlay`&&e.type===`checkbox`)p=(0,B.jsx)(`input`,{id:r,type:`checkbox`,className:`cg-detail-checkbox`,checked:wp(t[e.key]),disabled:!o,onChange:t=>u(e.key,t.target.checked?`1`:``)});else if(c&&e.type===`rating`){let n=nd(e),i=Rm(e,t[e.key]);p=(0,B.jsx)(`span`,{className:`cg-detail-value cg-detail-value--live`,role:`group`,"aria-labelledby":`${r}-lbl`,children:(0,B.jsx)(`span`,{className:`cg-detail-stars`,children:Array.from({length:n},(e,t)=>t+1).map(n=>(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-star`,"aria-pressed":n<=i,"aria-label":n===i?`Clear ${e.label}`:`${n} star${n===1?``:`s`}`,title:n===i?`Click again to clear`:void 0,onClick:()=>u(e.key,Wre(e,t[e.key],n)),children:(0,B.jsx)(Mm,{on:n<=i})},n))})})}else if(c&&(e.type===`select`||e.type===`user`)){let n=Nm(t[e.key]),i=Im(e,b,n);p=(0,B.jsxs)(`span`,{className:`cg-detail-value cg-detail-value--live cg-detail-pickslot`,children:[e.type===`user`&&n!==``&&(0,B.jsx)(QUe,{name:n,avatars:x}),(0,B.jsxs)(`select`,{id:r,className:`cg-detail-select`,value:n,onChange:t=>u(e.key,t.target.value),children:[(0,B.jsx)(`option`,{value:``,children:e.type===`user`?`Unassigned`:`None`}),i.map(e=>(0,B.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]})}else if(c&&e.type===`multiselect`){let n=t[e.key],i=Fm(n),a=Im(e,b,n);p=(0,B.jsx)(`span`,{className:`cg-detail-value cg-detail-value--live`,role:`group`,"aria-labelledby":`${r}-lbl`,children:a.length===0?(0,B.jsx)(`span`,{className:`cg-detail-nochoice`,children:`No choices yet. Add them from the column menu.`}):(0,B.jsx)(`span`,{className:`cg-detail-chips`,children:a.map(t=>{let r=i.includes(t.value);return(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-chip`+(r?` is-on`:``),"aria-pressed":r,title:t.stale?`No longer a choice on this field`:void 0,onClick:()=>u(e.key,Hre(n,t.value)),children:t.label},t.value)})})})}else if(c&&e.type===`date`){let n=t[e.key],i=Rre(n);p=i===null?(0,B.jsxs)(`span`,{className:`cg-detail-value cg-detail-value--live cg-detail-pickslot`,children:[(0,B.jsx)(`input`,{id:r,type:`text`,className:`cg-detail-input`,value:Nm(n),title:`This value is not a date the picker can read — it is shown as stored.`,onChange:t=>l(e.key,t.target.value),onBlur:t=>u(e.key,t.target.value)}),(0,B.jsx)(`span`,{className:`cg-detail-hint`,children:`not a recognised date`})]}):(0,B.jsx)(`span`,{className:`cg-detail-value cg-detail-value--live`,children:(0,B.jsx)(`input`,{id:r,type:`date`,className:`cg-detail-input`,value:i,onChange:t=>u(e.key,Bre(n,t.target.value))})})}else if(c&&(e.type===`int`||e.type===`currency`||e.type===`pct`)){let n=e.type===`currency`?`$`:e.type===`pct`?`%`:``;p=(0,B.jsxs)(`span`,{className:`cg-detail-value cg-detail-value--live cg-detail-pickslot`,children:[e.type===`currency`&&(0,B.jsx)(`span`,{className:`cg-detail-unit`,children:n}),(0,B.jsx)(`input`,{id:r,type:`number`,className:`cg-detail-input cg-detail-input--num`,value:Lm(t[e.key]),step:e.type===`int`?1:`any`,placeholder:`—`,onChange:t=>l(e.key,t.target.value),onBlur:n=>{let r=Ure(n.target.value);r===null?l(e.key,Lm(t[e.key])):u(e.key,r)}}),e.type===`pct`&&(0,B.jsx)(`span`,{className:`cg-detail-unit`,children:n})]})}else if(e.source===`overlay`&&e.type===`rating`)p=(0,B.jsx)(`span`,{className:`cg-detail-value`,title:a?void 0:`You do not have permission to edit this field`,children:(0,B.jsx)(Lre,{value:Rm(e,t[e.key]),max:nd(e)})});else if(e.type===`automation`){let n=Nm(t[e.key]),r=Dp(n);p=(0,B.jsxs)(`span`,{className:`cg-detail-value cg-detail-auto`,title:n||`Not run yet`,children:[(0,B.jsx)(`span`,{className:`cg-detail-auto-chip is-${r}`,children:Rne(n)}),Op(n)?(0,B.jsx)(`span`,{className:`cg-detail-auto-detail`,children:Op(n)}):null]})}else{let n=e.source===`overlay`?a?`No assignable people were supplied for this workspace`:`You do not have permission to edit this field`:void 0,r=e.type===`user`&&Nm(t[e.key])!==``;p=(0,B.jsxs)(`span`,{className:`cg-detail-value`+(r?` cg-detail-pickslot`:``),title:n,children:[r&&(0,B.jsx)(QUe,{name:Nm(t[e.key]),avatars:x}),kp(e,t[e.key])||`—`]})}let m=c&&(e.type===`rating`||e.type===`multiselect`),h=!m&&(s||c||e.source===`overlay`&&e.type===`checkbox`);return(0,B.jsxs)(`div`,{className:f,onDragOver:t=>{re.current&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,ae!==e.key&&oe(e.key))},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||oe(t=>t===e.key?null:t)},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`application/x-cg-field`)||re.current;oe(null),n&&fe(zUe(P,n,e.key))},children:[xe(e,n),h?(0,B.jsx)(`label`,{className:`cg-detail-label`,htmlFor:r,children:e.label}):(0,B.jsx)(`span`,{className:`cg-detail-label`,id:m?`${r}-lbl`:void 0,children:e.label}),p]},e.key)};return Up({panelRef:S,onDismiss:c,dismissOnOutside:!0,initialFocus:`[data-overlay-autofocus]`,trapFocus:!0}),(0,B.jsx)(Wp,{children:(0,B.jsx)(`div`,{className:`cg-record-backdrop`,children:(0,B.jsxs)(`div`,{className:`cg-record-modal`+(E?``:` cg-record-modal--single`),ref:S,role:`dialog`,"aria-modal":`true`,"aria-labelledby":C,"data-overlay-kind":`record-detail`,tabIndex:-1,children:[(0,B.jsxs)(`div`,{className:`cg-detail-header`,children:[(0,B.jsxs)(`div`,{className:`cg-detail-nav`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-navbtn`,onClick:o,disabled:!i,"aria-label":`Previous record`,title:`Previous record`,children:`‹`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-navbtn`,onClick:s,disabled:!a,"aria-label":`Next record`,title:`Next record`,children:`›`}),(0,B.jsx)(`span`,{className:`cg-detail-pos`,children:r})]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-detail-close`,"data-overlay-autofocus":!0,onClick:c,"aria-label":`Close panel`,title:`Close`,children:`×`})]}),(0,B.jsxs)(`div`,{className:`cg-record-layout`,children:[(0,B.jsxs)(`main`,{className:`cg-record-main`,children:[(0,B.jsx)(`div`,{className:`cg-detail-titlewrap`,children:(0,B.jsx)(`div`,{className:`cg-detail-title`,id:C,title:T,children:T})}),he&&(0,B.jsx)(`div`,{className:`cg-record-tabs`,role:`tablist`,"aria-label":`Record view`,children:[`fields`,`insights`].map(e=>(0,B.jsx)(`button`,{type:`button`,role:`tab`,id:`${w}-${e}`,"aria-selected":ge===e,"aria-controls":`${w}-panel`,className:`cg-record-tab`+(ge===e?` is-on`:``),onClick:()=>me(e),children:e===`fields`?`Fields`:`Insights`},e))}),(0,B.jsx)(`div`,{className:`cg-detail-body`,id:`${w}-panel`,role:he?`tabpanel`:void 0,"aria-labelledby":he?`${w}-${ge}`:void 0,children:ge===`insights`&&y?(0,B.jsx)(`div`,{className:`cg-record-insights`,children:(0,B.jsx)(AUe,{scope:y,pids:ye,fields:e,rows:be,display:_e,onDisplay:e=>ve(t=>({...t,...e})),locked:!0})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`section`,{className:`cg-detail-section cg-detail-fieldlist`,children:P.map((e,t)=>{let n=ee.get(e);return n?Se(n,t):null})}),m&&h&&g&&(0,B.jsx)(IUe,{pid:Number(t.pid),docs:f??[],docPayload:p,onAdd:m,onFetch:h,onDelete:g})]})})]}),E&&(0,B.jsx)(YUe,{pid:Number(t.pid),viewer:d},Number(t.pid))]})]})})})}var tWe=[`csv`,`xlsx`,`pdf`,`json`],nWe={csv:`CSV`,xlsx:`Excel`,pdf:`PDF`,json:`JSON`};function rWe(e,t,n){let r=(e.trim()||`export`).replace(/[\\/:*?"<>|]/g,`_`);return t?`${r} - ${t}.${n}`:`${r}.${n}`}function iWe(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function aWe(e,t){let n=[e.map(e=>iWe(e.label)).join(`,`)];for(let r of t)n.push(e.map(e=>iWe(kp(e,r[e.key]))).join(`,`));return n.join(`\r `)+`\r -`}function kUe(e,t){return JSON.stringify({fields:e.map(e=>({key:e.key,label:e.label,type:e.type})),rows:t.map(t=>{let n={pid:t.pid};for(let r of e)n[r.key]=t[r.key]??null;return n})},null,1)}var AUe=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function jUe(e){let t=4294967295;for(let n=0;n>>8;return(t^4294967295)>>>0}function MUe(e){let t=e?/^(\d{4})-(\d{2})-(\d{2})/.exec(e):null,n=t?Number(t[1]):2020,r=t?Number(t[2]):1,i=t?Number(t[3]):1;return{date:Math.max(1980,n)-1980<<9|r<<5|i,time:0}}function NUe(e,t){let n=new TextEncoder,r=MUe(t),i=[],a=[],o=0,s=e=>[e&255,e>>8&255],c=e=>[e&255,e>>8&255,e>>16&255,e>>24&255];for(let t of e){let e=n.encode(t.name),l=jUe(t.data),u=new Uint8Array([...c(67324752),...s(20),...s(2048),...s(0),...s(r.time),...s(r.date),...c(l),...c(t.data.length),...c(t.data.length),...s(e.length),...s(0)]);i.push(u,e,t.data),a.push(new Uint8Array([...c(33639248),...s(20),...s(20),...s(2048),...s(0),...s(r.time),...s(r.date),...c(l),...c(t.data.length),...c(t.data.length),...s(e.length),...s(0),...s(0),...s(0),...s(0),...c(0),...c(o)]),e),o+=u.length+e.length+t.data.length}let l=o,u=0;for(let e of a)u+=e.length;let d=new Uint8Array([...c(101010256),...s(0),...s(0),...s(e.length),...s(e.length),...c(u),...c(l),...s(0)]),f=o+u+d.length,p=new Uint8Array(f),m=0;for(let e of[...i,...a,d])p.set(e,m),m+=e.length;return p}function PUe(e){return e.replace(/&/g,`&`).replace(//g,`>`).replace(/"/g,`"`).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,``)}function FUe(e){return(e.replace(/[[\]:*?/\\]/g,`_`).trim()||`Export`).slice(0,31)}function IUe(e,t,n,r){let i=new TextEncoder,a=e=>`${PUe(e)}`,o=e=>`${e.join(``)}`,s=`${[o(e.map(e=>a(e.label))),...t.map(t=>o(e.map(e=>a(yp(e,t[e.key])))))].join(``)}`,c=``;return NUe([{name:`[Content_Types].xml`,data:i.encode(``)},{name:`_rels/.rels`,data:i.encode(``)},{name:`xl/workbook.xml`,data:i.encode(c)},{name:`xl/_rels/workbook.xml.rels`,data:i.encode(``)},{name:`xl/worksheets/sheet1.xml`,data:i.encode(s)}],r)}var f7=792,p7=612,m7=36,h7=8,g7=13,_7=17,v7=h7*.52,LUe={"…":133,"–":150,"—":151,"‘":145,"’":146,"“":147,"”":148,"·":183,"€":128,"•":149};function y7(e){let t=``;for(let n of e){let e=n.codePointAt(0)??63,r=e<=255?e:LUe[n]??63,i=String.fromCharCode(r);t+=i===`\\`?`\\\\`:i===`(`?`\\(`:i===`)`?`\\)`:i}return t}function b7(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function RUe(e,t,n,r){let i=f7-m7*2,a=t.slice(0,200),o=e.map(e=>{let t=e.label.length;for(let n of a)t=Math.max(t,yp(e,n[e.key]).length);return Math.min(170,Math.max(42,t*v7+8))}),s=Math.min(1,i/o.reduce((e,t)=>e+t,0)),c=o.map(e=>e*s),l=Math.max(1,Math.floor((p7-m7*2-26-_7-14)/g7)),u=Math.max(1,Math.ceil(t.length/l)),d=r?`${n} — ${r}`:n,f=[];for(let n=0;n`${5+t*2} 0 R`).join(` `);p.push(`1 0 obj +`}function oWe(e,t){return JSON.stringify({fields:e.map(e=>({key:e.key,label:e.label,type:e.type})),rows:t.map(t=>{let n={pid:t.pid};for(let r of e)n[r.key]=t[r.key]??null;return n})},null,1)}var sWe=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function cWe(e){let t=4294967295;for(let n=0;n>>8;return(t^4294967295)>>>0}function lWe(e){let t=e?/^(\d{4})-(\d{2})-(\d{2})/.exec(e):null,n=t?Number(t[1]):2020,r=t?Number(t[2]):1,i=t?Number(t[3]):1;return{date:Math.max(1980,n)-1980<<9|r<<5|i,time:0}}function uWe(e,t){let n=new TextEncoder,r=lWe(t),i=[],a=[],o=0,s=e=>[e&255,e>>8&255],c=e=>[e&255,e>>8&255,e>>16&255,e>>24&255];for(let t of e){let e=n.encode(t.name),l=cWe(t.data),u=new Uint8Array([...c(67324752),...s(20),...s(2048),...s(0),...s(r.time),...s(r.date),...c(l),...c(t.data.length),...c(t.data.length),...s(e.length),...s(0)]);i.push(u,e,t.data),a.push(new Uint8Array([...c(33639248),...s(20),...s(20),...s(2048),...s(0),...s(r.time),...s(r.date),...c(l),...c(t.data.length),...c(t.data.length),...s(e.length),...s(0),...s(0),...s(0),...s(0),...c(0),...c(o)]),e),o+=u.length+e.length+t.data.length}let l=o,u=0;for(let e of a)u+=e.length;let d=new Uint8Array([...c(101010256),...s(0),...s(0),...s(e.length),...s(e.length),...c(u),...c(l),...s(0)]),f=o+u+d.length,p=new Uint8Array(f),m=0;for(let e of[...i,...a,d])p.set(e,m),m+=e.length;return p}function dWe(e){return e.replace(/&/g,`&`).replace(//g,`>`).replace(/"/g,`"`).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,``)}function fWe(e){return(e.replace(/[[\]:*?/\\]/g,`_`).trim()||`Export`).slice(0,31)}function pWe(e,t,n,r){let i=new TextEncoder,a=e=>`${dWe(e)}`,o=e=>`${e.join(``)}`,s=`${[o(e.map(e=>a(e.label))),...t.map(t=>o(e.map(e=>a(kp(e,t[e.key])))))].join(``)}`,c=``;return uWe([{name:`[Content_Types].xml`,data:i.encode(``)},{name:`_rels/.rels`,data:i.encode(``)},{name:`xl/workbook.xml`,data:i.encode(c)},{name:`xl/_rels/workbook.xml.rels`,data:i.encode(``)},{name:`xl/worksheets/sheet1.xml`,data:i.encode(s)}],r)}var Q5=792,$5=612,e7=36,t7=8,n7=13,r7=17,i7=t7*.52,mWe={"…":133,"–":150,"—":151,"‘":145,"’":146,"“":147,"”":148,"·":183,"€":128,"•":149};function a7(e){let t=``;for(let n of e){let e=n.codePointAt(0)??63,r=e<=255?e:mWe[n]??63,i=String.fromCharCode(r);t+=i===`\\`?`\\\\`:i===`(`?`\\(`:i===`)`?`\\)`:i}return t}function o7(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function hWe(e,t,n,r){let i=Q5-e7*2,a=t.slice(0,200),o=e.map(e=>{let t=e.label.length;for(let n of a)t=Math.max(t,kp(e,n[e.key]).length);return Math.min(170,Math.max(42,t*i7+8))}),s=Math.min(1,i/o.reduce((e,t)=>e+t,0)),c=o.map(e=>e*s),l=Math.max(1,Math.floor(($5-e7*2-26-r7-14)/n7)),u=Math.max(1,Math.ceil(t.length/l)),d=r?`${n} — ${r}`:n,f=[];for(let n=0;n`${5+t*2} 0 R`).join(` `);p.push(`1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj `),p.push(`2 0 obj\n<< /Type /Pages /Kids [${m}] /Count ${f.length} >>\nendobj\n`),p.push(`3 0 obj @@ -390,14 +390,15 @@ endobj `),p.push(`4 0 obj << /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >> endobj -`),f.forEach((e,t)=>{let n=5+t*2;p.push(`${n} 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${f7} ${p7}] /Resources << /Font << /F1 3 0 R /F2 4 0 R >> >> /Contents ${n+1} 0 R >>\nendobj\n`),p.push(`${n+1} 0 obj\n<< /Length ${e.length} >>\nstream\n${e}endstream\nendobj\n`)});let h=`%PDF-1.4 -`,g=[];for(let e of p)g.push(h.length),h+=e;let _=h.length;h+=`xref\n0 ${p.length+1}\n0000000000 65535 f \n`;for(let e of g)h+=`${String(e).padStart(10,`0`)} 00000 n \n`;h+=`trailer\n<< /Size ${p.length+1} /Root 1 0 R >>\nstartxref\n${_}\n%%EOF\n`;let v=new Uint8Array(h.length);for(let e=0;eURL.revokeObjectURL(n),4e3)}function S7(e,t,n,r,i){let a=EUe(t,n,e);if(e===`csv`){x7(a,new Blob([``,OUe(r,i)],{type:`text/csv;charset=utf-8`}));return}if(e===`json`){x7(a,new Blob([kUe(r,i)],{type:`application/json`}));return}if(e===`xlsx`){x7(a,new Blob([IUe(r,i,t,n).buffer],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}));return}x7(a,new Blob([RUe(r,i,t,n).buffer],{type:`application/pdf`}))}var C7=(e,t)=>typeof e==`number`&&t-e<=12e4;function zUe(e,t){let n={},r=e=>{if(!e)return;let n=Object.entries(e).filter(([,e])=>C7(e,t));return n.length?Object.fromEntries(n.slice(-64)):void 0},i=e=>{if(!e)return;let n=Object.entries(e).filter(([,e])=>C7(e.at,t));return n.length?Object.fromEntries(n.slice(-64)):void 0},a=r(e?.created),o=i(e?.renamed),s=r(e?.deleted),c=i(e?.moved);return a&&(n.created=a),o&&(n.renamed=o),s&&(n.deleted=s),c&&(n.moved=c),n}function BUe(e,t,n,r){let i=e??[],a=[],o=new Set;for(let e of i){if(C7(n?.deleted?.[e.id],r))continue;o.add(e.id);let t=n?.renamed?.[e.id];a.push(C7(t?.at,r)&&t?{...e,name:t.name}:e)}for(let e of t??[])o.has(e.id)||C7(n?.created?.[e.id],r)&&(C7(n?.deleted?.[e.id],r)||a.push(e));return a.sort((e,t)=>(e.order??0)-(t.order??0)||e.name.localeCompare(t.name))}function VUe(e,t,n,r,i){let a=r?.moved?.[e],o=C7(a?.at,i)&&a?a.folderId:t??null;return o==null?null:n.some(e=>e.id===o)?o:null}function HUe(e,t,n){let r=new Map(t.map(e=>[e.id,[]])),i=[];for(let t of e){let e=n(t),a=e==null?void 0:r.get(e);a?a.push(t):i.push(t)}let a=t.map(e=>({folder:e,items:r.get(e.id)??[]}));return a.push({folder:null,items:i}),a}function UUe(){return`fld_${typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID().slice(0,8):Math.random().toString(36).slice(2,10)}`}function WUe({views:e,activeViewId:t,saveState:n,onSelect:r,onCreate:i,onRename:a,onNote:o,onDuplicate:s,onDelete:c,lists:l=[],onAddToList:u,onCohortLock:d,today:f,onExport:p,folders:m,folderIdOf:h,onFolderCreate:g,onFolderRename:_,onFolderDelete:v,onFolderDuplicate:y,onItemMove:b,folderAddPreview:x,onFolderAddToList:S,viewer:C,onToggleLock:w,userOptions:T=[]}){let[E,D]=(0,L.useState)(null),[O,k]=(0,L.useState)(null),[A,j]=(0,L.useState)(``),[M,ee]=(0,L.useState)(`personal`),[N,te]=(0,L.useState)([]),[ne,P]=(0,L.useState)(null),[re,F]=(0,L.useState)(null),[ie,ae]=(0,L.useState)(null),[oe,se]=(0,L.useState)(``),[ce,le]=(0,L.useState)(null),[ue,de]=(0,L.useState)(null),[fe,pe]=(0,L.useState)(``),[me,he]=(0,L.useState)(null),ge=me?e.find(e=>e.id===me.viewId):void 0,_e=ce?e.find(e=>e.id===ce.viewId):void 0,ve=ne?e.find(e=>e.id===ne.viewId):void 0,ye=!!ve&&Od(ve,C),[be,xe]=(0,L.useState)(new Set),[Se,Ce]=(0,L.useState)(null),[we,Te]=(0,L.useState)(null),[Ee,De]=(0,L.useState)(!1),[Oe,ke]=(0,L.useState)(``),[Ae,je]=(0,L.useState)({shape:jd,tone:Md}),[Me,Ne]=(0,L.useState)(null),[Pe,Fe]=(0,L.useState)(null),[Ie,Le]=(0,L.useState)(null),[Re,ze]=(0,L.useState)(``),[Be,Ve]=(0,L.useState)(null),[He,Ue]=(0,L.useState)(``),[We,Ge]=(0,L.useState)(()=>{try{return localStorage.getItem(`aios-views-rail`)===`1`}catch{return!1}}),Ke=()=>Ge(e=>{let t=!e;try{localStorage.setItem(`aios-views-rail`,t?`1`:`0`)}catch{}return t}),qe=He.trim().toLowerCase(),Je=qe?e.filter(e=>(e.name||``).toLowerCase().includes(qe)):e,Ye=!!m&&!!h&&!!b,Xe=HUe(Je,Ye?m:[],e=>h?h(e.id):null),Ze=Se?m?.find(e=>e.id===Se.id):void 0,Qe=Pe&&x?x(Pe):null,$e=e=>Ye?{onDragOver:t=>{t.preventDefault(),Ve(e??`__root__`)},onDragLeave:()=>Ve(null),onDrop:t=>{t.preventDefault(),Ve(null);let n=t.dataTransfer.getData(`text/plain`);n&&b?.(n,e)}}:{},et=ie?e.find(e=>e.id===ie.viewId):void 0,tt=()=>{let e=A.trim();!e||!E||(i(e,E,zee({edit:M,users:N},`personal`,T)),j(``),ee(`personal`),te([]),D(null))},nt=()=>{let e=Oe.trim();e&&(g?.(e,Vee(Ae)),ke(``),je({shape:jd,tone:Md}),De(!1))},I=e=>{k(null),De(!1),D(e)},rt=()=>{k(null),D(null),De(!0)},it=e=>{if(![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]`)];if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:e.key===`ArrowDown`?(n+1)%t.length:(n-1+t.length)%t.length]?.focus()};return(0,B.jsxs)(`aside`,{className:`cg-views`+(We?` is-collapsed`:``),"aria-label":`Customer views`,children:[(0,B.jsx)(`div`,{className:`cg-views-top`,children:(0,B.jsx)(`button`,{type:`button`,className:`cg-rail-toggle`,"aria-label":We?`Expand views`:`Minimize views`,"aria-expanded":!We,title:We?`Expand views`:`Minimize views`,onClick:Ke,children:(0,B.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M2.5 4.4h11M2.5 8h11M2.5 11.6h11`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`})})})}),(0,B.jsx)(`div`,{className:`cg-sr-only`,"aria-live":`polite`,children:n===`saving`?`Saving changes…`:`All changes saved`}),(0,B.jsx)(`div`,{className:`cg-create-new`,children:(0,B.jsxs)(`button`,{type:`button`,className:`cg-link-btn cg-create-btn`,"aria-haspopup":`menu`,"aria-expanded":!!O,onClick:e=>k(t=>t?null:e.currentTarget),children:[(0,B.jsx)(`span`,{className:`cg-create-icon`,"aria-hidden":`true`,children:`+`}),(0,B.jsx)(`span`,{className:`cg-create-label`,children:`Create new…`})]})}),(0,B.jsxs)(`div`,{className:`cg-find-view`,children:[(0,B.jsxs)(`svg`,{className:`cg-find-view-icon`,width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,B.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.4`,stroke:`currentColor`,strokeWidth:`1.35`}),(0,B.jsx)(`path`,{d:`m10.4 10.4 3.1 3.1`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`})]}),(0,B.jsx)(`input`,{type:`text`,value:He,placeholder:`Find a view`,"aria-label":`Find a view`,onChange:e=>Ue(e.target.value),onKeyDown:e=>{e.key===`Escape`&&Ue(``)}})]}),E&&(0,B.jsxs)(`div`,{className:`cg-view-create cg-create-form`,children:[(0,B.jsxs)(`label`,{htmlFor:`cg-new-view`,children:[`New `,Rf[E].toLowerCase(),` view`]}),(0,B.jsx)(`input`,{id:`cg-new-view`,className:`cg-input`,autoFocus:!0,value:A,placeholder:`e.g. Florida at risk`,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`Enter`&&tt(),e.key===`Escape`&&D(null)}}),(0,B.jsxs)(`div`,{className:`cg-perm`,role:`radiogroup`,"aria-label":`Who can edit this view`,children:[(0,B.jsx)(`span`,{className:`cg-perm-title`,children:`Who can edit`}),Dd.map(e=>(0,B.jsxs)(`label`,{className:`cg-radio-row cg-perm-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-view-perm`,checked:M===e,onChange:()=>ee(e)}),(0,B.jsxs)(`span`,{className:`cg-perm-label`,children:[Lee[e],(0,B.jsx)(`span`,{className:`cg-perm-blurb`,children:Ree[e]})]})]},e)),M===`users`&&(0,B.jsxs)(`div`,{className:`cg-perm-users`,children:[T.length===0?(0,B.jsx)(`span`,{className:`cg-perm-empty`,children:`No other accounts to pick — this will save as Personal.`}):T.map(e=>(0,B.jsxs)(`label`,{className:`cg-perm-user`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:N.includes(e),onChange:t=>te(n=>t.target.checked?[...n,e].slice(0,50):n.filter(t=>t!==e))}),(0,B.jsx)(`span`,{children:e})]},e)),T.length>0&&N.length===0&&(0,B.jsx)(`span`,{className:`cg-perm-empty`,children:`Pick at least one person, or this saves as Personal.`})]})]}),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,onClick:tt,disabled:!A.trim(),children:`Create`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:()=>D(null),children:`Cancel`})]})]}),Ye&&g&&Ee&&(0,B.jsxs)(`div`,{className:`cg-view-create cg-create-form cg-fold-form`,children:[(0,B.jsx)(`label`,{htmlFor:`cg-new-folder`,children:`New folder`}),(0,B.jsx)(`input`,{id:`cg-new-folder`,className:`cg-input`,autoFocus:!0,value:Oe,placeholder:`Folder name`,onChange:e=>ke(e.target.value),onKeyDown:e=>{e.key===`Enter`&&nt(),e.key===`Escape`&&De(!1)}}),(0,B.jsxs)(`div`,{className:`cg-fold-pick`,role:`group`,"aria-label":`Folder icon`,children:[(0,B.jsx)(`div`,{className:`cg-fold-pick-row`,children:kd.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cg-fold-swatch`+(Ae.shape===e?` is-on`:``),"aria-pressed":Ae.shape===e,"aria-label":Ite[e],title:Ite[e],onClick:()=>je(t=>({...t,shape:e})),children:(0,B.jsx)(Up,{icon:{shape:e,tone:Ae.tone},size:15})},e))}),(0,B.jsx)(`div`,{className:`cg-fold-pick-row`,children:Ad.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cg-fold-swatch`+(Ae.tone===e?` is-on`:``),"aria-pressed":Ae.tone===e,"aria-label":Fte[e],title:Fte[e],onClick:()=>je(t=>({...t,tone:e})),children:(0,B.jsx)(Up,{icon:{shape:Ae.shape,tone:e},size:15})},e))})]}),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,onClick:nt,disabled:!Oe.trim(),children:`Create`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:()=>De(!1),children:`Cancel`})]})]}),O&&(0,B.jsxs)(Pp,{anchor:O,className:`cg-view-menu cg-create-flyout`,placement:`right-start`,role:`menu`,ariaLabel:`Create new`,onDismiss:()=>k(null),onKeyDown:it,dataKind:`create-new`,children:[Lte.map(e=>(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`cg-create-row`,onClick:()=>I(e),children:[(0,B.jsx)(Rp,{mode:e,tone:Rte[e],size:16}),(0,B.jsx)(`span`,{children:Rf[e]})]},e)),Ye&&g&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`cg-menu-sep`,role:`separator`,"aria-hidden":!0}),(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`cg-create-row`,onClick:()=>rt(),children:[(0,B.jsx)(Up,{size:16}),(0,B.jsx)(`span`,{children:`Folder`})]})]})]}),(0,B.jsx)(`div`,{className:`cg-view-list cg-views-scroll`,children:Xe.map(e=>{let n=e.folder?.id??null;if(qe&&e.folder&&e.items.length===0)return null;let i=n===null,o=n!=null&&be.has(n);return(0,B.jsxs)(`div`,{className:(i?`cg-fold-root`:`cg-fold`)+(Be===(n??`__root__`)?` is-drop`:``),...$e(n),children:[e.folder&&(0,B.jsxs)(`div`,{className:`cg-fold-head`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`cg-fold-toggle`,"aria-expanded":!o,onClick:()=>xe(t=>{let n=new Set(t);return n.has(e.folder.id)?n.delete(e.folder.id):n.add(e.folder.id),n}),children:[(0,B.jsx)(`span`,{className:`cg-fold-chev`+(o?` is-shut`:``),"aria-hidden":!0,children:`▾`}),(0,B.jsx)(Up,{icon:e.folder.icon,size:16}),we===e.folder.id?(0,B.jsx)(`input`,{className:`cg-input cg-fold-rename`,autoFocus:!0,defaultValue:e.folder.name,onClick:e=>e.stopPropagation(),onBlur:t=>{let n=t.target.value.trim();n&&n!==e.folder.name&&_?.(e.folder.id,n),Te(null)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&Te(null)}}):(0,B.jsx)(`span`,{className:`cg-fold-name`,children:e.folder.name}),(0,B.jsx)(`span`,{className:`cg-fold-count`,children:e.items.length})]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-view-more`,"aria-label":`Actions for folder ${e.folder.name}`,"aria-haspopup":`menu`,onClick:t=>Ce(n=>n?.id===e.folder.id?null:{id:e.folder.id,anchor:t.currentTarget}),children:`···`})]}),!o&&e.items.map(e=>{let n=e.id===t,i=re===e.id,o=wd(e);return(0,B.jsxs)(`div`,{className:`cg-view-row`+(n?` is-active`:``)+(e.config?.cohortLock?` cg-view-lockset`:``),draggable:Ye&&!i&&Od(e,C),onDragStart:t=>t.dataTransfer.setData(`text/plain`,e.id),children:[i?(0,B.jsx)(`input`,{className:`cg-view-rename cg-input`,autoFocus:!0,defaultValue:e.name,onBlur:t=>{let n=t.target.value.trim();n&&n!==e.name&&a(e.id,n),F(null)},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&F(null)}}):(0,B.jsxs)(`button`,{type:`button`,className:`cg-view-main`,onClick:()=>r(e.id),title:e.note?`${e.name} — ${e.note}`:e.name,children:[(0,B.jsx)(Rp,{mode:o,tone:Rte[o],size:16}),(0,B.jsxs)(`span`,{className:`cg-view-text`,children:[(0,B.jsx)(`span`,{className:`cg-view-name`,children:e.name}),e.note&&(0,B.jsx)(`span`,{className:`cg-view-desc`,children:e.note})]}),(e.kind===`locked`||Td(e))&&(0,B.jsx)(`span`,{className:`cg-view-lock`,role:`img`,"aria-label":e.kind===`locked`?`${e.name}, a locked view`:`${Rf[o]} view, locked`,title:e.kind===`locked`?`Locked — this view shows only the records locked into it. Filters, sorts and columns still narrow within them.`+(Td(e)?` It also stays a ${Rf[o].toLowerCase()}.`:``):`Locked — this view stays a ${Rf[o].toLowerCase()}. Filters, sorts and columns are still editable.`,children:(0,B.jsx)(Hp,{})})]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-view-more`,"aria-label":`Actions for ${e.name}`,"aria-haspopup":`menu`,"aria-expanded":ne?.viewId===e.id,onClick:t=>P(n=>n?.viewId===e.id?null:{viewId:e.id,anchor:t.currentTarget}),children:`···`})]},e.id)}),e.folder&&!o&&e.items.length===0&&(0,B.jsx)(`div`,{className:`cg-fold-empty`,children:`Empty — drag a view here.`})]},n??`__root__`)})}),Se&&Ze&&(0,B.jsxs)(Pp,{anchor:Se.anchor,className:`cg-view-menu`,placement:`bottom-end`,role:`menu`,ariaLabel:`Actions for folder ${Ze.name}`,onDismiss:()=>{Ce(null),Ne(null)},dataKind:`folder-menu`,children:[(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:`cg-menu-item`,onClick:()=>{Te(Ze.id),Ce(null)},children:`Rename`}),x&&S&&(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:`cg-menu-item`,onClick:()=>{Fe(Ze.id),Le(Se.anchor),ze(f?`${Ze.name} · ${f}`:Ze.name),Ce(null)},children:`Add to cohort…`}),y&&(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:`cg-menu-item`,onClick:()=>{y(Ze.id),Ce(null)},children:`Duplicate folder and its views`}),v&&(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:`cg-menu-item cg-menu-item--danger`+(Me===Ze.id?` is-armed`:``),onClick:()=>{if(Me!==Ze.id){Ne(Ze.id);return}v(Ze.id),Ne(null),Ce(null)},children:Me===Ze.id?`Delete folder? Its views move to the top level.`:`Delete folder`})]}),ue&&d&&(()=>{let t=e.find(e=>e.id===ue.viewId)?.config?.cohortLock;return(0,B.jsxs)(Pp,{anchor:ue.anchor,className:`cg-pop cg-lock-pop`,placement:`bottom-start`,role:`dialog`,ariaLabel:`Lock this view to a locked view`,onDismiss:()=>de(null),dataKind:`view-cohort-lock`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Lock to a locked view`}),(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`This view can then only ever show the records locked into the view you pick. Filters still narrow within it, and the lock cannot be removed as a condition.`}),(l??[]).map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cg-pick-row`+(e.id===t?` is-on`:``),onClick:()=>{d(ue.viewId,e.id),de(null)},children:e.name},e.id)),t&&(0,B.jsx)(`button`,{type:`button`,className:`cg-pick-row cg-lock-clear`,onClick:()=>{d(ue.viewId,null),de(null)},children:`Unlock — show the whole table again`})]})})(),Pe&&Ie&&Qe&&S&&(0,B.jsxs)(Pp,{anchor:Ie??void 0,className:`cg-pop cg-fold-addpop`,placement:`bottom-start`,role:`dialog`,ariaLabel:`Add this folder's customers to a locked view`,onDismiss:()=>Fe(null),dataKind:`folder-add-to-list`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Add to cohort`}),(0,B.jsxs)(`div`,{className:`cg-pop-note`,children:[Qe.pids.length.toLocaleString(),` customer`,Qe.pids.length===1?``:`s`,` from `,Qe.counted.toLocaleString(),` `,`view`,Qe.counted===1?``:`s`,` in this folder, counted once each.`]}),Qe.skipped.length>0&&(0,B.jsxs)(`div`,{className:`cg-pop-note cg-fold-skipped`,children:[`Not included:`,Qe.skipped.map(e=>(0,B.jsxs)(`span`,{className:`cg-fold-skip`,children:[e.name,` — `,e.why]},e.name))]}),(l??[]).map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cg-pick-row`,onClick:()=>{S(Pe,e.id,e.name),Fe(null)},children:e.name},e.id)),(0,B.jsxs)(`div`,{className:`cg-view-create`,children:[(0,B.jsx)(`label`,{htmlFor:`cg-fold-new-list`,children:`Lock records into a new view`}),(0,B.jsx)(`input`,{id:`cg-fold-new-list`,className:`cg-input`,"data-overlay-autofocus":!0,value:Re,onChange:e=>ze(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Re.trim()&&(S(Pe,``,Re.trim()),Fe(null))}}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:!Re.trim()||Qe.pids.length===0,onClick:()=>{S(Pe,``,Re.trim()),Fe(null)},children:`Create and add`})]})]}),ne&&ve&&(0,B.jsxs)(Pp,{anchor:ne.anchor,className:`cg-view-menu`,placement:`bottom-end`,role:`menu`,ariaLabel:`Actions for ${ve.name}`,onDismiss:()=>P(null),onKeyDown:it,dataKind:`saved-view-menu`,children:[p&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{he({viewId:ve.id,anchor:ne.anchor}),P(null)},children:(0,B.jsx)(Bp,{icon:`download`,text:`Export`})}),(0,B.jsx)(`div`,{className:`cg-menu-sep`,role:`separator`,"aria-hidden":!0})]}),ye&&(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{F(ve.id),P(null)},children:(0,B.jsx)(Bp,{icon:`rename`,text:`Rename`})}),ye&&(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{se(ve.note??``),ae({viewId:ve.id,anchor:ne.anchor}),P(null)},children:(0,B.jsx)(Bp,{icon:`description`,text:ve.note?`Edit description`:`Add description`})}),(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{s(ve.id),P(null)},children:(0,B.jsx)(Bp,{icon:`duplicate`,text:`Duplicate`})}),u&&(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{pe(f?`${ve.name} · ${f}`:ve.name),le({viewId:ve.id,anchor:ne.anchor}),P(null)},children:(0,B.jsx)(Bp,{icon:`cohortAdd`,text:`Add to locked view`})}),d&&l.length>0&&ye&&ve.kind!==`locked`&&(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{de({viewId:ve.id,anchor:ne.anchor}),P(null)},children:(0,B.jsx)(Bp,{icon:`permissions`,text:ve.config?.cohortLock?`Change the lock…`:`Lock to a locked view…`})}),w&&ve.kind!==`system`&&ye&&Ed(ve,C)&&(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{w(ve.id,!Td(ve)),P(null)},children:(0,B.jsx)(Bp,{icon:Td(ve)?`unlock`:(0,B.jsx)(Lp,{mode:wd(ve),size:16}),text:Td(ve)?`Unlock view`:`Lock as ${Rf[wd(ve)]}`})}),!Cd(ve)&&ye&&(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,className:`is-danger`,onClick:()=>{c(ve.id),P(null)},children:(0,B.jsx)(Bp,{icon:`trash`,text:`Delete`})})]}),me&&ge&&p&&(0,B.jsxs)(Pp,{anchor:me.anchor,className:`cg-view-menu`,placement:`bottom-end`,role:`menu`,ariaLabel:`Export ${ge.name}`,onDismiss:()=>he(null),onKeyDown:it,dataKind:`view-export`,children:[(0,B.jsxs)(`div`,{className:`cg-pop-title cg-export-title`,children:[`Export `,ge.name]}),wUe.map(e=>(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{p(ge.id,e),he(null)},children:TUe[e]},e))]}),ce&&_e&&u&&(0,B.jsxs)(Pp,{anchor:ce.anchor,className:`cg-pop cg-add-list-pop`,placement:`bottom-end`,role:`dialog`,ariaLabel:`Add ${_e.name} to a locked view`,onDismiss:()=>le(null),dataKind:`add-to-list`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Add to cohort`}),(0,B.jsxs)(`div`,{className:`cg-pop-note`,children:[`Adds the customers `,(0,B.jsx)(`strong`,{children:_e.name}),` matches right now. The cohort stays fixed as the data changes.`]}),l.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cg-pick-row`,onClick:()=>{u(_e.id,e.id,e.name),le(null)},children:e.name},e.id)),(0,B.jsxs)(`div`,{className:`cg-view-create`,children:[(0,B.jsx)(`label`,{htmlFor:`cg-new-list`,children:`Lock records into a new view`}),(0,B.jsx)(`input`,{id:`cg-new-list`,className:`cg-input`,"data-overlay-autofocus":!0,value:fe,placeholder:`e.g. Q3 call plan`,onChange:e=>pe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&fe.trim()&&(u(_e.id,``,fe.trim()),le(null))}}),(0,B.jsx)(`div`,{className:`cg-form-actions`,children:(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:!fe.trim(),onClick:()=>{u(_e.id,``,fe.trim()),le(null)},children:`Create and add`})})]})]}),ie&&et&&(0,B.jsxs)(Pp,{anchor:ie.anchor,className:`cg-pop cg-view-note-pop`,placement:`bottom-end`,role:`dialog`,ariaLabel:`Description for ${et.name}`,onDismiss:()=>ae(null),dataKind:`saved-view-note`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Description`}),(0,B.jsxs)(`label`,{className:`cg-column-note`,children:[(0,B.jsx)(`span`,{children:`Shown under this view's name in the list.`}),(0,B.jsx)(`textarea`,{"data-overlay-autofocus":!0,value:oe,maxLength:2e3,placeholder:`What is this list for?…`,onChange:e=>se(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:oe===(et.note??``),onClick:()=>{o(et.id,oe),ae(null)},children:`Save description`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:()=>ae(null),children:`Cancel`})]})]})]})}var w7=30,GUe={ABS:[1,1],ROUND:[1,2],ROUNDUP:[1,2],ROUNDDOWN:[1,2],INT:[1,1],MOD:[2,2],SQRT:[1,1],POWER:[2,2],EXP:[1,1],LN:[1,1],SUM:[1,w7],AVERAGE:[1,w7],COUNT:[1,w7],COUNTA:[1,w7],MIN:[1,w7],MAX:[1,w7],IF:[2,3],AND:[1,w7],OR:[1,w7],NOT:[1,1],IFERROR:[2,2],ISBLANK:[1,1],CONCATENATE:[1,w7],LEFT:[1,2],RIGHT:[1,2],MID:[3,3],LEN:[1,1],TRIM:[1,1],UPPER:[1,1],LOWER:[1,1],PROPER:[1,1],VALUE:[1,1],TEXT:[2,2],TODAY:[0,0],YEAR:[1,1],MONTH:[1,1],DAY:[1,1],DAYS:[2,2]},KUe={CONCAT:`CONCATENATE`},qUe=new Set([`<`,`<=`,`>`,`>=`,`=`,`!=`]);function JUe(e){let t=[],n=0;for(;n=e.length)return`a text value is missing its closing quote`;if(e[r]===`"`){if(e[r+1]===`"`){i+=`"`,r+=2;continue}break}i+=e[r],r+=1}t.push({t:`str`,v:i}),n=r+1;continue}if(/[0-9]/.test(r)||r===`.`&&/[0-9]/.test(e[n+1]??``)){let r=/^(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)/.exec(e.slice(n));if(!r||/^[0-9.]/.test(e[n+r[0].length]??``))return`unreadable number at "${e.slice(n,n+8)}"`;t.push({t:`num`,v:Number(r[0])}),n+=r[0].length;continue}if(/[A-Za-z_]/.test(r)){let r=/^[A-Za-z_][A-Za-z0-9_]*/.exec(e.slice(n));t.push({t:`ident`,v:r[0]}),n+=r[0].length;continue}let i=e.slice(n,n+2);if(i===`<=`||i===`>=`||i===`!=`||i===`==`||i===`<>`){t.push({t:`op`,v:i===`==`?`=`:i===`<>`?`!=`:i}),n+=2;continue}if(`+-*/^&(),<>=`.includes(r)){t.push({t:`op`,v:r}),n+=1;continue}return`unexpected character "${r}"`}return t}function T7(e){if(typeof e!=`string`||e.trim()===``)return{ok:!1,error:`the formula is empty`};if(e.length>500)return{ok:!1,error:`formula longer than 500 characters`};let t=JUe(e);if(typeof t==`string`)return{ok:!1,error:t};if(t.length===0)return{ok:!1,error:`the formula is empty`};if(t.length>200)return{ok:!1,error:`formula has more than 200 tokens`};let n=0,r=()=>t[n],i=e=>{let r=t[n];return r?.t===`op`&&r.v===e},a=null,o=e=>(a===null&&(a=e),null);function s(e){if(e>24)return o(`formula is nested too deeply`);let t=c(e);if(!t)return null;let i=r();if(i?.t===`op`&&qUe.has(i.v)){n+=1;let a=c(e);if(!a)return null;let s=r();return s?.t===`op`&&qUe.has(s.v)?o(`comparisons cannot be chained (a < b < c)`):{t:`cmp`,op:i.v,l:t,r:a}}return t}function c(e){let t=l(e);if(!t)return null;for(;i(`&`);){n+=1;let r=l(e);if(!r)return null;t={t:`bin`,op:`&`,l:t,r}}return t}function l(e){let t=u(e);if(!t)return null;for(;;)if(i(`+`)||i(`-`)){let i=r().v;n+=1;let a=u(e);if(!a)return null;t={t:`bin`,op:i,l:t,r:a}}else return t}function u(e){let t=d(e);if(!t)return null;for(;;)if(i(`*`)||i(`/`)){let i=r().v;n+=1;let a=d(e);if(!a)return null;t={t:`bin`,op:i,l:t,r:a}}else return t}function d(e){if(e>24)return o(`formula is nested too deeply`);let t=f(e);if(!t)return null;if(i(`^`)){n+=1;let r=d(e+1);return r?{t:`bin`,op:`^`,l:t,r}:null}return t}function f(e){if(e>24)return o(`formula is nested too deeply`);if(i(`-`)){n+=1;let t=f(e+1);return t?{t:`neg`,e:t}:null}return p(e)}function p(e){if(e>24)return o(`formula is nested too deeply`);let t=r();if(!t)return o(`the formula ends unexpectedly`);if(t.t===`num`)return n+=1,{t:`num`,v:t.v};if(t.t===`str`)return n+=1,{t:`str`,v:t.v};if(t.t===`ref`)return n+=1,{t:`ref`,k:t.k};if(t.t===`op`&&t.v===`(`){n+=1;let t=s(e+1);return t?i(`)`)?(n+=1,t):o(`missing closing parenthesis`):null}if(t.t===`ident`){let r=t.v.toUpperCase();if(r===`TRUE`||r===`FALSE`)return n+=1,{t:`bool`,v:r===`TRUE`};let a=KUe[r]??r;if(!(a in GUe))return o(`unknown function ${r} — see the formula help for what is available`);if(n+=1,!i(`(`))return o(`${a} must be called with parentheses: ${a}(…)`);n+=1;let c=[];if(!i(`)`))for(;;){let t=s(e+1);if(!t)return null;if(c.push(t),i(`,`)){n+=1;continue}break}if(!i(`)`))return o(`missing closing parenthesis on ${a}(…)`);n+=1;let[l,u]=GUe[a];return c.lengthu?o(l===u?`${a} takes exactly ${l} argument${l===1?``:`s`}`:`${a} takes ${l} to ${u} arguments`):{t:`call`,fn:a,args:c}}return o(`unexpected "${t.t===`op`?t.v:String(t.v)}"`)}let m=s(1);if(!m)return{ok:!1,error:a??`could not parse the formula`};if(n!==t.length){let e=t[n];return{ok:!1,error:`unexpected "${e.t===`op`||e.t===`ident`?e.v:e.t===`ref`?`{${e.k}}`:String(e.v)}" after the formula`}}return{ok:!0,ast:m,refs:YUe(m)}}function YUe(e){let t=[],n=e=>{switch(e.t){case`ref`:t.includes(e.k)||t.push(e.k);return;case`neg`:n(e.e);return;case`bin`:case`cmp`:n(e.l),n(e.r);return;case`call`:e.args.forEach(n);return;default:return}};return n(e),t}function E7(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(e==null)return null;if(typeof e==`string`){let t=e.trim();if(t===``)return null;let n=Number(t);return Number.isFinite(n)?n:null}return null}function D7(e){return typeof e==`number`&&Number.isFinite(e)?e:typeof e==`string`?E7(e):null}function O7(e){return e==null?``:typeof e==`string`?e:typeof e==`boolean`?e?`TRUE`:`FALSE`:XUe(e)}function XUe(e){return String(Number.isInteger(e)?e:Number(e.toFixed(10)))}function ZUe(e,t){if(!Number.isInteger(t)||t<-10||t>10)return null;let n=10**t,r=Math.sign(e)*Math.round(Math.abs(e)*n)/n;return Number.isFinite(r)?r:null}function k7(e){if(typeof e!=`string`)return null;let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]);return r<1||r>12||i<1||i>31?null:{y:n,m:r,d:i}}function QUe(e){return Date.UTC(e.y,e.m-1,e.d)/864e5}function $Ue(e,t){let n=/^(\$?)(#,##0|0)(?:\.(0+))?(%?)$/.exec(t.trim());if(!n)return null;let[,r,i,a,o]=n,s=e;o===`%`&&(s*=100);let c=a?a.length:0,l=s<0||Object.is(s,-0)?`-`:``,[u,d]=Math.abs(s).toFixed(c).split(`.`);return i===`#,##0`&&(u=u.replace(/\B(?=(\d{3})+(?!\d))/g,`,`)),l+r+u+(c?`.`+d:``)+(o===`%`?`%`:``)}function A7(e,t){let n=[];for(let r of e){let e=t(r);if(e==null)continue;let i=D7(e);i!=null&&n.push(i)}return n}function eWe(e,t,n){let r=e=>eWe(e,t,n);switch(e.t){case`num`:return e.v;case`str`:return e.v;case`bool`:return e.v;case`ref`:{let n=t(e.k);return typeof n==`string`||typeof n==`number`&&Number.isFinite(n)?n:null}case`neg`:{let t=D7(r(e.e));return t==null?null:-t}case`bin`:{if(e.op===`&`)return O7(r(e.l))+O7(r(e.r));let t=D7(r(e.l));if(t==null)return null;let n=D7(r(e.r));if(n==null)return null;let i;switch(e.op){case`+`:i=t+n;break;case`-`:i=t-n;break;case`*`:i=t*n;break;case`/`:if(n===0)return null;i=t/n;break;case`^`:i=t**+n;break}return Number.isFinite(i)?i:null}case`cmp`:{let t=r(e.l),n=r(e.r),i=typeof t==`number`?t:null,a=typeof n==`number`?n:null,o=i??(typeof t==`string`?E7(t):null),s=a??(typeof n==`string`?E7(n):null);if(o!=null&&s!=null)return tWe(e.op,o,s);if(typeof t==`string`&&typeof n==`string`){let r=t.trim().toLowerCase(),i=n.trim().toLowerCase();return r===``||i===``?null:tWe(e.op,ri),0)}return null}case`call`:switch(e.fn){case`ABS`:{let t=D7(r(e.args[0]));return t==null?null:Math.abs(t)}case`ROUND`:case`ROUNDUP`:case`ROUNDDOWN`:{let t=D7(r(e.args[0]));if(t==null)return null;let n=e.args.length>1?D7(r(e.args[1])):0;if(n==null||!Number.isInteger(n)||n<-10||n>10)return null;if(e.fn===`ROUND`)return ZUe(t,n);let i=10**n,a=t*i,o=(e.fn===`ROUNDUP`?Math.sign(a)*Math.ceil(Math.abs(a)):Math.sign(a)*Math.floor(Math.abs(a)))/i;return Number.isFinite(o)?o:null}case`INT`:{let t=D7(r(e.args[0]));return t==null?null:Math.floor(t)}case`MOD`:{let t=D7(r(e.args[0])),n=D7(r(e.args[1]));return t==null||n==null||n===0?null:t-n*Math.floor(t/n)}case`SQRT`:{let t=D7(r(e.args[0]));return t==null||t<0?null:Math.sqrt(t)}case`POWER`:{let t=D7(r(e.args[0])),n=D7(r(e.args[1]));if(t==null||n==null)return null;let i=t**+n;return Number.isFinite(i)?i:null}case`EXP`:{let t=D7(r(e.args[0]));if(t==null)return null;let n=Math.exp(t);return Number.isFinite(n)?n:null}case`LN`:{let t=D7(r(e.args[0]));return t==null||t<=0?null:Math.log(t)}case`SUM`:return A7(e.args,r).reduce((e,t)=>e+t,0);case`AVERAGE`:{let t=A7(e.args,r);return t.length===0?null:t.reduce((e,t)=>e+t,0)/t.length}case`COUNT`:return A7(e.args,r).length;case`COUNTA`:{let t=0;for(let n of e.args){let e=r(n);e!=null&&e!==``&&(t+=1)}return t}case`MIN`:case`MAX`:{let t=A7(e.args,r);return t.length===0?null:e.fn===`MIN`?Math.min(...t):Math.max(...t)}case`IF`:{let t=r(e.args[0]);return typeof t==`boolean`?t?r(e.args[1]):e.args.length>2?r(e.args[2]):null:null}case`AND`:case`OR`:for(let t of e.args){let n=r(t);if(typeof n!=`boolean`)return null;if(e.fn===`AND`&&!n)return!1;if(e.fn===`OR`&&n)return!0}return e.fn===`AND`;case`NOT`:{let t=r(e.args[0]);return typeof t==`boolean`?!t:null}case`IFERROR`:return r(e.args[0])??r(e.args[1]);case`ISBLANK`:{let t=r(e.args[0]);return t==null||t===``}case`CONCATENATE`:return e.args.map(e=>O7(r(e))).join(``);case`LEFT`:case`RIGHT`:{let t=O7(r(e.args[0])),n=e.args.length>1?D7(r(e.args[1])):1;return n==null||!Number.isInteger(n)||n<0?null:e.fn===`LEFT`?t.slice(0,n):n===0?``:t.slice(-n)}case`MID`:{let t=O7(r(e.args[0])),n=D7(r(e.args[1])),i=D7(r(e.args[2]));return n==null||i==null||!Number.isInteger(n)||!Number.isInteger(i)||n<1||i<0?null:t.slice(n-1,n-1+i)}case`LEN`:return O7(r(e.args[0])).length;case`TRIM`:return O7(r(e.args[0])).replace(/\s+/g,` `).trim();case`UPPER`:return O7(r(e.args[0])).toUpperCase();case`LOWER`:return O7(r(e.args[0])).toLowerCase();case`PROPER`:return O7(r(e.args[0])).replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase());case`VALUE`:return D7(r(e.args[0]));case`TEXT`:{let t=D7(r(e.args[0])),n=r(e.args[1]);return t==null||typeof n!=`string`?null:$Ue(t,n)}case`TODAY`:return typeof n.today==`string`&&k7(n.today)?n.today:null;case`YEAR`:case`MONTH`:case`DAY`:{let t=k7(r(e.args[0]));return t?e.fn===`YEAR`?t.y:e.fn===`MONTH`?t.m:t.d:null}case`DAYS`:{let t=k7(r(e.args[0])),n=k7(r(e.args[1]));return!t||!n?null:Math.round(QUe(t)-QUe(n))}}return null;default:return null}}function tWe(e,t,n){switch(e){case`<`:return t`:return t>n;case`>=`:return t>=n;case`=`:return t===n;case`!=`:return t!==n}}function nWe(e,t,n={}){try{let r=eWe(e,t,n);return typeof r==`number`?Number.isFinite(r)?r:null:typeof r==`string`?r:typeof r==`boolean`?r?`TRUE`:`FALSE`:null}catch{return null}}function rWe(e){let t=new Map;for(let[n,r]of e){let i=T7(r);t.set(n,i.ok?i.refs.filter(t=>e.has(t)&&t!==n):[])}let n=[],r=new Map,i=new Set,a=(e,o)=>{let s=r.get(e);if(s===2)return!i.has(e);if(s===1){for(let t=o.lastIndexOf(e);t({value:e,label:zf[e]}));function N7(e){return e===`select`||e===`multiselect`}var P7=[`Not started`,`In progress`,`Blocked`,`Done`],iWe=0;function F7(){return iWe+=1,`choice-${iWe}`}function I7(e,t=void 0){return e.map(e=>({id:F7(),label:e,color:rp(t?.[e])??rp(dp(e))}))}function L7(e,t){let n=e.map(e=>t===`multiselect`?e.label.replace(/,/g,` `):e.label),r=pee(n.join(` -`)),i=new Map;e.forEach((e,t)=>{let r=n[t].trim();r&&!i.has(r.toLowerCase())&&i.set(r.toLowerCase(),e)});let a={};for(let e of r){let t=rp(i.get(e.toLowerCase())?.color);t&&t!==rp(dp(e))&&(a[e]=t)}return{options:r,colors:a}}function aWe(e,t){return e.map(e=>`${e}\u0000${rp(t?Object.entries(t).find(([t])=>t.trim().toLowerCase()===e.toLowerCase())?.[1]:void 0)??rp(dp(e))}`).join(``)}function oWe({value:e,disabled:t,label:n,onPick:r}){let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null),s=op(e);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{ref:o,type:`button`,className:`cg-option-color`,disabled:t,style:{background:s?.bg??rp(e)??`#FFFFFF`},"aria-label":`Colour for ${n}${s?` — ${s.label}`:``}`,"aria-haspopup":`dialog`,"aria-expanded":i,title:`Change option colour`,onClick:()=>a(e=>!e)}),i&&o.current&&(0,B.jsx)(Pp,{anchor:o.current,className:`cg-pop cg-swatch-pop`,onDismiss:()=>a(!1),role:`dialog`,ariaLabel:`Colour for ${n}`,dataKind:`option-colour`,children:(0,B.jsx)(`div`,{className:`cg-swatch-grid`,children:ap.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cg-swatch`+(s?.id===e.id?` is-on`:``),style:{background:e.bg,color:e.fg},"aria-label":e.label,"aria-pressed":s?.id===e.id,title:e.label,onClick:()=>{r(e.bg),a(!1)},children:s?.id===e.id&&(0,B.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`m3.5 8.5 3 3 6-6.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})},e.id))})})]})}function R7({idPrefix:e,drafts:t,onDrafts:n,colorCode:r,onColorCode:i,type:a}){let o=(e,r)=>n(t.map(t=>t.id===e?{...t,...r}:t)),s=L7(t,a);return(0,B.jsxs)(`div`,{className:`cg-options-editor`,children:[(0,B.jsxs)(`div`,{className:`cg-options-head`,children:[(0,B.jsx)(`strong`,{children:`Options`}),(0,B.jsxs)(`label`,{className:`cg-option-toggle`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),(0,B.jsx)(`span`,{children:`Color-code options`})]})]}),(0,B.jsx)(`div`,{className:`cg-option-list`,children:t.map((i,s)=>(0,B.jsxs)(`div`,{className:`cg-option-row`,children:[(0,B.jsx)(oWe,{value:rp(i.color)??np[s%np.length].bg,disabled:!r,label:i.label||`option ${s+1}`,onPick:e=>o(i.id,{color:e})}),(0,B.jsx)(`input`,{id:`${e}-${i.id}`,className:`cg-input cg-option-name`,type:`text`,maxLength:120,value:i.label,placeholder:`Option name`,"aria-label":`Option ${s+1}`,onChange:e=>{let t=a===`multiselect`?e.target.value.replace(/,/g,` `):e.target.value;o(i.id,{label:t})},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),n([...t,{id:F7(),label:``,color:np[t.length%np.length].bg}]))}}),(0,B.jsx)(`button`,{type:`button`,className:`cg-option-remove`,"aria-label":`Remove ${i.label||`option ${s+1}`}`,title:`Remove option`,onClick:()=>n(t.filter(e=>e.id!==i.id)),children:(0,B.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})})})]},i.id))}),(0,B.jsx)(`button`,{type:`button`,className:`cg-option-add`,onClick:()=>n([...t,{id:F7(),label:``,color:np[t.length%np.length].bg}]),children:`Add option`}),(0,B.jsxs)(`span`,{className:`cg-field-hint`,children:[s.options.length,` option`,s.options.length===1?``:`s`,`.`,a===`multiselect`&&` Commas inside an option are not supported.`]})]})}function sWe({value:e,onPick:t,offerMeasure:n,only:r}){let[i,a]=(0,L.useState)(``),o=i.trim().toLowerCase(),s=[...r?M7.filter(e=>r.includes(e.value)):M7,...n?[{value:`measure`,label:`Metric`}]:[]].filter(e=>!o||e.label.toLowerCase().includes(o));return(0,B.jsxs)(`div`,{className:`cg-type-picker`,children:[(0,B.jsxs)(`div`,{className:`cg-type-search`,children:[(0,B.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:[(0,B.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.4`,stroke:`currentColor`,strokeWidth:`1.35`}),(0,B.jsx)(`path`,{d:`m10.4 10.4 3.1 3.1`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`})]}),(0,B.jsx)(`input`,{type:`text`,value:i,placeholder:`Find a field type`,"aria-label":`Find a field type`,onChange:e=>a(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`cg-type-list`,role:`listbox`,"aria-label":`Field type`,children:[s.map(n=>(0,B.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e===n.value,className:`cg-type-row`+(e===n.value?` is-on`:``),onClick:()=>t(n.value),children:[(0,B.jsx)(Ip,{type:n.value===`measure`?`currency`:n.value,size:16}),(0,B.jsx)(`span`,{className:`cg-type-label`,children:n.label}),e===n.value&&(0,B.jsx)(`svg`,{className:`cg-type-check`,width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`m3.5 8.5 3 3 6-6.5`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})})]},n.value)),s.length===0&&(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`No matching type.`})]})]})}var cWe=`new:`,lWe=$u.filter(e=>e!==`formula`&&e!==`created_time`),uWe={kind:`ltm`};function z7({title:e,sub:t,onClose:n}){return(0,B.jsxs)(`div`,{className:`cg-column-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`cg-column-title`,children:e}),t&&(0,B.jsx)(`div`,{className:`cg-column-type`,children:t})]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-icon-btn`,onClick:n,"aria-label":`Close column menu`,children:`×`})]})}function dWe({value:e,onValue:t}){return(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Scope`}),(0,B.jsxs)(`select`,{className:`cg-select cg-scope-select`,value:e,"aria-label":`Field scope`,onChange:e=>t(e.target.value),children:[(0,B.jsx)(`option`,{value:`cohort`,disabled:e!==`cohort`,children:`The cohort table only (retired)`}),(0,B.jsx)(`option`,{value:`global`,children:`All customer tables`})]})]})}function B7({kind:e,fields:t,formulaText:n,onFormulaText:r,formulaError:i,maxValue:a,onMaxValue:o,idPrefix:s,showFormulaHelp:c=!0}){if(e===`formula`){let e=t.filter(e=>e.key!==`__proto__`);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Formula`}),(0,B.jsx)(`textarea`,{className:`cg-input cg-formula-editor`,rows:3,value:n,placeholder:`MAX(0, {revenue_ly} - {revenue_ytd})`,"aria-label":`Formula`,onChange:e=>r(e.target.value)})]}),(0,B.jsx)(`div`,{className:`cg-cond-line cg-formula-insert`,children:(0,B.jsx)(Kp,{ariaLabel:`Insert a field reference`,placeholder:`Insert a field reference…`,value:void 0,keepOpen:!0,onChange:e=>r((n+` {`+e+`}`).trimStart()),fields:e.map(e=>({key:e.key,label:e.label,type:e.type}))})}),n.trim()!==``&&i?(0,B.jsx)(`div`,{className:`cg-field-hint cg-formula-error`,children:i}):c?(0,B.jsxs)(`div`,{className:`cg-field-hint`,children:[`Excel-style: numbers, text in quotes, `,`{field}`,` references, + − × ÷ ^ & ( ), IF · AND · OR · SUM · AVERAGE · COUNT · MIN · MAX · ROUND(UP/DOWN) · ABS · MOD · SQRT · CONCATENATE · LEFT · RIGHT · MID · LEN · TRIM · UPPER · LOWER · PROPER · TEXT · VALUE · TODAY · DAYS · YEAR · MONTH · DAY · IFERROR · ISBLANK. Errors show a blank cell.`]}):null]})}return e===`rating`?(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Number of stars`}),(0,B.jsx)(`input`,{id:`${s}-rating-max`,className:`cg-input cg-rating-max`,type:`number`,min:2,max:10,value:a,"aria-label":`Number of stars`,onChange:e=>{let t=Math.round(Number(e.target.value));o(Number.isFinite(t)?Math.max(2,Math.min(10,t)):5)}})]}):e===`created_time`?(0,B.jsx)(`div`,{className:`cg-field-hint`,children:`Read-only. When the record was created in the source system.`}):null}function fWe({state:e,field:t,fields:n,locked:r,viewer:i,sortedDir:a,isFiltered:o,isGrouped:s,groupable:c,onClose:l,onNote:u,onHide:d,onCreate:f,onChangeField:p,onCreateAndSwap:m,onRetype:h,onRename:g,onFormula:_,initialPosition:v,scopeChoice:y=!1,pinnedTo:b=!1,onPinTo:x,onUnpin:S,onPeriod:C,onDelete:w,onDuplicate:T,onPermissions:E,onFormat:D,onSort:O,onClearSort:k,onFilterBy:A,onClearFilter:j,onGroupByField:M,onClearGroup:ee,userOptions:N=[],measures:te=[]}){let[ne,P]=(0,L.useState)(`menu`),[re,F]=(0,L.useState)(t.note??``),[ie,ae]=(0,L.useState)(v??null),[oe,se]=(0,L.useState)(!1),[ce,le]=(0,L.useState)(``),[ue,de]=(0,L.useState)(!1),[fe,pe]=(0,L.useState)(`text`),[me,he]=(0,L.useState)(()=>I7(P7)),[ge,_e]=(0,L.useState)(!0),[ve,ye]=(0,L.useState)(te[0]?.key??``),[be,xe]=(0,L.useState)(uWe),[Se,Ce]=(0,L.useState)(``),[we,Te]=(0,L.useState)(5),[Ee,De]=(0,L.useState)(``),[Oe,ke]=(0,L.useState)(``),[Ae,je]=(0,L.useState)(()=>I7(P7)),[Me,Ne]=(0,L.useState)(!0),[Pe,Fe]=(0,L.useState)(``),[Ie,Le]=(0,L.useState)(5),[Re,ze]=(0,L.useState)(null),[Be,Ve]=(0,L.useState)(t.permissions?.edit??`everyone`),[He,Ue]=(0,L.useState)(()=>({...t.format??{}})),[We,Ge]=(0,L.useState)(`cohort`),[Ke,qe]=(0,L.useState)(t.label),[Je,Ye]=(0,L.useState)(t.type),[Xe,Ze]=(0,L.useState)(()=>I7(nd(t).length?nd(t):P7,t.optionColors)),[Qe,$e]=(0,L.useState)(t.colorCodeOptions!==!1),[et,tt]=(0,L.useState)(()=>rd(t)),[nt,I]=(0,L.useState)(()=>typeof t.formula==`string`?t.formula:``),rt=Ee.startsWith(cWe)?Ee.slice(4):null,it=L7(me,fe),at=it.options,ot=rt?L7(Ae,rt):{options:[],colors:{}},st=ot.options,ct=L7(Xe,Je),lt=ct.options,ut=(0,L.useMemo)(()=>new Set(n.filter(e=>e.type!==`formula`).map(e=>e.key)),[n]),dt=(0,L.useMemo)(()=>{let e=new Map;for(let t of n){if(t.type!==`formula`)continue;let n=typeof t.formula==`string`?t.formula:``;n&&e.set(t.key,n)}return e},[n]),ft=(0,L.useMemo)(()=>Se.trim()===``?{ok:!1,error:`Type a formula`,refs:[]}:j7(Se,ut,dt),[Se,ut,dt]),pt=(0,L.useMemo)(()=>Pe.trim()===``?{ok:!1,error:`Type a formula`,refs:[]}:j7(Pe,ut,dt),[Pe,ut,dt]),mt=te.find(e=>e.key===ve),ht=mt?`${mt.label} · ${Zu(be)}`:``,gt=fe===`measure`&&!ue&&!ce.trim()?ht:ce,_t=gt.trim()!==``&&(!N7(fe)||at.length>0)&&(fe!==`measure`||!!mt)&&(fe!==`formula`||ft.ok),vt=(e,t,n)=>{if(e===`formula`)return{formula:t.trim()};if(e===`rating`)return{max:n}},yt=(e,t,n)=>N7(e)?{colorCodeOptions:n,...Object.keys(t).length?{optionColors:t}:{}}:{},bt=e=>y?{...e??{},scope:We}:e,xt=()=>{let e=gt.trim();if(!(!e||!ie||!_t)){if(fe===`measure`){if(!mt)return;f(e,mt.type,ie===`end`?null:t.key,ie,void 0,{key:mt.key,window:be},bt(void 0)),l();return}f(e,fe,ie===`end`?null:t.key,ie,N7(fe)?at:void 0,void 0,bt({...vt(fe,Se,we),...yt(fe,it.colors,ge)})),l()}},St=rt!=null&&Oe.trim()!==``&&(!N7(rt)||st.length>0)&&(rt!==`formula`||pt.ok),Ct=()=>{!rt||!St||(m(Oe.trim(),rt,N7(rt)?st:void 0,bt({...vt(rt,Pe,Ie),...yt(rt,ot.colors,Me)})),l())},wt=Ke.trim(),Tt=!!g&&wt!==``&&wt!==t.label,Et=N7(Je)&<.join(` -`)!==nd(t).join(` -`),Dt=N7(Je)&&(Qe!==(t.colorCodeOptions!==!1)||aWe(lt,ct.colors)!==aWe(nd(t),t.optionColors)),Ot=Je===`rating`&&et!==rd(t),kt=h!=null&&(Je!==t.type||Et||Dt||Ot),At=!N7(Je)||lt.length>0,jt=(0,L.useMemo)(()=>nt.trim()===``?{ok:!1,error:`Type a formula`,refs:[]}:j7(nt,ut,dt,t.key),[nt,ut,dt,t.key]),Mt=!!_&&t.type===`formula`&&nt.trim()!==(typeof t.formula==`string`?t.formula.trim():``),Nt=kt&&!At||Mt&&!jt.ok,Pt=t.measure?Yu(t.measure.window):null,Ft=Re?Yu(Re):null,It=Ft!=null&&JSON.stringify(Ft)!==JSON.stringify(Pt),Lt=!!t.measure&&!!C,Rt=!Nt&&(Tt||kt||Mt||Lt&&It),zt=()=>{Rt&&(kt&&h?h(Je,N7(Je)?lt:void 0,{...Je===`rating`?{max:et}:{},...N7(Je)?{colorCodeOptions:Qe,...Object.keys(ct.colors).length?{optionColors:ct.colors}:{}}:{},...Tt?{label:wt}:{}}):Mt&&_?_(nt.trim(),Tt?wt:void 0):Tt&&g&&g(wt),Lt&&It&&Ft&&C(Ft),l())},Bt=n.filter(e=>e.key!==t.key),Vt=Bt.filter(e=>e.source===`odoo`&&!e.custom),Ht=Bt.filter(e=>!(e.source===`odoo`&&!e.custom)),Ut=t.measure?`Metric, read-only`:t.type===`formula`?`Formula field, computed`:t.type===`created_time`?`Created time, read-only`:t.derived?`Read-only, derived`:t.source===`odoo`?`Read-only source field`:`Editable overlay field`,Wt=t.scope===`cohort`?`${Ut} · this cohort only`:Ut,Gt=t.type===`int`||t.type===`currency`||t.type===`formula`?`number`:t.type===`date`||t.type===`created_time`?`date`:null;if(ie)return(0,B.jsxs)(Pp,{anchor:e.anchor,className:`cg-column-menu`,onDismiss:l,role:`dialog`,ariaLabel:ie===`end`?`Add field`:`Insert field ${ie} of ${t.label}`,initialFocus:`[data-overlay-autofocus]`,dataKind:`column-menu`,children:[(0,B.jsx)(z7,{title:ie===`end`?`Add field`:ie===`left`?`Insert field left`:`Insert field right`,sub:ie===`end`?`Added as the last column`:`Next to ${t.label}`,onClose:l}),(0,B.jsxs)(`div`,{className:`cg-column-create`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Name`}),(0,B.jsx)(`input`,{className:`cg-input`,autoFocus:!0,"data-overlay-autofocus":!0,value:gt,onChange:e=>{le(e.target.value),de(!0)},onKeyDown:e=>e.key===`Enter`&&xt()})]}),(0,B.jsxs)(`div`,{className:`cg-type-block`,children:[(0,B.jsx)(`span`,{className:`cg-type-title`,children:`Field type`}),(0,B.jsx)(sWe,{value:fe,onPick:pe,offerMeasure:te.length>0})]}),fe===`measure`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Number`}),(0,B.jsx)(Kp,{ariaLabel:`Number to summarise`,placeholder:`Choose a number…`,value:mt?ve:void 0,onChange:ye,fields:te.map(e=>({key:e.key,label:e.label,type:`measure`}))})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Period`}),(0,B.jsx)(`span`,{className:`cg-measure-window`,children:(0,B.jsx)(Yp,{window:be,onWindow:xe})})]}),(0,B.jsx)(`div`,{className:`cg-field-hint`,children:`A total, average or count over the period you choose — e.g. Sales, last 90 days. Computed for every customer, and read-only.`})]}),(0,B.jsx)(B7,{kind:fe,fields:n,formulaText:Se,onFormulaText:Ce,formulaError:ft.ok?null:ft.error??null,maxValue:we,onMaxValue:Te,idPrefix:`cg-create`}),N7(fe)&&(0,B.jsx)(R7,{idPrefix:`cg-create-option`,drafts:me,onDrafts:he,colorCode:ge,onColorCode:_e,type:fe}),fe===`user`&&(0,B.jsx)(`div`,{className:`cg-field-hint`,children:N.length?`${N.length} people can be assigned, from your user list.`:`No user list yet, so there is no one to assign.`}),y&&(0,B.jsx)(dWe,{value:We,onValue:Ge}),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:!_t,onClick:xt,children:`Create field`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:()=>v?l():ae(null),children:`Cancel`})]})]})]});if(ne===`edit`)return(0,B.jsxs)(Pp,{anchor:e.anchor,className:`cg-column-menu`,onDismiss:l,role:`dialog`,ariaLabel:`Edit field ${t.label}`,initialFocus:`[data-overlay-autofocus]`,dataKind:`column-menu`,children:[(0,B.jsx)(z7,{title:`Edit field`,sub:Wt,onClose:l}),(0,B.jsxs)(`div`,{className:`cg-column-create`,children:[g?(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Name`}),(0,B.jsx)(`input`,{className:`cg-input`,autoFocus:!0,"data-overlay-autofocus":!0,value:Ke,onChange:e=>qe(e.target.value),onKeyDown:e=>e.key===`Enter`&&zt()})]}):(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Name`}),(0,B.jsx)(`input`,{className:`cg-input`,value:t.label,disabled:!0,"aria-label":`Field name (read-only)`}),(0,B.jsx)(`span`,{className:`cg-field-hint`,children:`A source field keeps its name and type from the data source.`})]}),h&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`cg-type-block`,children:[(0,B.jsx)(`span`,{className:`cg-type-title`,children:`Field type`}),(0,B.jsx)(sWe,{value:Je,onPick:e=>Ye(e),offerMeasure:!1,only:lWe})]}),Je===`rating`&&(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Number of stars`}),(0,B.jsx)(`input`,{className:`cg-input cg-rating-max`,type:`number`,min:2,max:10,value:et,"aria-label":`Number of stars`,onChange:e=>{let t=Math.round(Number(e.target.value));tt(Number.isFinite(t)?Math.max(2,Math.min(10,t)):5)}})]}),N7(Je)&&(0,B.jsx)(R7,{idPrefix:`cg-edit-option`,drafts:Xe,onDrafts:Ze,colorCode:Qe,onColorCode:$e,type:Je}),Je!==t.type&&(0,B.jsxs)(`div`,{className:`cg-field-hint`,children:[`Changes `,t.label,` into a `,zf[Je].toLowerCase(),` field, keeping its name and its values as entered. Cells that cannot be read in the new type show blank.`]})]}),Lt&&(0,B.jsxs)(`label`,{className:`cg-edit-period`,children:[(0,B.jsx)(`span`,{children:`Period`}),(0,B.jsx)(`span`,{className:`cg-measure-window`,children:(0,B.jsx)(Yp,{window:Re??t.measure.window,onWindow:ze})}),(0,B.jsx)(`span`,{className:`cg-field-hint`,children:`The window this number is computed over, for every customer.`})]}),!h&&t.type===`formula`&&_&&(0,B.jsx)(B7,{kind:`formula`,fields:n,formulaText:nt,onFormulaText:I,formulaError:jt.ok?null:jt.error??null,maxValue:et,onMaxValue:tt,idPrefix:`cg-edit`,showFormulaHelp:!1}),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:!Rt,onClick:zt,children:`Save`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:()=>P(`menu`),children:`Back`})]}),!r&&Bt.length>0&&(0,B.jsxs)(`div`,{className:`cg-edit-swap`,children:[(0,B.jsx)(`span`,{className:`cg-type-title`,children:`Change field`}),(0,B.jsx)(`div`,{className:`cg-field-hint`,children:`Show a different field in this column — the current one is hidden, not lost.`}),(0,B.jsxs)(`div`,{className:`cg-column-swap`,children:[(0,B.jsx)(Kp,{className:`cg-swap-select`,ariaLabel:`Change this column to another field`,placeholder:`Choose a field…`,overlayAutofocus:!g,value:Ee||void 0,onChange:De,fields:[...Vt.map(e=>({key:e.key,label:e.label,type:e.type,group:`Pre-set fields`})),...Ht.map(e=>({key:e.key,label:e.label,type:e.type,group:`Your fields`})),...M7.map(e=>({key:cWe+e.value,label:e.label,type:e.value,group:`New field`}))]}),!rt&&(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:!Ee,onClick:()=>{p(Ee),l()},children:`Change`})]}),rt&&(0,B.jsxs)(`div`,{className:`cg-column-create cg-swap-create`,children:[(0,B.jsxs)(`label`,{children:[(0,B.jsxs)(`span`,{children:[`New `,zf[rt].toLowerCase(),` field`]}),(0,B.jsx)(`input`,{className:`cg-input`,autoFocus:!0,value:Oe,placeholder:`Field name`,onChange:e=>ke(e.target.value),onKeyDown:e=>e.key===`Enter`&&Ct()})]}),(0,B.jsx)(B7,{kind:rt,fields:n,formulaText:Pe,onFormulaText:Fe,formulaError:pt.ok?null:pt.error??null,maxValue:Ie,onMaxValue:Le,idPrefix:`cg-swap`}),N7(rt)&&(0,B.jsx)(R7,{idPrefix:`cg-swap-option`,drafts:Ae,onDrafts:je,colorCode:Me,onColorCode:Ne,type:rt}),rt===`user`&&(0,B.jsx)(`div`,{className:`cg-field-hint`,children:N.length?`${N.length} people can be assigned.`:`No user list was supplied by the host yet.`}),y&&(0,B.jsx)(dWe,{value:We,onValue:Ge}),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:!St,onClick:Ct,children:`Create and change`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:()=>De(``),children:`Cancel`})]})]})]})]})]});if(ne===`note`)return(0,B.jsxs)(Pp,{anchor:e.anchor,className:`cg-column-menu`,onDismiss:l,role:`dialog`,ariaLabel:`Edit description for ${t.label}`,initialFocus:`[data-overlay-autofocus]`,dataKind:`column-menu`,children:[(0,B.jsx)(z7,{title:`Edit field description`,sub:t.label,onClose:l}),(0,B.jsxs)(`div`,{className:`cg-column-create`,children:[t.description&&(0,B.jsxs)(`div`,{className:`cg-field-hint cg-desc-default`,children:[`Default description: `,t.description]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Your description`}),(0,B.jsx)(`textarea`,{className:`cg-input`,"data-overlay-autofocus":!0,autoFocus:!0,rows:4,value:re,placeholder:t.description?`Write your own to replace the default…`:`Explain how this field should be used…`,onChange:e=>F(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:re===(t.note??``),onClick:()=>{u(re),l()},children:`Save`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:()=>P(`menu`),children:`Back`})]})]})]});if(ne===`permissions`)return(0,B.jsxs)(Pp,{anchor:e.anchor,className:`cg-column-menu`,onDismiss:l,role:`dialog`,ariaLabel:`Edit permissions for ${t.label}`,initialFocus:`[data-overlay-autofocus]`,dataKind:`column-menu`,children:[(0,B.jsx)(z7,{title:`Edit field permissions`,sub:t.label,onClose:l}),(0,B.jsxs)(`div`,{className:`cg-column-create`,children:[(0,B.jsxs)(`div`,{className:`cg-field-hint`,children:[`Who can edit this field's values`,t.createdBy?` (created by ${t.createdBy})`:``,`.`]}),[[`everyone`,`Everyone`],[`creator`,`Only the creator`],[`admins`,`Only admins`]].map(([e,t])=>(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-perm`,"data-overlay-autofocus":e===`everyone`||void 0,checked:Be===e,onChange:()=>Ve(e)}),(0,B.jsx)(`span`,{children:t})]},e)),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:Be===(t.permissions?.edit??`everyone`),onClick:()=>{E?.(Be),l()},children:`Save`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:()=>P(`menu`),children:`Back`})]})]})]});if(ne===`format`&&Gt)return(0,B.jsxs)(Pp,{anchor:e.anchor,className:`cg-column-menu`,onDismiss:l,role:`dialog`,ariaLabel:`Format ${t.label}`,initialFocus:`[data-overlay-autofocus]`,dataKind:`column-menu`,children:[(0,B.jsx)(z7,{title:`Field format`,sub:t.label,onClose:l}),(0,B.jsxs)(`div`,{className:`cg-column-create`,children:[Gt===`number`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,"data-overlay-autofocus":!0,checked:He.thousands!==!1,onChange:e=>Ue(t=>({...t,thousands:e.target.checked}))}),(0,B.jsx)(`span`,{children:`Thousands separator (12,345)`})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Decimal places`}),(0,B.jsxs)(`select`,{className:`cg-select`,value:Number.isInteger(He.decimals)?String(He.decimals):``,"aria-label":`Decimal places`,onChange:e=>Ue(t=>{let n={...t};return e.target.value===``?delete n.decimals:n.decimals=Number(e.target.value),n}),children:[(0,B.jsx)(`option`,{value:``,children:`As entered`}),[0,1,2,3,4].map(e=>(0,B.jsx)(`option`,{value:e,children:e},e))]})]}),(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:He.abbrev===!0,onChange:e=>Ue(t=>({...t,abbrev:e.target.checked}))}),(0,B.jsx)(`span`,{children:`Abbreviate large numbers (34.0M)`})]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,"data-overlay-autofocus":!0,checked:He.time??t.type===`created_time`,onChange:e=>Ue(t=>({...t,time:e.target.checked}))}),(0,B.jsx)(`span`,{children:`Include the time of day`})]}),(0,B.jsxs)(`label`,{children:[(0,B.jsx)(`span`,{children:`Time zone`}),(0,B.jsxs)(`select`,{className:`cg-select`,value:He.tz===`utc`?`utc`:`local`,"aria-label":`Time zone`,onChange:e=>Ue(t=>({...t,tz:e.target.value})),children:[(0,B.jsx)(`option`,{value:`local`,children:`Your local time`}),(0,B.jsx)(`option`,{value:`utc`,children:`UTC`})]})]})]}),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,disabled:JSON.stringify(He)===JSON.stringify(t.format??{}),onClick:()=>{D?.(He),l()},children:`Save`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,onClick:()=>P(`menu`),children:`Back`})]})]})]});let Kt=!!E&&!!i&&(i.isAdmin||t.createdBy!=null&&t.createdBy===i.name);return(0,B.jsxs)(Pp,{anchor:e.anchor,className:`cg-column-menu`,onDismiss:l,role:`dialog`,ariaLabel:`Column settings for ${t.label}`,initialFocus:`[data-overlay-autofocus]`,dataKind:`column-menu`,children:[(0,B.jsx)(z7,{title:t.label,sub:Wt,onClose:l}),Lt&&(0,B.jsxs)(`button`,{type:`button`,className:`cg-column-periodline`,onClick:()=>{qe(t.label),P(`edit`)},children:[(0,B.jsx)(`span`,{className:`cg-swap-label`,children:`Period`}),(0,B.jsx)(`span`,{className:`cg-column-periodval`,children:Zu(t.measure.window)})]}),(0,B.jsxs)(`div`,{className:`cg-column-actions`,children:[(0,B.jsx)(`button`,{type:`button`,"data-overlay-autofocus":!0,onClick:()=>{qe(t.label),P(`edit`)},children:(0,B.jsx)(Bp,{icon:`rename`,text:`Edit field`})}),(0,B.jsx)(`div`,{className:`cg-menu-sep`,role:`separator`,"aria-hidden":!0}),T&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{T(),l()},children:(0,B.jsx)(Bp,{icon:`duplicate`,text:`Duplicate field`})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>ae(`left`),children:(0,B.jsx)(Bp,{icon:`insertLeft`,text:`Insert field left`})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>ae(`right`),children:(0,B.jsx)(Bp,{icon:`insertRight`,text:`Insert field right`})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>ae(`end`),children:(0,B.jsx)(Bp,{icon:`addEnd`,text:`Add field at end`})}),(0,B.jsx)(`div`,{className:`cg-menu-sep`,role:`separator`,"aria-hidden":!0}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>P(`note`),children:(0,B.jsx)(Bp,{icon:`description`,text:`Edit field description`})}),Kt&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>P(`permissions`),children:(0,B.jsx)(Bp,{icon:`permissions`,text:`Edit field permissions`})}),Gt&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>P(`format`),children:(0,B.jsx)(Bp,{icon:`format`,text:`Field format`})}),(0,B.jsx)(`div`,{className:`cg-menu-sep`,role:`separator`,"aria-hidden":!0}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{O(`asc`),l()},children:(0,B.jsx)(Bp,{icon:`sortAsc`,text:`Sort ${ud(t.type,`asc`)}`})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{O(`desc`),l()},children:(0,B.jsx)(Bp,{icon:`sortDesc`,text:`Sort ${ud(t.type,`desc`)}`})}),a!=null&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{k(),l()},children:(0,B.jsx)(Bp,{icon:`off`,text:`Don't sort by this field`})}),(0,B.jsx)(`div`,{className:`cg-menu-sep`,role:`separator`,"aria-hidden":!0}),(t.filterable!==!1||t.measure!=null&&te.length>0)&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{A(),l()},children:(0,B.jsx)(Bp,{icon:`filter`,text:`Filter by this field`})}),o&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{j(),l()},children:(0,B.jsx)(Bp,{icon:`off`,text:`Don't filter by this field`})}),c&&!s&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M(),l()},children:(0,B.jsx)(Bp,{icon:`group`,text:`Group by this field`})}),s&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{ee(),l()},children:(0,B.jsx)(Bp,{icon:`off`,text:`Don't group by this field`})}),x&&!b&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{x(),l()},children:(0,B.jsx)(Bp,{icon:`pin`,text:`Pin up to this field`})}),S&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{S(),l()},children:(0,B.jsx)(Bp,{icon:`unpin`,text:`Unpin all fields`})}),(0,B.jsx)(`div`,{className:`cg-menu-sep`,role:`separator`,"aria-hidden":!0}),(0,B.jsx)(`button`,{type:`button`,disabled:r,title:r?`The primary field stays visible`:void 0,onClick:d,children:(0,B.jsx)(Bp,{icon:`hide`,text:`Hide field`})}),w&&(0,B.jsx)(`button`,{type:`button`,className:`is-danger`,title:t.measure?`Removes this formula column from the workspace.`:`Removes this field AND its values on every row.`,onClick:()=>oe?w():se(!0),children:(0,B.jsx)(Bp,{icon:`trash`,text:oe?`Delete permanently?`:`Delete field`})})]})]})}var pWe=[`bar`,`line`,`area`,`donut`,`kpi`,`table`],V7=[`sum`,`avg`,`count`,`min`,`max`],mWe={sum:`Sum of`,avg:`Average of`,count:`Count of records`,min:`Smallest`,max:`Largest`},hWe=[`brand`,`categorical`,`sequential`,`diverging`],gWe=[`auto`,`number`,`currency`,`percent`,`compact`],H7=[1,12],U7=[120,800],W7=[`bar`,`line`,`area`];function G7(e){return!!e&&e.startsWith(`measure_`)}function K7(e){return!!e.bucket&&G7(e.y)&&W7.includes(e.kind)}function _We(e){let t=String(e??``);return/^\d{4}-\d{2}/.test(t)?t.slice(0,7):null}function vWe(e){let t=Number(e.slice(0,4)),n=Number(e.slice(5,7));return!Number.isFinite(t)||!Number.isFinite(n)?e:new Date(Date.UTC(t,n-1,1)).toLocaleDateString(void 0,{month:`short`,year:`numeric`,timeZone:`UTC`})}function q7(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:null}function J7(e,t,n){if(e===`count`)return n;if(t.length===0)return 0;switch(e){case`sum`:return t.reduce((e,t)=>e+t,0);case`avg`:return t.reduce((e,t)=>e+t,0)/t.length;case`min`:return Math.min(...t);case`max`:return Math.max(...t)}}function yWe(e,t,n){return e===`count`?n:t.length===0?null:J7(e,t,n)}function Y7(e,t,n,r){let i={buckets:[],omitted:0,omittedValue:0,blanks:0,missingY:0,rows:t.length},a=e.y?n.get(e.y):void 0;if(e.y&&!a)return{...i,problem:`The field this chart measured no longer exists.`};if(a&&e.agg!==`count`&&!cd(a.type))return{...i,problem:`${a.label} is not a number, so it cannot be ${e.agg===`avg`?`averaged`:e.agg+`med`}.`};if(e.agg!==`count`&&!a)return{...i,problem:`Choose a number field to measure, or switch to Count.`};if(e.kind===`kpi`){let n=[],r=0;for(let e of t){if(!a)continue;let t=q7(e[a.key]);t==null?r+=1:n.push(t)}return{...i,missingY:r,buckets:[{key:``,label:``,value:J7(e.agg,n,t.length),n:t.length}]}}let o=e.x?n.get(e.x):void 0;if(!e.x)return{...i,problem:`Choose a field to group by.`};if(!o)return{...i,problem:`The field this chart grouped by no longer exists.`};let s=ld(o.type),c=new Map,l=0,u=0;for(let e of t){let t=e[o.key],n,r;if(s){let e=_We(t);e==null?(l+=1,n=``,r=`(no date)`):(n=e,r=vWe(e))}else{let e=String(t??``).trim();e===``?(l+=1,n=``,r=`(blank)`):(n=e,r=e)}let i=c.get(n);if(i||(i={label:r,vals:[],n:0},c.set(n,i)),i.n+=1,a){let t=q7(e[a.key]);t==null?u+=1:i.vals.push(t)}}let d=[...c.entries()].map(([t,n])=>({key:t,label:n.label,value:J7(e.agg,n.vals,n.n),n:n.n}));s?d.sort((e,t)=>e.key===``?1:t.key===``?-1:e.key.localeCompare(t.key)):d.sort((e,t)=>t.value-e.value||e.label.localeCompare(t.label));let f=d.filter(e=>e.value<0),p=d.filter(e=>e.value===0).length,m=f.reduce((e,t)=>e+t.value,0),h=0,g=0,_=r?.maxBuckets??12;if(d.length>_){let e=d.slice(0,_),t=d.slice(_);h=t.length,g=t.reduce((e,t)=>e+t.value,0),d=e}return{...i,buckets:d,omitted:h,omittedValue:g,blanks:l,missingY:u,negativeBuckets:f.length,negativeValue:m,zeroBuckets:p}}function bWe(e,t,n){let r=Y7({...e,splitBy:void 0},t,n),i={points:[],xOrder:[],seriesOrder:[],omitted:r.omitted,omittedValue:r.omittedValue,omittedSeries:0,omittedSeriesValue:0,nonPositive:0,nonPositiveValue:0,blanks:r.blanks,missingY:r.missingY,rows:r.rows,problem:r.problem};if(r.problem)return i;if(e.kind===`donut`){let e=r.buckets.filter(e=>e.value>0),t=r.negativeBuckets??r.buckets.filter(e=>e.value<0).length,n=t+(r.zeroBuckets??r.buckets.filter(e=>e.value===0).length),a=r.negativeValue??r.buckets.filter(e=>e.value<0).reduce((e,t)=>e+t.value,0);return t>0?{...i,nonPositive:n,nonPositiveValue:a,problem:`A donut cannot represent negative values without misrepresenting the whole. Use a bar or line chart for signed values.`}:r.buckets.length>0&&e.length===0?{...i,nonPositive:n,nonPositiveValue:a,problem:`A donut needs at least one positive value. Zero-value groups cannot be drawn as slices.`}:{...i,points:e.map(e=>({...e,seriesKey:``,seriesLabel:``})),xOrder:e.map(e=>e.key),nonPositive:n,nonPositiveValue:a}}if(!e.splitBy||e.kind===`kpi`)return{...i,points:r.buckets.map(e=>({...e,seriesKey:``,seriesLabel:``})),xOrder:r.buckets.map(e=>e.key)};let a=n.get(e.splitBy),o=e.x?n.get(e.x):void 0;if(!a)return{...i,problem:`The field this chart split into series no longer exists.`};if(!o)return{...i,problem:`The field this chart grouped by no longer exists.`};let s=e=>ld(o.type)?_We(e[o.key])??``:String(e[o.key]??``).trim(),c=e=>String(e[a.key]??``).trim(),l=new Set(r.buckets.map(e=>e.key)),u=new Map;for(let e of t){if(!l.has(s(e)))continue;let t=c(e),n=u.get(t);n?n.push(e):u.set(t,[e])}let d=[...u.entries()].map(([t,r])=>{let i=Y7({...e,splitBy:void 0},r,n);return{key:t,label:t||`(blank)`,data:i,weight:i.buckets.reduce((e,t)=>e+Math.abs(t.value),0)}});d.sort((e,t)=>t.weight-e.weight||e.label.localeCompare(t.label));let f=d.slice(0,12),p=Math.max(0,d.length-f.length),m=d.slice(12).reduce((e,t)=>e+t.weight,0),h=r.buckets.map(e=>e.key),g=new Map(r.buckets.map(e=>[e.key,e.label])),_=[];for(let e of f){let t=new Map(e.data.buckets.map(e=>[e.key,e]));for(let n of h){let r=t.get(n);_.push({key:n,label:g.get(n)??n,value:r?.value??0,n:r?.n??0,seriesKey:e.key,seriesLabel:e.label})}}return{...i,points:_,xOrder:h,seriesOrder:f.map(e=>e.key),omittedSeries:p,omittedSeriesValue:m}}function xWe(e,t){return{id:e,kind:`bar`,x:t.find(e=>e.type===`status`||e.type===`select`)?.key,agg:`count`,size:{w:6,h:280}}}function SWe(e){return e.filter(e=>e.type===`status`||e.type===`select`||e.type===`text`||ld(e.type))}function CWe(e){return e.filter(e=>cd(e.type))}function X7(e,t,n,r){return!n||n===`auto`?t?yp(t,e):r(e):n===`compact`?r(e):n===`number`?e.toLocaleString(void 0,{maximumFractionDigits:2}):n===`percent`?`${e.toLocaleString(void 0,{maximumFractionDigits:2})}%`:e.toLocaleString(void 0,{style:`currency`,currency:`USD`,maximumFractionDigits:0})}function wWe(e,[t,n]){return Math.max(t,Math.min(n,e))}function TWe(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n,r=typeof e.id==`string`&&e.id?e.id:``,i=e.kind,a=e.agg;if(!r||!pWe.includes(i)||!V7.includes(a))continue;let o={id:r,kind:i,agg:a};if(typeof e.x==`string`&&e.x&&(o.x=e.x),typeof e.y==`string`&&e.y&&(o.y=e.y),typeof e.title==`string`&&e.title&&(o.title=e.title.slice(0,60)),typeof e.splitBy==`string`&&e.splitBy&&e.splitBy!==o.x&&(o.splitBy=e.splitBy),o.splitBy&&(i===`bar`||i===`area`)&&e.stacked===!0&&(o.stacked=!0),hWe.includes(e.palette)&&(o.palette=e.palette),e.axis&&typeof e.axis==`object`&&!Array.isArray(e.axis)){let t=e.axis,n={};for(let e of[`x`,`y`]){let r=t[e];if(!r||typeof r!=`object`||Array.isArray(r))continue;let i=r,a={};typeof i.label==`string`&&i.label.trim()&&(a.label=i.label.trim().slice(0,40)),gWe.includes(i.format)&&(a.format=i.format),(a.label!==void 0||a.format!==void 0)&&(n[e]=a)}(n.x||n.y)&&(o.axis=n)}if(e.size&&typeof e.size==`object`&&!Array.isArray(e.size)){let t=e.size,n={};typeof t.w==`number`&&Number.isFinite(t.w)&&(n.w=wWe(Math.round(t.w),H7)),typeof t.h==`number`&&Number.isFinite(t.h)&&(n.h=wWe(Math.round(t.h),U7)),(n.w!==void 0||n.h!==void 0)&&(o.size=n)}if(typeof e.bucket==`string`&&id.includes(e.bucket)&&G7(o.y)&&(o.bucket=e.bucket,e.span&&typeof e.span==`object`&&!Array.isArray(e.span))){let t=e.span.lastN;if(typeof t==`number`&&Number.isFinite(t)){let e=Math.round(t);e>=1&&e<=120&&(o.span={lastN:e})}}if(e.compare===`prior_year`&&(o.bucket||i===`kpi`&&o.agg===`sum`&&G7(o.y))&&(o.compare=`prior_year`),t.push(o),t.length>=12)break}return t.length?t:void 0}var EWe={sum:`Total`,avg:`Average`,count:`Count`,min:`Lowest`,max:`Highest`},Z7=50;function DWe(){let e={stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`};return(0,B.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,"aria-hidden":!0,children:[(0,B.jsx)(`rect`,{x:`2.5`,y:`3`,width:`11`,height:`10`,rx:`1.5`,...e}),(0,B.jsx)(`path`,{d:`M5 7.5h6M5 10h4`,...e})]})}function OWe({mode:e,onMode:t,locked:n=!1,dateField:r,dateChoices:i,stackField:a,stackChoices:o,colorField:s,colorChoices:c,sizeField:l,sizeChoices:u,onPickField:d,clamped:f=!0,onClamp:p,calendarMode:m=`records`,onCalendarMode:h,calendarMetrics:g=[],metricChoices:_=[],onCalendarMetrics:v}){return(0,B.jsxs)(`span`,{className:`cg-modes`,children:[n?(0,B.jsxs)(`span`,{className:`cg-modes-locked`,title:`This view is locked as ${Rf[e]}. Filters, sorts and columns are still editable — its creator or an admin can unlock it from the view menu.`,children:[(0,B.jsx)(Lp,{mode:e}),(0,B.jsxs)(`span`,{children:[`View · `,Rf[e]]}),(0,B.jsx)(Hp,{})]}):(0,B.jsx)(mm,{label:`View · ${Rf[e]}`,icon:(0,B.jsx)(Lp,{mode:e}),active:e!==`grid`,children:n=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`View as`}),Lte.map(r=>(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-viewmode`,checked:e===r,onChange:()=>{t(r),n()}}),(0,B.jsx)(Lp,{mode:r}),(0,B.jsx)(`span`,{children:Rf[r]})]},r))]})}),e===`calendar`&&i.length>0&&(0,B.jsx)(Kp,{className:`cg-mode-field`,ariaLabel:`Calendar date field`,value:r?.key,onChange:e=>d(`dateField`,e),fields:i.map(e=>({key:e.key,label:e.label,type:e.type}))}),e===`kanban`&&o.length>0&&(0,B.jsx)(Kp,{className:`cg-mode-field`,ariaLabel:`Kanban stack field`,value:a?.key,onChange:e=>d(`stackField`,e),fields:o.map(e=>({key:e.key,label:e.label,type:e.type}))}),e===`kanban`&&p&&(0,B.jsx)(`button`,{type:`button`,className:`cg-tb-btn cg-mode-field`+(f?` is-on`:``),"aria-pressed":f,onClick:()=>p(!f&&void 0),title:f?`Cards are trimmed to a standard height. Click to let them grow to their content.`:`Cards grow to their content. Click to trim them to a standard height.`,children:f?`Short cards`:`Full cards`}),e===`calendar`&&h&&(0,B.jsx)(mm,{label:`Day cells · ${m===`summary`?`Summaries`:`Records`}`,icon:(0,B.jsx)(DWe,{}),active:m===`summary`,children:e=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Each day shows`}),[[`records`,`Records`,`The records that fall on that day, listed.`],[`summary`,`Summaries`,`Totals computed over that day's records.`]].map(([t,n,r])=>(0,B.jsxs)(`label`,{className:`cg-radio-row`,children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-cal-mode`,checked:t===`summary`?m===`summary`:m!==`summary`,onChange:()=>{h(t),e()}}),(0,B.jsxs)(`span`,{className:`cg-check-label`,children:[n,(0,B.jsx)(`span`,{className:`cg-pop-note cg-radio-help`,children:r})]})]},t))]})}),e===`calendar`&&m===`summary`&&v&&(0,B.jsx)(mm,{label:`Totals · ${g.length+1}`,icon:(0,B.jsx)(Lp,{mode:`chart`}),active:g.length>0,children:()=>(0,B.jsxs)(`div`,{className:`cg-pop-body`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Totals per day`}),(0,B.jsxs)(`div`,{className:`cg-pop-note`,children:[`Records is always counted — every other figure in the cell is computed over it. Up to `,4,` more.`]}),_.length===0&&(0,B.jsx)(`div`,{className:`cg-pop-note`,children:`This table has no numeric fields to total.`}),_.map(e=>{let t=g.find(t=>t.field===e.key),n=g.length>=4;return(0,B.jsxs)(`div`,{className:`cg-cal-pick`,children:[(0,B.jsxs)(`label`,{className:`cg-check-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!t,disabled:!t&&n,onChange:()=>{v(t?g.filter(t=>t.field!==e.key):[...g,{id:`cm_${e.key}`,field:e.key,agg:`sum`}])}}),(0,B.jsx)(Ip,{type:e.type,size:11}),(0,B.jsx)(`span`,{className:`cg-check-label`,children:e.label})]}),t&&(0,B.jsx)(`select`,{className:`cg-select`,value:t.agg,"aria-label":`How to total ${e.label}`,onChange:t=>v(g.map(n=>n.field===e.key?{...n,agg:t.target.value}:n)),children:V7.filter(e=>e!==`count`).map(e=>(0,B.jsx)(`option`,{value:e,children:EWe[e]},e))})]},e.key)})]})}),e===`map`&&c.length>0&&(0,B.jsx)(Kp,{className:`cg-mode-field`,ariaLabel:`Colour pins by`,placeholder:`Colour: none`,value:s?.key??``,onChange:e=>d(`colorField`,e),fields:[{key:``,label:`No colour`,type:void 0},...c.map(e=>({key:e.key,label:`Colour: ${e.label}`,type:e.type}))]}),e===`map`&&u.length>0&&(0,B.jsx)(Kp,{className:`cg-mode-field`,ariaLabel:`Size pins by`,placeholder:`Size: none`,value:l?.key??``,onChange:e=>d(`sizeField`,e),fields:[{key:``,label:`No size`,type:void 0},...u.map(e=>({key:e.key,label:`Size: ${e.label}`,type:e.type}))]})]})}var kWe=(0,L.memo)(function({rows:e,fieldByKey:t,visibleKeys:n,titleKey:r,onOpen:i,onToggleGroup:a}){let o=n.filter(e=>e!==r);return(0,B.jsxs)(`div`,{className:`cg-listview`,children:[e.map((e,n)=>{if(e.kind===`group-footer`)return null;if(e.kind===`group-header`)return(0,B.jsxs)(`button`,{type:`button`,className:`cg-lv-group`,onClick:()=>a(e.groupKey),"aria-expanded":!e.collapsed,children:[(0,B.jsx)(`span`,{className:`cg-lv-chev`,children:e.collapsed?`▶`:`▼`}),(0,B.jsx)(`span`,{className:`cg-lv-group-label`,children:e.label}),(0,B.jsx)(`span`,{className:`cg-lv-count`,children:e.count.toLocaleString()})]},`g:${e.groupKey}:${n}`);let s=e.record;return(0,B.jsxs)(`button`,{type:`button`,className:`cg-lv-row`,onClick:()=>i(s.pid),children:[(0,B.jsx)(`span`,{className:`cg-lv-title`,children:String(s[r]??``)}),(0,B.jsx)(`span`,{className:`cg-lv-cells`,children:o.map(e=>{let n=t.get(e);if(!n)return null;let r=yp(n,s[e]);return r?(0,B.jsxs)(`span`,{className:`cg-lv-cell`,children:[(0,B.jsx)(`span`,{className:`cg-lv-k`,children:n.label}),(0,B.jsx)(`span`,{className:`cg-lv-v`,children:r})]},e):null})})]},`r:${s.pid}:${n}`)}),e.length===0&&(0,B.jsx)(`div`,{className:`cg-mode-empty`,children:`No records match this view.`})]})});function AWe(e,t){let n=Number(e.slice(0,4)),r=Number(e.slice(5,7));return new Date(Date.UTC(n,r-1+t,1)).toISOString().slice(0,7)}function jWe(e){let t=Number(e.slice(0,4)),n=Number(e.slice(5,7));return new Date(Date.UTC(t,n-1,1)).toLocaleDateString(void 0,{month:`long`,year:`numeric`,timeZone:`UTC`})}function MWe(e,t,n,r){let i=e.field?r[e.field.key]:void 0;if(i)return i[t]??null;let a=[];if(e.field)for(let t of n){let n=q7(t.row[e.field.key]);n!=null&&a.push(n)}return yWe(e.agg,a,n.length)}var NWe=(0,L.memo)(function({rows:e,field:t,today:n,titleKey:r,mode:i=`records`,metrics:a,fieldByKey:o,scope:s=`customer`,onOpen:c,onSheet:l}){let u=(0,L.useMemo)(()=>e.map(e=>({pid:e.pid,title:String(e[r]??``),day:String(e[t.key]??``).slice(0,10),row:e})),[e,t.key,r]),d=(0,L.useMemo)(()=>u.filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e.day)),[u]),f=u.length-d.length,p=(0,L.useMemo)(()=>{if(n&&/^\d{4}-\d{2}/.test(n))return n.slice(0,7);let e=d.map(e=>e.day.slice(0,7)).sort();return e.length?e[e.length-1]:null},[n,d]),[m,h]=(0,L.useState)(p),g=m??p,_=(0,L.useMemo)(()=>{let e=new Map;if(!g)return e;for(let t of d){if(!t.day.startsWith(g))continue;let n=e.get(t.day)??[];n.push({pid:t.pid,title:t.title,row:t.row}),e.set(t.day,n)}return e},[d,g]),v=(0,L.useMemo)(()=>{let e=[{id:`__count__`,label:`Records`,agg:`count`}];for(let t of a??[]){let n=o?.get(t.field);n&&V7.includes(t.agg)&&e.push({id:t.id,label:n.label,field:n,agg:t.agg})}return e},[a,o]),y=(0,L.useMemo)(()=>v.filter(e=>e.field&&Im(e.field)===`server`).map(e=>e.field.key),[v]),[b,x]=(0,L.useState)({}),[S,C]=(0,L.useState)({}),w=(0,L.useRef)(0);if((0,L.useEffect)(()=>{if(i!==`summary`||!y.length||_.size===0){x({}),C({});return}let e=[..._.entries()].map(([e,t])=>({key:e,pids:t.map(e=>e.pid)})),t=++w.current;ete({groups:e,fields:y},s).then(({payload:e})=>{t===w.current&&(x(e?.values??{}),C(e?.windows??{}))})},[i,y,_,s]),(0,L.useEffect)(()=>{if(!l)return;if(i!==`summary`||!g){l(null);return}let e=(e,t)=>({key:e,label:t,type:`text`,source:`odoo`}),t=[e(`day`,`Day`),...v.map(t=>e(`m_${t.id}`,t.label))],n=[];for(let e of[..._.keys()].sort()){let t=_.get(e)??[],r={pid:n.length+1,day:e};for(let n of v){let i=MWe(n,e,t,b);r[`m_${n.id}`]=i==null?``:n.field?yp(n.field,i):i.toLocaleString()}n.push(r)}l({fields:t,rows:n})},[l,i,g,_,v,b]),!g)return(0,B.jsxs)(`div`,{className:`cg-mode-empty`,children:[`No dates to place on a calendar yet.`,f>0&&` ${f.toLocaleString()} record${f===1?``:`s`} carry no date.`]});let T=Number(g.slice(0,4)),E=Number(g.slice(5,7)),D=new Date(Date.UTC(T,E,0)).getUTCDate(),O=(new Date(Date.UTC(T,E-1,1)).getUTCDay()+6)%7,k=[...Array.from({length:O},()=>null),...Array.from({length:D},(e,t)=>t+1)];for(;k.length%7!=0;)k.push(null);let A=[..._.values()].reduce((e,t)=>e+t.length,0);return(0,B.jsxs)(`div`,{className:`cg-calview`,children:[(0,B.jsxs)(`div`,{className:`cg-cal-bar`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-cal-nav`,"aria-label":`Previous month`,onClick:()=>h(AWe(g,-1)),children:`‹`}),(0,B.jsx)(`span`,{className:`cg-cal-title`,children:jWe(g)}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-cal-nav`,"aria-label":`Next month`,onClick:()=>h(AWe(g,1)),children:`›`}),(0,B.jsx)(`span`,{className:`cg-cal-note`,children:i===`summary`?`Totals over ${A.toLocaleString()} record${A===1?``:`s`} placed this month · by ${t.label}`:`${A.toLocaleString()} in this month · by ${t.label}`}),f>0&&(0,B.jsxs)(`span`,{className:`cg-cal-nodate`,title:`${f.toLocaleString()} matching record${f===1?``:`s`} have no ${t.label} and are not on the calendar. They remain in the Grid and List views.`,children:[f.toLocaleString(),` without a date`]}),i===`summary`&&v.filter(e=>e.field&&S[e.field.key]?.label).map(e=>(0,B.jsxs)(`span`,{className:`cg-cal-window`,children:[e.label,` · `,S[e.field.key].label,`, as of each day`]},e.id))]}),(0,B.jsxs)(`div`,{className:`cg-cal-grid`,children:[[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`].map(e=>(0,B.jsx)(`div`,{className:`cg-cal-dow`,children:e},e)),k.map((e,t)=>{let r=e?`${g}-${String(e).padStart(2,`0`)}`:``,a=e?_.get(r)??[]:[];return(0,B.jsxs)(`div`,{className:`cg-cal-cell`+(e?``:` is-blank`)+(r===n?` is-today`:``),children:[e&&(0,B.jsx)(`div`,{className:`cg-cal-day`,children:e}),i===`summary`?e&&a.length>0&&v.map(e=>{let t=MWe(e,r,a,b);return(0,B.jsxs)(`div`,{className:`cg-cal-metric`,children:[(0,B.jsx)(Ip,{type:e.field?e.field.type:`int`,size:11}),(0,B.jsx)(`span`,{className:`cg-cal-metric-k`,children:e.label}),(0,B.jsx)(`span`,{className:`cg-cal-metric-v`,children:t==null?`—`:e.field?yp(e.field,t):t.toLocaleString()})]},e.id)}):a.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cg-cal-chip`,title:e.title,onClick:()=>c(e.pid),children:e.title},e.pid))]},t)})]})]})}),PWe=(0,L.memo)(function({rows:e,field:t,fieldByKey:n,cardKeys:r,titleKey:i,canMove:a,readOnlyReason:o,clamped:s=!0,onMove:c,onOpen:l}){let[u,d]=(0,L.useState)(new Set),f=(0,L.useMemo)(()=>{let n=t.type===`select`?[...nd(t)]:[],r=new Map(n.map(e=>[e,[]])),i=[];for(let a of e){let e=String(a[t.key]??``).trim();if(e===``){i.push(a);continue}let o=r.get(e);o||(o=[],r.set(e,o),n.push(e)),o.push(a)}let o=n.map(e=>({key:e,label:e,rows:r.get(e)}));return(i.length||a)&&o.push({key:``,label:`(empty)`,rows:i}),o},[e,t,a]),p=e=>t=>{t.preventDefault();let n=Number(t.dataTransfer.getData(`text/plain`));Number.isFinite(n)&&n>0&&c(n,e)},m=(0,L.useRef)(!1);return(0,B.jsxs)(`div`,{className:`cg-kbview`+(s?` is-clamped`:``),children:[o&&(0,B.jsx)(`div`,{className:`cg-kb-note`,children:o}),(0,B.jsx)(`div`,{className:`cg-kb-lanes`,children:f.map(e=>{let o=u.has(e.key),s=o?e.rows:e.rows.slice(0,Z7),c=e.key?up(t,e.key):void 0;return(0,B.jsxs)(`div`,{className:`cg-kb-lane`,onDragOver:a?e=>e.preventDefault():void 0,onDrop:a?p(e.key):void 0,children:[(0,B.jsxs)(`div`,{className:`cg-kb-head`,children:[(0,B.jsx)(`span`,{className:`cg-kb-pill`,style:c?{background:c.bg,color:c.fg}:void 0,children:e.label}),(0,B.jsx)(`span`,{className:`cg-kb-count`,children:e.rows.length.toLocaleString()})]}),(0,B.jsxs)(`div`,{className:`cg-kb-cards`,children:[s.map(e=>(0,B.jsxs)(`div`,{className:`cg-kb-card`+(a?` is-draggable`:``),draggable:a,role:`button`,tabIndex:0,"aria-label":`Open ${String(e[i]??`record`)}`,onClick:()=>{m.current||l(e.pid)},onKeyDown:t=>{t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),l(e.pid))},onDragStart:a?t=>{m.current=!0,t.dataTransfer.setData(`text/plain`,String(e.pid))}:void 0,onDragEnd:a?()=>{window.setTimeout(()=>{m.current=!1},0)}:void 0,children:[(0,B.jsx)(`span`,{className:`cg-kb-title`,children:String(e[i]??``)}),r.map(t=>{let r=n.get(t);if(!r)return null;let i=yp(r,e[t]);return i?(0,B.jsxs)(`div`,{className:`cg-kb-cell`,children:[(0,B.jsx)(`span`,{className:`cg-lv-k`,children:r.label}),(0,B.jsx)(`span`,{className:`cg-lv-v`,children:i})]},t):null})]},e.pid)),e.rows.length>Z7&&!o&&(0,B.jsxs)(`button`,{type:`button`,className:`cg-link-btn cg-kb-more`,onClick:()=>d(t=>new Set(t).add(e.key)),children:[`Showing first `,Z7,` — show all`,` `,e.rows.length.toLocaleString()]})]})]},e.key||`(empty)`)})})]})});function FWe(e){let{label:t,value:n}=e,r=e.prior??null,i={label:t,value:n,format:e.format??`auto`,delta:null,prior:r,dir:`off`};if(n===0&&r!=null&&r!==0)return{...i,note:`no orders yet`};if(r==null)return i;if(r===0||!Number.isFinite(r)||!Number.isFinite(n))return{...i,note:`no comparable prior period`};let a=(n-r)/Math.abs(r)*100;return{...i,delta:a,dir:a>0?`up`:a<0?`down`:`flat`,deltaLabel:e.deltaLabel??`vs prior`}}function IWe(e){let{rows:t,fieldByKey:n,groupBy:r,columns:i}=e,a=e.sort??`first-desc`,o={columns:i,rows:[],total:0,shown:0,blanks:0};if(!n.has(r))return{...o,problem:`The field this table grouped by no longer exists.`};if(i.length===0)return{...o,problem:`This table has no columns to aggregate.`};let s=i.map(e=>Y7({id:`gt-${e.key}`,kind:`bar`,x:r,y:e.y,agg:e.agg,size:void 0},t,n,{maxBuckets:2**53-1})),c=s.find(e=>e.problem)?.problem;if(c)return{...o,problem:c};let l=s[0],u=s.map(e=>new Map(e.buckets.map(e=>[e.key,e]))),d=l.buckets.map(e=>({key:e.key,label:e.label,n:e.n,values:i.map((t,n)=>u[n].get(e.key)?.value??null)}));d.sort((e,t)=>{if(a===`label`)return e.label.localeCompare(t.label);let n=e.values[0],r=t.values[0];return n==null||r==null?n==null?r==null?0:1:-1:a===`first-asc`?n-r:r-n});let f=e.limit??d.length;return{columns:i,rows:d.slice(0,Math.max(0,f)),total:d.length,shown:Math.min(d.length,Math.max(0,f)),blanks:l.blanks}}function LWe(e,t,n){let r={columns:[],rows:[],total:0,shown:0,blanks:0};if(!e.x)return{...r,problem:`Choose a field to group by.`};let i=e.y?n.get(e.y):void 0;if(e.agg!==`count`&&!e.y)return{...r,problem:`Choose a number field to measure, or switch to Count.`};let a=[];return e.agg!==`count`&&e.y&&a.push({key:`measure`,label:`${mWe[e.agg]} ${i?.label??e.y}`,agg:e.agg,y:e.y,format:e.axis?.y?.format}),a.push({key:`n`,label:`Records`,agg:`count`}),IWe({rows:t,fieldByKey:n,groupBy:e.x,columns:a,sort:`first-desc`,limit:25})}function RWe(e){let{values:t,back:n}=e,r=t.length?t[t.length-1]:null;if(r==null||!Number.isFinite(r))return null;let i=t.length-1-n,a=i>=0?t[i]:null;return FWe({label:e.label,value:r,prior:a,format:e.format,deltaLabel:`vs last year`})}var zWe=(0,L.lazy)(()=>Dc(()=>Promise.resolve().then(()=>(qHe(),GHe)),void 0,import.meta.url)),Q7=6;function $7(e,[t,n]){return Math.max(t,Math.min(n,e))}var BWe={brand:`Brand`,categorical:`Distinct categories`,sequential:`Low to high`,diverging:`Below / above a midpoint`},VWe={auto:`Automatic`,number:`Plain number`,currency:`Currency`,percent:`Percent`,compact:`Compact (1.2k)`};function e9(e,t,n){let r={...e.axis?.[t]??{},...n};r.label?.trim()||delete r.label,r.format===`auto`&&delete r.format;let i={...e.axis??{}};return r.label===void 0&&r.format===void 0?delete i[t]:i[t]=r,{...e,axis:i.x||i.y?i:void 0}}var HWe={bar:`Bar`,line:`Line`,area:`Area`,donut:`Donut`,kpi:`Single number`,table:`Table`},UWe=mWe,WWe={week:`Weekly`,month:`Monthly`,quarter:`Quarterly`,year:`Yearly`},GWe=[6,12,24,36];function KWe(e){let t=e.span?.lastN??12;return e.compare===`prior_year`?t+(Lm[e.bucket]??12):t}function qWe(e){return`${e.bucket}|${KWe(e)}`}var t9=`month`,JWe=Lm.month+1;function YWe(e){return e.kind===`kpi`&&e.compare===`prior_year`&&e.agg===`sum`&&G7(e.y)}function XWe(){return`${t9}|${JWe}`}function n9(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e9?(e/1e9).toFixed(1)+`B`:t>=1e6?(e/1e6).toFixed(1)+`M`:t>=1e3?(e/1e3).toFixed(1)+`k`:Number.isInteger(e)?e.toLocaleString():e.toFixed(2)}function ZWe({spec:e,data:t,fields:n,yField:r,onChange:i,onRemove:a,canPeriod:o,table:s,kpiCompare:c}){let[l,u]=(0,L.useState)(!1),d=(0,L.useMemo)(()=>SWe(n),[n]),f=(0,L.useMemo)(()=>CWe(n),[n]),p=K7(e)?WWe[e.bucket]:void 0,m=p?`Period`:e.x?n.find(t=>t.key===e.x)?.label:void 0,h=p?`, ${p.toLowerCase()}`:m?` by ${m}`:``,g=e.agg===`count`?`Count of records${h}`:`${UWe[e.agg]} ${r?.label??`…`}${h}`,_=(0,L.useMemo)(()=>Gm({spec:e,model:t,xTitle:e.axis?.x?.label??m,yTitle:e.axis?.y?.label??(e.agg===`count`?`Records`:r?.label),formatValue:t=>X7(t,r,e.axis?.y?.format,n9)}),[t,e,m,r]);return(0,B.jsxs)(`div`,{className:`cg-ch-card`,style:{gridColumn:`span ${e.size?.w??Q7}`,height:e.size?.h?`${e.size.h}px`:void 0},children:[(0,B.jsxs)(`div`,{className:`cg-ch-head`,children:[(0,B.jsx)(`span`,{className:`cg-ch-title`,title:e.title||g,children:e.title||g}),(0,B.jsx)(`button`,{type:`button`,className:`cg-icon-btn cg-ch-cfg`,"aria-label":`Configure this chart`,"aria-expanded":l,onClick:()=>u(e=>!e),children:(0,B.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M3 4.5h10M3 8h10M3 11.5h10`,stroke:`currentColor`,strokeWidth:1.3,strokeLinecap:`round`})})}),(0,B.jsx)(`button`,{type:`button`,className:`cg-icon-btn cg-ch-del`,"aria-label":`Remove this chart`,onClick:a,children:(0,B.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`,stroke:`currentColor`,strokeWidth:1.3,strokeLinecap:`round`})})})]}),l&&(0,B.jsxs)(`div`,{className:`cg-ch-cfgbody`,children:[(0,B.jsxs)(`div`,{className:`cg-ch-row cg-ch-kindrow`,role:`radiogroup`,"aria-label":`Chart type`,children:[(0,B.jsx)(`span`,{children:`Chart`}),(0,B.jsx)(`div`,{className:`cg-ch-kinds`,children:pWe.map(t=>(0,B.jsxs)(`label`,{className:`cg-ch-kind`+(e.kind===t?` is-on`:``),title:HWe[t],children:[(0,B.jsx)(`input`,{type:`radio`,name:`cg-ch-kind-${e.id}`,checked:e.kind===t,onChange:()=>i({...e,kind:t})}),(0,B.jsx)(Zne,{kind:t}),(0,B.jsx)(`span`,{children:HWe[t]})]},t))})]}),(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Show`}),(0,B.jsx)(`select`,{className:`cg-select`,value:e.agg,onChange:t=>{let n=t.target.value;i({...e,agg:n,...e.kind===`kpi`&&n!==`sum`?{compare:void 0}:{}})},children:V7.map(e=>(0,B.jsx)(`option`,{value:e,children:UWe[e]},e))})]}),e.agg!==`count`&&(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Which number`}),(0,B.jsxs)(`select`,{className:`cg-select`,value:e.y??``,onChange:t=>i({...e,y:t.target.value||void 0,...G7(t.target.value)?{}:{bucket:void 0,span:void 0,compare:void 0}}),children:[(0,B.jsx)(`option`,{value:``,children:`Choose a number…`}),f.map(e=>(0,B.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]}),o&&G7(e.y)&&W7.includes(e.kind)&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Over time`}),(0,B.jsxs)(`select`,{className:`cg-select`,value:e.bucket??``,onChange:t=>i({...e,bucket:t.target.value||void 0,span:t.target.value?e.span:void 0,compare:t.target.value?e.compare:void 0}),children:[(0,B.jsx)(`option`,{value:``,children:`No — group by a field`}),id.map(e=>(0,B.jsx)(`option`,{value:e,children:WWe[e]},e))]})]}),!!e.bucket&&(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`How far back`}),(0,B.jsx)(`select`,{className:`cg-select`,value:String(e.span?.lastN??12),onChange:t=>i({...e,span:{lastN:Number(t.target.value)}}),children:GWe.map(e=>(0,B.jsxs)(`option`,{value:e,children:[`Last `,e]},e))})]}),!!e.bucket&&(0,B.jsxs)(`label`,{className:`cg-ch-row cg-ch-check`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:e.compare===`prior_year`,onChange:t=>i({...e,compare:t.target.checked?`prior_year`:void 0})}),(0,B.jsx)(`span`,{children:`Compare to the year before`})]})]}),e.kind===`kpi`&&o&&e.agg===`sum`&&G7(e.y)&&(0,B.jsxs)(`label`,{className:`cg-ch-row cg-ch-check`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:e.compare===`prior_year`,onChange:t=>i({...e,compare:t.target.checked?`prior_year`:void 0})}),(0,B.jsx)(`span`,{children:`Compare to the year before`})]}),e.kind!==`kpi`&&!(o&&e.bucket&&W7.includes(e.kind))&&(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Grouped by`}),(0,B.jsxs)(`select`,{className:`cg-select`,value:e.x??``,onChange:t=>i({...e,x:t.target.value||void 0}),children:[(0,B.jsx)(`option`,{value:``,children:`Choose a field…`}),d.map(e=>(0,B.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]}),(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Title`}),(0,B.jsx)(`input`,{className:`cg-input`,value:e.title??``,placeholder:g,maxLength:60,onChange:t=>i({...e,title:t.target.value||void 0})})]}),e.kind!==`kpi`&&e.kind!==`donut`&&e.kind!==`table`&&!(o&&e.bucket&&W7.includes(e.kind))&&(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Break down by`}),(0,B.jsxs)(`select`,{className:`cg-select`,value:e.splitBy??``,onChange:t=>i({...e,splitBy:t.target.value||void 0,stacked:t.target.value?e.stacked:void 0}),children:[(0,B.jsx)(`option`,{value:``,children:`Don't break it down`}),d.filter(t=>t.key!==e.x).map(e=>(0,B.jsx)(`option`,{value:e.key,children:e.label},e.key))]})]}),!!e.splitBy&&(e.kind===`bar`||e.kind===`area`)&&(0,B.jsxs)(`label`,{className:`cg-ch-row cg-ch-check`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:e.stacked===!0,onChange:t=>i({...e,stacked:t.target.checked||void 0})}),(0,B.jsx)(`span`,{children:`Stack them on top of each other`})]}),e.kind!==`table`&&(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Colours`}),(0,B.jsxs)(`select`,{className:`cg-select`,value:e.palette??``,onChange:t=>i({...e,palette:t.target.value||void 0}),children:[(0,B.jsx)(`option`,{value:``,children:`Default`}),hWe.map(e=>(0,B.jsx)(`option`,{value:e,children:BWe[e]},e))]})]}),e.kind!==`kpi`&&e.kind!==`table`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Bottom axis label`}),(0,B.jsx)(`input`,{className:`cg-input`,value:e.axis?.x?.label??``,placeholder:m??`Category`,maxLength:40,onChange:t=>i(e9(e,`x`,{label:t.target.value}))})]}),(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Side axis label`}),(0,B.jsx)(`input`,{className:`cg-input`,value:e.axis?.y?.label??``,placeholder:r?.label??`Value`,maxLength:40,onChange:t=>i(e9(e,`y`,{label:t.target.value}))})]})]}),(0,B.jsxs)(`label`,{className:`cg-ch-row`,children:[(0,B.jsx)(`span`,{children:`Number format`}),(0,B.jsx)(`select`,{className:`cg-select`,value:e.axis?.y?.format??`auto`,onChange:t=>i(e9(e,`y`,{format:t.target.value})),children:gWe.map(e=>(0,B.jsx)(`option`,{value:e,children:VWe[e]},e))})]})]}),e.kind===`table`?!s||s.problem?(0,B.jsx)(`div`,{className:`cg-ch-empty`,children:s?.problem??`Choose a field to group by.`}):s.rows.length===0?(0,B.jsx)(`div`,{className:`cg-ch-empty`,children:`No records match this view, so there is nothing to list.`}):(0,B.jsx)(`div`,{className:`cg-ch-viz cg-ch-viz--table`,children:(0,B.jsx)(QWe,{table:s,xLabel:m??`Group`,yField:r})}):t.pending?(0,B.jsx)(`div`,{className:`cg-ch-empty`,children:(0,B.jsx)(`span`,{className:`lp-spin`,role:`status`,"aria-label":`Loading`})}):t.problem?(0,B.jsx)(`div`,{className:`cg-ch-empty`,children:t.problem}):t.points.length===0?(0,B.jsx)(`div`,{className:`cg-ch-empty`,children:`No records match this view, so there is nothing to chart.`}):(0,B.jsx)(`div`,{className:`cg-ch-viz cg-ch-viz--${e.kind}`,children:(0,B.jsx)(L.Suspense,{fallback:(0,B.jsx)(`div`,{className:`cg-ch-loading`,children:(0,B.jsx)(`span`,{className:`lp-spin`,role:`status`,"aria-label":`Loading`})}),children:(0,B.jsx)(zWe,{spec:_,label:e.title||g})})}),e.kind===`kpi`&&c&&(0,B.jsx)(`div`,{className:`cg-ch-kpidelta is-${c.dir}`,title:c.prior==null?void 0:`This period ${X7(c.value,r,e.axis?.y?.format,n9)} · a year earlier ${X7(c.prior,r,e.axis?.y?.format,n9)} (month-end anchored)`,children:c.delta==null?(0,B.jsx)(`span`,{children:c.note}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 14 14`,"aria-hidden":!0,children:c.dir===`up`?(0,B.jsx)(`path`,{d:`M3 9.5l4-5 4 5z`,fill:`currentColor`}):c.dir===`down`?(0,B.jsx)(`path`,{d:`M3 4.5l4 5 4-5z`,fill:`currentColor`}):(0,B.jsx)(`path`,{d:`M3 7h8`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`})}),(0,B.jsxs)(`span`,{children:[Math.abs(c.delta).toFixed(1),`% `,c.deltaLabel]})]})}),(0,B.jsxs)(`div`,{className:`cg-ch-foot`,children:[(0,B.jsxs)(`span`,{children:[t.rows.toLocaleString(),` records`]}),e.kind===`table`&&s&&!s.problem?(0,B.jsxs)(B.Fragment,{children:[s.shown0&&(0,B.jsxs)(`span`,{children:[`· `,s.blanks.toLocaleString(),` with no value grouped as blank`]})]}):(0,B.jsxs)(B.Fragment,{children:[t.omitted>0&&(0,B.jsxs)(`span`,{title:`The ${t.omitted.toLocaleString()} smallest groups are not drawn. Together they account for ${n9(t.omittedValue)}.`,children:[`· top `,12,` of `,(t.xOrder.length+t.omitted).toLocaleString(),` groups shown (+`,n9(t.omittedValue),` not drawn)`]}),t.omittedSeries>0&&(0,B.jsxs)(`span`,{title:`${t.omittedSeries.toLocaleString()} smaller series are not drawn. Together they account for ${n9(t.omittedSeriesValue)}.`,children:[`· `,t.omittedSeries.toLocaleString(),` series not drawn`]}),t.nonPositive>0&&(0,B.jsxs)(`span`,{title:`Donut slices require positive values. These groups have a combined value of ${n9(t.nonPositiveValue)} and are not included in the circle.`,children:[`· `,t.nonPositive.toLocaleString(),` zero/negative group`,t.nonPositive===1?``:`s`,` not drawn`]}),t.blanks>0&&(0,B.jsxs)(`span`,{children:[`· `,t.blanks.toLocaleString(),` with no value grouped as blank`]}),t.missingY>0&&(0,B.jsxs)(`span`,{title:`These records carry no number for the measured field, so they are counted in the group but excluded from the aggregate.`,children:[`· `,t.missingY.toLocaleString(),` not measurable`]})]})]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-ch-resize`,"aria-label":`Resize ${e.title||g}`,title:`Drag to resize · arrow keys also work`,onPointerDown:t=>{t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId);let n=t.currentTarget.parentElement,r=n?.parentElement;if(!n||!r)return;let a=t.clientX,o=t.clientY,s=e.size?.w??Q7,c=e.size?.h??n.getBoundingClientRect().height,l=Math.max(1,r.getBoundingClientRect().width/12),u=t=>{let n=$7(Math.round(s+(t.clientX-a)/l),H7),r=$7(Math.round(c+(t.clientY-o)),U7);i({...e,size:{w:n,h:r}})},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)},onKeyDown:t=>{let n=t.key===`ArrowRight`?1:t.key===`ArrowLeft`?-1:0,r=t.key===`ArrowDown`?20:t.key===`ArrowUp`?-20:0;!n&&!r||(t.preventDefault(),i({...e,size:{w:$7((e.size?.w??Q7)+n,H7),h:$7((e.size?.h??260)+r,U7)}}))},children:(0,B.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,"aria-hidden":!0,children:(0,B.jsx)(`path`,{d:`M9 3.5L3.5 9M9 7L7 9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})})})]})}function QWe({table:e,xLabel:t,yField:n}){return(0,B.jsx)(`div`,{className:`cg-ch-table`,children:(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:t}),e.columns.map(e=>(0,B.jsx)(`th`,{className:`cg-ch-td-num`,children:e.label},e.key))]})}),(0,B.jsx)(`tbody`,{children:e.rows.map(t=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{title:t.label,children:t.label}),t.values.map((t,r)=>{let i=e.columns[r];return(0,B.jsx)(`td`,{className:`cg-ch-td-num`,children:t==null?`—`:i.agg===`count`?t.toLocaleString():X7(t,i.y?n:void 0,i.format,n9)},i.key)})]},t.key||`(blank)`))})]})})}function $We({rows:e,fields:t,fieldByKey:n,charts:r,onCharts:i,scope:a}){let o=(0,L.useMemo)(()=>r.map(t=>bWe(t,e,n)),[r,e,n]),s=(0,L.useMemo)(()=>r.map(t=>t.kind===`table`?LWe(t,e,n):null),[r,e,n]),c=(0,L.useMemo)(()=>e.map(e=>Number(e.pid)).filter(Number.isFinite),[e]),l=(0,L.useMemo)(()=>r.filter(K7),[r]),u=(0,L.useMemo)(()=>r.filter(YWe),[r]),d=(0,L.useMemo)(()=>{let e=new Map,t=(t,n,r,i)=>{let a=e.get(t)??{bucket:n,lastN:r,fields:[]};i&&!a.fields.includes(i)&&a.fields.push(i),e.set(t,a)};for(let e of l)t(qWe(e),e.bucket,KWe(e),e.y);for(let e of u)t(XWe(),t9,JWe,e.y);return e},[l,u]),f=(0,L.useMemo)(()=>JSON.stringify([...d.entries()].map(([e,t])=>[e,[...t.fields].sort()])),[d]),[p,m]=(0,L.useState)({}),[h,g]=(0,L.useState)(!1),_=(0,L.useRef)(0);(0,L.useEffect)(()=>{if(!a||!d.size||!c.length){m({}),g(!1);return}let e=++_.current;g(!0),Promise.all([...d.entries()].map(([e,t])=>nf(km({pids:c,bucket:t.bucket,span:{lastN:t.lastN},fields:t.fields}),a).then(({payload:t})=>[e,t]))).then(t=>{e===_.current&&(m(Object.fromEntries(t)),g(!1))})},[a,f,c,d]);let v=(e,t)=>{if(!K7(e))return t;if(!a)return{...t,points:[],problem:`This chart is a trend over periods, but the host has not said which surface this view is, so it cannot be loaded.`};let n=p[qWe(e)];if(!n)return h?{...t,points:[],pending:!0}:{...t,points:[],problem:`The periods could not be loaded, so nothing is drawn rather than a guess.`};let r=Fm(n),i=r.rows.find(t=>t.field===e.y);return i?e.compare===`prior_year`?aie(i,r.columns,e.bucket,e.span?.lastN??12):Hm(i,r.columns):{...t,points:[],problem:`The server returned no series for this metric — a composite metric has no single aggregate to bucket.`}},y=e=>{if(!YWe(e))return;if(!a)return null;let t=p[XWe()];if(!t)return null;let n=Fm(t).rows.find(t=>t.field===e.y);return n?RWe({label:e.title??``,values:n.cells.map(e=>e.value),back:Lm[t9],format:e.axis?.y?.format}):null};return(0,B.jsxs)(`div`,{className:`cg-dashview`,children:[(0,B.jsxs)(`div`,{className:`cg-dash-bar`,children:[(0,B.jsxs)(`span`,{className:`cg-cal-note`,children:[e.length.toLocaleString(),` records · every chart describes exactly this view's rows, so filters and cohort scope already apply`]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary cg-dash-add`,disabled:r.length>=12,title:r.length>=12?`A view holds at most 12 charts.`:void 0,onClick:()=>{let e=`ch_${Math.random().toString(36).slice(2,10)}`;i([...r,xWe(e,t)])},children:`+ Add chart`})]}),r.length===0?(0,B.jsx)(`div`,{className:`cg-mode-empty`,children:`No charts on this view yet. "+ Add chart" builds one from the records this view already matches.`}):(0,B.jsx)(`div`,{className:`cg-dash-grid`,children:r.map((e,c)=>(0,B.jsx)(ZWe,{spec:e,data:v(e,o[c]),fields:t,yField:e.y?n.get(e.y):void 0,canPeriod:!!a,table:s[c],kpiCompare:y(e),onChange:t=>i(r.map(n=>n.id===e.id?t:n)),onRemove:()=>i(r.filter(t=>t.id!==e.id))},e.id))})]})}var eGe=`M465.85,1189.44l3.99,2.28 0.83,2.79 11.82,12.37 1.25,5.21 -0.42,1.67 0.93,0.27 1.84,-1.87 5.28,-3.59 2.67,-0.04 1.27,-2.84 0.01,-4 1.34,0.06 0.8,-0.54 0.35,-1.18 -0.85,-1.61 4.41,-1.31 5.21,-2.94 2.45,2.22 2.39,2.61 -0.23,3.08 1.45,3.42 5.72,4.51 1.64,4.13 5.42,4.24 4.77,6.42 -0.24,1.6 3.44,5.6 10.1,18.69 -1.2,2.5 3.48,1.11 -0.82,3.54 2.71,1.33 -0.23,1.05 0.6,1.19 0.1,1.96 2.84,-0.18 5.6,4 3.88,1.31 1.05,1.58 1.96,0.68 0.73,2.21 2.26,0.81 1.33,-0.54 0.85,1.93 0.1,1.3 -1.51,6 1.25,7.15 -1.54,3.21 -0.48,2.21 -4.11,5.07 -3.12,-0.75 -2.23,-7.37 0.7,-1.29 2.69,-1.48 -1.23,-0.74 -0.71,-7.66 -2.38,-4.54 -0.15,-0.76 1.23,-1.85 -8.55,4.31 -0.48,0.83 0.26,1.4 -1.61,4.28 -0.44,0.38 -1.54,-0.7 -1.19,-3.05 0.18,-0.65 2.3,-3.58 1.84,-4.69 3.33,-0.95 -3.83,-0.71 -1.53,-2.84 -1.82,-0.84 -1.4,-2.04 -0.6,-2.19 -1.34,-0.49 -0.13,-2.42 -1.73,-0.63 -1.85,-2.05 -0.42,-1.36 0.16,-2 -1.01,0.18 -6.28,-2.61 0.33,-3.47 -1.17,-4.59 -1.25,-1.87 0.52,-1.12 0.56,-0.01 4.97,2.74 -4.53,-4.44 -0.22,-1.24 0.27,-1.01 3.6,0.06 -4.15,-1.01 -1.11,1.79 -0.74,-0.07 -3.52,-4.89 -0.36,-2.99 0.2,-1.69 1.92,-4.97 -0.76,0.43 -2.14,4.75 -0.88,1.01 -3.15,-2.91 -2.02,-0.38 -1.28,-1.5 -1.9,-4.2 -0.49,-2.61 -1.66,-1.7 -0.97,-5.16 -1.29,-3.6 -0.38,-4.03 -0.56,2.26 -0.81,0.22 0.96,2.24 -1.17,0.12 1.33,2.55 0.59,3.93 3.09,12.43 0.14,0.74 -0.46,1.32 -2.41,-0.22 -1.68,-2.6 -1.39,-0.78 -3.7,0.25 0.41,-3.85 -2.1,-4.64 0.03,-0.71 2.47,-1.68 -2.17,0.53 -1.51,-3.85 -0.11,2.24 0.41,1.18 -0.01,1.62 -1.16,1.19 -2.56,-1.78 -1.31,-2.08 -4.81,-2.07 0.47,2.2 -1.27,1.35 2.05,-0.17 3.02,1.59 0.91,1.51 1.41,0.87 -0.84,1.82 2.95,0.33 1.85,3.26 0.07,1.49 -0.29,0.43 -4.34,0.79 -1.65,1.82 -10.66,-7.33 -0.23,-0.97 -3.4,-3.5 -1.86,-3.43 -3.7,-3.22 -2.37,-0.93 0.52,-0.82 -4.21,-1.58 -10.4,-6.91 2.13,-1.44 1.12,-1.97 -0.78,-3.4 0.14,-1.45 0.65,-0.94 0.74,-0.07 1.32,1.81 0.51,6.01 0.75,-4.72 2.64,-0.34 -2.89,-1.31 -2.15,-2.71 -1,-0.11 -4.52,4.8 -3.41,1.78 -2.32,0.36 -4.81,-0.86 -6.43,-3.48 1.34,-2.31 -0.45,-1.79 -0.9,-0.8 -0.01,1.72 -0.42,0.52 -2.54,1.13 -10,-2.64 -4.51,-0.25 -9.78,1.91 -3.89,-0.08 -0.16,-0.67 0.87,-0.39 -0.05,-0.48 -1.1,-1.52 -5.21,-1.69 -2.94,-2.54 0.88,-4.58 1.52,-3.14 -6.34,6.69 -7.41,-2.26 2.55,-4.01 -5.39,-0.22 -0.38,-1.72 -0.78,-0.33 -2.87,1.12 -0.77,-0.66 2.03,-1.91 -2.8,-2.01 0.03,-2.24 0.42,-1.43 3.57,-1.39 -3.39,-0.36 -3.31,2.89 -1.21,0.64 -2.44,-0.45 -1.9,1.93 -2.34,-1.88 -1,2 -1.73,0.56 -0.95,-0.1 -1.14,-1.37 0.23,-1.66 2.49,-4.71 -3.38,3.22 -3.33,0.52 -0.78,1.15 2.29,-0.43 -1.54,4.13 -2.41,0.62 -0.01,0.56 3.42,2.97 -0.55,2.13 -2.33,0.42 -1.48,1.76 5.92,-1.99 0.78,0.19 0.99,1.9 -0.93,1.31 -1.55,0.81 -0.39,1.61 0.21,3.56 -1.54,1.05 -1.11,3.02 -3.64,0.94 -2.89,-0.73 -1.33,-1.22 -1.65,0.81 -1.47,-2.45 -0.42,2.38 -1.33,2.43 -0.55,2.8 -1.32,-3.38 -0.92,1.45 0.14,2.39 -2.54,-0.77 0.44,2.13 -2.63,2.78 -1.59,-0.34 -1.68,1.04 -1.39,-0.63 -0.17,1.88 -0.62,1.18 -2,1.9 -0.93,2.06 -2.82,-1.15 0.13,1.42 -2.22,-0.19 -4.23,1.27 -2.41,-1.7 0.2,-1.73 0.94,-1.42 5.12,-2.47 2.39,-2.72 1.63,-3.03 -0.49,-0.4 -4.11,3.14 -3.57,-1.12 -0.6,-0.47 -0.41,-1.38 1.35,-4.68 3.85,-6.53 0.95,-4.42 -0.48,-4.48 -0.02,-1.47 0.39,-0.46 10.02,-6.56 1.05,0.02 2.69,2.1 5.47,-0.44 6.34,1.76 -0.77,-1.38 -5.12,-1.37 -5.24,-4.17 1.79,-1.43 1.81,-3.12 4.64,-3.19 -1.19,-0.08 -2.98,0.72 -1.46,1.36 -1.73,3.18 -5.64,0.46 -1.09,-1.11 -4.3,2.57 -2.33,2.65 -5.05,2.5 -1.6,1.61 -0.57,1.81 0.39,1.83 -2.8,1.69 -3.12,3.57 -0.39,1.74 0.51,1 -1.24,1.68 -3.24,2.25 -4.22,-1.31 4.09,3.9 0.4,0.95 -0.34,1.97 -1.13,1.74 -5.14,1.77 2.12,1.1 -0.27,1.44 -0.52,0.48 -3.07,1.11 -0.03,-1.58 -0.54,-0.23 -2.71,2.1 -0.21,0.27 0.7,0.45 -1.63,2.36 -3.82,3.28 0.23,0.6 -1.26,4.02 0.56,0.79 5.38,1.8 2.71,1.74 1.04,1.67 -1.26,2.84 -2.04,2.2 -2.79,1.46 -1.79,2.07 -0.75,2.76 -2.32,1.33 0.93,0.34 -0.45,2.79 -3.68,0.9 -0.16,1.34 -4.8,0.85 -1.6,2.88 -5.04,3.16 -0.06,0.7 -2.08,2.82 -2.53,0.49 -0.42,0.39 -0.2,1.67 -2.13,-0.03 -2.2,1.88 -0.49,0.68 0.92,1.84 -0.03,0.75 -0.85,2.09 -1.33,0.84 -0.42,1.15 -1.72,0.09 -4.08,3.74 -3.43,0.75 -1.57,3.23 -3.31,-0.22 -2.38,1.92 1.69,0.65 -5.51,1.75 -1.57,2.53 1.89,0.23 1.25,2.15 -2.28,2.47 -0.53,0.06 -0.22,-1.92 -0.56,-0.37 -1.29,2.89 -0.97,1.14 -8.34,3.59 -0.5,2.32 -1.05,1.4 -0.22,-4.01 -1.05,-0.34 -6.85,4.17 -1.44,1.97 -1.43,-0.31 -1.65,1.39 -1.44,-0.61 -3.2,2.5 -3.25,0.13 -0.15,-1.65 0.72,-1.43 2.41,-0.15 -1.77,-1.38 -1.81,-0.13 -1.57,1.11 -0.99,3.46 -3.78,5.03 -1.06,-0.09 -1.22,1.4 -1.28,0.42 -0.81,-0.51 0.52,-0.58 -0.94,-2.02 -0.54,-0.68 -1,-0.08 0.13,4.14 -0.63,0.83 -2.17,0.84 -1.49,-1.83 -1.41,-0.36 0.22,1.81 -0.35,1.13 -2.32,1.53 0.64,-5.6 1.87,-1.44 2.37,-0.03 8.52,-10.52 5.23,-3.8 5.48,-2.32 0.43,0.14 -0.5,0.76 0.34,0.47 3.34,-0.8 0.24,0.47 -0.28,0.59 -1.21,0.6 0.04,0.5 2.3,2.69 0.65,-0.35 -0.14,-1.68 0.59,-0.32 2,0.14 1.06,0.95 1.66,0.23 0.24,-0.55 -0.43,-0.65 -1.95,-1.44 -0.68,-1.44 2.7,-6.29 5.88,-5.09 5.71,-2.63 4.16,-4.02 0.26,1.37 2.5,0.44 0.16,-5.09 3.87,-5.43 2.13,-1.44 3.28,-3.42 1.23,-0.43 2.3,1.38 0.83,-0.49 -1.24,-0.73 -1.43,-2.94 0.86,-4.61 0.12,-3.34 0.63,-1.92 4.11,-1.17 -3.35,-1.28 -0.4,-3.64 0.71,-1.77 2.65,-3.01 2.89,-2.09 -0.75,-0.8 2.63,-7.98 -1.75,3.22 -2.04,2.45 -11.93,5.78 -1.27,-0.6 -2.28,-4.57 0.88,-3.29 3.92,0.48 -3.89,-2.48 -1.04,0.38 -1.87,3.17 -1.49,-0.99 0.39,1.58 -0.98,4.03 1.02,4.34 -0.19,1.73 -1.85,0.79 -1.5,-1.42 -4.22,-7.06 -2.46,-2.6 -2.85,2.01 -2.64,-1.9 -2.4,-3.2 -5.16,3.96 -4.89,1.58 -0.93,1.23 -0.37,1.62 -4.49,1.26 -4.43,-0.7 3.28,-1.6 1.51,-1.69 -0.64,-2.27 -0.1,-2.63 1.65,-2.06 -1.71,0 -1.1,0.74 -1.02,-1.55 -0.49,-3.06 1.72,-3.22 0.5,-3.6 -3.52,-8.85 -1.19,-4.52 -2.03,-2.42 3.21,-7.62 2.19,-1.64 -2.18,-0.02 -3.76,6.73 -2.46,2.89 1.56,0.87 0.23,0.73 0.31,1.66 -0.8,3.12 -1.85,-0.09 -1.65,1.61 -3.88,1.75 -7.83,0.88 -2.68,-2.04 0.13,-2.21 -3.86,-3.54 -2.18,-3.54 -1.57,-0.08 -2.97,-2.42 0.4,-2.03 -3.73,-0.94 3.84,-4.61 1.33,-3.11 1.07,-0.44 5.54,2.82 0.6,1.08 -1.21,3.09 4.24,-4.05 1.19,0.49 1.88,3.6 2.29,-1.73 1.22,-2.16 -2.3,-1.51 -3.22,-0.74 3.63,-1.15 -1.84,-1.56 -2.79,2.46 -5.09,-0.13 -3.55,-1.43 -4.11,-0.04 -0.69,-0.77 3.49,-3.43 -2.37,0.41 -0.69,-0.84 0.11,-1.47 -0.86,0.93 -1.61,-1.06 1.15,-1.68 -0.34,-0.14 -0.68,0.21 -0.66,1.27 0.12,2.5 -2.1,0.09 -1.43,-4.66 -1.96,-0.85 -0.48,-1.62 1.24,-2.08 -0.55,-1.07 -1.32,-0.35 -1.51,1.05 -0.67,-0.94 -0.17,-2.5 4.08,-1.09 -2.4,-1.25 -0.67,-1.32 5.3,-1.6 -1.28,-2.17 -0.21,-1.27 0.42,-2.16 5.83,-9.12 2.22,-1.49 2.75,0.91 -0.98,-2.08 1.78,-0.67 1.12,-2.5 -2.31,2.13 -0.6,-4.41 0.52,-2.92 1.39,-2.56 3.33,-0.26 0.11,-0.59 -1.71,-1.85 1.32,-2.2 3.43,-1.18 1.87,0.37 2.36,1.37 1.36,1.7 -1.38,2.74 2.65,-2.25 2.47,1.49 3.87,-1.72 1.59,-2.31 2.12,-1.49 3.85,-6.7 1.94,-0.12 0.64,1.6 0.94,0.47 5.33,-0.39 2.72,-0.73 3.86,-4.19 1.14,-1.76 0.55,-2.31 -1.43,-5.49 -0.95,-5.74 -2.65,-3.82 -1.88,-1.14 -1.2,0.16 0.87,-2.45 2.52,0.27 2.97,-1.66 1.09,-2.73 -0.58,-3.03 -2.76,-3.48 -3.83,3.5 -3.33,-0.58 -1.24,1.97 -5.31,3.45 -3.42,4.29 -0.86,1.93 -1.09,0.09 -0.79,-3.75 -3.73,-3.6 -1.12,1.23 1.46,1.93 1.39,0.35 -1.05,2.53 -3.89,-3.33 -2.58,-1.01 -6.72,0.11 -4.42,2.02 -0.83,-0.58 -2.43,2.01 -13.25,-3.42 -2.07,-1.14 -1.78,-2.72 0.04,-1.86 0.79,-0.78 -0.08,-2.67 -1.54,-0.71 -4.29,-5.51 1.88,0.6 2.64,-0.53 0.9,-2.52 3.76,-0.36 -0.41,-0.68 -14.19,-3.72 -6.63,-4 -1.15,-2.48 1.79,-2.5 0.19,1.86 3.8,-2.14 1.99,-2.8 3.77,-0.49 3.71,-4.89 3.97,-2.6 2.1,-0.72 2.34,1.37 4.31,-0.28 0.79,-1 -3.18,-2.2 0.32,-1.23 4.12,-3.45 4.39,-0.79 6.86,-4.3 8.34,-0.8 1.02,1.19 -2.91,-0.03 1.35,1.28 -1.45,4.35 0.1,2.59 -1.59,2.02 3.85,3.71 9.2,-0.44 3.41,1.36 4.24,-0.57 3.19,0.79 1.34,-0.3 2.95,-5.54 1.16,-0.87 2.89,1.75 1.04,-0.57 0.86,1.43 -0.4,-2.99 -0.58,-1.12 -4.83,-2.06 -3.22,1.02 -1.01,-1.16 0.33,-2.31 -3.46,-5.73 -1.44,-1.17 -1.7,-0.06 -1.59,-4.59 2.8,-1.53 1.23,0.83 1.38,3.4 1.3,0.5 -0.38,3.36 1.61,3.09 3.62,2.85 4.96,-1.02 4.22,3.16 1.52,0.32 4.77,-1.34 0.05,-2.51 -0.4,-1.83 -1.12,-1.15 -3.22,0.22 -2.51,-1.89 -2.13,0.52 -3.94,2.89 -5.22,-4.26 -0.25,-2.99 2.92,-5.08 -1.11,-1.2 -2.8,-0.85 -4.84,0.87 -0.21,-2.46 -1.97,2.5 -4.77,-0.26 -6.03,-2.2 -2.15,-2.72 -2.52,-8.33 -2.08,-3.85 -14.35,-13.23 -6.52,-3.36 -3.15,-3.74 -6.26,-2.52 2.74,-2 -1.16,1.56 0.88,0.4 2.16,-1.98 2.26,-11.61 -0.31,-2.78 7.96,0.56 13.73,-2.18 4.95,-3.17 3.78,-4.26 3.76,-7.15 0.5,0.14 0.77,-7.23 1.61,-4.83 12.18,-19.13 1.37,2.5 -3.56,3.22 12.26,-4.8 4.12,-4.81 5.88,-4.94 1.75,0.79 -1.62,3.26 1.14,0.86 -1.02,3.87 2.14,0.06 0.47,1.78 0.58,-7.4 1.5,0.68 3.37,-1.62 -4.09,-0.2 -2.45,-3.55 -1.36,-0.02 4.56,-5.24 4.16,-3.17 1.4,0.65 0.1,0.96 -1.78,1.76 1.01,1.13 2.9,-1.84 4.27,0.09 1.55,-1.45 6.54,-0.67 6.65,-6.25 6.16,-9.85 3.57,-3.16 0.85,0.39 -1.96,1.96 1.11,1.78 9.38,3.85 0.75,2.17 -0.63,2.09 -1.93,2.31 -3.89,2.36 1.19,0.89 0.78,2.09 1.15,0.26 3.33,-2.07 4.7,-7.16 2.53,0.56 3.08,3.36 -1.27,3.24 6.71,3.23 3.15,-2.64 4.79,-0.48 3.01,-1.44 10.61,2.98 0.77,1.26 -2.33,2.66 -0.38,2.74 2.29,1.34 0.19,1.59 0.91,0.4 4.6,-0.12 -2,3.68 8.19,1.13 6.39,-3.1 4.43,2.57 4.59,-2.56 6.84,0.3 6.61,2.88 2.38,3.33 3.82,-1.27 3.11,1.76 1.87,2.9 7.31,1.57 3.62,-0.71 10.49,1.06 7.12,5.06 6.58,0.88 2.3,-1.89 13.63,-2.58 5.81,2.75 4.68,5.44 6.8,3.28 3.31,3.84 4.62,0.09 0,254.4 5.42,1.88 0.83,-1.86 5.46,2.67 3.37,-3.33 6.8,-0.36 0,1.48 -1.21,4.48 1.47,1.87ZM158.04,1032.11l-0.44,0.16 3.71,-3 -3.27,2.84ZM97.13,1101.66l0.17,0.62 6.53,0.56 2.3,-1.92 2.75,-0.77 3.51,2.09 1.19,3.21 4.47,1.56 0.8,1.45 9.54,1.59 -0.52,2.45 -1.03,1.07 -5.83,0.01 -2.22,2.84 -0.13,1.54 -1.2,1.02 -1.62,-4.17 -4.22,-1.87 -0.94,-2.22 -2.9,-2.41 -4.86,-1.87 -6.43,3.07 -3.09,-2.35 -0.31,-2.68 0.82,-4.44 1.13,-0.61 2.09,2.23ZM364.88,1170.44l-1.44,0.19 -0.76,-0.62 0.25,-1.68 0.73,-0.18 0.83,0.56 0.39,1.73ZM82.58,1179l2.46,1.51 1.57,-0.16 1.77,2.29 -4.59,-0.68 -4.99,-3.79 0.3,-1.74 1.41,-0.89 0.72,2.34 1.35,1.12ZM318.34,1181.2l-0.55,0.08 0.74,-1.13 0.51,-2.22 0.68,0.3 0.14,0.41 -1.52,2.56ZM367.98,1179.16l-0.36,1.18 0.34,1.07 -0.82,3 -0.96,0.84 0.12,-1.04 -0.75,0.02 -0.23,-1.6 1.11,-3.69 0.39,0.49 0.81,-1.22 0.35,0.95ZM382.36,1179.17l0.26,0.64 3.06,0.25 -5.61,3.28 -1.22,-2.92 1.62,-1.96 1.89,0.71ZM396.87,1181.77l-0.36,0.56 -1.52,-0.56 1.77,-1.48 0.3,0.3 -0.19,1.18ZM157.75,1180.7l1.04,1.14 2.31,-0.28 1.26,0.73 0.46,2.07 -0.26,3.54 0.93,0.93 0.44,2.62 -4.04,0.53 -1.74,0.91 -0.35,0.68 0.28,1 -0.48,0.26 -1.29,-1.15 -4.16,-1.13 -5.82,-3.27 -3.38,-4.52 2.1,-0.62 4.72,0.38 0.59,-1.82 3.52,-1.98 3.87,-0.02ZM367.09,1193.71l-1.25,0.33 -0.3,-0.67 1.19,-2.61 4.91,-5.51 1.77,-3.97 1.83,0.6 0.71,0.99 -4.11,4.89 -2.05,4.21 -2.7,1.74ZM363.84,1187.99l-0.59,0.7 -2.25,-0.43 0.46,-1.37 1.72,-0.87 1.89,1.35 -1.23,0.62ZM403.16,1193.6l-0.54,0.13 1.92,-3.13 2.38,-1.47 -0.15,0.75 -3.61,3.72ZM217.1,1221.18l-1.72,0.18 -0.7,-2.17 1.65,-1.49 3.09,-1.29 -2.32,4.77ZM313.05,1223.19l-1.72,-1.24 1.98,-1.67 1.08,0.16 0.07,0.88 -1.41,1.87ZM313.83,1225.9l0.42,0.18 0.73,-1.34 1.35,1.1 0.82,-0.24 0.53,1.34 1.19,0.05 -0.09,1.42 -1.44,1.8 -1.82,-1.96 -0.75,0.94 0.29,1.6 -2.6,0.71 -0.38,-1.45 -0.31,0.12 -0.96,2.14 -2.8,1.5 -5.15,-2.01 4.61,-4.53 2.33,0.4 0.03,-1.45 -0.82,-1.54 2.6,-0.64 2.22,1.86ZM515.64,1230.19l5.01,0.39 3.12,5.8 1.62,5.23 -1.16,-0.9 -2.9,-7.28 -0.8,-0.81 -0.64,0.32 0.45,3.21 3.75,6.46 0.19,1.9 -0.6,0.85 0.74,1.75 -0.19,0.67 -1.99,0.78 -1.82,3.22 -1.99,1.88 -1.36,-0.01 -0.67,-1.69 -0.07,-1.2 0.5,-0.77 1.01,-5.27 -1.97,-3.31 -1.38,-9.41 -1.44,-3.99 -0.18,-1.99 0.98,0.75 1.79,3.42ZM519.82,1228.74l-0.08,0.54 -1.55,-0.05 -2.34,-1.83 1.61,-0.9 2.36,2.24ZM503.69,1228.41l1.63,2.11 -0.32,1.92 -0.89,0.41 0.91,1 3.04,-2.85 2.09,0.61 2.37,1.73 0.3,1.35 -0.49,2.9 -1.5,0.5 -1.46,-0.47 -1.22,1 1.01,0.77 3.08,0.18 1.2,2.87 -0.66,2.29 -7.2,-3.93 -0.5,0.34 -0.11,3.61 -0.84,1.28 -2.49,-0.56 -1.89,-4.84 -4.36,-4.24 -1.24,-2.12 0.64,-2.66 1.63,-1.01 0.54,-1.64 2.03,2.6 0.01,-1.2 0.55,-0.95 1.67,-0.17 1.83,-1.35 0.64,0.52ZM308.36,1237.45l0.08,1.17 3.13,-1.71 2.13,0.5 0.11,0.92 -0.76,1.03 0.04,0.66 0.81,1.22 1.99,0.66 0.23,0.8 -2.23,2.59 -6.02,-0.91 -0.64,0.61 2.46,0.33 1.16,2.29 -2.27,0.51 -1.97,1.75 -2.53,0.24 -3.57,3.12 -1.65,0.53 0.98,0.47 0.04,1.44 -1.3,2.14 -2.45,1.74 -0.89,-0.29 -0.22,-0.67 3.16,-3.52 -2.35,-1.26 -1.18,0.6 0.77,-2.11 -2.37,-0.44 -1.56,0.97 1.61,0.2 0.62,1.71 -0.87,1.95 -0.88,-0.19 -1.82,-2.41 -0.81,-3.55 -1.55,-2.73 0.37,-2.33 1.57,-2.4 2.89,-1.67 1.88,-0.28 0.98,0.43 0.4,0.92 -0.15,0.66 0.69,0.56 1.62,3.63 1.34,1.12 -1.26,-2.91 -0.46,-4.09 1.69,-0.1 -0.04,-0.48 -2.42,-2.72 0.74,-1.54 1.66,-0.18 1.94,3 0.42,0 1.11,-1.44 1.97,0.06 0.55,-2.46 -0.65,-1.01 0.74,-0.3 3.53,1.61 -0.54,1.56ZM304.46,1236.89l-0.62,0.44 -2.56,-2.71 0.45,-0.32 1.52,0.82 1.21,1.77ZM512.34,1247.47l1.67,4.1 2.31,9.14 0.11,2.38 -0.53,1.66 0.31,4.54 -0.59,1.77 -1.42,-1.34 -1.98,-4.88 0.16,-1.6 0.95,-1.71 -1.53,0.39 -1.61,-1.35 -0.05,-2.05 -1.38,0.49 -0.52,-0.45 0.17,-2.29 1.32,-1.99 -1.61,-1.13 -0.39,-2.25 -0.91,-1.28 -0.53,0.12 -1.82,4.41 -1.71,0.5 0.51,-1.9 -0.63,-3.78 0.4,-0.78 1.85,-0.78 2.01,-3.8 1.16,0.02 4.28,3.84ZM111.95,1251l-1.18,0.99 -1.07,-0.37 -0.32,-1.02 3.08,-0.82 -0.51,1.22ZM307.12,1252.24l-1.7,0.65 -1.58,1.95 -0.9,-1.07 0.23,-1.68 0.78,-1.11 4.29,0.68 -1.12,0.58ZM530.59,1254.78l0.76,0.65 0.41,-0.68 2.19,0.64 1.33,1.96 -0.06,4.22 -0.51,1.1 -3.7,-4.28 1.96,4.54 0.14,1.71 -0.41,1.12 -4.8,0.21 -0.53,-1.09 -0.36,-5.81 -1.62,-2.64 -1.78,-1.78 0.2,-0.71 1.09,-0.53 5.69,1.37ZM523.5,1258.08l0.73,1.44 1.07,-0.11 1.05,2.71 -0.32,1.04 -1.01,0.37 -0.33,5.97 -0.74,3.36 -0.5,0.55 -0.84,-0.65 -0.63,1.13 -0.76,0.01 -0.63,-2.58 0.56,-4.31 1.27,-0.88 -2.34,-2.55 0.13,-0.77 -1.21,-2.21 0.13,-2.39 1.13,-1.65 1.49,-0.3 1.75,1.82ZM537.64,1264.7l-1.57,0.27 -0.53,-0.25 -0.19,-0.88 1.2,-4.71 2.12,2.28 1,2.25 -2.03,1.04ZM116.56,1262.44l2.33,0.14 0.87,0.71 -1.8,0.99 -1.52,-1.28 0.12,-0.56ZM293.45,1264.92l-1.41,-0.5 0.12,-0.65 1.2,-0.79 1.21,0.12 -0.07,1.22 -1.05,0.6ZM288.05,1266.55l-0.77,0.49 -0.3,-0.58 1.75,-2.5 1.2,-0.81 0.83,0.57 -2.71,2.83ZM544.86,1273.24l-0.24,3.38 -2.68,0.07 -0.59,-0.81 0.16,-1 -0.51,-0.56 -2.37,-0.45 -0.45,-2.45 1.14,-0.88 2.49,-5.29 0.72,0.24 2.84,4.99 -0.51,2.76ZM537.26,1270.42l-1.27,-0.25 -1.66,-2.16 1.54,-1.83 2.94,0.38 -0.03,2.51 -1.52,1.35ZM528.31,1268.53l4.14,0.4 1.38,2.58 -0.17,2.12 3.85,1.94 1.82,2.03 1.91,4.21 2.93,4.15 -3.85,-2.27 -1.37,2.42 2.43,-0.19 2.3,1.99 0.63,1.21 -0.53,1.97 2.3,-0.12 0.32,0.44 -0.27,3.47 0.22,4.54 -0.46,1.55 -1.91,-0.17 -1.73,-3.41 -2.37,-0.89 -0.5,-0.86 -0.33,-2.79 -0.9,0.11 0.21,1.13 -0.24,0.87 -0.89,-0.37 -1.48,-2.78 -2.34,-2.78 0.17,-0.65 1.64,-0.71 -1.4,-2.18 0.56,-1.72 -3.02,-0.34 -0.8,-1.66 -2.1,-0.04 -1.44,-1.9 1.09,-1.04 1.96,0.77 1.94,-2.48 -0.55,-1.99 -0.93,-0.35 -3.56,1.89 -0.66,-0.45 -0.15,-0.7 2.56,-2.98 -0.73,-1.45 -0.05,-2.04 0.37,-0.48ZM557.75,1285.79l-1.18,4.46 -1.2,1.2 -0.84,-0.27 -0.62,-0.97 -1.19,-0.15 -0.34,-0.8 0.33,-1.05 -0.29,-0.8 -0.85,1.35 -1.36,0.84 -1.37,2.66 -0.56,-1.14 -0.4,-3.86 2.26,-3.41 0.26,-4.97 4.05,-2.51 3.09,4.62 0.36,1.17 -0.15,3.63ZM278,1279.1l-0.44,0.64 -0.86,-0.05 -0.65,-0.77 1.64,-1.91 0.31,2.09ZM531.28,1284.7l0.27,0.92 -4.19,4.58 0.17,-2.89 -1.16,-1.67 1.17,-0.85 3.74,-0.09ZM219.76,1289.29l1.51,-1.32 -0.35,1.46 1.09,2.45 -1.38,0.52 -1.06,-0.38 -1.06,0.65 -0.35,-0.57 -0.16,-3.22 1.32,-1.39 0.59,0.5 -0.15,1.3ZM223.81,1288.83l-0.16,1.58 -1.98,-1.5 2.14,-0.08ZM536.32,1297.65l0.28,0.26 0.75,-0.89 1.76,0.67 -0.34,2.69 -0.67,1.42 -1.15,-0.49 -2.3,-2.88 -1.29,-2.28 -1.46,-4.08 -1.9,-0.7 -0.41,-1 0.28,-0.86 1.51,-0.44 2.27,2.23 1.15,2.06 0.16,1.54 1.36,2.75ZM229,1293l-4.03,4.09 0.84,-2.29 -0.21,-1.69 2.16,-1.49 0.7,-1.39 0.56,0.08 -0.31,0.84 0.67,0.78 -0.38,1.07ZM553.65,1293.97l1.22,3.49 -1.98,0.19 -0.45,-0.3 0.16,-1.72 -0.57,-0.77 -1.26,0.19 -0.03,-1.3 0.45,-0.92 -0.26,-2.22 0.75,-0.28 1.23,0.98 0.74,2.66ZM233.07,1292.54l-0.22,1.83 -1.3,-0.29 0.11,-0.99 0.47,-0.03 0.26,-1.83 0.34,-0.17 0.34,1.48ZM234.81,1296.1l-0.67,-0.11 -0.46,-1.6 0.81,0.35 0.32,1.36ZM188.01,1295.94l1.1,3.27 2.78,1.82 0.58,1.06 -3.12,-1.31 -2.56,2.17 -5.58,0.09 -1.84,0.97 -1.92,2.42 -2.13,0.86 -2.64,-0.29 -0.92,-2.46 0.18,-1.24 2.07,-1.66 2.59,-4.24 2.33,0.14 5.31,-2.96 2.27,-0.03 1.5,1.39ZM201.41,1298.58l-1.06,-0.51 -0.49,-1.16 1.93,-1.03 0.35,1.02 -0.73,1.68ZM198.49,1307.34l-0.98,0.43 -1.05,-0.45 -0.9,-0.82 -0.1,-0.98 2,0.64 1.03,1.18ZM164.28,1312.5l-0.61,-0.06 -0.45,-2.21 1.18,-0.61 0.72,1.22 0.91,0.49 -1.75,1.17ZM161.09,1313.78l-2.22,0.46 -0.79,-1.9 0.74,-0.9 1.69,-0.31 2.27,2.08 -1.69,0.57ZM152.29,1317.07l0.49,0.91 0.85,-0.58 1.42,-2.23 1.61,1.28 -2.93,2.84 -0.69,1.63 1.87,-0.38 0.86,0.44 -4.47,3.09 -0.78,1.16 -4.36,1.3 -5.4,2.83 -2.05,-1.22 7.65,-3.87 0.5,-2.1 0.87,-1.2 1.39,0.02 0.85,1.07 0.17,-0.84 0.71,-0.53 -3.75,-1.36 -0.53,-1.72 0.91,-1.34 4.15,-1.23 0.52,0.19 0.14,1.84ZM156.9,1320.49l-0.46,-0.86 1.55,-1.45 -1.09,2.31ZM136.94,1327.73l-3.49,2.04 -2.67,3.69 -6.64,3.99 3.34,-4.02 0.2,-1.97 1,-1.49 3.53,-1.07 -0.19,-2.39 1.24,-1.74 2.44,-1.09 2.79,0.94 0.27,0.44 -0.69,1.86 -1.13,0.81ZM117.28,1337.16l-0.35,1.04 -2.93,-0.26 -0.13,-0.45 1.95,-1.01 1.46,0.68ZM105.43,1342.15l-0.72,0.6 -0.34,-0.96 1.65,-1.81 1.11,0.56 -0.34,1.09 -1.36,0.52ZM60.56,1352.32l-6.1,0.76 -0.93,-0.52 11.25,-3.59 0.54,-0.99 -2.01,-0.89 3.03,-1.92 1.72,1.65 -0.42,1.59 -1.41,0.85 0.66,1.21 -6.33,1.85ZM85.73,1347.92l-1.76,-0.01 1.7,-2.14 1.78,1.09 -1.72,1.06ZM73.35,1350.45l6.03,1.06 -4.98,0.69 -4.27,-0.12 -1.78,-1.39 2.26,0.35 1.56,-0.73 1.18,0.14ZM45.27,1352.93l-0.27,0.54 -1.11,-0.58 -0.48,-0.96 0.33,-0.8 0.89,-0.01 1.16,1.32 -0.52,0.49ZM38.76,1355.43l0.06,0.62 1.71,0.24 -0.17,1.55 -0.66,-0.18 -2.96,2.12 -0.75,-0.84 -1.42,1.32 0.99,-3.43 1.57,-0.91 -0.1,-1 0.54,-1.69 1.15,0.08 0.53,0.69 -0.49,1.43ZM32.45,1358.19l-5.77,0.74 -0.17,-0.45 4.7,-1.91 1.03,-1.93 0.64,-0.35 0.54,0.49 -0.82,1.75 -0.15,1.66ZM24.13,1359.42l-0.53,0.59 -1.51,-1.01 -0.23,-0.34 0.9,-0.48 0.15,-0.86 -2.37,-2.18 0.89,-0.62 1.85,-0.04 1.76,1.44 1.76,0.25 -1.43,0.9 -1.24,2.35ZM45.41,1356.43l-0.96,0.4 -1.26,-0.81 0.12,-0.95 2.1,1.36ZM42.25,1356.81l-0.72,1.08 -0.53,-0.49 -0.2,-1.49 0.4,-0.38 1.05,1.28ZM1052.56,1684.94l-1.51,1.48 -4.36,0.45 2.45,-0.8 -0.76,-1.53 -0.76,-0.55 0.01,-1.48 -1,-1.75 -1.42,4.32 -3,-0.05 -0.99,-20.2 4.57,-41.48 -1.35,-1.27 29.35,0.32 4.81,28.06 2.12,5.82 0.47,1.57 -0.14,0.66 0.73,1.01 -1.29,1.86 -1.01,3.58 -0.01,1.39 0.79,2.73 -0.42,3.69 0.28,2.37 0.69,1.54 -29.43,0.01 -0.09,1.86 2.2,2.9 -0.24,2.16 -0.69,1.33ZM1045.94,1686.59l-2.78,0.16 2.35,-0.44 0.43,0.28ZM1027.36,1608.42l0.18,1.13 -0.85,0.45 -0.18,1.17 -1.31,0.77 -0.56,1 0.2,1.23 -0.47,1.23 -1.12,1.25 -0.48,1.39 0.17,1.55 -0.56,1.24 -1.29,0.94 -0.73,2.05 -1.09,0.66 -0.67,1.26 -0.74,0.45 -0.5,3.1 -0.59,1.24 -1.44,0.79 -0.63,1.44 -1.05,0.87 -0.35,0.83 0.29,1.1 -1.77,1.02 0.37,1 -0.17,1.01 -1.76,2.08 0.4,0.8 -0.48,0.46 0.84,1.97 -0.26,1.97 0.65,1.04 -0.49,2.74 -32.9,0.05 -0.07,-7.38 -1.64,-0.47 -1.89,0.38 -1.44,-1.19 0.51,-24.01 -2.04,-15.66 50.7,0 1,1.83 -0.01,1.06 -2.59,2.78 -0.89,1.5 7.7,-0.12ZM807.28,1672.34l-22.69,0.05 -43.17,-15.87 1.31,-2.92 1.58,-0.14 0.75,-0.51 0.44,-0.94 -0.15,-1.92 -1.79,-1.2 -0.64,-1.33 -0.17,-2.19 0.2,-1.18 1.13,-0.71 0.92,-1.88 0.14,-4.06 2.05,-3.27 2.31,-1.99 -0.37,-0.94 -2.42,-1.84 -0.31,-1.4 -2.42,-4.4 0.23,-6.19 -0.81,-2.69 0.19,-1.2 -0.47,-4.02 -0.62,-1.35 0.82,-1.52 1.86,-0.49 1.13,0.11 1.98,1.64 0.56,0.02 1.6,-2.13 0.03,-11.65 56.81,0.04 -0.01,78.07ZM743.99,1622.54l-0.01,1.16 0.61,1.57 1.81,2.83 0.31,1.4 2.8,2.36 -0.01,0.42 -3.33,3.24 -1.03,2.02 -0.14,4.06 -0.92,1.88 -1.13,0.71 -0.03,3.37 0.64,1.33 1.79,1.2 0.25,0.97 -0.54,1.89 -0.75,0.51 -2.92,0.41 -26.05,2.31 -0.1,-1.56 -0.53,-0.53 -0.68,0.33 -0.22,-3.72 -0.64,-2.19 -1.69,-2.66 -6.97,-5.82 -2.1,-0.5 -0.33,0.63 -1.33,-0.43 0.2,-1.56 -1.29,-2.19 -3.7,-0.09 -3.55,-1.21 -1.05,-0.71 -0.36,-1.29 -3.85,-2.21 -1.22,0.26 -3.87,-0.97 -4.87,-0.03 -1.86,-1.49 0.23,-3.21 -0.44,-1.91 0.34,-1.77 -0.29,-0.63 -2.26,-1.22 -0.31,-0.91 0.28,-1.26 -0.45,-0.83 -1.4,-0.78 -1.31,-1.77 -1.66,-0.97 -0.68,-1.62 -3.65,-5.09 -2.42,-2.5 -0.47,-3.41 1.46,-2.27 -0.2,-1.69 -0.83,-1.24 -3.23,-0.74 -2.62,-3.09 -0.16,-2.37 -1.03,-2.43 -0.17,-3.3 0.78,-0.37 0.7,0.13 0.16,1.91 0.83,0.92 1.49,1.3 1.09,0.33 -3.58,-6.94 0.81,-0.67 2.58,-0.61 6.39,-0.09 -1.14,-0.41 -2.9,0.13 -1.72,-0.7 -1.39,0.84 -2.72,-1.15 -1.03,0.52 -0.13,2.24 0.32,1.67 -0.62,0.17 -4.67,-3.31 -0.76,0.97 0.35,-1.57 -0.11,-1.88 1.14,1.5 -0.35,-1.06 -1.57,-1.57 -0.86,-2.09 -1.91,-1.26 -4.68,-5.42 -0.21,-2.98 -1.15,-3.78 0.48,-2.16 -0.62,-3.85 -3.14,-4.73 -2.45,-2.35 -0.37,-1.78 -0.17,-1.79 1,-3.29 0.34,-0.45 0.38,0.66 0.34,-1.13 -0.33,-0.28 0.98,-2.7 -0.08,-2.81 0.82,-3.45 -0.56,-3.61 -0.52,-1.48 -0.93,-1.05 0.41,-1.54 -0.22,-1.72 48.1,0.01 0.01,44.9 21.32,18.98 40,38.16ZM684,1635.13l2.32,0.7 1.25,-0.33 0.22,0.34 -2.96,0.82 -0.86,-0.37 -0.37,-1 0.4,-0.16ZM679.18,1635.88l-1.54,-0.11 0.84,-0.55 0.7,0.66ZM682.17,1637.34l-1.4,0.01 -0.97,-1.32 2.05,-0.17 1,0.73 -0.68,0.75ZM701.46,1644.62l0.58,1.01 -1.7,-0.07 -0.52,-1.31 -0.76,-0.26 -0.12,-0.44 2.52,1.07ZM689.06,1646.92l-1.2,-0.1 -0.36,-0.73 1.1,0.05 0.46,0.78ZM701.44,1652.2l-1.4,-0.15 -1.33,-2.33 0.37,-0.3 2.36,2.78ZM807.29,1594.27l0,-58.59 79.89,0.01 0.14,58.58 -80.03,0ZM1231.07,1520.32l0.05,7.51 -0.53,2.8 -4.81,0.66 -1.2,-0.31 -1.23,0.55 -5.07,-0.14 -1.13,1.04 -6.9,3.39 -1.05,-1.7 2.71,-1.73 -0.69,-1.16 0.73,-11.58 7.66,0.33 0.01,0.4 0.56,-0.4 10.89,0.34ZM1171.57,1567.03l-1.05,-0.8 0.91,-1 1.26,1.81 -1,1.19 -0.12,-1.2ZM1194.24,1573.35l-7.62,0 -0.88,-18.57 1.23,-1.56 1.89,-0.24 1.02,0.42 -1.9,2.58 0.16,2.42 1.83,2.88 0.23,2.77 0.93,1.85 1.43,2.15 1.1,0.61 -0.46,2.11 -0.66,0.6 1.3,0.19 0.4,1.79ZM1052.56,1684.94l0.69,-1.33 0.24,-2.16 -2.2,-2.9 0.09,-1.86 29.43,-0.01 1.4,3.72 30.08,2.05 0.52,2.28 0.93,0.29 0.94,-1.4 -0.09,-3.36 0.92,-1.09 3.23,0.98 1.93,0.11 0.53,1.2 2.36,11.15 1.65,4.41 2.33,5.31 4.27,7.32 -0.49,0.77 -0.2,2 1.46,4.79 -0.49,-0.44 -1.25,-3.13 0.03,-4.47 -0.29,0.07 -0.69,2.24 -0.44,-1.53 0.49,-1.5 -0.88,-0.7 -0.05,-1.29 -0.77,-0.33 1.02,4.88 5.95,15.1 1.56,2.72 0.54,5.42 -0.97,9.32 -0.37,-0.56 -1.61,3.28 -0.76,3.62 -1.34,1.28 -0.83,-0.04 -2.03,0.96 -1.43,-0.25 -2.83,0.48 -0.64,-1.14 0.35,-1.02 0.44,-0.12 1.5,1.2 0.29,-0.51 -0.46,-0.59 -1.51,-0.7 -2.64,-4.6 -0.22,-1.25 -2.32,-0.77 -1.67,-1.16 -1.09,-2.06 -0.63,-3.67 -1.05,-0.7 1.48,-2.5 -1.04,0.7 -0.57,1.01 -0.79,0 -0.43,-1.93 0.12,-2.39 0.61,-0.89 -1.91,0.31 0.01,1.24 -1.25,-0.4 -1.72,-2.41 -2.04,-4.37 -1.07,-1.26 0.9,-0.32 2.67,-3.99 -0.51,-0.87 -0.6,0.45 -1.56,-1.46 -0.45,0.22 0.89,1.17 -0.16,1.24 -0.57,0.75 -0.62,-0.19 -0.31,0.31 -1.15,-1.76 2.09,-8.26 0.1,-5.21 -1.34,-2.13 -5.93,-5.22 -4.6,-6.21 -3.98,-2.34 -3.02,0.52 -0.52,0.47 -0.31,1.59 -1.9,0.13 -2.85,1.64 -1.01,-0.06 -1.59,0.74 -3.3,0.53 -0.65,-0.19 -0.43,-0.95 0,-0.98 0.88,1.34 0.25,-0.24 0.09,-0.52 -0.53,-1.02 -3.67,-3.23 0.6,0.06 0.15,-0.41 -0.61,-0.54 0.68,-1.29 -1.56,0.56 -0.17,1.02 -4.77,-2.18 -3.18,-0.88 2.44,-0.39 1.32,0.31 -0.47,-0.78 -1.05,-0.38 -2.17,-0.03 -2.63,1.22 -5.94,0.84 0.89,-0.75 1.56,-0.45 0.24,-0.94 -0.37,-0.91 -0.85,0.93 -1.12,-0.51 -0.16,1.12 -1.09,1.51 -2.22,0.6 -0.28,-0.2 0.59,-1.12 -0.47,0.22ZM1081.94,1694.59l-1.15,0.48 -1.23,-0.35 1.32,0.08 3,-1.38 -1.94,1.17ZM1135.65,1725.2l0.19,0.94 -2.34,-5.62 -0.69,-2.67 2.84,7.35ZM1114.07,1734.46l-0.02,0.75 -0.95,-2.64 0.54,0.45 0.43,1.44ZM1114.6,1735.72l-0.41,0.33 -0.82,-0.25 -0.64,-1.29 0.97,1.11 0.9,0.1ZM1133.43,1752.29l-2.26,2.36 1.42,-2.45 1.15,-1.06 0.04,-0.8 1.07,-0.64 -1.42,2.59ZM1130.52,1755.29l-0.31,0.06 0.57,-0.5 -0.26,0.44ZM1125.9,1757.63l-0.52,0.29 -0.54,-0.21 2.35,-0.62 -1.29,0.54ZM1122.59,1758.46l-0.5,0.17 -0.47,-1.42 1.11,0.81 -0.14,0.44ZM1119.95,1759.09l-0.74,0.12 0.6,-0.49 0.19,-0.75 0.34,0.94 -0.39,0.18ZM1117.48,1759.78l-0.31,-0.16 0.83,-0.22 -0.52,0.38ZM1080.81,1676.68l-0.69,-1.54 -0.28,-2.37 0.42,-3.69 -0.79,-2.73 0.01,-1.39 1.01,-3.58 1.29,-1.86 -0.73,-1.01 0.14,-0.66 -0.47,-1.57 -2.12,-5.82 -4.81,-28.06 28.55,0 -2.3,2.71 -0.44,1.35 3.44,2.73 2.34,1.02 2.94,5.77 2.7,2.47 1.63,2.38 2.31,1.92 2.56,4.47 2.3,1.72 1.01,1.8 1.28,4.44 0.99,0.68 1.35,2.39 0.41,2.67 0.69,0.97 2.3,1.07 -0.58,1.14 -2.16,0.89 0.54,1.21 -1.5,1.12 0.32,1.26 -1.02,0.95 0.95,0.1 -1.36,2.14 -0.97,0.24 1.05,1.18 -0.87,1.23 -0.88,-0.37 -0.89,4.32 0.19,1.89 -1.93,-0.11 -3.23,-0.98 -0.92,1.09 0.09,3.36 -0.94,1.4 -0.93,-0.29 -0.52,-2.28 -30.08,-2.05 -1.4,-3.72ZM1121.63,1677.08l-0.5,3.23 -0.24,-2.25 0.74,-0.98ZM234.69,1792.13l-1,0.69 -1.68,-0.41 -2.06,-1.62 0.72,-1.21 1.67,-1.02 2.59,0.04 0.58,1.41 -0.82,2.12ZM225.51,1793.25l-0.23,0.54 -0.39,-0.08 0.15,-1.15 1.37,-1.45 0.59,0.13 -0.36,1.2 -1.13,0.81ZM252.59,1797.96l0.9,-0.02 0.17,0.98 0.8,0.86 -1.86,0.47 -1.17,-0.88 -0.65,0.17 -0.22,-0.63 -0.45,0.13 0.42,0.63 -1.47,-0.03 -1.47,-2.08 -0.39,-1.18 1.71,-0.18 1.17,-1.12 0.66,-0.12 1.85,3ZM259.26,1800.9l5.7,0.74 -0.4,0.63 -1.28,0.57 -1.83,-0.5 -3.06,-0.18 0.46,-1.43 0.41,0.17ZM267.53,1804.35l0.29,0.22 2.09,-0.45 3.27,2.37 -1.33,1.36 -3.43,0.49 -0.34,-0.16 -0.48,-2.23 -0.72,0.14 -0.82,-0.39 -0.93,-1.55 0.46,-0.92 0.82,-0.12 1.12,1.24ZM263.4,1806.3l-0.67,0.34 -0.74,-0.16 -0.88,-1.88 1.24,-0.22 0.7,0.31 0.81,0.9 -0.46,0.71ZM277.83,1827.6l-0.5,0.58 -0.63,-0.04 -2.28,-1.24 -0.28,-0.67 0.17,-3.09 -1.8,-4.44 2.6,-3.19 -0.82,-1.86 0.21,-1.12 0.48,-0.2 7.2,3.42 1.29,1.43 0.22,1.54 0.88,0.2 0.41,1.06 1.69,1.45 -0.52,0.85 -2.31,1.62 -2.92,0.71 -2.57,1.82 -0.52,1.17ZM1007.59,1545.01l-2.73,-2.58 -0.56,-1.09 -45.89,0.34 -1.07,-2.15 0.28,-2.17 -0.14,-2.87 -0.74,-2.5 0.32,-0.64 -0.75,-1.21 0.07,-1.42 -0.44,-0.19 -0.34,-0.98 -0.53,-0.12 -0.32,-4.19 -1.31,-3.29 -1.07,-1.48 -0.69,-1.96 -0.31,-2.42 -1.11,-1.44 -0.66,-2.28 -0.94,-1.1 1.82,-6.22 -0.32,-1.18 -0.84,-0.58 0.33,-1.49 -0.73,-2.5 60.91,-0.08 0.3,1.68 1.16,1.01 0.12,0.83 -0.62,2.74 1.04,4.88 4.34,2.76 1.12,2.55 1.19,0.95 1.58,2.59 2.03,1.76 0.18,1.82 -0.75,2.57 -0.66,0.66 -0.81,2.1 -1.02,1.09 -1.71,1 -4,1.05 -1.25,0.86 -0.38,1.34 0.18,1.13 1.16,1.86 0.12,1.01 -1.69,4 -1.29,1.51 -1.41,0.68 -0.62,1.01 0.04,2.08 -0.59,0.27ZM716.36,1406.78l11.27,0 -0.01,16.97 3.76,5.48 0.32,1.26 -0.23,0.91 0.47,0.93 -0.5,0.86 4.63,3.62 6.29,8.28 1.05,-0.18 0.42,1.12 0.7,0.45 2.57,-0.14 -1.25,7.59 -0.44,0.68 0.08,2.01 0.71,0.87 0.22,1.49 -1.43,1.24 0.3,2.11 -0.38,1.79 2.64,1.43 2.06,-1.48 1.42,-1.86 2.15,1.5 1.2,4.8 2.84,4.46 -0.15,2.01 1.39,1.54 1.19,-0.03 1.06,0.71 0.89,1.61 0.71,2.95 1.66,1.3 1.57,-1.58 3.88,0.44 0.63,-1 1.01,-0.44 8.32,0.25 0.59,-2.66 0.86,-0.56 0.78,0.37 1.63,2.67 1.24,0.91 0.01,39.03 -67.88,0.01 -0.04,-28.16 1.23,-6.11 -0.47,-0.73 -2.12,-0.72 -0.65,-0.85 -0.05,-1.47 3.93,-7.51 0.19,-1.28 3.3,-7.61 0.82,-3 -0.5,-1.32 -3.96,-3.86 -0.7,-1.6 -0.14,-2.89 -1.09,-2.71 0,-43.9ZM1007.59,1545.01l0.59,-0.27 -0.04,-2.08 0.62,-1.01 1.41,-0.68 1.29,-1.51 1.69,-4 -0.12,-1.01 -1.16,-1.86 -0.18,-1.13 0.38,-1.34 1.25,-0.86 4,-1.05 1.71,-1 1.02,-1.09 0.32,-1.18 1.62,-2.66 0.28,-1.49 -0.18,-1.82 -2.03,-1.76 -0.9,-1.7 -2.56,-2.89 41.09,0.31 -2.07,11.23 -3.42,0 -0.13,35.74 -0.89,1.23 -0.04,1.44 -0.37,0.36 1.33,3.81 0.01,2.43 -1.72,3.71 -0.62,0.26 -1.57,2.54 -0.55,-0.04 -0.67,0.7 0.25,1.52 -0.54,0.45 0.18,0.34 -0.62,1.1 0.02,1.11 -0.6,0.88 0.61,1.25 -0.99,1.28 -0.13,1.14 0.37,1.24 -0.94,1 -3.46,1.43 0.55,3.49 -0.29,0.46 -4.56,-1.39 -1.98,0.04 -1,1.15 -0.23,1.57 -1.34,-1.25 -0.32,0.96 -1.29,-1.28 -0.83,-1.58 -0.18,-1.25 0.46,-0.94 0,-0.98 -0.7,-3.02 -3.41,-3.44 -3.98,-2.67 -2.19,-2.68 -0.1,-0.81 0.66,-2.15 2.07,-5.66 -0.97,-0.75 -2.94,-0.73 -1.13,0.56 -0.98,-1.14 -0.84,-2.85 -2.07,-3.01 -5.23,-5.35 -1.4,-5.17 0.03,-1.91 0.65,-2.29ZM1046.28,1582.99l-0.61,-1.25 0.6,-0.88 -0.02,-1.11 0.62,-1.1 -0.18,-0.34 0.54,-0.45 -0.25,-1.52 0.67,-0.7 0.55,0.04 1.57,-2.54 0.62,-0.26 1.72,-3.71 0.13,-1.01 -0.14,-1.42 -1.33,-3.81 0.37,-0.36 0.04,-1.44 0.89,-1.23 0.13,-35.74 31.01,0.02 -0.29,39.88 -0.45,0.76 0.29,0.64 -0.32,0.92 0.84,0.95 -0.12,0.72 -4.2,1.88 -1.56,-0.68 -1.12,0.1 -0.45,0.69 0.23,1.26 -0.39,0.96 -1,0.67 -1.82,2.65 -0.93,0.24 -1.97,3.92 -0.68,0.43 -2.12,-0.75 -1.22,-1.84 -0.53,-0.22 -0.04,0.49 -1.05,0.36 0.1,0.49 -1.72,3.05 -3.07,-1.46 -1.14,0.55 -1.95,1.91 -2.63,-1.7 -1.67,0.03 -0.78,-0.5 -0.64,1.77 -0.81,-0.96 -1.82,-0.23 -0.35,0.2 -0.37,1.56 -1.18,0.07ZM887.32,1594.27l-0.13,-43.63 75.98,0 2.62,1.92 1.5,-0.28 0.62,0.44 0.35,1.78 -1.2,0.73 -0.81,1.39 0.2,1.31 1.2,1.21 1.99,3.42 1.77,1.02 0.05,30.69 -84.14,0ZM1033.62,1594.4l0.23,-1.57 1,-1.15 1.98,-0.04 4.56,1.39 0.29,-0.46 -0.55,-3.49 3.46,-1.43 0.94,-1 -0.37,-1.24 0.13,-1.14 1.22,-1.45 0.95,0.1 0.52,-1.72 2.02,0.19 0.81,0.96 0.64,-1.77 0.78,0.5 0.7,-0.24 3.6,1.91 1.95,-1.91 1.14,-0.55 3.07,1.46 1.72,-3.05 -0.1,-0.49 1.05,-0.36 0.04,-0.49 0.53,0.22 1.22,1.84 2.12,0.75 0.68,-0.43 1.97,-3.92 0.93,-0.24 1.82,-2.65 1,-0.67 0.39,-0.96 -0.23,-1.26 0.45,-0.69 1.12,-0.1 1.56,0.68 4.2,-1.88 0.12,-0.72 -0.84,-0.95 0.32,-0.92 -0.29,-0.64 1.08,-1.25 1.95,0.58 1.87,-0.08 1.59,1.71 0.72,1.6 1.3,0.97 3.24,0.98 1.58,1.19 1.72,-0.73 2.06,1.06 1.75,-0.17 2.31,-1.1 1.36,0.06 1.4,2.46 1.92,1.76 0.12,2.15 -0.45,1.77 2.55,4.64 1.29,2.03 2.02,1.68 1.57,0.44 -4.3,3.48 -3.85,2.27 -0.58,1.28 -1.85,2.02 -1.69,0.86 -1.21,1.19 -6.61,2.49 -31.59,-1.11 -15.15,0.3 -0.34,-0.44 -2.59,-0.26 0.42,2.74 -15.83,0 0.61,-1.25 0.76,-0.4 0.84,0.31 0.61,-0.44 0.83,-2.64 0.08,-1.42 -0.36,-1.15ZM1029.83,1601.34l-0.79,0.03 0.08,-0.73 0.35,-0.03 0.36,0.73ZM978.02,1649.7l32.9,-0.05 0.06,0.67 0.55,0.39 -0.45,2.47 0.49,0.4 -0.65,1.36 0.52,1.82 1.81,2.15 0.08,0.72 -1.56,1.97 -0.2,1.14 -0.73,1.01 -1.48,1.16 -0.98,1.48 -0.98,2.92 -0.53,0.49 -0.27,2.31 -0.33,0.77 -0.68,0.14 -0.14,0.79 0.39,1.43 -0.69,1.44 21.86,0.01 -1.14,3.58 0.18,1.58 1.53,1.97 1.07,3.15 0.8,0.4 -0.77,0.36 -4.16,-1.36 -1.03,-1.09 -2.05,-0.36 -1.22,1.34 -0.92,1.8 2.71,1.47 2.06,-0.4 1.14,-0.88 0.93,0.03 0.85,-0.63 0.79,0.36 0.03,0.36 -1.71,1.44 0.81,1.02 1.28,0.34 0.48,-0.15 0.3,-1.14 0.78,-0.74 1.07,0.16 -0.15,0.47 0.64,1.18 0.03,1.32 -2,0.63 -0.69,0.61 0.36,0.36 -1.4,0.3 -0.43,0.73 0.52,1.06 1.83,1.55 3.79,1.1 0.73,1.14 1.15,0.59 -0.07,0.78 -1,0.58 -0.52,1.06 -0.92,-0.83 -1.59,1.29 0.26,-1.15 -1.02,-1.62 -2.02,-1.41 -1.96,-0.4 -0.29,-1.08 -0.67,-0.55 -3.21,-1.03 0.2,0.75 1.01,0.63 0,1.23 -0.95,2.62 -0.87,0.41 -1.01,-1.97 -0.88,-0.51 -1.41,-0.06 -0.95,0.36 -1.04,1.58 -0.83,0.26 -6.14,-2.06 0.09,-0.42 0.51,-0.13 0.99,0.17 -1.06,-1.82 -0.06,-1.4 -0.93,0.66 -2.09,-0.54 -1.8,-2.5 -1.73,-0.06 -0.78,-1.12 -1.41,0.47 -1.35,1.32 0.87,1.08 -0.28,0.32 -2.01,0.47 -4.67,-0.53 -5.74,-2.38 -5.91,0.12 -1.5,0.58 -0.65,-1.11 0.85,-0.53 0.41,-0.83 -0.24,-0.83 0.95,-1.78 -0.45,-3.06 0.34,-2.82 1.61,-3.51 0.18,-2.4 0.37,-0.55 -0.31,-1.78 -1.23,-1.9 -0.82,-2.55 -0.78,-0.73 -0.44,-3 -2.25,-2.76 0.02,-13.67ZM1032.83,1688.8l0.04,0.61 -1.38,-0.33 1.79,-1.39 -0.45,1.11ZM1037.34,1692.43l-0.32,0.42 0.31,-2 -0.44,-1.69 0.62,1.62 -0.17,1.65ZM1036.64,1693.68l-0.62,0.68 0.81,-1.21 -0.19,0.53ZM1003.59,1696.45l-0.42,0.19 -1.88,-1.14 -0.12,-0.48 1.49,-0.4 1.38,0.97 -0.45,0.86ZM1231.07,1520.32l-10.89,-0.34 -0.56,0.4 -0.01,-0.4 -7.66,-0.33 -0.3,-0.37 2.89,-10.36 21.89,0.77 4.04,-2.62 1.91,-0.08 -0.26,0.8 0.55,1.61 0.52,0.8 1.27,-0.03 0.12,0.75 -2.48,1.09 -2.45,3.41 3.51,1.57 1.37,2.9 -0.44,0.81 1.22,0.74 0.39,2.07 1,0.7 1.49,0.44 3.35,-1.49 -1.24,-3.12 -0.71,-0.5 -0.27,0.43 -0.51,-0.86 1.51,0.2 1.49,1.79 0.5,3.83 -0.17,0.51 -5.19,0.76 -2.87,1.41 -0.11,-2.68 -0.39,-0.07 -3.11,2.53 -1.2,0.16 -1.01,0.74 -0.41,-2.31 0.64,-1.59 -0.97,0.6 -1.22,-1.4 0.04,-1.42 -0.48,-0.17 -0.09,-1.75 -4.7,0.07ZM1245.75,1530.01l-3.13,0.74 -0.5,-0.48 2.43,-1.49 1.03,0.64 0.17,0.59ZM1251.81,1531.68l-0.88,0.25 -2.03,-0.56 1.94,-0.64 0.25,-1.04 0.72,1.99ZM1171.57,1567.03l0.12,1.2 1,-1.19 -1.26,-1.81 -0.91,1 -2.03,-1.61 -2.05,-0.87 -0.29,-0.43 0.31,-1.15 -2.96,-1.96 -0.6,-1.29 0.14,-0.69 -1.05,-1.29 0.19,-0.35 -1.96,-0.47 -0.8,-0.69 -0.95,-0.11 -2.56,0.85 -1.01,1.4 -2.08,-0.24 -1.14,-1.14 -2.2,2.55 -1.18,-0.33 -2.48,2.42 -2.22,1.48 0.12,-7.54 42.02,0.01 0.88,18.57 7.62,0 -0.01,0.42 -0.41,0.88 0.01,-0.64 -0.49,0.05 -0.49,2.2 -0.75,0.18 -1.71,3.14 -2.78,0.38 -0.44,0.65 -2.18,-0.25 0.63,-1.67 -1.51,-1.19 0.73,-1.33 0.06,-1.47 -1.24,1.03 -0.21,-0.59 -0.74,0.76 -1.83,-1.19 -0.95,-1.93 0.35,-1.53 3,-0.03 -2.41,-2.28 -0.75,-0.21 -0.71,0.92 0.46,-1.59 1.51,-0.5 -0.26,-0.92 -0.57,-0.4 -1.02,0.5 0.01,-0.64 0.19,-0.83 1.45,0.27 0.57,-1.34 0.03,-0.6 -0.96,0.87 -0.21,-1.87 0.94,-1.82 0.89,-0.79 2.26,-0.1 -1.45,-0.52 1.48,-1.47 -1.1,0.09 0.13,-1.19 -1.19,0.36 -0.39,1.89 -0.5,0.44 -0.85,0.34 -0.36,-0.87 -0.33,1.71 -0.62,-1.19 -0.32,1.16 -0.53,0.31 -0.17,1.16 -1.7,-0.65 0.92,1.62 0.7,0.48 0.09,0.76 -0.6,0.64 -0.98,-0.51 0.74,1.76 -0.49,2.96 0.41,3.06 1.22,2.37 -0.51,0.11 -1.52,-1.08 -1.2,-2.56 0.1,1.08 0.3,1.21 2.66,2.7 0.86,1.85 -0.09,0.78 -1.29,-1.25 -3.58,-1.3 -1.13,-1.85 -0.24,1.43 -1.27,-2.22 -1.76,0.7 -0.87,-0.16 0.13,-1.94 2.3,-3.45 -0.13,-1.62ZM1192.1,1579.36l-0.31,0.04 1.76,-3.77 -1.45,3.73ZM1262.32,1435.74l0.58,0.98 1.98,0.55 5.14,-1.89 0.22,-0.48 1.39,-0.02 4.88,4.41 0.45,19.11 -0.4,3.25 2.35,1.74 1.86,0.29 0.09,1.18 -0.79,0.91 0.75,1.56 -0.51,1.65 1.79,1.98 0.75,-0.76 1.42,0.5 0.5,2.91 -0.38,0.72 0.08,0.95 1.06,0.28 0.31,0.64 -2.33,2.44 -1.96,-0.34 -2.19,0.83 -0.49,1.09 -0.61,0.23 -2.12,-0.22 -0.77,1.95 -0.63,-0.17 -1.07,1.28 -1.09,-1.88 -1.43,-0.08 -1.09,0.99 -0.88,-1 -0.8,2.03 -0.13,1.94 -0.9,-0.83 -2.28,-0.46 1.16,-1.64 -0.96,-0.19 0.36,-1.86 -0.96,1.37 -1.3,0.82 0.06,1.36 -1.22,2.8 -0.05,1.18 -1.8,1.76 -1.35,-0.23 -2,1.64 -0.41,-1.35 -0.38,1.52 -0.39,0.09 -0.32,-1.79 -0.53,0.62 -0.35,1.62 -0.75,-0.92 -0.14,2.18 -0.73,-0.74 -1.16,0.5 0.1,-1.06 -2.43,1.39 -1.03,1.49 0.76,0.72 -3.62,4.35 -1.38,3.35 -1.04,1 -0.9,-1.46 -0.19,-1.17 -1.03,-1.4 -0.54,-2.03 -1.33,-29.23 1.41,-0.63 0.71,1.14 0.37,-0.13 0.75,-2.17 1.25,-0.38 -0.14,-2 3.19,-3.04 0.15,-1.04 1.27,-1.7 -0.09,-2.48 0.64,-3.18 2.06,-3.13 0.68,-4.44 7.38,-10.71 1.32,-1.89 2.19,0.61 -0.04,2.22ZM1272.18,1484.11l-1.39,0.18 -0.06,1.14 -1.1,-0.71 0.02,-1.11 1.25,-1.47 0.7,0.29 0.58,1.68ZM1267.22,1486.28l-0.89,0.21 -0.02,-0.78 0.3,-0.39 0.61,0.96ZM1029.71,1423.86l2.56,-0.37 7.53,-4.16 2.65,-0.67 2.48,1.33 37.37,22.35 1.1,4.36 2.48,2.98 1.82,-0.96 2.87,-0.45 0.27,0.25 -0.29,1.37 0.71,3.59 1.26,2.33 4.12,-0.53 1.66,2.01 -1.4,2.9 11.85,7.64 4.7,28.32 -3.07,7.79 -0.91,5.18 -0.65,1.77 -3.67,3.7 -2.34,1.31 -0.41,0.76 -0.46,1.67 0.32,2.94 -3.9,3.22 -15.15,0.58 0,-0.89 -27.59,-0.02 2.07,-11.23 -1.32,-12.95 0.15,-5.2 1.24,-6.84 3.62,-12.03 2.03,-3.14 3.09,-2.99 -5.8,-3.65 -3.88,0 -1.47,2.63 -1.99,1.71 -0.46,1.87 -2.2,-0.87 -0.77,-1.95 0.65,-2.08 -2.02,0.17 -0.38,-0.4 0.91,-3.42 -0.16,-1.46 -1.29,-1.21 -2.21,-0.91 0.23,-1.02 -0.63,-1.1 -3.88,-1.11 -3.92,-0.38 -3.21,-1.85 -11.37,-3.16 -1.27,-2.78 -1.26,-0.8 -0.58,0.15 -0.23,-0.6 10.4,-23.7ZM941.79,1406.78l23.48,0.02 0.07,-6.58 2.46,0.36 0.97,0.78 0.58,5.25 1.12,3.36 0.95,1.14 6.44,1.44 2.32,0.89 0.54,1 1.09,0.41 2.78,-0.62 0.98,-0.95 4.34,0.08 5.64,3.03 0.98,2.72 0.75,0 0.57,-0.89 1.44,-0.16 1.9,0.62 1.67,1.78 3.87,2.38 1.49,-0.01 3.91,-2.3 1.45,-0.26 0.86,0.14 1.09,1.64 7.43,-0.23 1.11,1.75 1.06,0.34 4.58,-0.05 -5.23,12.01 -7.92,-0.37 -9.27,6.42 -5.65,3.25 -1.82,-0.55 -1.12,1.52 -0.77,0.17 -0.02,9.51 -4.56,2.87 -2.31,4.09 0.05,1.03 1.54,0.84 0.85,1.79 -0.81,2.52 -0.06,2.69 -0.39,0.63 0.34,2.21 -0.41,2.32 0.34,1.02 1.43,1.29 2.3,0.94 2.29,1.99 2.11,0.99 2.43,3.27 5.22,3.22 0.71,0.86 0.47,2.19 0.38,4.64 -59.26,0.02 0,-28.6 -0.86,-1.2 -1.9,-0.98 -1.76,-3.15 2.69,-2.84 0.66,-2.33 -0.05,-3.21 -0.64,-3.1 -1.29,-2.41 -0.64,-2.9 0.19,-4.51 -0.63,-1.65 -0.38,-9.56 -1.47,-3.92 -0.22,-1.79 -1.35,-4.21 -0.02,-8.71 -1.11,-5.39ZM1027.36,1608.42l-7.7,0.12 0.89,-1.5 2.59,-2.78 0.01,-1.06 -1,-1.83 -50.7,0 -0.04,-37.79 -1.77,-1.02 -1.99,-3.42 -1.2,-1.21 -0.2,-1.31 0.81,-1.39 1.2,-0.73 -0.35,-1.78 -0.62,-0.44 -1.5,0.28 -2.8,-2.05 -0.82,-1.28 -0.33,-1.52 -2.26,-2.45 -1.17,-3.58 45.89,-0.34 0.56,1.09 2.73,2.58 -0.65,2.29 -0.03,1.91 1.4,5.17 5.23,5.35 2.07,3.01 0.84,2.85 0.98,1.14 1.13,-0.56 2.94,0.73 0.97,0.75 -2.07,5.66 -0.66,2.15 0.1,0.81 2.19,2.68 3.98,2.67 3.41,3.44 0.7,3.02 0,0.98 -0.46,0.94 0.18,1.25 1.53,2.53 0.71,0.32 0.2,-0.95 1.34,1.25 0.36,1.15 -0.08,1.42 -0.83,2.64 -0.61,0.44 -0.84,-0.31 -0.76,0.4 -0.85,1.4 -0.54,-0.93 -0.35,0.03 0.11,1.78 -0.81,1.48 0.32,0.71 -1.04,0.72 0.46,0.75 -0.09,0.89 -0.71,1.45ZM1044.78,1622.43l1.01,0.92 -4.57,41.48 0.99,20.2 -3.33,0.2 -2.42,-0.79 -3.63,1.09 -1.1,-0.17 -1.4,1.61 -0.88,0.4 -0.8,-0.4 -1.07,-3.15 -1.53,-1.97 -0.18,-1.58 1.14,-3.58 -21.86,-0.01 0.69,-1.44 -0.39,-1.43 0.14,-0.79 0.68,-0.14 0.33,-0.77 0.27,-2.31 0.53,-0.49 0.98,-2.92 0.98,-1.48 1.48,-1.16 0.73,-1.01 0.2,-1.14 1.56,-1.97 -0.08,-0.72 -1.81,-2.15 -0.52,-1.82 0.63,-0.93 -0.48,-1.55 0.46,-1.75 -0.55,-0.39 -0.1,-1 0.53,-2.41 -0.65,-1.04 0.26,-1.97 -0.84,-1.97 0.48,-0.46 -0.4,-0.8 1.76,-2.08 -0.08,-2.22 1.65,-0.81 -0.29,-1.1 0.35,-0.83 1.05,-0.87 0.63,-1.44 1.44,-0.79 0.59,-1.24 0.5,-3.1 0.74,-0.45 0.67,-1.26 1.09,-0.66 0.43,-0.64 -0.13,-0.78 24.12,0.03ZM750.22,1406.78l114.11,0 0.32,66.64 -80.16,0 -0.01,8.04 -1.24,-0.91 -1.63,-2.67 -0.78,-0.37 -0.86,0.56 -0.59,2.66 -8.32,-0.25 -1.01,0.44 -0.63,1 -3.88,-0.44 -0.81,0.55 -0.5,1.06 -0.9,-0.36 -1.02,-0.97 -0.71,-2.95 -0.89,-1.61 -1.06,-0.71 -1.19,0.03 -1.39,-1.54 0.15,-2.01 -2.84,-4.46 -1.2,-4.8 -2.15,-1.5 -1.42,1.86 -2.06,1.48 -2.64,-1.43 0.38,-1.79 -0.3,-2.11 1.43,-1.24 -0.22,-1.49 -0.71,-0.87 -0.08,-2.01 0.44,-0.68 1.25,-7.59 -2.57,0.14 -0.7,-0.45 -0.42,-1.12 -1.05,0.18 -6.29,-8.28 -4.51,-3.47 0.38,-1.01 -0.47,-0.93 0.23,-0.91 -0.32,-1.26 -3.76,-5.48 0.01,-16.97 22.59,0ZM1102.34,1622.4l-13.77,0.18 0.73,-3.64 2.26,-0.5 0.66,-1.79 1.51,-1.41 4.1,-0.97 4.44,-2.66 1.49,-0.37 1.16,-2.12 0.85,0.06 1.29,-1.16 1.01,-0.25 0.66,1.08 2.94,-2.29 1.28,-0.28 0.93,0.66 0.56,-0.23 1.63,-2.59 1.98,-0.69 0.34,-2.52 0.51,-1.09 64.77,0.84 -0.14,1.73 1.28,2.28 0.53,2.18 -0.72,-0.88 -3.01,-1.46 -0.03,1.88 -1.37,-0.62 0.49,1.04 -1.78,-0.25 -1.08,1.48 -0.92,0.18 -1.36,-0.84 -0.62,-2.17 0.09,3.83 4.18,0.06 1.73,-0.54 1.56,0.3 -0.16,3.92 0.94,-0.44 0.25,-2.44 1.9,-0.84 0.76,2.67 -0.33,1.66 -3.75,3.73 -0.8,0.37 -3.59,-0.6 -0.49,-1.56 -0.51,-0.33 -0.38,0.04 -0.27,1.06 -1.22,0.31 -3.39,-1.34 0.74,0.96 4.31,1.8 0.94,0.82 -1.07,1.64 -0.24,1.11 -1.72,1.15 -0.93,-0.2 -2.38,-2.08 1.09,1.8 0.86,0.76 1.75,0.41 3.28,-0.68 1.08,0.74 -1.76,2.21 -2.17,0.34 -0.29,0.63 -4.56,-0.01 -1.85,1.45 -0.71,-0.24 -0.61,-1.53 -0.01,1.92 0.38,0.9 -4.22,3.34 -1.25,1.86 -0.77,2.88 -0.28,-3.15 -0.2,2.41 -0.49,1.12 -4.46,-0.08 -1.81,0.56 -12.39,-12.67 -12.86,-0.45 -0.1,-1.86 -1.61,-2.09 -1.26,0.66 -0.02,-0.91 -0.46,-0.34 -14.85,-0.77 -4,1.77 -4.22,1.15ZM1184.55,1600.67l0.36,0 1.13,4.54 2.55,5.77 -3.14,-6.36 -0.9,-3.95ZM1187.43,1610.47l-0.17,0.28 -0.75,-1.55 0.77,0.5 0.15,0.77ZM1188.48,1619.08l-1.67,0.26 1.75,-0.8 0.63,-4.1 -0.25,-2.76 0.53,2.87 -0.09,1.62 -0.9,2.91ZM1177.56,1627.37l-0.29,0.15 1.05,-1.72 2.61,-2.53 -3.37,4.1ZM894.67,1406.78l47.12,0 1.11,5.39 0.02,8.71 1.35,4.21 0.22,1.79 1.47,3.92 0.38,9.56 0.63,1.65 -0.19,4.51 0.64,2.9 1.5,3.32 0.43,2.19 0.05,3.21 -84.82,-0.01 -0.25,-51.35 30.34,0ZM887.19,1550.64l-0.01,-14.95 -22.72,-0.01 -0.08,-30.63 63.57,0.01 3.4,2.31 2.03,0.72 0.95,-0.68 2.08,-0.39 5.23,0.22 6.41,3.45 0.48,1.07 0.86,0.68 1.21,0.29 0.77,1.36 0.31,2.42 0.69,1.96 1.07,1.48 1.31,3.29 0.32,4.19 0.53,0.12 0.34,0.98 0.44,0.19 -0.07,1.42 0.65,0.78 -0.17,1.58 0.41,0.36 0.42,4.5 -0.28,2.17 1.98,4.18 0.26,1.55 0.62,1 0.98,0.46 0.66,0.99 0.33,1.52 1,1.41 -75.98,0ZM1234.29,1473.31l1.12,-3.11 1.04,-1.45 1.43,0.49 1.34,-0.55 1.33,29.23 0.54,2.03 1.03,1.4 0.19,1.17 0.9,1.46 -0.5,2.02 -0.33,0.99 -1.91,0.08 -4.04,2.62 -12.94,-0.43 -0.95,-2.43 0.87,-2.36 1.27,-8.57 2.81,-5.97 0.95,-5.31 2.35,-1.17 2.46,-2.23 0.46,-1.49 -0.59,-2.63 1.25,-2.19 -0.08,-1.6ZM1193.82,1550.91l3.86,-2.55 -2.74,-3.75 -0.66,-0.21 -0.72,-1.84 -1.04,-0.79 0.16,-2.69 1.13,-1.22 -0.54,-2.15 2.39,-2.36 1.14,-2.21 1.29,-0.84 8.98,5.51 -1.32,3.55 -1.83,1.63 -0.88,1.79 0.26,1.08 2.18,0.4 0.58,-0.34 0.3,0.78 0.17,1.07 -1.39,8.03 0.17,-3.04 -0.6,0.82 -0.67,3.13 -0.91,1.67 -0.85,1.15 -0.87,-0.19 0.2,0.91 -0.44,1.47 -0.52,0.66 -1.19,0.39 -2.45,4.61 -1.47,0.89 -0.35,-0.13 0.65,-2.87 -1.74,-0.96 -0.98,0.05 -2.47,-1.94 -1.95,-2.22 0.01,-1.64 1.16,-2.78 3.05,-1.2 0.9,-1.67ZM1204.53,1555.39l-1.34,2.24 1.64,-3.21 -0.3,0.97ZM807.28,1672.34l0.01,-78.07 68.79,0 0.01,7.1 -0.48,0.01 -0.27,61.94 -40.99,0.03 1.16,2.43 1.38,0.68 -20.1,-0.14 -0.03,6 -9.48,0.02ZM750.48,1594.23l-0.03,11.65 -1.6,2.13 -0.56,-0.02 -1.98,-1.64 -1.13,-0.11 -1.86,0.49 -0.82,1.52 0.62,1.35 0.47,4.02 -0.19,1.2 0.81,2.69 -0.22,5.03 -40,-38.16 -21.32,-18.98 -0.01,-44.9 67.79,-0.01 0.03,73.74ZM1140.49,1512.22l8.25,-4.08 1.11,-0.95 0.21,-1.11 -1.2,-1.28 -0.46,-1.38 0.08,-2.68 -1.28,-2.95 5.14,-2.49 21.62,-0.06 4.04,-6.77 3.18,-2.92 0.39,-0.98 3.13,-1.8 5.4,-5.68 2.53,-2.04 3.67,-1.68 17.12,-0.02 -0.23,6.54 0.71,2.2 -0.13,3.03 -1.2,3.08 0.59,4.28 -0.47,3.37 0.97,-0.58 0.95,1.16 -0.38,11.54 0.31,0.95 -2.89,10.36 0.3,0.37 -0.73,11.58 0.69,1.16 -2.71,1.73 1.05,1.7 -4.06,3.62 1.31,-4.57 -0.12,-1.75 -0.49,-0.72 -0.5,-0.48 0.59,1.73 0.09,2.16 -8.98,-5.51 -0.65,-1.01 -2.04,-0.77 -1.32,-2.04 -0.02,-2.38 -0.48,-1.02 -1.63,-0.93 -1.28,-1.62 -50.2,-0.04 0.02,-8.27ZM1223,1535.91l-0.81,0.97 0.73,0.1 3.79,-1.99 0.93,0.48 2.26,-0.69 -7.42,3.54 -7.27,2.58 -8.02,1.25 1.14,-1.06 -0.87,-0.15 -0.61,0.79 -0.98,0.26 -0.19,-0.86 1.74,-2.3 2.09,-1.18 0.49,0.49 0.11,-0.65 0.78,-0.58 10.8,-1.09 3.99,-2.43 -2.68,2.52ZM1203.9,1542.86l-0.54,0.07 0.54,-1.44 1.36,-0.52 -0.12,0.94 -1.24,0.95ZM1102.26,1521.27l1.04,1.79 3.87,2.41 2.86,0 13.21,-8.17 8.61,-1.77 0.02,25.48 -1.35,0.65 -0.24,0.6 0.62,1.77 0.03,1.21 -3.08,9.34 -0.02,1.05 -1.01,1.38 -3.41,2.72 -0.8,0.35 -1.21,-0.44 -1.9,1.74 -0.58,0.04 -1.65,2.73 0.25,2.03 -1.32,0.78 -0.61,-1.4 -0.58,-0.32 -0.81,0.71 -1.49,2.84 0.26,1.91 -2.35,2.96 -1.26,0.28 -1.41,-0.52 -2.54,-2.58 -0.41,-1.2 -1.36,-0.06 -2.31,1.1 -1.75,0.17 -2.06,-1.06 -1.72,0.73 -1.58,-1.19 -3.24,-0.98 -1.3,-0.97 -0.72,-1.6 -1.59,-1.71 -2.62,-0.05 -0.53,-0.5 -1.3,0.54 0.29,-38.99 15.15,-0.58 3.9,-3.22ZM971.45,1601.37l2.04,15.66 -0.51,24.01 -2.56,-0.7 -5.76,-3.56 -1.8,1.17 -1.71,-0.17 -0.8,-0.8 -2.16,1.1 -1.79,-0.25 -2.25,0.83 -2,1.52 -3.15,-1.89 -0.17,-0.77 -1.59,0.7 -1.15,-0.39 -0.98,-0.97 -1.48,1.33 -0.63,1.67 -0.83,-0.69 0.07,-1.17 -0.33,-0.37 -2.09,0.91 -1.96,-1.16 -0.8,-1.04 -2.29,1.59 -0.9,-0.04 -0.34,-1.27 -1.34,-0.95 -0.33,-1.44 -2.93,0.05 -1.11,0.87 -1.76,-1.14 -1.39,0.2 -4.86,-1.06 -1.09,-2.27 -1.22,-0.93 -0.51,0.88 -2.58,0.05 -2.67,-2.14 -1.51,-0.6 -0.04,-26.77 -34.1,0 -0.01,-7.1 95.38,0 -0.01,7.1ZM682.66,1520.5l-48.1,-0.01 -1.45,-1.87 -0.74,-3.97 0.16,-3.12 -1.51,-3.55 2.19,-8.24 1.7,-1.28 -1.03,0.22 1.58,-4.43 0.57,-10.16 0.59,-1.46 -0.14,-5.63 1.48,-12.9 -0.36,-4.33 0.16,-4.88 -0.48,-1.29 0.88,0.61 2.71,-0.01 1.73,-0.65 2.27,1.29 2.29,-0.57 0.89,0.31 1.14,0.74 1.13,2.24 1.33,4.97 0.87,0.75 5.09,0.59 1.33,-0.18 2.31,-1.42 2.5,-0.46 2.96,0.1 1.82,0.4 0.66,0.71 1.58,0.07 7.9,-1.4 4.74,-1.84 5.75,-1.57 2.87,-0.18 1.79,-0.91 24.16,-0.02 1.5,2.11 2.77,2.46 0.5,1.32 -0.82,3 -2.14,4.65 -1.35,4.24 -3.93,7.51 0.05,1.47 0.65,0.85 2.12,0.72 0.47,0.73 -1.23,6.11 0.04,28.16 -33.95,0ZM1131.85,1515.53l3.11,-0.64 5.53,-2.67 -0.02,8.27 50.2,0.04 1.28,1.62 1.63,0.93 0.48,1.02 0.02,2.38 0.8,1.53 2.56,1.28 0.65,1.01 -1.29,0.84 -1.14,2.21 -2.39,2.36 0.54,2.15 -1.13,1.22 -0.2,1.28 0.04,1.41 1.04,0.79 0.72,1.84 0.66,0.21 2.74,3.75 -3.28,2.04 -1.7,1.82 -2.82,1.18 -2.43,-0.36 -1.71,1.74 -53.87,-0.01 -0.02,-39.24ZM1230.59,1530.63l0.53,-2.8 -0.05,-7.51 4.7,-0.07 0.09,1.75 0.48,0.17 -0.04,1.42 1.22,1.4 -0.43,0.38 -1.35,-1.74 0.3,1.42 -0.72,1.05 -0.19,2.73 -0.9,1.14 -3.64,0.66ZM1237.43,1528.25l-1.19,0.35 0.75,-2.3 0.55,-0.52 -0.11,2.47ZM1236.02,1528.35l-0.31,0.29 0.1,-1.58 0.33,0.43 -0.12,0.86ZM1127.85,1662.96l-2.3,-1.07 -0.69,-0.97 -0.41,-2.67 -1.35,-2.39 -0.99,-0.68 -1.28,-4.44 -1.01,-1.8 -2.3,-1.72 -2.56,-4.47 -2.31,-1.92 -1.63,-2.38 -2.7,-2.47 -2.94,-5.77 -2.34,-1.02 -3.44,-2.73 0.44,-1.35 2.22,-2.7 4.3,-1.16 4,-1.77 14.85,0.77 0.46,0.34 0.02,0.91 1.26,-0.66 1.61,2.09 0.1,1.86 12.86,0.45 12.39,12.67 -4.05,2.99 -2.48,3.45 -0.63,2.2 -0.51,-0.92 0.14,-1.27 -0.63,1.22 0.6,1.77 -0.53,0.68 -1.64,1.26 -1.9,0.57 -0.32,1.24 -2.16,1.65 -1.46,-0.31 0.45,1.1 -0.54,0.83 -0.92,0.64 -2.37,0.59 -1.51,1.02 -2.38,-0.44 -0.71,0.29 1.82,1.2 -0.13,0.96 -1.06,0.87 -0.33,-0.08 -0.45,-1.39 -0.7,0.8 -1.06,-1.5 0.05,1.14 1.18,1.99 -0.73,0.99 -1.03,0.38 -0.27,1.13ZM950.57,1497.24l-1.65,0.06 0.73,2.5 -0.33,1.49 0.84,0.58 0.32,1.18 -1.88,5.8 1,1.52 0.66,2.28 -1.73,-0.89 -0.48,-1.07 -1.47,-0.98 -4.94,-2.47 -5.23,-0.22 -2.08,0.39 -0.95,0.68 -2.03,-0.72 -3.4,-2.31 -63.57,-0.01 -0.09,-31.63 0.37,-0.2 -0.08,-15.09 84.82,0.01 -0.66,2.33 -2.69,2.84 1.76,3.15 1.9,0.98 0.86,1.2 0,28.6ZM1073.79,1622.4l-29.2,-0.33 0.19,0.36 -24.12,-0.08 1.72,-1.52 0.56,-1.24 -0.17,-1.55 2.07,-3.87 -0.2,-1.23 0.56,-1 1.31,-0.77 0.18,-1.17 0.85,-0.45 -0.23,-0.87 0.85,-2.6 -0.46,-0.75 1.04,-0.72 -0.32,-0.71 0.64,-0.72 -0.02,-1.81 17.04,0.02 -0.42,-2.74 2.59,0.26 0.34,0.44 15.15,-0.3 31.59,1.11 23.57,-0.34 -0.51,1.09 -0.34,2.52 -1.98,0.69 -1.63,2.59 -0.56,0.23 -0.93,-0.66 -1.28,0.28 -2.94,2.29 -0.66,-1.08 -1.01,0.25 -1.29,1.16 -0.85,-0.06 -1.16,2.12 -1.49,0.37 -4.44,2.66 -4.1,0.97 -1.51,1.41 -0.66,1.79 -2.26,0.5 -0.73,3.64 -14.78,-0.18ZM972.98,1641.04l1.44,1.19 1.89,-0.38 1.64,0.47 0.05,21.05 2.25,2.76 0.44,3 0.78,0.73 0.82,2.55 1.23,1.9 0.31,1.78 -0.37,0.55 -0.18,2.4 -1.61,3.51 -0.34,2.82 0.45,3.06 -0.95,1.78 -0.54,-0.04 -1.19,2.17 0.64,1.64 -2.39,0.25 -7.5,3.74 0.1,-0.44 2.55,-1.7 -2.87,0 0.62,-1.4 -0.2,-1.24 -1.03,-0.04 -0.66,1 -1.51,-0.34 0.34,2.25 1.19,2.09 -2.85,2.65 -0.15,1.15 -1.38,1.5 -6.6,4.2 -4.34,1.96 2.55,-1.85 -4.13,-0.32 -0.85,0.81 -1.45,-1.58 -0.73,0.09 1.31,2.86 1.18,0.4 -1.6,1.17 -1.3,0.33 -1.11,-1.04 -0.38,2.61 -0.37,0.33 -0.59,0.48 -0.48,-0.87 -0.93,0.79 -1.6,0.25 0.17,1.07 1.21,-0.42 -0.44,1.39 -1.12,1.37 -0.91,0.32 -1.39,-0.2 -0.65,0.42 1.62,2.15 -1.71,4.39 -0.96,0.18 -2.79,-1.84 0.87,2.18 2.36,0.64 0.1,1.53 -0.9,1.92 1.37,6.14 2.51,5.3 0.72,0.03 0.12,0.45 -0.07,0.87 -1.54,0.25 -0.87,0.9 -2.61,-1.44 -2.43,-0.73 -5.39,-0.88 -1.17,-0.9 -3.57,-1.19 -0.84,-0.82 -3.9,-1.35 -1.39,-4.01 -2.57,-3.76 0.18,-1.45 -0.79,-2.18 0.27,-0.74 -0.22,-1.92 -2.83,-2.34 -4.07,-5.7 -2.1,-2 -0.4,-2.26 -2.48,-4.14 -1.24,-3.21 -1.09,-1.49 -2.98,-2.84 -0.26,-0.78 -3.01,-2.27 -0.87,-1.42 -1.87,-0.54 -0.02,-0.32 -5.06,0.16 -3.16,-0.99 -0.85,0.08 -0.48,0.77 -1.03,0.49 -1.58,0.22 -1.36,1.42 -1.13,2.61 -0.5,1.68 0.14,0.75 -2.56,2.82 -0.89,0.56 -1.01,-0.03 -1.88,-0.91 -4.9,-2.87 -1.55,-0.42 -4.68,-3.27 -2.52,-3.68 -0.67,-1.79 0,-1.89 -2.69,-5.92 -6.78,-5.26 -5.81,-5.55 -1.41,-0.71 -3.28,-4.19 -1.48,-0.73 -1.16,-2.43 40.99,-0.03 0.27,-61.94 34.58,-0.01 0.04,26.77 1.51,0.6 2.06,1.76 0.61,0.38 2.58,-0.05 0.51,-0.88 1.22,0.93 1.09,2.27 4.86,1.06 1.39,-0.2 1.76,1.14 1.11,-0.87 2.93,-0.05 0.33,1.44 1.34,0.95 0.34,1.27 0.9,0.04 2.29,-1.59 0.8,1.04 1.96,1.16 2.32,-0.82 -0.07,1.13 0.63,0.97 0.53,-0.18 0.4,-1.45 1.48,-1.33 0.98,0.97 1.15,0.39 1.59,-0.7 0.17,0.77 3.15,1.89 2,-1.52 2.25,-0.83 1.79,0.25 2.16,-1.1 0.8,0.8 1.71,0.17 1.8,-1.17 5.76,3.56 2.56,0.7ZM966.66,1701.08l-0.57,0.13 3,-2.68 0.67,0.03 -3.1,2.52ZM947.04,1713.96l-0.42,0.05 0.52,-0.69 4,-2.32 -0.11,0.57 -3.99,2.39ZM944.19,1717.19l-0.24,0.04 0.65,-1.48 1.38,-1.54 0.2,0.57 -1.99,2.41ZM940.33,1724.92l-0.35,0.73 1.02,-3.59 1.88,-3.29 0.79,-0.55 -2.17,3.61 -1.17,3.09ZM942.41,1739.45l-0.15,0.59 -2.48,-8.99 0.18,-4.81 0.4,5.05 2.05,8.16ZM807.29,1594.27l-56.81,-0.04 -0.03,-73.74 34.04,0 0.01,15.19 22.79,0 0,58.59ZM1170.52,1566.23l1.05,0.8 -0.18,1.65 -2.44,2.57 -0.61,2.95 0.93,0.82 2.11,-0.24 1.6,2.32 4.06,1.48 0.88,1.2 2.36,1.7 -0.47,2.48 -0.44,0.66 -1.68,-0.1 -3.83,-4.02 -1.27,-1.93 -1.94,-1.02 2.11,1.92 4.28,5.24 2.77,1.4 -0.7,0.6 1.12,0.5 0.06,1.98 -1.56,-0.42 0.09,1.23 -0.7,0.38 -0.96,-0.51 -2.49,-2.81 0.22,0.81 1.45,1.81 3.23,2.48 0.5,1.38 -1.34,0.87 -2.29,-2.16 -0.33,-1.13 -0.83,0.06 -3.45,-1.43 -2.77,-0.16 6.58,2.23 0.44,1.79 1.47,1.23 0.19,0.91 1,0.1 1.77,-0.89 2.79,0.57 1.61,5.14 -65.81,-0.63 -3,-0.33 -0.54,0.29 -19.51,-0.1 5.89,-2.23 1.21,-1.19 1.69,-0.86 1.85,-2.02 0.58,-1.28 3.85,-2.27 4.3,-3.48 -0.07,0.96 1.09,2.05 3.26,1.74 2.72,-1.8 1.95,1.01 2.99,-0.69 0.82,-1.58 1.41,0.3 2.41,-0.98 0.49,0.52 1.06,-0.57 1.43,-2.12 -0.45,-0.81 0.45,-1.07 3.12,-4.25 0.78,-1.95 2.14,-3.24 0.86,-2.44 0.96,0.19 0.57,0.99 1.24,0.53 1.77,-0.32 2.27,-4.56 0.56,-0.44 1.4,0.03 3.27,-2.65 1.66,-2.37 1.29,-4.28 5.53,4.51 1.24,-2.96 2.19,1.19 0.63,0.66 -0.31,1.15 0.29,0.43 2.05,0.87 2.03,1.61ZM1187.17,1580.61l0.44,-0.65 2.78,-0.38 -2.51,5.68 0.11,1.04 -1.27,0.6 -1.29,1.31 -1.39,3.91 -0.72,-1.6 0.25,-1.93 0.99,-3.16 1.92,-2.91 0.69,-1.91ZM1191.79,1579.4l0.31,-0.04 -1.22,2.2 -0.52,0.23 1.43,-2.39ZM1213.42,1473.35l20.87,-0.04 0.08,1.6 -1.25,2.19 0.59,2.63 -0.46,1.49 -2.46,2.23 -2.35,1.17 -0.95,5.31 -2.81,5.97 -1.27,8.57 -0.87,2.36 0.95,2.43 -8.95,-0.34 -0.31,-0.95 0.38,-11.54 -0.95,-1.16 -0.97,0.58 0.47,-3.37 -0.59,-4.28 1.2,-3.08 0.13,-3.03 -0.71,-2.2 0.23,-6.54ZM650.94,1406.78l65.42,0 0,43.9 1.09,2.71 0.24,1.13 -0.3,0.64 0.59,2.01 -24.16,0.02 -1.79,0.91 -2.87,0.18 -5.75,1.57 -4.74,1.84 -7.9,1.4 -1.58,-0.07 -0.66,-0.71 -1.82,-0.4 -2.96,-0.1 -2.5,0.46 -2.31,1.42 -1.33,0.18 -5.09,-0.59 -0.87,-0.75 -1.33,-4.97 -1.13,-2.24 -1.14,-0.74 -0.89,-0.31 -1.14,0.41 -2.78,-1.93 -2.11,0.05 -0.43,-0.52 -2.36,0.52 -0.73,-0.54 -1.28,0.35 0.32,-5.37 1.12,2.85 0.65,-3.77 -2.08,-1.4 -0.46,-1.96 3.06,-1.68 -3.06,-1.2 -0.31,1.35 -0.68,-4.25 -1.25,-3.29 -0.76,-4.28 -0.96,-2.12 -1.83,-2.03 -0.48,-1.19 -0.53,-6.93 8.35,3.62 7.75,0.83 1.51,-0.59 2.14,1.38 2.22,-1.09 1.39,4.36 -1.39,2.42 -0.26,0.05 -0.22,-0.98 -2.61,4.07 -1.01,2.8 0.4,0.63 2.07,-1 -1.65,0.14 0.08,-0.91 0.88,-1.78 1.92,-1.67 2.34,-3 0.26,-1.57 0.6,0.14 0.1,2.55 -1.21,1.3 0.19,1.3 -0.7,0.06 1.34,2.51 -0.23,2.86 -0.81,0.19 -0.67,-0.58 -0.68,1.64 -0.69,-1.98 -1.04,0.78 -1.23,2.53 2.45,-0.12 1.25,0.59 1.12,-0.94 0.7,-1.82 1.39,-0.61 0.76,-1 -0.17,-3.91 -0.48,-0.82 0.31,-1.08 -0.21,-1.15 1.82,-3.84 -1.98,-2.95 0.24,1.7 -1.39,-1.29 -0.04,-1.19 1.33,-0.68 -0.06,-0.42 -1.51,-2.01 -1.45,-0.93 0.47,-0.56 1.49,-0.13 -0.18,-2.82 -0.56,-1.87 -1.04,0.24 -0.37,-0.52 -1.17,-3.44ZM651.01,1412.31l0.15,0.38 -0.78,0.42 -0.74,-0.66 0.12,1.21 -1.26,-0.99 1.2,-1 1.31,0.64ZM648.38,1415.27l0.3,0.56 -1.74,-0.68 -0.25,-1.69 0.54,-0.12 1.15,1.93ZM650.57,1416.46l-1.14,-0.44 0.1,-1.39 0.49,-0.18 0.55,2.01ZM653.39,1421.16l0.56,2.24 0.24,-0.93 1.55,1.61 -0.19,1.05 -1.98,-1.17 -0.74,-2.71 -1.36,-1.26 1.29,-2.72 1.06,1.08 -0.08,0.47 -1.76,1.11 1.13,0.48 0.28,0.75ZM654.25,1430.7l-0.89,-0.42 0.3,-1.43 0.47,0.36 0.12,1.49ZM655.43,1434.05l-0.49,0.68 -0.36,-0.59 -0.47,0.54 0.27,-2.2 1.05,1.57ZM650.2,1437.25l-0.26,0.31 -0.36,-0.67 0.26,-0.81 0.36,1.17ZM1016.6,1512.62l-0.43,-1.5 -4.34,-2.76 -0.55,-1.45 -0.49,-3.43 0.62,-2.74 -0.12,-0.83 -0.7,-0.44 -0.68,-1.27 -0.93,-7.81 -0.71,-0.86 -5.22,-3.22 -2.43,-3.27 -2.11,-0.99 -2.29,-1.99 -2.3,-0.94 -1.43,-1.29 -0.34,-1.02 0.41,-2.32 -0.34,-2.21 0.39,-0.63 -0.08,-2.03 0.95,-3.18 -0.85,-1.79 -1.54,-0.84 -0.05,-1.03 2.31,-4.09 4.56,-2.87 0.02,-9.51 0.77,-0.17 1.12,-1.52 1.82,0.55 5.65,-3.25 9.27,-6.42 7.92,0.37 -5.17,11.69 0.23,0.6 0.58,-0.15 1.26,0.8 1.27,2.78 11.37,3.16 3.21,1.85 3.92,0.38 3.88,1.11 0.63,1.1 -0.23,1.02 2.21,0.91 1.29,1.21 0.16,1.46 -0.91,3.42 0.38,0.4 2.02,-0.17 -0.65,2.08 0.77,1.95 2.2,0.87 0.46,-1.87 1.99,-1.71 1.47,-2.63 3.88,0 5.8,3.65 -3.09,2.99 -2.03,3.14 -3.62,12.03 -1.24,6.84 -0.15,5.2 1.32,12.95 -41.09,-0.31ZM1115.42,1586.57l-1.57,-0.44 -2.02,-1.68 -3.51,-5.95 -0.33,-0.72 0.45,-1.77 -0.39,-2.56 1.31,0.49 2.04,-0.94 0.31,-1.06 1.26,-1.24 -0.26,-1.91 1.49,-2.84 0.81,-0.71 0.58,0.32 0.61,1.4 1.32,-0.78 -0.25,-2.03 1.65,-2.73 0.58,-0.04 1.9,-1.74 1.21,0.44 0.8,-0.35 3.41,-2.72 1.01,-1.38 0.02,-1.05 3.08,-9.34 -0.03,-1.21 -0.62,-1.77 0.24,-0.6 1.35,-0.65 0,13.76 11.85,0 -0.12,7.54 2.22,-1.48 2.48,-2.42 1.18,0.33 2.2,-2.55 1.14,1.14 2.08,0.24 1.01,-1.4 2.56,-0.85 0.95,0.11 0.8,0.69 1.96,0.47 -0.19,0.35 1.05,1.29 -0.14,0.69 0.74,1.4 -1.24,2.96 -5.53,-4.51 -1.29,4.28 -1.66,2.37 -3.27,2.65 -1.4,-0.03 -0.56,0.44 -2.27,4.56 -1.77,0.32 -1.24,-0.53 -0.57,-0.99 -0.96,-0.19 -0.86,2.44 -2.14,3.24 -0.78,1.95 -3.12,4.25 -0.45,1.07 0.45,0.81 -1.43,2.12 -1.06,0.57 -0.49,-0.52 -2.41,0.98 -1.41,-0.3 -0.82,1.58 -2.99,0.69 -1.95,-1.01 -2.72,1.8 -3.26,-1.74 -1.09,-2.05 0.07,-0.96ZM864.46,1535.68l-79.96,0 -0.01,-62.26 79.8,0 0.17,62.26ZM3705.84,1830.6l-0.35,0.45 -0.37,-0.98 0.7,0.2 0.02,0.33ZM3705.88,1859.53l-0.61,0.03 -0.31,-0.5 0.73,-0.02 0.19,0.49ZM3700.79,1885.25l-0.56,0.55 -0.72,-0.62 0.91,-0.3 0.37,0.37ZM3706.62,1838.8l-0.55,0.26 0.89,-1.38 0.32,0.43 -0.66,0.69ZM3706.33,1873.78l-0.03,0.31 -0.74,-0.21 0.33,-1.07 1.24,-0.59 -0.8,1.56ZM3705.31,1875.7l-0.47,0.6 -0.39,-1.31 0.44,-0.35 0.25,0.01 0.17,1.05ZM1310.21,1835.79l-0.86,0.11 -1.17,-0.56 1.53,-0.08 0.5,0.53ZM1312.32,1835.5l-1.46,0.16 0.4,-0.37 1.06,0.21ZM1311.11,1842.2l0.95,0.53 1.16,0 -1.21,0.53 -2.3,0.05 0.05,-0.84 1.35,-0.27ZM3694.84,1895.77l-0.48,0.02 -0.56,-0.65 -0.01,-1.35 1.6,-1.15 0.53,-1.11 0.44,0.09 0.74,0.52 -1.83,1.86 -0.43,1.77ZM105.51,2213.02l-0.48,0.1 -0.59,-0.56 1.5,-0.64 1.37,0.11 -0.82,0.18 -0.98,0.81ZM1295.59,1834.42l0.7,0.2 -0.28,-0.49 0.26,0 5.02,1.05 0.09,1.66 -3.98,3.21 -3.12,0.33 -6,-0.47 -1.45,0.46 -3.38,-0.55 0.28,-2.76 -1.05,-1.68 1.05,-0.85 0.15,-0.77 1.13,-0.27 9.91,0.56 0.67,0.37ZM1303.6,1838.48l-1.47,-0.02 -0.2,-0.36 1.09,-0.33 2.07,0.38 -1.49,0.33ZM1275.76,1839.03l-0.66,-0.32 0,-0.34 0.99,0.05 -0.33,0.61Z`,tGe=`M1102.45,1516.11l0.32,0.17 -0.35,3.14 3.11,1.13 2.15,-0.62 1.52,1.61 0.57,-1.92 0.57,-0.7 6.11,-3.25 -0.14,0.89 0.23,-0.02 1.55,-2.9 3.71,-2.83 4.15,-0.5 10.76,1.79 0.36,-0.12 -4.43,-0.91 2.63,-2.49 1.38,-0.44 8.11,-1.21 3.75,0.28 1.53,-0.95 -1.34,-1.52 -0.3,-1.32 1.95,0.75 -0.33,0.94 0.53,3.08 -3.78,3.78 -5.63,3.93 -7.17,3.98 -10.17,4.13 -5.63,3.95 -4.53,0.28 -4.08,1.44 -1.85,-1.05 -4.38,0.19 3.73,-1.01 -1.49,-0.89 -1.51,0.57 -5.61,-3.05 1.07,-2.1 2.12,-2.58 0.01,-1.5 0.8,-2.15Z(M1149.27,1505.2l0.33,0.06 0.51,-1.02 -1.12,0.03 0.28,0.93Z(M1107.76,1524.37l-0.18,-1.23 -0.35,1.4 0.53,-0.17Z(M1185.72,1481.69l0.12,0.41 -0.64,0.98 -5.92,4.63 0.53,0.99 1.51,-0.57 0.22,0.54 -0.44,0.66 1.39,0.08 -1.46,1.96 -0.43,0.06 0.04,-0.38 -0.59,0.4 0.76,1.76 0.17,2.88 -3.07,1.06 -2.84,2.58 -1.85,0.44 -0.89,0.79 -3.5,-0.48 -2.94,0.42 -3.52,-1.4 -3.83,-0.59 -5.85,0.52 -7.38,2.56 -4.44,-0.86 -0.51,-0.75 2.32,-4.35 3.03,-1.75 2.76,-2.29 15.18,-2.75 0.5,-0.56 1.51,0.31 -0.21,0.28 0.74,0.71 2.77,-0.02 -0.63,0.27 0.54,0.4 0.88,-0.42 -0.21,1.14 1.75,-0.12 2,-0.94 0.1,-0.35 -1.98,0.21 2.06,-2.35 -2.73,0.85 -0.16,-0.52 0.38,-1.09 -0.36,-0.39 -1.78,0.54 -0.28,0.65 -0.4,-0.1 -0.01,-0.78 -2.87,0.93 3.8,-1.49 2.18,-0.26 0.44,0.13 -0.15,0.64 0.27,0.06 1.29,-0.55 -1.89,1.52 0.81,0.27 3.45,-2.28 3.19,-0.7 5.3,-2.36 1.26,-1.27 0.51,0.09Z(M1175.47,1487.21l0.51,-0.98 -1.9,0.94 1.39,0.04Z(M1180.16,1489.25l0.15,0.29 0.36,-0.6 -0.51,0.31Z(M1180.59,1485.7l0.12,-0.34 -2.32,0.43 -0.6,0.77 -0.01,0.8 0.7,0.1 1.06,-1.37 1.05,-0.39Z(M1130.62,1730.2l-1.29,2.42 -0.47,0.08 -1.27,-0.78 -2.11,-2.6 2.4,-2.44 1.27,-0.45 1.18,1.64 0.29,2.13Z(M773.99,1535.66l0.15,0.92 -1.56,0.91 -1.05,1.68 -2.05,1.03 -1.23,-3.65 -0.78,1.57 -0.38,-0.14 -1.69,-2.57 -0.97,-3.09 -1.68,-2.33 -0.6,-3.34 1.93,-0.91 1.17,-0.03 0.39,0.86 -0.34,1 1.52,1.6 0.87,0.16 1.03,3.06 0.8,-0.45 -0.41,-2.78 0.33,-0.38 1.48,0.98 2.04,-0.11 -0.14,0.8 -1.87,0.03 -0.72,0.95 2.52,3.29 1.24,0.94Z(M771.74,1537.58l0.18,-1.21 -0.49,-1.52 -0.43,-0.2 -0.3,0.17 0.15,1.41 0.89,1.35Z(M1083.59,1460.59l-2.49,0.42 0.3,0.38 -0.25,0.6 -1.26,1.65 0,1.6 1.8,1.53 -3.34,0.92 -1.74,1.28 -0.15,3.94 -1.82,4.19 0.63,-3.58 -0.46,0.31 -0.67,2.56 -0.33,0.19 -0.29,-0.54 0.93,-5.94 -0.58,0.22 -2.74,3.73 -0.6,-0.24 -1.67,0.97 -0.78,2.7 -1.51,0.78 0.19,2.37 -0.62,3.51 -2.56,4.38 0.83,2.07 0.12,1.75 -1.19,2.77 2.43,6.47 1.22,5.04 -0.43,5.72 -1.68,4.73 -2.57,4.79 -1.88,1.88 -4.1,2.16 -2.25,0.05 -1.8,-1.18 -2.05,-5.56 -1.17,-1.95 -0.17,-5.1 0.35,-3.26 -1.21,-4.02 -0.16,-3.63 1.15,-4.59 1.15,-2.91 -0.34,-2.01 0.34,-1.98 1.1,-2.35 0.78,-0.78 0.25,-0.89 -0.17,-2.47 2.17,-6.24 -0.94,-1.44 -2.1,0.3 -2.09,3.13 -2.06,1.59 -0.57,-0.3 -0.11,-0.75 0.88,-2.33 1.38,-2.87 2.31,-1.45 0.39,-2.34 5.44,-8.35 1.5,-3.67 -0.11,2.09 0.62,1.46 2.1,-2.6 2.16,-0.38 0.05,1.25 -1.51,1.71 0.02,0.72 0.77,0.56 1.08,-2.13 2,-1.27 0.91,-1.72 1.69,-0.53 2.38,0.45 3.4,-1.29 1.55,-1.43 1.06,-0.02 4.71,1.96 2.44,2.06 -0.06,1.15Z(M1075.29,1461.12l-0.53,-0.25 -0.39,0.61 -0.45,2.1 1.18,-0.25 0.19,-2.21Z(M1068.91,1470.91l0.17,0.87 0.57,0.24 0.09,-0.71 -0.83,-0.4Z(M1058.97,1466.73l-0.46,0.76 0.23,0.36 0.97,-0.1 0,-0.91 -0.74,-0.11Z(M1057.57,1468.55l-2.38,2.66 -1.57,2.96 0.48,1.85 0.84,0.07 1.05,-1.4 0.54,-1.91 0.93,-1 -0.28,-0.83 0.31,0.06 0.03,-1.09 0.71,-0.37 0.06,-0.55 -0.72,-0.45Z(M1087.35,1448.61l1,-0.15 -2.09,1.57 -1.22,-0.76 -2.46,0.21 -2.08,-0.6 0.22,-2.99 0.53,-1.4 -0.53,-0.21 -6.84,1.54 -5.87,0.06 -3.08,1.64 -2.67,2.23 -1.09,-0.61 -2.05,0.11 -1.38,-0.99 -1.55,0.49 -2.13,-0.18 -3.18,-5.01 -1.59,-1.02 -5,-1.06 -1.89,1.28 -0.75,1.22 -0.31,-0.59 0.11,-2.93 -0.88,-1.82 -1.01,-0.76 -0.21,-1.09 -2.03,1.44 -1.35,1.72 -2.35,0.91 -2.28,1.78 -3.87,0.72 -5.22,3.06 -3.58,1.16 -3.05,-1.73 -0.38,0.72 -1.98,0.43 2,-4.8 -0.82,-0.9 -1.2,0.14 -2.07,1.44 -1.02,-0.3 -3.21,1.98 -3.83,1.07 -1.72,0.05 -1.36,-1.05 0.48,-0.94 4.77,-3.85 9.09,-8.99 2.83,-1.73 8.75,-3.61 5.5,-3.74 1.41,-3.24 0.23,-2.4 4.85,-2.27 -1.16,3.46 -0.64,0.79 2.26,-0.84 1.24,-3.68 0.86,-1.02 0.54,-3.02 1.22,-0.21 0.49,0.42 0.33,1.42 -2.77,3.62 -0.2,0.62 0.28,0.78 0.67,-0.35 0.65,-1.6 2.39,-0.63 1.08,-1.48 0.34,-1.61 -1.32,-1.57 -0.44,-1.85 2.2,-0.48 9.63,3.91 4.59,0.05 1.45,-0.61 1.27,0.95 1.69,-0.09 1.71,2.76 2.03,6.65 2.16,3.08 3.41,1.51 8.64,-0.16 -1.81,5.27 0.89,1.67 2.5,1.9 1.38,1.79 -1.42,2.99 -0.63,2.3 1.71,1.36 1.55,-0.36 1.18,0.64 0.03,0.87 -1.17,0.1 -0.78,0.7 0.15,1.8 0.59,-0.77 0.57,0.34 -1.48,2.98 0.77,0.99 0.78,-0.64Z(M1015.4,1441.26l-0.06,0.46 0.6,0.16 -0.54,-0.62Z(M1016.57,1443.54l0.65,-0.68 -2.23,1.6 1.58,-0.92Z(M1017.78,1442.02l0.05,-0.73 -1.23,0.43 1.18,0.3Z(M1019.33,1439.94l-0.42,-0.37 -0.28,0.81 0.7,-0.44Z(M1046.11,1409.48l-0.34,0.5 0.34,1.58 2.74,-0.89 0.58,-1.26 -1.71,-0.41 -1.61,0.48Z(M1036.39,1424.91l3.26,-1.8 0.49,-1.17 1.1,-0.96 -1.18,0.15 -6.35,3.5 -0.61,0.61 0.35,0 -0.29,1.1 2.56,-0.49 0.53,-0.4 -0.36,-0.36 0.5,-0.18Z(M1049.14,1433.78l0.56,-0.37 -1.56,-0.85 -2.64,0.19 -2.39,0.87 -2.75,2.5 -0.61,1.64 2.07,0.87 -0.23,-0.5 0.42,-0.66 0.09,1.01 -0.68,1.4 0.34,0.61 0.42,-0.14 1.88,-2.33 0.17,-0.87 2.81,-2.42 -0.52,-0.63 2.62,-0.32Z(M1050.28,1410.98l0.78,-0.12 -0.05,-0.4 -0.87,-1.06 -0.52,0.12 0.05,1.22 0.61,0.24Z(M1074,1428.2l-0.41,-0.67 -1.41,-0.42 -1.33,0.27 -0.78,0.73 1.05,0.48 2.88,-0.39Z(M1088.35,1448.46l2.03,-0.52 0.9,0.92 -0.06,2.41 7.2,2.03 4.93,0.93 3.49,-0.43 0.92,0.57 3.28,-0.34 1.75,0.97 4.86,0.49 0.04,0.76 1.71,-1.01 0.84,0.74 -1.12,0.56 0.48,0.47 -0.33,0.55 0.34,0.19 1.68,-0.46 2.42,0.33 0.71,-0.68 0.16,1 0.72,0.22 3.17,-0.16 3.5,5.9 0.75,0.09 0.35,-0.58 0.73,3.58 1.96,0.89 0.01,-0.85 1.36,0.36 0.08,1.19 -0.81,1.25 0.82,0.31 0.48,0.82 -0.9,0.71 2.09,2.46 0.84,0.33 0.65,1.88 0.86,-0.9 -0.15,1.35 0.35,0.35 -1.69,0.02 -1.12,-0.72 -0.05,-0.8 -2.03,0.9 1.26,2.47 -0.12,1.29 -0.88,1.31 -4.27,-1.41 -1.51,-0.97 -0.88,-1.41 -1.36,0.42 -1.36,1.33 0.16,-2.62 -0.77,-0.45 -1.9,0.63 1.41,-1.71 0.38,-1.5 -1.15,0.9 -0.68,-0.07 -0.05,-0.8 -1.38,-0.97 -0.61,-2.06 0.32,-1.38 -4.69,-0.16 -0.1,0.45 1.31,0.93 1.59,2.43 1.09,0.61 -0.04,1.06 0.91,1.95 0.01,2.34 -1.42,2.92 -1.85,1.61 -1.63,3.64 -0.27,1.11 0.22,9.24 -0.82,2.3 -4.51,3.78 -2.68,1.05 -0.51,-0.99 -2.29,-12.12 -0.61,-1.34 -1.84,-1.72 -1.32,-0.21 -4.42,2.17 0.34,0.7 -1.32,2.34 -1.19,0.53 -1.07,1.2 -2.05,-0.67 -1.03,-1.16 0.68,-3.55 3.01,-1.52 1.15,-3.37 0.57,0.1 1.5,-1.76 0.36,-6.55 -0.32,-1.34 -1.41,-1.98 0.29,-1.08 1.67,0.2 -0.59,-1.89 -0.74,-0.93 -0.02,-0.84 -0.92,-1.05 -5,-2.39 -1.76,-0.38 -1.93,-2.19 -2.27,-0.52 -3.65,-1.9 0.06,-1.15 0.5,-0.12 -0.13,-1.42 1.06,-1.56 1.26,0.95 6.17,0.54 0.88,-0.32 -0.18,-0.65 -1.41,-1.11 -0.16,-1.16 -2.19,-0.72 0.52,-1.32 -0.6,-2.05 -1.18,-1.6 0.16,-0.44Z(M1099.72,1457.32l-1.05,0.48 -0.49,0.93 1.07,0.62 0.62,-0.19 0.71,-1.09 -0.86,-0.75Z(M1097.63,1456.81l-0.91,-1.19 -0.86,-0.16 0.01,0.8 -0.36,0.33 -1.78,0.33 -0.04,0.42 0.59,0.59 2.67,0.23 1.08,-0.81 -0.4,-0.54Z(M1094.21,1454.78l0.39,-1.1 -0.31,-0.64 -1.69,-0.82 -1.44,0.26 1.35,2.93 0.82,0.2 0.35,-0.84 0.53,0.01Z(M1090.35,1451.87l-0.19,0.74 0.73,0.55 0.02,-0.64 -0.56,-0.65Z(M1090.76,1451.6l-0.35,-1.14 0.24,-2 -0.84,-0.08 -0.66,0.8 0.97,2.1 0.64,0.32Z(M1087.39,1460.36l-1.53,0.05 1.72,1.1 0.42,-0.48 -0.61,-0.67Z(M1104.07,1459.92l7.28,2.45 3.04,1.99 2.67,-2.12 0.7,-0.1 -1.2,1.42 -1.27,0.66 1.08,0.56 1.44,-0.91 1.84,-3.26 -1.04,-0.16 0.23,-1.15 -0.38,-0.36 -1.21,2.46 -0.39,-0.74 -0.02,-1.58 -0.44,-0.12 -0.68,-1.42 -1.32,0.4 -1,1.4 -2.16,-1.84 -2.22,0.7 -0.6,0.71 0.68,0.76 -0.12,0.71 -1.47,-0.88 -1.19,0.02 -0.66,-0.84 -0.25,-1.32 -2.87,0.9 -0.9,-0.55 -0.45,0.59 -0.07,0.5 0.7,0.44 2.25,0.68Z(M1118.29,1464.93l-1.42,0.68 0.56,0.3 0.86,-0.98Z(M1135.81,1476.71l0.02,-1.1 -0.74,0 0.72,1.1Z(M977.9,1400.16l0.05,1.84 -0.81,1.07 0.1,-0.99 -1.27,-2.28 -0.65,-0.24 0.28,-1.11 -4.47,0.46 -1.12,0.62 -0.51,0.98 1.7,-0.01 2.01,2.12 1.25,-0.59 1.3,1.48 1.89,0.45 -1.4,1.03 -1.28,-0.13 -0.16,0.57 -4.43,3.59 -1.2,-0.07 -2.1,-1.67 -2.01,1.17 -1.07,0.18 -0.45,-0.73 0.6,-3.62 3.16,-1.02 0.53,-0.77 -0.06,-1.42 -0.83,-0.82 4.2,-4.12 -1.14,-0.23 -4.12,2.68 -0.36,-0.15 0.26,-1.24 -0.41,-1.4 1.64,-0.22 0.53,0.25 -0.14,0.65 0.54,0.14 0.98,-0.64 -0.34,-0.88 0.54,-0.49 2.67,-0.59 0.32,-0.7 -0.18,-0.77 -1.17,-2.57 0.73,-0.7 0.86,1.08 0.1,1.39 0.9,2.03 1.19,0.23 0.39,0.69 -0.03,1.5 -0.61,0.64 0.76,0.85 1.46,0.32 0.33,1.21 1.05,0.95Z(M970.51,1403.35l-0.98,-0.04 0.64,1.75 0.84,0.04 0.73,0.93 0.74,-0.09 0.93,-2.4 -0.78,-0.62 -2.12,0.43Z(M296.15,1194.71l-6.4,3.19 -0.91,3.96 -12.85,2.61 -1.57,-0.94 -0.37,-1.79 0.77,-1.81 9.71,-3.78 7.56,-1.94 4.06,0.5Z(M683.32,1565.04l-0.26,0.99 -0.77,0.18 -0.54,-0.38 -0.67,-1.75 0.08,-0.77 0.83,-1.15 1.11,-0.48 0.5,0.7 -0.28,2.66Z(M1043.06,1488.32l-0.1,2.04 -1.11,2.06 -0.38,-0.09 -0.62,-3.4 0.39,-1.29 0.76,-1.34 0.68,-0.02 0.42,0.25 -0.04,1.79Z(M1213.18,1487.05l-0.37,1.48 0.43,4.69 -0.95,-5.15 0.08,-1.74 1.02,-1.4 -1.02,-5.68 1.11,-6.11 0.26,-0.17 0.44,1.87 0.92,-1.76 1.14,-0.9 -0.08,1.1 -0.93,0.85 0.23,0.6 -0.47,5.33 -0.56,0.72 0.4,1.54 -1.65,4.73Z(M732.6,1646.14l-0.05,0.7 -0.93,1.15 -1.04,-0.11 -3.1,-3.9 0.09,-0.94 1.19,-0.24 3.84,3.34Z(M749.16,1424.97l-0.49,-1.81 0.74,-0.89 0.99,1.3 0.26,1.38 0.22,2.53 -0.59,1.25 -1.06,-0.06 -0.15,-0.43 0.42,-0.74 -0.25,-0.49 -1.16,-0.41 1.07,-1.63Z(M755.08,1610.82l-1.81,-2.51 -2.21,-2.19 -0.57,0.02 -0.81,1.85 -1.12,0.37 -0.97,-0.34 -0.9,-0.99 -0.89,0.29 -0.6,-0.37 -1.55,0 -1.15,1.3 -0.8,-0.86 -0.05,-0.66 4.37,-1.63 0.51,-3.47 0.58,-0.52 -0.39,4.38 0.86,1.4 0.78,0.85 0.76,-0.38 1.47,-2.37 0.38,0.02 2.5,2.75 1.61,3.06Z(M885.79,1431.15l-1.02,-0.36 -2.19,0.45 1.48,-1.6 -0.42,-1.69 -2.56,-0.48 -0.62,-0.57 -0.42,-1.65 0.44,-1.29 -1.67,-1.56 -3.39,-0.71 -4.56,1.87 -0.69,-0.2 -0.71,-1.18 -1.9,1.35 -0.26,-0.17 0.16,-0.79 1.05,-1.16 1.04,-0.19 1.41,1.47 1.12,-0.15 2.67,-1.62 2.29,0 2.75,1.12 0.87,0.89 0.46,1.45 -0.2,2.1 0.55,0.36 1.35,0.29 0.27,-0.24 -0.35,-2.01 1.79,-0.67 -0.41,1.12 0.62,2.47 0.8,0.62 -0.49,0.88 0.59,0.9 3.15,1.06 7.75,-1.41 0.71,0.65 -2.95,1.69 -2.16,-0.15 -3.73,0.86 -2.62,-1.75Z(M755.08,1610.82l-1.81,-2.51 -2.21,-2.19 -0.57,0.02 -0.81,1.85 -1.12,0.37 -0.97,-0.34 -0.9,-0.99 -0.89,0.29 -0.6,-0.37 -1.55,0 -1.15,1.3 -0.8,-0.86 -0.05,-0.66 4.37,-1.63 0.51,-3.47 0.58,-0.52 -0.39,4.38 0.86,1.4 0.78,0.85 0.76,-0.38 1.47,-2.37 0.38,0.02 2.5,2.75 1.61,3.06Z(M792.26,1581.42l-0.75,2.69 -4.57,6.97 0.49,0.45 1.62,-0.22 -0.3,0.48 -3.63,0.87 -5.44,2.59 -0.64,-1.38 2.17,-0.47 0.95,-1.2 0.51,0.39 0.54,-0.66 2.28,0.21 1.19,-2.63 0.67,-0.25 0.72,-1.13 -0.22,-1.36 0.84,-0.07 1.44,-1.44 1.23,-1.98 0.13,-1.48 0.36,-0.5 0.41,0.12Z(M906.94,1473.16l-0.93,0.46 -0.25,1.49 -0.95,1.63 -1.82,0.71 0.46,2.38 1.22,0.44 -0.18,0.82 1.21,0.83 -0.16,0.82 -2.26,-0.82 -0.82,-3.9 -0.48,-0.28 -1.4,-0.51 -3.88,0.59 2.2,-0.8 0.41,-0.66 1.75,-0.26 0.44,-0.26 -0.13,-0.51 2.49,1.15 0.67,-0.96 0.49,-0.02 0.12,-2.06 1.14,-1.64 0.14,-0.9 0.2,-1.65 -0.33,-0.73 -0.7,-0.71 -2.33,-0.1 3.05,-0.58 -1.03,-1.84 -2.31,-2.58 2.16,0.29 0.65,-1.06 -0.27,-1.6 -2.79,-5.1 -0.1,-0.69 0.85,-2.5 -0.14,-2.89 -0.32,-1.51 -1.52,-1.53 -0.11,-0.69 0.72,0.14 1.47,1.46 0.65,3.82 -0.53,3.28 0.17,1.49 0.76,1.78 1.62,2.19 0.06,2.75 -0.72,1.98 1.44,2.22 0.3,2.99 -0.35,2.49 0.27,0.7 -0.3,0.44Z`.split(`(`),r9=4096,nGe=85.05112878;function i9(e,t){let n=Math.max(-85.05112878,Math.min(nGe,t))*Math.PI/180,r=(e+180)/360,i=.5-Math.log(Math.tan(Math.PI/4+n/2))/(2*Math.PI);return{x:r*r9,y:i*r9}}function rGe(e){let t=.5-e.y/r9,n=2*Math.atan(Math.exp(2*Math.PI*t))-Math.PI/2;return{lon:e.x/r9*360-180,lat:n*180/Math.PI}}function iGe(e,t){return{x:(e.x-t.tx)/t.k,y:(e.y-t.ty)/t.k}}function aGe(e){if(!Number.isFinite(e)||e<=0)return 4;let t=Math.log2(r9*1.08*e/256);return Math.max(0,Math.min(21,Math.round(t)))}function oGe(e,t){return e!=null&&t!=null&&Number.isFinite(e)&&Number.isFinite(t)&&Math.abs(e)<=90&&Math.abs(t)<=180}function sGe(e,t,n){let r=`${e.toFixed(6)},${t.toFixed(6)}`;return n==null?`https://www.google.com/maps/search/?api=1&query=${r}`:`https://www.google.com/maps/@${r},${Math.round(n)}z`}function cGe(e,t){return`https://www.google.com/maps/dir/?api=1&destination=${e.toFixed(6)},${t.toFixed(6)}`}function a9(e,t){return{x:t.tx+e.x*t.k,y:t.ty+e.y*t.k}}function lGe(e,t,n,r=40,i=r9/90){if(e.length===0)return null;let a=1/0,o=-1/0,s=1/0,c=-1/0;for(let t of e)a=Math.min(a,t.x),o=Math.max(o,t.x),s=Math.min(s,t.y),c=Math.max(c,t.y);let l=Math.max(o-a,i),u=Math.max(c-s,i),d=(a+o)/2,f=(s+c)/2;l*=1.16,u*=1.16;let p=Math.min((t-r*2)/l,(n-r*2)/u);return{k:p,tx:t/2-d*p,ty:n/2-f*p}}function uGe(e,t,n,r,i,a){let o=Math.max(i,Math.min(a,e.k*t));return o===e.k?e:{k:o,tx:n-(n-e.tx)*o/e.k,ty:r-(r-e.ty)*o/e.k}}function o9(e,t){return e/t}function dGe(e,t,n){return`${o9(e,n)} ${o9(t,n)}`}function fGe(e,t,n=1/0){let r=t/r9;return{kMin:Math.min(e,Math.max(r,e*.25)),kMax:Math.max(e,Math.min(e*60,n))}}function pGe(e){return Math.max(0,Math.min(1,(1.5-e)/.9))}function mGe(e,t,n,r,i,a,o=14,s=6){let c=t-r-o;return{x:Math.max(s,Math.min(i-n-s,e-n/2)),y:Math.max(s,Math.min(a-r-s,c>=s?c:t+o))}}var hGe=6371.0088,gGe=(e,t)=>{let n=Math.PI/180,r=(t.lat-e.lat)*n,i=(t.lon-e.lon)*n,a=Math.sin(r/2)**2+Math.cos(e.lat*n)*Math.cos(t.lat*n)*Math.sin(i/2)**2;return 2*hGe*Math.asin(Math.min(1,Math.sqrt(a)))};function _Ge(e,t,n,r=!1){if(e.length<2)return 0;let i=0;for(let r=1;rn(t[e],t[r]);for(let e=0;e`${e.lat.toFixed(6)},${e.lon.toFixed(6)}`,i=Math.min(e.length,xGe(!!t.coarsePointer,n));for(;;){let t=e.slice(0,i),a=t[0],o=n?a:t[t.length-1],s=n?t.slice(1):t.slice(1,-1),c=`https://www.google.com/maps/dir/?api=1&origin=${r(a)}&destination=${r(o)}`+(s.length?`&waypoints=${s.map(r).join(`|`)}`:``)+`&travelmode=driving`;if(c.length<=2048||i<=2)return{url:c,used:i};--i}}function CGe(e,t,n,r){return{x0:Math.min(e,n),y0:Math.min(t,r),x1:Math.max(e,n),y1:Math.max(t,r)}}function wGe(e,t,n,r,i,a){if(e==null||!Number.isFinite(e))return a;if(!(n>t))return(r+i)/2;let o=Math.max(0,Math.min(1,(e-t)/(n-t)));return Math.sqrt(r*r+o*(i*i-r*r))}var s9=1e3,c9=620,TGe=3.2,EGe=15,DGe=4.5,OGe=2.6,l9=[{fill:`#9DBFF2`,line:`#5F7FB0`},{fill:`#A5D8B4`,line:`#5E9C74`},{fill:`#F5D989`,line:`#B39A46`},{fill:`#F0A8A0`,line:`#B76D65`},{fill:`#7E99C2`,line:`#4A6790`},{fill:`#84AD91`,line:`#4C7A5C`},{fill:`#C4AE6E`,line:`#8C7838`},{fill:`#C0867F`,line:`#8A5049`}],u9={fill:`#D7DBE3`,line:`#8A909C`},d9={fill:`#9DBFF2`,line:`#4F6079`};function kGe(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:null}function AGe(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:null}function jGe({rows:e,field:t,colorField:n,sizeField:r,selectedPids:i,onSelectPids:a,onOpen:o}){let[s,c]=(0,L.useState)(null),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),[_,v]=(0,L.useState)(null),[y,b]=(0,L.useState)(null),x=(0,L.useRef)(null),S=(0,L.useRef)(!1),C=(0,L.useRef)(!1),w=(0,L.useMemo)(()=>{let i=[];for(let a of e){let e=kGe(a.lat),o=kGe(a.lon);e==null||o==null||Math.abs(e)>90||Math.abs(o)>180||i.push({pid:a.pid,title:String(a[t.key]??``),p:i9(o,e),lat:e,lon:o,colorKey:n?String(a[n.key]??``).trim():null,size:r?AGe(a[r.key]):null,colorVal:n?a[n.key]:null,sizeVal:r?a[r.key]:null})}return i},[e,t.key,n,r]),T=e.length-w.length,E=(0,L.useMemo)(()=>lGe(w.map(e=>e.p),s9,c9),[w]);(0,L.useEffect)(()=>{E&&(!C.current||h==null)&&g(E)},[E]);let{kMin:D,kMax:O}=(0,L.useMemo)(()=>E?fGe(E.k,c9,32):{kMin:1,kMax:1},[E]),k=(0,L.useMemo)(()=>{if(!n)return null;let e=[],t=new Map;for(let n of w){let r=n.colorKey??``;t.has(r)||(t.set(r,0),e.push(r)),t.set(r,(t.get(r)??0)+1)}let r=e.filter(e=>e!==``),i=new Map;return r.forEach((e,t)=>i.set(e,t{if(!r)return null;let e=1/0,t=-1/0,n=0;for(let r of w){if(r.size==null){n+=1;continue}e=Math.min(e,r.size),t=Math.max(t,r.size)}return Number.isFinite(e)?{min:e,max:t,missing:n,none:!1}:{min:0,max:0,missing:n,none:!0}},[r,w]),j=(0,L.useMemo)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(pointer: coarse)`).matches,[]),M=(0,L.useMemo)(()=>i.size<2?[]:w.filter(e=>i.has(e.pid)&&oGe(e.lat,e.lon)).sort((e,t)=>e.pid-t.pid),[w,i]),ee=i.size-M.length,N=(0,L.useMemo)(()=>{if(!l||M.length<2)return null;let e=M.map(e=>({lat:e.lat,lon:e.lon})),t=0;for(let e=1;ee.pid===p);e>=0&&(t=e)}let{order:n,km:r}=bGe(e,gGe,{start:t,roundTrip:d});return{ordered:n.map(e=>M[e]),km:r,link:SGe(n.map(t=>e[t]),{roundTrip:d,coarsePointer:j})}},[l,M,d,p,j]),te=(0,L.useCallback)(e=>{if(!k)return d9;let t=e.colorKey??``;return t===``?u9:k.swatch.get(t)??u9},[k]),ne=(0,L.useCallback)(e=>!r||!A||A.none?DGe:wGe(e.size,A.min,A.max,TGe,EGe,OGe),[r,A]),P=(0,L.useCallback)((e,t)=>{if(!y)return{x:0,y:0};let n=y.getBoundingClientRect();return{x:(e-n.left)/n.width*s9,y:(t-n.top)/n.height*c9}},[y]);(0,L.useEffect)(()=>{if(!y)return;let e=e=>{e.preventDefault();let{x:t,y:n}=P(e.clientX,e.clientY);C.current=!0,g(r=>r&&uGe(r,Math.exp(-e.deltaY*.0016),t,n,D,O))};return y.addEventListener(`wheel`,e,{passive:!1}),()=>y.removeEventListener(`wheel`,e)},[y,P,D,O]);let re=(0,L.useCallback)(e=>{C.current=!0,g(t=>t&&uGe(t,e,s9/2,c9/2,D,O))},[D,O]),F=(0,L.useCallback)(()=>{C.current=!1,g(E)},[E]),ie=(0,L.useCallback)((e,t)=>{C.current=!0,g(n=>n&&{...n,tx:n.tx+e,ty:n.ty+t})},[]),ae=(0,L.useCallback)(e=>{let t=e.shiftKey?160:60;switch(e.key){case`ArrowLeft`:ie(t,0);break;case`ArrowRight`:ie(-t,0);break;case`ArrowUp`:ie(0,t);break;case`ArrowDown`:ie(0,-t);break;case`+`:case`=`:re(1.6);break;case`-`:case`_`:re(1/1.6);break;case`0`:F();break;case`Escape`:if(!_)return;v(null);break;default:return}e.preventDefault()},[ie,re,F,_]),oe=(0,L.useCallback)(e=>{if(e.button!==0||!h)return;let{x:t,y:n}=P(e.clientX,e.clientY);S.current=!1,e.currentTarget.setPointerCapture(e.pointerId),e.shiftKey||e.ctrlKey||e.metaKey?v({x0:t,y0:n,x1:t,y1:n}):x.current={x:t,y:n,tx:h.tx,ty:h.ty}},[h,P]),se=(0,L.useCallback)(e=>{let{x:t,y:n}=P(e.clientX,e.clientY);if(_){S.current=!0,v(e=>e&&{...e,x1:t,y1:n});return}let r=x.current;r&&(Math.abs(t-r.x)+Math.abs(n-r.y)>2&&(S.current=!0),C.current=!0,g(e=>e&&{...e,tx:r.tx+(t-r.x),ty:r.ty+(n-r.y)}))},[_,P]),ce=(0,L.useCallback)(e=>{if(_&&h){let t=CGe(_.x0,_.y0,_.x1,_.y1);if(t.x1-t.x0>3&&t.y1-t.y0>3){let n=[];for(let e of w){let r=a9(e.p,h);r.x>=t.x0&&r.x<=t.x1&&r.y>=t.y0&&r.y<=t.y1&&n.push(e.pid)}a(n,e.altKey?`add`:`replace`)}v(null)}x.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},[_,h,w,a]);if(!h||!E)return(0,B.jsxs)(`div`,{className:`cg-mode-empty`,children:[`No records with a location to map yet.`,T>0&&` ${T.toLocaleString()} matching record${T===1?``:`s`} have no location.`]});let le=s==null?void 0:w.find(e=>e.pid===s),ue=_?CGe(_.x0,_.y0,_.x1,_.y1):null,de=`translate(${h.tx.toFixed(2)} ${h.ty.toFixed(2)}) scale(${h.k.toFixed(6)})`,fe=e=>o9(e,h.k),pe=pGe(h.k),me=rGe(iGe({x:s9/2,y:c9/2},h)),he=sGe(me.lat,me.lon,aGe(h.k)),ge=i.size===1?w.find(e=>i.has(e.pid)):void 0,_e=A&&!A.none&&A.max>A.min?[A.min,(A.min+A.max)/2,A.max]:null;return(0,B.jsxs)(`div`,{className:`cg-mapview`,children:[(0,B.jsxs)(`div`,{className:`cg-map-bar`,children:[(0,B.jsxs)(`span`,{className:`cg-cal-note cg-map-count`,children:[(0,B.jsx)(`strong`,{children:w.length.toLocaleString()}),` of`,` `,e.length.toLocaleString(),` mapped · pinned at each customer's address`]}),T>0&&(0,B.jsxs)(`span`,{className:`cg-cal-nodate`,title:`${T.toLocaleString()} matching record${T===1?``:`s`} have no geocoded location and are not on the map. They remain in the Grid and List views.`,children:[T.toLocaleString(),` matching record`,T===1?` has`:`s have`,` no location`]}),ge&&(0,B.jsxs)(`span`,{className:`cg-map-go`,children:[(0,B.jsxs)(`a`,{href:sGe(ge.lat,ge.lon),target:`_blank`,rel:`noopener noreferrer`,title:`Open ${ge.title} in Google Maps at ${ge.lat.toFixed(5)}, ${ge.lon.toFixed(5)} (new tab)`,children:[ge.title||`Selected pin`,` in Google Maps`]}),(0,B.jsx)(`a`,{href:cGe(ge.lat,ge.lon),target:`_blank`,rel:`noopener noreferrer`,title:`Directions to ${ge.title} (new tab)`,children:`Directions`})]}),i.size>=2&&(0,B.jsxs)(`span`,{className:`cg-map-route`,children:[l?N&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`cg-map-route-sum`,children:[(0,B.jsx)(`strong`,{children:N.ordered.length.toLocaleString()}),` stops ·`,` `,Math.round(N.km).toLocaleString(),` km`,(0,B.jsx)(`span`,{className:`cg-map-route-note`,children:` straight-line, not driving distance`})]}),(0,B.jsxs)(`label`,{className:`cg-map-route-opt`,children:[`Start`,(0,B.jsx)(`select`,{className:`cg-map-route-start`,value:String(N.ordered[0].pid),onChange:e=>m(Number(e.target.value)),children:M.map(e=>(0,B.jsx)(`option`,{value:e.pid,children:e.title||`#${e.pid}`},e.pid))})]}),(0,B.jsxs)(`label`,{className:`cg-map-route-opt`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`Return to start`]}),N.link&&(0,B.jsxs)(`a`,{href:N.link.url,target:`_blank`,rel:`noopener noreferrer`,title:`Open this route in Google Maps for driving directions (new tab)`,children:[`Open route in Google Maps`,N.link.used{u(!1),m(null)},children:`Clear`})]}):(0,B.jsxs)(`button`,{type:`button`,className:`cg-map-route-go`,onClick:()=>u(!0),disabled:M.length<2,title:M.length<2?`At least two selected records need a location to plan a route`:`Order these stops into a route`,children:[`Plan route (`,M.length.toLocaleString(),` stops)`]}),ee>0&&(0,B.jsxs)(`span`,{className:`cg-cal-nodate`,children:[ee.toLocaleString(),` selected record`,ee===1?` has`:`s have`,` no location and cannot be routed`]})]}),(0,B.jsx)(`span`,{className:`cg-map-hint`,children:`Scroll to zoom · drag to pan · shift-drag to select`})]}),(0,B.jsxs)(`div`,{className:`cg-map-frame`,tabIndex:0,role:`group`,"aria-label":`Map canvas. Arrow keys pan, plus and minus zoom, zero fits to data.`,onKeyDown:ae,children:[(0,B.jsxs)(`svg`,{ref:b,viewBox:`0 0 ${s9} ${c9}`,preserveAspectRatio:`xMidYMid meet`,className:`cg-map-svg`+(_?` is-selecting`:``),role:`img`,"aria-label":`Map of ${w.length.toLocaleString()} customers`,onPointerDown:oe,onPointerMove:se,onPointerUp:ce,onPointerCancel:ce,children:[(0,B.jsx)(`rect`,{className:`cg-map-water`,x:0,y:0,width:s9,height:c9}),(0,B.jsxs)(`g`,{transform:de,children:[pe>.01&&(0,B.jsxs)(`g`,{className:`cg-map-grat`,strokeWidth:fe(.6),opacity:pe,children:[Array.from({length:17},(e,t)=>{let n=i9(0,-80+t*10).y;return(0,B.jsx)(`line`,{x1:0,y1:n,x2:4096,y2:n},`p${t}`)}),Array.from({length:19},(e,t)=>{let n=i9(-180+t*20,0).x;return(0,B.jsx)(`line`,{x1:n,y1:0,x2:n,y2:4096},`m${t}`)})]}),(0,B.jsx)(`path`,{className:`cg-map-land`,d:eGe,strokeWidth:fe(.9)}),tGe.map((e,t)=>(0,B.jsx)(`path`,{className:`cg-map-lake`,d:e,strokeWidth:fe(.8)},t)),N&&N.ordered.length>1&&(0,B.jsx)(`polyline`,{className:`cg-map-route-line`,strokeWidth:fe(1.8),strokeDasharray:dGe(5,4,h.k),points:N.ordered.map(e=>`${e.p.x},${e.p.y}`).join(` `)+(d?` ${N.ordered[0].p.x},${N.ordered[0].p.y}`:``)}),w.map(e=>{let t=te(e),n=i.has(e.pid),r=ne(e)/h.k;return(0,B.jsx)(`circle`,{className:`cg-map-pin`+(s===e.pid?` is-hover`:``)+(n?` is-selected`:``),cx:e.p.x,cy:e.p.y,r:s===e.pid?r*1.28:r,fill:t.fill,stroke:n?`#202433`:t.line,strokeWidth:fe(n?2:1),role:`button`,tabIndex:0,"aria-label":`Open ${e.title}`,onMouseEnter:()=>c(e.pid),onMouseLeave:()=>c(t=>t===e.pid?null:t),onFocus:()=>c(e.pid),onBlur:()=>c(t=>t===e.pid?null:t),onClick:()=>{S.current||o(e.pid)},onKeyDown:t=>{t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),o(e.pid))},children:(0,B.jsx)(`title`,{children:e.title})},e.pid)})]}),N&&N.ordered.map((e,t)=>{let n=a9(e.p,h);return(0,B.jsxs)(`g`,{className:`cg-map-stopno`,transform:`translate(${n.x.toFixed(2)} ${(n.y-13).toFixed(2)})`,children:[(0,B.jsx)(`circle`,{r:7.5}),(0,B.jsx)(`text`,{textAnchor:`middle`,dy:`3.4`,children:t+1})]},e.pid)}),le&&(()=>{let e=a9(le.p,h),t=[];n&&t.push(`${n.label}: ${yp(n,le.colorVal)||`—`}`),r&&t.push(`${r.label}: ${yp(r,le.sizeVal)||`—`}`);let i=le.title||`(untitled)`,a=Math.max(i.length,...t.map(e=>e.length))*6.2+20,o=21+t.length*14,s=mGe(e.x,e.y,a,o,s9,c9);return(0,B.jsxs)(`g`,{className:`cg-map-card`,"aria-hidden":`true`,children:[(0,B.jsx)(`rect`,{x:s.x,y:s.y,width:a,height:o,rx:5}),(0,B.jsx)(`text`,{className:`cg-map-card-t`,x:s.x+10,y:s.y+15,children:i}),t.map((e,t)=>(0,B.jsx)(`text`,{className:`cg-map-card-l`,x:s.x+10,y:s.y+15+14*(t+1),children:e},t))]})})(),ue&&(0,B.jsx)(`rect`,{className:`cg-map-marquee`,x:ue.x0,y:ue.y0,width:ue.x1-ue.x0,height:ue.y1-ue.y0})]}),(0,B.jsxs)(`div`,{className:`cg-map-ctl`,role:`group`,"aria-label":`Map camera`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-map-ctl-b`,title:h.k>=O*.999999999?`Zoom in — at the limit. The basemap's detail ends here; use Open in Google Maps for street level.`:`Zoom in (+)`,"aria-label":`Zoom in`,disabled:h.k>=O*.999999999,onClick:()=>re(1.6),children:(0,B.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M8 3.6v8.8M3.6 8h8.8`})})}),(0,B.jsx)(`button`,{type:`button`,className:`cg-map-ctl-b`,title:`Zoom out (−)`,"aria-label":`Zoom out`,disabled:h.k<=D*1.000000001,onClick:()=>re(1/1.6),children:(0,B.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M3.6 8h8.8`})})}),(0,B.jsx)(`button`,{type:`button`,className:`cg-map-ctl-b`,title:`Fit to data (0)`,"aria-label":`Fit to data`,onClick:F,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M2.6 5.8V2.6h3.2M10.2 2.6h3.2v3.2M13.4 10.2v3.2h-3.2M5.8 13.4H2.6v-3.2`}),(0,B.jsx)(`path`,{d:`M6.6 8h2.8M8 6.6v2.8`})]})}),(0,B.jsx)(`a`,{className:`cg-map-ctl-b`,href:he,target:`_blank`,rel:`noopener noreferrer`,title:`Open this area in Google Maps (new tab)`,"aria-label":`Open this area in Google Maps`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M7 3.8H4.3a.9.9 0 0 0-.9.9v6.9a.9.9 0 0 0 .9.9h6.9a.9.9 0 0 0 .9-.9V9.2`}),(0,B.jsx)(`path`,{d:`M8.6 3.4h4v4M12.6 3.4 7.4 8.6`})]})})]}),(k||_e)&&(0,B.jsxs)(`div`,{className:`cg-map-legends`,children:[n&&k&&(0,B.jsxs)(`div`,{className:`cg-map-legend`,children:[(0,B.jsx)(`div`,{className:`cg-map-legend-t`,children:n.label}),k.order.slice(0,l9.length+1).map(e=>{let t=e===``?u9:k.swatch.get(e)??u9;return(0,B.jsxs)(`div`,{className:`cg-map-legend-row`,children:[(0,B.jsx)(`span`,{className:`cg-map-swatch`,style:{background:t.fill,borderColor:t.line}}),(0,B.jsx)(`span`,{className:`cg-map-legend-k`,children:e===``?`(blank)`:e}),(0,B.jsx)(`span`,{className:`cg-map-legend-n`,children:(k.counts.get(e)??0).toLocaleString()})]},e||`(blank)`)}),k.overflow>0&&(0,B.jsxs)(`div`,{className:`cg-map-legend-note`,children:[k.overflow.toLocaleString(),` further value`,k.overflow===1?` is`:`s are`,` drawn grey — the palette holds `,l9.length,` colours and reusing one would make two values look like the same value.`]})]}),r&&A&&(0,B.jsxs)(`div`,{className:`cg-map-legend`,children:[(0,B.jsx)(`div`,{className:`cg-map-legend-t`,children:r.label}),_e?(0,B.jsx)(`div`,{className:`cg-map-sizerow`,children:_e.map((e,t)=>(0,B.jsxs)(`span`,{className:`cg-map-sizeitem`,children:[(0,B.jsx)(`svg`,{width:32,height:32,"aria-hidden":!0,children:(0,B.jsx)(`circle`,{cx:16,cy:16,r:wGe(e,A.min,A.max,TGe,EGe,OGe),fill:d9.fill,stroke:d9.line})}),(0,B.jsx)(`span`,{className:`cg-map-legend-k`,children:yp(r,e)})]},t))}):(0,B.jsxs)(`div`,{className:`cg-map-legend-note`,children:[`Every mapped record has the same `,r.label.toLowerCase(),`, so the bubbles cannot differ in size.`]}),A.missing>0&&(0,B.jsxs)(`div`,{className:`cg-map-legend-note`,children:[A.missing.toLocaleString(),` mapped record`,A.missing===1?` has`:`s have`,` no value — drawn at the smallest dot, never removed from the map.`]})]})]})]})]})}function MGe(e,t){let n=e.trim().toLowerCase();return t.find(e=>e.trim().toLowerCase()===n)}function NGe(e){let t=e.trim().replace(/[$,%\s]/g,``);if(t===``)return``;let n=Number(t);return Number.isFinite(n)?String(n):void 0}function PGe(e,t,n=nd(e)){let r=t.replace(/\r/g,``),i=r.trim();switch(e.type){case`formula`:case`created_time`:case`status`:return;case`checkbox`:{if(i===``)return``;let e=i.toLowerCase();return[`1`,`true`,`yes`,`y`,`on`,`checked`,`x`].includes(e)?`1`:[`0`,`false`,`no`,`n`,`off`,`unchecked`].includes(e)?``:void 0}case`int`:case`currency`:case`pct`:return NGe(r);case`rating`:{if(i===``)return``;let t=Number(i);return Number.isInteger(t)&&t>=1&&t<=rd(e)?String(t):void 0}case`select`:case`user`:return i===``?``:MGe(i,n);case`multiselect`:{if(i===``)return``;let e=[],t=new Set;for(let i of r.split(/[,\n]/)){if(!i.trim())continue;let r=MGe(i,n);if(!r)return;let a=r.toLowerCase();t.has(a)||(t.add(a),e.push(r))}return e.length?e.join(`,`):``}case`date`:return i===``||!Number.isNaN(Date.parse(i))?i:void 0;default:return r}}function FGe(e){return e.length>0&&e.every(e=>e.length===1)}var f9={fieldKey:null,armedUntil:0};function IGe(e,t){return{fieldKey:e,armedUntil:t+1e3}}function LGe(e,t){return t<=e.armedUntil?{...e,armedUntil:0}:f9}function RGe(e,t,n){return e<=0?0:!t||t.width!==1||t.x!==n.col||t.y!==n.row?e:Math.max(e,t.height)}function zGe({field:e,sourceFieldKey:t,editable:n,values:r,targetPids:i,allowedChoices:a}){if(!n||!FGe(r)||t&&t!==e.key||i.lengthe==null))return null;let o=[];for(let t=0;te.trim()).filter(e=>e!==``)}function eKe(e,t){for(let n of e)if(yd(n)){if(eKe(n.children,t))return!0}else if(n.colId===t)return!0;return!1}function tKe(e,t){let n=[];for(let r of e)if(yd(r)){let e=tKe(r.children,t);e.length&&n.push({...r,children:e})}else r.colId!==t&&n.push(r);return n}function y9(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``).slice(0,28)||`field`}function nKe(e,t,n,r){let i=`custom_${y9(e)}_${Math.random().toString(36).slice(2,7)}`;return t===`formula`||t===`created_time`?{key:i,label:e,type:t,source:`odoo`,derived:!0,filterable:!0,default:!0,custom:!0,...t===`formula`?{agg:`sum`,...r?.formula?{formula:r.formula}:{}}:{}}:{key:i,label:e,type:t,source:`overlay`,default:!0,custom:!0,agg:[`currency`,`int`].includes(t)?`sum`:void 0,...(t===`select`||t===`multiselect`)&&n?.length?{options:n}:{},...t===`select`||t===`multiselect`?{colorCodeOptions:r?.colorCodeOptions!==!1,...r?.optionColors&&Object.keys(r.optionColors).length?{optionColors:r.optionColors}:{}}:{},...t===`multiselect`?{multi:!0}:{},...t===`rating`?{max:r?.max??5}:{}}}function rKe({scope:e=`customer`}={}){let t=Sd(e),{fields:n,rawRows:r,payload:i,loading:a,overlayEdits:o,setOverlayEdits:s,patchOverlay:c}=dte(e),[l,u]=(0,L.useState)([]),[d,f]=(0,L.useState)([]),[p,m]=(0,L.useState)(m9),[h,g]=(0,L.useState)(()=>Hf([])),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(`saved`),[x,S]=(0,L.useState)(``),[C,w]=(0,L.useState)(new Set),[T,E]=(0,L.useState)(void 0),[D,O]=(0,L.useState)(null),[k,A]=(0,L.useState)(null),[j,M]=(0,L.useState)(null),[ee,N]=(0,L.useState)(null),te=(0,L.useCallback)(()=>{N(null),requestAnimationFrame(()=>Ee.current?.focus())},[]),[ne,P]=(0,L.useState)(!1),[re,F]=(0,L.useState)(``),ie=(0,L.useRef)(null),[ae,oe]=(0,L.useState)(null),[se,ce]=(0,L.useState)(!1),[le,ue]=(0,L.useState)(``),[de,fe]=(0,L.useState)(new Set),pe=(0,L.useRef)(null),[me,he]=(0,L.useState)(null),[ge,_e]=(0,L.useState)(null),ve=(0,L.useRef)({edited:{},deleted:{}}),[ye,be]=(0,L.useState)(null),[xe,Se]=(0,L.useState)(null),Ce=(0,L.useRef)({}),we=(0,L.useRef)(null),Te=(0,L.useRef)(null),Ee=(0,L.useRef)(null),De=(0,L.useRef)(null),Oe=(0,L.useRef)(f9);(0,L.useEffect)(()=>{let e=()=>{Oe.current=LGe(Oe.current,Date.now())},t=()=>{Oe.current=f9};return document.addEventListener(`copy`,e,!0),window.addEventListener(`blur`,t),()=>{document.removeEventListener(`copy`,e,!0),window.removeEventListener(`blur`,t)}},[]);let[ke,Ae]=(0,L.useState)({width:800,height:600}),je=i?.workspace?.storageKey??`customer-grid-standalone`;(0,L.useEffect)(()=>{if(!i||n.length===0||we.current===je)return;let e=XGe(je),t=uf(e?.fieldStamps,Date.now());ve.current={edited:{...t.edited??{}},deleted:{...t.deleted??{}}};let r=ste(n,e?.fields??[],t,Date.now(),i.workspace!=null),a=i.workspace?.views??[],o=new Map;o.set(m9,YGe(r));for(let t of e?.views??[])o.set(t.id,t);let s=new Map;for(let t of a){let n=ote(t,o.get(t.id),e?.savedAt,Date.now()),r=ate(n,t,e?.reemitted?.[t.id]);r!==null&&s.set(t.id,r),o.set(t.id,n)}let c=[...o.values()].map(e=>({...e,config:v9(e.config,r)})),l=e?.activeViewId??i.workspace?.activeViewId??m9,d=c.find(e=>e.id===l)??c[0];if(u(r),f(c),m(d.id),g(d.config),v(!0),we.current=je,s.size>0){let t={...e?.reemitted??{}};for(let e of c){let n=s.get(e.id);n!==void 0&&(Jd({id:Yd(`view`),type:`view_upsert`,view:e}),t[e.id]=n)}Ce.current=t}else Ce.current={...e?.reemitted??{}}},[i,n,je]),(0,L.useEffect)(()=>{_&&ZGe(je,{fields:l,views:d,activeViewId:p,savedAt:Date.now(),fieldStamps:uf(ve.current,Date.now()),reemitted:Ce.current})},[_,je,l,d,p]);let Me=(0,L.useCallback)(e=>{let t=uf(ve.current,Date.now());ve.current={edited:{...t.edited??{},[e]:Date.now()},deleted:{...t.deleted??{}}}},[]),Ne=(0,L.useCallback)(e=>{let t=uf(ve.current,Date.now()),n={...t.edited??{}};delete n[e],ve.current={edited:n,deleted:{...t.deleted??{},[e]:Date.now()}}},[]),Pe=(0,L.useCallback)(e=>{e.groupBy!==h.groupBy&&w(new Set),g(e)},[h.groupBy]),{visibleCols:Fe,fieldByKey:Ie,order:Le,visible:Re,lockedKey:ze,onColumnResize:Be,onColumnMoved:Ve,onColumnProposeMove:He,setColumnVisible:Ue,insertColumn:We}=sne(l,h,Pe);(0,L.useEffect)(()=>{if(!_)return;let e=d.find(e=>e.id===p);if(!e||_9(e.config,h)){b(`saved`);return}return b(`saving`),Te.current!==null&&window.clearTimeout(Te.current),Te.current=window.setTimeout(()=>{let t={...e,config:h};f(e=>e.map(e=>e.id===t.id?t:e)),Jd({id:Yd(`view`),type:`view_upsert`,view:t}),b(`saved`),Te.current=null},420),()=>{Te.current!==null&&window.clearTimeout(Te.current)}},[_,p,h,d]),(0,L.useLayoutEffect)(()=>{let e=De.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();t.width>0&&t.height>0&&Ae({width:Math.floor(t.width),height:Math.floor(t.height)})};t();let n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[_]);let Ge=Hee(i?.counts)===`server-windowed`,Ke=i?.workspace?.hideViews===!0,qe=od(h.display),Je=Ge?`grid`:qe?.mode??`grid`,Ye=(0,L.useMemo)(()=>i?.measures??[],[i?.measures]),Xe=(0,L.useRef)({}),Ze=(0,L.useMemo)(()=>{let e=i?.measureSets;if(e){let t={};for(let[n,r]of Object.entries(e))t[n]=new Set(r);Xe.current=t}return Xe.current},[i?.measureSets]),Qe=(0,L.useMemo)(()=>Zf(h.filters,Ze),[h.filters,Ze]),$e=(0,L.useMemo)(()=>Qf(h.filters).join(`,`),[h.filters]),et=(0,L.useMemo)(()=>Object.keys(Ze).join(`,`),[Ze]),tt=(0,L.useMemo)(()=>i?.workspace?.lists??[],[i?.workspace?.lists]),nt=(0,L.useMemo)(()=>{let e={};for(let t of tt)t.pids&&(e[t.id]=new Set(t.pids));return e},[tt]),rt=i?.today,it=i?.viewer,at=(0,L.useCallback)(e=>See(e,it),[it]),ot=(0,L.useMemo)(()=>$f(h.filters,{cohortSets:nt,today:rt}),[h.filters,nt,rt]),st=(0,L.useMemo)(()=>{let e=new Map;for(let t of l){if(t.type!==`formula`)continue;let n=hee(t);n&&e.set(t.key,n)}let{order:t,cyclic:n}=rWe(e),r=[];for(let i of t){if(n.has(i))continue;let t=T7(e.get(i));t.ok&&r.push({key:i,ast:t.ast})}return r},[l]),ct=(0,L.useMemo)(()=>l.filter(e=>e.type===`created_time`).map(e=>e.key),[l]),lt=(0,L.useMemo)(()=>{if(st.length===0&&ct.length===0)return r;let e={today:i?.today};return r.map(t=>{let n=o[t.pid],r=n?{...t,...n}:{...t},i={...t};for(let e of ct)i[e]=t._created??null,r[e]=i[e];for(let{key:t,ast:n}of st){let a=nWe(n,e=>r[e],e);i[t]=a,r[t]=a}return i})},[r,o,st,ct,i?.today]),ut=i?.workspace?.cohortMode===!0;(0,L.useEffect)(()=>{ut&&(ae&&tt.some(e=>e.id===ae)||oe(tt[0]?.id??null))},[ut,tt,ae]);let dt=ut?tt.find(e=>e.id===ae)??null:null,ft=(0,L.useMemo)(()=>new Set(dt?.pids??[]),[dt]),{visibleRows:pt,pidToIndex:mt}=Ene((0,L.useMemo)(()=>ut?lt.filter(e=>ft.has(e.pid)):lt,[ut,lt,ft]),l,h.filters,x,h.sorts,Ge?null:h.groupBy,C,h.memberPids,h.filterConj,Ge,Ze,nt,rt,h.cohortLock),[ht,gt]=(0,L.useState)(qGe),_t=pt.length>ht,vt=(0,L.useMemo)(()=>_t?pt.slice(0,ht):pt,[_t,pt,ht]),yt=(0,L.useMemo)(()=>{if(!_t)return mt;let e=new Map;return vt.forEach((t,n)=>{t.kind===`data`&&!e.has(t.record.pid)&&e.set(t.record.pid,n)}),e},[_t,vt,mt]),[bt,xt]=(0,L.useState)(0);(0,L.useEffect)(()=>(Sp(()=>xt(e=>e+1)),()=>Sp(void 0)),[]);let St=i?.workspace?.userAvatars,Ct=(0,L.useMemo)(()=>{if(!h.groupBy)return null;let e=Math.min(VGe(h),Fe.length),t=0;for(let n=0;n{let e=new Set;for(let t of l)t.editRequestId&&t.key.startsWith(`measure_`)&&e.add(t.key);return e},[l]),[Tt,Et]=(0,L.useState)(0),[Dt,Ot]=(0,L.useState)(!1);(0,L.useEffect)(()=>{if(Ot(!1),wt.size===0)return;let e=0,t=window.setInterval(()=>{if(e+=1,e>UGe){window.clearInterval(t),Ot(!0);return}Et(e=>e+1)},HGe);return()=>window.clearInterval(t)},[wt]);let kt=Une(vt,Fe,Ie,o,at,St,bt,Ct,KGe,Dt?WGe:wt,Tt),{gridSelection:At,selectedPids:jt,onGridSelectionChange:Mt,selectPids:Nt,togglePid:Pt,setActiveCell:Ft,clearSelection:It}=Wne(vt,yt,Fe.length),Lt=(0,L.useMemo)(()=>Le.map(e=>Ie.get(e)).filter(e=>!!e),[Le,Ie]),Rt=At.current?.cell[1],zt=(0,L.useMemo)(()=>{let e={};for(let t of l){if(t.type===`select`||t.type===`multiselect`){e[t.key]=nd(t);continue}if(t.type===`user`){e[t.key]=i?.userOptions??[];continue}t.type===`status`&&(e[t.key]=[...new Set(r.map(e=>e[t.key]).filter(e=>e!=null&&e!==``).map(String))].sort())}return e},[l,r,i?.userOptions]),Bt=BGe[h.rowHeightMode],Vt=mt.size,Ht=yt.size,Ut=(0,L.useCallback)(e=>{let t=vt[e];if(!(!t||t.kind!==`data`))return e===T?h.colorBy?Tte[String(t.record[h.colorBy]??``).toLowerCase()]??Dte:Dte:h.colorBy?wte[String(t.record[h.colorBy]??``).toLowerCase()]:e===Rt?Ote:void 0},[vt,h.colorBy,T,Rt]),Wt=(0,L.useCallback)(e=>{let t=e.kind===`cell`?e.location[1]:void 0;E(e=>e===t?e:t);let n=t===void 0?void 0:vt[t];if(e.kind===`cell`&&n?.kind===`data`&&t!==void 0){let e=n.record.pid,r=Ee.current?.getBounds(0,t),i=r?Zte(r,De.current?.getBoundingClientRect()):null;O(t=>i?t&&t.pid===e&&t.x===i.x&&t.y===i.y?t:{pid:e,x:i.x,y:i.y,size:i.size}:null)}if(e.kind===`header`){let t=Fe[e.location[0]],n=t?Ie.get(t.id):void 0,r=n?n.note||n.description:void 0,i=n&&t&&t.title!==n.label&&n?r?`${n.label} — ${r}`:n.label:r,a=e.bounds;if(i&&a){be(e=>e&&e.text===i&&e.x===a.x?e:{text:i,x:a.x,y:a.y+a.height+4});return}}if(be(e=>e===null?e:null),e.kind===`cell`&&t!==void 0){let n=vt[t],r=Fe[e.location[0]];if(n?.kind===`data`&&r){let t=Ie.get(r.id),i=t?yp(t,n.record[t.key]):``,a=e.bounds,o=a?Ute(i,GGe(i),a.width):null;if(o&&a){let e=Wte(a.x,window.innerWidth,GGe(o)+20),t=a.y+a.height+4;Se(n=>n&&n.text===o&&n.x===e&&n.y===t?n:{text:o,x:e,y:t});return}}}Se(e=>e===null?e:null)},[Fe,Ie,vt]),Gt=(0,L.useMemo)(()=>h.groupBy?e=>vt[e]?.kind===`group-header`?32:Bt:Bt,[h.groupBy,Bt,vt]),Kt=Je===`calendar`||Je===`kanban`||Je===`map`,qt=Kt?pt:vt,Jt=k===null?void 0:(Kt?mt:yt).get(k);(0,L.useEffect)(()=>{k!==null&&Jt===void 0&&A(null)},[k,Jt]);let Yt=(0,L.useMemo)(()=>{if(Jt===void 0)return null;let e=qt[Jt];return!e||e.kind!==`data`?null:o[e.record.pid]?{...e.record,...o[e.record.pid]}:e.record},[Jt,qt,o]),Xt=(0,L.useMemo)(()=>Jt===void 0?0:qt.slice(0,Jt+1).filter(e=>e.kind===`data`).length,[Jt,qt]),Zt=(0,L.useCallback)(e=>{if(Jt===void 0)return!1;for(let t=Jt+e;t>=0&&t{if(Jt!==void 0)for(let t=Jt+e;t>=0&&t{let n=e.column.id?Ie.get(e.column.id):void 0;if(e.ctx.font=`${e.theme.headerFontStyle} ${e.theme.fontFamily}`,t(),!n)return;let r=!!(n.note||n.description),i=n.source===`overlay`,a=qte(e.rect,e.menuBounds.width,Jte(r,i));if(!a)return;let o=0;if(r){let t=a[o++];e.spriteManager.drawSprite(`aiosInfo`,`normal`,e.ctx,t.x,t.y,t.size,e.theme)}if(i){let t=a[o++],n=e.ctx;n.save(),n.beginPath(),n.arc(t.x+t.size/2,t.y+t.size/2,t.size/2,0,Math.PI*2),n.fillStyle=Ate,n.fill(),n.restore()}},[Ie]),en=(0,L.useCallback)((e,t)=>{let n=vt[e[1]];if(!n)return;if(Hd(Vd),n.kind===`group-header`){t.preventDefault(),w(e=>{let t=new Set(e);return t.has(n.groupKey)?t.delete(n.groupKey):t.add(n.groupKey),t});return}let r=Fe[e[0]],i=r?Ie.get(r.id):void 0;if(n.kind===`data`&&i&&at(i)&&(ed(i.type)||i.type===`rating`)){t.preventDefault(),Ft(e[0],e[1]);let r=t.bounds;N({pid:n.record.pid,fieldKey:i.key,anchor:{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height,width:r.width,height:r.height}});return}if(n.kind===`data`&&i?.type===`url`){let e=String(o[n.record.pid]?.[i.key]??n.record[i.key]??``).trim();if(e){let n=/^https?:\/\//i.test(e)?e:/^[\w-]+(\.[\w-]+)+/.test(e)?`https://${e}`:null;if(n){t.preventDefault(),window.open(n,`_blank`,`noopener`);return}}}n.kind===`data`&&i&&i.key===ze&&Pt(n.record.pid)},[vt,Fe,Ie,at,o,ze,Pt,Ft]),tn=(0,L.useCallback)(e=>{let t=vt[e[1]],n=Fe[e[0]],r=n?Ie.get(n.id):void 0;t?.kind===`data`&&r?.source!==`overlay`&&A(t.record.pid)},[vt,Fe,Ie]),nn=(0,L.useCallback)((e,t)=>{let n=vt[e[1]],r=Fe[e[0]],i=r?Ie.get(r.id):void 0;if(!(!n||n.kind!==`data`||!i||!at(i))){if(t.kind===I.Boolean&&i.type===`checkbox`){c(n.record.pid,{[i.key]:t.data?`1`:``});return}if(t.kind===I.Uri){c(n.record.pid,{[i.key]:t.data??``});return}(t.kind===I.Text||t.kind===I.Number)&&c(n.record.pid,{[i.key]:t.data})}},[vt,Fe,Ie,c,at]),rn=(0,L.useCallback)(e=>{let t=vt[e[1]],n=Fe[e[0]],r=n?Ie.get(n.id):void 0;return!!t&&t.kind===`data`&&!!r&&at(r)&&!ed(r.type)&&r.type!==`rating`&&r.type!==`status`},[vt,Fe,Ie,at]),an=(0,L.useCallback)((e,t)=>{let n=Fe[e[0]],r=n?Ie.get(n.id):void 0;if(!r)return!1;let i=RGe(t.length,At.current?.range,{col:e[0],row:e[1]}),a=Array.from({length:i},(t,n)=>{let r=vt[e[1]+n];return r?.kind===`data`?r.record.pid:null}),o=zGe({field:r,sourceFieldKey:Oe.current.fieldKey,editable:at(r),values:t,targetPids:a,allowedChoices:zt[r.key]??nd(r)});if(!o)return!1;for(let e of o)c(e.pid,{[r.key]:e.value});return!1},[Fe,Ie,at,zt,vt,c,At.current]),R=(0,L.useCallback)((e,t)=>{let n=Fe[e];n?.id&&M({fieldKey:n.id,anchor:{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height,width:t.width,height:t.height}})},[Fe]),on=(0,L.useCallback)((e,t)=>{t.isEdge||(t.preventDefault(),R(e,t.bounds))},[R]),sn=(0,L.useCallback)(e=>{if(e.key.toLowerCase()===`c`&&(e.ctrlKey||e.metaKey)&&!e.altKey){let e=At.current?.range,t=e?.width===1?Fe[e.x]:void 0;Oe.current=IGe(t?.id??null,Date.now());return}if(e.key===`Enter`&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=At.current?.cell;if(t){e.preventDefault(),e.stopPropagation(),e.cancel();let n=vt[t[1]],r=Fe[t[0]],i=r?Ie.get(r.id):void 0;if(!e.shiftKey&&n?.kind===`data`&&i&&at(i)&&(ed(i.type)||i.type===`rating`)){let e=Ee.current?.getBounds(t[0],t[1]);if(e){N({pid:n.record.pid,fieldKey:i.key,anchor:{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height,width:e.width,height:e.height}});return}}let a=e.shiftKey?-1:1,o=t[1]+a;for(;o>=0&&o=0&&o0?e.location[0]-1:void 0,r=At.current?.cell[0]??n;if(!t||r===void 0||!e.bounds)return;let i=De.current?.getBoundingClientRect()?.top??e.bounds.y;e.preventDefault(),e.stopPropagation(),e.cancel(),R(r,{x:e.bounds.x,y:i,width:e.bounds.width,height:36})},[At.current,R,vt,Ft,Fe,Ie,at]),cn=(0,L.useCallback)(e=>{f(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]),Jd({id:Yd(`view`),type:`view_upsert`,view:e})},[]),ln=(0,L.useCallback)((e,t)=>{let n=d.find(t=>t.id===e);if(!n)return;let r={...n.config};t?r.cohortLock=t:delete r.cohortLock,cn({...n,config:r}),e===p&&g(e=>{let n={...e};return t?n.cohortLock=t:delete n.cohortLock,n})},[d,p,cn]),un=(0,L.useCallback)(e=>{let t=d.find(e=>e.id===p);t&&!_9(t.config,h)&&cn({...t,config:h});let n=d.find(t=>t.id===e);n&&(m(e),g(v9(n.config,l)),w(new Set),S(``),A(null),gt(qGe),Jd({id:Yd(`view`),type:`view_select`,viewId:e}),Hd(Vd))},[d,p,h,cn,l]),dn=(0,L.useCallback)((e,t,n)=>{let r=td(e,d.map(e=>e.name)),i={...h,display:od({...h.display??{},mode:t})},a={id:QGe(),name:r,kind:`custom`,config:i,permissions:n};cn(a),m(a.id),g(i),b(`saved`)},[h,cn,d]),fn=(0,L.useCallback)((e,t)=>{let n=d.find(t=>t.id===e);if(n){let r=td(t,d.filter(t=>t.id!==e).map(e=>e.name));cn({...n,name:r})}},[d,cn]),pn=(0,L.useCallback)((e,t)=>{let n=d.find(t=>t.id===e);!n||!Ed(n,it)||cn({...n,locked:t})},[d,cn,it]),z=(0,L.useCallback)((e,t)=>{let n=d.find(t=>t.id===e);n&&cn({...n,note:t.slice(0,2e3)})},[d,cn]),mn=(0,L.useCallback)(e=>{let t=d.find(t=>t.id===e);if(!t)return;let n={...t,id:QGe(),name:td(`${t.name} copy`,d.map(e=>e.name)),kind:`custom`,locked:!1,permissions:{edit:`personal`},createdBy:void 0,config:{...t.config}};cn(n),m(n.id),g(n.config)},[d,cn]),hn=(0,L.useCallback)(e=>{let t=d.find(t=>t.id===e);if(!(!t||Cd(t)||!Od(t,it))&&(f(t=>t.filter(t=>t.id!==e)),Jd({id:Yd(`view-delete`),type:`view_delete`,viewId:e}),p===e)){let e=d.find(e=>e.id===m9)??YGe(l);m(e.id),g(e.config)}},[d,p,l,it]);(0,L.useEffect)(()=>{if(!ut||!_||!ae)return;let e=`cohort:${ae}`;if(p===e)return;let t=d.find(e=>e.id===p);t&&!_9(t.config,h)&&cn({...t,config:h});let n=d.find(t=>t.id===e),r=n??{id:e,name:tt.find(e=>e.id===ae)?.name??`Cohort`,kind:`custom`,config:Hf(l)};n||f(e=>[...e,r]),m(e),g(v9(r.config,l)),w(new Set),S(``)},[ut,_,ae,p,d,h,l,tt,cn]);let gn=(0,L.useCallback)((e,t,n)=>{if(Ge)return;let r=d.find(t=>t.id===e);if(!r||Zf(r.config.filters,Ze)>0)return;let{visibleRows:i}=tp({rawRows:lt,fields:l,filters:r.config.filters,search:``,sorts:r.config.sorts,groupBy:null,collapsed:new Set,memberPids:r.config.memberPids,filterConj:r.config.filterConj??`and`,measureSets:Ze,cohortSets:nt,today:rt}),a=i.filter(e=>e.kind===`data`).map(e=>e.record.pid);Jd({id:Yd(`addlist`),type:`add_to_list`,viewId:e,cohortId:t,name:n,pids:a})},[d,lt,l,Ge,Ze,nt,rt]),[_n,vn]=(0,L.useState)({}),[yn,bn]=(0,L.useState)([]),xn=i?.workspace?.folders,Sn=(0,L.useMemo)(()=>BUe(xn,yn,_n,Date.now()),[xn,yn,_n]),Cn=(0,L.useCallback)(e=>VUe(e,d.find(t=>t.id===e)?.folderId??null,Sn,_n,Date.now()),[d,Sn,_n]),wn=(0,L.useCallback)(e=>{vn(t=>zUe(e(t),Date.now()))},[]),Tn=(0,L.useCallback)(e=>{let t=new Set,n=[],r=0;for(let i of d){if(Cn(i.id)!==e)continue;if(Ge){n.push({name:i.name,why:`this table loads one page at a time`});continue}if(Zf(i.config.filters,Ze)>0){n.push({name:i.name,why:`a metric condition has no answer yet`});continue}r+=1;let{visibleRows:a}=tp({rawRows:lt,fields:l,filters:i.config.filters,search:``,sorts:i.config.sorts,groupBy:null,collapsed:new Set,memberPids:i.config.memberPids,filterConj:i.config.filterConj??`and`,measureSets:Ze,cohortSets:nt,today:rt});for(let e of a)e.kind===`data`&&t.add(e.record.pid)}return{pids:[...t],counted:r,skipped:n}},[d,Cn,Ge,lt,l,Ze,nt,rt]),En=(0,L.useCallback)((e,t,n)=>{let{pids:r}=Tn(e);r.length&&Jd({id:Yd(`addlist`),type:`add_to_list`,viewId:``,cohortId:t,name:n,pids:r})},[Tn]),Dn=(0,L.useCallback)((e,t,n,r)=>{if(Ge||Zf(t.filters,Ze)>0)return;let{visibleRows:i}=tp({rawRows:n,fields:l,filters:t.filters,search:``,sorts:t.sorts,groupBy:null,collapsed:new Set,memberPids:t.memberPids,filterConj:t.filterConj??`and`,measureSets:Ze,cohortSets:nt,today:rt}),a=i.filter(e=>e.kind===`data`).map(e=>o[e.record.pid]?{...e.record,...o[e.record.pid]}:e.record),s=new Set(t.order),c=[...t.order,...l.map(e=>e.key).filter(e=>!s.has(e))],u=new Set(t.visible),d=c.filter(e=>u.has(e)).map(e=>Ie.get(e)).filter(e=>!!e);S7(r,e,rt,d,a)},[Ge,l,Ie,Ze,nt,rt,o]),On=(0,L.useRef)(null),kn=(0,L.useCallback)(e=>{On.current=e},[]),An=(0,L.useRef)(null),jn=(0,L.useCallback)(e=>{An.current=e},[]),Mn=(0,L.useCallback)((e,t)=>{let n=d.find(t=>t.id===e);if(!n)return;let r=v9(n.config,l),i=od(r.display),a=e===p,o=e=>Hd(Rd,`Open "${n.name}" first: ${e} is exported from what it draws on screen.`);if(i?.mode===`timeseries`){let e=a?On.current:null;if(!e)return o(`a time series`);if(e.empty){Hd(Rd,`"${n.name}" has no metrics on its sheet yet — add one, then export.`);return}if(t===`csv`)x7(EUe(n.name,rt,t),new Blob([``+oie(e)],{type:`text/csv;charset=utf-8`}));else{let{fields:r,rows:i}=sie(e);S7(t,n.name,rt,r,i)}return}if(i?.mode===`calendar`&&i.calendarMode===`summary`){let e=a?An.current:null;if(!e)return o(`a calendar summary`);S7(t,n.name,rt,e.fields,e.rows);return}Dn(n.name,r,lt,t)},[d,l,lt,Dn,p,rt]),Nn=(0,L.useCallback)((e,t)=>{let n=[...jt];!n.length||Ge||(Jd({id:Yd(`addlist`),type:`add_to_list`,viewId:p,cohortId:e,name:t,pids:n}),P(!1),F(``),It())},[jt,Ge,p,It]),Pn=i?.workspace?.scopeChoice===!0,Fn=h.cohortLock,In=(0,L.useMemo)(()=>{let e=Fn;if(!e)return;let t=tt.find(t=>t.id===e);return t?{name:t.name,count:t.pids?.length??0}:{}},[Fn,tt]),Ln=i?.workspace?.recordLayout?.order,Rn=(0,L.useCallback)(e=>{Jd({id:Yd(`rlayout`),type:`record_layout`,order:e})},[]),zn=(0,L.useCallback)((e,t)=>{let n=Yd(`field`),r={...e,label:td(e.label,l.filter(t=>t.key!==e.key).map(e=>e.label)),editRequestId:n};delete r.labelCorrectedFrom,delete r.labelCorrectionId,Me(r.key),u(e=>e.some(e=>e.key===r.key)?e.map(e=>e.key===r.key?r:e):[...e,r]),Jd({id:n,type:`field_upsert`,field:r,...t?{scope:t}:{}})},[Me,l]),Bn=(0,L.useCallback)((e,t,n,r,i,a,o)=>{let s=Pn?o?.scope:void 0,c=s===`cohort`?{scope:`cohort`}:{};if(a){let i={key:`measure_${y9(e)}_${Math.random().toString(36).slice(2,7)}`,label:e,type:t,source:`odoo`,default:!0,custom:!0,derived:!0,filterable:!1,agg:[`currency`,`int`].includes(t)?`sum`:void 0,measure:a,...c};zn(i,s),We(i.key,n,r);return}let l={...nKe(e,t,i,o),...c};zn(l,s),We(l.key,n,r)},[We,zn,Pn]),Vn=(0,L.useCallback)((e,t)=>{if(e===ze||e===t||!Ie.has(t))return;let n=Le.filter(e=>e!==t),r=n.indexOf(e);if(r<0)return;n.splice(r,0,t);let i=new Set(Re);i.delete(e),i.add(t),Pe({...h,order:n,visible:[...i]})},[h,Pe,Le,Re,Ie,ze]),Hn=(0,L.useCallback)(e=>{if(!Ie.get(e)?.custom||e===ze)return;u(t=>t.filter(t=>t.key!==e));let t={...h.widths??{}};delete t[e],Pe({...h,order:Le.filter(t=>t!==e),visible:[...Re].filter(t=>t!==e),widths:t,sorts:(h.sorts??[]).filter(t=>t.colId!==e),groupBy:h.groupBy===e?null:h.groupBy,colorBy:h.colorBy===e?null:h.colorBy}),Ne(e),Jd({id:Yd(`fielddel`),type:`field_delete`,key:e})},[h,Pe,Le,Re,Ie,ze,Ne]),Un=(0,L.useCallback)((e,t,n,r,i)=>{let a=Pn?i?.scope:void 0,o={...nKe(t,n,r,i),...a===`cohort`?{scope:`cohort`}:{}};zn(o,a),Vn(e,o.key)},[zn,Vn,Pn]),Wn=(0,L.useCallback)((e,t,n,r)=>{let i=Ie.get(e);if(!i?.custom||i.source!==`overlay`||t===`formula`||t===`created_time`)return;let a=e=>e===`int`||e===`currency`,o=i.format&&(a(i.type)&&a(t)||i.type===t),s={key:e,label:r?.label?.trim()||i.label,type:t,source:`overlay`,default:i.default,custom:!0,agg:[`currency`,`int`].includes(t)?`sum`:void 0,...i.note?{note:i.note}:{},...i.description?{description:i.description}:{},...i.scope?{scope:i.scope}:{},...i.createdBy?{createdBy:i.createdBy}:{},...i.permissions?{permissions:i.permissions}:{},...o?{format:i.format}:{},...(t===`select`||t===`multiselect`)&&n?.length?{options:n}:{},...t===`select`||t===`multiselect`?{colorCodeOptions:r?.colorCodeOptions!==!1,...r?.optionColors&&Object.keys(r.optionColors).length?{optionColors:r.optionColors}:{}}:{},...t===`multiselect`?{multi:!0}:{},...t===`rating`?{max:r?.max??5}:{}};zn(s)},[Ie,zn]),Gn=(0,L.useCallback)(e=>{let t=e.key.startsWith(`measure_`)?`measure_`:`custom_`,n=td(`${e.label} copy`,l.map(e=>e.label)),r=`${t}${y9(n)}_${Math.random().toString(36).slice(2,7)}`,i=Yd(`fielddup`),a={...e,key:r,label:n,editRequestId:i};delete a.createdBy,delete a.permissions,delete a.labelCorrectedFrom,delete a.labelCorrectionId,Me(r),u(e=>[...e,a]),Jd({id:i,type:`field_duplicate`,sourceKey:e.key,key:r,label:n,...Pn&&e.scope===`cohort`?{scope:`cohort`}:{}}),We(r,e.key,`right`)},[We,Pn,Me,l]),Kn=(0,L.useCallback)((e,t)=>{let n=Ie.get(e);if(!n?.measure)return;let r=Ye.find(e=>e.key===n.measure?.key),i=r?`${r.label} · ${Zu(n.measure.window)}`:null,a=r&&i&&n.label===i?`${r.label} · ${Zu(t)}`:n.label;zn({...n,label:a,measure:{...n.measure,window:t}})},[Ie,Ye,zn]),qn=(0,L.useCallback)(()=>{if(!ae)return;let e=[...jt].filter(e=>ft.has(e));e.length&&(Jd({id:Yd(`cohortrm`),type:`cohort_remove`,cohortId:ae,pids:e}),It())},[ae,jt,ft,It]),Jn=(0,L.useCallback)(()=>{!ae||de.size===0||(Jd({id:Yd(`cohortadd`),type:`cohort_add`,cohortId:ae,pids:[...de]}),fe(new Set),ue(``),ce(!1))},[ae,de]),Yn=(0,L.useMemo)(()=>{if(!se)return[];let e=le.trim().toLowerCase(),t=[];for(let n of r){if(ft.has(n.pid))continue;let r=String(n[ze]??``);e&&!r.toLowerCase().includes(e)||t.push({pid:n.pid,name:r})}return t},[se,le,r,ft,ze]),Xn=(0,L.useMemo)(()=>Le.filter(e=>Re.has(e)),[Le,Re]),Zn=VGe(h),Qn=(0,L.useCallback)(e=>{let t=Xn.indexOf(e);if(t<0)return;if(t<8){Pe({...h,frozenCount:sd(t+1)});return}let n=Xn.filter(t=>t!==e);n.splice(7,0,e);let r=0,i=Le.map(e=>Re.has(e)?n[r++]:e);Pe({...h,order:i,frozenCount:8})},[Xn,Le,Re,h,Pe]),$n=(0,L.useCallback)(()=>Pe({...h,frozenCount:void 0}),[h,Pe]),er=(0,L.useCallback)(e=>{let t=d.find(e=>e.id===p);if(t&&Td(t))return;let n=od(h.display);if(e===`grid`){Pe({...h,display:n?od({...n,mode:`grid`}):void 0});return}Pe({...h,display:{...n??{},mode:e}})},[h,Pe,d,p]),tr=(0,L.useCallback)((e,t)=>{let n=od(h.display);if(!n)return;let r={...n,[e]:t};t||delete r[e],Pe({...h,display:r})},[h,Pe]),nr=(0,L.useCallback)(e=>{let t=od(h.display);if(!t)return;let n={...t};e===!1?n.kanbanClamp=!1:delete n.kanbanClamp,Pe({...h,display:n})},[h,Pe]),rr=(0,L.useCallback)(e=>{let t=od(h.display);if(!t)return;let n={...t},r=e.slice(0,4);r.length?n.calendarMetrics=r:delete n.calendarMetrics,Pe({...h,display:n})},[h,Pe]),ir=(0,L.useCallback)(e=>{let t=od(h.display);if(!t)return;let n={...t};e===`summary`?n.calendarMode=`summary`:delete n.calendarMode,Pe({...h,display:n})},[h,Pe]),ar=(0,L.useMemo)(()=>l.filter(e=>ld(e.type)),[l]),or=(0,L.useMemo)(()=>l.filter(e=>e.type===`status`||e.type===`select`),[l]),sr=(e,t,n)=>(e?t.find(t=>t.key===e):void 0)||((n?t.find(e=>e.key===n):void 0)??t[0]),cr=(0,L.useMemo)(()=>TWe(qe?.charts)??[],[qe?.charts]),lr=(0,L.useCallback)(e=>{let t=od(h.display);if(!t)return;let n={...t,charts:e};e.length||delete n.charts,Pe({...h,display:n})},[h,Pe]),ur=(0,L.useMemo)(()=>l.filter(e=>e.type===`status`||e.type===`select`),[l]),dr=(0,L.useMemo)(()=>l.filter(e=>cd(e.type)),[l]),fr=qe?.colorField?ur.find(e=>e.key===qe.colorField):void 0,pr=qe?.sizeField?dr.find(e=>e.key===qe.sizeField):void 0,mr=sr(qe?.dateField,ar,`last_order`),hr=sr(qe?.stackField,or),gr=(0,L.useMemo)(()=>{if(Je!==`calendar`&&Je!==`kanban`&&Je!==`map`&&Je!==`chart`&&Je!==`timeseries`)return[];let e=new Set,t=[];for(let n of pt){if(n.kind!==`data`||e.has(n.record.pid))continue;e.add(n.record.pid);let r=o[n.record.pid];t.push(r?{...n.record,...r}:n.record)}return t},[Je,pt,o]),_r=(0,L.useMemo)(()=>hr?Xn.filter(e=>e!==ze&&e!==hr.key).slice(0,3):[],[Xn,ze,hr]),vr=(0,L.useCallback)((e,t)=>{hr&&c(e,{[hr.key]:t})},[hr,c]),yr=(0,L.useCallback)(e=>{w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),br=(0,L.useMemo)(()=>Je===`timeseries`?gr.map(e=>e.pid):[],[Je,gr]),xr=(0,L.useCallback)(e=>{let t=od(h.display)??{mode:`timeseries`};Pe({...h,display:{...t,...e}})},[h,Pe]),Sr=!!hr&&hr.type===`select`&&at(hr),Cr=hr?hr.type===`status`?`Stacked by ${hr.label} — read-only, computed from the source system.`:at(hr)?null:`You do not have permission to edit this field, so cards cannot be moved.`:null;if(a||!_)return(0,B.jsx)(`div`,{className:`cg-loading`,children:(0,B.jsx)(`span`,{className:`lp-spin lp-spin--lg`,role:`status`,"aria-label":`Loading`})});let wr=d.find(e=>e.id===p),Tr=ut?(0,B.jsx)(`button`,{type:`button`,className:`cg-tb-btn cg-tb-addcust`,ref:pe,disabled:!ae,onClick:()=>ce(e=>!e),"aria-expanded":se,"aria-haspopup":`dialog`,children:`+ Add customers`}):void 0,Er=new Set(l.filter(e=>e.custom&&e.key!==ze).map(e=>e.key)),Dr=j?Ie.get(j.fieldKey):void 0,Or=Dr?h.sorts.find(e=>e.colId===Dr.key)?.dir??null:null,kr=Dr?eKe(h.filters,Dr.key):!1,Ar=Dr?Xn.indexOf(Dr.key):-1,jr=Ar>=0&&Zn>1&&Ar+1===Zn,Mr=Ge?void 0:(0,B.jsx)(OWe,{mode:Je,onMode:er,locked:!!wr&&Td(wr),dateField:mr,dateChoices:ar,stackField:hr,stackChoices:or,colorField:fr,colorChoices:ur,sizeField:pr,sizeChoices:dr,onPickField:tr,clamped:qe?.kanbanClamp!==!1,onClamp:nr,calendarMode:qe?.calendarMode??`records`,onCalendarMode:ir,calendarMetrics:qe?.calendarMetrics,metricChoices:dr,onCalendarMetrics:rr}),Nr=ee?Ie.get(ee.fieldKey):void 0,Pr=Nr?Nr.type===`user`?i?.userOptions??[]:nd(Nr):[],Fr=ee?r.find(e=>e.pid===ee.pid):void 0,Ir=String((ee&&o[ee.pid]?.[ee.fieldKey])??(Nr&&Fr?Fr[Nr.key]:``)??``),Lr=Nr?.type===`multiselect`,Rr=Lr?$Ge(Ir):[],zr=Pr.length?Lr?Rr.find(e=>Pr.includes(e))??Pr[0]:Pr.includes(Ir)?Ir:Pr[0]:null;return(0,B.jsxs)(`div`,{className:`cg-shell`,"data-today":rt??``,"data-measure-rules":$e,"data-measure-sets":et,children:[!Ke&&(0,B.jsx)(WUe,{onCohortLock:ln,views:d,activeViewId:p,saveState:y,onSelect:un,onCreate:dn,onRename:fn,onNote:z,onDuplicate:mn,onDelete:hn,lists:tt,onAddToList:Ge?void 0:gn,today:rt,onExport:Ge?void 0:Mn,folders:Sn,folderIdOf:Cn,onFolderCreate:(e,t)=>{let n=UUe();bn(r=>[...r.slice(-31),{id:n,name:e,order:9999,icon:t}]),wn(e=>({...e,created:{...e.created,[n]:Date.now()}})),Jd({id:Yd(`foldnew`),type:`folder_create`,surface:`views`,folderId:n,name:e,icon:t})},onFolderRename:(e,t)=>{wn(n=>({...n,renamed:{...n.renamed,[e]:{at:Date.now(),name:t}}})),Jd({id:Yd(`foldren`),type:`folder_rename`,surface:`views`,folderId:e,name:t})},onFolderDelete:e=>{wn(t=>({...t,deleted:{...t.deleted,[e]:Date.now()}})),Jd({id:Yd(`folddel`),type:`folder_delete`,surface:`views`,folderId:e})},onFolderDuplicate:e=>{let t=UUe(),n=Sn.find(t=>t.id===e);bn(e=>[...e.slice(-31),{id:t,name:`${n?.name??`Folder`} copy`,order:9999}]),wn(e=>({...e,created:{...e.created,[t]:Date.now()}})),Jd({id:Yd(`folddup`),type:`folder_duplicate`,surface:`views`,folderId:e,newId:t})},onItemMove:(e,t)=>{wn(n=>({...n,moved:{...n.moved,[e]:{at:Date.now(),folderId:t}}})),Jd({id:Yd(`itemmove`),type:`item_move`,surface:`views`,itemId:e,folderId:t})},folderAddPreview:Ge?void 0:Tn,onFolderAddToList:Ge?void 0:En,viewer:it,onToggleLock:pn,userOptions:i?.userOptions}),(0,B.jsxs)(`main`,{className:`cg-main`,children:[(0,B.jsx)(Are,{nouns:t.nouns,cohortLock:In,copyViews:d.filter(e=>e.id!==p),onCopyConfig:e=>Pe({...h,...e}),fields:l,visible:Re,lockedKey:ze,onColumnVisible:Ue,onColumnsVisible:e=>Pe({...h,visible:[...new Set([ze,...e])]}),orderedFields:Lt,onFieldOrder:e=>Pe({...h,order:e}),deletableKeys:Er,onDeleteField:Hn,colorOn:h.colorBy!==null,onToggleColor:e=>Pe({...h,colorBy:e?l.find(e=>e.type===`status`)?.key??null:null}),rowHeightMode:h.rowHeightMode,onRowHeightMode:e=>Pe({...h,rowHeightMode:e}),filters:h.filters,onFilters:e=>Pe({...h,filters:e}),filterConj:h.filterConj??`and`,onFilterConj:e=>Pe({...h,filterConj:e}),sorts:h.sorts,onSorts:e=>Pe({...h,sorts:e}),groupBy:Ge?null:h.groupBy,onGroupBy:e=>Pe({...h,groupBy:e}),statusValues:zt,measures:Ye,unresolvedCount:ot,lists:tt,pendingMeasureCount:Qe,search:x,onSearch:S,recordCount:Vt,scopeCounts:i?.counts,pool:i?.workspace?.pool,serverWindowed:Ge,cohortAction:Tr,filterSeed:me,modeControl:Mr}),(0,B.jsxs)(`div`,{className:`cg-grid-box`,ref:De,onMouseLeave:()=>O(e=>e===null?e:null),children:[Je===`grid`&&(0,B.jsx)(lee,{ref:Ee,columns:Fe,getCellContent:kt,rows:vt.length,theme:jf,freezeColumns:Zn,rowHeight:Gt,headerHeight:36,rowMarkers:`both`,gridSelection:At,onGridSelectionChange:Mt,getRowThemeOverride:Ut,onItemHovered:Wt,onCellClicked:en,onCellActivated:tn,onCellEdited:nn,onPaste:an,validateCell:rn,onColumnResize:Be,onColumnMoved:Ve,onColumnProposeMove:He,drawHeader:$t,onHeaderMenuClick:(e,t)=>R(e,t),onHeaderClicked:on,onHeaderContextMenu:on,onKeyDown:sn,maxColumnWidth:600,getCellsForSelection:!0,rowSelectionMode:`multi`,smoothScrollX:!0,smoothScrollY:!0,width:ke.width,height:ke.height,customRenderers:[Lne,Ine],headerIcons:Hte,rightElement:(0,B.jsx)(`button`,{type:`button`,className:`cg-add-field-btn`,"aria-label":`Add field`,title:`Add a field`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();_e({left:t.left,top:t.top,right:t.right,bottom:t.bottom,width:t.width,height:t.height})},children:`+`}),rightElementProps:{sticky:!0,fill:!1}}),Je===`list`&&(0,B.jsx)(kWe,{rows:vt,fieldByKey:Ie,visibleKeys:Xn,titleKey:ze,onOpen:A,onToggleGroup:yr}),Je===`calendar`&&(mr?(0,B.jsx)(NWe,{rows:gr,field:mr,today:rt,titleKey:ze,mode:qe?.calendarMode??`records`,metrics:qe?.calendarMetrics,fieldByKey:Ie,scope:e,onOpen:A,onSheet:jn}):(0,B.jsx)(`div`,{className:`cg-mode-empty`,children:`This table has no date field to place records by.`})),Je===`kanban`&&(hr?(0,B.jsx)(PWe,{rows:gr,field:hr,fieldByKey:Ie,cardKeys:_r,titleKey:ze,canMove:Sr,readOnlyReason:Cr,clamped:qe?.kanbanClamp!==!1,onMove:vr,onOpen:A}):(0,B.jsx)(`div`,{className:`cg-mode-empty`,children:`This table has no status or single-select field to stack by.`})),Je===`chart`&&(0,B.jsx)($We,{rows:gr,fields:l,fieldByKey:Ie,charts:cr,onCharts:lr}),Je===`timeseries`&&(0,B.jsx)($He,{scope:e,pids:br,fields:l,rows:gr,display:qe,onDisplay:xr,onSheet:kn}),Je===`map`&&Ie.get(ze)&&(0,B.jsx)(jGe,{rows:gr,field:Ie.get(ze),colorField:fr,sizeField:pr,selectedPids:jt,onSelectPids:Nt,onOpen:A}),Je===`grid`&&D&&(0,B.jsx)(`button`,{type:`button`,className:`cg-row-expand`,style:{left:D.x,top:D.y,width:D.size,height:D.size},title:`Expand record`,"aria-label":`Expand record`,onMouseDown:e=>e.preventDefault(),onClick:()=>A(D.pid),children:(0,B.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`13`,height:`13`,"aria-hidden":!0,focusable:`false`,children:(0,B.jsx)(`path`,{d:`M9.5 2.5H13.5V6.5M6.5 13.5H2.5V9.5M13.5 2.5L9 7M2.5 13.5L7 9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),ye&&(0,B.jsx)(`div`,{className:`cg-header-tip`,style:{left:ye.x,top:ye.y},"aria-hidden":!0,children:ye.text}),xe&&(0,B.jsx)(`div`,{className:`cg-header-tip cg-cell-tip`,style:{left:xe.x,top:xe.y},"aria-hidden":!0,children:xe.text}),jt.size>0&&!Ge&&(Je===`grid`||Je===`map`)&&(0,B.jsxs)(`div`,{className:`cg-selbar`,children:[(0,B.jsxs)(`span`,{className:`cg-selbar-count`,children:[jt.size.toLocaleString(),` selected`]}),ut?(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--danger cg-selbar-remove`,style:p9,onClick:qn,children:`Remove from cohort`}):(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary cg-selbar-add`,style:p9,ref:ie,onClick:()=>{if(!ne){let e=wr?.name??`Customers`;F(rt?`${e} · ${rt}`:e)}P(!ne)},"aria-expanded":ne,"aria-haspopup":`dialog`,children:`Add to cohort`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,style:p9,onClick:It,children:`Clear`})]})]}),_t&&(Je===`grid`||Je===`list`)&&(0,B.jsxs)(`div`,{className:`cg-more`,children:[(0,B.jsxs)(`span`,{className:`cg-more-note`,children:[`Showing first `,Ht.toLocaleString(),` of`,` `,Vt.toLocaleString()]}),(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>gt(e=>e+JGe),children:`See more`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-link-btn`,onClick:()=>gt(pt.length),children:`Show all`})]})]}),Dr&&j&&(0,B.jsx)(fWe,{state:j,field:Dr,fields:l,locked:Dr.key===ze,viewer:it,sortedDir:Or,isFiltered:kr,isGrouped:h.groupBy===Dr.key,groupable:Cee(Dr,ze),onClose:()=>M(null),onNote:e=>zn({...Dr,note:e}),onHide:()=>{Ue(Dr.key,!1),M(null)},onCreate:Bn,onChangeField:e=>Vn(Dr.key,e),onCreateAndSwap:(e,t,n,r)=>Un(Dr.key,e,t,n,r),onRetype:Dr.custom&&Dr.source===`overlay`?(e,t,n)=>Wn(Dr.key,e,t,n):void 0,onRename:Dr.custom?e=>zn({...Dr,label:e}):void 0,onFormula:Dr.custom&&Dr.type===`formula`?(e,t)=>zn({...Dr,formula:e,...t?{label:t}:{}}):void 0,onPeriod:Dr.measure?e=>Kn(Dr.key,e):void 0,onDelete:Dr.custom&&Dr.key!==ze?()=>{Hn(Dr.key),M(null)}:void 0,onDuplicate:Dr.custom?()=>Gn(Dr):void 0,onPermissions:Dr.custom?e=>zn({...Dr,permissions:{edit:e}}):void 0,onFormat:e=>zn({...Dr,format:e}),onSort:e=>Pe({...h,sorts:[{colId:Dr.key,dir:e}]}),onClearSort:()=>Pe({...h,sorts:h.sorts.filter(e=>e.colId!==Dr.key)}),onFilterBy:()=>he(e=>({n:(e?.n??0)+1,...Dr.measure?{measure:{key:Dr.measure.key,window:Dr.measure.window}}:{key:Dr.key}})),pinnedTo:jr,onPinTo:Ar>0&&!jr?()=>Qn(Dr.key):void 0,onUnpin:Zn>1?$n:void 0,scopeChoice:Pn,onClearFilter:()=>Pe({...h,filters:tKe(h.filters,Dr.key)}),onGroupByField:()=>Pe({...h,groupBy:Dr.key}),onClearGroup:()=>Pe({...h,groupBy:null}),userOptions:i?.userOptions??[],measures:Ye},Dr.key),ge&&Ie.get(ze)&&(0,B.jsx)(fWe,{state:{fieldKey:ze,anchor:ge},field:Ie.get(ze),fields:l,locked:!0,viewer:it,sortedDir:null,isFiltered:!1,isGrouped:!1,groupable:!1,initialPosition:`end`,onClose:()=>_e(null),onNote:()=>void 0,onHide:()=>void 0,onCreate:Bn,onChangeField:()=>void 0,onCreateAndSwap:()=>void 0,onSort:()=>void 0,onClearSort:()=>void 0,onFilterBy:()=>void 0,onClearFilter:()=>void 0,onGroupByField:()=>void 0,onClearGroup:()=>void 0,scopeChoice:Pn,userOptions:i?.userOptions??[],measures:Ye},`__add-at-end__`),ne&&ie.current&&jt.size>0&&(0,B.jsxs)(Pp,{anchor:ie.current,className:`cg-pop cg-add-list-pop`,placement:`bottom-start`,role:`dialog`,ariaLabel:`Add selected customers to a locked view`,onDismiss:()=>P(!1),dataKind:`selection-add-to-list`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Add to locked view`}),(0,B.jsxs)(`div`,{className:`cg-pop-note`,children:[`Adds the `,jt.size.toLocaleString(),` checked customer`,jt.size===1?``:`s`,`. The cohort stays fixed as the data changes.`]}),tt.map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cg-pick-row`,onClick:()=>Nn(e.id,e.name),children:e.name},e.id)),(0,B.jsxs)(`div`,{className:`cg-view-create`,children:[(0,B.jsx)(`label`,{htmlFor:`cg-sel-new-list`,children:`Lock records into a new view`}),(0,B.jsx)(`input`,{id:`cg-sel-new-list`,className:`cg-input`,"data-overlay-autofocus":!0,value:re,placeholder:`e.g. Q3 call plan`,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`&&re.trim()&&Nn(``,re.trim())}}),(0,B.jsx)(`div`,{className:`cg-form-actions`,children:(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,style:p9,disabled:!re.trim(),onClick:()=>Nn(``,re.trim()),children:`Create and add`})})]})]}),ut&&se&&pe.current&&ae&&(0,B.jsxs)(Pp,{anchor:pe.current,className:`cg-pop cg-addcust-pop`,placement:`bottom-start`,role:`dialog`,ariaLabel:`Add customers to this locked view`,onDismiss:()=>ce(!1),dataKind:`cohort-add-customers`,children:[(0,B.jsx)(`div`,{className:`cg-pop-title`,children:`Add customers`}),(0,B.jsxs)(`div`,{className:`cg-pop-note`,children:[`Search your customer pool and tick who to add to`,` `,(0,B.jsx)(`strong`,{children:dt?.name??`this locked view`}),`.`]}),(0,B.jsx)(`input`,{type:`text`,className:`cg-input cg-addcust-search`,"data-overlay-autofocus":!0,placeholder:`Search customers…`,"aria-label":`Search customers`,value:le,onChange:e=>ue(e.target.value)}),(0,B.jsxs)(`div`,{className:`cg-pick-list cg-addcust-list`,children:[Yn.slice(0,50).map(e=>(0,B.jsxs)(`label`,{className:`cg-check-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:de.has(e.pid),onChange:()=>fe(t=>{let n=new Set(t);return n.has(e.pid)?n.delete(e.pid):n.add(e.pid),n})}),(0,B.jsx)(`span`,{className:`cg-check-label`,children:e.name})]},e.pid)),Yn.length===0&&(0,B.jsx)(`div`,{className:`cg-pop-note`,children:le.trim()?`No customer outside this locked view matches your search.`:`Every customer in your pool is already in this locked view.`})]}),Yn.length>50&&(0,B.jsxs)(`div`,{className:`cg-field-hint`,children:[`Showing the first 50 of `,Yn.length.toLocaleString(),` matches — keep typing to narrow.`]}),(0,B.jsxs)(`div`,{className:`cg-form-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`cg-btn cg-btn--primary`,style:p9,disabled:de.size===0,onClick:Jn,children:de.size===0?`Add customers`:`Add ${de.size.toLocaleString()} customer${de.size===1?``:`s`}`}),(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,style:p9,onClick:()=>ce(!1),children:`Cancel`})]})]}),Nr&&ee&&(0,B.jsxs)(Pp,{anchor:ee.anchor,className:`cg-pop cg-pick-pop`,placement:`bottom-start`,role:`listbox`,ariaLabel:`Choose ${Nr.label}`,onDismiss:te,dataKind:`cell-picker`,initialFocus:`[data-overlay-autofocus]`,onKeyDown:e=>{let t=e.key===`ArrowDown`||e.key===`ArrowRight`,n=e.key===`ArrowUp`||e.key===`ArrowLeft`;if(!t&&!n)return;let r=Array.from(e.currentTarget.querySelectorAll(`.cg-pick-row, .cg-star-btn`));if(!r.length)return;e.preventDefault();let i=r.indexOf(document.activeElement);r[t?(i+1)%r.length:(i-1+r.length)%r.length]?.focus()},children:[Nr.type===`rating`&&(0,B.jsx)(`div`,{className:`cg-stars`,role:`radiogroup`,"aria-label":`Set ${Nr.label}`,children:Array.from({length:rd(Nr)},(e,t)=>t+1).map(e=>(0,B.jsx)(`button`,{type:`button`,className:`cg-star-btn`,role:`radio`,"aria-checked":Number(Ir)===e,"data-overlay-autofocus":Number(Ir)===e||!Ir&&e===1||void 0,"aria-label":`${e} star${e===1?``:`s`}`,onClick:()=>{c(ee.pid,{[Nr.key]:String(e)}),te()},children:(0,B.jsx)(xm,{on:Number(Ir)>=e})},e))}),Nr.type!==`rating`&&Pr.length===0&&(0,B.jsx)(`div`,{className:`cg-pop-note`,children:Nr.type===`user`?`No assignable people were supplied for this workspace.`:`This field has no choices yet. Add them from the column menu.`}),(0,B.jsx)(`div`,{className:`cg-pick-list`,"aria-multiselectable":Lr||void 0,children:Pr.map(e=>{let t=up(Nr,e),n=Lr?Rr.includes(e):Ir===e;return(0,B.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,"data-overlay-autofocus":e===zr||void 0,className:`cg-pick-row`+(n?` is-on`:``),onClick:()=>{if(Lr){let t=n?Rr.filter(t=>t!==e):[...Rr,e];c(ee.pid,{[Nr.key]:t.join(`,`)});return}c(ee.pid,{[Nr.key]:e}),te()},children:[Nr.type===`user`&&(0,B.jsxs)(`span`,{className:`cg-pick-avatar`,"aria-hidden":`true`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,flex:`0 0 auto`,width:20,height:20,borderRadius:`50%`,overflow:`hidden`,marginRight:8,fontSize:9,fontWeight:600,lineHeight:1,position:`relative`,background:sp(e).bg,color:sp(e).fg},children:[fp(e),St?.[e]&&(0,B.jsx)(`img`,{src:St[e],alt:``,onError:e=>{e.currentTarget.style.visibility=`hidden`},style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`cover`}})]}),(0,B.jsx)(`span`,{className:`cg-pick-pill`,style:t?{background:t.bg,color:t.fg}:void 0,children:e})]},e)})}),Lr&&(0,B.jsx)(`div`,{className:`cg-form-actions`,children:(0,B.jsx)(`button`,{type:`button`,className:`cg-btn`,style:p9,onClick:te,children:`Done`})}),Ir!==``&&(0,B.jsx)(`button`,{type:`button`,className:`cg-pick-row cg-pick-clear`,"data-overlay-autofocus":Pr.length===0||void 0,onClick:()=>{c(ee.pid,{[Nr.key]:``}),te()},children:`Clear`})]}),Yt&&k!==null&&(0,B.jsx)(CUe,{fields:l,record:Yt,titleKey:ze,positionLabel:`Record ${Xt.toLocaleString()} of ${Vt.toLocaleString()}`,canPrev:Zt(-1),canNext:Zt(1),onPrev:()=>Qt(-1),onNext:()=>Qt(1),onClose:()=>A(null),recordLayout:Ln,onRecordLayout:Rn,scope:e,docs:i?.docs?.[String(k)]??[],docPayload:i?.docPayload,onDocAdd:i?.docs?e=>Jd({id:Yd(`docadd`),type:`doc_add`,pid:k,docId:`doc_${Yd(`d`).slice(2,14).replace(/[^a-z0-9]/gi,``)}`,...e}):void 0,onDocFetch:i?.docs?e=>Jd({id:Yd(`docget`),type:`doc_fetch`,pid:k,docId:e}):void 0,onDocDelete:i?.docs?e=>Jd({id:Yd(`docdel`),type:`doc_delete`,pid:k,docId:e}):void 0,onNotesChange:(e,t)=>s(n=>({...n,[k]:{...n[k],[e]:t}})),onNotesCommit:(e,t)=>c(k,{[e]:t}),viewer:it,userOptions:i?.userOptions??[],userAvatars:St})]})}var iKe=(0,L.memo)(rKe);function b9(e){if(e==null||e===``)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:null}function x9(e,t){let n=b9(e);if(n==null)return`—`;let r=t??+(Math.abs(n)<10&&!Number.isInteger(n));return n.toLocaleString(void 0,{minimumFractionDigits:r,maximumFractionDigits:r})}function aKe(e,t){let n=b9(e);return n==null?`—`:n<0?`-$${x9(Math.abs(n),t)}`:`$${x9(n,t)}`}function S9(e){let t=b9(e);return t==null?`—`:Math.round(t).toLocaleString()}function oKe(e,t={}){let n=b9(e);return n==null?`—`:n>=999?`+${(1+n/100).toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0})}×`:`${t.signed&&n>=0?`+`:``}${x9(n,t.dp)}%`}var sKe=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function cKe(e){if(e==null||e===``)return`—`;let t=String(e),n=/^(\d{4})-(\d{2})$/.exec(t);if(n){let e=Number(n[2]);if(e>=1&&e<=12)return`${sKe[e-1]} ${n[1].slice(2)}`}let r=t.includes(` `)?t.replace(` `,`T`):t,i=/T\d{2}:\d{2}/.test(r)&&!/(?:[zZ]|[+-]\d{2}:?\d{2})$/.test(r)?`${r}Z`:r,a=new Date(i);return Number.isNaN(a.getTime())?t:a.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`,timeZone:`UTC`})}var C9={money:aKe,num:x9,pct:oKe,int:S9,date:cKe};function w9(e,t,n){if(t==null||t===``)return e==null||e===``?`—`:String(e);switch(t){case`money`:return aKe(e);case`num`:return x9(e);case`pct`:return oKe(e,n);case`int`:return S9(e);case`date`:return cKe(e);default:return e==null||e===``?`—`:String(e)}}function lKe(e){return!!e&&e.kind===`decomp`}function uKe(e,t){return typeof e!=`number`||typeof t!=`number`||!Number.isFinite(e)||!Number.isFinite(t)?null:{text:`Showing ${S9(e)} of ${S9(t)}`,capped:t>e}}function dKe(e,t){if(!t)return;if(lKe(t)){let n=e[t.row_key];if(!n||typeof n!=`object`)return;let r=n;return r.kind!==`decomp`||!r.date_from||!r.date_to?void 0:r}let n=e[t.id_key];if(n==null||n===``)return;let r=t.label_key?e[t.label_key]:void 0;return{kind:t.kind,id:n,label:String(r??n)}}function fKe(e){return(e??``).trim()||`Nothing matched this scope.`}function T9({d:e,size:t,className:n}){return(0,B.jsx)(`svg`,{className:n,width:t,height:t,viewBox:`0 0 24 24`,"aria-hidden":`true`,focusable:`false`,children:(0,B.jsx)(`path`,{d:e,fill:`currentColor`})})}function pKe({size:e=15}){return(0,B.jsx)(T9,{className:`pg-icon`,size:e,d:`M12 15.6 6.8 10.4l1.4-1.4 2.8 2.8V3h2v8.8l2.8-2.8 1.4 1.4zM5 20a2 2 0 0 1-2-2v-3h2v3h14v-3h2v3a2 2 0 0 1-2 2z`})}function mKe({size:e=14}){return(0,B.jsx)(T9,{className:`pg-icon`,size:e,d:`M9.6 17.6 4 12l1.4-1.4 4.2 4.2 9-9L20 7.2z`})}function hKe({size:e=14}){return(0,B.jsx)(T9,{className:`pg-icon`,size:e,d:`M11 15h2v2h-2zm0-10h2v8h-2z`})}function gKe({title:e,asOf:t,subtitle:n,controls:r,onControl:i,busy:a}){return(0,B.jsxs)(`header`,{className:`pg-header`,children:[(0,B.jsxs)(`div`,{className:`pg-title-row`,children:[(0,B.jsx)(`h1`,{className:`pg-title`,children:e}),r&&r.length>0?(0,B.jsx)(`div`,{className:`pg-controls`,children:r.map(e=>(0,B.jsxs)(`label`,{className:`pg-control`,children:[(0,B.jsx)(`span`,{className:`pg-control-label`,children:e.label}),(0,B.jsx)(`select`,{className:`pg-select`,value:String(e.value),disabled:a||!i,onChange:t=>i?.(e.key,t.target.value),children:e.options.map(e=>(0,B.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))})]},e.key))}):null]}),(0,B.jsx)(`div`,{className:`pg-rule`}),n?(0,B.jsx)(`p`,{className:`pg-subtitle`,children:n}):null,t?(0,B.jsxs)(`p`,{className:`pg-asof`,children:[`Data pulled `,(0,B.jsx)(`time`,{dateTime:t,children:C9.date(t)})]}):null]})}function _Ke({label:e,note:t,children:n}){return(0,B.jsxs)(`section`,{className:`pg-section`,children:[(0,B.jsx)(`h2`,{className:`pg-section-label`,children:e}),t?(0,B.jsx)(`p`,{className:`pg-section-note`,children:t}):null,n]})}function vKe({items:e,onOpen:t}){return e.length?(0,B.jsx)(`div`,{className:`pg-kpis`,children:e.map((e,n)=>{let r=w9(e.value,e.fmt),i=e.delta!=null,a=i?w9(e.delta,e.delta_fmt??`pct`,{signed:!0}):``,o=e.delta_dir??(i?`flat`:`off`),s=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`pg-kpi-label`,children:e.label}),(0,B.jsx)(`span`,{className:`pg-kpi-value`,children:r}),a||e.delta_label?(0,B.jsxs)(`span`,{className:`pg-kpi-delta is-${o}`,children:[a,a&&e.delta_label?` `:``,e.delta_label??``]}):null]}),c=e.key??`${e.label}-${n}`;return e.drill&&t?(0,B.jsx)(`button`,{type:`button`,className:`pg-kpi is-clickable`,onClick:()=>t(e.drill),children:s},c):(0,B.jsx)(`div`,{className:`pg-kpi`,children:s},c)})}):null}function yKe({rows:e,columns:t,filename:n,note:r}){return(0,B.jsxs)(`a`,{className:`pg-download`,href:(0,L.useMemo)(()=>{let n=e=>/[",\r\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,r=``+[t.map(e=>n(e.label)).join(`,`),...e.map(e=>t.map(t=>n(w9(e[t.key],t.fmt))).join(`,`))].join(`\r -`);return URL.createObjectURL(new Blob([r],{type:`text/csv;charset=utf-8`}))},[e,t]),download:`${n}.csv`,children:[(0,B.jsx)(pKe,{}),(0,B.jsx)(`span`,{children:`Download CSV`}),r?(0,B.jsx)(`span`,{className:`pg-download-note`,children:r}):null]})}function bKe({columns:e,rows:t,drill:n,shown:r,total:i,onOpen:a,empty:o,download:s}){let c=uKe(r,i),l=c?.capped??!1;return t.length?(0,B.jsxs)(`div`,{className:`pg-table-wrap`,children:[(0,B.jsxs)(`table`,{className:`pg-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsx)(`tr`,{children:e.map(e=>(0,B.jsx)(`th`,{className:e.align===`right`?`is-right`:e.align===`center`?`is-center`:``,scope:`col`,children:e.label},e.key))})}),(0,B.jsx)(`tbody`,{children:t.map((t,r)=>{let i=dKe(t,n);return(0,B.jsx)(`tr`,{className:i&&a?`is-clickable`:``,children:e.map((e,n)=>{let r=w9(t[e.key],e.fmt);return(0,B.jsx)(`td`,{className:e.align===`right`?`is-right`:e.align===`center`?`is-center`:``,children:n===0&&i&&a?(0,B.jsx)(`button`,{type:`button`,className:`pg-cell-link`,onClick:()=>a(i),children:r}):r},e.key)})},String(t[e[0]?.key]??r))})})]}),(0,B.jsxs)(`div`,{className:`pg-table-foot`,children:[c?(0,B.jsx)(`span`,{className:c.capped?`pg-shown is-capped`:`pg-shown`,children:c.text}):null,s?(0,B.jsx)(yKe,{rows:t,columns:e,filename:s.filename,note:l?`the rows shown`:void 0}):null]})]}):(0,B.jsx)(`p`,{className:`pg-empty`,children:fKe(o)})}function xKe({checks:e}){if(!e.length)return null;let t=e.filter(e=>!e.ok).length;return(0,B.jsxs)(`details`,{className:`pg-validation`,open:t>0,children:[(0,B.jsxs)(`summary`,{className:t?`is-failed`:`is-ok`,children:[t?(0,B.jsx)(hKe,{}):(0,B.jsx)(mKe,{}),(0,B.jsx)(`span`,{children:t?`${C9.int(t)} of ${C9.int(e.length)} reconciliation checks did not tie`:`All ${C9.int(e.length)} reconciliation checks tie to Odoo`})]}),(0,B.jsxs)(`table`,{className:`pg-table pg-validation-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{scope:`col`,children:`Check`}),(0,B.jsx)(`th`,{scope:`col`,className:`is-right`,children:`Expected`}),(0,B.jsx)(`th`,{scope:`col`,className:`is-right`,children:`Actual`}),(0,B.jsx)(`th`,{scope:`col`,children:`Note`})]})}),(0,B.jsx)(`tbody`,{children:e.map(e=>(0,B.jsxs)(`tr`,{className:e.ok?``:`is-failed`,children:[(0,B.jsx)(`td`,{children:e.name}),(0,B.jsx)(`td`,{className:`is-right`,children:w9(e.expected,e.fmt)}),(0,B.jsx)(`td`,{className:`is-right`,children:w9(e.actual,e.fmt)}),(0,B.jsx)(`td`,{children:e.note??``})]},e.name))})]})]})}var SKe={customer:`Customer`,sku:`Product`,rep:`Salesperson`,bu:`Business Unit`};function E9({label:e,value:t}){return(0,B.jsxs)(`div`,{className:`pg-drill-row`,children:[(0,B.jsx)(`span`,{className:`pg-drill-key`,children:e}),(0,B.jsx)(`span`,{className:`pg-drill-val`,children:t})]})}function CKe({drill:e,onClose:t}){let n=e.kind===`decomp`,r=e,i=e;return(0,B.jsxs)(`aside`,{className:`pg-drill`,role:`dialog`,"aria-label":e.label,children:[(0,B.jsxs)(`header`,{className:`pg-drill-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`pg-drill-kind`,children:n?`Period`:SKe[e.kind]??e.kind}),(0,B.jsx)(`h2`,{className:`pg-drill-title`,children:e.label})]}),(0,B.jsx)(`button`,{type:`button`,className:`pg-drill-close`,onClick:t,"aria-label":`Close`,children:`×`})]}),(0,B.jsxs)(`div`,{className:`pg-drill-body`,children:[n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(E9,{label:`Window`,value:`${C9.date(r.date_from)} – ${C9.date(r.date_to)}`}),r.cmp_from&&r.cmp_to?(0,B.jsx)(E9,{label:`Compared with`,value:`${C9.date(r.cmp_from)} – ${C9.date(r.cmp_to)}`}):null,(0,B.jsx)(E9,{label:`Scope`,value:r.scope_value==null?r.scope_type:`${r.scope_type} · ${r.scope_value}`})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(E9,{label:SKe[e.kind]??`Record`,value:i.label}),(0,B.jsx)(E9,{label:`Identifier`,value:String(i.id)})]}),(0,B.jsxs)(`p`,{className:`pg-drill-note`,children:[`This wave ships the drill as a complete `,(0,B.jsx)(`em`,{children:`declaration`}),`: the exact scope above is what the number was computed over, and you can check it. The row-level breakdown behind it opens in the next release — until then, use the same view in the current application.`]})]})]})}var wKe=new Set([`text`,`status`,`currency`,`int`,`date`,`pct`,`select`,`user`,`multiselect`,`checkbox`,`phone`,`email`,`url`,`rating`,`created_time`,`formula`]);function TKe(e){return e.map(e=>({key:e.key,label:e.label,type:wKe.has(e.type)?e.type:`text`,source:e.source===`overlay`?`overlay`:`odoo`}))}function EKe(e,t){if(!t||t.length===0)return e;let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e.key)??2**53-1)-(n.get(t.key)??2**53-1))}var D9=720,O9=230,k9=52,A9=10,j9=12,DKe=34;function M9(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e9?(e/1e9).toFixed(1)+`B`:t>=1e6?(e/1e6).toFixed(1)+`M`:t>=1e3?(e/1e3).toFixed(1)+`k`:Number.isInteger(e)?e.toLocaleString():e.toFixed(2)}function OKe(e){let t=e>0?`+`:e<0?`−`:``,n=Math.abs(e);return n>=999?`${t}${Math.round(n/100)}×`:`${t}${n.toFixed(+(n<10))}%`}function kKe({spec:e,series:t,fields:n,rows:r,xOrder:i,deltaByKey:a,onPick:o,pickable:s}){let c=(0,L.useMemo)(()=>TKe(n),[n]),l=(0,L.useMemo)(()=>new Map(c.map(e=>[e.key,e])),[c]),u=(0,L.useMemo)(()=>t.map(t=>({def:t,data:Y7({...e,y:t.y},r,l)})),[t,e,r,l]),d=(0,L.useMemo)(()=>{let e=new Map;for(let t of u)for(let n of t.data.buckets)e.has(n.key)||e.set(n.key,n.label);return EKe([...e].map(([e,t])=>({key:e,label:t,value:0,n:0})),i)},[u,i]),f=u.find(e=>e.data.problem)?.data.problem;if(f)return(0,B.jsx)(`p`,{className:`pg-empty`,children:f});if(!d.length)return(0,B.jsx)(`p`,{className:`pg-empty`,children:`No periods in this scope yet, so there is nothing to plot.`});let p=u.map(e=>({def:e.def,data:e.data,lookup:new Map(e.data.buckets.map(e=>[e.key,e]))})),m=Math.max(0,...p.flatMap(e=>e.data.buckets.map(e=>e.value))),h=m>0?(O9-j9-DKe)/m:0,g=(D9-k9-A9)/d.length,_=Math.max(2,g*.72/Math.max(1,p.length)),v=Math.max(1,Math.ceil(d.length/12)),y=O9-DKe,b=p[0]?.data.rows??0,x=p.reduce((e,t)=>e+t.data.missingY,0),S=p[0]?.data.omitted??0,C=p[0]?.data.omittedValue??0;return(0,B.jsxs)(`div`,{className:`pg-charts`,children:[(0,B.jsx)(`div`,{className:`pg-legend`,children:p.map((e,t)=>(0,B.jsxs)(`span`,{className:`pg-legend-key`,children:[(0,B.jsx)(`span`,{className:`pg-legend-swatch pg-ser-${t%4}`}),e.def.label]},e.def.y))}),(0,B.jsxs)(`svg`,{className:`pg-chart-svg`,viewBox:`0 0 ${D9} ${O9}`,role:`img`,"aria-label":e.title??`Chart`,children:[(0,B.jsx)(`line`,{className:`pg-ax`,x1:k9,y1:y,x2:D9-A9,y2:y}),(0,B.jsx)(`line`,{className:`pg-ax pg-ax-soft`,x1:k9,y1:j9,x2:D9-A9,y2:j9}),(0,B.jsx)(`text`,{className:`pg-ax-lab`,x:k9-6,y:16,textAnchor:`end`,children:M9(m)}),(0,B.jsx)(`text`,{className:`pg-ax-lab`,x:k9-6,y,textAnchor:`end`,children:`0`}),d.map((e,t)=>{let n=k9+t*g,r=_*p.length,i=n+(g-r)/2;return(0,B.jsxs)(`g`,{children:[s&&o?(0,B.jsx)(`rect`,{className:`pg-slot`,x:n,y:j9,width:g,height:y-j9,onClick:()=>o(e.key),children:(0,B.jsx)(`title`,{children:`Open ${e.label}`})}):null,p.map((t,n)=>{let r=t.lookup.get(e.key)?.value??0,a=Math.max(+(r>0),r*h);return(0,B.jsx)(`rect`,{className:`pg-bar pg-ser-${n%4}`,x:i+n*_,y:y-a,width:Math.max(1,_-1.5),height:a,children:(0,B.jsx)(`title`,{children:`${e.label} · ${t.def.label}: ${M9(r)}`})},t.def.y)}),(()=>{let t=a?.get(e.key);if(t==null)return null;let r=Math.max(0,...p.map(t=>{let n=t.lookup.get(e.key)?.value??0;return Math.max(+(n>0),n*h)}));return(0,B.jsx)(`text`,{className:`pg-bar-delta ${t>0?`is-up`:t<0?`is-down`:``}`,x:n+g/2,y:Math.max(8,y-r-4),textAnchor:`middle`,children:OKe(t)})})(),t%v===0?(0,B.jsx)(`text`,{className:`pg-ax-lab`,x:n+g/2,y:210,textAnchor:`middle`,children:e.label}):null]},e.key||`(blank)-${t}`)})]}),(0,B.jsxs)(`p`,{className:`pg-chart-note`,children:[`${b.toLocaleString()} period${b===1?``:`s`} plotted`,S>0?` · ${S} more not drawn, worth ${M9(C)}`:``,x>0?` · ${x} value${x===1?``:`s`} the measure could not use`:``,s?` · click a period to decompose it`:``]})]})}function AKe(e){let t=[],n={body:[]};for(let r of e)r.type===`section`?((n.head||n.body.length)&&t.push(n),n={head:r,body:[]}):n.body.push(r);return(n.head||n.body.length)&&t.push(n),t}function jKe({block:e,onOpen:t}){let n=e.drill,r=new Map;if(lKe(n)){let t=e.spec.x;for(let i of e.rows){let e=i[n.row_key],a=t?i[t]:void 0;a!=null&&e&&typeof e==`object`&&e.kind===`decomp`&&r.set(String(a),e)}}let i=new Map;if(e.delta_key){let t=e.spec.x;for(let n of e.rows){let r=t?n[t]:void 0,a=n[e.delta_key];r!=null&&typeof a==`number`&&Number.isFinite(a)&&i.set(String(r),a)}}let a=!!t&&r.size>0;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(kKe,{spec:e.spec,series:e.series??[],fields:e.fields,rows:e.rows,xOrder:e.x_order,deltaByKey:i.size?i:void 0,pickable:a,onPick:e=>{let n=r.get(e);n&&t&&t(n)}}),e.shown!=null&&e.total!=null&&e.total>e.shown?(0,B.jsxs)(`p`,{className:`pg-shown is-capped`,children:[`Showing `,e.shown,` of `,e.total,` periods`]}):null]})}function MKe({block:e,onOpen:t}){switch(e.type){case`kpis`:return(0,B.jsx)(vKe,{items:e.items,onOpen:t});case`table`:{let n=e;return(0,B.jsx)(bKe,{columns:n.columns,rows:n.rows,drill:n.drill,shown:n.shown,total:n.total,empty:n.empty,download:n.download,onOpen:t})}case`chart`:return(0,B.jsx)(jKe,{block:e,onOpen:t});case`validation`:return(0,B.jsx)(xKe,{checks:e.checks});default:return null}}function NKe({page:e,onControl:t,onOpen:n,busy:r}){let i=AKe(e.blocks);return(0,B.jsxs)(`div`,{className:`pg-page`,children:[(0,B.jsx)(gKe,{title:e.title,asOf:e.as_of,subtitle:e.subtitle,controls:e.controls,onControl:t,busy:r}),i.map((e,t)=>e.head?(0,B.jsx)(_Ke,{label:e.head.label,note:e.head.note,children:e.body.map((e,t)=>(0,B.jsx)(MKe,{block:e,onOpen:n},e.key??`b${t}`))},e.head.key??`s${t}`):(0,B.jsx)(`div`,{children:e.body.map((e,t)=>(0,B.jsx)(MKe,{block:e,onOpen:n},e.key??`b${t}`))},`g${t}`))]})}async function PKe(e){let t=``,n=``;try{let r=await e.json();t=String(r?.error?.code??``),n=String(r?.error?.message??``)}catch{}if(e.status>=500)return{ok:!1,status:e.status,code:t||`server_error`,message:`Something went wrong on our side. Try again in a moment.`};let r=e.status===401?`Your session has ended. Sign in again.`:e.status===403?`This account does not have access to that.`:e.status===404?`That page does not exist.`:`That request could not be completed.`;return{ok:!1,status:e.status,code:t||String(e.status),message:n||r}}async function FKe(e,t={}){let n=new URLSearchParams(t).toString(),r=`${Pd}/pages/${encodeURIComponent(e)}${n?`?${n}`:``}`;try{let e=await fetch(r,{credentials:Fd});if(!e.ok)return PKe(e);let t=await e.json();return!t||typeof t!=`object`||!Array.isArray(t.blocks)?{ok:!1,status:200,code:`bad_envelope`,message:`The server sent a page this client could not read.`}:{ok:!0,page:t}}catch{return{ok:!1,status:0,code:`offline`,message:`The server could not be reached.`}}}function IKe({pageKey:e,label:t}){let[n,r]=(0,L.useState)({phase:`loading`}),[i,a]=(0,L.useState)({}),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(null),u=JSON.stringify(i);(0,L.useEffect)(()=>{let t=!1;return s(!0),FKe(e,JSON.parse(u)).then(e=>{if(!t){if(s(!1),e.ok){r({phase:`ready`,page:e.page});return}if(e.status===401){Hd(Id);return}r({phase:`error`,message:e.message})}}),()=>{t=!0}},[e,u]);let d=(0,L.useCallback)((e,t)=>{l(null),a(n=>({...n,[e]:t}))},[]);return n.phase===`loading`?(0,B.jsxs)(`div`,{className:`pg-state`,children:[(0,B.jsx)(`h1`,{children:t}),(0,B.jsx)(`span`,{className:`lp-spin lp-spin--lg`,role:`status`,"aria-label":`Loading`})]}):n.phase===`error`?(0,B.jsxs)(`div`,{className:`pg-state pg-error`,children:[(0,B.jsx)(`h1`,{children:t}),(0,B.jsx)(`p`,{children:n.message}),(0,B.jsx)(`button`,{className:`login-submit shell-retry`,type:`button`,onClick:()=>a(e=>({...e})),children:`Try again`})]}):(0,B.jsxs)(`div`,{className:o?`pg-host is-busy`:`pg-host`,children:[(0,B.jsx)(NKe,{page:n.page,onControl:d,onOpen:l,busy:o}),c?(0,B.jsx)(CKe,{drill:c,onClose:()=>l(null)}):null]})}function N9(e){return e?.role===`admin`}function LKe(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.username==`string`?t.username.trim():``;return n?{username:n,name:typeof t.name==`string`&&t.name.trim()!==``?t.name.trim():n,role:typeof t.role==`string`?t.role:``,bus:Array.isArray(t.bus)?t.bus.filter(e=>typeof e==`string`):[],modules:t.modules===`all`?`all`:Array.isArray(t.modules)?t.modules.filter(e=>typeof e==`string`):[],avatar:typeof t.avatar==`string`&&t.avatar.startsWith(`data:image/`)?t.avatar:null}:null}function P9(e){return!e||typeof e!=`object`?null:LKe(e.user)}var RKe=`Incorrect username or password.`,F9=`Sign-in is unavailable right now. Try again in a moment.`,zKe=`Cannot reach the server. Check your connection and try again.`;function BKe(e,t){if(e===0)return zKe;if(e>=500)return F9;let n=t?.error;return(typeof n?.message==`string`?n.message.trim():``)||(e===401?RKe:F9)}async function VKe(e){try{return await e.json()}catch{return null}}async function HKe(e,t){let n;try{n=await fetch(`${Pd}/auth/login`,{method:`POST`,credentials:Fd,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:e,password:t})})}catch{return{ok:!1,message:BKe(0,null)}}let r=await VKe(n);if(!n.ok)return{ok:!1,message:BKe(n.status,r)};let i=P9(r);return i?{ok:!0,user:i}:{ok:!1,message:F9}}async function UKe(){try{let e=await fetch(`${Pd}/auth/me`,{credentials:Fd});return e.ok?P9(await VKe(e)):null}catch{return null}}async function WKe(){try{await fetch(`${Pd}/auth/logout`,{method:`POST`,credentials:Fd})}catch{}}async function I9(e,t){try{let n=await fetch(`${Pd}${e}`,{credentials:Fd,headers:t?.body?{"Content-Type":`application/json`}:void 0,...t});if(n.status===204)return{ok:!0,data:void 0};let r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.error,t=n.status>=500?`Something went wrong on our side. Try again in a moment.`:e?.message||(n.status===403?`Administrators only.`:n.status===409?`That username already exists. Edit the existing account instead.`:`That change could not be saved.`);return{ok:!1,status:n.status,message:t}}return{ok:!0,data:r}}catch{return{ok:!1,status:0,message:`The server could not be reached.`}}}function GKe(){return I9(`/settings`)}function KKe(){return I9(`/admin/users`)}function qKe(e){return I9(`/admin/users`,{method:`POST`,body:JSON.stringify(e)})}function JKe(e,t){return I9(`/admin/users/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function YKe(e,t){return I9(`/admin/users/${encodeURIComponent(e)}/password`,{method:`POST`,body:JSON.stringify({password:t})})}function XKe(e){return I9(`/admin/users/${encodeURIComponent(e)}/perms`)}function ZKe(e,t){return I9(`/admin/users/${encodeURIComponent(e)}/perms`,{method:`PUT`,body:JSON.stringify(t)})}function QKe(e){return I9(`/auth/me/avatar`,{method:`POST`,body:JSON.stringify({dataUrl:e})})}function $Ke(){return I9(`/auth/me/avatar`,{method:`DELETE`})}function eqe(e,t){return e===`users`&&!t?`account`:e}var tqe=new Set(Object.keys({text:!0,status:!0,currency:!0,int:!0,date:!0,pct:!0,select:!0,user:!0,multiselect:!0,checkbox:!0,phone:!0,email:!0,url:!0,rating:!0,created_time:!0,formula:!0}));function nqe(e){return typeof e==`string`&&tqe.has(e)?e:`text`}function rqe(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function iqe(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.key!=`string`||t.key===``)return null;let n=typeof t.label==`string`&&t.label!==``?t.label:t.key,r=rqe(t.options);return{key:t.key,label:n,type:nqe(t.type),source:t.source===`overlay`?`overlay`:`odoo`,...t.pinned===!0?{pinned:!0}:{},...r.length?{options:r}:{},...typeof t.note==`string`?{note:t.note}:{},...typeof t.description==`string`&&t.description!==``?{note:t.description}:{}}}function aqe(e,t,n){let r=[];for(let e of Array.isArray(n)?n:[]){let t=iqe(e);t&&r.push(t)}return{key:e,label:t||e,fields:r}}function oqe(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(!Array.isArray(t.nodes))return null;let n=t.conj===`or`?`or`:t.conj===`and`?`and`:void 0;return{...n?{conj:n}:{},nodes:t.nodes}}function sqe(e){if(!e||typeof e!=`object`||Array.isArray(e))return{access:!1,filter:null,hiddenFields:[]};let t=e;return{access:t.access===!0,filter:oqe(t.filter),hiddenFields:L9(rqe(t.hiddenFields))}}function L9(e){return[...new Set(e)].sort()}function R9(e){return e.find(e=>e.pinned)?.key??e[0]?.key??``}function cqe(e){let t=R9(e);return e.filter(e=>e.key!==t).map(e=>e.key)}function lqe(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.fields_by_module&&typeof t.fields_by_module==`object`?t.fields_by_module:{},r=t.perms&&typeof t.perms==`object`&&!Array.isArray(t.perms)?t.perms:{},i=(Array.isArray(t.modules)?t.modules.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.key==`string`&&t.key?[{key:t.key,label:typeof t.label==`string`?t.label:t.key}]:[]}):Object.keys(n).map(e=>({key:e,label:e}))).map(e=>aqe(e.key,e.label,n[e.key])),a={};for(let e of i)a[e.key]=sqe(r[e.key]);return{modules:i,entries:a,orphanModules:Object.keys(r).filter(e=>!(e in a)).sort(),migrated:typeof t.perms_v==`number`&&t.perms_v>=1,isAdmin:t.is_admin===!0}}function z9(e,t,n){let r=e[t]??{access:!1,filter:null,hiddenFields:[]};return{...e,[t]:{...r,...n}}}function uqe(e,t,n){return z9(e,t,{access:n})}function dqe(e,t,n){return z9(e,t,{filter:!n||n.nodes.length===0?null:n})}function B9(e,t,n){return z9(e,t,{hiddenFields:L9(n)})}function fqe(e,t,n){let r=e[t]?.hiddenFields??[];return B9(e,t,r.includes(n)?r.filter(e=>e!==n):[...r,n])}function pqe(e,t){return new Set(e[t]?.hiddenFields??[])}function mqe(e,t){return e[t]?.filter??{nodes:[]}}function V9(e,t){let n={};for(let r of e.modules){let e=t[r.key]??{access:!1,filter:null,hiddenFields:[]},i=R9(r.fields);n[r.key]=r.fields.length?{access:e.access,filter:e.filter,hiddenFields:L9(e.hiddenFields.filter(e=>e!==i))}:{access:e.access,filter:null,hiddenFields:[]}}return{perms:n}}function hqe(e,t,n){if(n.kind===`all`){let n={};for(let r of e.modules)n[r.key]=t[r.key]??{access:!1,filter:null,hiddenFields:[]};return n}return{...e.entries,[n.key]:t[n.key]??{access:!1,filter:null,hiddenFields:[]}}}function gqe(e,t,n){let r=new Set(e.modules.map(e=>e.key));return(n.kind===`all`?Object.keys(t):[n.key]).filter(e=>!r.has(e)).sort()}function _qe(e,t,n){return JSON.stringify(V9(e,t))!==JSON.stringify(V9(e,n))}function vqe(e){if(!e)return 0;let t=0,n=e=>{for(let r of e)r&&typeof r==`object`&&Array.isArray(r.children)?n(r.children):t+=1};return n(e.nodes),t}function H9(e,t=!1){if(!e||!e.access)return`No access`;if(t)return`Full access`;let n=vqe(e.filter),r=e.hiddenFields.length;if(!n&&!r)return`Full access`;let i=[];return n&&i.push(`${n} condition${n===1?``:`s`}`),r&&i.push(`${r} field${r===1?``:`s`} hidden`),i.join(`, `)}function U9(e,t){if(!e||e.modules.length===0)return``;let n=e.modules.filter(e=>t[e.key]?.access);if(n.length===0)return`No access`;let r=n.filter(e=>e.fields.length>0&&((t[e.key]?.filter?.nodes.length??0)>0||(t[e.key]?.hiddenFields.length??0)>0)).length,i=n.length===e.modules.length?`All ${n.length} module${n.length===1?``:`s`}`:`${n.length} of ${e.modules.length} modules`;return r?`${i}, ${r} restricted`:i}function W9(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function G9(e){return e.kind===`all`?`this account's whole access`:`${e.label} access`}function yqe({user:e,userOptions:t,copyTargets:n,onBack:r,onSaved:i}){let a=e.name||e.username,o=e.username,[s,c]=(0,L.useState)({phase:`loading`}),[l,u]=(0,L.useState)({}),[d,f]=(0,L.useState)({}),[p,m]=(0,L.useState)(null),[h,g]=(0,L.useState)(null),[_,v]=(0,L.useState)(!1),[y,b]=(0,L.useState)(``),[x,S]=(0,L.useState)(``),[C,w]=(0,L.useState)(e.name??``),[T,E]=(0,L.useState)(e.role??`user`),[D,O]=(0,L.useState)(``);(0,L.useEffect)(()=>{let e=!1;return c({phase:`loading`}),XKe(o).then(t=>{if(e)return;if(!t.ok){c({phase:`error`,message:t.message});return}let n=lqe(t.data);if(!n){c({phase:`error`,message:`The permission record could not be read. Close and try again.`});return}u(n.entries),f(n.entries),c({phase:`ready`,payload:n})}),()=>{e=!0}},[o]);let k=s.phase===`ready`?s.payload:null,A=k?_qe(k,l,d):!1,j=e.role===`admin`||k?.isAdmin===!0,M=C.trim()!==(e.name??``).trim()||T!==(e.role??`user`),ee=A||M,N=(0,L.useCallback)(()=>{ee?m({kind:`discard`}):r()},[ee,r]),te=(0,L.useRef)(ee);te.current=ee;let ne=(0,L.useRef)(p);ne.current=p;let P=(0,L.useRef)(h);P.current=h,(0,L.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){if(P.current){e.stopPropagation(),P.current.phase!==`writing`&&g(null);return}if(ne.current){e.stopPropagation(),m(null);return}te.current&&(e.stopPropagation(),m({kind:`discard`}))}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]);let re=(0,L.useRef)(null);(0,L.useEffect)(()=>{!p&&!h||(re.current?.scrollIntoView({block:`center`}),re.current?.querySelector(`button`)?.focus())},[p,h]);let F=(0,L.useCallback)(()=>{if(!k)return;v(!0),b(``);let e=V9(k,d);ZKe(o,e).then(t=>{v(!1),m(null),t.ok?(u(e.perms),S(`Saved access for ${o}.`),i(`Saved access for ${o}.`)):b(t.message)})},[k,d,o,i]),ie=(0,L.useCallback)((e,t)=>{v(!0),b(``),JKe(o,e).then(e=>{v(!1),e.ok?(S(t),i(t)):b(e.message)})},[o,i]),ae=(0,L.useCallback)(async(e,t)=>{g({phase:`preparing`,scope:e});let r=[],i=[];for(let a of n??[]){if(!t.includes(a.username))continue;let n=await XKe(a.username);if(!n.ok){i.push({username:a.username,why:n.message});continue}let o=lqe(n.data);if(!o){i.push({username:a.username,why:`its permission record could not be read`});continue}let s=[];o.isAdmin&&s.push(`is an administrator — the rules will be stored but stay inert until the account is changed to Member`),o.migrated||s.push(`still uses the previous access model — this write moves it to the per-module model`),o.orphanModules.length&&s.push(`has rules for ${o.orphanModules.join(`, `)}, which this deployment no longer offers — those are removed`);let c=gqe(o,l,e);if(c.length){let e=c.map(e=>k?.modules.find(t=>t.key===e)?.label??e);s.push(`does not offer ${e.join(`, `)}, so that part of this copy cannot be written at all`)}r.push({user:a,payload:o,before:e.kind===`all`?U9(o,o.entries)||`No access`:H9(o.entries[e.key],(o.modules.find(t=>t.key===e.key)?.fields.length??0)===0),notes:s})}g({phase:`confirm`,scope:e,plans:r,refused:i})},[n,l,k]),oe=(0,L.useCallback)(async(e,t)=>{g({phase:`writing`,scope:e}),b(``);let n=[],r=[],a=new Set;for(let i of t){let t=hqe(i.payload,l,e);for(let t of gqe(i.payload,l,e))a.add(t);let o=await ZKe(i.user.username,V9(i.payload,t));o.ok?n.push(i.user.username):r.push(`${i.user.username} (${o.message})`)}if(g(null),n.length){let t=`Copied ${G9(e)} to ${W9(n)}.`;S(t),i(t)}let o=[];if(r.length&&o.push(`Not copied to ${W9(r)}.`),a.size){let e=W9([...a].sort());o.push(`${e} could not be copied — the accounts you picked do not offer ${a.size===1?`it`:`them`}.`)}o.length&&b(o.join(` `))},[l,i]),se=(n?.length??0)>0&&!!k&&!A,ce=(0,L.useCallback)(e=>{m(null),b(``),S(``),g({phase:`pick`,scope:e,picked:new Set})},[]);return(0,B.jsxs)(`div`,{className:`set-pane set-perms`,children:[(0,B.jsxs)(`div`,{className:`set-perm-head`,children:[(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,onClick:N,children:`Back to accounts`}),(0,B.jsxs)(`div`,{className:`set-perm-who`,children:[(0,B.jsx)(`h3`,{className:`set-h set-perm-title`,children:a}),(0,B.jsx)(`span`,{className:`set-username`,children:o})]}),(0,B.jsx)(`span`,{className:T===`admin`?`set-chip set-chip--admin`:`set-chip`,children:T===`admin`?`Admin`:`Member`}),e.active?null:(0,B.jsx)(`span`,{className:`set-chip set-chip--off`,children:`Deactivated`})]}),y?(0,B.jsx)(`p`,{className:`set-error`,children:y}):null,x?(0,B.jsx)(`p`,{className:`set-notice`,children:x}):null,(0,B.jsxs)(`section`,{className:`set-card`,children:[(0,B.jsx)(`h4`,{className:`set-h4`,children:`Account`}),(0,B.jsxs)(`div`,{className:`set-grid2`,children:[(0,B.jsxs)(`div`,{className:`set-field`,children:[(0,B.jsx)(`label`,{className:`set-label`,htmlFor:`set-name`,children:`Display name`}),(0,B.jsx)(`input`,{id:`set-name`,className:`set-input`,value:C,onChange:e=>w(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`set-field`,children:[(0,B.jsx)(`label`,{className:`set-label`,htmlFor:`set-role`,children:`Role`}),(0,B.jsxs)(`select`,{id:`set-role`,className:`pg-select`,value:T,onChange:e=>E(e.target.value),children:[(0,B.jsx)(`option`,{value:`user`,children:`Member`}),(0,B.jsx)(`option`,{value:`admin`,children:`Admin`})]})]})]}),T===`admin`&&(e.role??`user`)!==`admin`?(0,B.jsx)(`p`,{className:`set-help`,children:`Saving this makes the account an administrator, which bypasses every access rule set below.`}):null,(0,B.jsxs)(`div`,{className:`set-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`set-primary`,disabled:_||!M,onClick:()=>ie({name:C,role:T},`Saved ${o}.`),children:`Save account`}),(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,disabled:_,onClick:()=>ie({active:!e.active},`${e.active?`Deactivated`:`Reactivated`} ${o}.`),children:e.active?`Deactivate account`:`Reactivate account`})]}),(0,B.jsxs)(`div`,{className:`set-danger set-grid2`,children:[(0,B.jsxs)(`div`,{className:`set-field`,children:[(0,B.jsx)(`label`,{className:`set-label`,htmlFor:`set-pw`,children:`Set a new password`}),(0,B.jsx)(`input`,{id:`set-pw`,className:`set-input`,type:`password`,value:D,autoComplete:`new-password`,onChange:e=>O(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`set-pw-side`,children:[(0,B.jsxs)(`p`,{className:`set-help`,children:[`This signs `,o,` out everywhere immediately.`]}),(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,disabled:_||D.length===0,onClick:()=>{b(``),YKe(o,D).then(e=>{e.ok?(O(``),S(`Password reset; ${o} was signed out.`)):b(e.message)})},children:`Reset password`})]})]})]}),s.phase===`loading`?(0,B.jsx)(`div`,{className:`set-loading`,children:(0,B.jsx)(`span`,{className:`lp-spin lp-spin--lg`,role:`status`,"aria-label":`Loading`})}):null,s.phase===`error`?(0,B.jsx)(`p`,{className:`set-error`,children:s.message}):null,k?(0,B.jsxs)(B.Fragment,{children:[j?(0,B.jsx)(`p`,{className:`set-notice set-perm-banner`,children:`This is an administrator account. Administrators see everything, so nothing set here applies to them — these rules take effect only if the account is changed to Member.`}):null,!k.migrated&&!j?(0,B.jsx)(`p`,{className:`set-notice set-perm-banner`,children:`This account still uses the previous access model, so the rules below are not in force yet. Saving moves it to the per-module model — set every module deliberately before you do.`}):null,k.orphanModules.length?(0,B.jsxs)(`p`,{className:`set-error set-perm-banner`,children:[`This account has rules for `,k.orphanModules.join(`, `),`, which this deployment no longer offers. Saving removes them.`]}):null,(0,B.jsxs)(`div`,{className:`set-perm-sect`,children:[(0,B.jsx)(`h4`,{className:`set-h4`,children:`Access`}),n?.length?(0,B.jsx)(`button`,{type:`button`,className:`set-secondary set-copy-door`,disabled:!se||_,title:A?`Save this account's access first — a copy sends what is stored, not what is on screen.`:void 0,onClick:()=>ce({kind:`all`}),children:`Apply this access to…`}):null]}),(0,B.jsxs)(`p`,{className:`set-help set-perm-intro`,children:[U9(k,d),`. Each module can be turned off entirely, narrowed to the records a condition describes, or shown with fields hidden. Restrictions apply everywhere the account looks — the tables, the exports and every number computed from them.`]}),A&&n?.length?(0,B.jsx)(`p`,{className:`set-help set-copy-why`,children:`Copying is unavailable while there are unsaved changes — a copy sends what is stored, not what is on screen.`}):null,k.modules.length===0?(0,B.jsx)(`p`,{className:`pg-empty`,children:`This deployment declares no modules that can be restricted.`}):null,k.modules.map(e=>{let r=d[e.key],i=r?.access===!0,a=e.fields.length===0;return(0,B.jsxs)(`section`,{className:`set-card set-perm-mod`,children:[(0,B.jsxs)(`div`,{className:`set-perm-modhead`,children:[(0,B.jsxs)(`label`,{className:`set-check set-perm-toggle`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:i,onChange:t=>f(n=>uqe(n,e.key,t.target.checked))}),(0,B.jsx)(`span`,{className:`set-perm-modname`,children:e.label})]}),(0,B.jsx)(`span`,{className:`set-perm-sum`,children:H9(r,a)}),n?.length?(0,B.jsx)(`button`,{type:`button`,className:`set-secondary set-copy-door`,disabled:!se||_,onClick:()=>ce({kind:`module`,key:e.key,label:e.label}),children:`Copy to…`}):null]}),i&&a?(0,B.jsx)(`p`,{className:`set-help`,children:`No field list is available for this module, so access is all this editor can set for it. Conditions and hidden fields need a schema.`}):null,i&&!a?(0,B.jsxs)(`div`,{className:`set-perm-panels`,children:[(0,B.jsx)(`div`,{className:`cg-pop set-perm-pop`,children:(0,B.jsx)(fm,{fields:e.fields,filters:mqe(d,e.key),onChange:t=>f(n=>dqe(n,e.key,t)),userOptions:t})}),(0,B.jsx)(`div`,{className:`cg-pop set-perm-pop`,children:(0,B.jsx)(pm,{fields:e.fields,hidden:pqe(d,e.key),onToggle:t=>f(n=>fqe(n,e.key,t)),lockedKey:R9(e.fields),onHideAll:()=>f(t=>B9(t,e.key,cqe(e.fields))),onShowAll:()=>f(t=>B9(t,e.key,[]))})})]}):null]},e.key)}),(0,B.jsxs)(`div`,{className:`set-actions set-perm-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`set-primary`,disabled:_||!A,onClick:()=>m({kind:`save`}),children:`Save access`}),(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,disabled:_,onClick:N,children:`Cancel`}),A?(0,B.jsx)(`span`,{className:`set-help set-perm-dirty`,children:`Unsaved changes`}):null]})]}):null,p?(0,B.jsx)(`div`,{className:`set-confirm-wrap`,children:(0,B.jsxs)(`div`,{ref:re,className:`set-confirm`,role:`alertdialog`,"aria-modal":`true`,"aria-label":p.kind===`save`?`Confirm access change`:`Discard changes`,children:[p.kind===`save`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`h4`,{className:`set-h4`,children:[`Change what `,a,` can see?`]}),(0,B.jsxs)(`p`,{className:`set-help`,children:[`This takes effect the next time they load a page. `,bqe(k,d)]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`h4`,{className:`set-h4`,children:`Discard these changes?`}),(0,B.jsxs)(`p`,{className:`set-help`,children:[xqe(A,M),` for `,a,` stay as they were.`]})]}),(0,B.jsxs)(`div`,{className:`set-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`set-primary`,disabled:_,onClick:()=>p.kind===`save`?F():(m(null),r()),children:p.kind===`save`?`Save access`:`Discard`}),(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,disabled:_,onClick:()=>m(null),children:`Keep editing`})]})]})}):null,h?(0,B.jsx)(`div`,{className:`set-confirm-wrap`,children:(0,B.jsxs)(`div`,{ref:re,className:`set-confirm set-copy`,role:`alertdialog`,"aria-modal":`true`,"aria-label":`Copy ${G9(h.scope)}`,children:[h.phase===`pick`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`h4`,{className:`set-h4`,children:[`Copy `,G9(h.scope),` to…`]}),(0,B.jsx)(`p`,{className:`set-help`,children:h.scope.kind===`all`?`Every account you pick has its whole access record replaced with ${a}'s.`:`Every account you pick has its ${h.scope.label} access replaced with ${a}'s. Their other modules are left alone.`}),(0,B.jsx)(`div`,{className:`set-copy-list`,children:(n??[]).map(e=>(0,B.jsxs)(`label`,{className:`set-check set-copy-row`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:h.picked.has(e.username),onChange:t=>{let n=new Set(h.picked);t.target.checked?n.add(e.username):n.delete(e.username),g({...h,picked:n})}}),(0,B.jsx)(`span`,{className:`set-copy-name`,children:e.name||e.username}),(0,B.jsx)(`span`,{className:`set-username set-copy-user`,children:e.username}),e.role===`admin`?(0,B.jsx)(`span`,{className:`set-chip set-chip--admin`,children:`Admin`}):null,e.active?null:(0,B.jsx)(`span`,{className:`set-chip set-chip--off`,children:`Deactivated`})]},e.username))}),(0,B.jsxs)(`div`,{className:`set-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`set-primary`,disabled:h.picked.size===0,onClick:()=>void ae(h.scope,[...h.picked]),children:`Continue`}),(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,onClick:()=>g(null),children:`Cancel`})]})]}):null,h.phase===`preparing`||h.phase===`writing`?(0,B.jsx)(`div`,{className:`set-loading`,children:(0,B.jsx)(`span`,{className:`lp-spin lp-spin--lg`,role:`status`,"aria-label":`Loading`})}):null,h.phase===`confirm`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`h4`,{className:`set-h4`,children:[`Replace `,G9(h.scope),` for `,h.plans.length,` account`,h.plans.length===1?``:`s`,`?`]}),h.plans.length===0?(0,B.jsx)(`p`,{className:`set-help`,children:`None of the accounts picked could be read, so there is nothing to write.`}):(0,B.jsx)(`ul`,{className:`set-copy-plans`,children:h.plans.map(e=>(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`span`,{className:`set-copy-name`,children:e.user.name||e.user.username}),` `,(0,B.jsxs)(`span`,{className:`set-copy-before`,children:[`now: `,e.before]}),e.notes.map(t=>(0,B.jsxs)(`span`,{className:`set-copy-note`,children:[e.user.username,` `,t]},t))]},e.user.username))}),h.refused.length?(0,B.jsxs)(`p`,{className:`set-error`,children:[W9(h.refused.map(e=>`${e.username} (${e.why.replace(/\.\s*$/,``)})`)),` `,`could not be read and will not be changed.`]}):null,(0,B.jsxs)(`div`,{className:`set-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`set-primary`,disabled:h.plans.length===0,onClick:()=>void oe(h.scope,h.plans),children:`Replace access`}),(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,onClick:()=>g(null),children:`Cancel`})]})]}):null]})}):null]})}function bqe(e,t){let n=U9(e,t);return n?`${n} after this change.`:``}function xqe(e,t){return e&&t?`The account details and access rules`:t?`The account details`:`The access rules`}function Sqe(e){return e===`all`||!Array.isArray(e)||e.length===0?`All modules`:`${e.length} module${e.length===1?``:`s`}: ${e.join(`, `)}`}function Cqe(){return(0,B.jsx)(`svg`,{className:`set-acct-chev`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M4.4 2.4 8 6l-3.6 3.6`})})}function wqe(){let[e,t]=(0,L.useState)(null),[n,r]=(0,L.useState)(``),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(null),c=(0,L.useCallback)(()=>{KKe().then(e=>{e.ok?(t(e.data.users??[]),r(``)):(t([]),r(e.message))})},[]);if((0,L.useEffect)(c,[c]),e===null)return(0,B.jsx)(`div`,{className:`set-loading`,children:(0,B.jsx)(`span`,{className:`lp-spin lp-spin--lg`,role:`status`,"aria-label":`Loading`})});if(o){let t=e.find(e=>e.username===o);return t?(0,B.jsx)(yqe,{user:t,userOptions:e.map(e=>e.name||e.username),copyTargets:e.filter(e=>e.username!==t.username),onBack:()=>s(null),onSaved:e=>{a(e),r(``),c()}},t.username):(0,B.jsx)(`div`,{className:`set-pane`,children:(0,B.jsxs)(`section`,{className:`set-card`,children:[(0,B.jsx)(`h4`,{className:`set-h4`,children:`That account is no longer listed`}),(0,B.jsx)(`p`,{className:`set-help`,children:`It may have been removed since this list was loaded.`}),(0,B.jsx)(`div`,{className:`set-actions`,children:(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,onClick:()=>s(null),children:`Back to accounts`})})]})})}return(0,B.jsxs)(`div`,{className:`set-pane`,children:[(0,B.jsx)(`h3`,{className:`set-h`,children:`Accounts`}),n?(0,B.jsx)(`p`,{className:`set-error`,children:n}):null,i?(0,B.jsx)(`p`,{className:`set-notice`,children:i}):null,e.length===0&&!n?(0,B.jsx)(`p`,{className:`pg-empty`,children:`No accounts are configured on this deployment yet.`}):(0,B.jsx)(`ul`,{className:`set-acctlist`,children:e.map(e=>(0,B.jsx)(`li`,{children:(0,B.jsxs)(`button`,{type:`button`,className:`set-acct`+(e.active?``:` is-inactive`),onClick:()=>s(e.username),children:[(0,B.jsx)(kqe,{name:e.name||e.username}),(0,B.jsxs)(`span`,{className:`set-acct-body`,children:[(0,B.jsxs)(`span`,{className:`set-acct-top`,children:[(0,B.jsx)(`span`,{className:`set-acct-name`,children:e.name||e.username}),(0,B.jsx)(Aqe,{admin:e.role===`admin`}),e.active?null:(0,B.jsx)(`span`,{className:`set-chip set-chip--off`,children:`Deactivated`})]}),(0,B.jsx)(`span`,{className:`set-acct-sub`,children:e.username}),(0,B.jsx)(`span`,{className:`set-acct-access`,children:e.role===`admin`?`Everything (admin)`:e.accessSummary??Sqe(e.modules)})]}),(0,B.jsxs)(`span`,{className:`set-acct-go`,children:[`Edit`,(0,B.jsx)(Cqe,{})]})]})},e.username))}),(0,B.jsx)(Tqe,{onCreated:e=>{a(e),r(``),c()},onError:r})]})}function Tqe({onCreated:e,onError:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(`user`),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(!1);if(!n)return(0,B.jsx)(`button`,{type:`button`,className:`set-primary set-add`,onClick:()=>r(!0),children:`Add an account`});let m=i.trim().length>0&&u.length>0;return(0,B.jsxs)(`section`,{className:`set-card`,children:[(0,B.jsx)(`h4`,{className:`set-h4`,children:`New account`}),(0,B.jsxs)(`div`,{className:`set-field`,children:[(0,B.jsx)(`label`,{className:`set-label`,htmlFor:`set-new-user`,children:`Username`}),(0,B.jsx)(`input`,{id:`set-new-user`,className:`set-input`,value:i,autoComplete:`off`,onChange:e=>a(e.target.value)}),(0,B.jsx)(`p`,{className:`set-help`,children:`Must be new. To change an existing account, edit it above — re-creating one would revive sessions that were revoked.`})]}),(0,B.jsxs)(`div`,{className:`set-field`,children:[(0,B.jsx)(`label`,{className:`set-label`,htmlFor:`set-new-name`,children:`Display name`}),(0,B.jsx)(`input`,{id:`set-new-name`,className:`set-input`,value:o,onChange:e=>s(e.target.value)})]}),(0,B.jsxs)(`div`,{className:`set-field`,children:[(0,B.jsx)(`label`,{className:`set-label`,htmlFor:`set-new-role`,children:`Role`}),(0,B.jsxs)(`select`,{id:`set-new-role`,className:`pg-select`,value:c,onChange:e=>l(e.target.value),children:[(0,B.jsx)(`option`,{value:`user`,children:`Member`}),(0,B.jsx)(`option`,{value:`admin`,children:`Admin`})]})]}),(0,B.jsxs)(`div`,{className:`set-field`,children:[(0,B.jsx)(`label`,{className:`set-label`,htmlFor:`set-new-pw`,children:`Password`}),(0,B.jsx)(`input`,{id:`set-new-pw`,className:`set-input`,type:`password`,value:u,autoComplete:`new-password`,onChange:e=>d(e.target.value)}),(0,B.jsx)(`p`,{className:`set-help`,children:`A new account starts with access to everything this deployment shows. Open it from the list afterwards to set what they may see.`})]}),(0,B.jsxs)(`div`,{className:`set-actions`,children:[(0,B.jsx)(`button`,{type:`button`,className:`set-primary`,disabled:f||!m,onClick:()=>{p(!0),qKe({username:i.trim().toLowerCase(),name:o||i.trim(),role:c,modules:`all`,password:u}).then(n=>{p(!1),n.ok?(e(`Created ${i.trim().toLowerCase()}.`),r(!1),a(``),s(``),d(``)):t(n.message)})},children:`Create account`}),(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,onClick:()=>r(!1),children:`Cancel`})]})]})}async function Eqe(e){let t=URL.createObjectURL(e);try{let e=new Image;if(await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(`unreadable image`)),e.src=t}),!e.width||!e.height)return null;let n=Math.min(128,Math.max(e.width,e.height)),r=document.createElement(`canvas`);r.width=n,r.height=n;let i=r.getContext(`2d`);if(!i)return null;let a=Math.min(e.width,e.height);return i.drawImage(e,(e.width-a)/2,(e.height-a)/2,a,a,0,0,n,n),r.toDataURL(`image/jpeg`,.85)}catch{return null}finally{URL.revokeObjectURL(t)}}function Dqe(e){return(e.match(/[\p{L}\p{N}]/u)?.[0]??`?`).toUpperCase()}function Oqe({user:e,large:t}){let n=t?`set-avatar set-avatar--lg`:`set-avatar`;return e.avatar?(0,B.jsx)(`img`,{className:n,src:e.avatar,alt:``,"aria-hidden":`true`}):(0,B.jsx)(`span`,{className:n,"aria-hidden":`true`,children:Dqe(e.name)})}function kqe({name:e}){return(0,B.jsx)(`span`,{className:`set-avatar`,"aria-hidden":`true`,children:Dqe(e)})}function Aqe({admin:e}){return(0,B.jsx)(`span`,{className:e?`set-chip set-chip--admin`:`set-chip`,children:e?`Admin`:`Member`})}function jqe({user:e,admin:t,onUser:n}){let[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(``),s=(0,L.useRef)(null),c=(0,L.useCallback)(async e=>{i(!0),o(``);let t=await Eqe(e);if(!t){i(!1),o(`That file could not be read as an image.`);return}let r=await QKe(t);if(i(!1),r.ok){let e=P9(r.data);e&&n?.(e)}else o(r.message)},[n]),l=(0,L.useCallback)(async()=>{i(!0),o(``);let e=await $Ke();if(i(!1),e.ok){let t=P9(e.data);t&&n?.(t)}else o(e.message)},[n]);return(0,B.jsxs)(`div`,{className:`set-identity`,children:[(0,B.jsx)(Oqe,{user:e,large:!0}),(0,B.jsxs)(`div`,{className:`set-identity-body`,children:[(0,B.jsxs)(`div`,{className:`set-identity-head`,children:[(0,B.jsx)(`span`,{className:`set-identity-name`,children:e.name}),(0,B.jsx)(Aqe,{admin:t})]}),(0,B.jsx)(`div`,{className:`set-identity-sub`,children:e.username}),(0,B.jsxs)(`div`,{className:`set-identity-acts`,children:[(0,B.jsx)(`input`,{ref:s,type:`file`,accept:`image/png,image/jpeg`,className:`set-filepick`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c(t)}}),(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,disabled:r,onClick:()=>s.current?.click(),children:e.avatar?`Change photo`:`Upload photo`}),e.avatar?(0,B.jsx)(`button`,{type:`button`,className:`set-secondary`,disabled:r,onClick:l,children:`Remove`}):null]}),a?(0,B.jsx)(`p`,{className:`set-error set-identity-err`,children:a}):null]})]})}function Mqe({user:e,section:t,onSection:n,onClose:r,onUser:i,moduleLabels:a}){let[o,s]=(0,L.useState)(null),c=N9(e);(0,L.useEffect)(()=>{GKe().then(e=>{e.ok&&s(e.data)})},[]),(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let l=[[`account`,`Account`],[`scope`,`Your access`],...c?[[`users`,`Manage users`]]:[]],u=eqe(t,c);return(0,B.jsx)(`div`,{className:`set-backdrop`,onMouseDown:e=>{e.target===e.currentTarget&&r()},children:(0,B.jsxs)(`div`,{className:`set-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Profile`,children:[(0,B.jsxs)(`nav`,{className:`set-rail`,children:[(0,B.jsx)(`span`,{className:`set-rail-cap`,children:`Profile`}),l.map(([e,t])=>(0,B.jsx)(`button`,{type:`button`,className:`set-rail-item`+(u===e?` is-active`:``),onClick:()=>n(e),children:t},e))]}),(0,B.jsxs)(`div`,{className:`set-body`,children:[(0,B.jsx)(`button`,{type:`button`,className:`set-close`,onClick:r,"aria-label":`Close profile`,children:`×`}),u===`account`?(0,B.jsxs)(`div`,{className:`set-pane`,children:[(0,B.jsx)(`h3`,{className:`set-h`,children:`Account`}),(0,B.jsx)(jqe,{user:e,admin:c,onUser:i})]}):null,u===`scope`?(0,B.jsxs)(`div`,{className:`set-pane`,children:[(0,B.jsx)(`h3`,{className:`set-h`,children:`Your access`}),(0,B.jsx)(`p`,{className:`set-help set-pane-intro`,children:`What this account may open, and anything that narrows it. Only an administrator can change this.`}),(0,B.jsxs)(`section`,{className:`set-card set-card--rows`,children:[(0,B.jsxs)(`div`,{className:`pg-drill-row`,children:[(0,B.jsx)(`span`,{className:`pg-drill-key`,children:`Modules`}),(0,B.jsx)(`span`,{className:`pg-drill-val`,children:Sqe(o?.scope.modules??e.modules)})]}),c?(0,B.jsxs)(`div`,{className:`pg-drill-row`,children:[(0,B.jsx)(`span`,{className:`pg-drill-key`,children:`Restrictions`}),(0,B.jsx)(`span`,{className:`pg-drill-val`,children:`None apply — administrators bypass every rule`})]}):null,c?null:Object.entries(o?.scope.perms??{}).map(([e,t])=>{let n=H9(sqe(t));return n===`Full access`?null:(0,B.jsxs)(`div`,{className:`pg-drill-row`,children:[(0,B.jsx)(`span`,{className:`pg-drill-key`,children:a?.[e]??e}),(0,B.jsx)(`span`,{className:`pg-drill-val`,children:n})]},e)})]})]}):null,u===`users`?(0,B.jsx)(wqe,{}):null]})]})})}var Nqe=`./favicon.svg`;function Pqe({size:e}){return(0,B.jsx)(`img`,{className:`lp-mark`,src:Nqe,width:e,height:e,alt:``,"aria-hidden":`true`,draggable:!1})}function K9({size:e,className:t}){return(0,B.jsxs)(`div`,{className:t,children:[(0,B.jsx)(Pqe,{size:e}),(0,B.jsx)(`span`,{className:`lp-wordmark`,children:`Loopable`})]})}function Fqe({off:e}){return(0,B.jsxs)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M2.2 10s2.8-4.6 7.8-4.6S17.8 10 17.8 10 15 14.6 10 14.6 2.2 10 2.2 10z`}),(0,B.jsx)(`circle`,{cx:`10`,cy:`10`,r:`2.3`}),e?(0,B.jsx)(`path`,{d:`M4 16 16 4`}):null]})}function Iqe({onSignedIn:e}){let[t,n]=(0,L.useState)(``),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1);async function d(n){if(n.preventDefault(),s)return;c(!0),o(``);let a=await HKe(t,r);if(a.ok){e(a.user);return}c(!1),o(a.message),i(``)}function f(e){return t=>{a&&o(``),e(t.target.value)}}return(0,B.jsx)(`div`,{className:`login-root`,children:(0,B.jsxs)(`div`,{className:`login-card`,children:[(0,B.jsx)(K9,{size:44,className:`login-brand`}),(0,B.jsxs)(`form`,{className:`login-form`,onSubmit:d,noValidate:!0,children:[(0,B.jsx)(`label`,{className:`lp-sr-only`,htmlFor:`login-username`,children:`Username`}),(0,B.jsx)(`input`,{id:`login-username`,className:`login-input`,name:`username`,type:`text`,autoComplete:`username`,placeholder:`Username`,value:t,onChange:f(n),disabled:s,"aria-invalid":a?!0:void 0}),(0,B.jsx)(`label`,{className:`lp-sr-only`,htmlFor:`login-password`,children:`Password`}),(0,B.jsxs)(`div`,{className:`login-field`,children:[(0,B.jsx)(`input`,{id:`login-password`,className:`login-input`,name:`password`,type:l?`text`:`password`,autoComplete:`current-password`,placeholder:`Password`,value:r,onChange:f(i),disabled:s,"aria-invalid":a?!0:void 0}),(0,B.jsx)(`button`,{type:`button`,className:`login-eye`,"aria-label":l?`Hide password`:`Show password`,onClick:()=>u(e=>!e),disabled:s,tabIndex:-1,children:(0,B.jsx)(Fqe,{off:l})})]}),(0,B.jsx)(`button`,{className:`login-submit`,type:`submit`,disabled:s,children:s?`Signing in…`:`Log in`})]}),(0,B.jsx)(`p`,{className:`login-msg`,role:`status`,"aria-live":`polite`,children:a})]})})}function Lqe(e){let t=e?.pages;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e,r=typeof t.key==`string`?t.key.trim():``,i=typeof t.label==`string`?t.label.trim():``;!r||!i||n.push({key:r,label:i,...typeof t.source==`string`&&t.source?{source:t.source}:{},...typeof t.parent==`string`&&t.parent?{parent:t.parent}:{},...t.group_only===!0?{group_only:!0}:{},...t.chrome===`main`||t.chrome===`utility`?{chrome:t.chrome}:{}})}return n}function Rqe(e){let t=[],n=[];for(let r of e)(r.chrome===`utility`?n:t).push(r);return{main:t,utility:n}}async function zqe(){try{let e=await fetch(`${Pd}/nav`,{credentials:Fd});return e.ok?{ok:!0,pages:Lqe(await e.json())}:{ok:!1,status:e.status}}catch{return{ok:!1,status:0}}}var q9={folders:[],placement:{}};function Bqe(e){let t=e?.prefs??e;if(!t||typeof t!=`object`)return q9;let n=t,r=[],i=new Set;if(Array.isArray(n.folders))for(let e of n.folders.slice(0,16)){if(!e||typeof e!=`object`)continue;let t=String(e.id??``).trim().slice(0,40),n=String(e.name??``).trim().replace(/\s+/g,` `).slice(0,40);!t||i.has(t)||!n||(i.add(t),r.push({id:t,name:n}))}let a={};if(n.placement&&typeof n.placement==`object`)for(let[e,t]of Object.entries(n.placement)){let n=String(t??``).slice(0,40);e&&i.has(n)&&(a[e.slice(0,60)]=n)}return{folders:r,placement:a}}async function Vqe(){try{let e=await fetch(`${Pd}/nav/prefs`,{credentials:Fd});return e.ok?Bqe(await e.json()):q9}catch{return q9}}async function Hqe(e){try{return(await fetch(`${Pd}/nav/prefs`,{method:`POST`,credentials:Fd,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).ok}catch{return!1}}function Uqe(e,t,n){let r=[];for(let t of e)t.depth>0&&r.length>0?r[r.length-1].children.push(t):r.push({head:t,children:[]});let i=new Map,a=[],o=new Set(t.folders.map(e=>e.id));for(let e of r){let n=t.placement[e.head.key];if(n&&o.has(n)){let t=i.get(n);t?t.push(e):i.set(n,[e])}else a.push(e)}let s=[],c=(e,t)=>{s.push({kind:`entry`,entry:e.head,...t?{folderId:t}:{}});for(let n of e.children)s.push({kind:`entry`,entry:n,...t?{folderId:t}:{}})};for(let e of t.folders){let t=i.get(e.id)??[],r=!n.has(e.id);if(s.push({kind:`folder`,folder:e,count:t.length,open:r}),r)for(let n of t)c(n,e.id)}for(let e of a)c(e);return s}function Wqe(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.key!=`string`||typeof t.label!=`string`)return null;let n=[];if(Array.isArray(t.fields))for(let e of t.fields){if(!e||typeof e!=`object`)continue;let t=e;typeof t.key!=`string`||typeof t.label!=`string`||n.push({key:t.key,label:t.label,type:String(t.type??``),source:String(t.source??``),description:String(t.description??``),...Array.isArray(t.options)?{options:t.options.map(String)}:{}})}let r=[];if(Array.isArray(t.measures))for(let e of t.measures){if(!e||typeof e!=`object`)continue;let t=e;typeof t.key!=`string`||!t.key||r.push({key:t.key,label:String(t.label??t.key),type:String(t.type??``)})}return{key:t.key,label:t.label,source:String(t.source??``),fields:n,measures:r,...typeof t.note==`string`&&t.note?{note:t.note}:{}}}async function Gqe(e){try{let t=await fetch(`${Pd}/nav/schema/${encodeURIComponent(e)}`,{credentials:Fd});return t.ok?Wqe(await t.json()):null}catch{return null}}var Kqe=new Set([`customer_data`,`product_data`]),qqe=new Set([]);function J9(e,t){return`${e}/?page=${encodeURIComponent(t)}`}function Jqe(e,t){let n=new Set(e.map(e=>e.key)),r=new Map;for(let t of e){if(!t.parent||!n.has(t.parent))continue;let e=r.get(t.parent);e?e.push(t):r.set(t.parent,[t])}let i=(e,n)=>{let i=Kqe.has(e.key),a=i?`native`:e.group_only||r.has(e.key)?`group`:`handoff`;return{key:e.key,label:e.label,...e.source?{source:e.source}:{},kind:a,depth:n,...a===`group`?{}:{href:i?`#/${e.key}`:J9(t,e.key)}}},a=[];for(let t of e){if(t.parent&&n.has(t.parent))continue;let e=i(t,0),o=r.get(t.key)??[];if(!(e.kind===`group`&&o.length===0)){a.push(e);for(let e of o)a.push(i(e,1))}}return a}var Yqe=[`customer_data`];function Xqe(e){for(let t of Yqe){let n=e.find(e=>e.key===t&&e.kind===`native`);if(n)return n.key}return e.find(e=>e.kind===`native`)?.key??e.find(e=>e.kind!==`group`)?.key??``}function Zqe(e,t){let n=e.findIndex(e=>e.key===t);if(n>=0){let t=e[n];if(t.kind!==`group`)return t;for(let r of e.slice(n+1)){if(r.depth<=t.depth)break;if(r.kind!==`group`)return r}}let r=Xqe(e);return e.find(e=>e.key===r)}function Qqe(){return(0,B.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`shell-dots-icon`,children:[(0,B.jsx)(`circle`,{cx:`8`,cy:`3.2`,r:`1.35`}),(0,B.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.35`}),(0,B.jsx)(`circle`,{cx:`8`,cy:`12.8`,r:`1.35`})]})}function $qe(){return(0,B.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`shell-nav-icon`,children:(0,B.jsx)(`path`,{d:`M2.2 4.4c0-.66.54-1.2 1.2-1.2h3l1.4 1.6h4.8c.66 0 1.2.54 1.2 1.2v6c0 .66-.54 1.2-1.2 1.2H3.4c-.66 0-1.2-.54-1.2-1.2z`})})}function eJe(){let[e,t]=(0,L.useState)(null),n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(!e)return;let r=e=>{n.current&&!n.current.contains(e.target)&&t(null)},i=e=>{e.key===`Escape`&&t(null)};return document.addEventListener(`mousedown`,r,!0),document.addEventListener(`keydown`,i,!0),()=>{document.removeEventListener(`mousedown`,r,!0),document.removeEventListener(`keydown`,i,!0)}},[e]),{at:e,ref:n,openFrom:e=>{let n=e.getBoundingClientRect();t({x:Math.round(n.right+4),y:Math.round(n.top)})},close:()=>t(null)}}function tJe({at:e,menuRef:t,children:n}){return(0,B.jsx)(`div`,{className:`shell-navmenu`,style:{left:Math.min(e.x,Math.max(8,window.innerWidth-248)),top:Math.min(e.y,Math.max(8,window.innerHeight-260))},ref:t,role:`menu`,children:n})}function nJe({entryLabel:e,canSchema:t,onSchema:n}){let{at:r,ref:i,openFrom:a,close:o}=eJe();return t?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:`shell-dots`,"aria-label":`Options for ${e}`,"aria-haspopup":`menu`,onClick:e=>{e.preventDefault(),e.stopPropagation(),a(e.currentTarget)},children:(0,B.jsx)(Qqe,{})}),r&&(0,B.jsx)(tJe,{at:r,menuRef:i,children:(0,B.jsx)(`button`,{type:`button`,className:`shell-navmenu-item`,onClick:()=>{o(),n()},children:`View schema`})})]}):null}function rJe({onCreate:e}){let[t,n]=(0,L.useState)(!1),[r,i]=(0,L.useState)(``),a=()=>{let t=r.trim().replace(/\s+/g,` `);t&&(e(t),i(``),n(!1))};return t?(0,B.jsxs)(`form`,{className:`shell-navmenu-form shell-newfolder-form`,onSubmit:e=>{e.preventDefault(),a()},children:[(0,B.jsx)(`input`,{className:`shell-navmenu-input`,autoFocus:!0,maxLength:40,placeholder:`Folder name`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(i(``),n(!1))}}),(0,B.jsx)(`button`,{type:`submit`,className:`shell-navmenu-go`,disabled:!r.trim(),children:`Add`})]}):(0,B.jsx)(`button`,{type:`button`,className:`shell-newfolder`,onClick:()=>n(!0),children:`+ New folder`})}function iJe({folder:e,count:t,open:n,collapsed:r,onToggle:i,onRename:a,onDelete:o,isDrop:s,dropProps:c}){let{at:l,ref:u,openFrom:d,close:f}=eJe(),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(e.name),_=()=>{let t=h.trim().replace(/\s+/g,` `);t&&t!==e.name&&a(t),m(!1),f()};return r?null:(0,B.jsxs)(`div`,{className:`shell-nav-folder`+(s?` is-drop`:``),...c??{},children:[(0,B.jsxs)(`button`,{type:`button`,className:`shell-nav-folderbtn`,"aria-expanded":n,onClick:i,children:[(0,B.jsx)($qe,{}),(0,B.jsx)(`span`,{className:`shell-nav-label`,children:e.name}),(0,B.jsx)(`span`,{className:`shell-nav-foldercount`,children:t})]}),(0,B.jsx)(`button`,{type:`button`,className:`shell-dots`,"aria-label":`Options for folder ${e.name}`,"aria-haspopup":`menu`,onClick:t=>{t.stopPropagation(),g(e.name),m(!1),d(t.currentTarget)},children:(0,B.jsx)(Qqe,{})}),l&&(0,B.jsxs)(tJe,{at:l,menuRef:u,children:[p?(0,B.jsxs)(`form`,{className:`shell-navmenu-form`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,B.jsx)(`input`,{className:`shell-navmenu-input`,autoFocus:!0,maxLength:40,value:h,onChange:e=>g(e.target.value)}),(0,B.jsx)(`button`,{type:`submit`,className:`shell-navmenu-go`,disabled:!h.trim(),children:`Save`})]}):(0,B.jsx)(`button`,{type:`button`,className:`shell-navmenu-item`,onClick:()=>m(!0),children:`Rename folder`}),(0,B.jsx)(`button`,{type:`button`,className:`shell-navmenu-item is-danger`,onClick:()=>{f(),o()},children:`Delete folder`})]})]})}function aJe({schemaKey:e,onClose:t}){let[n,r]=(0,L.useState)({phase:`loading`});return(0,L.useEffect)(()=>{let t=!1;return r({phase:`loading`}),Gqe(e).then(e=>{t||r(e?{phase:`ready`,schema:e}:{phase:`error`})}),()=>{t=!0}},[e]),(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]),(0,B.jsx)(`div`,{className:`shell-schema-backdrop`,onMouseDown:t,children:(0,B.jsxs)(`aside`,{className:`shell-schema`,role:`dialog`,"aria-label":`Database schema`,onMouseDown:e=>e.stopPropagation(),children:[n.phase===`loading`&&(0,B.jsx)(`div`,{className:`shell-schema-empty is-spin`,children:(0,B.jsx)(`span`,{className:`lp-spin lp-spin--lg`,role:`status`,"aria-label":`Loading`})}),n.phase===`error`&&(0,B.jsx)(`div`,{className:`shell-schema-empty`,children:`The schema could not be loaded. Close this panel and try again.`}),n.phase===`ready`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`header`,{className:`shell-schema-head`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`shell-schema-title`,children:n.schema.label}),n.schema.source&&(0,B.jsxs)(`div`,{className:`shell-schema-sub`,children:[`Source · `,n.schema.source]})]}),(0,B.jsx)(`button`,{type:`button`,className:`shell-schema-close`,"aria-label":`Close schema`,onClick:t,children:`×`})]}),(0,B.jsxs)(`div`,{className:`shell-schema-body`,children:[n.schema.note&&(0,B.jsx)(`div`,{className:`shell-schema-note`,children:n.schema.note}),n.schema.fields.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`shell-schema-kicker`,children:[`Fields · `,n.schema.fields.length]}),(0,B.jsxs)(`table`,{className:`shell-schema-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:`Field`}),(0,B.jsx)(`th`,{children:`Type`}),(0,B.jsx)(`th`,{children:`Source`})]})}),(0,B.jsx)(`tbody`,{children:n.schema.fields.map(e=>(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`td`,{children:[(0,B.jsx)(`div`,{className:`shell-schema-fname`,children:e.label}),e.description&&(0,B.jsx)(`div`,{className:`shell-schema-fdesc`,children:e.description}),e.options&&(0,B.jsxs)(`div`,{className:`shell-schema-fdesc`,children:[`Choices: `,e.options.join(` · `)]})]}),(0,B.jsx)(`td`,{className:`shell-schema-type`,children:e.type}),(0,B.jsx)(`td`,{className:`shell-schema-type`,children:e.source})]},e.key))})]})]}),n.schema.measures.length>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`shell-schema-kicker`,children:[`Semantic measures · `,n.schema.measures.length]}),(0,B.jsx)(`div`,{className:`shell-schema-measures`,children:n.schema.measures.map(e=>(0,B.jsxs)(`div`,{className:`shell-schema-measure`,children:[(0,B.jsx)(`span`,{className:`shell-schema-fname`,children:e.label}),(0,B.jsx)(`span`,{className:`shell-schema-type`,children:e.type})]},e.key))})]})]})]})]})})}var Y9=`https://royal-imports-cfo-os.hf.space`,X9=`login`,Z9=`application/x-loopable-nav`,oJe=[],sJe=[];function cJe(){let e=()=>window.location.hash.replace(/^#\/?/,``),[t,n]=(0,L.useState)(e);return(0,L.useEffect)(()=>{let t=()=>n(e());return window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},[]),t}function lJe({entry:e}){return(0,B.jsxs)(`div`,{className:`shell-placeholder`,children:[(0,B.jsx)(`h1`,{children:e.label}),(0,B.jsx)(`p`,{children:`This surface runs in the current application.`}),(0,B.jsxs)(`a`,{className:`shell-link`,href:e.href,target:`_blank`,rel:`noreferrer`,children:[`Open `,e.label]})]})}function uJe(){return(0,B.jsxs)(`svg`,{className:`shell-nav-icon`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,B.jsx)(`ellipse`,{cx:`8`,cy:`3.6`,rx:`5.3`,ry:`2.1`}),(0,B.jsx)(`path`,{d:`M2.7 3.6v8.8c0 1.16 2.37 2.1 5.3 2.1s5.3-.94 5.3-2.1V3.6`}),(0,B.jsx)(`path`,{d:`M2.7 8c0 1.16 2.37 2.1 5.3 2.1S13.3 9.16 13.3 8`})]})}function dJe(){return(0,B.jsxs)(`svg`,{className:`shell-nav-icon is-spark`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M6.2 2.2 7.5 5.5l3.3 1.3-3.3 1.3-1.3 3.3-1.3-3.3-3.3-1.3 3.3-1.3z`}),(0,B.jsx)(`path`,{d:`M12.2 9.4l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8z`})]})}function Q9(){return(0,B.jsx)(`svg`,{className:`shell-nav-open`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M4.6 3h4.4v4.4M8.8 3.2 3.2 8.8`})})}function fJe(){return(0,B.jsxs)(`svg`,{className:`shell-account-dots`,viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,B.jsx)(`circle`,{cx:`3.5`,cy:`8`,r:`1.25`}),(0,B.jsx)(`circle`,{cx:`8`,cy:`8`,r:`1.25`}),(0,B.jsx)(`circle`,{cx:`12.5`,cy:`8`,r:`1.25`})]})}function pJe(){return(0,B.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:(0,B.jsx)(`path`,{d:`M2.5 4.4h11M2.5 8h11M2.5 11.6h11`,stroke:`currentColor`,strokeWidth:`1.35`,strokeLinecap:`round`})})}function mJe({user:e,utility:t,onSignOut:n,onSettings:r}){let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null);(0,L.useEffect)(()=>{if(!i)return;let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=(e.name.match(/[\p{L}\p{N}]/u)?.[0]??``).toUpperCase(),c=t.filter(e=>e.key!==`analyst`);return(0,B.jsxs)(`div`,{className:`shell-account-wrap`,ref:o,children:[i?(0,B.jsxs)(`div`,{className:`shell-menu`,role:`menu`,children:[(0,B.jsx)(`button`,{type:`button`,className:`shell-menu-item`,role:`menuitem`,onClick:()=>{a(!1),r(`account`)},children:`Profile`}),N9(e)?(0,B.jsx)(`button`,{type:`button`,className:`shell-menu-item`,role:`menuitem`,onClick:()=>{a(!1),r(`users`)},children:`Manage users`}):null,c.length?(0,B.jsx)(`div`,{className:`shell-menu-rule`,role:`separator`}):null,c.map(e=>(0,B.jsxs)(`a`,{className:`shell-menu-item`,role:`menuitem`,href:J9(Y9,e.key),target:`_blank`,rel:`noreferrer`,onClick:()=>a(!1),children:[e.label,(0,B.jsx)(Q9,{})]},e.key)),(0,B.jsx)(`div`,{className:`shell-menu-rule`,role:`separator`}),(0,B.jsx)(`button`,{type:`button`,className:`shell-menu-item is-signout`,role:`menuitem`,onClick:()=>{a(!1),n()},children:`Sign out`})]}):null,(0,B.jsxs)(`button`,{type:`button`,className:`shell-account`,"aria-haspopup":`menu`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[e.avatar?(0,B.jsx)(`img`,{className:`shell-avatar`,src:e.avatar,alt:``,"aria-hidden":`true`,style:{objectFit:`cover`,padding:0}}):(0,B.jsx)(`span`,{className:`shell-avatar`,"aria-hidden":`true`,children:s}),(0,B.jsxs)(`span`,{className:`shell-account-who`,children:[(0,B.jsx)(`span`,{className:`shell-account-name`,children:e.name}),(0,B.jsx)(`span`,{className:`shell-account-role`,children:N9(e)?`Admin`:`Member`})]}),(0,B.jsx)(fJe,{})]})]})}function hJe(){let[e,t]=(0,L.useState)({phase:`checking`}),[n,r]=(0,L.useState)({phase:`idle`}),[i,a]=(0,L.useState)(``),[o,s]=(0,L.useState)(``),[c,l]=(0,L.useState)(null),u=cJe(),[d,f]=(0,L.useState)(()=>{try{return localStorage.getItem(`aios-nav-collapsed`)===`1`}catch{return!1}});(0,L.useEffect)(()=>{try{localStorage.setItem(`aios-nav-collapsed`,d?`1`:`0`)}catch{}},[d]);let[p,m]=(0,L.useState)(null);(0,L.useEffect)(()=>{d||m(null)},[d]);let h=(0,L.useCallback)(e=>t=>{let n=t.currentTarget.getBoundingClientRect();m({label:e,y:n.top+n.height/2})},[]),g=(0,L.useCallback)(()=>m(null),[]);(0,L.useEffect)(()=>{let e=()=>t({phase:`anon`}),n=e=>a(String(e.detail??``)||`The data could not be loaded.`),r=e=>s(String(e.detail??``)),i=()=>f(!0);return window.addEventListener(Id,e),window.addEventListener(Ld,n),window.addEventListener(Rd,r),window.addEventListener(Vd,i),()=>{window.removeEventListener(Id,e),window.removeEventListener(Ld,n),window.removeEventListener(Rd,r),window.removeEventListener(Vd,i)}},[]),(0,L.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>s(``),6e3);return()=>clearTimeout(e)},[o]),(0,L.useEffect)(()=>{let e=!1;return UKe().then(n=>{e||t(n?{phase:`authed`,user:n}:{phase:`anon`})}),()=>{e=!0}},[]);let _=e.phase===`authed`?e.user.username:null;(0,L.useEffect)(()=>{if(_===null){r({phase:`idle`});return}let e=!1;return r({phase:`loading`}),a(``),s(``),zqe().then(n=>{if(!e)if(n.ok){let{main:e,utility:t}=Rqe(n.pages);r({phase:`ready`,entries:Jqe(e,Y9),utility:t})}else n.status===401?t({phase:`anon`}):r({phase:`error`})}),()=>{e=!0}},[_]);let v=n.phase===`ready`?n.entries:oJe,[y,b]=(0,L.useState)(q9),x=(0,L.useRef)(y);x.current=y;let[S,C]=(0,L.useState)(new Set),[w,T]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(_===null){b(q9),T(null);return}let e=!1;return Vqe().then(t=>{e||b(t)}),()=>{e=!0}},[_]);let E=(0,L.useCallback)(e=>{let t=x.current;b(e),Hqe(e).then(e=>{e||(b(t),s(`The folder change was not saved — the store refused the write.`))})},[]),D=(0,L.useCallback)((e,t)=>{let n=x.current,r={...n.placement};t?r[e]=t:delete r[e],E({folders:n.folders,placement:r})},[E]),O=(0,L.useCallback)((e,t)=>{let n=x.current;E({folders:n.folders.map(n=>n.id===e?{...n,name:t}:n),placement:n.placement})},[E]),k=(0,L.useCallback)(e=>{let t=x.current;E({folders:t.folders.filter(t=>t.id!==e),placement:Object.fromEntries(Object.entries(t.placement).filter(([,t])=>t!==e))})},[E]),A=(0,L.useCallback)(e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[j,M]=(0,L.useState)(null),[ee,N]=(0,L.useState)(null),te=(0,L.useCallback)(e=>{let t=x.current;if(t.folders.length>=16){s(`At most 16 folders.`);return}let n=`nf_${Date.now().toString(36)}${Math.floor(Math.random()*1e6).toString(36)}`;E({folders:[...t.folders,{id:n,name:e}],placement:t.placement})},[E]);(0,L.useEffect)(()=>{e.phase===`anon`&&u!==X9?window.location.hash=`#/${X9}`:e.phase===`authed`&&u===X9&&v.length&&(window.location.hash=`#/${Xqe(v)}`)},[e.phase,u,v]);let ne=(0,L.useCallback)(()=>{ef(),WKe().then(()=>t({phase:`anon`}))},[]);if(e.phase===`checking`)return(0,B.jsx)(`div`,{className:`shell-boot`,children:(0,B.jsx)(K9,{size:44,className:`login-brand`})});if(e.phase===`anon`)return(0,B.jsx)(Iqe,{onSignedIn:e=>{ef(),t({phase:`authed`,user:e})}});let P=Zqe(v,u),re=n.phase===`ready`?n.utility:sJe,F=re.find(e=>e.key===`analyst`);return(0,B.jsxs)(`div`,{className:`shell-root`,children:[(0,B.jsxs)(`aside`,{className:`shell-side`+(d?` is-collapsed`:``),children:[(0,B.jsxs)(`div`,{className:`shell-side-head`,children:[(0,B.jsx)(`button`,{type:`button`,className:`shell-brand-btn`,disabled:!d,"aria-label":d?`Expand navigation`:void 0,onMouseEnter:d?h(`Expand navigation`):void 0,onMouseLeave:d?g:void 0,onClick:()=>f(!1),children:(0,B.jsx)(K9,{size:26,className:`shell-brand`})}),(0,B.jsx)(`button`,{type:`button`,className:`shell-rail-toggle`,"aria-label":`Minimize navigation`,"aria-expanded":!d,title:`Minimize navigation`,onClick:()=>f(!0),children:(0,B.jsx)(pJe,{})})]}),(0,B.jsxs)(`nav`,{className:`shell-nav`,children:[F?(0,B.jsxs)(`a`,{className:`shell-nav-item shell-nav-assist`,href:J9(Y9,`analyst`),target:`_blank`,rel:`noreferrer`,onMouseEnter:d?h(`AI assistant`):void 0,onMouseLeave:d?g:void 0,children:[(0,B.jsx)(dJe,{}),(0,B.jsx)(`span`,{className:`shell-nav-label`,children:`AI assistant`}),(0,B.jsx)(Q9,{})]}):null,(0,B.jsxs)(`div`,{className:`shell-nav-list`+(ee===`__root__`?` is-drop-root`:``),onDragOver:e=>{e.dataTransfer.types.includes(Z9)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,N(`__root__`))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||N(null)},onDrop:e=>{let t=e.dataTransfer.getData(Z9);N(null),M(null),t&&(e.preventDefault(),D(t,null))},children:[Uqe(v,d?q9:y,S).map(e=>{if(e.kind===`folder`)return(0,B.jsx)(iJe,{folder:e.folder,count:e.count,open:e.open,collapsed:d,onToggle:()=>A(e.folder.id),onRename:t=>O(e.folder.id,t),onDelete:()=>k(e.folder.id),isDrop:ee===e.folder.id,dropProps:{onDragOver:t=>{t.dataTransfer.types.includes(Z9)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`move`,N(e.folder.id))},onDrop:t=>{let n=t.dataTransfer.getData(Z9);N(null),M(null),n&&(t.preventDefault(),t.stopPropagation(),D(n,e.folder.id))}}},`folder:${e.folder.id}`);let t=e.entry,n=!!P&&P.key===t.key,r=`shell-nav-item`+(t.depth>0?` is-child`:``)+(n?` is-active`:``),i=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(uJe,{}),(0,B.jsx)(`span`,{className:`shell-nav-label`,children:t.label}),t.kind===`handoff`?(0,B.jsx)(Q9,{}):null]});if(t.kind===`group`)return(0,B.jsx)(`div`,{className:`shell-nav-group`,children:i},t.key);let a=d?{onMouseEnter:h(t.label),onMouseLeave:g}:{},o=t.kind===`native`?(0,B.jsx)(`a`,{className:r,href:t.href,...a,children:i}):(0,B.jsx)(`a`,{className:r,href:t.href,target:`_blank`,rel:`noreferrer`,...a,children:i});return(0,B.jsxs)(`div`,{className:`shell-nav-row`+(n?` is-active`:``)+(e.folderId?` is-foldered`:``)+(j===t.key?` is-dragging`:``),draggable:!d&&t.depth===0,onDragStart:e=>{e.dataTransfer.setData(Z9,t.key),e.dataTransfer.effectAllowed=`move`,M(t.key)},onDragEnd:()=>{M(null),N(null)},children:[o,!d&&t.depth===0&&(0,B.jsx)(nJe,{entryLabel:t.label,canSchema:!0,onSchema:()=>T(t.key)})]},t.key)}),!d&&n.phase===`ready`&&v.length>0?(0,B.jsx)(rJe,{onCreate:te}):null]}),n.phase===`loading`?(0,B.jsx)(`div`,{className:`shell-nav-note is-spin`,children:(0,B.jsx)(`span`,{className:`lp-spin`,role:`status`,"aria-label":`Loading`})}):null,n.phase===`error`?(0,B.jsx)(`div`,{className:`shell-nav-note`,children:`Navigation unavailable. Reload to retry.`}):null,n.phase===`ready`&&v.length===0?(0,B.jsx)(`div`,{className:`shell-nav-note`,children:`No surfaces are available to this account.`}):null]}),(0,B.jsx)(`div`,{className:`shell-side-bottom`,onClickCapture:d?e=>{e.preventDefault(),e.stopPropagation(),f(!1)}:void 0,onMouseEnter:d?h(e.user.name):void 0,onMouseLeave:d?g:void 0,children:(0,B.jsx)(mJe,{user:e.user,utility:re,onSignOut:ne,onSettings:l})})]}),p?(0,B.jsx)(`div`,{className:`shell-nav-tip`,style:{top:p.y},role:`tooltip`,"aria-hidden":`true`,children:p.label}):null,(0,B.jsx)(`main`,{className:`shell-main`,children:i&&P?.kind===`native`?(0,B.jsxs)(`div`,{className:`shell-placeholder`,children:[(0,B.jsx)(`h1`,{children:P.label}),(0,B.jsx)(`p`,{children:i}),(0,B.jsx)(`button`,{className:`login-submit shell-retry`,type:`button`,onClick:()=>window.location.reload(),children:`Retry`})]}):P?.kind===`native`&&qqe.has(P.key)?(0,B.jsx)(IKe,{pageKey:P.key,label:P.label},P.key):P?.kind===`native`?(0,B.jsx)(`div`,{className:`shell-grid-host`,children:(0,B.jsx)(jp,{children:(0,B.jsx)(iKe,{scope:P.key===`product_data`?`product`:`customer`},P.key)})}):P?(0,B.jsx)(lJe,{entry:P}):n.phase===`ready`||n.phase===`error`?(0,B.jsxs)(`div`,{className:`shell-placeholder`,children:[(0,B.jsx)(`h1`,{children:`Nothing to show`}),(0,B.jsx)(`p`,{children:n.phase===`error`?`The navigation service did not answer. Reload to retry.`:`This account has access to no surfaces yet.`})]}):(0,B.jsx)(`div`,{className:`shell-loading`,children:(0,B.jsx)(`span`,{className:`lp-spin lp-spin--lg`,role:`status`,"aria-label":`Loading`})})}),c?(0,B.jsx)(Mqe,{user:e.user,section:c,onSection:l,onClose:()=>l(null),onUser:e=>t({phase:`authed`,user:e}),moduleLabels:Object.fromEntries(v.map(e=>[e.key,e.label]))}):null,w?(0,B.jsx)(aJe,{schemaKey:w,onClose:()=>T(null)}):null,o?(0,B.jsx)(`div`,{className:`shell-toast`,role:`status`,"aria-live":`polite`,children:o}):null]})}var $9=Gd()||window.__AIOS_GRID__!==void 0;function gJe(){return $9?(0,B.jsx)(`div`,{style:{width:`100%`,height:`100%`,overflow:`hidden`},children:(0,B.jsx)(jp,{children:(0,B.jsx)(iKe,{})})}):(0,B.jsx)(hJe,{})}qee(),$9||ite(),(0,y.createRoot)(document.getElementById(`root`)).render((0,B.jsx)(L.StrictMode,{children:(0,B.jsx)(gJe,{})})); - diff --git a/web/src/apiContract.ts b/web/src/apiContract.ts index 8a5db81281db05d03749161651c7ce7d0317675a..8dab35e12624fae286996b58ab027b12e7fc2b58 100644 --- a/web/src/apiContract.ts +++ b/web/src/apiContract.ts @@ -76,6 +76,12 @@ export const WORKSPACE_STALE_EVENT = "aios:workspace-stale"; * which is exactly the host-neutral contract the other signals follow. */ export const NAV_MINIMIZE_EVENT = "aios:nav-minimize"; +/** Wave 18 (C3-UT): rows changed OUTSIDE the grid's own write path — a shell "Add record", + * an automation run — and the current topic's rows should be refetched. The grid clears its + * rows cache and reloads; senders call `clearCustomersCache()` first so the refetch cannot + * be served from the 5-minute memo. */ +export const ROWS_STALE_EVENT = "aios:rows-stale"; + export function signal(name: string, detail?: unknown): void { if (typeof window === "undefined") return; window.dispatchEvent(new CustomEvent(name, { detail })); diff --git a/web/src/automation/AutomationEditor.tsx b/web/src/automation/AutomationEditor.tsx new file mode 100644 index 0000000000000000000000000000000000000000..bae5176ba39ec6f98719b0ec7997bdb349669951 --- /dev/null +++ b/web/src/automation/AutomationEditor.tsx @@ -0,0 +1,662 @@ +// --------------------------------------------------------------------------- +// automation/AutomationEditor.tsx — one automation: what it does, when it runs, +// and what it did last time. +// +// THE SHAPE OF THE SCRAPE FLOW IS THE POINT. You cannot map columns you have not +// seen, so "Read the page" comes BEFORE the field map and the preview is real +// rows off the real URL — not a schema the user is asked to describe from +// memory. The server's `/automations/preview` never writes, so the read is free +// to be taken as many times as it takes to get the mapping right. +// +// EVERY COUNT DRILLS TO ROWS. A run that says "412 updated" opens the 412 +// ([[no-unverifiable-aggregates]]) — a number with no way back to its records is +// exactly what this codebase treats as a defect rather than a summary. +// --------------------------------------------------------------------------- +import { useCallback, useEffect, useMemo, useState } from "react"; + +import type { + Automation, + AutomationKind, + RunEntry, + RunRows, + SourcePreview, + UserTable, +} from "./automationApi"; +import { + AutomationError, + COUNT_LABELS, + createAutomation, + deleteAutomation, + fieldKeyFor, + listTables, + patchAutomation, + previewSource, + runAutomation, + runRows, +} from "./automationApi"; + +interface Props { + automation: Automation | null; + kinds: { key: AutomationKind; label: string }[]; + cronPresets: { cron: string; label: string }[]; + onSaved: (id?: string) => void | Promise; + onDeleted: () => void | Promise; + onCancel: () => void; +} + +interface ColumnPlan { + column: string; + include: boolean; + key: string; +} + +const DEFAULT_CRON = "0 6 * * *"; + +export default function AutomationEditor({ + automation, + kinds, + cronPresets, + onSaved, + onDeleted, + onCancel, +}: Props) { + const isNew = !automation; + const cfg = (automation?.config || {}) as Record; + + const [name, setName] = useState(automation?.name || ""); + const [kind, setKind] = useState(automation?.kind || "scrape_db"); + const [cron, setCron] = useState(automation?.schedule?.cron || DEFAULT_CRON); + const [enabled, setEnabled] = useState(!!automation?.schedule?.enabled); + const [message, setMessage] = useState(""); + const [problem, setProblem] = useState(""); + const [saving, setSaving] = useState(false); + + // --- scrape_db half + const [url, setUrl] = useState(String(cfg.url || "")); + const [extract, setExtract] = useState(String(cfg.extract || "table")); + const [tableIndex, setTableIndex] = useState(Number(cfg.tableIndex || 0)); + const [targetLabel, setTargetLabel] = useState(String(cfg.targetLabel || "")); + const [preview, setPreview] = useState(null); + const [reading, setReading] = useState(false); + const [plan, setPlan] = useState(() => + Object.entries((automation?.config as { fieldMap?: Record })?.fieldMap || {}) + .map(([column, key]) => ({ column, include: true, key })) + ); + const [keyField, setKeyField] = useState(String(cfg.keyField || "")); + + // --- field_instagram half + const [tables, setTables] = useState([]); + const [targetTable, setTargetTable] = useState(String(cfg.targetTable || "")); + const [fieldKey, setFieldKey] = useState(String(cfg.fieldKey || "")); + const [urlField, setUrlField] = useState(String(cfg.urlField || "")); + const [maxPosts, setMaxPosts] = useState(Number(cfg.maxPosts || 24)); + + // --- run history drill + const [drill, setDrill] = useState(null); + const [drillFor, setDrillFor] = useState(""); + + useEffect(() => { + const ac = new AbortController(); + listTables(ac.signal) + .then((r) => setTables(r.tables)) + .catch(() => setTables([])); + return () => ac.abort(); + }, []); + + const table = tables.find((t) => t.key === targetTable) || null; + + const readPage = useCallback(async () => { + setReading(true); + setProblem(""); + try { + const p = await previewSource(url, extract, tableIndex); + setPreview(p); + if (!p.ok) { + setProblem(p.note || `That page answered ${p.status}.`); + return; + } + // Seed the plan from what the page ACTUALLY offers, keeping any mapping the user + // already made for a column that is still there — re-reading a page must not throw + // away the work of mapping it. + setPlan((prev) => { + const had = new Map(prev.map((c) => [c.column, c])); + return p.columns.map((column) => { + const before = had.get(column); + return { + column, + include: before ? before.include : true, + key: before ? before.key : fieldKeyFor(column), + }; + }); + }); + setKeyField((k) => + k && p.columns.some((c) => fieldKeyFor(c) === k) ? k : fieldKeyFor(p.columns[0] || "") + ); + if (!targetLabel) setTargetLabel(p.title || "Scraped table"); + setMessage( + `Read ${p.rowCount} rows and ${p.columns.length} columns` + + (p.tableCount && p.tableCount > 1 ? ` (of ${p.tableCount} tables on the page)` : "") + ); + } catch (e) { + setProblem( + e instanceof AutomationError ? e.message : "That page could not be read." + ); + } finally { + setReading(false); + } + }, [url, extract, tableIndex, targetLabel]); + + const buildConfig = (): Record => { + if (kind === "scrape_db") { + const fieldMap: Record = {}; + for (const c of plan) if (c.include && c.key) fieldMap[c.column] = c.key; + return { + url, + extract, + tableIndex, + fieldMap, + keyField, + targetTable: String(cfg.targetTable || ""), + targetLabel, + }; + } + return { targetTable, fieldKey, urlField, maxPosts }; + }; + + const save = async () => { + setSaving(true); + setProblem(""); + setMessage(""); + const body = { + name, + kind, + config: buildConfig(), + schedule: { cron, enabled }, + }; + try { + const res = automation + ? await patchAutomation(automation.id, body) + : await createAutomation(body); + setMessage("Saved."); + await onSaved(res.automation.id); + } catch (e) { + setProblem(e instanceof AutomationError ? e.message : "That could not be saved."); + } finally { + setSaving(false); + } + }; + + const start = async () => { + if (!automation) return; + setProblem(""); + try { + await runAutomation(automation.id); + setMessage("Started. The rail's status dot follows it."); + await onSaved(automation.id); + } catch (e) { + setProblem(e instanceof AutomationError ? e.message : "It did not start."); + } + }; + + const remove = async () => { + if (!automation) return; + setProblem(""); + try { + await deleteAutomation(automation.id); + await onDeleted(); + } catch (e) { + setProblem(e instanceof AutomationError ? e.message : "It was not deleted."); + } + }; + + const openDrill = async (entry: RunEntry) => { + if (!automation) return; + if (drillFor === entry.ts) { + setDrill(null); + setDrillFor(""); + return; + } + try { + const rows = await runRows(automation.id); + setDrill(rows); + setDrillFor(entry.ts); + } catch (e) { + setProblem(e instanceof AutomationError ? e.message : "Those rows could not be read."); + } + }; + + const presetMatch = useMemo( + () => cronPresets.find((p) => p.cron === cron)?.cron || "", + [cronPresets, cron] + ); + + const canSave = + !!name.trim() && + (kind === "scrape_db" + ? !!url.trim() && plan.some((c) => c.include && c.key === keyField) + : !!targetTable && !!fieldKey); + + return ( +

+
+
+ setName(e.target.value)} + /> + {automation ? ( + + {automation.running ? "Running" : automation.status?.state || "idle"} + + ) : ( + New + )} +
+
+ {automation ? ( + + ) : null} + + {automation ? ( + + ) : ( + + )} +
+
+ + {problem ? ( +
+ {problem} +
+ ) : null} + {message ? ( +
+ {message} +
+ ) : null} + +
+
+

What it does

+ {isNew ? ( +
+ {kinds.map((k) => ( + + ))} +
+ ) : ( +

+ {kinds.find((k) => k.key === kind)?.label || kind} — the kind is fixed once an + automation exists, because its configuration and the database it fills are + shaped by it. +

+ )} + + {kind === "scrape_db" ? ( + <> +
+ +
+ setUrl(e.target.value)} + /> + +
+

+ Public web pages only. Private, loopback and link-local addresses are + refused — including a public URL that redirects to one. +

+
+ +
+
+ + +
+ {extract === "table" ? ( +
+ + setTableIndex(Number(e.target.value) || 0)} + /> +
+ ) : null} +
+ + setTargetLabel(e.target.value)} + /> +
+
+ + {plan.length ? ( +
+

Columns

+

+ Pick the key — the column that identifies a row. On every re-run, a row + whose key already exists is updated; a new key is inserted; a key that + has stopped appearing is counted and kept. +

+ + + + + + + + {preview?.sample?.length ? : null} + + + + {plan.map((c, i) => ( + + + + + + {preview?.sample?.length ? ( + + ) : null} + + ))} + +
UseSource columnField keyKeyFirst value
+ + setPlan((p) => + p.map((x, j) => + j === i ? { ...x, include: e.target.checked } : x + ) + ) + } + /> + {c.column} + + setPlan((p) => + p.map((x, j) => + j === i ? { ...x, key: fieldKeyFor(e.target.value) } : x + ) + ) + } + /> + + setKeyField(c.key)} + /> + + {String(preview.sample[0]?.[c.column] ?? "")} +
+
+ ) : ( +

+ Read the page to see what columns it offers. +

+ )} + + ) : ( + <> +
+
+ + +
+
+ + +
+
+ + +
+
+ + setMaxPosts(Number(e.target.value) || 24)} + /> +
+
+

+ Anonymous public endpoints only — no login and no credentials. Instagram + blocks datacenter addresses and has closed most of its anonymous surface, + so a pull reports what it actually got: ok (profile and + posts), partial (profile only), or blocked. + It never reports success on nothing. +

+ {table && !(table.fields || []).some((f) => f.type === "automation") ? ( +

+ That database has no automation column yet. Add one from the grid’s + column menu, then choose it here. +

+ ) : null} + + )} +
+ +
+

When it runs

+
+
+ + +
+
+ + setCron(e.target.value)} + /> +
+ +
+

+ {automation?.nextRunAt + ? `Next run ${automation.nextRunAt}.` + : enabled + ? "Saved schedules start from the moment they are enabled — enabling a daily job after today's time does not fire it immediately." + : "Disabled. It still runs when you press Run now."} +

+
+ +
+

Run history

+ {!automation?.runs?.length ? ( +

It has not run yet.

+ ) : ( +
    + {automation.runs.map((r) => ( +
  1. + +
    + {COUNT_LABELS.filter(([k]) => typeof r.counts?.[k] === "number").map( + ([k, label]) => ( + + {r.counts[k]} {label} + + ) + )} +
    + {drillFor === r.ts && drill ? ( +
    +

    + The rows this run touched in {drill.label} + {drill.truncated ? " (first 200)" : ""}. +

    +
    + + + + {drill.fields.map((f) => ( + + ))} + + + + {drill.rows.slice(0, 50).map((row) => ( + + {drill.fields.map((f) => ( + + ))} + + ))} + +
    {f.label}
    {String(row[f.key] ?? "")}
    +
    +
    + ) : null} +
  2. + ))} +
+ )} +
+
+
+ ); +} diff --git a/web/src/automation/AutomationSurface.tsx b/web/src/automation/AutomationSurface.tsx new file mode 100644 index 0000000000000000000000000000000000000000..ca000f1e5efaa30176c2ad42210825b14463953f --- /dev/null +++ b/web/src/automation/AutomationSurface.tsx @@ -0,0 +1,287 @@ +// --------------------------------------------------------------------------- +// automation/AutomationSurface.tsx — the Automation surface (contract C-AUTONAV). +// +// ⛔ THE CONTRACT THIS FILE GUARANTEES, verbatim: this module path, a DEFAULT +// export, and NO PROPS. The shell mounts `` and hands it +// nothing; it fetches its own data from `/api/v1/automations`. That is the whole +// interface, and it is stated here because the mount line lives in a file this +// session does not own — a named export would cost a cross-session round trip. +// +// "Automation replaces the Views rail" (owner) is implemented the way the wave +// scout established: the secondary rail is NOT a shell concept — each surface +// owns its own. So this renders a sibling of `.cg-views` built from the same +// `--lp-rail-w` tokens and the same fold behaviour, and the Views rail is +// untouched. +// --------------------------------------------------------------------------- +import type { KeyboardEvent as ReactKeyboardEvent } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; + +import AutomationEditor from "./AutomationEditor"; +import type { Automation, AutomationList } from "./automationApi"; +import { + AutomationError, + listAutomations, + patchAutomation, + stateOf, +} from "./automationApi"; + +/** The status dot's title — the rail says WHY it is that colour, not just that it is. */ +function stateTitle(a: Automation): string { + const s = stateOf(a); + if (s === "running") return "Running now"; + if (s === "ok") return `Last run succeeded — ${a.status?.lastSummary || ""}`; + if (s === "partial") return `Last run was partial — ${a.status?.lastSummary || ""}`; + if (s === "error") return `Last run failed — ${a.status?.lastSummary || ""}`; + return "Has not run yet"; +} + +/** + * The rail's second line — ONE fact, not two. + * + * ⚠ It carried "Next 2026-08-04 06:00 · last 2026-08-04 00:20", and the rail is `--lp-rail-w` + * wide, so it rendered as "Next 2026-08-04 06:00 · l…" — a second line whose only complete word + * was "Next". Two facts that both truncate are worth less than one that fits. The forward-looking + * one wins when a schedule exists (it is the question the rail answers: does this run itself?), + * the last run otherwise. The full picture is one click away in the editor's run history, and the + * row's `title` already says both. + * + * Caught by READING the screenshot: the DOM was correct and the CSS ellipsis was doing exactly + * its job. [[ui-invisible-to-assertions]] — judge the pixels even when everything is green. + */ +function railSubtitle(a: Automation): string { + if (a.schedule?.enabled) return a.nextRunAt ? `Next ${a.nextRunAt}` : "Scheduled"; + const last = a.status?.lastRunAt ? a.status.lastRunAt.replace("T", " ").slice(0, 16) : ""; + return last ? `Last run ${last}` : "Manual only"; +} + +export default function AutomationSurface() { + const [data, setData] = useState(null); + const [error, setError] = useState(""); + const [activeId, setActiveId] = useState(""); + const [creating, setCreating] = useState(false); + const [railShut, setRailShut] = useState(false); + const [busy, setBusy] = useState(""); + const listRef = useRef(null); + + const load = useCallback(async (abort?: AbortSignal) => { + try { + const next = await listAutomations(abort); + setData(next); + setError(""); + return next; + } catch (e) { + if ((e as Error)?.name === "AbortError") return null; + setError( + e instanceof AutomationError + ? e.message + : "The automation service did not answer." + ); + return null; + } + }, []); + + useEffect(() => { + const ac = new AbortController(); + void load(ac.signal); + return () => ac.abort(); + }, [load]); + + // A run is a background thread on the server, so the surface has to ASK whether it + // finished. Polling only while something is actually running keeps an idle surface + // silent — a fixed interval would be a request every few seconds forever, for a page + // whose contents change a handful of times a day. + const anyRunning = (data?.automations || []).some((a) => a.running); + useEffect(() => { + if (!anyRunning) return undefined; + const t = window.setInterval(() => void load(), 2500); + return () => window.clearInterval(t); + }, [anyRunning, load]); + + const items = data?.automations || []; + const active = items.find((a) => a.id === activeId) || null; + + const toggleEnabled = async (a: Automation) => { + setBusy(a.id); + try { + await patchAutomation(a.id, { + schedule: { cron: a.schedule.cron, enabled: !a.schedule.enabled }, + }); + await load(); + } catch (e) { + setError(e instanceof AutomationError ? e.message : "That change was not saved."); + } finally { + setBusy(""); + } + }; + + const onRailKey = (event: ReactKeyboardEvent) => { + if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return; + const rows = Array.from( + listRef.current?.querySelectorAll(".auto-row-main") || [] + ); + if (!rows.length) return; + event.preventDefault(); + const at = rows.indexOf(document.activeElement as HTMLButtonElement); + const next = event.key === "ArrowDown" ? (at + 1) % rows.length + : (at - 1 + rows.length) % rows.length; + rows[next < 0 ? 0 : next]?.focus(); + }; + + return ( +
+ + +
+ {error ? ( +
+ {error} +
+ ) : null} + {data && !data.storeAvailable ? ( +
+ The tenant store is unavailable, so nothing can be saved right now. +
+ ) : null} + + {creating || active ? ( + { + setCreating(false); + const next = await load(); + if (id && next) setActiveId(id); + }} + onDeleted={async () => { + setActiveId(""); + setCreating(false); + await load(); + }} + onCancel={() => setCreating(false)} + /> + ) : ( +
+

Automations

+

+ An automation is a job this workspace runs for you — on demand, or on a + schedule. Pick one on the left, or create a new one. +

+
    +
  • + Web page to database. Read a public page, map its columns + to fields, and keep a database in step with it. Re-runs update matched rows + by key and insert new ones; a row that stops appearing is counted and kept, + never deleted. +
  • +
  • + Instagram profile column. For every record carrying a + public profile URL, read what is anonymously available and write the result + into an automation column, with each pull timestamped so the history is + filterable by date. +
  • +
+
+ )} +
+
+ ); +} diff --git a/web/src/automation/automationApi.ts b/web/src/automation/automationApi.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0d6a1c42182e5565dfe286513f4fd9c01b1d584 --- /dev/null +++ b/web/src/automation/automationApi.ts @@ -0,0 +1,208 @@ +// --------------------------------------------------------------------------- +// automation/automationApi.ts — the Automation surface's whole data layer. +// +// Wave-18 item 5 (contracts C4-AUTO + C-AUTONAV). Deliberately its own leaf +// rather than an addition to `customer-grid/apiBridge.ts`: the grid tree is the +// ASSET that also ships inside the Streamlit embed, and an automation surface +// that only the standalone shell mounts must not grow an edge into it. It +// imports `apiContract` (the shared leaf both trees already read) and nothing +// else. +// +// ⚠ EVERY VOCABULARY HERE COMES FROM THE SERVER. The kind list and the cron +// presets ride on `GET /automations` rather than sitting in a client constant, +// because the parser that accepts a cron string lives in Python — a client copy +// of the preset list is a list that can offer a schedule the server rejects, +// and the user would see the refusal as "it just doesn't save". +// --------------------------------------------------------------------------- +import { API_V1, CREDENTIALS, UNAUTHORIZED_EVENT, signal } from "../apiContract"; + +export type AutomationKind = "scrape_db" | "field_instagram"; +export type RunState = "idle" | "running" | "ok" | "error" | "partial"; + +export interface RunEntry { + ts: string; + ok: boolean; + summary: string; + counts: Record; + affected?: string[]; +} + +export interface Automation { + id: string; + name: string; + kind: AutomationKind; + config: Record; + schedule: { cron: string; enabled: boolean; enabledAt?: string }; + status: { state: RunState; lastRunAt?: string; lastSummary?: string; step?: string }; + runs: RunEntry[]; + created?: string; + createdBy?: string; + nextRunAt?: string; + running?: boolean; +} + +export interface AutomationList { + automations: Automation[]; + kinds: { key: AutomationKind; label: string }[]; + cronPresets: { cron: string; label: string }[]; + storeAvailable: boolean; +} + +export interface UserTable { + key: string; + label: string; + source: string; + rowCount: number; + fields: { key: string; label: string; type: string; automation?: unknown }[]; +} + +export interface SourcePreview { + ok: boolean; + status: number; + url: string; + title?: string; + note?: string; + columns: string[]; + sample: Record[]; + rowCount: number; + tableCount?: number; +} + +export interface RunRows { + table: string; + label: string; + fields: { key: string; label: string }[]; + rows: Record[]; + truncated: boolean; +} + +export class AutomationError extends Error { + status: number; + + constructor(message: string, status: number) { + super(message); + this.name = "AutomationError"; + this.status = status; + } +} + +async function result(response: Response): Promise { + let body: unknown = null; + try { + body = await response.json(); + } catch { + // The status is still an honest answer; the message below says so. + } + if (response.status === 401) signal(UNAUTHORIZED_EVENT); + if (!response.ok) { + const shaped = body as { error?: { message?: string } } | null; + throw new AutomationError( + shaped?.error?.message || `The server answered ${response.status}.`, + response.status + ); + } + return body as T; +} + +function send(path: string, init?: RequestInit): Promise { + return fetch(`${API_V1}${path}`, { + credentials: CREDENTIALS, + headers: init?.body ? { "Content-Type": "application/json" } : undefined, + ...init, + }).then((r) => result(r)); +} + +export function listAutomations(abort?: AbortSignal): Promise { + return send("/automations", { signal: abort }); +} + +export function listTables(abort?: AbortSignal): Promise<{ tables: UserTable[] }> { + return send<{ tables: UserTable[] }>("/automations/tables", { signal: abort }); +} + +export function createAutomation(body: unknown): Promise<{ automation: Automation }> { + return send("/automations", { method: "POST", body: JSON.stringify(body) }); +} + +export function patchAutomation( + id: string, + body: unknown +): Promise<{ automation: Automation }> { + return send(`/automations/${encodeURIComponent(id)}`, { + method: "PATCH", + body: JSON.stringify(body), + }); +} + +export function deleteAutomation(id: string): Promise<{ deleted: string }> { + return send(`/automations/${encodeURIComponent(id)}`, { method: "DELETE" }); +} + +export function runAutomation(id: string): Promise<{ started: string }> { + return send(`/automations/${encodeURIComponent(id)}/run`, { method: "POST" }); +} + +export function getAutomation(id: string): Promise<{ automation: Automation }> { + return send(`/automations/${encodeURIComponent(id)}`); +} + +export function runRows(id: string): Promise { + return send(`/automations/${encodeURIComponent(id)}/rows`); +} + +export function previewSource( + url: string, + extract: string, + tableIndex: number +): Promise { + return send("/automations/preview", { + method: "POST", + body: JSON.stringify({ url, extract, tableIndex }), + }); +} + +/** + * A source column name → a storable field key. Mirrors the server's own + * normalisation (`clean_config`) so the key the UI shows is the key that gets + * stored — a preview that promised `gics_sector` and a store that wrote + * `gics__sector` would look like data loss. + */ +export function fieldKeyFor(column: string): string { + return (column || "") + .toLowerCase() + .replace(/[^a-z0-9_]+/g, "_") + .replace(/^_+|_+$/g, "") + .slice(0, 60); +} + +/** The state word a status dot / chip paints from. */ +export function stateOf(a: Automation): RunState { + return a.running ? "running" : (a.status?.state as RunState) || "idle"; +} + +/** + * A run's counts as ordered label/value pairs. The ORDER is the sentence the + * numbers make — new, updated, unchanged, then the ones that need explaining — + * and `orphans` is spelled out rather than abbreviated because a bare number + * next to the word "orphans" is the one count a user must not have to guess at. + */ +export const COUNT_LABELS: [string, string][] = [ + ["inserted", "New"], + ["updated", "Updated"], + ["unchanged", "Unchanged"], + ["orphans", "No longer on the page (kept)"], + ["duplicates", "Duplicate keys"], + ["skipped", "Skipped"], + ["source_rows", "Rows read"], + ["profiles", "Profiles"], + ["ok", "Read in full"], + // ⚠ ADDED after reading the first live screenshot. The engine counts `partial` separately + // (profile read, media not anonymously readable) but this table did not, so a run whose + // summary said "1/1 profiles read" showed a chip row reading "0 Read" — the chips + // contradicting the sentence directly above them. A count the summary names must have a chip. + ["partial", "Profile only"], + ["blocked", "Blocked"], + ["error", "Errors"], + ["posts", "Posts"], + ["new_posts", "New posts"], +]; diff --git a/web/src/customer-grid/CatalogView.tsx b/web/src/customer-grid/CatalogView.tsx new file mode 100644 index 0000000000000000000000000000000000000000..e6b701ec0d08d9abf86ba461db6937c4a837fc56 --- /dev/null +++ b/web/src/customer-grid/CatalogView.tsx @@ -0,0 +1,1147 @@ +// --------------------------------------------------------------------------- +// customer-grid / CatalogView.tsx +// Wave-18 owner item 4 (contract C6-CATALOG) — the CATALOG view. +// +// A view holds several catalogs; a catalog is an ordered list of pages; a +// section page names product CODES and joins them to the live pool at paint +// time. Three columns: the rail (catalogs, then that catalog's pages), the +// stage (the pages themselves, at true paper size, scaled to fit), and the +// inspector (everything about the selected page, plus the catalog's brand, +// paper and column bindings). +// +// FIDELITY. The default templates reproduce `Royal Collection 2027.pdf`, which +// was rendered and read before this file was written: +// · section header — letterspaced caps, navy, light weight, top-left +// · product renders on WHITE (the C2-ASSET web derivative is alpha-preserving +// PNG precisely so this works) +// · description in caps, centred, two lines +// · a full-width navy PILL carrying the pack line +// · SKU in terracotta bold on the left, colour name on the right +// · a full-bleed lifestyle strip under the grid +// · crown mark bottom-left, folio bottom-right +// · gallery pages full-bleed with a letterspaced caps title +// +// TYPE. Catalog pages use a display SERIF for titles (`--cat-serif`, a system +// Didone/old-style stack — Didot, Bodoni, Playfair, Cormorant, Georgia). That is +// deliberate and it is the ONLY place it appears: app chrome stays Inter, per +// the owner constant. Listing text is Inter with wide tracking, which is what +// the reference's geometric sans reads as at listing size. NO EMOJIS anywhere — +// every mark here is a drawn path. +// --------------------------------------------------------------------------- + +import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"; +import { createPortal } from "react-dom"; +import { + CATALOG_COLS, + CATALOG_NAME_MAX, + CATALOG_ORIENTATIONS, + CATALOG_PAGE_KINDS, + CATALOG_PAPERS, + MAX_CATALOGS, + MAX_CATALOG_PAGES, + MAX_CATALOG_CODES, +} from "./types"; +import type { + CatalogOrientation, + CatalogPage, + CatalogPageKind, + CatalogPaper, + CatalogQuality, + CatalogSpec, + Field, + Row, +} from "./types"; +import { + CATALOG_CODE_FIELD, + DEFAULT_BRAND, + PAGE_KIND_LABELS, + PAPER_LABELS, + addCodes, + assetUrl, + autoBind, + codesUsed, + fetchAssetCodes, + indexByCode, + newCatalog, + newPage, + pageBox, + resolveItems, + sectionLayout, +} from "./catalogData"; +import type { CatalogItem } from "./catalogData"; +import { applyPrintCss, awaitImages, printOnce } from "./catalogPrint"; +import { formatDisplay } from "./display"; + +// ------------------------------------------------------------------- marks + +const STROKE = { + stroke: "currentColor", + strokeWidth: 1.5, + strokeLinecap: "round" as const, + strokeLinejoin: "round" as const, + fill: "none", +}; + +function IconPlus() { + return ( + + + + ); +} +function IconTrash() { + return ( + + + + ); +} +function IconUp() { + return ( + + + + ); +} +function IconDown() { + return ( + + + + ); +} +function IconPrint() { + return ( + + + + + + ); +} + +/** + * The Royal crown-diamond mark, drawn as paths. + * + * A row of three diamond outlines over a solid bar — the silhouette the 2027 + * catalogue carries on its cover, its footers and its back page. Drawn rather + * than uploaded because a catalog has to print the mark at whatever size the + * page gives it, and because an image dependency for the ONE element on every + * page would make an unreachable asset route into a blank catalogue. + */ +function CrownMark({ className }: { className?: string }) { + return ( + + + + + + + + + ); +} + +// ------------------------------------------------------------ page templates + +/** The image slot every template shares: the asset, or a STATED gap. + * + * A missing master is drawn as a labelled frame naming the code, never as + * silence — the user has to be able to see, in the designer, that this page + * will print an empty box, and which SKU caused it. */ +function Shot({ + code, + quality, + missing, + cover, +}: { + code?: string; + quality: CatalogQuality; + missing?: boolean; + cover?: boolean; +}) { + if (!code) + return ( +
+ No image +
+ ); + if (missing) + return ( +
+ No master for {code} +
+ ); + return ( +
+ +
+ ); +} + +function ProductCard({ + item, + quality, + layout, + hasAsset, +}: { + item: CatalogItem; + quality: CatalogQuality; + layout: ReturnType; + hasAsset: (code: string) => boolean | null; +}) { + const known = hasAsset(item.code); + return ( +
+ + {/* CAPS in CSS (`text-transform`), never by upper-casing the string: the + value stays the value, so a copy of it is not shouting. */} +
{item.name ?? (item.known ? "" : "Not in this table")}
+ {layout.showPack && item.pack ?
{item.pack}
: null} +
+ {item.code} + {layout.showColor && item.color ? ( + {item.color} + ) : null} +
+ {layout.showPrice && item.price ?
{item.price}
: null} +
+ ); +} + +/** Crown mark left, folio right — exactly the reference's footer, which carries no + * company line (the wordmark's place is the cover). `light` inverts it for the + * pages whose field is dark. + * + * `mark={false}` drops the crown: the intro page's terracotta lattice bleeds through the + * bottom-left corner, and a second terracotta mark sitting inside it reads as a smudge on the + * lattice rather than as the brand. The reference's own letter spread carries no crown there + * either — judged from the rendered page, not assumed. */ +function PageFooter({ + folio, + light, + mark = true, +}: { + folio: number; + light?: boolean; + mark?: boolean; +}) { + return ( +
+ {mark ? : null} + {folio} +
+ ); +} + +/** ONE page, at true paper size. The same component paints the stage and the + * print tree — there is no second renderer that could drift from what the + * screenshot showed. */ +const CatalogPageView = memo(function CatalogPageView({ + cat, + page, + index, + items, + quality, + hasAsset, +}: { + cat: CatalogSpec; + page: CatalogPage; + index: number; + items: CatalogItem[]; + quality: CatalogQuality; + hasAsset: (code: string) => boolean | null; +}) { + const box = pageBox(cat.paper, cat.orientation); + const px = box.unit === "in" ? 96 : 96 / 25.4; + const brand = cat.brand ?? {}; + const primary = brand.primary ?? DEFAULT_BRAND.primary; + const accent = brand.accent ?? DEFAULT_BRAND.accent; + const company = brand.company ?? DEFAULT_BRAND.company; + const style = { + "--cat-w": `${box.w * px}px`, + "--cat-h": `${box.h * px}px`, + "--cat-primary": primary, + "--cat-accent": accent, + } as React.CSSProperties; + const folio = index + 1; + const logoKnown = brand.logo ? hasAsset(brand.logo) : null; + + const Wordmark = ( +
+ {brand.logo && logoKnown !== false ? ( + + ) : ( + + )} + {company} +
+ ); + + if (page.kind === "cover") { + const known = page.imageCode ? hasAsset(page.imageCode) : null; + return ( +
+ +
+ {Wordmark} +
+ {page.title} + {page.body ? {page.body} : null} +
+
+ ); + } + + if (page.kind === "intro") { + return ( +
+
+ {/* The terracotta lattice bleeding off the left edge — the reference's + own device for the letter spread, drawn from the crown's diamond. */} + + + + + + + +
+
+

{page.title}

+ {/* Paragraphs, not a wall: the reference's letter is set in short + blocks and reads as one because of the spacing between them. */} + {(page.body ?? "").split(/\n{2,}/).map((para, i) => + para.trim() ? ( +

+ {para.trim()} +

+ ) : null + )} +
The {company} Team
+
+ +
+ ); + } + + if (page.kind === "gallery") { + const known = page.imageCode ? hasAsset(page.imageCode) : null; + return ( +
+ +
+ {page.title ?
{page.title}
: null} + +
+ ); + } + + const layout = sectionLayout(page); + const stripKnown = page.imageCode ? hasAsset(page.imageCode) : null; + return ( +
+

{page.title}

+
+ {items.map((item) => ( + + ))} +
+ {page.imageCode ? ( +
+ +
+ ) : null} + +
+ ); +}); + +// ------------------------------------------------------------------- stage + +function CatalogPages({ + cat, + itemsFor, + quality, + hasAsset, + scale, + selectedId, + onSelect, +}: { + cat: CatalogSpec; + itemsFor: (page: CatalogPage) => CatalogItem[]; + quality: CatalogQuality; + hasAsset: (code: string) => boolean | null; + /** Absent = paint at true size (the PRINT tree). */ + scale?: number; + selectedId?: string; + onSelect?: (id: string) => void; +}) { + const box = pageBox(cat.paper, cat.orientation); + const px = box.unit === "in" ? 96 : 96 / 25.4; + return ( + <> + {cat.pages.map((page, i) => { + const body = ( + + ); + if (scale === undefined) return
{body}
; + return ( +
onSelect?.(page.id)} + > + {body} +
+ ); + })} + + ); +} + +// ------------------------------------------------------------------- view + +export const CatalogView = memo(function CatalogView({ + catalogs, + onCatalogs, + fields, + fieldByKey, + poolRows, + filteredCodes, +}: { + catalogs: CatalogSpec[]; + onCatalogs: (next: CatalogSpec[]) => void; + fields: Field[]; + fieldByKey: Map; + /** The WHOLE pool — a catalogue keeps painting what it names after the view + * is filtered, so the join must not run over the filtered rows. */ + poolRows: Row[]; + /** The codes the CURRENT filter kept — the "add what the view shows" door. */ + filteredCodes: string[]; +}) { + const [openId, setOpenId] = useState(catalogs[0]?.id ?? null); + const [pageId, setPageId] = useState(null); + const [search, setSearch] = useState(""); + const [picked, setPicked] = useState>(() => new Set()); + const [assetCodes, setAssetCodes] = useState | null>(null); + const [printing, setPrinting] = useState<{ cat: CatalogSpec; quality: CatalogQuality } | null>( + null + ); + const [askQuality, setAskQuality] = useState(null); + const stageRef = useRef(null); + const printRef = useRef(null); + const [stageW, setStageW] = useState(0); + + const cat = catalogs.find((c) => c.id === openId) ?? null; + const page = cat?.pages.find((p) => p.id === pageId) ?? null; + + // The manifest, once. `null` means "we do not know" and the designer stays + // quiet — a false gap report sends the user hunting for images that are there. + useEffect(() => { + let live = true; + void fetchAssetCodes().then((codes) => { + if (live) setAssetCodes(codes); + }); + return () => { + live = false; + }; + }, []); + + const hasAsset = useCallback( + (code: string): boolean | null => (assetCodes ? assetCodes.has(code) : null), + [assetCodes] + ); + + useLayoutEffect(() => { + const el = stageRef.current; + if (!el || typeof ResizeObserver === "undefined") return; + const ro = new ResizeObserver(() => setStageW(el.clientWidth)); + ro.observe(el); + setStageW(el.clientWidth); + return () => ro.disconnect(); + }, []); + + const byCode = useMemo(() => indexByCode(poolRows), [poolRows]); + const itemsFor = useCallback( + (p: CatalogPage) => + resolveItems(p.products ?? [], byCode, cat?.fields, formatDisplay, fieldByKey), + [byCode, cat?.fields, fieldByKey] + ); + + const scale = useMemo(() => { + if (!cat || !stageW) return 0.5; + const box = pageBox(cat.paper, cat.orientation); + const px = box.unit === "in" ? 96 : 96 / 25.4; + return Math.min(1, Math.max(0.2, (stageW - 56) / (box.w * px))); + }, [cat, stageW]); + + // ------------------------------------------------------------- mutation + const write = useCallback( + (next: CatalogSpec[]) => { + onCatalogs(next); + }, + [onCatalogs] + ); + const patchCat = useCallback( + (id: string, patch: Partial) => { + write(catalogs.map((c) => (c.id === id ? { ...c, ...patch } : c))); + }, + [catalogs, write] + ); + const patchPage = useCallback( + (catId: string, pgId: string, patch: Partial) => { + write( + catalogs.map((c) => + c.id !== catId + ? c + : { ...c, pages: c.pages.map((p) => (p.id === pgId ? { ...p, ...patch } : p)) } + ) + ); + }, + [catalogs, write] + ); + + const addCatalog = () => { + if (catalogs.length >= MAX_CATALOGS) return; + const made = newCatalog(`Catalog ${catalogs.length + 1}`, fields); + write([...catalogs, made]); + setOpenId(made.id); + setPageId(made.pages[0]?.id ?? null); + }; + + const addPage = (kind: CatalogPageKind) => { + if (!cat || cat.pages.length >= MAX_CATALOG_PAGES) return; + const made = newPage(kind); + patchCat(cat.id, { pages: [...cat.pages, made] }); + setPageId(made.id); + }; + + const movePage = (delta: number) => { + if (!cat || !page) return; + const i = cat.pages.findIndex((p) => p.id === page.id); + const j = i + delta; + if (i < 0 || j < 0 || j >= cat.pages.length) return; + const pages = [...cat.pages]; + [pages[i], pages[j]] = [pages[j], pages[i]]; + patchCat(cat.id, { pages }); + }; + + // ------------------------------------------------------------ the picker + const matches = useMemo(() => { + if (!cat) return []; + const q = search.trim().toLowerCase(); + const nameKey = cat.fields?.name; + const out: { code: string; label: string }[] = []; + for (const r of poolRows) { + const code = r[CATALOG_CODE_FIELD]; + if (typeof code !== "string" || !code) continue; + const nameField = nameKey ? fieldByKey.get(nameKey) : undefined; + const label = nameField ? formatDisplay(nameField, r[nameKey as string]) : ""; + if (q && !code.toLowerCase().includes(q) && !label.toLowerCase().includes(q)) continue; + out.push({ code, label }); + if (out.length >= 200) break; + } + return out; + }, [cat, poolRows, search, fieldByKey]); + + const commitCodes = (codes: string[]) => { + if (!cat || !page) return; + const res = addCodes(cat, page.id, codes); + patchCat(cat.id, { pages: res.pages }); + setPicked(new Set()); + if (res.skippedCap || res.skippedDuplicate) { + const parts: string[] = []; + if (res.skippedDuplicate) parts.push(`${res.skippedDuplicate} already on the page`); + if (res.skippedCap) + parts.push(`${res.skippedCap} over the ${MAX_CATALOG_CODES}-product catalog limit`); + setNote(`Added ${res.added}. Skipped ${parts.join("; ")}.`); + } else { + setNote(`Added ${res.added}.`); + } + }; + const [note, setNote] = useState(""); + + // ------------------------------------------------------------- printing + useEffect(() => { + if (!printing) return; + let cancelled = false; + void (async () => { + // One frame so the print tree is in the DOM before its images are awaited. + await new Promise((res) => requestAnimationFrame(() => res())); + await awaitImages(printRef.current); + if (cancelled) return; + const drop = applyPrintCss(printing.cat); + await printOnce(); + drop(); + if (!cancelled) setPrinting(null); + })(); + return () => { + cancelled = true; + }; + }, [printing]); + + // ----------------------------------------------------------------- paint + if (!catalogs.length) + return ( +
+
+ +

No catalogs yet

+

+ A catalog is a printable document built from this table’s products — cover, + introduction, product sections and full-page images. Print it to PDF from the browser + when it is ready. +

+ +
+
+ ); + + const used = cat ? codesUsed(cat) : 0; + + return ( +
+ {/* ------------------------------------------------------------ rail */} + + + {/* ----------------------------------------------------------- stage */} +
+ {cat ? ( + <> +
+ patchCat(cat.id, { name: e.target.value })} + /> + + + + {used}/{MAX_CATALOG_CODES} products + + +
+
+ +
+ + ) : ( +
Pick a catalog to open it.
+ )} +
+ + {/* ------------------------------------------------------- inspector */} +