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(`${nc(e.formatted)} `):e.format===`string-array`?t.push(`${e.formatted.map((t,n)=>`- `+nc(t)+`
`).join(``)}
`):t.push(`${nc(e.formatted)} `)}t.push(` `)}return t.push(`
`),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(`${rc(e.formatted)} `):e.format===`string-array`?t.push(`${e.formatted.map((t,n)=>`- `+rc(t)+`
`).join(``)}
`):t.push(`${rc(e.formatted)} `)}t.push(` `)}return t.push(`
`),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})=>``}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})=>``}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;++r